query
stringlengths
10
3.85k
ru_query
stringlengths
9
3.76k
document
stringlengths
17
430k
metadata
dict
negatives
listlengths
97
100
negative_scores
listlengths
97
100
document_score
stringlengths
5
10
document_rank
stringclasses
2 values
Stop sends a shutdown signal to the polling goroutine to return
Stop отправляет сигнал о завершении вирутальному го-рутине для возврата
func (p *Poller) Stop() { wg := &sync.WaitGroup{} wg.Add(1) p.Shutdown <- wg wg.Wait() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (rcsw *RemoteClusterServiceWatcher) Stop(cleanupState bool) {\n\trcsw.probeEventsSink.send(&ClusterNotRegistered{\n\t\tclusterName: rcsw.clusterName,\n\t})\n\tclose(rcsw.stopper)\n\tif cleanupState {\n\t\trcsw.eventsQueue.Add(&ClusterUnregistered{})\n\t}\n\trcsw.eventsQueue.ShutDown()\n}", "func (w *UnbondingWatcher) Stop() {\n\tclose(w.quit)\n}", "func (m *Mainloop) Stop() {\n\tgo func() { m.termchan <- 1 }()\n\treturn\n}", "func (p *Poller) Stop() {\n\tp.stopMutex.Lock()\n\tdefer p.stopMutex.Unlock()\n\n\tp.isStopped = true\n\tclose(p.Channel)\n}", "func (m *WebsocketRoutineManager) Stop() error {\n\tif m == nil {\n\t\treturn fmt.Errorf(\"websocket routine manager %w\", ErrNilSubsystem)\n\t}\n\n\tm.mu.Lock()\n\tif atomic.LoadInt32(&m.state) == stoppedState {\n\t\tm.mu.Unlock()\n\t\treturn fmt.Errorf(\"websocket routine manager %w\", ErrSubSystemNotStarted)\n\t}\n\tatomic.StoreInt32(&m.state, stoppedState)\n\tm.mu.Unlock()\n\n\tclose(m.shutdown)\n\tm.wg.Wait()\n\n\treturn nil\n}", "func Stop() {\n\tquit <- true\n\tfor id, socket := range sockets {\n\t\tfmt.Printf(\"Closing socket %s\\n\", id)\n\t\tsocket.Close()\n\t\tpoller.RemoveBySocket(socket)\n\t}\n\tzctx.Term()\n}", "func (w *Watcher) Stop() {\n\tw.StopChannel <- true\n}", "func Stop() {\n\tstopRunning <- true\n\n}", "func (hb *heartbeat) stop() {\n\tselect {\n\tcase hb.stopChan <- struct{}{}:\n\tdefault:\n\t}\n}", "func (brw *blockRetrievalWorker) Shutdown() {\n\tselect {\n\tcase <-brw.stopCh:\n\tdefault:\n\t\tclose(brw.stopCh)\n\t}\n}", "func (w *WatchManager) Stop() {\n\tlog.Println(\"Stopping Watcher...\")\n\tclose(w.stopChannel)\n\tw.RunWaitGroup.Done()\n}", "func Stop() {\n\t// /bin/dbus-send --system --dest=org.ganesha.nfsd --type=method_call /org/ganesha/nfsd/admin org.ganesha.nfsd.admin.shutdown\n}", "func (w *Worker) Stop() {\n\tgo func() {\n\t\tw.QuitChan <- true\n\t}()\n}", "func (w *Worker) Stop() {\n\tgo func() {\n\t\tw.QuitChan <- true\n\t}()\n}", "func (w *Worker) Stop() {\n\tgo func() {\n\t\tw.QuitChan <- true\n\t}()\n}", "func (w *Worker) Stop() {\n\tgo func() {\n\t\tw.QuitChan <- true\n\t}()\n}", "func (w *Worker) Stop() {\n\tgo func() {\n\t\tw.QuitChan <- true\n\t}()\n}", "func (w *Worker) Stop() {\n\tgo func() {\n\t\tw.QuitChan <- true\n\t}()\n}", "func (d *Driver) Stop() error {\n\tif err := d.verifyRootPermissions(); err != nil {\n\t\treturn err\n\t}\n\n\ts, err := d.GetState()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif s != state.Stopped {\n\t\terr := d.sendSignal(syscall.SIGTERM)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"hyperkit sigterm failed\")\n\t\t}\n\t\t// wait 120s for graceful shutdown\n\t\tfor i := 0; i < 60; i++ {\n\t\t\ttime.Sleep(2 * time.Second)\n\t\t\ts, _ := d.GetState()\n\t\t\tlog.Debugf(\"VM state: %s\", s)\n\t\t\tif s == state.Stopped {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\treturn errors.New(\"VM Failed to gracefully shutdown, try the kill command\")\n\t}\n\treturn nil\n}", "func (bt *BackTest) Stop() {\n\tclose(bt.shutdown)\n}", "func (u *utxoNursery) Stop() error {\n\tif !atomic.CompareAndSwapUint32(&u.stopped, 0, 1) {\n\t\treturn nil\n\t}\n\n\tutxnLog.Infof(\"UTXO nursery shutting down\")\n\n\tclose(u.quit)\n\tu.wg.Wait()\n\n\treturn nil\n}", "func (w *IndexPoller) Stop() {\n\tdefer close(w.controlChannel)\n\tw.controlChannel <- true\n}", "func Stop() {\n\tExitChannel <- true\n}", "func (w *Worker) Stop() {\n go func() {\n w.QuitChan <- true\n }()\n}", "func (s *SlaveHealthChecker) Stop() {\n\tclose(s.stop)\n}", "func (w *Watcher) Stop() {\n\tw.stopChan <- struct{}{}\n}", "func (w Worker) Stop() {\n\tgo func() {\n\t\tw.QuitChan <- true\n\t}()\n}", "func (p *ProbeHandler) Stop() {\n\tp.quit <- struct{}{}\n}", "func (management *Management) Stop() {\n\tlog.Info(management.logPrefix, \"Shutdown\")\n\tmanagement.closesOnce.Do(func() {\n\t\tclose(management.shutdownStarted)\n\t})\n\n\tmanagement.shutdownWaiter.Wait()\n\n\tlog.Info(management.logPrefix, \"Shutdown finished\")\n}", "func (lp *LongPoll) Shutdown() {\n\tif lp.cancel != nil {\n\t\tlp.cancel()\n\t}\n}", "func Stop() {\n\tclose(shutdownChannel)\n\tshutdownWaitGroup.Wait()\n\tlog4go.Info(\"Console shutdown complete\")\n}", "func (pool *SubPool) Stop() {\n\tpool.StopChan <- struct{}{}\n}", "func (pw *PurgeWorker) Stop() {\n\tpw.StopChan <- true\n}", "func (w *Worker) Stop() {\n\tgo func() {\n\t\tw.Quit <- true\n\t}()\n}", "func (b *BTCVanity) Stop() {\n\tb.stop <- true\n}", "func (b *BTCVanity) Stop() {\n\tb.stop <- true\n}", "func (w *Worker) Shutdown() {\n\tw.Stopped = true\n\tclose(w.stopChan)\n}", "func (w *worker) stop() {\n\tw.quitChan <- true\n}", "func (s *Streamer) Stop() error {\n\ts.mu.Lock()\n\tif s.state != stateRunning {\n\t\ts.mu.Unlock()\n\t\treturn ErrNotRunning\n\t}\n\ts.state = stateStopping\n\ts.mu.Unlock()\n\n\ts.fsNotify.Close() // trigger stop chain: fsNotify -> (sendChangeEvents,logNotifyErrors) -> eventsRouter\n\ts.threads.Wait()\n\n\ts.mu.Lock()\n\ts.state = stateStopped\n\ts.mu.Unlock()\n\n\treturn nil\n}", "func (c *Crawler) Stop() {\t\n\tch := make(chan bool)\n\tc.stopChan <- ch\n\n\t// Wait until it has stopped\n\t<- ch\n}", "func (sp *StreamPool) Stop() {\n\t//sw.quitCh <- true\n}", "func (h *handler) Stop(ctx context.Context) {\n\th.closeOnce.Do(func() {\n\t\th.startClosingTime = h.clock.Time()\n\n\t\t// Must hold the locks here to ensure there's no race condition in where\n\t\t// we check the value of [h.closing] after the call to [Signal].\n\t\th.syncMessageQueue.Shutdown()\n\t\th.asyncMessageQueue.Shutdown()\n\t\tclose(h.closingChan)\n\n\t\t// TODO: switch this to use a [context.Context] with a cancel function.\n\t\t//\n\t\t// Don't process any more bootstrap messages. If a dispatcher is\n\t\t// processing a bootstrap message, stop. We do this because if we\n\t\t// didn't, and the engine was in the middle of executing state\n\t\t// transitions during bootstrapping, we wouldn't be able to grab\n\t\t// [h.ctx.Lock] until the engine finished executing state transitions,\n\t\t// which may take a long time. As a result, the router would time out on\n\t\t// shutting down this chain.\n\t\tstate := h.ctx.State.Get()\n\t\tbootstrapper, ok := h.engineManager.Get(state.Type).Get(snow.Bootstrapping)\n\t\tif !ok {\n\t\t\th.ctx.Log.Error(\"bootstrapping engine doesn't exists\",\n\t\t\t\tzap.Stringer(\"type\", state.Type),\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\tbootstrapper.Halt(ctx)\n\t})\n}", "func (n *SQSNotify) Stop() {\n\tn.running = false\n\t_ = n.flushDeleteQueue0()\n}", "func (bt *Heartbeat) Stop() {\n\tclose(bt.done)\n}", "func (is *idleSweep) Stop() {\n\tif !is.started {\n\t\treturn\n\t}\n\n\tis.started = false\n\tis.ch.log.Info(\"Stopping idle connections poller.\")\n\tclose(is.stopCh)\n}", "func (sh *SignalHandler) Stop() {\n\tsh.lock.Lock()\n\tdefer sh.lock.Unlock()\n\n\tif sh.isRunning == true {\n\t\tsh.isRunning = false\n\t}\n}", "func (p *pollerAutoScaler) Stop() {\n\tp.cancel()\n\tp.wg.Wait()\n}", "func Stopping() error {\n\treturn SdNotify(\"STOPPING=1\")\n}", "func (s *T) Stop() {\n\tclose(s.stopCh)\n\ts.wg.Wait()\n}", "func (w *Worker) Stop() {\n\tgo func() {\n\t\tw.quit <- true\n\t}()\n}", "func (p *PollingListener) Shutdown() {\n\tclose(p.s)\n}", "func handleStop(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {\n\tselect {\n\tcase s.requestProcessShutdown <- struct{}{}:\n\tdefault:\n\t}\n\treturn \"kaspad stopping.\", nil\n}", "func (s *Service) Stop() {\n\tclose(s.stopChan)\n}", "func (w *Worker) Stop() {\n\tw.QuitChan <- true\n\t// fmt.Fprintln(os.Stderr, \"Worker got stop call\")\n}", "func (p *statusUpdate) Stop() {\n\tfor _, client := range p.eventClients {\n\t\tclient.Stop()\n\t}\n\tlog.Info(\"Task status updater stopped\")\n\tfor _, listener := range p.listeners {\n\t\tlistener.Stop()\n\t}\n\tp.applier.drainAndShutdown()\n}", "func (z *Zipkin) Stop() {\n\tctx, cancel := context.WithTimeout(context.Background(), defaultShutdownTimeout)\n\n\tdefer z.waitGroup.Wait()\n\tdefer cancel()\n\n\tz.server.Shutdown(ctx) //nolint:errcheck // Ignore the returned error as we cannot do anything about it anyway\n}", "func (w *Worker) Stop() {\n\tw.quit <- true\n}", "func (f *framework) stop() {\n\tclose(f.epochChan)\n}", "func (w Worker) Stop() {\n\tgo func() {\n\t\tw.quit <- true\n\t}()\n}", "func (w Worker) Stop() {\n\tgo func() {\n\t\tw.quit <- true\n\t}()\n}", "func (w Worker) Stop() {\n\tgo func() {\n\t\tw.quit <- true\n\t}()\n}", "func (w Worker) Stop() {\n\tgo func() {\n\t\tw.quit <- true\n\t}()\n}", "func (w Worker) Stop() {\n go func() {\n w.quit <- true\n }()\n}", "func (s *Server) Stop(ctx context.Context) {\n\ts.shutdownFuncsM.Lock()\n\tdefer s.shutdownFuncsM.Unlock()\n\ts.shutdownOnce.Do(func() {\n\t\tclose(s.shuttingDown)\n\t\t// Shut down the HTTP server in parallel to calling any custom shutdown functions\n\t\twg := sync.WaitGroup{}\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tif err := s.srv.Shutdown(ctx); err != nil {\n\t\t\t\tslog.Debug(ctx, \"Graceful shutdown failed; forcibly closing connections 👢\")\n\t\t\t\tif err := s.srv.Close(); err != nil {\n\t\t\t\t\tslog.Critical(ctx, \"Forceful shutdown failed, exiting 😱: %v\", err)\n\t\t\t\t\tpanic(err) // Something is super hosed here\n\t\t\t\t}\n\t\t\t}\n\t\t}()\n\t\tfor _, f := range s.shutdownFuncs {\n\t\t\tf := f // capture range variable\n\t\t\twg.Add(1)\n\t\t\tgo func() {\n\t\t\t\tdefer wg.Done()\n\t\t\t\tf(ctx)\n\t\t\t}()\n\t\t}\n\t\twg.Wait()\n\t})\n}", "func (m *MaintenanceScheduler) Stop() {\n\tm.schan <- true\n}", "func (s *SimpleServer) Stop() {\n\tif s != nil {\n\t\ts.shutdownReq <- true\n\t}\n}", "func (c *Concentrator) Stop() {\n\tclose(c.exit)\n\tc.exitWG.Wait()\n}", "func (w *Worker) Stop() {\n\tw.os.Do(func() {\n\t\tw.l.Info(\"astikit: stopping worker...\")\n\t\tw.cancel()\n\t\tw.wg.Done()\n\t})\n}", "func (eis *eventSocket) stop() error {\n\teis.log.Info(\"closing Chain IPC\")\n\terrs := wrappers.Errs{}\n\terrs.Add(eis.unregisterFn(), eis.socket.Close())\n\treturn errs.Err\n}", "func (k *Kinsumer) Stop() {\n\tk.stoprequest <- true\n\tk.mainWG.Wait()\n}", "func (api *API) Stop() error {\n\n\t// context: wait for 3 seconds\n\tctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)\n\tdefer cancel()\n\n\terr := api.srv.Shutdown(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (r *ring) Stop() {\n\tif !atomic.CompareAndSwapInt32(\n\t\t&r.status,\n\t\tcommon.DaemonStatusStarted,\n\t\tcommon.DaemonStatusStopped,\n\t) {\n\t\treturn\n\t}\n\n\tr.peerProvider.Stop()\n\tr.value.Store(emptyHashring())\n\n\tr.subscribers.Lock()\n\tdefer r.subscribers.Unlock()\n\tr.subscribers.keys = make(map[string]chan<- *ChangedEvent)\n\tclose(r.shutdownCh)\n\n\tif success := common.AwaitWaitGroup(&r.shutdownWG, time.Minute); !success {\n\t\tr.logger.Warn(\"service resolver timed out on shutdown.\")\n\t}\n}", "func (f5 *BigIP) Stop() error {\n\tf5.shutdown <- true\n\n\treturn nil\n}", "func (s *server) Stop() error {\n\t// Make sure this only happens once.\n\tif atomic.AddInt32(&s.shutdown, 1) != 1 {\n\t\tlogging.CPrint(logging.INFO, \"server is already in the process of shutting down\", logging.LogFormat{})\n\t\treturn nil\n\t}\n\n\ts.syncManager.Stop()\n\n\t// Signal the remaining goroutines to quit.\n\tclose(s.quit)\n\n\ts.wg.Done()\n\n\treturn nil\n}", "func (dw *DirWatcher) Stop() {\n\tdw.qrun <- false\n}", "func (w *Worker) Stop() {\n\tw.wQuit <- true\n}", "func (tkr *RandTicker) Stop() {\n\tclose(tkr.done)\n}", "func (hmr *receiver) Shutdown(ctx context.Context) error {\n\tclose(hmr.done)\n\treturn hmr.closeScrapers(ctx)\n}", "func (t *Ticker) Stop() {\n\tselect {\n\tcase t.stop <- struct{}{}:\n\tdefault:\n\t}\n}", "func (s *SignalMonitor) Stop() {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\n\tif s.isOn {\n\t\ts.isOn = false\n\t\ts.offc <- struct{}{}\n\t}\n}", "func (d *loadReporterDaemonImpl) Stop() {\n\tif !atomic.CompareAndSwapInt32(&d.started, 1, 0) {\n\t\treturn\n\t}\n\n\tclose(d.shutdownCh)\n\tif success := AwaitWaitGroup(&d.shutdownWG, time.Minute); !success {\n\t\td.logger.Warn(\"Timed out waiting to shutdown load reporter.\")\n\t}\n\n\td.logger.Info(\"Load reporter stopped.\")\n}", "func (m *ManagerImpl) Stop() error {\n\tif !m.lifecycle.BeginShutdown() {\n\t\treturn ErrNotRunning\n\t}\n\tm.statusTracker.NotifySSEShutdownExpected()\n\tm.withRefreshTokenLock(func() {\n\t\tif m.nextRefresh != nil {\n\t\t\tm.nextRefresh.Stop()\n\t\t}\n\t})\n\tm.StopWorkers()\n\tm.sseClient.StopStreaming()\n\tm.lifecycle.AwaitShutdownComplete()\n\treturn nil\n}", "func (c *ZKCluster) Stop() {\n\tif c.checkerdone != nil {\n\t\tclose(c.checkerdone)\n\t\tclose(c.updates)\n\t\tc.checkerdone = nil\n\t}\n}", "func (r *RoverDriver) Stop() {\n r.commands <- stop\n}", "func (a API) Stop(ctx context.Context) error {\n\treturn a.srv.Shutdown(ctx)\n}", "func (h *Harness) Stop() {\n\tfin := make(chan struct{})\n\tgo func() {\n\t\tdefer close(fin)\n\t\tif err := h.Client.Close(); err != nil {\n\t\t\th.t.Fatal(err)\n\t\t}\n\n\t\tif err := h.cmd.Process.Kill(); err != nil {\n\t\t\th.t.Fatal(err)\n\t\t}\n\n\t\tif err := os.Remove(h.configPath); err != nil {\n\t\t\th.t.Fatal(err)\n\t\t}\n\t}()\n\tselect {\n\tcase <-fin:\n\tcase <-time.After(h.StopTimeout):\n\t}\n}", "func (n *DcrdNotifier) Stop() error {\n\t// Already shutting down?\n\tif atomic.AddInt32(&n.stopped, 1) != 1 {\n\t\treturn nil\n\t}\n\n\t// Shutdown the rpc client, this gracefully disconnects from dcrd, and\n\t// cleans up all related resources.\n\tn.chainConn.Shutdown()\n\n\tclose(n.quit)\n\tn.wg.Wait()\n\n\tn.chainUpdates.Stop()\n\n\t// Notify all pending clients of our shutdown by closing the related\n\t// notification channels.\n\tfor _, epochClient := range n.blockEpochClients {\n\t\tclose(epochClient.cancelChan)\n\t\tepochClient.wg.Wait()\n\n\t\tclose(epochClient.epochChan)\n\t}\n\tn.txNotifier.TearDown()\n\n\treturn nil\n}", "func (e *Engine) Stop() {\n\tif atomic.CompareAndSwapInt32(&e.stopping, 0, 1) {\n\t\te.wg.Wait()\n\t\te.running = 0\n\t\te.stopping = 0\n\t}\n}", "func (lt *Logtailer) Stop() {\n\tclose(lt.shutdown)\n}", "func (srv *Server) StopNotify() <-chan struct{} {\n return srv.stopc\n}", "func (b *Backend) Stop() error {\n\tb.eventSock.Close()\n\tb.commandSock.Close()\n\n\tb.eventSockCancel()\n\tb.commandSockCancel()\n\n\treturn nil\n}", "func (t *Ticker) Stop() {\n\tt.Done <- struct{}{}\n}", "func (n *Node) stop() (err error) {\n\tif err = n.stateCheck(nodeRunning, nodeHealthChecking); err != nil {\n\t\treturn\n\t}\n\tn.setState(nodeShuttingDown)\n\tn.stopChan <- true\n\tn.expireTicker.Stop()\n\tclose(n.stopChan)\n\tlogDebug(\"[Node]\", \"(%v) shutting down.\", n)\n\tn.shutdown()\n\treturn\n}", "func (r *runtime) Stop() {\n\tr.logger.Info(\"stopping broker server...\")\n\tdefer r.cancel()\n\n\tr.Shutdown()\n\n\tif r.httpServer != nil {\n\t\tr.logger.Info(\"stopping http server...\")\n\t\tif err := r.httpServer.Close(r.ctx); err != nil {\n\t\t\tr.logger.Error(\"shutdown http server error\", logger.Error(err))\n\t\t} else {\n\t\t\tr.logger.Info(\"stopped http server successfully\")\n\t\t}\n\t}\n\n\t// close registry, deregister broker node from active list\n\tif r.registry != nil {\n\t\tr.logger.Info(\"closing discovery-registry...\")\n\t\tif err := r.registry.Deregister(r.node); err != nil {\n\t\t\tr.logger.Error(\"unregister broker node error\", logger.Error(err))\n\t\t}\n\t\tif err := r.registry.Close(); err != nil {\n\t\t\tr.logger.Error(\"unregister broker node error\", logger.Error(err))\n\t\t} else {\n\t\t\tr.logger.Info(\"closed discovery-registry successfully\")\n\t\t}\n\t}\n\n\tif r.master != nil {\n\t\tr.logger.Info(\"stopping master...\")\n\t\tr.master.Stop()\n\t}\n\n\tif r.stateMachineFactory != nil {\n\t\tr.stateMachineFactory.Stop()\n\t}\n\n\tif r.repo != nil {\n\t\tr.logger.Info(\"closing state repo...\")\n\t\tif err := r.repo.Close(); err != nil {\n\t\t\tr.logger.Error(\"close state repo error, when broker stop\", logger.Error(err))\n\t\t} else {\n\t\t\tr.logger.Info(\"closed state repo successfully\")\n\t\t}\n\t}\n\tif r.stateMgr != nil {\n\t\tr.stateMgr.Close()\n\t}\n\tif r.srv.channelManager != nil {\n\t\tr.logger.Info(\"closing write channel manager...\")\n\t\tr.srv.channelManager.Close()\n\t\tr.logger.Info(\"closed write channel successfully\")\n\t}\n\n\tif r.factory.connectionMgr != nil {\n\t\tif err := r.factory.connectionMgr.Close(); err != nil {\n\t\t\tr.logger.Error(\"close connection manager error, when broker stop\", logger.Error(err))\n\t\t} else {\n\t\t\tr.logger.Info(\"closed connection manager successfully\")\n\t\t}\n\t}\n\tr.logger.Info(\"close connections successfully\")\n\n\t// finally, shutdown rpc server\n\tif r.grpcServer != nil {\n\t\tr.logger.Info(\"stopping grpc server...\")\n\t\tr.grpcServer.Stop()\n\t\tr.logger.Info(\"stopped grpc server successfully\")\n\t}\n\n\tr.state = server.Terminated\n\tr.logger.Info(\"stopped broker server successfully\")\n}", "func (f *HTTPFeeder) Stop(stopChan chan bool) {\n\tif f.IsRunning {\n\t\tf.Server.Shutdown(context.TODO())\n\t}\n\tclose(stopChan)\n}", "func (w *wsEvents) Stop() error { return w.ws.Stop() }", "func (t *TCPTest) Stop() {\n\tt.exit<-struct{}{}\n}", "func (wsServer *WsServer) Stop() {\n\tif atomic.AddInt32(&wsServer.shutdown, 1) != 1 {\n\t\tLogger.log.Info(\"RPC server is already in the process of shutting down\")\n\t}\n\tLogger.log.Info(\"RPC server shutting down\")\n\tif wsServer.started != 0 {\n\t\twsServer.server.Close()\n\t}\n\tfor _, listen := range wsServer.config.HttpListenters {\n\t\tlisten.Close()\n\t}\n\tLogger.log.Warn(\"RPC server shutdown complete\")\n\twsServer.started = 0\n\twsServer.shutdown = 1\n}", "func (a *appsec) stop() {\n\ta.unregisterWAF()\n\ta.limiter.Stop()\n}", "func (w *worker) stop() {\n\tselect {\n\tcase w.stopCh <- struct{}{}:\n\tdefault: // Non-blocking.\n\t}\n}" ]
[ "0.7100459", "0.70205927", "0.69549215", "0.69389325", "0.69152033", "0.6909807", "0.6899172", "0.68864995", "0.6879378", "0.6826131", "0.6764922", "0.6750816", "0.67412126", "0.67412126", "0.67412126", "0.67412126", "0.67412126", "0.67412126", "0.6737912", "0.672382", "0.6704135", "0.6684673", "0.6676277", "0.6670724", "0.66676867", "0.6665554", "0.6663922", "0.66551757", "0.6623341", "0.66232324", "0.66222405", "0.66117454", "0.66031784", "0.66025573", "0.65995336", "0.65995336", "0.6594916", "0.6589645", "0.6582771", "0.6579329", "0.65666395", "0.65598315", "0.6559553", "0.6556075", "0.65534836", "0.65476596", "0.65435827", "0.65416014", "0.653483", "0.6531247", "0.6527875", "0.651898", "0.65171874", "0.6515303", "0.65085745", "0.65021634", "0.64956844", "0.64866644", "0.6480522", "0.6480522", "0.6480522", "0.6480522", "0.64761156", "0.64678836", "0.6464896", "0.6456774", "0.64556086", "0.6453572", "0.64515907", "0.64478856", "0.6447824", "0.6443389", "0.64420176", "0.6441434", "0.64399296", "0.6438904", "0.6436266", "0.643566", "0.64352477", "0.64349556", "0.642367", "0.64182574", "0.64153856", "0.64113283", "0.64104265", "0.64090365", "0.64053553", "0.64036644", "0.6401902", "0.6395193", "0.6395024", "0.6394285", "0.6393274", "0.63908595", "0.6384889", "0.6380325", "0.6372703", "0.6371762", "0.6371052", "0.6369634" ]
0.78706795
0
GetAndDelete retrieves a PendingFileshare from the repository and then deletes it.
GetAndDelete извлекает PendingFileshare из репозитория и затем удаляет его.
func (r *inMemoryFileshareRepository) GetAndDelete(key string) (PendingFileshare, bool) { r.Lock() defer r.Unlock() fileshare, ok := r.pendingFileshares[key] if !ok { return PendingFileshare{}, false } delete(r.pendingFileshares, key) return fileshare, true }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (am *AutogitManager) Delete(\n\tctx context.Context, dstTLF *libkbfs.TlfHandle, dstDir string,\n\trepo, branchName string) (doneCh <-chan struct{}, err error) {\n\tam.log.CDebugf(ctx, \"Autogit delete request for %s/%s:%s\",\n\t\tdstTLF.GetCanonicalPath(), dstDir, repo, branchName)\n\tdefer func() {\n\t\tam.deferLog.CDebugf(ctx, \"Delete request processed: %+v\", err)\n\t}()\n\n\treq := deleteReq{\n\t\tdstTLF, dstDir, repo, branchName, make(chan struct{}),\n\t}\n\n\tselect {\n\tcase am.deleteQueue.In() <- req:\n\tcase <-ctx.Done():\n\t\treturn nil, ctx.Err()\n\t}\n\treturn req.doneCh, nil\n}", "func (s *SharemeService) Delete(c *gae.Context, session *Session, key string) (ret Share) {\n\tstat := s.Stat(c, key)\n\tif stat.IsError() {\n\t\treturn stat\n\t}\n\n\terr := stat.Delete(c)\n\tif err != nil {\n\t\treturn *noShare(err)\n\t}\n\n\tc.HTTPContext.ReturnStatus = http.StatusOK\n\tsession.Delete(fmt.Sprintf(\"%s%s\", KeySessionPrefix, key))\n\tret = Share{Key: ret.Key, Expires: 0, Size: 0}\n\treturn\n}", "func (s *shares) Delete(shareID int) error {\n\t_, err := s.c.baseRequest(http.MethodDelete, routes.shares, nil, strconv.Itoa(shareID))\n\treturn err\n}", "func (vrfs *VRFShare) Delete(ctx context.Context) error {\n\treturn vrfs.GetEntityMetadata().GetStore().Delete(ctx, vrfs)\n}", "func RelationshipPendingDelete(w http.ResponseWriter, r *http.Request) {\n\taccessToken := auth.ParseApiKey(r, accessTokenKey, true)\n\tif !checkToken(accessToken, w) {\n\t\treturn\n\t}\n\n\tk := r.URL.Query().Get(\"key\")\n\tif k == \"\" {\n\t\tapi.Api.BuildMissingParameter(w)\n\t\treturn\n\t}\n\n\tout, err := managers.RelationshipPendingManagerDelete(k)\n\tif err != nil {\n\t\tlogger.Error(err.Error())\n\t\tapi.Api.BuildErrorResponse(http.StatusInternalServerError, \"failed to delete rel\", w)\n\t\treturn\n\t}\n\n\tapi.Api.BuildJsonResponse(true, \"rel deleted\", out, w)\n}", "func (fs *Stow) Delete(ctx context.Context, id string) (string, interface{}, error) {\n\tdg, close, err := dgraph.NewClient(ctx)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tdefer close()\n\n\ttx := dg.NewTxn()\n\tdefer dgraph.Discard(ctx, tx)\n\n\tfile, err := FindFileImpl(ctx, tx, id)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\tif file == nil {\n\t\treturn \"\", nil, fmt.Errorf(\"file not found: %s\", id)\n\t}\n\n\tlocation, err := stow.Dial(fs.kind, fs.config)\n\tif err != nil {\n\t\tlog.Errorf(\"stow.Dial fail: %v\", err)\n\t\treturn \"\", nil, err\n\t}\n\tdefer location.Close()\n\n\tcontainer, err := location.Container(fs.bucket)\n\tif err != nil {\n\t\tlog.Errorf(\"stow.GetContainer fail: %v\", err)\n\t\treturn \"\", nil, err\n\t}\n\n\terr = container.RemoveItem(file.Path)\n\tif err != nil {\n\t\tlog.Errorf(\"stow.Container.RemoveItem fail: %v\", err)\n\t\treturn id, nil, err\n\t}\n\n\tresp2, err := dgraph.DeleteNode(ctx, tx, file.ID)\n\tif err != nil {\n\t\treturn file.ID, nil, err\n\t}\n\n\treturn file.ID, resp2, nil\n}", "func (t *SimpleChaincode) delete(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tfmt.Println(\"- start delete transfer\")\n\n\ttype transferDeleteTransientInput struct {\n\t\tName string `json:\"name\"`\n\t}\n\n\tif len(args) != 0 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Private transfer name must be passed in transient map.\")\n\t}\n\n\ttransMap, err := stub.GetTransient()\n\tif err != nil {\n\t\treturn shim.Error(\"Error getting transient: \" + err.Error())\n\t}\n\n\tif _, ok := transMap[\"transfer_delete\"]; !ok {\n\t\treturn shim.Error(\"transfer_delete must be a key in the transient map\")\n\t}\n\n\tif len(transMap[\"transfer_delete\"]) == 0 {\n\t\treturn shim.Error(\"transfer_delete value in the transient map must be a non-empty JSON string\")\n\t}\n\n\tvar transferDeleteInput transferDeleteTransientInput\n\terr = json.Unmarshal(transMap[\"transfer_delete\"], &transferDeleteInput)\n\tif err != nil {\n\t\treturn shim.Error(\"Failed to decode JSON of: \" + string(transMap[\"transfer_delete\"]))\n\t}\n\n\tif len(transferDeleteInput.Name) == 0 {\n\t\treturn shim.Error(\"name field must be a non-empty string\")\n\t}\n\n\t// to maintain the authorization~name index, we need to read the transfer first and get its authorization\n\tvalAsbytes, err := stub.GetPrivateData(\"collectionFileTransfer\", transferDeleteInput.Name) //get the marble from chaincode state\n\tif err != nil {\n\t\treturn shim.Error(\"Failed to get state for \" + transferDeleteInput.Name)\n\t} else if valAsbytes == nil {\n\t\treturn shim.Error(\"Transfer does not exist: \" + transferDeleteInput.Name)\n\t}\n\n\tvar transferToDelete fileTransfer\n\terr = json.Unmarshal([]byte(valAsbytes), &transferToDelete)\n\tif err != nil {\n\t\treturn shim.Error(\"Failed to decode JSON of: \" + string(valAsbytes))\n\t}\n\n\t// delete the transfer from state\n\terr = stub.DelPrivateData(\"collectionFileTransfer\", transferDeleteInput.Name)\n\tif err != nil {\n\t\treturn shim.Error(\"Failed to delete state:\" + err.Error())\n\t}\n\n\t// Also delete the transfer from the authorization~name index\n\tindexName := \"authorization~name\"\n\tauthorizationNameIndexKey, err := stub.CreateCompositeKey(indexName, []string{transferToDelete.Authorization, transferToDelete.Name})\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\terr = stub.DelPrivateData(\"collectionFileTransfer\", authorizationNameIndexKey)\n\tif err != nil {\n\t\treturn shim.Error(\"Failed to delete state:\" + err.Error())\n\t}\n\n\t// Finally, delete private details of transfer\n\terr = stub.DelPrivateData(\"collectionFileTransferPrivateDetails\", transferDeleteInput.Name)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\n\treturn shim.Success(nil)\n}", "func (g *GistFile) Delete(id string) (*http.Response, error) {\n\turll := fmt.Sprintf(\"/gists/%s\", id)\n\treq, err := http.NewRequest(http.MethodDelete, urll, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp, err := auth.Session.Client.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn resp, nil\n}", "func (a *GoogleAuth) GetAndDelete(state string) bool {\n\ta.mu.Lock()\n\tdefer a.mu.Unlock()\n\n\t_, ok := a.states[state]\n\tif ok {\n\t\tdelete(a.states, state)\n\t\treturn true\n\t}\n\treturn false\n}", "func (s *gcBlobTaskStore) Delete(ctx context.Context, b *models.GCBlobTask) error {\n\tdefer metrics.InstrumentQuery(\"gc_blob_task_delete\")()\n\n\tq := \"DELETE FROM gc_blob_review_queue WHERE digest = decode($1, 'hex')\"\n\tdgst, err := NewDigest(b.Digest)\n\tif err != nil {\n\t\treturn err\n\t}\n\tres, err := s.db.ExecContext(ctx, q, dgst)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"deleting GC blob task: %w\", err)\n\t}\n\tcount, err := res.RowsAffected()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"deleting GC blob task: %w\", err)\n\t}\n\tif count == 0 {\n\t\treturn fmt.Errorf(\"GC blob task not found\")\n\t}\n\n\treturn nil\n}", "func (h Handler) makeDelete(v Injection) http.HandlerFunc {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tparams := mux.Vars(r)\n\t\tmtx.Lock()\n\t\t_, deleted := v.Share[params[\"id\"]]\n\t\tdelete(v.Share, params[\"id\"])\n\t\tmtx.Unlock()\n\t\tjson.NewEncoder(w).Encode(deleted)\n\t})\n}", "func (is *ObjectStorage) DeleteBlob(repo string, digest godigest.Digest) error {\n\tvar lockLatency time.Time\n\n\tif err := digest.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\tblobPath := is.BlobPath(repo, digest)\n\n\tis.Lock(&lockLatency)\n\tdefer is.Unlock(&lockLatency)\n\n\t_, err := is.store.Stat(context.Background(), blobPath)\n\tif err != nil {\n\t\tis.log.Error().Err(err).Str(\"blob\", blobPath).Msg(\"failed to stat blob\")\n\n\t\treturn zerr.ErrBlobNotFound\n\t}\n\n\t// first check if this blob is not currently in use\n\tif ok, _ := common.IsBlobReferenced(is, repo, digest, is.log); ok {\n\t\treturn zerr.ErrBlobReferenced\n\t}\n\n\tif fmt.Sprintf(\"%v\", is.cache) != fmt.Sprintf(\"%v\", nil) {\n\t\tdstRecord, err := is.cache.GetBlob(digest)\n\t\tif err != nil && !errors.Is(err, zerr.ErrCacheMiss) {\n\t\t\tis.log.Error().Err(err).Str(\"blobPath\", dstRecord).Msg(\"dedupe: unable to lookup blob record\")\n\n\t\t\treturn err\n\t\t}\n\n\t\t// remove cache entry and move blob contents to the next candidate if there is any\n\t\tif ok := is.cache.HasBlob(digest, blobPath); ok {\n\t\t\tif err := is.cache.DeleteBlob(digest, blobPath); err != nil {\n\t\t\t\tis.log.Error().Err(err).Str(\"digest\", digest.String()).Str(\"blobPath\", blobPath).\n\t\t\t\t\tMsg(\"unable to remove blob path from cache\")\n\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\t// if the deleted blob is one with content\n\t\tif dstRecord == blobPath {\n\t\t\t// get next candidate\n\t\t\tdstRecord, err := is.cache.GetBlob(digest)\n\t\t\tif err != nil && !errors.Is(err, zerr.ErrCacheMiss) {\n\t\t\t\tis.log.Error().Err(err).Str(\"blobPath\", dstRecord).Msg(\"dedupe: unable to lookup blob record\")\n\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// if we have a new candidate move the blob content to it\n\t\t\tif dstRecord != \"\" {\n\t\t\t\tif err := is.store.Move(context.Background(), blobPath, dstRecord); err != nil {\n\t\t\t\t\tis.log.Error().Err(err).Str(\"blobPath\", blobPath).Msg(\"unable to remove blob path\")\n\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}\n\n\tif err := is.store.Delete(context.Background(), blobPath); err != nil {\n\t\tis.log.Error().Err(err).Str(\"blobPath\", blobPath).Msg(\"unable to remove blob path\")\n\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (gc *GalleryContext) DeleteAndConfirm() uiauto.Action {\n\tdeleteButtonFinder := nodewith.Role(role.Button).Name(\"Delete\").Ancestor(RootFinder)\n\tconfirmButtonFinder := nodewith.Role(role.Button).Name(\"Delete\").Ancestor(DialogFinder)\n\treturn uiauto.Combine(\"remove current opened media file\",\n\t\tgc.ui.WithTimeout(30*time.Second).WithInterval(1*time.Second).LeftClickUntil(\n\t\t\tdeleteButtonFinder, gc.ui.WithTimeout(3*time.Second).WaitUntilExists(confirmButtonFinder)),\n\t\tgc.ui.LeftClick(confirmButtonFinder),\n\t)\n}", "func (m *Manager) Get(id string) *Transfer {\n\tm.mu.RLock()\n\tdefer m.mu.RUnlock()\n\n\treturn m.transfers[id]\n}", "func TestDelete(t *testing.T) {\n\tth.SetupHTTP()\n\tdefer th.TeardownHTTP()\n\n\tMockDeleteResponse(t)\n\tres := sharetypes.Delete(client.ServiceClient(), \"shareTypeID\")\n\tth.AssertNoErr(t, res.Err)\n}", "func (ss *redisStore) GetAndDelete(key string) (*storage.Secret, error) {\n\tbb, err := ss.rdb.GetDel(ctx, key).Bytes()\n\tif err == redis.Nil {\n\t\treturn nil, storage.ErrNoRecord\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar s storage.Secret\n\terr = json.Unmarshal(bb, &s)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &s, nil\n}", "func (s RPCService) Delete(ctx context.Context, req *IdRequest) (*Void, error) {\n\treturn &Void{}, s.storage.Delete(req.Id)\n}", "func (r *Remoter) Get(waitCtx context.Context, remote string, local string) error {\n\tclt, err := sftp.NewClient(r.clt)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_ = os.Remove(local)\n\trf, err := clt.Open(remote)\n\tif err != nil {\n\t\t_ = clt.Close()\n\t\treturn err\n\t}\n\twf, err := os.Create(local)\n\tif err != nil {\n\t\t_ = clt.Close()\n\t\t_ = rf.Close()\n\t\treturn err\n\t}\n\tnoWait, waitGrp := r.wait(waitCtx)\n\t_, err = io.Copy(wf, rf)\n\tclose(noWait)\n\twaitGrp.Wait()\n\t_ = wf.Close()\n\t_ = rf.Close()\n\t_ = clt.Close()\n\treturn err\n}", "func (s *SharemeService) Get(c *gae.Context, key string) interface{} { // Return either Share in case of Error or Binary.\n\tst := s.Stat(c, key)\n\tif st.IsError() {\n\t\treturn noShare(fmt.Errorf(st.Error))\n\t}\n\n\t/* retrieve blob */\n\trc, err := s.storageService.Get(c, st.StorageKey)\n\tif err != nil {\n\t\tc.HTTPContext.ReturnStatus = http.StatusNotFound\n\t\t//TODO: delete key from datastore and session.\n\t\treturn noShare(err)\n\t}\n\t/* generate return object */\n\treturn &BlobBinary{Reader: rc, mimeType: st.MimeType}\n}", "func (rc *RequiredCapability) Delete() (error, error, int) {\n\tauthorized, err := rc.isTenantAuthorized()\n\tif !authorized {\n\t\treturn errors.New(\"not authorized on this tenant\"), nil, http.StatusForbidden\n\t} else if err != nil {\n\t\treturn nil, fmt.Errorf(\"checking authorization for existing DS ID: %s\" + err.Error()), http.StatusInternalServerError\n\t}\n\t_, cdnName, _, err := dbhelpers.GetDSNameAndCDNFromID(rc.ReqInfo.Tx.Tx, *rc.DeliveryServiceID)\n\tif err != nil {\n\t\treturn nil, err, http.StatusInternalServerError\n\t}\n\tuserErr, sysErr, errCode := dbhelpers.CheckIfCurrentUserCanModifyCDN(rc.ReqInfo.Tx.Tx, string(cdnName), rc.ReqInfo.User.UserName)\n\tif userErr != nil || sysErr != nil {\n\t\treturn userErr, sysErr, errCode\n\t}\n\treturn api.GenericDelete(rc)\n}", "func (l *Locker) LoadAndDelete(key Flags) (interface{}, bool) {\n\treturn l.data.LoadAndDelete(key)\n}", "func (storage *B2Storage) DeleteFile(threadIndex int, filePath string) (err error) {\n\n if strings.HasSuffix(filePath, \".fsl\") {\n filePath = filePath[:len(filePath) - len(\".fsl\")]\n entries, err := storage.clients[threadIndex].ListFileNames(filePath, true, true)\n if err != nil {\n return err\n }\n\n toBeDeleted := false\n\n for _, entry := range entries {\n if entry.FileName != filePath || (!toBeDeleted && entry.Action != \"hide\" ) {\n continue\n }\n\n toBeDeleted = true\n\n err = storage.clients[threadIndex].DeleteFile(filePath, entry.FileID)\n if err != nil {\n return err\n }\n }\n\n return nil\n\n } else {\n entries, err := storage.clients[threadIndex].ListFileNames(filePath, true, false)\n if err != nil {\n return err\n }\n\n if len(entries) == 0 {\n return nil\n }\n return storage.clients[threadIndex].DeleteFile(filePath, entries[0].FileID)\n }\n}", "func (api *bucketAPI) SyncDelete(obj *objstore.Bucket) error {\n\tvar writeErr error\n\tif api.ct.resolver != nil {\n\t\tapicl, err := api.ct.apiClient()\n\t\tif err != nil {\n\t\t\tapi.ct.logger.Errorf(\"Error creating API server clent. Err: %v\", err)\n\t\t\treturn err\n\t\t}\n\n\t\t_, writeErr = apicl.ObjstoreV1().Bucket().Delete(context.Background(), &obj.ObjectMeta)\n\t}\n\n\tif writeErr == nil {\n\t\tapi.ct.handleBucketEvent(&kvstore.WatchEvent{Object: obj, Type: kvstore.Deleted})\n\t}\n\n\treturn writeErr\n}", "func (repo Repository) Delete(fullPath string) error {\n\tfilePath := path.Join(repo.StorageDir, fullPath)\n\n\treturn os.Remove(filePath)\n}", "func NewDeleteSmbShareDefault(code int) *DeleteSmbShareDefault {\n\treturn &DeleteSmbShareDefault{\n\t\t_statusCode: code,\n\t}\n}", "func (svc *SSHKeysService) Delete(ctx context.Context, prj, id string) (*http.Response, error) {\n\tpath := deleteSSHKeyPath(prj, id)\n\treturn svc.client.resourceDelete(ctx, path)\n}", "func (s *Store) Delete(id packet.ID) {\n\t// acquire mutex\n\ts.mutex.Lock()\n\tdefer s.mutex.Unlock()\n\n\t// delete future\n\tdelete(s.store, id)\n}", "func (client *GCSBlobstore) Delete(dest string) error {\n\tif client.readOnly() {\n\t\treturn ErrInvalidROWriteOperation\n\t}\n\n\terr := client.getObjectHandle(client.authenticatedGCS, dest).Delete(context.Background())\n\tif err == storage.ErrObjectNotExist {\n\t\treturn nil\n\t}\n\treturn err\n}", "func (pg *PGClient) DeletePendingTransfer(id int64) error {\n\ttx, err := pg.DB.Beginx()\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\tswitch err {\n\t\tcase nil:\n\t\t\terr = tx.Commit()\n\t\tdefault:\n\t\t\ttx.Rollback()\n\t\t}\n\t}()\n\n\tcheck := &model.PendingTransfer{}\n\tif err = tx.Get(check, qPendingTransferBy + `id = $1`, id); err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\treturn ErrPendingTransferNotFound\n\t\t}\n\t\treturn err\n\t}\n\n\tresult, err := tx.Exec(qDeletePendingTransfer, id)\n\tif err != nil {\n\t\treturn err\n\t}\n\trows, err := result.RowsAffected()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif rows != 1 {\n\t\treturn ErrPendingTransferNotFound\n\t}\n\treturn err\n}", "func (api *snapshotrestoreAPI) SyncDelete(obj *cluster.SnapshotRestore) error {\n\tvar writeErr error\n\tif api.ct.resolver != nil {\n\t\tapicl, err := api.ct.apiClient()\n\t\tif err != nil {\n\t\t\tapi.ct.logger.Errorf(\"Error creating API server clent. Err: %v\", err)\n\t\t\treturn err\n\t\t}\n\n\t\t_, writeErr = apicl.ClusterV1().SnapshotRestore().Delete(context.Background(), &obj.ObjectMeta)\n\t}\n\n\tif writeErr == nil {\n\t\tapi.ct.handleSnapshotRestoreEvent(&kvstore.WatchEvent{Object: obj, Type: kvstore.Deleted})\n\t}\n\n\treturn writeErr\n}", "func (api *dscprofileAPI) SyncDelete(obj *cluster.DSCProfile) error {\n\tvar writeErr error\n\tif api.ct.resolver != nil {\n\t\tapicl, err := api.ct.apiClient()\n\t\tif err != nil {\n\t\t\tapi.ct.logger.Errorf(\"Error creating API server clent. Err: %v\", err)\n\t\t\treturn err\n\t\t}\n\n\t\t_, writeErr = apicl.ClusterV1().DSCProfile().Delete(context.Background(), &obj.ObjectMeta)\n\t}\n\n\tif writeErr == nil {\n\t\tapi.ct.handleDSCProfileEvent(&kvstore.WatchEvent{Object: obj, Type: kvstore.Deleted})\n\t}\n\n\treturn writeErr\n}", "func (c *Client) Delete(d core.Digest) error {\n\t_, err := httputil.Delete(fmt.Sprintf(\"http://%s/blobs/%s\", c.addr, d))\n\treturn err\n}", "func (s *GDrive) Delete(ctx context.Context, token string, filename string) (err error) {\n\tmetadata, _ := s.findID(fmt.Sprintf(\"%s.metadata\", filename), token)\n\t_ = s.service.Files.Delete(metadata).Do()\n\n\tvar fileID string\n\tfileID, err = s.findID(filename, token)\n\tif err != nil {\n\t\treturn\n\t}\n\n\terr = s.service.Files.Delete(fileID).Context(ctx).Do()\n\treturn\n}", "func (f FileRepo) Delete(context context.Context, id string) (string, error) {\n\topts := options.FindOneAndDelete().SetProjection(bson.D{{\"_id\", 1}})\n\tobjID, err := primitive.ObjectIDFromHex(id)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tquery := bson.M{\n\t\t\"_id\": objID,\n\t}\n\tvar delFile model.File\n\terr = f.collection.FindOneAndDelete(context, query, opts).Decode(&delFile)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn delFile.ID.Hex(), nil\n}", "func (api *distributedservicecardAPI) SyncDelete(obj *cluster.DistributedServiceCard) error {\n\tvar writeErr error\n\tif api.ct.resolver != nil {\n\t\tapicl, err := api.ct.apiClient()\n\t\tif err != nil {\n\t\t\tapi.ct.logger.Errorf(\"Error creating API server clent. Err: %v\", err)\n\t\t\treturn err\n\t\t}\n\n\t\t_, writeErr = apicl.ClusterV1().DistributedServiceCard().Delete(context.Background(), &obj.ObjectMeta)\n\t}\n\n\tif writeErr == nil {\n\t\tapi.ct.handleDistributedServiceCardEvent(&kvstore.WatchEvent{Object: obj, Type: kvstore.Deleted})\n\t}\n\n\treturn writeErr\n}", "func ExampleFileSharesClient_Delete() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclient, err := armstorage.NewFileSharesClient(\"{subscription-id}\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\t_, err = client.Delete(ctx,\n\t\t\"res4079\",\n\t\t\"sto4506\",\n\t\t\"share9689\",\n\t\t&armstorage.FileSharesClientDeleteOptions{XMSSnapshot: nil,\n\t\t\tInclude: nil,\n\t\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n}", "func (e *etcdStore) GetAndDelete(ctx context.Context, codec store.Codec) error {\n\tvar (\n\t\tkey = codec.Key()\n\t\tresp *clientv3.DeleteResponse\n\t\terr error\n\t)\n\tif key == \"\" {\n\t\treturn errKeyIsBlank\n\t}\n\tif resp, err = e.cli.Delete(ctx, key, clientv3.WithPrevKV()); err != nil {\n\t\treturn err\n\t}\n\tif len(resp.PrevKvs) == 0 {\n\t\treturn store.ErrKVNotExists\n\t}\n\tcodec.SetVersion(0)\n\treturn codec.Decode(string(resp.PrevKvs[0].Value))\n}", "func (s *State) DeletePending(peerID core.PeerID, h core.InfoHash) {\n\tif s.get(h, peerID).status != _pending {\n\t\treturn\n\t}\n\ts.delete(h, peerID)\n\ts.log(\"hash\", h, \"peer\", peerID).Infof(\n\t\t\"Deleted pending conn, capacity now at %d\", s.capacity(h))\n}", "func Delete(client *gophercloud.ServiceClient, id string, bearer map[string]string) (r volumes.DeleteResult) {\n\t_, r.Err = client.Delete(deleteURL(client, id), &gophercloud.RequestOpts{\n\t\tMoreHeaders: bearer,\n\t})\n\treturn\n}", "func (c *BinaryFileClient) Delete() *BinaryFileDelete {\n\tmutation := newBinaryFileMutation(c.config, OpDelete)\n\treturn &BinaryFileDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}\n}", "func (a *UtilsApiService) DeleteFeatureTrackUsingDelete(ctx context.Context, featureTrackId string) (*http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Delete\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t)\n\n\t// create path and map variables\n\ta.client = NewAPIClient(&Configuration{\n\t\tBasePath: ctx.Value(\"BasePath\").(string),\n\t\tDefaultHeader: make(map[string]string),\n\t\tUserAgent: \"Swagger-Codegen/1.0.0/go\",\n\t})\n\tlocalVarPath := a.client.cfg.BasePath + \"/nucleus/v1/feature_track/{feature_track_id}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"feature_track_id\"+\"}\", fmt.Sprintf(\"%v\", featureTrackId), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\"*/*\"}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericSwaggerError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\n\t\treturn localVarHttpResponse, newErr\n\t}\n\n\treturn localVarHttpResponse, nil\n}", "func UnshareFile(w http.ResponseWriter, r *http.Request) {\n\t//log\n\tnow, userIP := globalPkg.SetLogObj(r)\n\tlogobj := logpkg.LogStruct{\"_\", now, userIP, \"macAdress\", \"UnshareFile\", \"file\", \"_\", \"_\", \"_\", 0}\n\tvar requestObj RetrieveBody\n\tdecoder := json.NewDecoder(r.Body)\n\tdecoder.DisallowUnknownFields()\n\terr := decoder.Decode(&requestObj)\n\tif err != nil {\n\t\tglobalPkg.SendError(w, \"please enter your correct request\")\n\t\tglobalPkg.WriteLog(logobj, \"please enter your correct request\", \"failed\")\n\t\treturn\n\t}\n\ttime.Sleep(time.Millisecond * 10)\n\taccountObj := account.GetAccountByAccountPubicKey(requestObj.Publickey)\n\tif accountObj.AccountPublicKey != requestObj.Publickey {\n\t\tglobalPkg.SendError(w, \"error in public key\")\n\t\tglobalPkg.WriteLog(logobj, \"error in public key\", \"failed\")\n\t\treturn\n\t}\n\tif accountObj.AccountPassword != requestObj.Password {\n\t\tglobalPkg.SendError(w, \"error in password\")\n\t\tglobalPkg.WriteLog(logobj, \"error in password\", \"failed\")\n\t\treturn\n\t}\n\t// Signture string\n\tvalidSig := false\n\tpk1 := account.FindpkByAddress(accountObj.AccountPublicKey).Publickey\n\tif pk1 != \"\" {\n\t\tpublickey1 := cryptogrpghy.ParsePEMtoRSApublicKey(pk1)\n\t\tsignatureData := requestObj.Publickey + requestObj.Password + requestObj.FileID\n\t\tvalidSig = cryptogrpghy.VerifyPKCS1v15(requestObj.Signture, signatureData, *publickey1)\n\t} else {\n\t\tvalidSig = false\n\t}\n\t// validSig = true\n\tif !validSig {\n\t\tglobalPkg.SendError(w, \"you are not allowed to delete unshare file\")\n\t\tglobalPkg.WriteLog(logobj, \"you are not allowed to delete unshare file\", \"failed\")\n\t\treturn\n\t}\n\tfound := false\n\tsharefile := filestorage.FindSharedfileByAccountIndex(accountObj.AccountIndex)\n\tif len(sharefile.OwnerSharefile) != 0 {\n\t\tfor sharefileindex, sharefileObj := range sharefile.OwnerSharefile {\n\t\t\tfileindex := containsfileidindex(sharefileObj.Fileid, requestObj.FileID)\n\t\t\tif fileindex != -1 {\n\t\t\t\tfound = true\n\t\t\t\tsharefileObj.Fileid = append(sharefileObj.Fileid[:fileindex], sharefileObj.Fileid[fileindex+1:]...)\n\t\t\t\tsharefile.OwnerSharefile = append(sharefile.OwnerSharefile[:sharefileindex], sharefile.OwnerSharefile[sharefileindex+1:]...)\n\t\t\t\t// fmt.Println(\"============== file ids :\", len(sharefileObj.Fileid), \"============\", len(sharefile.OwnerSharefile))\n\t\t\t\t// delete from permission list\n\t\t\t\taccountOwnerObj := account.GetAccountByAccountPubicKey(sharefileObj.OwnerPublicKey)\n\t\t\t\tFilelistOwner := accountOwnerObj.Filelist\n\t\t\t\tvar indexpk int = -1\n\t\t\t\tvar indexfile int = -1\n\t\t\t\tfor j, fileOwnerObj := range FilelistOwner {\n\t\t\t\t\tif fileOwnerObj.Fileid == requestObj.FileID {\n\t\t\t\t\t\tif len(fileOwnerObj.PermissionList) != 0 {\n\t\t\t\t\t\t\tfor k, pkpermission := range fileOwnerObj.PermissionList {\n\t\t\t\t\t\t\t\tif pkpermission == requestObj.Publickey {\n\t\t\t\t\t\t\t\t\tindexpk = k\n\t\t\t\t\t\t\t\t\tindexfile = j\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif indexpk != -1 {\n\t\t\t\t\taccountOwnerObj.Filelist[indexfile].PermissionList = append(accountOwnerObj.Filelist[indexfile].PermissionList[:indexpk], accountOwnerObj.Filelist[indexfile].PermissionList[indexpk+1:]...)\n\t\t\t\t\tbroadcastTcp.BoardcastingTCP(accountOwnerObj, \"updateaccountFilelist\", \"file\")\n\t\t\t\t\t// accountOwnerObj.Filelist = FilelistOwner\n\t\t\t\t}\n\t\t\t\t//\n\t\t\t\tif len(sharefileObj.Fileid) != 0 && len(sharefile.OwnerSharefile) >= 1 {\n\t\t\t\t\tsharefile.OwnerSharefile = append(sharefile.OwnerSharefile, sharefileObj)\n\t\t\t\t} else if len(sharefileObj.Fileid) != 0 && len(sharefile.OwnerSharefile) == 0 {\n\t\t\t\t\tsharefile.OwnerSharefile = append(sharefile.OwnerSharefile, sharefileObj)\n\t\t\t\t}\n\t\t\t\tbroadcastTcp.BoardcastingTCP(sharefile, \"updatesharefile\", \"file\")\n\n\t\t\t\tif len(sharefile.OwnerSharefile) == 0 {\n\t\t\t\t\tbroadcastTcp.BoardcastingTCP(sharefile, \"deleteaccountindex\", \"file\")\n\t\t\t\t}\n\t\t\t\tglobalPkg.SendResponseMessage(w, \"you unshare file successfully\")\n\t\t\t\tglobalPkg.WriteLog(logobj, \"you unshare file successfully\", \"success\")\n\t\t\t\treturn\n\n\t\t\t}\n\t\t}\n\t}\n\n\tif !found {\n\t\tglobalPkg.SendError(w, \"you not take share file\")\n\t\tglobalPkg.WriteLog(logobj, \"you not take share file\", \"failed\")\n\t\treturn\n\t}\n\n}", "func GetShare(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *ShareState, opts ...pulumi.ResourceOption) (*Share, error) {\n\tvar resource Share\n\terr := ctx.ReadResource(\"google-native:file/v1beta1:Share\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (api *objectAPI) SyncDelete(obj *objstore.Object) error {\n\tvar writeErr error\n\tif api.ct.resolver != nil {\n\t\tapicl, err := api.ct.apiClient()\n\t\tif err != nil {\n\t\t\tapi.ct.logger.Errorf(\"Error creating API server clent. Err: %v\", err)\n\t\t\treturn err\n\t\t}\n\n\t\t_, writeErr = apicl.ObjstoreV1().Object().Delete(context.Background(), &obj.ObjectMeta)\n\t}\n\n\tif writeErr == nil {\n\t\tapi.ct.handleObjectEvent(&kvstore.WatchEvent{Object: obj, Type: kvstore.Deleted})\n\t}\n\n\treturn writeErr\n}", "func PostDeleteTrack(w http.ResponseWriter, r *http.Request) {\n\n\treqData := map[string]string{}\n\n\t// Parse JSON Data\n\tdec := json.NewDecoder(r.Body)\n\terr := dec.Decode(&reqData)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tt := reqData[\"track_id\"]\n\n\tcontext.tq.remove(t)\n\n\tw.WriteHeader(204)\n\tw.Write([]byte(`{\"status\":\"deleted\", \"track\":\"` + t + `\"}`))\n}", "func (m *manifestService) Delete(ctx context.Context, dgst digest.Digest) error {\n\tcontext.GetLogger(ctx).Debugf(\"(*manifestService).Delete\")\n\treturn m.manifests.Delete(withRepository(ctx, m.repo), dgst)\n}", "func GetPendingTask(uid int64, shared bool) (*Task, error) {\n\t//declarations\n\trows, err := db.Query(\"SELECT tasks.id, users.token FROM tasks \"+\n\t\t\"INNER JOIN group_tasks ON tasks.gid = group_tasks.id \"+\n\t\t\"INNER JOIN users ON group_tasks.uid = users.id \"+\n\t\t\"WHERE group_tasks.uid = $1 AND tasks.status = $2\", uid, Pending)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\n\t// fetch task\n\tfor rows.Next() {\n\t\tvar tid, user_token string\n\t\tif err := rows.Scan(&tid, &user_token); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\ttask, err := GetTask(tid, user_token)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn task, nil\n\t}\n\n\tif shared {\n\t\t//declarations\n\t\trows, err := db.Query(\"SELECT tasks.id, users.token FROM tasks \"+\n\t\t\t\"INNER JOIN group_tasks ON tasks.gid = group_tasks.id \"+\n\t\t\t\"INNER JOIN users ON group_tasks.uid = users.id \"+\n\t\t\t\"WHERE tasks.status = $1\", Pending)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// fetch task\n\t\tdefer rows.Close()\n\t\tfor rows.Next() {\n\t\t\tvar tid, user_token string\n\t\t\tif err := rows.Scan(&tid, &user_token); err != nil {\n\t\t\t\treturn nil, nil\n\t\t\t}\n\n\t\t\ttask, err := GetTask(tid, user_token)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\treturn task, nil\n\t\t}\n\t}\n\n\treturn nil, nil\n}", "func (cache *diskBlockCacheWrapped) Delete(ctx context.Context,\n\tblockIDs []kbfsblock.ID) (numRemoved int, sizeRemoved int64, err error) {\n\t// This is a write operation but we are only reading the pointers to the\n\t// caches. So we use a read lock.\n\tcache.mtx.RLock()\n\tdefer cache.mtx.RUnlock()\n\tnumRemoved, sizeRemoved, err = cache.workingSetCache.Delete(ctx, blockIDs)\n\tif cache.syncCache == nil || err != nil {\n\t\treturn numRemoved, sizeRemoved, err\n\t}\n\tsyncNumRemoved, syncSizeRemoved, err :=\n\t\tcache.syncCache.Delete(ctx, blockIDs)\n\treturn numRemoved + syncNumRemoved, sizeRemoved + syncSizeRemoved, err\n}", "func (c *BinaryFileClient) DeleteOne(bf *BinaryFile) *BinaryFileDeleteOne {\n\treturn c.DeleteOneID(bf.ID)\n}", "func (httpfs *FS) Delete(ctx context.Context, path string) (err error) {\n\treturn qfs.ErrReadOnly\n}", "func (p *Peer) Delete(ctx context.Context, dgst digest.Digest) error {\n\tc, err := digestconv.DigestToCid(dgst)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to convert digest\")\n\t}\n\n\treturn p.dserv.Remove(ctx, c)\n}", "func (p *GetService) Get(request string, reply *string) error {\n\tvar sdfsfilename string\n\tvar localfilename string\n\tvar IP string\n\tIP = strings.Split(request, \" \")[0]\n\tsdfsfilename = strings.Split(request, \" \")[1]\n\tlocalfilename = strings.Split(request, \" \")[2]\n\ttime.Sleep(time.Second * 1)\n\tputfile(sdfsfilename, localfilename, IP)\n\treturn nil\n}", "func GetDatastoreFileshare(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *DatastoreFileshareState, opts ...pulumi.ResourceOption) (*DatastoreFileshare, error) {\n\tvar resource DatastoreFileshare\n\terr := ctx.ReadResource(\"azure:machinelearning/datastoreFileshare:DatastoreFileshare\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (r *repository) Delete(id uint) error {\n\tif err := r.db.Where(\"id = ?\", id).Delete(&models.Upload{}).Error; err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (l *RemoteProvider) DeleteSchedule(req *http.Request, scheduleID string) ([]byte, error) {\n\tif !l.Capabilities.IsSupported(PersistSchedules) {\n\t\tlogrus.Error(\"operation not available\")\n\t\treturn nil, ErrInvalidCapability(\"PersistSchedules\", l.ProviderName)\n\t}\n\n\tep, _ := l.Capabilities.GetEndpointForFeature(PersistSchedules)\n\n\tlogrus.Infof(\"attempting to fetch schedule from cloud for id: %s\", scheduleID)\n\n\tremoteProviderURL, _ := url.Parse(fmt.Sprintf(\"%s%s/%s\", l.RemoteProviderURL, ep, scheduleID))\n\tlogrus.Debugf(\"constructed schedule url: %s\", remoteProviderURL.String())\n\tcReq, _ := http.NewRequest(http.MethodDelete, remoteProviderURL.String(), nil)\n\n\ttokenString, err := l.GetToken(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresp, err := l.DoRequest(cReq, tokenString)\n\tif err != nil {\n\t\tlogrus.Errorf(\"unable to delete schedules: %v\", err)\n\t\treturn nil, ErrDelete(err, \"Perf Schedule :\"+scheduleID, resp.StatusCode)\n\t}\n\tdefer func() {\n\t\t_ = resp.Body.Close()\n\t}()\n\tbdr, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, ErrDataRead(err, \"Perf Schedule :\"+scheduleID)\n\t}\n\n\tif resp.StatusCode == http.StatusOK {\n\t\tlogrus.Infof(\"schedule successfully retrieved from remote provider\")\n\t\treturn bdr, nil\n\t}\n\treturn nil, ErrDelete(err, fmt.Sprint(bdr), resp.StatusCode)\n}", "func (fs *Ipfs) Delete(path string) error {\n\t// Remoe file if on disk and unpinn\n\tif fname, err := fs.makeFilename(path); err == nil {\n\t\tos.Remove(fname)\n\t}\n\n\tipath := ipath.New(path)\n\treturn fs.coreAPI.Pin().Rm(context.Background(), ipath)\n}", "func (self *CassandraMetaStore) GetPending(v *meta.RequestVars) (*meta.Object, error) {\n\treturn self.findOid(v.Oid, true)\n}", "func (r *RecordingService) Delete(ctx context.Context, sid string) error {\n\treturn r.client.DeleteResource(ctx, recordingsPathPart, sid)\n}", "func (f FileURL) Delete(ctx context.Context) (*FileDeleteResponse, error) {\n\treturn f.fileClient.Delete(ctx, nil)\n}", "func (s *server) Delete(_ context.Context, request *pb.DeleteRequest) (*pb.DeleteResponse, error) {\n\tfmt.Printf(\"deleting %s\\n\", path.Join(s.localReplicaPath, request.FullPath))\n\terr := os.Remove(path.Join(s.localReplicaPath, request.FullPath))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to delete at %s: %w\", request.FullPath, err)\n\t}\n\treturn &pb.DeleteResponse{}, nil\n}", "func (f *Fs) delete(ctx context.Context, isFile bool, id string, remote string, hardDelete bool) (err error) {\n\tif hardDelete {\n\t\topts := rest.Opts{\n\t\t\tMethod: \"DELETE\",\n\t\t\tRootURL: id,\n\t\t\tNoResponse: true,\n\t\t}\n\t\treturn f.pacer.Call(func() (bool, error) {\n\t\t\tresp, err := f.srv.Call(ctx, &opts)\n\t\t\treturn shouldRetry(ctx, resp, err)\n\t\t})\n\t}\n\t// Move file/dir to deleted files if not hard delete\n\tleaf := path.Base(remote)\n\tif isFile {\n\t\t_, err = f.moveFile(ctx, id, leaf, f.opt.DeletedID)\n\t} else {\n\t\terr = f.moveDir(ctx, id, leaf, f.opt.DeletedID)\n\t}\n\treturn err\n}", "func (dtm *DfgetTaskManager) Delete(ctx context.Context, clientID, taskID string) error {\n\tkey, err := generateKey(clientID, taskID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn dtm.dfgetTaskStore.Delete(key)\n}", "func (p *SharedPrivateLinkResourcesDeletePoller) Poll(ctx context.Context) (*http.Response, error) {\n\treturn p.pt.Poll(ctx)\n}", "func (s *shares) Get(shareID string) (Share, error) {\n\tres, err := s.c.baseRequest(http.MethodGet, routes.shares, nil, shareID)\n\tif err != nil {\n\t\treturn Share{}, err\n\t}\n\tvar r sharesListResponse\n\tres.JSON(&r)\n\treturn r.Ocs.Data[0], nil\n}", "func (dq *deleteQueue) deleteFromPending() {\n\tdq.Lock()\n\tdefer dq.Unlock()\n\n\tn := len(dq.entries)\n\tif n > awsBatchSizeLimit {\n\t\tn = awsBatchSizeLimit\n\t}\n\tfails, err := dq.deleteBatch(dq.entries[:n])\n\tif err != nil {\n\t\tdq.svc.Logger(\"Error deleting batch: %s\", err)\n\t\treturn\n\t}\n\n\tdq.entries = dq.entries[n:]\n\n\tif len(fails) > 0 {\n\t\tdq.entries = append(dq.entries, fails...)\n\t}\n}", "func (obj *MessengerCloudFsFileInfoList) Delete() {\n\tif obj == nil {\n\t\treturn\n\t}\n\truntime.SetFinalizer(obj, nil)\n\tobj.delete()\n}", "func Get() (int, error) {\n\tstorage, err := New(SharedDir)\n\tif err != nil {\n\t\treturn -1, err\n\t}\n\n\tif err := storage.Lock(); err != nil {\n\t\treturn -1, err\n\t}\n\tdefer storage.Unlock()\n\ts, err := storage.Acquire()\n\tif err != nil {\n\t\treturn -1, err\n\t}\n\treturn s, nil\n}", "func (sfs *SafeFileSet) Delete(metahash [32]byte) {\n\tsfs.filesSet.Delete(metahash)\n}", "func (s *Server) Delete(ctx context.Context, req *pb.DeleteRequest) (*pb.Empty, error) {\n\tp, ok := peer.FromContext(ctx)\n\tif !ok {\n\t\treturn nil, errors.New(\"failed to extract peer details from context\")\n\t}\n\ts.logger.Info(\"delete request received\", zap.Stringer(\"addr\", p.Addr), zap.String(\"key\", req.Key))\n\n\tif err := s.store.Delete(req.GetKey(), time.Now().UTC().UnixNano()); err != nil {\n\t\treturn &pb.Empty{}, fmt.Errorf(\"failed to process delete: %w\", err)\n\t}\n\treturn &pb.Empty{}, nil\n}", "func (g *gcs) Delete(ctx context.Context, remotePath string) (err error) {\n\tif err = g.bucket.Object(remotePath).Delete(g.context); err != nil {\n\t\treturn err\n\t}\n\n\treturn\n}", "func (b *Blob) Delete() error {\n\tif ref := b.DecRefCount(); ref == 0 {\n\t\tutils.Remove(b.FilePath())\n\t\tutils.Remove(b.RefCountPath())\n\t}\n\treturn nil\n}", "func (s *scheduledWorkQueue) Forget(obj interface{}) {\n\ts.workLock.Lock()\n\tdefer s.workLock.Unlock()\n\n\tif cancel, ok := s.work[obj]; ok {\n\t\tcancel()\n\t\tdelete(s.work, obj)\n\t}\n}", "func (a *UtilsApiService) DeleteNotificationUsingDelete(ctx context.Context, notificationId string) (*http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Delete\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t)\n\n\t// create path and map variables\n\ta.client = NewAPIClient(&Configuration{\n\t\tBasePath: ctx.Value(\"BasePath\").(string),\n\t\tDefaultHeader: make(map[string]string),\n\t\tUserAgent: \"Swagger-Codegen/1.0.0/go\",\n\t})\n\tlocalVarPath := a.client.cfg.BasePath + \"/nucleus/v1/notification/{notification_id}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"notification_id\"+\"}\", fmt.Sprintf(\"%v\", notificationId), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\"*/*\"}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericSwaggerError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\n\t\treturn localVarHttpResponse, newErr\n\t}\n\n\treturn localVarHttpResponse, nil\n}", "func (s TensePresIndResource) Delete(id string, r api2go.Request) (api2go.Responder, error) {\n\terr := s.TensePresIndStorage.Delete(id)\n\n\tif err != nil {\n\t\treturn &Response{Code: http.StatusNotFound}, api2go.NewHTTPError(err, err.Error(), http.StatusNotFound)\n\t}\n\n\treturn &Response{Code: http.StatusNoContent}, err\n}", "func (o *SwiftObject) Delete(metadata map[string]string) error {\n\tif _, err := o.newFile(\"ts\", 0); err != nil {\n\t\treturn err\n\t} else {\n\t\tdefer o.Close()\n\t\treturn o.Commit(metadata)\n\t}\n}", "func delete(resource string, id string) ([]byte, error) {\n\thttpParams := &HTTPParams{\n\t\tResource: resource + \"/\" + id,\n\t\tVerb: \"DELETE\",\n\t}\n\treturn processRequest(httpParams)\n}", "func (r *MonitorGTPResource) Delete(id string) error {\n\tif err := r.c.ModQuery(\"DELETE\", BasePath+MonitorGTPEndpoint+\"/\"+id, nil); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *ResourcesHandler) Delete(event.DeleteEvent, workqueue.RateLimitingInterface) {}", "func (s *CarShareStorage) Delete(id string, context api2go.APIContexter) error {\n\t_, exists := s.carShares[id]\n\tif !exists {\n\t\treturn storage.ErrNotFound\n\t}\n\tdelete(s.carShares, id)\n\n\treturn nil\n}", "func (s *s3ManifestService) Delete(ctx context.Context, dgst godigest.Digest) error {\n\treturn fmt.Errorf(\"unimplemented\")\n}", "func (p *StoragesDeletePoller) Poll(ctx context.Context) (*http.Response, error) {\n\treturn p.pt.Poll(ctx)\n}", "func (c *PluginContext) SyncDelete(key ContextKey) {\n\tc.Mx.Lock()\n\tdefer c.Mx.Unlock()\n\tc.Delete(key)\n}", "func (obj *MessengerFileCipher) Delete() {\n\tif obj == nil {\n\t\treturn\n\t}\n\truntime.SetFinalizer(obj, nil)\n\tobj.delete()\n}", "func (h *HubService) GetDeleteToken(repo string, auth Authenticator) (*TokenAuth, error) {\n\tpath := fmt.Sprintf(\"v1/repositories/%s/\", repo)\n\treq, err := h.newRequest(\"DELETE\", path, auth)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn h.do(req)\n}", "func (a *UtilsApiService) DeleteNotificationSettingUsingDelete(ctx context.Context, notificationSettingId string) (*http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Delete\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t)\n\n\t// create path and map variables\n\ta.client = NewAPIClient(&Configuration{\n\t\tBasePath: ctx.Value(\"BasePath\").(string),\n\t\tDefaultHeader: make(map[string]string),\n\t\tUserAgent: \"Swagger-Codegen/1.0.0/go\",\n\t})\n\tlocalVarPath := a.client.cfg.BasePath + \"/nucleus/v1/notification_setting/{notification_setting_id}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"notification_setting_id\"+\"}\", fmt.Sprintf(\"%v\", notificationSettingId), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\"*/*\"}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericSwaggerError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\n\t\treturn localVarHttpResponse, newErr\n\t}\n\n\treturn localVarHttpResponse, nil\n}", "func Delete(c *gophercloud.ServiceClient, networkID string) os.DeleteResult {\n\treturn os.Delete(c, networkID)\n}", "func (c *UnsavedPostAttachmentClient) Delete() *UnsavedPostAttachmentDelete {\n\tmutation := newUnsavedPostAttachmentMutation(c.config, OpDelete)\n\treturn &UnsavedPostAttachmentDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}\n}", "func (f File) Delete() File {\n\t//DPrintf(\"delete %v from versions %v\", f.Path, f)\n\tif f.Deleted {\n\t\tDPrintf(\"WARNING: deleting an already deleted file\")\n\t}\n\tf.Deleted = true\n\treturn f\n}", "func (_BaseAccessWallet *BaseAccessWalletTransactor) ClearPending(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _BaseAccessWallet.contract.Transact(opts, \"clearPending\")\n}", "func (m *DisksClientMock) Get(ctx context.Context, resourceGroupName string, diskName string) (result compute.Disk, rerr *retry.Error) {\n\treturn compute.Disk{}, nil\n}", "func (t *Token) Delete() error {\n\treturn t.deleteFile()\n}", "func (w *wireMap) AtomicDelete(wire *GRPCWire) error {\n\tw.mu.Lock()\n\tdefer w.mu.Unlock()\n\tdelete(w.wires, linkKey{\n\t\tnamespace: wire.LocalPodNetNS,\n\t\tlinkUID: wire.UID,\n\t})\n\n\tdelete(w.handles, wire.LocalNodeIfaceID)\n\n\treturn nil\n}", "func Delete(instructionData reflect.Value, finished chan bool) int {\n\tfmt.Println(\"FIBER INFO: Deleting File ...\")\n\n\tpath, err := variable.GetValue(instructionData, \"PathVarName\", \"PathIsVar\", \"Path\")\n\tif err != nil {\n\t\tfinished <- true\n\t\treturn -1\n\t}\n\n\tos.Remove(path.(string))\n\tfinished <- true\n\treturn -1\n}", "func (p *DeleteService) ForwardDelete(request string, reply *string) error {\n\t_, index := Getip()\n\tmemid := election()\n\tif _, ok := fileList[request]; ok {\n\t\tnodelist := fileList[request].NodeList\n\t\tfor _, i := range nodelist {\n\t\t\tif i == index {\n\t\t\t\tos.Remove(request)\n\t\t\t} else {\n\t\t\t\tclient, err := rpc.Dial(\"tcp\", straddr[i]+\":4000\")\n\t\t\t\tif (err != nil) {\n\t\t\t\t\tfmt.Println(err)\n\t\t\t\t}\n\t\t\t\terr = client.Call(\"DeleteService.Delete\", request, &reply)\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Println(err)\n\t\t\t\t}\n\t\t\t\t*reply = \"file delete!\"\n\t\t\t\tdefer client.Close()\n\t\t\t}\n\t\t}\n\t\tfor _, index1 := range memid {\n\t\t\tif index1 == index {\n\t\t\t\tdelete(fileList, request)\n\t\t\t} else {\n\t\t\t\tvar temp = make(map[string]pair)\n\t\t\t\ttemp[request] = pair{\n\t\t\t\t\tTimeStamp: 0,\n\t\t\t\t\tNodeList: nil,\n\t\t\t\t}\n\t\t\t\tsendlist(temp, straddr[index1])\n\t\t\t}\n\t\t}\n\t} else {\n\t\t*reply = \"no such file!\"\n\t}\n\treturn nil\n}", "func (c *ServerConn) Delete(path string) error {\n\t_, _, err := c.cmd(StatusRequestedFileActionOK, \"DELE %s\", path)\n\treturn err\n}", "func (pc pidController) delete() {\n\tpid := pc.pidProvider.provide()\n\tfilePID, err := pc.get()\n\tif err != nil {\n\t\toktetoLog.Infof(\"unable to delete PID file at %s: %s\", pc.pidFilePath, err)\n\t}\n\n\tif err := pc.watcher.Close(); err != nil {\n\t\toktetoLog.Infof(\"could not close watcher: %w\", err)\n\t}\n\n\tif strconv.Itoa(pid) != filePID {\n\t\toktetoLog.Infof(\"okteto process with PID '%s' has the ownership of the file.\", filePID)\n\t\toktetoLog.Info(\"skipping deletion of PID file\")\n\t\treturn\n\t}\n\terr = pc.filesystem.Remove(pc.pidFilePath)\n\tif err != nil && !os.IsNotExist(err) {\n\t\toktetoLog.Infof(\"unable to delete PID file at %s: %s\", pc.pidFilePath, err)\n\t}\n}", "func (t *FakeObjectTracker) Delete(gvr schema.GroupVersionResource, ns, name string) error {\n\treturn nil\n}", "func TestDeleteFile(t *testing.T) {\n\tfmt.Println(\"Get File info test\")\n\tcc := getClientConnection()\n\n\t// when done the connection will be close.\n\tdefer cc.Close()\n\n\t// Create a new client service...\n\tc := filepb.NewFileServiceClient(cc)\n\n\trqst := &filepb.DeleteFileRequest{\n\t\tPath: \"C:\\\\Temp\\\\toto.bmp\",\n\t}\n\n\trsp, err := c.DeleteFile(context.Background(), rqst)\n\tif err != nil {\n\t\tlog.Fatalf(\"error while testing get file info: %v\", err)\n\t}\n\n\tlog.Println(\"Delete file succeed:\", rsp.Result)\n}", "func ExampleFileSharesClient_Get() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclient, err := armstorage.NewFileSharesClient(\"{subscription-id}\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := client.Get(ctx,\n\t\t\"res9871\",\n\t\t\"sto6217\",\n\t\t\"share1634\",\n\t\t&armstorage.FileSharesClientGetOptions{Expand: to.Ptr(\"stats\"),\n\t\t\tXMSSnapshot: nil,\n\t\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// TODO: use response item\n\t_ = res\n}", "func (_BaseContentSpace *BaseContentSpaceTransactor) ClearPending(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _BaseContentSpace.contract.Transact(opts, \"clearPending\")\n}" ]
[ "0.50653577", "0.5034428", "0.4935411", "0.4918671", "0.47782397", "0.47302368", "0.46873987", "0.46159875", "0.45806068", "0.45560926", "0.4527142", "0.45016083", "0.44963208", "0.44932404", "0.44923154", "0.44845128", "0.4465482", "0.44443616", "0.44268724", "0.442413", "0.44082674", "0.44048682", "0.44005018", "0.43910846", "0.43831557", "0.43810475", "0.43648708", "0.4353177", "0.43451512", "0.43398616", "0.4319744", "0.43115503", "0.43091625", "0.43084115", "0.4307879", "0.43002096", "0.42881882", "0.42863333", "0.4267286", "0.425731", "0.42411047", "0.42373547", "0.41976142", "0.4197086", "0.41945192", "0.41881", "0.4184357", "0.41768727", "0.41714287", "0.4167408", "0.41647607", "0.41629493", "0.41627523", "0.41506726", "0.41478115", "0.41429427", "0.41390234", "0.41254988", "0.41241863", "0.411722", "0.41035706", "0.40868276", "0.40857258", "0.4085581", "0.4082384", "0.40784743", "0.40677637", "0.4067659", "0.40650195", "0.40628585", "0.40624565", "0.40601888", "0.40564308", "0.40552875", "0.40537018", "0.40471813", "0.4042135", "0.4038989", "0.40293342", "0.40176928", "0.40136307", "0.40126547", "0.40122333", "0.4012112", "0.40117556", "0.4008499", "0.40054828", "0.4002601", "0.3997073", "0.39961907", "0.39922374", "0.39905113", "0.39863193", "0.3984429", "0.39837417", "0.3983345", "0.39819688", "0.39810938", "0.39750004", "0.39738235" ]
0.758004
0
Set adds a new PendingFileshare in the repository. If the key already exists, it returns false, otherwise it returns true.
Set добавляет новый PendingFileshare в репозиторий. Если ключ уже существует, возвращается false, иначе возвращается true.
func (r *inMemoryFileshareRepository) Set(key string, fd PendingFileshare) bool { r.Lock() defer r.Unlock() if _, ok := r.pendingFileshares[key]; ok { return false // Key already exists. } if r.pendingFileshares == nil { r.pendingFileshares = make(map[string]PendingFileshare) } r.pendingFileshares[key] = fd return true }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Filter) Set(key string) (bool, error) {\n\tcmd := \"s \" + f.Name + \" \" + f.getKey(key)\n\tresp, err := f.Conn.SendAndReceive(cmd)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif resp == \"Yes\" || resp == \"No\" {\n\t\treturn resp == \"Yes\", nil\n\t}\n\treturn false, errInvalidResponse(resp)\n}", "func (r *inMemoryFileshareRepository) GetAndDelete(key string) (PendingFileshare, bool) {\n\tr.Lock()\n\tdefer r.Unlock()\n\n\tfileshare, ok := r.pendingFileshares[key]\n\tif !ok {\n\t\treturn PendingFileshare{}, false\n\t}\n\n\tdelete(r.pendingFileshares, key)\n\treturn fileshare, true\n}", "func (l *localStore) Set(key string, b []byte) error {\n\t_, ok := l.m[key]\n\tl.m[key] = b\n\tif ok {\n\t\treturn ErrKeyExist\n\t}\n\treturn nil\n}", "func (s *SyncStorage) SetIfNotExists(ns string, key string, data interface{}) (bool, error) {\n\treturn s.getDbBackend(ns).SetNX(getNsPrefix(ns)+key, data, 0)\n}", "func (kvs *FS) Set(key string, value []byte) error {\n\treturn lockedfile.Write(kvs.filename(key), bytes.NewReader(value), 0600)\n}", "func (c *fileStorageClient) Set(key string, value []byte) error {\n\treturn c.Batch(SetOperation(key, value))\n}", "func (fs *FSCache) Set(key string, content []byte) error {\n\treturn ioutil.WriteFile(\n\t\tpath.Join(fs.Root, key),\n\t\tcontent,\n\t\t0600,\n\t)\n}", "func (f *NaiveMap) Set(key string, value interface{}) bool {\n\tf.lock.Lock()\n\tdefer f.lock.Unlock()\n\n\tif f.capacity <= f.count {\n\t\tlog.Print(\"At maximum capacity!\")\n\t\treturn false\n\t}\n\n\tif key == \"\" {\n\t\tlog.Print(\"Invalid input.\")\n\t\treturn false\n\t}\n\t// Check if they key has been set, if so, put value with key.\n\tfor i, _ := range f.keys {\n\t\tif f.keys[i] == key {\n\t\t\tf.values[i] = value\n\t\t\treturn true\n\t\t}\n\t}\n\n\t// Make sure there's an an empty spot, then add.\n\tfor i, _ := range f.keys {\n\t\tif f.keys[i] == \"\" {\n\t\t\tf.keys[i] = key\n\t\t\tf.values[i] = value\n\t\t\tf.count++\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (c *Cache) Set(key string, msg *CacheItem) bool {\n\tc.mu.Lock()\n\tc.backend[key] = msg\n\tc.mu.Unlock()\n\n\treturn true\n}", "func (storage *PaymentChannelStorage) PutIfAbsent(key *PaymentChannelKey, state *PaymentChannelData) (ok bool, err error) {\n\treturn storage.delegate.PutIfAbsent(key, state)\n}", "func (s *SharemeService) Add(c *gae.Context, session *Session, key string) (stat Share) {\n\tstat = s.Stat(c, key)\n\tif stat.IsError() {\n\t\treturn\n\t}\n\tsession.Set(fmt.Sprintf(\"%s%s\", KeySessionPrefix, key), stat.Name)\n\treturn\n}", "func (s *SyncStorage) SetIfNotExistsAndPublish(ns string, channelsAndEvents []string, key string, data interface{}) (bool, error) {\n\tnsPrefix := getNsPrefix(ns)\n\tif len(channelsAndEvents) == 0 {\n\t\treturn s.getDbBackend(ns).SetNX(nsPrefix+key, data, 0)\n\t}\n\tif err := s.checkChannelsAndEvents(\"SetIfNotExistsAndPublish\", channelsAndEvents); err != nil {\n\t\treturn false, err\n\t}\n\tchannelsAndEventsPrepared := s.prepareChannelsAndEvents(nsPrefix, channelsAndEvents)\n\treturn s.getDbBackend(ns).SetNXPub(channelsAndEventsPrepared, nsPrefix+key, data)\n}", "func (m *mSignatureKeyHolderMockEquals) Set(f func(p SignatureKeyHolder) (r bool)) *SignatureKeyHolderMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.EqualsFunc = f\n\treturn m.mock\n}", "func (storage *remoteStorage) Set(key *data.ID, value []byte) error {\n\tnode := storage.node\n\n\turl := fmt.Sprintf(\"http://%s/storage/%s\", node.TCPAddr().String(), key.String())\n\n\t// Base64 encoding, RFC 4648.\n\t// str := base64.StdEncoding.EncodeToString(value)\n\treq, err := http.NewRequest(http.MethodPut, url, bytes.NewReader(value))\n\tif req.Body != nil {\n\t\tdefer req.Body.Close()\n\t}\n\tif err != nil {\n\t\tnode.disconnect(err)\n\t\treturn err\n\t}\n\tres, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\tnode.disconnect(err)\n\t\treturn err\n\t}\n\tif res.Body != nil {\n\t\tdefer res.Body.Close()\n\t}\n\tif res.StatusCode < 200 || res.StatusCode > 299 {\n\t\terr := fmt.Errorf(\"HTTP storage Put %s -> %d %s\", url, res.StatusCode, res.Status)\n\t\tnode.disconnect(err)\n\t\treturn err\n\t}\n\treturn nil\n}", "func (ak *AlertKey) Set(key string) {\n\t_ = ak.Akdb.Put([]byte(key), []byte(\"true\"), nil)\n}", "func (s *CacheServer) Set(ctx context.Context, item *pb.CacheItem) (*pb.Success, error) {\n\texpire, _ := time.Parse(time.RFC3339, item.ExpireTime)\n\terr := cache.Set(item.Key, item.Value, expire)\n\tif err != nil {\n\t\treturn &pb.Success{\n\t\t\tSuccess: false,\n\t\t}, err\n\t}\n\tlog.Printf(\"set item: %v, %v, %v\", item.Key, item.Value, expire)\n\treturn &pb.Success{\n\t\tSuccess: true,\n\t}, nil\n}", "func (s *InMemoryHashStorage) Set(key int64, value string) {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\n\ts.hashes[key] = value\n}", "func (c *BlockCache) Set(key string) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tkey = strings.ToLower(key)\n\tc.m[key] = true\n}", "func (s *Store) Put(key string, value []byte) bool {\n\n\tif _, ok := s.objects.Load(key); !ok {\n\t\ts.objects.Store(key, value)\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (fc *fileCache) Set(key, value string, ttl int) {\n\tfc.cache.Set(key, &cacheObject{\n\t\tValue: value,\n\t\tTimestamp: time.Now().Unix(),\n\t\tTTL: ttl,\n\t})\n\tfc.dirty = true\n}", "func (us *urlStatus) Set(key string, val bool) {\n\tus.mu.Lock()\n\t// Lock so only one goroutine at a time can access the map c.v.\n\tdefer us.mu.Unlock()\n\tus.v[key] = val\n}", "func (t *SBF) Add(hashes []uint64) bool {\n // Check if the key is in SBF already\n t.mutex.RLock()\n for _, pf := range t.plainFilters {\n if pf.Has(hashes) {\n t.mutex.RUnlock()\n // Has the key already.\n return true\n }\n }\n t.mutex.RUnlock()\n\n // Add the key to SBF\n t.mutex.Lock()\n defer t.mutex.Unlock()\n pf := t.plainFilters[len(t.plainFilters)-1]\n\n if t.keys == t.capacity {\n // SBF is full. Expand it by attaching another plainFilter\n pf := plainFilter.NewPlainFilter(scale_size*pf.Capacity, r*pf.Probability)\n t.plainFilters = append(t.plainFilters, pf)\n atomic.AddUint64(&t.capacity, pf.Capacity)\n }\n\n // In most cases added is false. Since we checked the key is not in the filter in the\n // top half of this function. But there is a tiny chance there is a context switch happens\n // between the RWLock and we could add the same key twice. So double check added here.\n added := pf.Add(hashes)\n if !added {\n atomic.AddUint64(&t.keys, 1)\n }\n \n return added\n}", "func (c *SimpleCache) Set(k string, v interface{}, ttl int64) bool {\n\tc.Lock.Lock()\n\tdata, present := c.getData(k, ttl)\n\tif present == true {\n\t\tif ttl == -1 {\n\t\t\tdata.ExpireAt = time.Now().Unix() + c.TTL\n\t\t} else {\n\t\t\tdata.ExpireAt = time.Now().Unix() + ttl\n\t\t}\n\t\tc.Queue.update(data)\n\t\tc.Data[k] = data\n\t} else {\n\t\tvar ttx int64\n\t\tif ttl == -1 {\n\t\t\tttx = time.Now().Unix() + c.TTL\n\t\t} else {\n\t\t\tttx = time.Now().Unix() + ttl\n\t\t}\n\t\tnewData := newQueueItem(k, v, ttx)\n\t\tc.Queue.push(newData)\n\t\tc.Data[k] = newData\n\t}\n\tc.Lock.Unlock()\n\treturn true\n}", "func (ps *peerSet) Put(addr net.UDPAddr) bool {\n\ts := addr.String()\n\n\tif _, ok := ps.values[s]; ok {\n\t\treturn false\n\t}\n\n\tps.values[s] = struct{}{}\n\n\tr := &ring.Ring{\n\t\tValue: addr,\n\t}\n\n\tif ps.ring == nil {\n\t\tps.ring = r\n\t} else {\n\t\tps.ring.Link(r)\n\t}\n\n\treturn true\n}", "func (b *Bcache) Set(key, val string, expiredTimestamp int64) {\n\tb.peer.Set(key, val, expiredTimestamp)\n}", "func (b *SharingKeys) Add(name string, key *[32]byte) (*SharingKey, error) {\n\tif name == \"\" {\n\t\treturn nil, ErrSharingKeyNameInvalid\n\t}\n\tn := []byte(name)\n\tif v := b.b.Get(n); v != nil {\n\t\treturn nil, ErrSharingKeyExist\n\t}\n\tif err := b.b.Put([]byte(name), key[:]); err != nil {\n\t\treturn nil, err\n\t}\n\ts := &SharingKey{\n\t\tb: b,\n\t\tname: n,\n\t\tsecret: key[:],\n\t}\n\treturn s, nil\n}", "func (c *Cache) Set(key string, value []byte) (changed bool) {\n\tif len(value) != ValueSize {\n\t\t// check done to enable future optimization with fixed sized records.\n\t\tpanic(\"value with bad length provided\")\n\t}\n\n\t// do as much work as possible outside a transaction\n\tk := []byte(key)\n\tchanged = true\n\n\terr := c.db.Update(func(tx *bolt.Tx) error {\n\t\tb := tx.Bucket(bkt)\n\t\tcv := b.Get(k)\n\t\tif bytes.Equal(value, cv) {\n\t\t\tchanged = false\n\t\t}\n\t\treturn b.Put(k, value)\n\t})\n\tif err != nil {\n\t\tchanged = true\n\t\tif c.err == nil {\n\t\t\tc.err = err\n\t\t}\n\t}\n\treturn\n}", "func (this HashString) Set(val string) <-chan bool {\n\treturn BoolCommand(this.parent, this.args(\"hset\", val)...)\n}", "func (l *Locker) Set(key Flags, value interface{}) {\n\tl.data.Store(key, value)\n}", "func (s *FileSet) Add(file string) {\n\ts.files[file] = true\n}", "func (c *Cache) IsSet(key string) bool {\n\t_, ok := c.candidateState[key]\n\n\treturn ok\n}", "func (obj *OrderedObject) Set(key string, value interface{}) (exists bool) {\n\tif idx, ok := obj.keys[key]; ok {\n\t\tobj.Object[idx].Value = value\n\t\treturn false\n\t} else {\n\t\tobj.keys[key] = len(obj.Object)\n\t\tobj.Object = append(obj.Object, json.Member{Key: key, Value: value})\n\t\treturn true\n\t}\n}", "func (s Set) Add(key string) {\n\ts[key] = true\n}", "func (mmHasPendings *mClientMockHasPendings) Set(f func(ctx context.Context, object insolar.Reference) (b1 bool, err error)) *ClientMock {\n\tif mmHasPendings.defaultExpectation != nil {\n\t\tmmHasPendings.mock.t.Fatalf(\"Default expectation is already set for the Client.HasPendings method\")\n\t}\n\n\tif len(mmHasPendings.expectations) > 0 {\n\t\tmmHasPendings.mock.t.Fatalf(\"Some expectations are already set for the Client.HasPendings method\")\n\t}\n\n\tmmHasPendings.mock.funcHasPendings = f\n\treturn mmHasPendings.mock\n}", "func (c *AdapterMemory) SetIfNotExist(ctx context.Context, key interface{}, value interface{}, duration time.Duration) (bool, error) {\n\tisContained, err := c.Contains(ctx, key)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif !isContained {\n\t\tif _, err = c.doSetWithLockCheck(ctx, key, value, duration); err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}", "func (t *T) Set(key, value string) error {\n\tif _, err := t.file.WriteString(fmt.Sprintf(\"\\n%s,%s\", key, value)); err != nil {\n\t\treturn err\n\t}\n\tt.links[key] = value\n\treturn nil\n}", "func (o *Object) Set(key StringOrSymbol, val, receiver Value) Boolean {\n\tif p, ok := o.fields[key]; ok {\n\t\treturn p.Set()(val)\n\t}\n\treturn False\n}", "func (l *LocalStore) Set(ctx context.Context, key, data string) error {\n\tl.lock.Lock()\n\tl.store[key] = data\n\tl.lock.Unlock()\n\n\treturn nil\n}", "func (h Hash) Add(in string) bool {\n\tif _, ok := h[in]; ok {\n\t\t// already in the set\n\t\treturn false\n\t}\n\t// not in the set\n\th[in] = struct{}{}\n\treturn true\n}", "func (this HashFloat) Set(val float64) <-chan bool {\n\treturn BoolCommand(this.parent, this.args(\"hset\", ftoa(val))...)\n}", "func (s *server) Set(key string, value *string) error {\n\tres := make(chan error)\n\ts.ops <- func() {\n\t\ts.store[key] = value\n\t\tres <- nil\n\t}\n\treturn <-res\n}", "func (s *Storage) Set(key []byte, value []byte) error {\n\treturn s.SetWithTTL(key, value, 0)\n}", "func (mmAdd *mListRepositoryMockAdd) Set(f func(ip *net.IPNet) (b1 bool, err error)) *ListRepositoryMock {\n\tif mmAdd.defaultExpectation != nil {\n\t\tmmAdd.mock.t.Fatalf(\"Default expectation is already set for the ListRepository.Add method\")\n\t}\n\n\tif len(mmAdd.expectations) > 0 {\n\t\tmmAdd.mock.t.Fatalf(\"Some expectations are already set for the ListRepository.Add method\")\n\t}\n\n\tmmAdd.mock.funcAdd = f\n\treturn mmAdd.mock\n}", "func (sc *LoanMarketShareContract) Put(ctx contractapi.TransactionContextInterface, shareID int, titleholder string, amount float64, repayments float64, statutes string, rating float64, status string)\t(err error) {\n\n\tif shareID == 0 {\n\t\terr = errors.New(\"Loan Rating ID can not be empty\")\n\t\treturn\n\t}\n\t\n\tobj := new(LoanMarketShareObj)\n\tobj.ShareID = shareID\n\tobj.TitleHolder = titleholder\n\tobj.Amount = amount\n\tobj.Repayments = repayments\n\tobj.Statutes = statutes\n\tobj.Rating = rating\n\tobj.Status = status\n\t\n\n\tif obj.Created, err = GetTimestamp(ctx); err != nil {\n\t\treturn\n\t}\n\n\tif obj.Createdby, err = GetCallerID(ctx); err != nil {\n\t\treturn\n\t}\n\n\tkey := strconv.Itoa(shareID)\n\tobjBytes, _ := json.Marshal(obj)\t\n\terr = ctx.GetStub().PutState(key, []byte(objBytes))\n return \n}", "func (m *BoltMeta) Set(key, value []byte) error {\n\terr := m.DS.Update(func(tx *bolt.Tx) error {\n\t\tbucket, err := tx.CreateBucketIfNotExists(m.MetadataBucket)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = bucket.Put(key, value)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n\n\treturn err\n}", "func (session KeyValueSession) Set(key DatabaseKey, value interface{}) bool {\n\tbuffer := convertData(value)\n\tsession.store.tree.Set(key, buffer)\n\n\treturn true\n}", "func (m *Module) SetKeyIfNotExists(ctx context.Context, key, value string, t time.Duration) (bool, error) {\n\tm.lock.Lock()\n\tdefer m.lock.Unlock()\n\n\treturn m.client.SetNX(ctx, key, value, t).Result()\n}", "func (sfs *SafeFileSet) AddUnique(metahash [32]byte) (isNew bool) {\n\t_, notNew := sfs.filesSet.LoadOrStore(metahash, true)\n\treturn !notNew\n}", "func (s *SyncStorage) SetIf(ns string, key string, oldData, newData interface{}) (bool, error) {\n\treturn s.getDbBackend(ns).SetIE(getNsPrefix(ns)+key, oldData, newData)\n}", "func (v *Viper) Set(key string, value interface{}) bool {\n\treturn true\n}", "func (c *Cache) Add(key string, value []byte) bool {\n\tkh := c.hash64([]byte(key))\n\n\tc.mutex.Lock()\n\t_, addFail := c.chunkMap[kh]\n\n\tif addFail == false {\n\t\t// cache miss: we can write to the index of nextChunk\n\t\tchunk := c.nextChunk\n\t\t// this index will be changed -> update in-memory struct\n\t\toldMeta := c.metaMap[chunk]\n\t\tnewMeta := MetaEntry{Key: kh, Len: uint32(len(value)), Checksum: c.hash32(value)}\n\n\t\tc.replaceMeta(oldMeta.Key, newMeta, false)\n\n\t\tc.seekToData(chunk)\n\t\tbinary.Write(c.fh, binary.LittleEndian, value)\n\n\t\tc.nextChunk++\n\t\tif c.nextChunk >= c.chunkCount {\n\t\t\tc.nextChunk = 0 // overflowed -> next chunk shall be 0\n\t\t}\n\t}\n\tc.mutex.Unlock()\n\treturn !addFail\n}", "func (p *Pair) Set(fkey, fvalue string) bool {\n\tvar (\n\t\tidx int = -1\n\t)\n\n\tcomponents := strings.SplitN(p.Value, \",\", len(p.Format))\n\n\tif len(p.Format) == 0 {\n\t\treturn false\n\t}\n\tif len(components) != len(p.Format) {\n\t\treturn false\n\t}\n\n\tfor i, formatKey := range p.Format {\n\t\tif formatKey == fkey {\n\t\t\tidx = i\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif idx == -1 {\n\t\treturn false\n\t}\n\n\tif idx >= len(components) {\n\t\treturn false\n\t}\n\n\tcomponents[idx] = fvalue\n\n\tp.Value = strings.Join(components, \",\")\n\n\treturn true\n}", "func (s *Flaky) Set(k, v []byte) error {\n\tif s.fail() {\n\t\treturn s.err\n\t}\n\treturn s.Txn.Set(k, v)\n}", "func (s *StorageBase) Set(ctx context.Context, sessionId string, key string, value interface{}, ttl time.Duration) error {\n\treturn ErrorDisabled\n}", "func (m MockKeyring) Set(item keyring.Item) error {\n\treturn nil\n}", "func (bs *cachedFlatFsDataStore) Put(key string, value []byte) (err error) {\n\n\tbs.Lock()\n\tdefer bs.Unlock()\n\tif err = bs.dataStore.Put(key, value); err != nil {\n\t\tbs.cacheSet[key] = struct{}{}\n\t}\n\n\treturn err\n}", "func (s *TXPoolServer) setPendingTx(tx *tx.Transaction,\n\tsender tc.SenderType, txResultCh chan *tc.TxResult) bool {\n\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\tif ok := s.allPendingTxs[tx.Hash()]; ok != nil {\n\t\tlog.Debugf(\"setPendingTx: transaction %x already in the verifying process\",\n\t\t\ttx.Hash())\n\t\treturn false\n\t}\n\n\tpt := &serverPendingTx{\n\t\ttx: tx,\n\t\tsender: sender,\n\t\tch: txResultCh,\n\t}\n\n\ts.allPendingTxs[tx.Hash()] = pt\n\treturn true\n}", "func (mi *MasterIndex) addPending(id restic.ID, tpe restic.BlobType) bool {\n\n\tmi.idxMutex.Lock()\n\tdefer mi.idxMutex.Unlock()\n\n\t// Check if blob is pending or in index\n\tif mi.pendingBlobs.Has(restic.BlobHandle{ID: id, Type: tpe}) {\n\t\treturn false\n\t}\n\n\tfor _, idx := range mi.idx {\n\t\tif idx.Has(id, tpe) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// really not known -> insert\n\tmi.pendingBlobs.Insert(restic.BlobHandle{ID: id, Type: tpe})\n\treturn true\n}", "func (s UserSet) SetShare(value bool) {\n\ts.RecordCollection.Set(models.NewFieldName(\"Share\", \"share\"), value)\n}", "func (m *mCryptographyServiceMockVerify) Set(f func(p crypto.PublicKey, p1 insolar.Signature, p2 []byte) (r bool)) *CryptographyServiceMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.VerifyFunc = f\n\treturn m.mock\n}", "func (c *Conn) Set(key, value []byte) error {\n\tresponse := c.client.Cmd(cmdSet, key, value)\n\tif !isOK(response) {\n\t\treturn errx.Errorf(\"set command failed\")\n\t}\n\treturn nil\n}", "func (mmIssuePendingExecution *mDelegationTokenFactoryMockIssuePendingExecution) Set(f func(msg mm_insolar.Message, pulse mm_insolar.PulseNumber) (d1 mm_insolar.DelegationToken, err error)) *DelegationTokenFactoryMock {\n\tif mmIssuePendingExecution.defaultExpectation != nil {\n\t\tmmIssuePendingExecution.mock.t.Fatalf(\"Default expectation is already set for the DelegationTokenFactory.IssuePendingExecution method\")\n\t}\n\n\tif len(mmIssuePendingExecution.expectations) > 0 {\n\t\tmmIssuePendingExecution.mock.t.Fatalf(\"Some expectations are already set for the DelegationTokenFactory.IssuePendingExecution method\")\n\t}\n\n\tmmIssuePendingExecution.mock.funcIssuePendingExecution = f\n\treturn mmIssuePendingExecution.mock\n}", "func (https *FS) Has(ctx context.Context, path string) (bool, error) {\n\treturn false, nil\n}", "func (fr *FileRing) Contains(f File) bool {\n\tfr.lock.RLock()\n\tdefer fr.lock.RUnlock()\n\n\th := f.Id()\n\tif m, ok := fr.hashMap[h]; ok {\n\t\tfound, ok := m.versionMap[f.Sequence]\n\t\tif ok {\n\t\t\t// We have assumed till now that there are no hash cnoflicts. What if there is one?\n\t\t\t// Panic for now. Fix later :P\n\t\t\tif found.File != f.File {\n\t\t\t\tlog.Fatal(\"Hash conflict!\")\n\t\t\t}\n\t\t\tif found.AutoTombstone == false && f.AutoTombstone == true {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (p *peerContactsSet) put(peerContact string) bool {\n\tif len(peerContact) < 6 {\n\t\treturn false\n\t}\n\tif ok := p.set[peerContact]; ok {\n\t\treturn false\n\t}\n\tp.set[peerContact] = true\n\tr := &ring.Ring{Value: peerContact}\n\tif p.ring == nil {\n\t\tp.ring = r\n\t} else {\n\t\tp.ring.Link(r)\n\t}\n\treturn true\n}", "func (r *Connection) Set(key string, value []byte) error {\n\treturn r.cache.Set([]byte(key), value, r.expiry)\n}", "func (s *metadataSupplier) Set(key string, value string) {\n\ts.metadata.Set(key, value)\n}", "func (txn *Txn) Set(key, val []byte) error {\n\treturn txn.SetEntry(NewEntry(key, val))\n}", "func (mmEquals *mDigestHolderMockEquals) Set(f func(other DigestHolder) (b1 bool)) *DigestHolderMock {\n\tif mmEquals.defaultExpectation != nil {\n\t\tmmEquals.mock.t.Fatalf(\"Default expectation is already set for the DigestHolder.Equals method\")\n\t}\n\n\tif len(mmEquals.expectations) > 0 {\n\t\tmmEquals.mock.t.Fatalf(\"Some expectations are already set for the DigestHolder.Equals method\")\n\t}\n\n\tmmEquals.mock.funcEquals = f\n\treturn mmEquals.mock\n}", "func (lmem *lockedMemRepo) Put(name string, key types.KeyInfo) error {\n\tif err := lmem.checkToken(); err != nil {\n\t\treturn err\n\t}\n\tlmem.Lock()\n\tdefer lmem.Unlock()\n\n\t_, isThere := lmem.mem.keystore[name]\n\tif isThere {\n\t\treturn xerrors.Errorf(\"putting key '%s': %w\", name, types.ErrKeyExists)\n\t}\n\n\tlmem.mem.keystore[name] = key\n\treturn nil\n}", "func (c *concurrentStorage) add(u url.URL) (bool) {\n\tc.Lock()\n\tdefer c.Unlock()\n\tif _, ok := c.urls[u]; ok{\n\t\treturn false\n\t}\n\tc.urls[u] = true\n\tc.urlsSize++\n\treturn true\n}", "func (ts *TweetSearch) MarkTweetAsAlreadyTweeted(projectName string) (bool, error) {\n\tstorageConn := ts.Storage.Get()\n\tdefer storageConn.Close()\n\n\t// Generate score in format YYYYMMDDHHiiss\n\tnow := time.Now()\n\tscore := now.Format(\"20060102150405\")\n\n\tres, err := storageConn.MarkRepositoryAsTweeted(projectName, score)\n\tif err != nil || !res {\n\t\tlog.Printf(\"Adding project %s to tweeted list: ❌ s%s (%v)\\n\", projectName, err, res)\n\t}\n\n\treturn res, err\n}", "func (tsm *ThreadSafeMap) SetIfNotExists(key string, val interface{}) bool {\n\ttsm.Lock()\n\tdefer tsm.Unlock()\n\n\tif _, ok := tsm.items[key]; !ok {\n\t\ttsm.items[key] = val\n\t\treturn true\n\t}\n\treturn false\n}", "func (s *devStorage) setIfNot(imei string, dr devReq) bool {\n\ts.mux.Lock()\n\tdefer s.mux.Unlock()\n\tif _, ok := s.storage[imei]; ok {\n\t\treturn false\n\t}\n\ts.storage[imei] = dr\n\treturn true\n}", "func (a *Adapter) Set(key uint64, response []byte, expiration time.Time) {\n\ta.mutex.Lock()\n\tdefer a.mutex.Unlock()\n\n\tif _, ok := a.store[key]; ok {\n\t\t// Known key, overwrite previous item.\n\t\ta.store[key] = response\n\t\treturn\n\t}\n\n\t// New key, make sure we have the capacity.\n\tif len(a.store) == a.capacity {\n\t\ta.evict()\n\t}\n\n\ta.store[key] = response\n}", "func (b *BadgerDB) Set(key Key, value []byte) error {\n\tfullKey := append(key.Scope().Bytes(), key.ID()...)\n\n\terr := b.backend.Update(func(txn *badger.Txn) error {\n\t\treturn txn.Set(fullKey, value)\n\t})\n\n\treturn err\n}", "func (f *Flag) Set() { atomic.CompareAndSwapUint32((*uint32)(unsafe.Pointer(f)), 0, 1) }", "func (s *SyncStorage) Set(ns string, pairs ...interface{}) error {\n\tif len(pairs) == 0 {\n\t\treturn nil\n\t}\n\n\tkeyAndData, err := s.setNamespaceToKeys(getNsPrefix(ns), pairs...)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn s.getDbBackend(ns).MSet(keyAndData...)\n}", "func (c *FileSystemCache) Set(data []byte, expire time.Duration, key ...string) error {\n\tif len(key) < 1 {\n\t\treturn fmt.Errorf(\"no key specified\")\n\t}\n\tfolder := c.keyPath(key[:len(key)-1]...)\n\t_, err := os.Stat(folder)\n\tif os.IsNotExist(err) {\n\t\tos.MkdirAll(folder, 0700)\n\t}\n\tif expire > 0 {\n\t\texpireTS := time.Now().Add(expire).UnixNano()\n\t\terr := ioutil.WriteFile(c.expirePath(key...), []byte(strconv.FormatInt(expireTS, 10)), 0600)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn ioutil.WriteFile(c.keyPath(key...), data, 0600)\n}", "func (c *DetailsDB) Set(key, value []byte) error {\n\terr := c.db.Update(func(tx *bolt.Tx) error {\n\t\tbucket, err := tx.CreateBucketIfNotExists(c.bucket)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = bucket.Put(key, value)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n\n\treturn err\n}", "func (s Set) Add(st string) {\n\tif _, ok := s[st]; !ok {\n\t\ts[st] = true\n\t}\n}", "func (s *Set) Add(str string) bool {\n\tif s.Exist(str) {\n\t\treturn false\n\t}\n\ts.m[str] = struct{}{}\n\treturn false\n}", "func (l *ShardedNoTS) Set(tenantID, key string, val interface{}) error {\n\t_, ok := l.cache[tenantID]\n\tif !ok {\n\t\tl.cache[tenantID] = l.constructor()\n\t\tl.itemCount[tenantID] = 0\n\t}\n\n\tl.itemCount[tenantID]++\n\treturn l.cache[tenantID].Set(key, val)\n}", "func (s *Storage) Set(key string, value interface{}) {\n\ts.mu.Lock()\n\ts.data[key] = value\n\tctx, cancel := context.WithTimeout(context.Background(), s.timeout)\n\ts.cancelFuncs[key] = cancel\n\ts.mu.Unlock()\n\tgo func(ctx context.Context) {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\ts.mu.Lock()\n\t\t\tdelete(s.data, key)\n\t\t\tdelete(s.cancelFuncs, key)\n\t\t\ts.mu.Unlock()\n\t\t}\n\t}(ctx)\n}", "func (ss Set) Put(k string) {\n\tss[k] = true\n}", "func (self *Store) Set(k string) []byte {\n\tself.mu.Lock()\n\tself.mu.Unlock()\n\treturn nil\n}", "func (_m *DataStoreTxn) Set(key []byte, value []byte) error {\n\tret := _m.Called(key, value)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func([]byte, []byte) error); ok {\n\t\tr0 = rf(key, value)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func (h *hashDisk) Set(value []byte, fileIndex, fileOffset uint32) error {\n\tif bytes.Equal(value, h.emptyValue) {\n\t\treturn ErrInvalidKey\n\t}\n\tif h.totalEntries >= h.MaxSize {\n\t\treturn ErrNoSpace\n\t}\n\tnewEntry := true\n\t// Compute hash\n\tslot := hyperloglog.MurmurBytes(value) % h.entries\n\toffset := slot * h.entrySize\n\tfor { // Try to find an empty slot\n\t\tslotValue := h.m[offset : offset+keySize]\n\t\tif bytes.Equal(slotValue, value) {\n\t\t\t// Found same key, override. We could just return instead but it was found in\n\t\t\t// benchmarks that it hardly change anything at all so it's better to be able to override\n\t\t\tnewEntry = false\n\t\t\tbreak\n\t\t}\n\t\tif bytes.Equal(slotValue, h.emptyValue) {\n\t\t\t// Found empty slot\n\t\t\tbreak\n\t\t}\n\t\tslot = (slot + 1) % h.entries\n\t\toffset = slot * h.entrySize\n\t}\n\t// Insert\n\tindexes := make([]byte, 4+4)\n\tencoding.PutUint32(indexes[0:4], fileIndex)\n\tencoding.PutUint32(indexes[4:8], fileOffset)\n\tcopy(h.m[offset:offset+keySize], value)\n\tcopy(h.m[offset+keySize:offset+keySize+8], indexes)\n\tif newEntry {\n\t\th.totalEntries++\n\t}\n\treturn nil\n}", "func (f File) Set(groupName string, group HostGroup) {\n\tf[groupName] = group\n}", "func (that *StrAnyMap) SetIfNotExist(key string, value interface{}) bool {\n\tif !that.Contains(key) {\n\t\tthat.doSetWithLockCheck(key, value)\n\t\treturn true\n\t}\n\treturn false\n}", "func (o *PtNaturalBcs) Set(key string, nod *Node, fcn fun.Func, extra string) (setisok bool) {\n\td := nod.GetDof(key)\n\tif d == nil { // handle LBB nodes\n\t\treturn\n\t}\n\tif idx, ok := o.Eq2idx[d.Eq]; ok {\n\t\to.Bcs[idx].Key = \"f\" + key\n\t\to.Bcs[idx].Eq = d.Eq\n\t\to.Bcs[idx].X = nod.Vert.C\n\t\to.Bcs[idx].Fcn = fcn\n\t\to.Bcs[idx].Extra = extra\n\t} else {\n\t\to.Eq2idx[d.Eq] = len(o.Bcs)\n\t\to.Bcs = append(o.Bcs, &PtNaturalBc{\"f\" + key, d.Eq, nod.Vert.C, fcn, extra})\n\t}\n\treturn true\n}", "func (c *cache) Set(id types.UID, status *PodStatus, err error, timestamp time.Time) (updated bool) {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\n\tif utilfeature.DefaultFeatureGate.Enabled(features.EventedPLEG) {\n\t\t// Set the value in the cache only if it's not present already\n\t\t// or the timestamp in the cache is older than the current update timestamp\n\t\tif cachedVal, ok := c.pods[id]; ok && cachedVal.modified.After(timestamp) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tc.pods[id] = &data{status: status, err: err, modified: timestamp}\n\tc.notify(id, timestamp)\n\treturn true\n}", "func (o *FileversionFileversion) HasPendingFileRef() bool {\n\tif o != nil && o.PendingFileRef != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (q *UniqueQueue) Enqueue(key string, val interface{}) bool {\n\tq.mu.Lock()\n\tdefer q.mu.Unlock()\n\n\tif q.doneChanClosed {\n\t\treturn false\n\t}\n\n\t// Key is already in the queue. Update the set's entry and\n\t// return without modifying its place in the queue.\n\tif entry, ok := q.queuedSet[key]; ok {\n\t\tentry.val = val\n\t\treturn true\n\t}\n\n\tif q.full() {\n\t\treturn false\n\t}\n\n\tq.queue[q.tail] = entry{\n\t\tkey: key,\n\t\tval: val,\n\t}\n\tq.queuedSet[key] = &q.queue[q.tail]\n\tq.tail = q.inc(q.tail)\n\n\tq.trySchedule()\n\n\treturn true\n}", "func (userdata *User) ShareFile(filename string, recipient string) (\r\n\taccessToken uuid.UUID, err error) {\r\n\tvar shareInvite ShareInvite\r\n\tvar fileKeyMeta FileKeyMeta\r\n\t//IMPLEMENT SHAREDUSERS AND USERTOKENS in FILEKEYSTRUCT\r\n\r\n\t//check is file exists in users file space\r\n\tupdatedUser, err := GetLatestUser(userdata.UUID_, userdata.PasswordHash, userdata.HMACKey, userdata.EncKey)\r\n\tif err != nil {\r\n\t\treturn uuid.Nil, errors.New(\"Failed to retrieve latest user info.\")\r\n\t}\r\n\r\n\tvar fk FileKey\r\n\tfileKey, fileFound := updatedUser.Filespace[filename]\r\n\r\n\tif !fileFound {\r\n\t\treturn uuid.Nil, errors.New(\"File does not exist in caller's personal filespace.\")\r\n\t}\r\n\r\n\t//what if this person is sharing a shared file? check access token!\r\n\t_, own := updatedUser.FilesOwned[filename]\r\n\tif !own { //this is just in case a revocation has happened and the fileKey data has changed\r\n\t\tat := userdata.AccessTokens[filename]\r\n\t\tfk, err = updatedUser.RetrieveAccessToken(at)\r\n\t\tif err != nil {\r\n\t\t\treturn uuid.Nil, errors.New(\"Failed to retrieve access token.\")\r\n\t\t}\r\n\t} else { //just in case fileKey data has changed from a recent session\r\n\t\tcurrFileKey, _ := userlib.DatastoreGet(fileKey.KeyId)\r\n\t\tlen_data := len(currFileKey) - userlib.HashSizeBytes\r\n\r\n\t\tif len_data < 0 || len_data > len(currFileKey) || len(currFileKey[:len_data]) < userlib.HashSizeBytes {\r\n\t\t\t//automatically return error, file has been changed\r\n\t\t\treturn uuid.Nil, errors.New(\"FileKey data length has changed.\")\r\n\t\t}\r\n\t\t//verify integrity of both fileKey struct and the file itself\r\n\t\tcomputedMac, _ := userlib.HMACEval(fileKey.HMAC_key, currFileKey[:len_data])\r\n\t\tif !userlib.HMACEqual(computedMac, currFileKey[len_data:]) {\r\n\t\t\treturn uuid.Nil, errors.New(\"File key struct has been tampered with in Datastore.\")\r\n\t\t}\r\n\t\t//decrypt + depad fileKey from DS to current fileKey var (overwrite)\r\n\t\tdecrypt := userlib.SymDec(fileKey.Enc_key, currFileKey[:len_data])\r\n\t\tdecrypt = PKCS(decrypt, \"remove\")\r\n\r\n\t\terr = json.Unmarshal(decrypt, &fk)\r\n\t\tif err != nil {\r\n\t\t\treturn uuid.Nil, errors.New(\"Error demarshaling.\")\r\n\t\t}\r\n\t}\r\n\r\n\t//check if recipient exists\r\n\tpubKey, userFound := userlib.KeystoreGet(recipient + \"public_key\")\r\n\tif !userFound {\r\n\t\treturn uuid.Nil, errors.New(\"Recepient not found.\")\r\n\t}\r\n\r\n\t//populate Shareinvite and FileKeyMeta struct\r\n\tfileKeyMeta.DSid = fk.KeyId\r\n\tfileKeyMeta.HMACkey = fk.HMAC_key\r\n\tfileKeyMeta.ENCkey = fk.Enc_key\r\n\r\n\tfkm_json, _ := json.Marshal(fileKeyMeta)\r\n\t//encrypt FileKeyMeta using RSA\r\n\tfileKeyMeta_enc, _ := userlib.PKEEnc(pubKey, fkm_json) //dont need to pad?\r\n\r\n\t//Marshal the fileKeyMeta info\r\n\tshareInvite.RSAFileKey = fileKeyMeta_enc\r\n\t//msg for signature is the RSA encrypted, MARSHALED FileMetaKey struct\r\n\tshareInvite.Signature, _ = userlib.DSSign(userdata.PrivSignKey, shareInvite.RSAFileKey)\r\n\tshareInvite.Sender = updatedUser.Username\r\n\tshareInvite_json, _ := json.Marshal(shareInvite)\r\n\r\n\taccessToken = uuid.New() //generate random accessToken\r\n\tuserlib.DatastoreSet(accessToken, shareInvite_json)\r\n\r\n\t//update SharedUsers and UserTokens fields in fileKey\r\n\t//if they are a DIRECT sharer (meaning theyre one level below owner) generate key\r\n\t//and put recipient in their list\r\n\t//else, put them under the direct sharer from their lineage\r\n\tfk.UserTokens[recipient] = accessToken //update user tokens for possible revoking later\r\n\tlist, direct_user := fk.SharedUsers[updatedUser.Username] //should return true if user is a key\r\n\tif own {\r\n\t\tvar emptyList []string\r\n\t\tfk.SharedUsers[recipient] = emptyList\r\n\t} else if direct_user {\r\n\t\tlist = append(list, recipient) //add recipient to direct sharer's list\r\n\t\tfk.SharedUsers[recipient] = list\r\n\t} else { //indirect user case, iterate over map of shared users\r\n\t\tvar originalSharer string\r\n\t\t//provides each key and respective value\r\n\t\tfor directSharer, listShared := range fk.SharedUsers {\r\n\t\t\tfor _, indirectSharer := range listShared {\r\n\t\t\t\tif updatedUser.Username == indirectSharer {\r\n\t\t\t\t\toriginalSharer = directSharer\r\n\t\t\t\t\tbreak\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif originalSharer != \"\" {\r\n\t\t\t\tbreak //break out of second for loop if you've found the original sharer\r\n\t\t\t}\r\n\t\t}\r\n\t\tif originalSharer == \"\" {\r\n\t\t\treturn uuid.Nil, errors.New(\"User is not owner but could not find who shared file with them.\")\r\n\t\t}\r\n\t\tlist = append(list, recipient)\r\n\t\tfk.SharedUsers[originalSharer] = list //add the recipient of this indirect user to list\r\n\t}\r\n\t//Now lets send the updated fileKey to the Datastore\r\n\tfileKey_json, _ := json.Marshal(fk)\r\n\tfk_IV := userlib.RandomBytes(userlib.AESBlockSizeBytes)\r\n\tfileKey_enc := userlib.SymEnc(fk.Enc_key, fk_IV, PKCS(fileKey_json, \"add\"))\r\n\t//Add HMACs for both file key and file elem struct (runtime corresponds to size of appended file, nothing else)\r\n\tfk_hmac, _ := userlib.HMACEval(fk.HMAC_key, fileKey_enc)\r\n\tfileKey_enc = append(fileKey_enc, fk_hmac...)\r\n\tuserlib.DatastoreSet(fileKey.KeyId, fileKey_enc)\r\n\r\n\treturn accessToken, nil\r\n}", "func (s BlobSet) Has(h BlobHandle) bool {\n\t_, ok := s[h]\n\treturn ok\n}", "func (self *SafeMap) Set(k interface{}, v interface{}) bool {\n\tself.lock.Lock()\n\tdefer self.lock.Unlock()\n\n\tif val, ok := self.sm[k]; !ok {\n\t\tself.sm[k] = v\n\t} else if val != v {\n\t\tself.sm[k] = v\n\t} else {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func (b *Bloom) AddExisted(value string) bool {\n\texisted := true\n\tfor i := 0; i < len(b.keys); i++ {\n\t\thash := SipHash24([]byte(value), b.keys[i]) % b.size\n\t\tif !b.get(hash) {\n\t\t\texisted = false\n\t\t}\n\t\tb.set(hash)\n\t}\n\treturn existed\n}", "func ShareFiles(w http.ResponseWriter, r *http.Request) {\n\t//log\n\tnow, userIP := globalPkg.SetLogObj(r)\n\tlogobj := logpkg.LogStruct{\"_\", now, userIP, \"macAdress\", \"ShareFiles\", \"file\", \"_\", \"_\", \"_\", 0}\n\tvar ShareFiledataObj ShareFiledata\n\tdecoder := json.NewDecoder(r.Body)\n\tdecoder.DisallowUnknownFields()\n\terr := decoder.Decode(&ShareFiledataObj)\n\tif err != nil {\n\t\tglobalPkg.SendError(w, \"please enter your correct request\")\n\t\tglobalPkg.WriteLog(logobj, \"please enter your correct request\", \"failed\")\n\t\treturn\n\t}\n\ttime.Sleep(time.Millisecond * 10) // for handle unknown issue\n\taccountObj := account.GetAccountByAccountPubicKey(ShareFiledataObj.Publickey)\n\tif accountObj.AccountPublicKey != ShareFiledataObj.Publickey {\n\t\tglobalPkg.SendError(w, \"error in public key\")\n\t\tglobalPkg.WriteLog(logobj, \"error in public key\", \"failed\")\n\t\treturn\n\t}\n\tif accountObj.AccountPassword != ShareFiledataObj.Password {\n\t\tglobalPkg.SendError(w, \"error in password\")\n\t\tglobalPkg.WriteLog(logobj, \"error in password\", \"failed\")\n\t\treturn\n\t}\n\t// check user own this file id\n\tfiles := accountObj.Filelist\n\tfound := false\n\tfor _, fileObj := range files {\n\t\tif fileObj.Fileid == ShareFiledataObj.FileID {\n\t\t\tfound = true\n\t\t}\n\t}\n\tif !found {\n\t\tglobalPkg.SendError(w, \"You don't have this file\")\n\t\tglobalPkg.WriteLog(logobj, \"You don't have this file\", \"failed\")\n\t\treturn\n\t}\n\t// check pk already exist in blockchain\n\taccountList := accountdb.GetAllAccounts()\n\tfor _, pk := range ShareFiledataObj.PermissionPkList {\n\t\tif !containspk(accountList, pk) {\n\t\t\tglobalPkg.SendError(w, \"this public key is not associated with any account\")\n\t\t\tglobalPkg.WriteLog(logobj, \"You don't have this file\", \"failed\")\n\t\t\treturn\n\t\t}\n\t}\n\t// Signture string\n\tvalidSig := false\n\tpk1 := account.FindpkByAddress(accountObj.AccountPublicKey).Publickey\n\tif pk1 != \"\" {\n\t\tpublickey1 := cryptogrpghy.ParsePEMtoRSApublicKey(pk1)\n\t\tstrpermissionlist := strings.Join(ShareFiledataObj.PermissionPkList, \"\")\n\t\tfmt.Println(\"strpermissionlist : \", strpermissionlist)\n\t\tsignatureData := strpermissionlist + ShareFiledataObj.FileID + ShareFiledataObj.Publickey\n\t\tvalidSig = cryptogrpghy.VerifyPKCS1v15(ShareFiledataObj.Signture, signatureData, *publickey1)\n\t} else {\n\t\tvalidSig = false\n\t}\n\t// validSig = true\n\tif !validSig {\n\t\tglobalPkg.SendError(w, \"you are not allowed to share file\")\n\t\tglobalPkg.WriteLog(logobj, \"you are not allowed to share file\", \"failed\")\n\t\treturn\n\t}\n\t//\n\n\tfilelistOwner := accountObj.Filelist\n\t// add account index see file , ownerpk , fileid\n\t//append share file id , ownerpk to account index want to share file to you\n\tfor _, pk := range ShareFiledataObj.PermissionPkList {\n\t\tvar sharedfileObj filestorage.SharedFile\n\t\tvar ownerfileObj filestorage.OwnersharedFile\n\t\tvar ownerfileObj2 filestorage.OwnersharedFile\n\t\tvar foundOwnerpk bool\n\t\taccountind := account.GetAccountByAccountPubicKey(pk)\n\t\tsharedfileObj.AccountIndex = accountind.AccountIndex\n\t\townedsharefile := filestorage.FindSharedfileByAccountIndex(sharedfileObj.AccountIndex)\n\t\tif pk != ShareFiledataObj.Publickey { //same owner share to himself\n\t\t\tif len(ownedsharefile.OwnerSharefile) != 0 {\n\t\t\t\tfor _, ownedsharefileObj := range ownedsharefile.OwnerSharefile {\n\n\t\t\t\t\tif ownedsharefileObj.OwnerPublicKey == ShareFiledataObj.Publickey {\n\t\t\t\t\t\tfoundOwnerpk = true\n\t\t\t\t\t\tif !containsfileid(ownedsharefileObj.Fileid, ShareFiledataObj.FileID) {\n\t\t\t\t\t\t\townedsharefileObj.Fileid = append(ownedsharefileObj.Fileid, ShareFiledataObj.FileID)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tsharedfileObj.OwnerSharefile = append(sharedfileObj.OwnerSharefile, ownedsharefileObj)\n\t\t\t\t}\n\t\t\t\tif !foundOwnerpk {\n\t\t\t\t\townerfileObj2.OwnerPublicKey = ShareFiledataObj.Publickey\n\t\t\t\t\townerfileObj2.Fileid = append(ownerfileObj2.Fileid, ShareFiledataObj.FileID)\n\t\t\t\t\tsharedfileObj.OwnerSharefile = append(sharedfileObj.OwnerSharefile, ownerfileObj2)\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\townerfileObj.OwnerPublicKey = ShareFiledataObj.Publickey\n\t\t\t\townerfileObj.Fileid = append(ownerfileObj.Fileid, ShareFiledataObj.FileID)\n\t\t\t\tsharedfileObj.OwnerSharefile = append(sharedfileObj.OwnerSharefile, ownerfileObj)\n\t\t\t}\n\t\t\tbroadcastTcp.BoardcastingTCP(sharedfileObj, \"sharefile\", \"file\")\n\t\t\t//append permisssionlist to account owner filelist\n\t\t\tfor m := range filelistOwner {\n\t\t\t\tif filelistOwner[m].Fileid == ShareFiledataObj.FileID {\n\t\t\t\t\tif !containsfileid(filelistOwner[m].PermissionList, pk) {\n\t\t\t\t\t\tfilelistOwner[m].PermissionList = append(filelistOwner[m].PermissionList, pk)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\taccountObj.Filelist = filelistOwner\n\tbroadcastTcp.BoardcastingTCP(accountObj, \"updateaccountFilelist\", \"file\")\n\n\tglobalPkg.SendResponseMessage(w, \"you shared file successfully\")\n\tglobalPkg.WriteLog(logobj, \"you shared file successfully\", \"success\")\n}", "func (s *OrderedRequestBodies) Set(key string, val *RequestBody) bool {\n\treturn s.data.Set(key, val)\n}" ]
[ "0.56819904", "0.5656244", "0.56193894", "0.5489106", "0.547759", "0.5415303", "0.5358624", "0.5329123", "0.5298075", "0.5251422", "0.5236577", "0.518625", "0.51822776", "0.51691777", "0.51528174", "0.5129096", "0.5112244", "0.5102831", "0.5098065", "0.5075395", "0.5075193", "0.5069218", "0.50587875", "0.50115156", "0.50058746", "0.49935445", "0.49846864", "0.4969345", "0.4963284", "0.4958479", "0.49434528", "0.49427998", "0.49327493", "0.49325326", "0.49287853", "0.4912423", "0.49069577", "0.48915246", "0.48909193", "0.48884398", "0.48815522", "0.48809186", "0.48790106", "0.4873914", "0.48673648", "0.48570365", "0.48534843", "0.48378074", "0.48351842", "0.48254824", "0.48254266", "0.48142982", "0.4812445", "0.48069984", "0.48056346", "0.48041052", "0.47874373", "0.47744697", "0.4773371", "0.47695345", "0.4761128", "0.47582212", "0.47570246", "0.47510725", "0.47437623", "0.47336155", "0.47332895", "0.47312617", "0.47295195", "0.47254533", "0.47162998", "0.4701438", "0.46996418", "0.4693732", "0.46876216", "0.46843454", "0.46841013", "0.46839523", "0.4683913", "0.46813342", "0.46796092", "0.4678921", "0.46763113", "0.4664546", "0.46639284", "0.46620402", "0.46354783", "0.46354", "0.46339247", "0.46329728", "0.463194", "0.4631577", "0.4631392", "0.4629464", "0.46242055", "0.4623186", "0.46225983", "0.4618754", "0.46157706", "0.4614538" ]
0.85217196
0
Env returns Environment associated with Expect instance. Tests can use it to store arbitrary data. Example: e := httpexpect.Default(t, " e.Env().Put("key", "value") value := e.Env().GetString("key")
Env возвращает среду, связанную с экземпляром Expect. Тесты могут использовать её для хранения произвольных данных. Пример: e := httpexpect.Default(t, " e.Env().Put("key", "value") value := e.Env().GetString("key")
func (e *Expect) Env() *Environment { return e.chain.env() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Env(env string) (value []byte, err error) {\n\tvalue, err = exec.Command(\"go\", \"env\", env).Output()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvalue = bytes.TrimSpace(value)\n\n\tif len(value) == 0 {\n\t\terr = ErrEmptyEnv{env}\n\t}\n\n\treturn\n}", "func (envManager *TestEnvManager) GetEnv() TestEnv {\n\treturn envManager.testEnv\n}", "func (e *echo) Env(val string) *echo {\n\tvars := e.declareVars(val)\n\tfor k, v := range vars {\n\t\tif err := os.Setenv(k, v); err != nil {\n\t\t\te.shouldPanic(err.Error())\n\t\t} else {\n\t\t\tdelete(e.vars, k) // overwrite local var\n\t\t}\n\t}\n\treturn e\n}", "func Env() *Environment {\n\tonce.Do(func() {\n\t\te = &Environment{}\n\t})\n\treturn e\n}", "func (b *Executable) Env(arg, value string) *Executable {\n\tif b.Environment == nil {\n\t\tb.Environment = make(map[string]string)\n\t}\n\tb.Environment[arg] = value\n\treturn b\n}", "func (suite *Suite[Env]) Env() *Env {\n\tif suite.env == nil || !suite.isUpdateEnvCalledInThisTest {\n\t\tsuite.UpdateEnv(suite.defaultStackDef)\n\t}\n\treturn suite.env\n}", "func GetENV(experimentDetails *experimentTypes.ExperimentDetails) {\n\texperimentDetails.ExperimentName = Getenv(\"EXPERIMENT_NAME\", \"\")\n\texperimentDetails.AppNS = Getenv(\"APP_NS\", \"\")\n\texperimentDetails.TargetContainer = Getenv(\"APP_CONTAINER\", \"\")\n\texperimentDetails.TargetPods = Getenv(\"APP_POD\", \"\")\n\texperimentDetails.AppLabel = Getenv(\"APP_LABEL\", \"\")\n\texperimentDetails.ChaosDuration, _ = strconv.Atoi(Getenv(\"TOTAL_CHAOS_DURATION\", \"30\"))\n\texperimentDetails.ChaosNamespace = Getenv(\"CHAOS_NAMESPACE\", \"litmus\")\n\texperimentDetails.EngineName = Getenv(\"CHAOS_ENGINE\", \"\")\n\texperimentDetails.ChaosUID = clientTypes.UID(Getenv(\"CHAOS_UID\", \"\"))\n\texperimentDetails.ChaosPodName = Getenv(\"POD_NAME\", \"\")\n\texperimentDetails.ContainerRuntime = Getenv(\"CONTAINER_RUNTIME\", \"\")\n\texperimentDetails.NetworkInterface = Getenv(\"NETWORK_INTERFACE\", \"eth0\")\n\texperimentDetails.TargetIPs = Getenv(\"TARGET_IPs\", \"\")\n}", "func (cmd Cmd) Env(env *Env) Cmd {\n\tcmd.Environment = env\n\treturn cmd\n}", "func Env(env Environ) func(*Runner) error {\n\treturn func(r *Runner) error {\n\t\tif env == nil {\n\t\t\tenv, _ = EnvFromList(os.Environ())\n\t\t}\n\t\tr.Env = env\n\t\treturn nil\n\t}\n}", "func getTestEnv() *Env {\n\tdb := createMockDB()\n\n\toauthConf := &oauth2.Config{\n\t\tClientID: \"abcdef0123abcdef4567\",\n\t\tClientSecret: \"abcdef0123abcdef4567abcdef8901abcdef2345\",\n\t\tScopes: []string{\"user:email\"},\n\t\tEndpoint: githuboauth.Endpoint,\n\t}\n\n\tenv := &Env{\n\t\tdb: db,\n\t\tjwtSecretKey: \"keyForTesting\",\n\t\toauthConf: oauthConf,\n\t\toauthState: \"nonRandomStateString\",\n\t}\n\treturn env\n}", "func NewEnv(t *testing.T) *Env {\n\treturn &Env{t, make(chan struct{}), sync.Mutex{}, make([]string, 0)}\n}", "func (s RunSpec) GetEnv() (env []string) {\n\tif s.Environment == nil {\n\t\ts.Environment = make(map[string]string)\n\t}\n\n\ts.Environment[\"RANNA_HOSTDIR\"] = s.HostDir\n\n\tenv = make([]string, len(s.Environment))\n\ti := 0\n\tfor k, v := range s.Environment {\n\t\tenv[i] = fmt.Sprintf(`%s=%s`, k, v)\n\t\ti++\n\t}\n\n\treturn\n}", "func GetEnv() Environment {\n\treturn sharedEnv\n}", "func Env() EnvType {\n\treturn env.Load().(EnvType)\n}", "func (app *Application) GetEnv() string {\n return app.env\n}", "func GetEnv() string {\n\tenv := os.Getenv(\"ENV\")\n\tif len(env) == 0 {\n\t\treturn TestEnv\n\t}\n\n\treturn env\n}", "func (ci MrbCallInfo) Env() REnv {\n\treturn REnv{C.mrb_vm_ci_env(ci.p), nil}\n}", "func (p RProc) Env() REnv {\n\tif !p.HasEnv() {\n\t\treturn REnv{nil, p.mrb}\n\t}\n\treturn REnv{C._MRB_PROC_ENV(p.p), p.mrb}\n}", "func FakeEnv() Env {\n\treturn NewScope(nil)\n}", "func InjectEnv() env.Env {\n\twire.Build(\n\t\twire.Bind(new(env.Env), new(env.GoDotEnv)),\n\t\tenv.NewGoDotEnv,\n\t)\n\treturn env.GoDotEnv{}\n}", "func Env() string {\n\tr := Get(\"ENV\")\n\tif r != Dev && r != Test && r != Acc && r != Prod {\n\t\tr = Dev\n\t}\n\treturn r\n}", "func (c *Context) Env() map[string]string {\n\treturn c.env\n}", "func NewExpectWithEnv(name string, args []string, env []string, serverProcessConfigName string) (ep *ExpectProcess, err error) {\n\tep = &ExpectProcess{\n\t\tcfg: expectConfig{\n\t\t\tname: serverProcessConfigName,\n\t\t\tcmd: name,\n\t\t\targs: args,\n\t\t\tenv: env,\n\t\t},\n\t\treadCloseCh: make(chan struct{}),\n\t}\n\tep.cmd = commandFromConfig(ep.cfg)\n\n\tif ep.fpty, err = pty.Start(ep.cmd); err != nil {\n\t\treturn nil, err\n\t}\n\n\tep.wg.Add(2)\n\tgo ep.read()\n\tgo ep.waitSaveExitErr()\n\treturn ep, nil\n}", "func Env(env ...string) string {\n\tvar returnVar string\n\tif len(env) == 0 {\n\t\tlogger.Error(\" env number is zero\")\n\t\treturn \"\"\n\t}\n\tfor i := 0; i < len(env); i++ {\n\t\tif returnVar == \"\" {\n\t\t\treturnVar = os.Getenv(env[i])\n\t\t} else {\n\t\t\treturn returnVar\n\t\t}\n\t}\n\treturn returnVar\n}", "func Env(name string) string {\n\treturn os.Getenv(name)\n}", "func (p *Process) Env() map[string]string {\n\treturn static.CopyStringMap(p.Builder.Env)\n}", "func (cb *clientBase) GetEnv() string {\n\treturn cb.env\n}", "func (env *Environment) Get() interface{} {\n\treturn *env\n}", "func (c *LocalCmd) Env(env ...string) *LocalCmd {\n\tc.env = env\n\treturn c\n}", "func Env(key string) EnvVars {\n\treturn EnvVars{\n\t\tKey: key,\n\t}\n}", "func (o BuildSpecRuntimePtrOutput) Env() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v *BuildSpecRuntime) map[string]string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Env\n\t}).(pulumi.StringMapOutput)\n}", "func GetEnv(name string, defaultValue string) string {\n\tif strVal, ok := os.LookupEnv(name); ok && len(strVal) > 0 {\n\t\treturn strVal\n\t}\n\n\treturn defaultValue\n}", "func (h *Helpers) Env(s string) string {\n\ts = strings.ToUpper(s)\n\tif v, ok := os.LookupEnv(s); ok {\n\t\treturn v\n\t}\n\n\treturn \"\"\n}", "func NewEnv() Env {\n\tenv := Env{}\n\tenv.LoadEnv()\n\treturn env\n}", "func (dir EnvDir) Env(secrets map[string]string, _ tpl.SecretReader) (map[string]string, error) {\n\treturn dir, nil\n}", "func (t *TestContext) Environment() environment.Implementation {\n\treturn t.impl\n}", "func GetENV() string {\n\tif env == \"\" {\n\t\treturn Dev\n\t}\n\treturn env\n}", "func NewEnv() (*Env, error) {\n\tctx := context.Background()\n\tdomainID := fmt.Sprintf(\"domain %d\", rand.Int()) // nolint: gas\n\tdb, err := testdb.New(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"env: failed to open database: %v\", err)\n\t}\n\n\t// Map server\n\tmapEnv, err := maptest.NewMapEnv(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"env: failed to create trillian map server: %v\", err)\n\t}\n\n\ttlog := fake.NewTrillianLogClient()\n\n\t// Configure domain, which creates new map and log trees.\n\tdomainStorage, err := domain.NewStorage(db)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"env: failed to create domain storage: %v\", err)\n\t}\n\tadminSvr := adminserver.New(tlog, mapEnv.Map, mapEnv.Admin, mapEnv.Admin, domainStorage, vrfKeyGen)\n\tdomainPB, err := adminSvr.CreateDomain(ctx, &pb.CreateDomainRequest{\n\t\tDomainId: domainID,\n\t\tMinInterval: ptypes.DurationProto(1 * time.Second),\n\t\tMaxInterval: ptypes.DurationProto(5 * time.Second),\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"env: CreateDomain(): %v\", err)\n\t}\n\n\tmapID := domainPB.Map.TreeId\n\tlogID := domainPB.Log.TreeId\n\tmapPubKey, err := der.UnmarshalPublicKey(domainPB.Map.GetPublicKey().GetDer())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"env: Failed to load signing keypair: %v\", err)\n\t}\n\tvrfPub, err := p256.NewVRFVerifierFromRawKey(domainPB.Vrf.GetDer())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"env: Failed to load vrf pubkey: %v\", err)\n\t}\n\n\t// Common data structures.\n\tmutations, err := mutationstorage.New(db)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"env: Failed to create mutations object: %v\", err)\n\t}\n\tauth := authentication.NewFake()\n\tauthz := authorization.New()\n\n\tqueue := mutator.MutationQueue(mutations)\n\tserver := keyserver.New(tlog, mapEnv.Map, mapEnv.Admin, mapEnv.Admin,\n\t\tentry.New(), auth, authz, domainStorage, queue, mutations)\n\tgsvr := grpc.NewServer()\n\tpb.RegisterKeyTransparencyServer(gsvr, server)\n\n\t// Sequencer\n\tseq := sequencer.New(tlog, mapEnv.Map, entry.New(), domainStorage, mutations, queue)\n\t// Only sequence when explicitly asked with receiver.Flush()\n\td := &domaindef.Domain{\n\t\tDomainID: domainID,\n\t\tLogID: logID,\n\t\tMapID: mapID,\n\t}\n\treceiver := seq.NewReceiver(ctx, d, 60*time.Hour, 60*time.Hour)\n\treceiver.Flush(ctx)\n\n\taddr, lis, err := Listen()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tgo gsvr.Serve(lis)\n\n\t// Client\n\tcc, err := grpc.Dial(addr, grpc.WithInsecure())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Dial(%v) = %v\", addr, err)\n\t}\n\tktClient := pb.NewKeyTransparencyClient(cc)\n\tclient := grpcc.New(ktClient, domainID, vrfPub, mapPubKey, coniks.Default, fake.NewFakeTrillianLogVerifier())\n\tclient.RetryCount = 0\n\n\treturn &Env{\n\t\tEnv: &integration.Env{\n\t\t\tClient: client,\n\t\t\tCli: ktClient,\n\t\t\tDomain: domainPB,\n\t\t\tReceiver: receiver,\n\t\t},\n\t\tmapEnv: mapEnv,\n\t\tgrpcServer: gsvr,\n\t\tgrpcCC: cc,\n\t\tdb: db,\n\t}, nil\n}", "func (p RProc) EnvGet(i int) Value {\n\tif !p.HasEnv() {\n\t\treturn nilValue\n\t}\n\treturn p.mrb.ProcCFuncEnvGet(i)\n}", "func (s *EnvironmentsServiceOp) Get(env string) (*Environment, *Response, error) {\n\tpath := path.Join(environmentsPath, env)\n\treq, e := s.client.NewRequest(\"GET\", path, nil)\n\tif e != nil {\n\t\treturn nil, nil, e\n\t}\n\treturnedEnv := Environment{}\n\tresp, e := s.client.Do(req, &returnedEnv)\n\tif e != nil {\n\t\treturn nil, resp, e\n\t}\n\treturn &returnedEnv, resp, e\n}", "func SetEnv(e EnvType) {\n\tif e == EnvTypeDev ||\n\t\te == EnvTypeProd ||\n\t\te == EnvTypeTest {\n\t\tenv.Store(e)\n\t}\n}", "func (o StorageClusterSpecStorkPtrOutput) Env() StorageClusterSpecStorkEnvArrayOutput {\n\treturn o.ApplyT(func(v *StorageClusterSpecStork) []StorageClusterSpecStorkEnv {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Env\n\t}).(StorageClusterSpecStorkEnvArrayOutput)\n}", "func (b *taskBuilder) env(key, value string) {\n\tif b.Spec.Environment == nil {\n\t\tb.Spec.Environment = map[string]string{}\n\t}\n\tb.Spec.Environment[key] = value\n}", "func (o BuildSpecRuntimeOutput) Env() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v BuildSpecRuntime) map[string]string { return v.Env }).(pulumi.StringMapOutput)\n}", "func (o StorageClusterSpecStorkOutput) Env() StorageClusterSpecStorkEnvArrayOutput {\n\treturn o.ApplyT(func(v StorageClusterSpecStork) []StorageClusterSpecStorkEnv { return v.Env }).(StorageClusterSpecStorkEnvArrayOutput)\n}", "func (lkp OsEnvVariableLookuper) GetEnv(envVarName string) string {\n\tif TestingEnvVariableLookup != nil {\n\t\treturn TestingEnvVariableLookup.GetEnv(envVarName)\n\t}\n\n\treturn GetEnv(envVarName)\n}", "func TestEnvironmentGet(t *testing.T) {\n\tport := make(chan int, 1)\n\tdefer createTestServer(port, t).Close()\n\taddr := <-port\n\tresp, err := http.Get(fmt.Sprintf(\"http://localhost:%d/env/get\", addr))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer resp.Body.Close()\n\tbodyContent, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif string(bodyContent) != \"Testing env.set function\" {\n\t\tt.Fatalf(\"Wrong env.get value. Expected 'Testing env.set function' but got '%s'\", string(bodyContent))\n\t}\n}", "func Env() Vars {\n\tif _env == nil {\n\t\t_envLock.Lock()\n\t\tdefer _envLock.Unlock()\n\t\tif _env == nil {\n\t\t\t_env = NewVarsFromEnvironment()\n\t\t}\n\t}\n\treturn _env\n}", "func (v *VirtualEnvironment) GetEnv(inherit bool, projectDir string) (map[string]string, error) {\n\tenv := make(map[string]string)\n\tif v.getEnv == nil {\n\t\t// if runtime is not explicitly disabled, this is an error\n\t\tif os.Getenv(constants.DisableRuntime) != \"true\" {\n\t\t\treturn nil, locale.NewError(\n\t\t\t\t\"err_get_env_unactivated\", \"Trying to set up an environment in an un-activated environment. This should not happen. Please report this issue in our forum: %s\",\n\t\t\t\tconstants.ForumsURL,\n\t\t\t)\n\t\t}\n\t\tenv[\"PATH\"] = os.Getenv(\"PATH\")\n\t} else {\n\t\tvar err error\n\t\tenv, err = v.getEnv(inherit, projectDir)\n\t\tif err != nil {\n\t\t\treturn env, err\n\t\t}\n\t}\n\n\tif projectDir != \"\" {\n\t\tenv[constants.ActivatedStateEnvVarName] = projectDir\n\t\tenv[constants.ActivatedStateIDEnvVarName] = v.activationID\n\n\t\t// Get project from explicitly defined configuration file\n\t\tpj, fail := project.Parse(filepath.Join(projectDir, constants.ConfigFileName))\n\t\tif fail != nil {\n\t\t\treturn env, fail.ToError()\n\t\t}\n\t\tfor _, constant := range pj.Constants() {\n\t\t\tenv[constant.Name()] = constant.Value()\n\t\t}\n\t}\n\n\tif inherit {\n\t\treturn inheritEnv(env), nil\n\t}\n\n\treturn env, nil\n}", "func Setenv(t testing.TB, name, val string) {\n\tNew(t).Setenv(name, val)\n}", "func (gf *genericFramework) Env(key, value string) error {\n\tif gf.adam.Variables == nil {\n\t\tgf.adam.Variables = jsonutil.NewVariableMap(\"\", nil)\n\t}\n\tif _, ok := gf.adam.Variables.Get(key); ok {\n\t\treturn fmt.Errorf(\"%v has been defined\", key)\n\t}\n\tgf.adam.Variables.Set(key, jsonutil.NewStringVariable(key, value))\n\treturn nil\n}", "func Env() string {\n\treturn AppConfig.Env\n}", "func Env(key, defaultValue string) string {\n\tvalue, defined := os.LookupEnv(key)\n\tif !defined {\n\t\treturn defaultValue\n\t}\n\n\treturn value\n}", "func (e *Env) NewEnv() *Env {\n\treturn &Env{\n\t\tenv: make(map[string]interface{}),\n\t\tparent: e,\n\t\tbuiltin: e.builtin,\n\t\tglobal: e.global,\n\t\tfuncArg: make(map[string]interface{}),\n\t\t//importFunc: e.importFunc,\n\t\tfileInfo: e.fileInfo,\n\t}\n}", "func env() *awscdk.Environment {\n\treturn &awscdk.Environment{\n\t Account: aws.String(os.Getenv(\"CDK_DEFAULT_ACCOUNT\")),\n\t Region: aws.String(os.Getenv(\"CDK_DEFAULT_REGION\")),\n\t}\n}", "func (o StorageClusterSpecPtrOutput) Env() StorageClusterSpecEnvArrayOutput {\n\treturn o.ApplyT(func(v *StorageClusterSpec) []StorageClusterSpecEnv {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Env\n\t}).(StorageClusterSpecEnvArrayOutput)\n}", "func env() *awscdk.Environment {\n\treturn nil\n\n\t//---------------------------------------------------------------------------\n\t// return &awscdk.Environment{\n\t// Account: jsii.String(os.Getenv(\"CDK_DEFAULT_ACCOUNT\")),\n\t// Region: jsii.String(os.Getenv(\"CDK_DEFAULT_REGION\")),\n\t// }\n}", "func NewEnv(context *libcoap.Context) *Env {\n return &Env{\n context,\n nil,\n make(chan Event, 32),\n nil,\n }\n}", "func Env(varName string, defaultValue string) string {\n\tvarValue := os.Getenv(varName)\n\tif varValue == \"\" {\n\t\treturn defaultValue\n\t}\n\treturn varValue\n}", "func (this *Go) GetEnviron() map[string]string {\n\tenv := make(map[string]string)\n\tfor _, p := range os.Environ() {\n\t\tarr := strings.SplitN(p, \"=\", 2)\n\t\tenv[arr[0]] = arr[1]\n\t}\n\treturn env\n}", "func NewMockEnv(t *testing.T) *MockEnv {\n\troot := testlib.TempDirAbs(t)\n\n\tlocal := filepath.Join(root, \"local\")\n\tif err := os.Mkdir(local, os.ModePerm); err != nil {\n\t\tpanic(err)\n\t}\n\tremote := filepath.Join(root, \"remote\")\n\tif err := os.Mkdir(remote, os.ModePerm); err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn &MockEnv{\n\t\tlocalRoot: local,\n\t\tremoteRoot: remote,\n\n\t\tplumbing: DevPlumbing{\n\t\t\tPlumbing: gggit.NewPlumbing(),\n\n\t\t\tSilenceStderr: true,\n\t\t\tURLMap: make(map[string]string),\n\t\t},\n\n\t\tvars: env.Variables{\n\t\t\tHOME: local,\n\t\t\tPATH: \"\",\n\t\t\tGGROOT: local,\n\t\t},\n\t}\n}", "func (o StorageClusterSpecOutput) Env() StorageClusterSpecEnvArrayOutput {\n\treturn o.ApplyT(func(v StorageClusterSpec) []StorageClusterSpecEnv { return v.Env }).(StorageClusterSpecEnvArrayOutput)\n}", "func (m *MockenvDescriber) EXPECT() *MockenvDescriberMockRecorder {\n\treturn m.recorder\n}", "func (c *Cli) Getenv(name string) string {\n\tvar s string\n\te, err := c.EnvAttribute(name)\n\tif err != nil {\n\t\treturn s\n\t}\n\tswitch e.Type {\n\tcase \"bool\":\n\t\treturn fmt.Sprintf(\"%t\", e.BoolValue)\n\tcase \"int\":\n\t\treturn fmt.Sprintf(\"%d\", e.IntValue)\n\tcase \"int64\":\n\t\treturn fmt.Sprintf(\"%d\", e.Int64Value)\n\tcase \"uint\":\n\t\treturn fmt.Sprintf(\"%d\", e.UintValue)\n\tcase \"uint64\":\n\t\treturn fmt.Sprintf(\"%d\", e.Uint64Value)\n\tcase \"float64\":\n\t\treturn fmt.Sprintf(\"%f\", e.Float64Value)\n\tcase \"time.Duration\":\n\t\treturn fmt.Sprintf(\"%s\", e.DurationValue)\n\t}\n\treturn e.StringValue\n}", "func (o VirtualDatabaseSpecOutput) Env() VirtualDatabaseSpecEnvArrayOutput {\n\treturn o.ApplyT(func(v VirtualDatabaseSpec) []VirtualDatabaseSpecEnv { return v.Env }).(VirtualDatabaseSpecEnvArrayOutput)\n}", "func Getenv(dst interface{}, key string) error {\n\treturn DefaultReader.Getenv(dst, key)\n}", "func (o VirtualDatabaseSpecPtrOutput) Env() VirtualDatabaseSpecEnvArrayOutput {\n\treturn o.ApplyT(func(v *VirtualDatabaseSpec) []VirtualDatabaseSpecEnv {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Env\n\t}).(VirtualDatabaseSpecEnvArrayOutput)\n}", "func GetEnv(root *pb.Span, t *pb.TraceChunk) string {\n\tif v, ok := root.Meta[envKey]; ok {\n\t\treturn v\n\t}\n\tfor _, s := range t.Spans {\n\t\tif s.SpanID == root.SpanID {\n\t\t\tcontinue\n\t\t}\n\t\tif v, ok := s.Meta[envKey]; ok {\n\t\t\treturn v\n\t\t}\n\t}\n\treturn \"\"\n}", "func env(key string, defaultValue string) string {\n\tif value, exists := os.LookupEnv(key); exists {\n\t\treturn value\n\t}\n\treturn defaultValue\n}", "func (e EnvFile) Env(secrets map[string]string, sr tpl.SecretReader) (map[string]string, error) {\n\tenv, err := e.env.Env(secrets, sr)\n\tif err != nil {\n\t\treturn nil, ErrParsingTemplate(e.path, err)\n\t}\n\treturn env, nil\n}", "func GetEnv(key string) string {\n\treturn envHash[key]\n}", "func NewEnv(files []string) *Env {\n\tglobal := make(map[string]interface{})\n\tglobal[\"ENVIRON\"] = getEnvVars()\n\n\treturn &Env{\n\t\tenv: make(map[string]interface{}),\n\t\tparent: nil,\n\t\tbuiltin: newBuiltIn(files),\n\t\tglobal: global,\n\t\tfuncArg: make(map[string]interface{}),\n\t\t//importFunc: make(map[string]func(*Env) (reflect.Value, error)),\n\t\tfileInfo: &FileInfo{\n\t\t\tfiles: files,\n\t\t\tcurFileIndex: 0,\n\t\t\treadCloser: make(map[string]*io.ReadCloser),\n\t\t\tscanner: make(map[string]*bufio.Scanner),\n\t\t},\n\t}\n}", "func (c *Client) EnvGet(ctx context.Context) (map[string]string, error) {\n\tvar resp EnvGetResponse\n\tif err := c.client.Do(ctx, \"GET\", envURL, nil, &resp); err != nil {\n\t\treturn nil, err\n\t}\n\treturn resp.Env, nil\n}", "func NewEnv() *Env {\n\tenv := new(Env)\n\t// env.EnvParams.DefaultEnv()\n\t// env.EnvParams.Initialize()\n\treturn env\n}", "func Mock() Env {\n\treturn mock.New()\n}", "func (p RProc) SetEnv(stackItems ...Value) {\n\tif len(stackItems) == 0 {\n\t\tC._mrb_create_env(p.mrb.p, p.p, 0, nil)\n\t\treturn\n\t}\n\n\tC._mrb_create_env(p.mrb.p, p.p, C.mrb_int(len(stackItems)), &(stackItems[0].v))\n}", "func env(key string, defaultValue string) string {\n\tvalue := os.Getenv(key)\n\n\tif len(value) > 0 {\n\t\treturn value\n\t}\n\treturn defaultValue\n\n}", "func (context *Context) GetEnv(target string) (string, bool) {\n\tv, ok := context.Env.Get(target)\n\tif !ok {\n\t\treturn context.Global.GEnv.Get(target)\n\t}\n\treturn v, ok\n}", "func NewEnv() *Env {\n\treturn &Env{\n\t\tos.Getenv(clusterRoot),\n\t\tos.Getenv(kubeConfig),\n\t}\n}", "func assertEnv(ctx context.Context, client client.Client, spec corev1.PodSpec, component, container, key, expectedValue string) error {\n\tvalue, err := getEnv(ctx, client, spec, component, container, key)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif value != nil && strings.ToLower(*value) != expectedValue {\n\t\treturn ErrIncompatibleCluster{\n\t\t\terr: fmt.Sprintf(\"%s=%s is not supported\", key, *value),\n\t\t\tcomponent: component,\n\t\t\tfix: fmt.Sprintf(\"remove the %s env var or set it to '%s'\", key, expectedValue),\n\t\t}\n\t}\n\n\treturn nil\n}", "func Env(prefix string) Provider {\n\treturn &env{prefix}\n}", "func (m *wasiSnapshotPreview1Impl) environGet(penviron pointer, penvironBuf pointer) (err wasiErrno) {\n\tfor _, s := range m.env {\n\t\tbuf := m.bytes(penvironBuf)\n\t\tcopy(buf, s)\n\t\tbuf[len(s)] = 0\n\n\t\tm.putUint32(uint32(penvironBuf), penviron)\n\t\tpenvironBuf, penviron = penvironBuf+pointer(len(s))+1, penviron+4\n\t}\n\treturn wasiErrnoSuccess\n}", "func (o VirtualDatabaseSpecBuildOutput) Env() VirtualDatabaseSpecBuildEnvArrayOutput {\n\treturn o.ApplyT(func(v VirtualDatabaseSpecBuild) []VirtualDatabaseSpecBuildEnv { return v.Env }).(VirtualDatabaseSpecBuildEnvArrayOutput)\n}", "func (c *CmdReal) GetEnv() []string {\n\treturn c.cmd.Env\n}", "func (c *Config) Env() map[string]interface{} {\r\n\tc.mu.Lock()\r\n\tdefer c.mu.Unlock()\r\n\r\n\treturn cloneMap(c.env)\r\n}", "func (envx *EnvBufferedExec) SetEnv(key string, value string) *EnvBufferedExec {\n\tenvx.env[key] = value\n\treturn envx\n}", "func (o VirtualDatabaseSpecBuildPtrOutput) Env() VirtualDatabaseSpecBuildEnvArrayOutput {\n\treturn o.ApplyT(func(v *VirtualDatabaseSpecBuild) []VirtualDatabaseSpecBuildEnv {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Env\n\t}).(VirtualDatabaseSpecBuildEnvArrayOutput)\n}", "func Environ() string {\n\treturn environ\n}", "func (c *Cli) Env(name string) string {\n\te, ok := c.env[name]\n\tif ok == false {\n\t\treturn fmt.Sprintf(\"%q not documented for environment\", name)\n\t}\n\treturn e.Usage\n}", "func Setenv(key, value string) error", "func GetEnv(fileName string) (*Env, error) {\n\tv := viper.New()\n\tv.AutomaticEnv()\n\tv.AddConfigPath(configPath)\n\tv.SetConfigType(configType)\n\tv.SetConfigName(fileName)\n\n\tif err := v.ReadInConfig(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tlogger := v.GetString(envKeyLogger)\n\tif logger == \"\" {\n\t\tlogger = defaultLoggerEnvironment\n\t}\n\n\tmySQLHost := v.GetString(envKeyMySQLHost)\n\tif mySQLHost == \"\" {\n\t\treturn nil, missingEnvError(envKeyMySQLHost)\n\t}\n\n\tmySQLPort := v.GetString(envKeyMySQLPort)\n\tif mySQLPort == \"\" {\n\t\treturn nil, missingEnvError(envKeyMySQLPort)\n\t}\n\n\tmySQLName := v.GetString(envKeyMySQLName)\n\tif mySQLName == \"\" {\n\t\treturn nil, missingEnvError(envKeyMySQLName)\n\t}\n\n\tmySQLPassword := v.GetString(envKeyMySQLPassword)\n\n\tmySQLUser := v.GetString(envKeyMySQLUser)\n\n\tredisHost := v.GetString(envKeyRedisHost)\n\tif redisHost == \"\" {\n\t\treturn nil, missingEnvError(envKeyRedisHost)\n\t}\n\n\tredisPort := v.GetInt(envKeyRedisPort)\n\tif redisPort == 0 {\n\t\treturn nil, missingEnvError(envKeyRedisPort)\n\t}\n\n\tredisPassword := v.GetString(envKeyRedisPassword)\n\n\tredisKeyPrefix := v.GetString(envKeyRedisKeyPrefix)\n\n\tport := v.GetString(envKeyPort)\n\tif port == \"\" {\n\t\tport = defaultValuePort\n\t}\n\n\tenv := &Env{\n\t\tlogger: logger,\n\t\tmySQLHost: mySQLHost,\n\t\tmySQLName: mySQLName,\n\t\tmySQLPassword: mySQLPassword,\n\t\tmySQLPort: mySQLPort,\n\t\tmySQLUser: mySQLUser,\n\t\tport: port,\n\t\tredisHost: redisHost,\n\t\tredisPassword: redisPassword,\n\t\tredisPort: redisPort,\n\t\tredisKeyPrefix: redisKeyPrefix,\n\t}\n\n\treturn env, nil\n}", "func (c *Action) SetEnv(k, v string) {\n\tfmt.Fprintf(c.w, setEnvFmt, k, escapeData(v))\n}", "func (s *Action) Env(c *cli.Context) error {\n\tctx := ctxutil.WithGlobalFlags(c)\n\tname := c.Args().First()\n\targs := c.Args().Tail()\n\tkeepCase := c.Bool(\"keep-case\")\n\n\tif len(args) == 0 {\n\t\treturn exit.Error(exit.Usage, nil, \"Missing subcommand to execute\")\n\t}\n\n\tif !s.Store.Exists(ctx, name) && !s.Store.IsDir(ctx, name) {\n\t\treturn exit.Error(exit.NotFound, nil, \"Secret %s not found\", name)\n\t}\n\n\tkeys := make([]string, 0, 1)\n\tif s.Store.IsDir(ctx, name) {\n\t\tdebug.Log(\"%q is a dir, adding it's entries\", name)\n\n\t\tl, err := s.Store.Tree(ctx)\n\t\tif err != nil {\n\t\t\treturn exit.Error(exit.List, err, \"failed to list store: %s\", err)\n\t\t}\n\n\t\tsubtree, err := l.FindFolder(name)\n\t\tif err != nil {\n\t\t\treturn exit.Error(exit.NotFound, nil, \"Entry %q not found\", name)\n\t\t}\n\n\t\tfor _, e := range subtree.List(tree.INF) {\n\t\t\tdebug.Log(\"found key: %s\", e)\n\t\t\tkeys = append(keys, e)\n\t\t}\n\t} else {\n\t\tkeys = append(keys, name)\n\t}\n\n\tenv := make([]string, 0, 1)\n\tfor _, key := range keys {\n\t\tdebug.Log(\"exporting to environment key: %s\", key)\n\t\tsec, err := s.Store.Get(ctx, key)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get entry for env prefix %q: %w\", name, err)\n\t\t}\n\t\tenvKey := path.Base(key)\n\t\tif !keepCase {\n\t\t\tenvKey = strings.ToUpper(envKey)\n\t\t}\n\t\tenv = append(env, fmt.Sprintf(\"%s=%s\", envKey, sec.Password()))\n\t}\n\n\tcmd := exec.CommandContext(ctx, args[0], args[1:]...)\n\tcmd.Env = append(os.Environ(), env...)\n\tcmd.Stdin = os.Stdin\n\tcmd.Stdout = stdout\n\tcmd.Stderr = os.Stderr\n\n\treturn cmd.Run()\n}", "func (t *Task) Env() map[string]string {\n\treturn t.opts.env\n}", "func (config *Configuration) GetEnv() string {\n\treturn string(config.env)\n}", "func TestEnviron(t *testing.T) {\n\ttests := map[string]string{\n\t\t\"KEY_0\": \"Abc\",\n\t\t\"KEY_1\": \"Def\",\n\t}\n\n\t// Set test data.\n\tos.Clearenv()\n\tfor key, value := range tests {\n\t\tif err := os.Setenv(key, value); err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}\n\n\t// Test function.\n\tfor i, str := range Environ() {\n\t\ttmp := strings.Split(str, \"=\")\n\t\tkey, value := tmp[0], tmp[1]\n\t\tif v, ok := tests[key]; v != value || !ok {\n\t\t\tif !ok {\n\t\t\t\tt.Errorf(\"test %v. extra key`%v`\", i, key)\n\t\t\t} else {\n\t\t\t\tt.Errorf(\"test %v. expected `%v` but `%v`\", i, v, value)\n\t\t\t}\n\t\t}\n\t}\n}", "func (r *CheckedDaemonSet) assertEnv(ctx context.Context, client client.Client, container, key, expectedValue string) error {\n\tif err := assertEnv(ctx, client, r.Spec.Template.Spec, ComponentCalicoNode, container, key, expectedValue); err != nil {\n\t\treturn err\n\t}\n\tr.ignoreEnv(container, key)\n\treturn nil\n}", "func TestSetEnv(t *testing.T, key string, value string) func() {\n\tt.Helper()\n\toriginalValue := os.Getenv(key)\n\tos.Setenv(key, value)\n\treturn func() { os.Setenv(key, originalValue) }\n}", "func NewEnvironment(testKeys []string) Environment {\n\tvars := make(map[string]string)\n\tfor _, key := range testKeys {\n\t\tvars[key] = os.Getenv(key)\n\t}\n\treturn Environment{backup: vars}\n}", "func GetEnv(name string) string {\n\treturn os.Getenv(name)\n}" ]
[ "0.69212854", "0.66415465", "0.65178424", "0.6469878", "0.63406515", "0.63362306", "0.6283041", "0.62473047", "0.6217694", "0.6203327", "0.619105", "0.61533636", "0.6140795", "0.61385715", "0.6101667", "0.609115", "0.6076825", "0.603624", "0.60137403", "0.59723485", "0.5957127", "0.59388554", "0.5920079", "0.58856606", "0.587825", "0.5873134", "0.58566993", "0.5851227", "0.5830275", "0.58210164", "0.5800738", "0.57835776", "0.57793826", "0.57723325", "0.57713693", "0.57635313", "0.57602006", "0.5758193", "0.5753125", "0.57499605", "0.57354426", "0.5729966", "0.57240933", "0.57232356", "0.5722918", "0.5713317", "0.57131594", "0.5699462", "0.5691218", "0.5683483", "0.56799144", "0.5672831", "0.5668093", "0.5659458", "0.5657843", "0.56556475", "0.56528175", "0.5639351", "0.56380147", "0.5634281", "0.5625658", "0.56179756", "0.56152016", "0.56125575", "0.5610904", "0.56096786", "0.5609369", "0.5608131", "0.5607647", "0.56071424", "0.55994487", "0.5597153", "0.55965644", "0.5593531", "0.55898863", "0.5586755", "0.5581781", "0.5570247", "0.55677176", "0.5563317", "0.55616945", "0.5550284", "0.55305046", "0.55275595", "0.5526128", "0.552028", "0.55191404", "0.55163205", "0.5509128", "0.5508744", "0.55020726", "0.54898137", "0.54886657", "0.5485311", "0.5483277", "0.548059", "0.5478879", "0.54714453", "0.5470773", "0.54704654" ]
0.7403274
0
Request returns a new Request instance. Arguments are similar to NewRequest. After creating request, all builders attached to Expect instance are invoked. See Builder.
Запрос возвращает новый экземпляр Request. Аргументы аналогичны NewRequest. После создания запроса вызываются все строители, привязанные к экземпляру Expect. См. Builder.
func (e *Expect) Request(method, path string, pathargs ...interface{}) *Request { opChain := e.chain.enter("Request(%q)", method) defer opChain.leave() req := newRequest(opChain, e.config, method, path, pathargs...) for _, builder := range e.builders { builder(req) } for _, matcher := range e.matchers { req.WithMatcher(matcher) } return req }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Request) Request() *http.Request {\n\treq := httptest.NewRequest(r.Method, r.Target, strings.NewReader(r.Body))\n\treq.Header = r.Header\n\treturn req\n}", "func (f Factory) Request(method string, arguments interface{}) (request Request) {\n\trequest.Token = f.Token\n\trequest.Method = method\n\tif arguments != nil {\n\t\tvar err error\n\t\trequest.Values, err = query.Values(arguments)\n\t\tmust(err)\n\t}\n\treturn request\n}", "func NewRequest(requestName string, params rata.Params, header http.Header, query url.Values, body ...io.Reader) Request {\n\tif header == nil {\n\t\theader = http.Header{}\n\t}\n\theader.Set(\"Accept\", \"application/json\")\n\n\trequest := Request{\n\t\tRequestName: requestName,\n\t\tParams: params,\n\t\tHeader: header,\n\t\tQuery: query,\n\t}\n\n\tif len(body) == 1 {\n\t\trequest.Body = body[0]\n\t}\n\n\treturn request\n}", "func NewRequest() (r *Request) {\n\treturn &Request{}\n}", "func (r *Request) Request() (*http.Request, error) {\n\tvar req *http.Request\n\tvar err error\n\n\tif r.body != nil {\n\t\tbody, err := json.Marshal(r.body)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tbuff := bytes.NewBuffer(body)\n\n\t\treq, err = http.NewRequest(r.method, r.url, buff)\n\t} else {\n\t\treq, err = http.NewRequest(r.method, r.url, nil)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tv, err := query.Values(r.query)\n\tif err == nil {\n\t\treq.URL.RawQuery = v.Encode()\n\t}\n\n\treturn req, nil\n}", "func NewRequest() *Request {\n\treturn defaul.NewRequest()\n}", "func NewRequest() *Request {\n\treturn &Request{}\n}", "func NewRequest() *Request {\n\treturn &Request{}\n}", "func NewRequest() *Request {\n\tr := &Request{}\n\treturn r\n}", "func NewRequest() *Request {\n\tr := &Request{}\n\treturn r\n}", "func NewRequest() *Request {\n\tr := &Request{}\n\treturn r\n}", "func (s APIv1) NewRequest(ctx context.Context, method, path string, data interface{}) (req *http.Request, err error) {\n\t// Resolve the URL reference from the path\n\tendpoint := s.endpoint.ResolveReference(&url.URL{Path: path})\n\n\tvar body io.ReadWriter\n\tif data != nil {\n\t\tbody = &bytes.Buffer{}\n\t\tif err = json.NewEncoder(body).Encode(data); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"could not serialize request data: %s\", err)\n\t\t}\n\t} else {\n\t\tbody = nil\n\t}\n\n\t// Create the http request\n\tif req, err = http.NewRequestWithContext(ctx, method, endpoint.String(), body); err != nil {\n\t\treturn nil, fmt.Errorf(\"could not create request: %s\", err)\n\t}\n\n\t// Set the headers on the request\n\treq.Header.Add(\"User-Agent\", \"Whisper/1.0\")\n\treq.Header.Add(\"Accept\", \"application/json\")\n\treq.Header.Add(\"Accept-Language\", \"en-US,en\")\n\treq.Header.Add(\"Accept-Encoding\", \"gzip, deflate, br\")\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\treturn req, nil\n}", "func NewRequest() *Request {\n\tr := &Request{\n\t\tAggregations: make(map[string]types.Aggregations, 0),\n\t\tExt: make(map[string]json.RawMessage, 0),\n\t\tScriptFields: make(map[string]types.ScriptField, 0),\n\t}\n\treturn r\n}", "func NewRequest() *Request {\n\tr := &Request{\n\t\tAggregations: make(map[string]types.Aggregations, 0),\n\t\tExt: make(map[string]json.RawMessage, 0),\n\t\tScriptFields: make(map[string]types.ScriptField, 0),\n\t}\n\treturn r\n}", "func NewRequest(robot *Robot, message *Message, query []string) *Request {\n\treturn &Request{\n\t\tMessage: message,\n\t\tQuery: query,\n\t\trobot: robot,\n\t}\n}", "func NewRequest(bufid string, acts ...Action) Request {\n\tr := Request{BufferID: bufid}\n\tr.Add(acts...)\n\treturn r\n}", "func NewRequest() *HttpRequest {\n\ttr := &http.Transport{\n\t\tTLSClientConfig: &tls.Config{},\n\t}\n\n\thR := HttpRequest{client: &http.Client{Transport: tr}}\n\thR.cache = cache.NewMemoryCache()\n\thR.params = Params{}\n\thR.parsers = []bodyParser{rawParser()}\n\thR.handlers = []ResponseStatusHandler{handler()}\n\thR.fetch = fetchXML()\n\treturn &hR\n}", "func NewRequest(t *testing.T, h http.Handler, target string) *Request {\n\treturn &Request{\n\t\tT: t,\n\t\tHandler: h,\n\t\tTarget: target,\n\t}\n}", "func NewRequest(addr string, body []byte) *Request {\n\treturn &Request{\n\t\tAddr: addr,\n\t\tHeader: defaultHeader(len(body)),\n\t\tBody: body,\n\t}\n}", "func NewRequest(params interface{}, atta map[string]interface{}) *DubboRequest {\n\tif atta == nil {\n\t\tatta = make(map[string]interface{})\n\t}\n\treturn &DubboRequest{\n\t\tParams: params,\n\t\tAttachments: atta,\n\t}\n}", "func NewRequest(id, replyTo string, object ObjectID, method string, args ...interface{}) (*Request, error) {\n\tinputs, err := newTuple(args...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Request{\n\t\tID: id,\n\t\tInputs: inputs,\n\t\tObject: object,\n\t\tReplyTo: replyTo,\n\t\tMethod: method,\n\t}, nil\n}", "func New() *Request {\n\treturn &Request{\n\t\tclient: &http.Client{Timeout: time.Second * 3},\n\t\tmethod: \"GET\",\n\t\theader: make(http.Header),\n\t}\n}", "func NewRequest(session *Session, path string) *Request {\n\trequest := new(Request)\n\trequest.UnderlyingRequest = api.NewRequest(session.underlyingSession, path)\n\trequest.session = session\n\treturn request\n}", "func NewRequest() *Request {\n\treturn &Request{\n\t\tCounter: 1,\n\t\tURLStruct: &url.URL{},\n\t\tHeader: make(http.Header),\n\t\tPathParams: make(map[string]string),\n\t}\n}", "func NewRequest(url string, branch string, author string, email string, date string, deps *[]Request) *Request {\n\treturn &Request{\n\t\turl,\n\t\tbranch,\n\t\tauthor,\n\t\temail,\n\t\tdate,\n\t\tdeps,\n\t}\n}", "func NewRequest(r *http.Request) *Request {\n\tvar request Request\n\trequest.ID = atomic.AddUint32(&requestID, 1)\n\trequest.Method = r.Method\n\trequest.Body = r.Body\n\trequest.BodyBuff = new(bytes.Buffer)\n\trequest.BodyBuff.ReadFrom(r.Body)\n\trequest.RemoteAddr = r.Header.Get(\"X-Forwarded-For\")\n\trequest.Header = r.Header\n\tif request.RemoteAddr == \"\" {\n\t\trequest.RemoteAddr = r.RemoteAddr\n\t}\n\trequest.UrlParams = mux.Vars(r)\n\trequest.QueryParams = r.URL.Query()\n\treturn &request\n}", "func (s *Nap) Request() (*http.Request, error) {\n\treqURL, err := url.Parse(s.rawURL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = buildQueryParamUrl(reqURL, s.queryStructs, s.queryParams)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar body io.Reader\n\tif s.bodyProvider != nil {\n\t\tbody, err = s.bodyProvider.Body()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treq, err := http.NewRequestWithContext(s.Context(), s.method, reqURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\taddHeaders(req, s.header)\n\treturn req, err\n}", "func NewRequest(m Manager) *Request {\n\treturn &Request{\n\t\tm: m,\n\t\trLocks: make(map[string]struct{}),\n\t\twLocks: make(map[string]struct{}),\n\t}\n}", "func NewRequest(path string, mode xrdfs.OpenMode, options xrdfs.OpenOptions) *Request {\n\treturn &Request{Mode: mode, Options: options, Path: path}\n}", "func (r *RecordedRequest) Request() *http.Request {\n\turl := r.URL\n\treturn &http.Request{\n\t\tMethod: r.Method,\n\t\tURL: &url,\n\t\tProto: r.Proto,\n\t\tProtoMajor: r.ProtoMajor,\n\t\tProtoMinor: r.ProtoMinor,\n\t\tHeader: r.Header,\n\t\tBody: ioutil.NopCloser(bytes.NewBuffer(r.Body)),\n\t\tContentLength: r.ContentLength,\n\t\tTransferEncoding: r.TransferEncoding,\n\t\tHost: r.Host,\n\t\tForm: r.Form,\n\t\tPostForm: r.PostForm,\n\t\tMultipartForm: r.MultipartForm,\n\t\tTrailer: r.Trailer,\n\t\tRemoteAddr: r.RemoteAddr,\n\t\tRequestURI: r.RequestURI,\n\t\tTLS: r.TLS,\n\t}\n}", "func NewRequest(session *Session, path string) *Request {\n\tr := new(Request)\n\tr.path = path\n\tr.session = session\n\tr.queryValues = make(url.Values)\n\treturn r\n}", "func newRequest(db *Database) *Request {\n\treq := &Request{\n\t\tdb: db,\n\t\tpath: \"/\",\n\t\tquery: url.Values{},\n\t\theader: http.Header{},\n\t}\n\treturn req\n}", "func NewRequest(t Type, body io.WriterTo) *Request {\n\treq := &Request{\n\t\tBody: &copyReader{WriterTo: body},\n\t\tProto: \"OFP/1.3\",\n\t\tProtoMajor: 1, ProtoMinor: 3,\n\t}\n\n\treq.Header.Version = uint8(req.ProtoMajor + req.ProtoMinor)\n\treq.Header.Type = t\n\n\treturn req\n}", "func (c *baseClient) Request() (*http.Request, error) {\n\treqURL, err := url.Parse(c.url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif c.queryStruct != nil {\n\t\terr = addQueryStruct(reqURL, c.queryStruct)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tbody := &bytes.Buffer{}\n\tif c.body != nil {\n\t\tif err := json.NewEncoder(body).Encode(c.body); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treq, err := http.NewRequest(c.method, reqURL.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Add headers to request\n\tfor k, vs := range c.header {\n\t\tfor _, v := range vs {\n\t\t\treq.Header.Add(k, v)\n\t\t}\n\t}\n\n\treturn req, nil\n}", "func (c *apiHttp) NewRequest(command string) RequestBuilder {\n\theaders := make(map[string]string)\n\tif c.Headers != nil {\n\t\tfor k := range c.Headers {\n\t\t\theaders[k] = c.Headers.Get(k)\n\t\t}\n\t}\n\n\treturn &requestBuilder{\n\t\tcommand: command,\n\t\tclient: c,\n\t\theaders: headers,\n\t}\n}", "func (i *instance) NewRequest(method, urlStr string, body io.Reader) (*http.Request, error) {\n\treq, err := http.NewRequest(method, urlStr, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Make a context for this request.\n\tc := &context{\n\t\treq: req,\n\t\tsession: newSessionID(),\n\t\tinstance: i,\n\t}\n\n\t// Associate this request.\n\trelease := appengine_internal.RegisterTestContext(req, c)\n\ti.relFuncs = append(i.relFuncs, release)\n\n\treturn req, nil\n}", "func NewRequest(method, urlStr string, body io.Reader, meta MetaMap) (req *Request, err error) {\n\tif meta == nil {\n\t\tmeta = make(MetaMap, 2)\n\t}\n\n\tif httpReq, err := http.NewRequest(method, urlStr, body); err == nil {\n\t\treq = &Request{\n\t\t\tRequest: httpReq,\n\t\t\tMeta: meta,\n\t\t}\n\t}\n\treturn\n}", "func (c *Client) Request() *Request {\n\treq := &Request{\n\t\tmake(map[string]string),\n\t\tmake(map[string]string),\n\t}\n\n\tfor _, modifier := range c.modifiers {\n\t\tmodifier(req)\n\t}\n\n\treturn req\n}", "func NewRequest(q string) *Request {\n\treq := &Request{\n\t\tq: q,\n\t\tHeader: make(map[string][]string),\n\t}\n\treturn req\n}", "func (g *Group) newRequest(operation *request.Operation, input interface{}, output interface{}, handlers *request.Handlers) *request.Request {\n return request.New(g.Client, operation, input, output, handlers)\n}", "func NewRequest(method, url string) *Request {\n\treturn &Request{method: method, url: url}\n}", "func NewRequest(url string) *Request {\n\treturn client.NewRequest(url)\n}", "func NewRequest(r *http.Request, ns string, body []byte) (*Request, error) {\n\th, err := json.Marshal(r.Header)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Request{\n\t\tID: uuid.NewV4(),\n\t\tMethod: r.Method,\n\t\tHeaders: h,\n\t\tPayload: body,\n\t\tHost: r.Host,\n\t\tScheme: r.URL.Scheme,\n\t\tPath: r.URL.Path,\n\t\tNamespace: ns,\n\t\tRetries: 0,\n\t}, nil\n}", "func NewRequest(req Requester) *Transaction {\n\treturn &Transaction{\n\t\ttp: Request,\n\t\tReq: req,\n\t}\n}", "func NewRequest(src, dest string) *Request {\n\treturn &Request{src: src, dest: dest}\n}", "func New(handler http.Handler) *Request {\n\tapiTest := &APITest{}\n\n\trequest := &Request{apiTest: apiTest}\n\tresponse := &Response{apiTest: apiTest}\n\tapiTest.request = request\n\tapiTest.response = response\n\tapiTest.handler = handler\n\n\treturn apiTest.request\n}", "func (c *Client) newRequest(t RequestType) *Request {\n\tc.seqID++\n\treturn &Request{\n\t\tAPIVersion: \"v1\",\n\t\tRequestType: t,\n\t\tTracerTime: time.Now().Unix(),\n\t\tRuntimeID: globalconfig.RuntimeID(),\n\t\tSeqID: c.seqID,\n\t\tDebug: c.debug,\n\t\tApplication: Application{\n\t\t\tServiceName: c.Service,\n\t\t\tEnv: c.Env,\n\t\t\tServiceVersion: c.Version,\n\t\t\tTracerVersion: version.Tag,\n\t\t\tLanguageName: \"go\",\n\t\t\tLanguageVersion: runtime.Version(),\n\t\t},\n\t\tHost: Host{\n\t\t\tHostname: hostname,\n\t\t\tContainerID: internal.ContainerID(),\n\t\t\tOS: getOSName(),\n\t\t\tOSVersion: getOSVersion(),\n\t\t},\n\t}\n}", "func newRequest(req *http.Request) *Request {\n\trequest := &Request{\n\t\tRequest: req,\n\t}\n\n\treturn request\n}", "func (c *Context) Request(body interface{}) (req *Request, err error) {\n\tdefer c.Req.Body.Close()\n\n\treq, err = RequestReader(c.Req.Body, body)\n\treturn\n}", "func (m *InMemManager) NewRequest() *Request {\n\treturn NewRequest(m)\n}", "func NewRequest(id string, method string, params interface{}) *Request {\n\tbuffer, err := json.Marshal(params)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn &Request{JsonRPC: \"2.0\", Id: id, Method: method, Params: buffer}\n}", "func NewRequest(methodName string, params []interface{}) (req Request, err error) {\n\treq = Request{\n\t\tMethodName: methodName,\n\t\tParams: make([]Value, 0, len(params)),\n\t}\n\n\tfor _, p := range params {\n\t\tv := NewValue(p)\n\t\tif v == nil {\n\t\t\treturn req, fmt.Errorf(\"NewRequest: cannot convert parameter %v\", p)\n\t\t}\n\n\t\treq.Params = append(req.Params, *v)\n\t}\n\n\treturn req, nil\n}", "func NewRequest(op OpCode, bdy proto.Message, authenticator auth.Authenticator, provider ProviderID) (*Request, error) {\n\tbodyBuf, err := proto.Marshal(bdy)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tauthtok, err := authenticator.NewRequestAuth()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tr := &Request{\n\t\tHeader: wireHeader{\n\t\t\tversionMajor: versionMajorOne,\n\t\t\tversionMinor: versionMinorZero,\n\t\t\tflags: flagsZero,\n\t\t\tprovider: provider,\n\t\t\t// todo set session handles\n\t\t\tcontentType: contentTypeProtobuf,\n\t\t\tauthType: authtok.AuthType(),\n\t\t\tbodyLen: uint32(len(bodyBuf)),\n\t\t\tauthLen: uint16(authtok.Buffer().Len()),\n\t\t\topCode: op,\n\t\t\tStatus: StatusSuccess,\n\t\t},\n\t\tBody: RequestBody{\n\t\t\tbytes.NewBuffer(bodyBuf),\n\t\t},\n\t\tAuth: authtok,\n\t}\n\treturn r, nil\n}", "func New(env *solo.Solo) *RequestManager {\n\trequestManager := &RequestManager{env: env}\n\treturn requestManager\n}", "func newRequest(req *http.Request) *Request {\n\treturn &Request{\n\t\tRequest: req,\n\t}\n}", "func NewRequest(f map[string]string, r io.Reader, h map[string]string, d encoding.DecodeFunc) *Request {\n\treturn &Request{Fields: f, Raw: r, Headers: h, decode: d}\n}", "func NewRequest(method, toURL string, body io.Reader) (*Request, error) {\n\tif method == \"\" {\n\t\t// We document that \"\" means \"GET\" for Request.Method, and people have\n\t\t// relied on that from NewRequest, so keep that working.\n\t\t// We still enforce ValidMethod for non-empty methods.\n\t\tmethod = GET\n\t}\n\tif !ValidMethod(method) {\n\t\treturn nil, fmt.Errorf(\"github.com/badu//http: invalid method %q\", method)\n\t}\n\tu, err := url.Parse(toURL) // Just url.Parse (url is shadowed for godoc).\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trc, ok := body.(io.ReadCloser)\n\tif !ok && body != nil {\n\t\trc = ioutil.NopCloser(body)\n\t}\n\t// The host's colon:port should be normalized. See Issue 14836.\n\tu.Host = removeEmptyPort(u.Host)\n\treq := &Request{\n\t\tMethod: method,\n\t\tURL: u,\n\t\tProto: HTTP1_1,\n\t\tProtoMajor: 1,\n\t\tProtoMinor: 1,\n\t\tHeader: make(hdr.Header),\n\t\tBody: rc,\n\t\tHost: u.Host,\n\t}\n\tif body != nil {\n\t\tswitch v := body.(type) {\n\t\tcase *bytes.Buffer:\n\t\t\treq.ContentLength = int64(v.Len())\n\t\t\tbuf := v.Bytes()\n\t\t\treq.GetBody = func() (io.ReadCloser, error) {\n\t\t\t\tr := bytes.NewReader(buf)\n\t\t\t\treturn ioutil.NopCloser(r), nil\n\t\t\t}\n\t\tcase *bytes.Reader:\n\t\t\treq.ContentLength = int64(v.Len())\n\t\t\tsnapshot := *v\n\t\t\treq.GetBody = func() (io.ReadCloser, error) {\n\t\t\t\tr := snapshot\n\t\t\t\treturn ioutil.NopCloser(&r), nil\n\t\t\t}\n\t\tcase *strings.Reader:\n\t\t\treq.ContentLength = int64(v.Len())\n\t\t\tsnapshot := *v\n\t\t\treq.GetBody = func() (io.ReadCloser, error) {\n\t\t\t\tr := snapshot\n\t\t\t\treturn ioutil.NopCloser(&r), nil\n\t\t\t}\n\t\tdefault:\n\t\t\t// This is where we'd set it to -1 (at least\n\t\t\t// if body != NoBody) to mean unknown, but\n\t\t\t// that broke people during the Go 1.8 testing\n\t\t\t// period. People depend on it being 0 I\n\t\t\t// guess. Maybe retry later. See Issue 18117.\n\t\t}\n\t\t// For client requests, Request.ContentLength of 0\n\t\t// means either actually 0, or unknown. The only way\n\t\t// to explicitly say that the ContentLength is zero is\n\t\t// to set the Body to nil. But turns out too much code\n\t\t// depends on NewRequest returning a non-nil Body,\n\t\t// so we use a well-known ReadCloser variable instead\n\t\t// and have the http package also treat that sentinel\n\t\t// variable to mean explicitly zero.\n\t\tif req.GetBody != nil && req.ContentLength == 0 {\n\t\t\treq.Body = NoBody\n\t\t\treq.GetBody = func() (io.ReadCloser, error) { return NoBody, nil }\n\t\t}\n\t}\n\n\treturn req, nil\n}", "func NewRequest(conn Conn, data []byte, offset int) Request {\n\treturn &request{conn: conn, data: data, offset: offset}\n}", "func NewRequest(name string) *Request {\n\tresult := Request{name: name}\n\tresult.pending = nil\n\tresult.approved = nil\n\treturn &result\n}", "func newRequest(t *testing.T, path string) *http.Request {\n\tif !strings.HasPrefix(path, \"/\") {\n\t\tpath = \"/\" + path\n\t}\n\tu := fmt.Sprintf(\"http://localhost:%d%s\", expectedPort, path)\n\treq, err := http.NewRequestWithContext(\n\t\tcontext.Background(),\n\t\thttp.MethodGet, u,\n\t\tnil,\n\t)\n\trequire.NoError(t, err)\n\treturn req\n}", "func Request(url, method string, args interface{}) (req *http.Request, err error) {\n\n\tmessage, err := rpc.EncodeClientRequest(method, args)\n\tif err != nil {\n\t\treturn\n\t}\n\treq, err = http.NewRequest(\"POST\", url, bytes.NewBuffer(message))\n\tif err != nil {\n\t\treturn\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treturn\n}", "func (r *Search) Request(req *Request) *Search {\n\tr.req = req\n\n\treturn r\n}", "func NewRequest(ctx context.Context) *Request {\n\tr := &Request{\n\t\tctx: ctx,\n\t\tquery: url.Values{},\n\t}\n\n\tr.url, _ = url.Parse(endpoint)\n\n\treturn r\n}", "func (c *Client) NewRequest(method, path string) *Request {\n\trequestUrl := path\n\tif !strings.HasPrefix(path, \"http\") {\n\t\trequestUrl = c.Config.ApiAddress + path\n\t}\n\n\tr := &Request{\n\t\tmethod: method,\n\t\turl: requestUrl,\n\t\tparams: make(map[string][]string),\n\t}\n\treturn r\n}", "func newRequest(r *http.Request, vars map[string]string) *Request {\n\trequest := &Request{r, vars, nil}\n\treturn request\n}", "func NewRequest(endpoint Endpoint, payload interface{}, config *models.Config) *Request {\n\treturn &Request{\n\t\tEndpoint: endpoint,\n\t\tPayload: payload,\n\t\tConfig: config,\n\t\tMethod: POST,\n\t\tContentType: JSONContentType,\n\t}\n}", "func (fn RequestMakerFunc) MakeRequest() Request {\n\treturn fn()\n}", "func (s *Stein) newRequest(method string, path string, body io.Reader) (*http.Request, error) {\n\treq, err := http.NewRequest(method, path, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\treturn req, nil\n}", "func (b *AuroraBackend) NewRequest(params *CallParams) (*http.Request, error) {\n\treq, err := http.NewRequest(params.Method, params.Path, params.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\theaders := params.Headers\n\tif headers == nil {\n\t\theaders = make(http.Header)\n\t}\n\n\tif params.Credentials != nil {\n\t\theaders.Add(\"X-Application-ID\", params.Credentials.AppID)\n\t\theaders.Add(\"X-Application-Token\", params.Credentials.AppToken)\n\t\theaders.Add(\"X-Device-ID\", params.Credentials.DeviceID)\n\t}\n\n\treq.Header = headers\n\treturn req, nil\n}", "func (enc *Enqueuer) Request() (*http.Request, error) {\n\tbodyBytes, err := enc.BodyBytes()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq, err := http.NewRequest(\n\t\t\"POST\",\n\t\tenc.RequestPath(),\n\t\tbytes.NewReader(bodyBytes),\n\t)\n\treq.Header.Add(\"Content-Length\", strconv.Itoa(len(bodyBytes)))\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\treturn req, nil\n}", "func (r *Request) New() *Request {\n\theaders := make(http.Header)\n\tfor key, value := range r.header {\n\t\theaders[key] = value\n\t}\n\n\treturn &Request{\n\t\tclient: r.client,\n\t\tmethod: r.method,\n\t\turl: r.url,\n\t\theader: headers,\n\t\tquery: r.query,\n\t\tbody: r.body,\n\t\tSuccess: r.Success,\n\t\tFailure: r.Failure,\n\t}\n}", "func mockRequest() *request.Request {\n\tr := request.Request{}\n\thl := request.HandlerList{\n\t\tAfterEachFn: func(item request.HandlerListRunItem) bool { return true },\n\t}\n\n\tr.Handlers = request.Handlers{\n\t\tValidate: hl,\n\t\tBuild: hl,\n\t\tSend: hl,\n\t\tSign: hl,\n\t\tValidateResponse: hl,\n\t\tUnmarshal: hl,\n\t\tUnmarshalMeta: hl,\n\t\tUnmarshalError: hl,\n\t\tRetry: hl,\n\t\tAfterRetry: hl,\n\t\tComplete: hl,\n\t}\n\n\treturn &r\n}", "func NewRequest(method, urlStr string, body ...[]byte) (*Request, error) {\n\tif method == \"\" {\n\t\tmethod = \"GET\"\n\t}\n\tvar r io.Reader\n\tif body != nil {\n\t\tr = bytes.NewReader(body[0])\n\t}\n\n\treq, err := http.NewRequest(method, urlStr, r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Request{Req: req}, nil\n}", "func NewRequest(method, urlStr string, body io.Reader) (*Request, error) {\n\treq, err := http.NewRequest(method, urlStr, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Request{\n\t\t\treq, Retries, Timeout, backoff.NewExponentialBackOff()},\n\t\tnil\n}", "func (s *ApplicationsService) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := s.NewRequest(op, params, data)\n\n\treturn req\n}", "func NewRequest(bufConn io.Reader) (*Request, error) {\n\t// Read the version byte\n\theader := []byte{0, 0, 0}\n\tif _, err := io.ReadAtLeast(bufConn, header, 3); err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to get command version: %v\", err)\n\t}\n\n\t// ensure compatibility\n\tif header[0] != socks5Version {\n\t\treturn nil, fmt.Errorf(\"Unsupported command version: %v\", header[0])\n\t}\n\n\t// Read in the destination address\n\tdest, err := readAddrSpec(bufConn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Request{\n\t\tVersion: socks5Version,\n\t\tCommand: header[1],\n\t\tDestAddr: dest,\n\t\tbufConn: bufConn,\n\t}, nil\n}", "func (c *Client) NewRequest(ctx context.Context, method, path string, params interface{}, data interface{}) *request.Request {\n\thttpReq, _ := http.NewRequest(method, path, nil)\n\thttpReq = httpReq.WithContext(ctx)\n\thttpReq.URL, _ = url.Parse(c.Info.Endpoint + path)\n\n\tr := request.New(httpReq, c.Info, c.Handlers.Copy(), params, data)\n\tr.HTTPClient = c.HTTPClient\n\treturn r\n}", "func (api *API) Request(method string, result interface{}) *resty.Request {\n\trequest := resty.New().R()\n\tif result != nil {\n\t\trequest.SetResult(result)\n\t}\n\n\treturn request\n}", "func NewRequest(parent context.Context, br *openrtb.BidRequest, endpoint string, encoder Encoder) (*Request, error) {\n\tif br == nil {\n\t\treturn nil, ErrNilBidRequest\n\t} else if len(endpoint) == 0 {\n\t\treturn nil, ErrEmptyURL\n\t}\n\n\tif encoder == nil {\n\t\tencoder = DefaultEncoder\n\t}\n\n\t// TODO(@garukun): Consider implementing another constructor that does not marshal bid request\n\t// object to JSON reader every single time.\n\tbuf := bytes.NewBuffer(nil)\n\tif err := encoder.EncodeToWriter(buf, br); err != nil {\n\t\treturn nil, err\n\t}\n\n\thr, err := http.NewRequest(http.MethodPost, endpoint, buf)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Request{\n\t\tctx: parent,\n\t\tbr: br,\n\t\thr: hr,\n\t}, nil\n}", "func (c *IoT) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\t// Run custom request initialization if present\n\tif initRequest != nil {\n\t\tinitRequest(req)\n\t}\n\n\treturn req\n}", "func NewRequest(host string) *Request {\n\trequest := &Request{host, url.Values{}, http.Header{}, BasicAuth{}}\n\treturn request\n}", "func (c *Client) NewRequest(method, relPath string, body, options, headers interface{}) (*http.Request, error) {\n\trel, err := url.Parse(relPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Make the full url based on the relative path\n\tu := c.baseURL.ResolveReference(rel)\n\n\t// Add custom options\n\tif options != nil {\n\t\toptionsQuery, err := query.Values(options)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tfor k, values := range u.Query() {\n\t\t\tfor _, v := range values {\n\t\t\t\toptionsQuery.Add(k, v)\n\t\t\t}\n\t\t}\n\t\tu.RawQuery = optionsQuery.Encode()\n\t}\n\n\t// A bit of JSON ceremony\n\tvar js []byte = nil\n\tif body != nil {\n\t\tjs, err = json.Marshal(body)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treq, err := http.NewRequest(method, u.String(), bytes.NewBuffer(js))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\treq.Header.Add(\"Accept\", \"application/json\")\n\treq.Header.Add(\"User-Agent\", UserAgent)\n\n\tc.makeSignature(req)\n\n\treturn req, nil\n}", "func (c *Client) NewRequest(method, path string, reqBody interface{}, needAuth bool) (*http.Request, error) {\n\tvar body []byte\n\tvar err error\n\n\tif reqBody != nil {\n\t\tbody, err = json.Marshal(reqBody)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\ttarget := fmt.Sprintf(\"%s%s\", c.APIEndPoint, path)\n\treq, err := http.NewRequest(method, target, bytes.NewReader(body))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Inject headers\n\tif body != nil {\n\t\treq.Header.Set(\"Content-Type\", \"application/json;charset=utf-8\")\n\t}\n\treq.Header.Set(\"Authorization\", fmt.Sprintf(\"sso-key %s:%s\", c.APIKey, c.APISecret))\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treq.Header.Set(\"User-Agent\", \"ExternalDNS/\"+externaldns.Version)\n\n\t// Send the request with requested timeout\n\tc.Client.Timeout = c.Timeout\n\n\treturn req, nil\n}", "func NewRequest(r *http.Request, cfg *UploadsConfig) (req *Request, err error) {\n\treq = &Request{\n\t\tRemoteAddr: fetchIP(r.RemoteAddr),\n\t\tProtocol: r.Proto,\n\t\tMethod: r.Method,\n\t\tURI: uri(r),\n\t\tHeader: r.Header,\n\t\tCookies: make(map[string]string),\n\t\tRawQuery: r.URL.RawQuery,\n\t\tAttributes: attributes.All(r),\n\t}\n\n\tfor _, c := range r.Cookies() {\n\t\tif v, err := url.QueryUnescape(c.Value); err == nil {\n\t\t\treq.Cookies[c.Name] = v\n\t\t}\n\t}\n\n\tswitch req.contentType() {\n\tcase contentNone:\n\t\treturn req, nil\n\n\tcase contentStream:\n\t\treq.body, err = ioutil.ReadAll(r.Body)\n\t\treturn req, err\n\n\tcase contentMultipart:\n\t\tif err = r.ParseMultipartForm(defaultMaxMemory); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treq.Uploads = parseUploads(r, cfg)\n\t\tfallthrough\n\tcase contentFormData:\n\t\tif err = r.ParseForm(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treq.body = parseData(r)\n\t}\n\n\treq.Parsed = true\n\treturn req, nil\n}", "func Request(ctx context.Context) *http.Request {\n\treturn ctx.Value(reqKey).(*http.Request)\n}", "func newRequest(ctx context.Context, msg interface{}) *request {\n\treturn &request{\n\t\tctx: ctx,\n\t\tmsg: msg,\n\t\tfailure: make(chan error, 1),\n\t\tresponse: make(chan *Delivery, 1),\n\t}\n}", "func newRequest(method, path string, body io.Reader) (*http.Request, error) {\n\tr := http.Request{\n\t\tMethod: method,\n\t\tURL: &url.URL{Path: path},\n\t\tProto: \"HTTP/1.1\",\n\t\tProtoMajor: 1,\n\t\tProtoMinor: 1,\n\t\tHeader: make(http.Header),\n\t}\n\n\tif body != nil {\n\t\tswitch b := body.(type) {\n\t\tcase *bytes.Buffer:\n\t\t\tr.Body = ioutil.NopCloser(body)\n\t\t\tr.ContentLength = int64(b.Len())\n\t\tcase *bytes.Reader:\n\t\t\tr.Body = ioutil.NopCloser(body)\n\t\t\tr.ContentLength = int64(b.Len())\n\t\tcase *strings.Reader:\n\t\t\tr.Body = ioutil.NopCloser(body)\n\t\t\tr.ContentLength = int64(b.Len())\n\t\tdefault:\n\t\t\tr.Body = ioutil.NopCloser(body)\n\t\t}\n\t}\n\n\treturn &r, nil\n}", "func NewRequest(commandName string, arguments []string) ([]byte, error) {\n\tvar err error\n\tvar q Request\n\tvar payload []byte\n\n\tq = Request{Command: commandName, Arguments: arguments}\n\n\tif payload, err = json.Marshal(q); err != nil {\n\t\tlog.Fatalln(\"Error on JSON Marshal: \", err)\n\t\treturn nil, err\n\t}\n\n\treturn payload, nil\n}", "func (r *Request) Build() (*Request, error) {\n\tif err := r.checkError(); err != nil {\n\t\treturn nil, err\n\t}\n\tif \"\" == r.httpVerb {\n\t\treturn nil, errors.New(\"No HttpVerb Provided\")\n\t}\n\tif \"\" == r.url {\n\t\treturn nil, errors.New(\"No URL Provided\")\n\t}\n\n\t// Check if this can be moved to WithHeaders method or using url.Values{}\n\tif r.requestParams != nil {\n\t\treqParamString := \"?\"\n\t\tfor k, v := range r.requestParams {\n\t\t\tif reqParamString != \"?\" {\n\t\t\t\treqParamString += \"&\"\n\t\t\t}\n\t\t\treqParamString = reqParamString + k + `=` + v\n\t\t}\n\t\tr.url = r.url + reqParamString\n\t}\n\n\t// TODO: Move to a Function\n\tif len(r.requestBody) == 0 && len(r.requestBodyParams) != 0 {\n\t\tr.WithRequestBody(r.requestBodyParams)\n\t}\n\n\treturn r, nil\n}", "func NewRequest(command string) (qr quantum.Request, err error) {\n\tr := Request{\n\t\tCommand: command,\n\t}\n\td, err := json.Marshal(r)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tqr = NewRequestJSON(d)\n\treturn\n}", "func (r *Forecast) Request(req *Request) *Forecast {\n\tr.req = req\n\n\treturn r\n}", "func NewRequest(id string, method string) *Request {\n\n\treq := &Request{\n\t\tJSONRPC: \"2.0\",\n\t\tID: id,\n\t\tMethod: method,\n\t}\n\treturn req\n}", "func (c *Client) NewRequest(url string) *Request {\n\tvar r Request\n\tr.params = make(map[string]string)\n\n\tif url[0] == '/' {\n\t\turl = url[1:]\n\t}\n\tr.url = url\n\tr.client = c\n\n\treturn &r\n}", "func (c *Client) Request(verb, spath string, ro *RequestOptions) (*http.Request, error) {\n\tlog.Printf(\"[INFO] request: %s %s\", verb, spath)\n\n\tif ro == nil {\n\t\tro = new(RequestOptions)\n\t}\n\n\tu := *c.URL\n\tu.Path = path.Join(c.URL.Path, spath)\n\n\tif c.Token != \"\" {\n\t\tif ro.Headers == nil {\n\t\t\tro.Headers = make(map[string]string)\n\t\t}\n\t\tro.Headers[\"Authorization\"] = fmt.Sprintf(\"Bearer %s\", c.Token)\n\t}\n\n\treturn c.rawRequest(verb, &u, ro)\n}", "func (c *Client) NewRequest(method, requestPath string) *Request {\n\tc.modifyLock.RLock()\n\taddr := c.addr\n\ttoken := c.token\n\tmfaCreds := c.mfaCreds\n\twrappingLookupFunc := c.wrappingLookupFunc\n\tpolicyOverride := c.policyOverride\n\tc.modifyLock.RUnlock()\n\n\thost := addr.Host\n\t// if SRV records exist (see https://tools.ietf.org/html/draft-andrews-http-srv-02), lookup the SRV\n\t// record and take the highest match; this is not designed for high-availability, just discovery\n\t// Internet Draft specifies that the SRV record is ignored if a port is given\n\tif addr.Port() == \"\" && c.config.SRVLookup {\n\t\t_, addrs, err := net.LookupSRV(\"http\", \"tcp\", addr.Hostname())\n\t\tif err == nil && len(addrs) > 0 {\n\t\t\thost = fmt.Sprintf(\"%s:%d\", addrs[0].Target, addrs[0].Port)\n\t\t}\n\t}\n\n\treq := &Request{\n\t\tMethod: method,\n\t\tURL: &url.URL{\n\t\t\tUser: addr.User,\n\t\t\tScheme: addr.Scheme,\n\t\t\tHost: host,\n\t\t\tPath: path.Join(addr.Path, requestPath),\n\t\t},\n\t\tHost: addr.Host,\n\t\tClientToken: token,\n\t\tParams: make(map[string][]string),\n\t}\n\n\tvar lookupPath string\n\tswitch {\n\tcase strings.HasPrefix(requestPath, \"/v1/\"):\n\t\tlookupPath = strings.TrimPrefix(requestPath, \"/v1/\")\n\tcase strings.HasPrefix(requestPath, \"v1/\"):\n\t\tlookupPath = strings.TrimPrefix(requestPath, \"v1/\")\n\tdefault:\n\t\tlookupPath = requestPath\n\t}\n\n\treq.MFAHeaderVals = mfaCreds\n\n\tif wrappingLookupFunc != nil {\n\t\treq.WrapTTL = wrappingLookupFunc(method, lookupPath)\n\t} else {\n\t\treq.WrapTTL = DefaultWrappingLookupFunc(method, lookupPath)\n\t}\n\n\treq.Headers = c.Headers()\n\treq.PolicyOverride = policyOverride\n\n\treturn req\n}", "func NewRequest(token string) *Request {\n\treqID := fmt.Sprintf(\"alaudacli-%d\", time.Now().Unix())\n\trestyReq := resty.R()\n\trestyReq.SetHeader(\"Content-Type\", \"application/json\")\n\trestyReq.SetHeader(\"Alauda-Request-ID\", reqID)\n\n\tif token != \"\" {\n\t\trestyReq.SetHeader(\"Authorization\", fmt.Sprintf(\"Token %s\", token))\n\t}\n\n\treturn &Request{\n\t\trestyReq,\n\t}\n}", "func (a *APITest) Request() *Request {\n\treturn a.request\n}", "func (rt *registryRoundTripper) NewRequest(method, path string,\n\tquery *url.Values, body interface{}) (*http.Request, error) {\n\n\treq, err := rt.DefaultRequestDoer.NewRequest(method, path, query, body)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif tok := rt.holder.Token(); tok != \"\" {\n\t\treq.Header.Set(\"Authorization\", \"Bearer \"+tok)\n\t}\n\n\treq.Header.Set(\"User-Agent\", \"Torus-Daemon/\"+rt.version)\n\treq.Header.Set(\"X-Registry-Version\", rt.apiVersion)\n\n\treturn req, nil\n}", "func NewRequestObject(node *tree.Node, res www.ResponseWriter, r *www.Request) *Request {\n\n\treturn &Request{\n\t\tParameters: \tparameters.New(),\n\t\tconfig:\t\t\tnode.Config,\n\t\tNode:\t\t\tnode,\n\t\tres:\t\t \tres,\n\t\tr: \t\t\t\tr,\n\t\tmethod: \t\tr.Method,\n\t}\n}", "func (c client) newRequest(ctx context.Context, method string, url string, body io.Reader) (*http.Request, error) {\n\treq, err := http.NewRequestWithContext(ctx, method, url, body)\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to build request %w\", err)\n\t}\n\n\treturn req, nil\n}" ]
[ "0.73795944", "0.71671206", "0.70723724", "0.70567113", "0.69686484", "0.6907132", "0.68797153", "0.68797153", "0.68705773", "0.68705773", "0.68705773", "0.6861712", "0.68570507", "0.68570507", "0.6850988", "0.68318594", "0.6826593", "0.6780901", "0.67803687", "0.6775812", "0.6749095", "0.674192", "0.6670509", "0.66667384", "0.66025054", "0.6588116", "0.65837353", "0.65777725", "0.65765405", "0.6571973", "0.65408385", "0.65356886", "0.6498663", "0.6494698", "0.6486694", "0.6482431", "0.64689076", "0.6465789", "0.6465072", "0.64327115", "0.6425263", "0.64133984", "0.6410421", "0.640301", "0.63916427", "0.638521", "0.63847613", "0.6367591", "0.6362813", "0.63603306", "0.63492787", "0.6333264", "0.63244534", "0.6320266", "0.6311177", "0.6309158", "0.6307617", "0.63064253", "0.62992394", "0.629578", "0.6287799", "0.6286711", "0.6286627", "0.6273797", "0.62627524", "0.6257802", "0.62523466", "0.62505513", "0.6243899", "0.62398016", "0.6223657", "0.62171316", "0.62170917", "0.6216524", "0.6216206", "0.62115234", "0.6207934", "0.6204767", "0.6204446", "0.62034774", "0.61938286", "0.6191767", "0.61770177", "0.61766094", "0.6176006", "0.61753464", "0.6168175", "0.61657584", "0.61638665", "0.616349", "0.6158406", "0.6157383", "0.6156242", "0.61517197", "0.61486554", "0.61471725", "0.6141996", "0.61372423", "0.61368334", "0.6136393" ]
0.80211514
0
OPTIONS is a shorthand for e.Request("OPTIONS", path, pathargs...).
OPTIONS — это сокращение для e.Request("OPTIONS", path, pathargs...).
func (e *Expect) OPTIONS(path string, pathargs ...interface{}) *Request { return e.Request(http.MethodOptions, path, pathargs...) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Options(url string, data ...interface{}) (*ClientResponse, error) {\n\treturn DoRequest(\"OPTIONS\", url, data...)\n}", "func (g *Group) OPTIONS(path string, handler Handler, middleware ...Middleware) *Group {\n\treturn g.Add(http.MethodOptions, path, handler, middleware...)\n}", "func (r *Request) Options(path string, params ...url.Values) {\n\tcontentType := \"text/html\"\n\n\tif len(params) == 0 {\n\t\tr.Send(\"OPTIONS\", path, contentType)\n\t} else {\n\t\tr.Send(\"OPTIONS\", path, contentType, params[0])\n\t}\n}", "func Options(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\trecord(\"OPTIONS\", path)\n\n\tinfoMutex.Lock()\n\tr.OPTIONS(path, Handler(alice.New(c...).ThenFunc(fn)))\n\tinfoMutex.Unlock()\n}", "func (serv *Server) OPTIONS(url string, handlers ...Handler) {\n\tserv.Handle(\"OPTIONS\", url, handlers...)\n}", "func (r *Router) OPTIONS(url string, viewFn View) *Path {\n\treturn r.Path(fasthttp.MethodOptions, url, viewFn)\n}", "func (router *Router) OPTIONS(relativePath string, handler Handler, decorators ...Decorator) {\n\trouter.createRouter(http.MethodOptions, relativePath, handler, \"\", decorators...)\n}", "func (c *Client) Options(url string, headers, queryParams map[string][]string) (response *http.Response, err error) {\n\treturn c.makeRequest(url, http.MethodOptions, headers, queryParams, nil)\n}", "func (engine *Engine) OPTIONS(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn engine.handle(http.MethodOptions, relativePath, handlers)\n}", "func (e *Engine) OPTIONS(path string, handler Handler) {\n\te.registerRoute(http.MethodOptions, path, handler)\n}", "func (c *Client) Options(ctx context.Context, url string, data ...interface{}) (*Response, error) {\n\treturn c.DoRequest(ctx, http.MethodOptions, url, data...)\n}", "func (f *Fastglue) OPTIONS(path string, h FastRequestHandler) {\n\tf.Router.OPTIONS(path, f.handler(h))\n}", "func (r *Router) OPTIONS(path string, handle HandlerFunc, middleware ...MiddlewareFunc) {\n\tr.Handle(\"OPTIONS\", path, handle, middleware...)\n}", "func (group *RouterGroup) OPTIONS(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn group.handle(http.MethodOptions, relativePath, handlers)\n}", "func (F *Frisby) Options(url string) *Frisby {\n\tF.Method = \"OPTIONS\"\n\tF.Url = url\n\treturn F\n}", "func (group *RouterGroup) OPTIONS(path string, handlers ...HandlerFunc) {\n\tgroup.Handle(\"OPTIONS\", path, handlers)\n}", "func (r *bitroute) OPTIONS(path string, f func(router.Control)) {\n\tr.register(\"OPTIONS\", path, f)\n}", "func (r *Router) OPTIONS(path string, h HandlerFunc) {\n\tr.router.OPTIONS(path, r.handle(h, r.getValidationForPath(path, \"OPTIONS\")))\n}", "func Options(c *gin.Context) {\n\tif c.Request.Method != \"OPTIONS\" {\n\t\tc.Next()\n\t} else {\n\t\tc.Header(\"Access-Control-Allow-Origin\", \"*\")\n\t\tc.Header(\"Access-Control-Allow-Methods\", \"GET,POST,PUT,PATCH,DELETE,OPTIONS\")\n\t\tc.Header(\"Access-Control-Allow-Headers\", \"authorization,origin,content-type,accept\")\n\t\tc.Header(\"Allow\", \"HEAD,GET,POST,PUT,PATCH,DELETE,OPTIONS\")\n\t\tc.Header(\"Content-Type\", \"application/json\")\n\t\tc.AbortWithStatus(200)\n\t}\n}", "func (router *Router) Options(path string, handler http.Handler) {\n\trouter.Handle(\"OPTIONS\", path, handler)\n}", "func (rg *RouteGroup) OPTIONS(path string, handlers ...Handler) *Route {\n\treturn rg.add(\"OPTIONS\", path, handlers)\n}", "func (r *Router) OPTIONS(path string, handle Handle) {\n\tr.Handle(http.MethodOptions, path, handle)\n}", "func (s *Server) OPTIONS(path string, handle http.HandlerFunc) {\n\ts.router.OPTIONS(\"/*path\", s.wrapHandler(handle))\n}", "func (r *Mux) OPTIONS(path string, handler http.HandlerFunc) {\n\tr.HandleFunc(\"OPTIONS\", path, handler)\n}", "func (n *NS) Options(url string) *route {\n\treturn &route{context: n.c, method: \"OPTIONS\", url: n.prefix + url, bCtrl: n.bCtrl, aCtrl: n.aCtrl}\n}", "func (r *Request) Options(url string) (*Response, error) {\n\treturn r.Execute(MethodOptions, url)\n}", "func (rb *RequestBuilder) Options(url string) *Response {\n\treturn rb.DoRequest(http.MethodOptions, url, nil)\n}", "func (g *Group) OPTIONS(path string, h Handler, gases ...Gas) {\n\tg.Air.OPTIONS(g.Prefix+path, h, append(g.Gases, gases...)...)\n}", "func Options(path string, fn httprouter.Handle) {\n\tr.Router.OPTIONS(path, fn)\n}", "func Option(c *gin.Context) {\n\tif c.Request.Method != \"OPTIONS\" {\n\t\tc.Next()\n\t} else {\n\t\tc.Header(\"Access-Control-Allow-Origin\", \"*\")\n\t\tc.Header(\"Access-Control-Allow-Methods\", \"GET,POST,PUT,OPTIONS,PATCH,DELETE\")\n\t\tc.Header(\"Access-Control-Allow-Headers\", \"authorization,origin,content-type,accept\")\n\t\tc.Header(\"Allow\", \"HEAD,GET,POST,PUT,OPTIONS,PATCH,DELETE\")\n\t\tc.Header(\"Content-Cype\", \"application/json\")\n\t\tc.AbortWithStatus(200)\n\t}\n\n}", "func (this *Route) OPTIONS(handlers ...HTTPHandler) *Route {\n\treturn this.addHandler(\"options\", handlers...)\n}", "func (r *Router) OPTIONS(route string, handler interface{}) *Router {\n\tr.Handle(MethodOPTIONS, route, handler)\n\treturn r\n}", "func (g *RouterGroup) OPTIONS(url string, handler ...Handler) *RouterGroup {\n\tg.app.routeANY = false\n\tg.AppendReqAndResp(url, \"options\", handler)\n\treturn g\n}", "func OptionsHandler(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Add(\"Allow\", http.MethodGet)\n\tw.Header().Add(\"Allow\", http.MethodHead)\n\tw.Header().Add(\"Allow\", http.MethodPost)\n\tw.Header().Add(\"Allow\", http.MethodPut)\n\tw.Header().Add(\"Allow\", http.MethodDelete)\n\tw.Header().Add(\"Allow\", http.MethodOptions)\n\tw.Header().Set(\"Transfer-Encoding\", \"chunked\")\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tw.WriteHeader(http.StatusNoContent)\n}", "func Options(ctx context.Context, url string, options ...RequestOption) (*Response, error) {\n\tr, err := newRequest(ctx, http.MethodConnect, url, nil, options...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn doRequest(http.DefaultClient, r)\n}", "func OptionsBytes(url string, data ...interface{}) []byte {\n\treturn RequestBytes(\"OPTIONS\", url, data...)\n}", "func (r *Route) Options(h http.Handler) *Route {\n\tr.Add(\"OPTIONS\", h)\n\n\treturn r\n}", "func (app *App) OPTIONS(url string, handler ...Handler) *App {\n\tapp.routeANY = false\n\tapp.AppendReqAndResp(url, \"options\", handler)\n\treturn app\n}", "func (c *Client) Request(verb, spath string, ro *RequestOptions) (*http.Request, error) {\n\tlog.Printf(\"[INFO] request: %s %s\", verb, spath)\n\n\tif ro == nil {\n\t\tro = new(RequestOptions)\n\t}\n\n\tu := *c.URL\n\tu.Path = path.Join(c.URL.Path, spath)\n\n\tif c.Token != \"\" {\n\t\tif ro.Headers == nil {\n\t\t\tro.Headers = make(map[string]string)\n\t\t}\n\t\tro.Headers[\"Authorization\"] = fmt.Sprintf(\"Bearer %s\", c.Token)\n\t}\n\n\treturn c.rawRequest(verb, &u, ro)\n}", "func (r *Router) Options(pattern string, handlers ...interface{}) *Router {\n\tc := r.pattern(pattern)\n\tc.Method = \"OPTIONS\"\n\tclone := r.clone(c)\n\tclone.handle(handlers)\n\treturn clone\n}", "func (rg *RouteGroup) Options(path string, handlers ...Handler) *Route {\n\treturn rg.add(\"OPTIONS\", path, handlers)\n}", "func (r *Router) OPTIONS(pattern string, handler func(Context)) Route {\n\treturn r.Handle(\"OPTIONS\", pattern, wrap(handler))\n}", "func Options(c *gin.Context) {\r\n\tc.Writer.Header().Set(\"Access-Control-Allow-Methods\", \"DELETE,POST,PUT\")\r\n\tc.Writer.Header().Set(\"Access-Control-Allow-Headers\", \"Content-Type\")\r\n\tc.Next()\r\n}", "func (r *Router) Options(pattern string, handler http.Handler) Route {\n\treturn r.Handle(\"OPTIONS\", pattern, handler)\n}", "func (s *System) Options(path string) string, error {\n\treq, err := http.NewRequest(http.MethodOptions, \"https://\"+s.host+\"/bps/api/v2/core/\"+path, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t//add the header\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\tres, err := s.HTTPClient.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer res.Body.Close()\n\n\tif res.StatusCode != http.StatusNoContent {\n\t\treturn fmt.Errorf(\"unknown error, status code: %d\", res.StatusCode)\n\t}\n\n\treturn nil\n}", "func (router *Router) OptionsFunc(path string, handler http.HandlerFunc) {\n\trouter.Handle(\"OPTIONS\", path, handler)\n}", "func (mm *Middleman) Options(path string, middleware Middleware) error {\r\n\treturn mm.addMiddleware(path, http.MethodOptions, middleware)\r\n}", "func (APIResourceBase) Options(session *Session, url string, queries url.Values, body io.Reader) (APIStatus, interface{}) {\n\treturn FailSimple(http.StatusMethodNotAllowed), nil\n}", "func (tr *Transport) Options(url string, fn HandlerFunc, options ...HandlerOption) {\n\ttr.mux.Handler(net_http.MethodOptions, url, encapsulate(fn, tr.options, options))\n}", "func OptionsResponse(w http.ResponseWriter, r *http.Request, argv map[string]string) error {\n\tw.Header().Set(\"Allow\", \"GET,PUT,POST,DELETE,OPTIONS\")\n\n\treturn nil\n}", "func OptionsContent(url string, data ...interface{}) string {\n\treturn RequestContent(\"OPTIONS\", url, data...)\n}", "func (r *Router) Options(path string, handle HandleFunc) {\n\tr.register(path, http.MethodOptions, handle)\n}", "func DefaultOptions(\n server Server,\n transactor *Transactor,\n methods []*RouteControllerHelper,\n) responses.Data {\n var methodStrings []string\n seenMethods := map[RequestMethod]bool{\n MethodOPTIONS: true,\n }\n for _, rch := range(methods) {\n for _, method := range rch.AllMethods() {\n if _, ok := seenMethods[method]; !ok {\n methodStrings = append(methodStrings, method.String())\n seenMethods[method] = true\n }\n }\n }\n sort.Strings(methodStrings)\n methodStrings = append([]string{MethodOPTIONS.String()}, methodStrings...)\n err := transactor.SetHeader(\n \"Access-Control-Allow-Methods\",\n strings.Join(methodStrings, \", \"),\n )\n if err != nil {\n return transactor.Abort(\n http.StatusInternalServerError,\n neterr.DefaultOptionsHeaderSetError,\n neterr.CodedErrorFromError(0, err),\n )\n }\n\n return transactor.Respond(http.StatusOK)\n}", "func (r *Router) Options(path, title string, fn Handle) {\n\tr.addRoute(\"OPTIONS\", path, title, fn)\n}", "func (m *MockRouterTx) OPTIONS(path string, handler interface{}, options ...interface{}) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{path, handler}\n\tfor _, a := range options {\n\t\tvarargs = append(varargs, a)\n\t}\n\tm.ctrl.Call(m, \"OPTIONS\", varargs...)\n}", "func (r *Route) Options(h interface{}) *Route {\n\treturn r.Handle(toHandler(h), \"OPTIONS\")\n}", "func (m *MockRouter) OPTIONS(path string, handler interface{}, options ...interface{}) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{path, handler}\n\tfor _, a := range options {\n\t\tvarargs = append(varargs, a)\n\t}\n\tm.ctrl.Call(m, \"OPTIONS\", varargs...)\n}", "func (server *HTTPServer) handleOptionsMethod(nextHandler http.Handler) http.Handler {\n\treturn http.HandlerFunc(\n\t\tfunc(w http.ResponseWriter, r *http.Request) {\n\t\t\tif r.Method == \"OPTIONS\" {\n\t\t\t\tw.WriteHeader(http.StatusOK)\n\t\t\t} else {\n\t\t\t\tnextHandler.ServeHTTP(w, r)\n\t\t\t}\n\t\t})\n}", "func (server *HTTPServer) handleOptionsMethod(nextHandler http.Handler) http.Handler {\n\treturn http.HandlerFunc(\n\t\tfunc(w http.ResponseWriter, r *http.Request) {\n\t\t\tif r.Method == \"OPTIONS\" {\n\t\t\t\tw.WriteHeader(http.StatusOK)\n\t\t\t} else {\n\t\t\t\tnextHandler.ServeHTTP(w, r)\n\t\t\t}\n\t\t})\n}", "func Options(c *gin.Context) {\n\tOrigin := c.MustGet(\"CorsOrigin\").(string)\n\n\tc.Writer.Header().Set(\"Access-Control-Allow-Origin\", Origin)\n\tc.Writer.Header().Set(\"Access-Control-Allow-Methods\", \"GET,DELETE,POST,PUT\")\n\tc.Writer.Header().Set(\"Access-Control-Allow-Credentials\", \"true\")\n\tc.Writer.Header().Set(\"Access-Control-Allow-Headers\", \"Content-Type\")\n\tc.Next()\n}", "func (p *PatternServeMux) Options(pat string, h http.Handler) {\n\tp.Add(\"OPTIONS\", pat, h)\n}", "func (b *Baa) Options(pattern string, h ...HandlerFunc) RouteNode {\n\treturn b.Router().Add(\"OPTIONS\", pattern, h)\n}", "func RequestOptions(opts ...RequestOpt) Opt {\n\tif len(opts) == 0 {\n\t\treturn nil\n\t}\n\treturn func(c *Client) Opt {\n\t\told := append([]RequestOpt{}, c.requestOpts...)\n\t\tc.requestOpts = opts\n\t\treturn RequestOptions(old...)\n\t}\n}", "func (r *Router) Options(path string, handlers ...Handler) {\n\tr.addToRoutes(http.MethodOptions, path, handlers...)\n}", "func OptionsHandler(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Access-Control-Allow-Methods\", \"GET, POST, PUT\")\n\tw.Header().Set(\"Access-Control-Max-Age\", \"120\")\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tw.Header().Set(\"Access-Control-Allow-Headers\", \"content-type\")\n\tw.WriteHeader(200)\n}", "func (tr *Transport) OPTION(\n\turl string,\n\tfn Handler,\n\toptions ...HandlerOption,\n) {\n\ttr.mux.Handler(\n\t\tnet_http.MethodOptions,\n\t\turl,\n\t\tnewHandler(fn, append(tr.options, options...)...),\n\t)\n}", "func (m *Mux) Options(pattern string, handler HandlerFunc) {\n\tm.Handle(http.MethodOptions, pattern, handler)\n}", "func (mx *Mux) Options(pattern string, handlerFn http.HandlerFunc) {\n\tmx.handle(mOPTIONS, pattern, handlerFn)\n}", "func (c *ClientConn) Options(u *base.URL) (*base.Response, error) {\n\terr := c.checkState(map[clientConnState]struct{}{\n\t\tclientConnStateInitial: {},\n\t\tclientConnStatePrePlay: {},\n\t\tclientConnStatePreRecord: {},\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tres, err := c.Do(&base.Request{\n\t\tMethod: base.Options,\n\t\tURL: u,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif res.StatusCode != base.StatusOK {\n\t\t// since this method is not implemented by every RTSP server,\n\t\t// return only if status code is not 404\n\t\tif res.StatusCode == base.StatusNotFound {\n\t\t\treturn res, nil\n\t\t}\n\t\treturn res, liberrors.ErrClientWrongStatusCode{Code: res.StatusCode, Message: res.StatusMessage}\n\t}\n\n\tc.getParameterSupported = func() bool {\n\t\tpub, ok := res.Header[\"Public\"]\n\t\tif !ok || len(pub) != 1 {\n\t\t\treturn false\n\t\t}\n\n\t\tfor _, m := range strings.Split(pub[0], \",\") {\n\t\t\tif base.Method(m) == base.GetParameter {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\treturn false\n\t}()\n\n\treturn res, nil\n}", "func (m *Mux) OptionsFunc(path string, handler http.HandlerFunc) *Route {\n\treturn m.register(\"OPTIONS\", path, handler)\n}", "func Options(url string, opts ...RequestOption) (*Response, error) {\n\treturn DefaultSession.Options(url, opts...)\n}", "func SendOptions(ctx context.Context, response http.ResponseWriter,\n\trequest *http.Request, pipeline filter.Pipeline) {\n\tresponse.Header().Add(\"Allow\", \"OPTIONS, GET, HEAD\")\n\tresponse.WriteHeader(http.StatusNoContent)\n\tmedia := strings.NewReader(\"\")\n\terr := error(nil)\n\tif len(pipeline) > 0 {\n\t\t// use a filter pipeline\n\t\t_, err = filter.PipelineCopy(ctx, response, media, request, pipeline)\n\t} else {\n\t\t// unfiltered, simple copy\n\t\t_, err = io.Copy(response, media)\n\t}\n\tif err != nil {\n\t\tlog.Error().Msgf(\"SendOptions: %v\", err)\n\t}\n}", "func (mr *MockRouterMockRecorder) OPTIONS(path, handler interface{}, options ...interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\tvarargs := append([]interface{}{path, handler}, options...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"OPTIONS\", reflect.TypeOf((*MockRouter)(nil).OPTIONS), varargs...)\n}", "func (mr *MockRouterTxMockRecorder) OPTIONS(path, handler interface{}, options ...interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\tvarargs := append([]interface{}{path, handler}, options...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"OPTIONS\", reflect.TypeOf((*MockRouterTx)(nil).OPTIONS), varargs...)\n}", "func (r *Route) Options(handler http.Handler) *Route {\n\tr.handlers[http.MethodOptions] = handler\n\treturn r\n}", "func (s *Nap) Options(pathURL string) *Nap {\n\ts.method = MethodOptions\n\treturn s.Path(pathURL)\n}", "func (ctl Controller) Options(ctx *gin.Context) {\n\n\tMethodNotAllowedJSON(ctx)\n}", "func (c *BaseController) Options(w http.ResponseWriter, r *Request) {\n\thttp.Error(w, \"Method Not Allowed\", 405)\n}", "func TestOptionsFilter(t *testing.T) {\n\ttearDown()\n\tws := new(WebService)\n\tws.Route(ws.GET(\"/candy/{kind}\").To(dummy))\n\tws.Route(ws.DELETE(\"/candy/{kind}\").To(dummy))\n\tws.Route(ws.POST(\"/candies\").To(dummy))\n\tAdd(ws)\n\tFilter(OPTIONSFilter())\n\n\thttpRequest, _ := http.NewRequest(\"OPTIONS\", \"http://here.io/candy/gum\", nil)\n\thttpWriter := httptest.NewRecorder()\n\tDefaultContainer.dispatch(httpWriter, httpRequest)\n\tactual := httpWriter.Header().Get(HEADER_Allow)\n\tif \"GET,DELETE\" != actual {\n\t\tt.Fatal(\"expected: GET,DELETE but got:\" + actual)\n\t}\n\n\thttpRequest, _ = http.NewRequest(\"OPTIONS\", \"http://here.io/candies\", nil)\n\thttpWriter = httptest.NewRecorder()\n\tDefaultContainer.dispatch(httpWriter, httpRequest)\n\tactual = httpWriter.Header().Get(HEADER_Allow)\n\tif \"POST\" != actual {\n\t\tt.Fatal(\"expected: POST but got:\" + actual)\n\t}\n}", "func handleOptions(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"Handle options!\")\n\tw.Header().Set(\"Access-Control-Allow-Credentials\", \"false\")\n\tw.Header().Set(\"Access-Control-Allow-Headers\", \"Accept, Content-Type, Pragma, X-Requested-With\")\n\tw.Header().Set(\"Access-Control-Allow-Methods\", \"POST, GET, PUT, DELETE, OPTIONS\")\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tw.Header().Set(\"Access-Control-Max-Age\", \"86400\")\n\tw.WriteHeader(http.StatusOK)\n\treturn\n}", "func (o *OptionsFilter) Filter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {\n\tif \"OPTIONS\" != req.Request.Method {\n\t\tchain.ProcessFilter(req, resp)\n\t\treturn\n\t}\n\n\tarchs := req.Request.Header.Get(restful.HEADER_AccessControlRequestHeaders)\n\t//methods := strings.Join(o.getContainer().ComputeAllowedMethods(req), \",\")\n\torigin := req.Request.Header.Get(restful.HEADER_Origin)\n\tif len(origin) == 0 {\n\t\torigin = \"*\"\n\t}\n\tlog.Printf(\"request >> origin:%s\\n\", origin)\n\tresp.AddHeader(restful.HEADER_Allow, \"*\")\n\tresp.AddHeader(restful.HEADER_AccessControlAllowOrigin, origin)\n\tresp.AddHeader(restful.HEADER_AccessControlAllowHeaders, archs)\n\tresp.AddHeader(restful.HEADER_AccessControlAllowMethods, \"*\")\n\tresp.AddHeader(restful.HEADER_AccessControlAllowCredentials, \"true\")\n}", "func AccessControlRequestMethod(value string) Option {\n\treturn setHeader(\"Access-Control-Request-Method\", value)\n}", "func (s *HTTPServer) preparedQuerySpecificOptions(resp http.ResponseWriter, req *http.Request) interface{} {\n\tpath := req.URL.Path\n\tswitch {\n\tcase strings.HasSuffix(path, \"/execute\"):\n\t\tresp.Header().Add(\"Allow\", strings.Join([]string{\"OPTIONS\", \"GET\"}, \",\"))\n\t\treturn resp\n\n\tcase strings.HasSuffix(path, \"/explain\"):\n\t\tresp.Header().Add(\"Allow\", strings.Join([]string{\"OPTIONS\", \"GET\"}, \",\"))\n\t\treturn resp\n\n\tdefault:\n\t\tresp.Header().Add(\"Allow\", strings.Join([]string{\"OPTIONS\", \"GET\", \"PUT\", \"DELETE\"}, \",\"))\n\t\treturn resp\n\t}\n}", "func (c *Client) HTTP(verb, spath string, ro *RequestOptions) (*http.Response, error) {\n\treq, err := c.Request(verb, spath, ro)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tres, err := dispose(c.HTTPClient.Do(req))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn res, nil\n}", "func OptGet() Option {\n\treturn func(r *Request) error {\n\t\tr.Method = \"GET\"\n\t\treturn nil\n\t}\n}", "func (r *Request) Get(path string) *Request {\n\treturn r.method(\"GET\", path)\n}", "func (mx *Mux) Options(pattern string, handler interface{}) {\n\tmx.handle(OPTIONS, pattern, handler)\n}", "func OptionsUser(c *gin.Context) {\n\tc.Writer.Header().Set(\"Access-Control-Allow-Methods\", \"DELETE,POST, PUT\")\n\tc.Writer.Header().Set(\"Access-Control-Allow-Headers\", \"Content-Type\")\n\tc.Next()\n}", "func (ctx *AppContext) OptionsHandler(h http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {\n\t\tif request.Method == \"OPTIONS\" {\n\t\t\tfmt.Fprintf(writer, \"\")\n\t\t\treturn\n\t\t}\n\n\t\th.ServeHTTP(writer, request)\n\t})\n}", "func (e *Expect) GET(path string, pathargs ...interface{}) *Request {\n\treturn e.Request(http.MethodGet, path, pathargs...)\n}", "func (api *Client) Call(opts *Opts) (resp *http.Response, err error) {\n\tapi.mu.RLock()\n\tdefer api.mu.RUnlock()\n\tif opts == nil {\n\t\treturn nil, errors.New(\"call() called with nil opts\")\n\t}\n\turl := api.rootURL\n\tif opts.RootURL != \"\" {\n\t\turl = opts.RootURL\n\t}\n\tif url == \"\" {\n\t\treturn nil, errors.New(\"RootURL not set\")\n\t}\n\turl += opts.Path\n\tif opts.Parameters != nil && len(opts.Parameters) > 0 {\n\t\turl += \"?\" + opts.Parameters.Encode()\n\t}\n\treq, err := http.NewRequest(opts.Method, url, opts.Body)\n\tif err != nil {\n\t\treturn\n\t}\n\theaders := make(map[string]string)\n\t// Set default headers\n\tfor k, v := range api.headers {\n\t\theaders[k] = v\n\t}\n\tif opts.ContentType != \"\" {\n\t\theaders[\"Content-Type\"] = opts.ContentType\n\t}\n\tif opts.ContentLength != nil {\n\t\treq.ContentLength = *opts.ContentLength\n\t}\n\tif opts.ContentRange != \"\" {\n\t\theaders[\"Content-Range\"] = opts.ContentRange\n\t}\n\t// Set any extra headers\n\tif opts.ExtraHeaders != nil {\n\t\tfor k, v := range opts.ExtraHeaders {\n\t\t\theaders[k] = v\n\t\t}\n\t}\n\t// add any options to the headers\n\tfs.OpenOptionAddHeaders(opts.Options, headers)\n\t// Now set the headers\n\tfor k, v := range headers {\n\t\tif v != \"\" {\n\t\t\treq.Header.Add(k, v)\n\t\t}\n\t}\n\tif opts.UserName != \"\" || opts.Password != \"\" {\n\t\treq.SetBasicAuth(opts.UserName, opts.Password)\n\t}\n\tc := ClientWithHeaderReset(api.c, headers)\n\tapi.mu.RUnlock()\n\tresp, err = c.Do(req)\n\tapi.mu.RLock()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !opts.IgnoreStatus {\n\t\tif resp.StatusCode < 200 || resp.StatusCode > 299 {\n\t\t\treturn resp, api.errorHandler(resp)\n\t\t}\n\t}\n\tif opts.NoResponse {\n\t\treturn resp, resp.Body.Close()\n\t}\n\treturn resp, nil\n}", "func digestOptions()(reqOpts RequestOptions, outOpts OutputOptions, err error) {\n\treturn RequestOptions{\n\t\tMethod : \"GET\",\n\t\tURL : \"localhost:8080/test\",\n\t}, OutputOptions {\n\t\tOutputHTML : true,\n\t\tShowFullJSON : true,\n\t}, nil\n}", "func Method(method string, urlPath string) (Request, error) {\n\tif method != \"GET\" && method != \"POST\" && method != \"PUT\" && method != \"DELETE\" &&\n\t\tmethod != \"HEAD\" && method != \"OPTIONS\" && method != \"PATCH\" {\n\t\treturn nil, errors.New(\"method not supported\")\n\t}\n\treturn newRequest(method, urlPath, sessionWithoutCookies)\n}", "func (e *Expect) PATCH(path string, pathargs ...interface{}) *Request {\n\treturn e.Request(http.MethodPatch, path, pathargs...)\n}", "func HttpOptions(httpOpts *server.Options) Option {\n\treturn func(c *Service) {\n\t\tc.serverOptions = httpOpts\n\t}\n}", "func optionsHandler(ctx apiContext, w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Access-Control-Allow-Origin\", originAddress)\n\tw.Header().Set(\"Access-Control-Allow-Headers\", supportedHeaders)\n\tw.Header().Set(\"Access-Control-Allow-Credentials\", \"true\")\n\tw.Header().Set(\"Access-Control-Allow-Methods\", methodsToString(ctx.supportedMethods))\n\tw.WriteHeader(http.StatusOK)\n}", "func (srv *Server) handleOptions(res http.ResponseWriter, req *http.Request) {\n\tmethods := make(map[string]bool)\n\n\tnode := srv.getFSNode(req.URL.Path)\n\tif node != nil {\n\t\tmethods[http.MethodGet] = true\n\t\tmethods[http.MethodHead] = true\n\t}\n\n\tfor _, rute := range srv.routeDeletes {\n\t\t_, ok := rute.parse(req.URL.Path)\n\t\tif ok {\n\t\t\tmethods[http.MethodDelete] = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor _, rute := range srv.routeGets {\n\t\t_, ok := rute.parse(req.URL.Path)\n\t\tif ok {\n\t\t\tmethods[http.MethodGet] = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor _, rute := range srv.routePatches {\n\t\t_, ok := rute.parse(req.URL.Path)\n\t\tif ok {\n\t\t\tmethods[http.MethodPatch] = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor _, rute := range srv.routePosts {\n\t\t_, ok := rute.parse(req.URL.Path)\n\t\tif ok {\n\t\t\tmethods[http.MethodPost] = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor _, rute := range srv.routePuts {\n\t\t_, ok := rute.parse(req.URL.Path)\n\t\tif ok {\n\t\t\tmethods[http.MethodPut] = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif len(methods) == 0 {\n\t\tres.WriteHeader(http.StatusNotFound)\n\t\treturn\n\t}\n\n\tmethods[http.MethodOptions] = true\n\n\tvar x int\n\tallows := make([]string, len(methods))\n\tfor k, v := range methods {\n\t\tif v {\n\t\t\tallows[x] = k\n\t\t\tx++\n\t\t}\n\t}\n\n\tsort.Strings(allows)\n\n\tres.Header().Set(\"Allow\", strings.Join(allows, \", \"))\n\tres.WriteHeader(http.StatusOK)\n}", "func OptionsAnswer(w http.ResponseWriter) {\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tw.Header().Set(\"Access-Control-Allow-Headers\", \"*\")\n\tw.Header().Set(\"Access-Control-Allow-Methods\", \"*\")\n}", "func OptionsUser(c *gin.Context) {\n\tc.Writer.Header().Add(\"Access-Control-Allow-Origin\", \"*\")\n\tc.Writer.Header().Set(\"Access-Control-Allow-Methods\", \"GET, DELETE, POST, PATCH, PUT, OPTIONS\")\n\tc.Writer.Header().Set(\"Access-Control-Allow-Headers\", \"Content-Type\")\n\tc.Writer.Header().Set(\"Access-Control-Allow-Headers\", \"X-Requested-With\")\n\tc.Next()\n}", "func ReqOpts(hdr http.Header) *toclient.RequestOptions {\n\topts := toclient.NewRequestOptions()\n\topts.Header = hdr\n\treturn &opts\n}" ]
[ "0.76900136", "0.7574512", "0.7364902", "0.7281106", "0.7234489", "0.7181617", "0.71771985", "0.71593726", "0.71545005", "0.7152557", "0.7115014", "0.70317966", "0.7006474", "0.697124", "0.69393027", "0.69371873", "0.69233954", "0.69009876", "0.6857603", "0.6837377", "0.6830049", "0.68299896", "0.68084", "0.6745392", "0.6663974", "0.66606045", "0.6617182", "0.6592707", "0.65867925", "0.65356016", "0.6523823", "0.65135735", "0.6508351", "0.64645416", "0.6446378", "0.6445187", "0.64395785", "0.6437644", "0.6435132", "0.63730514", "0.62997985", "0.6299091", "0.6237802", "0.6229727", "0.61944234", "0.6187936", "0.61652786", "0.6124756", "0.6122601", "0.61160296", "0.61151344", "0.61073035", "0.6058957", "0.60516125", "0.6046014", "0.60429704", "0.60131854", "0.60056454", "0.60056454", "0.59670436", "0.59312755", "0.592525", "0.5909391", "0.59046376", "0.5877589", "0.5865045", "0.58533645", "0.58007663", "0.579405", "0.57740045", "0.5767243", "0.57410824", "0.5734779", "0.57119584", "0.57031745", "0.5680191", "0.56750613", "0.56686246", "0.56661975", "0.56444114", "0.56357545", "0.5629346", "0.5611519", "0.5597881", "0.55878127", "0.55825984", "0.5556712", "0.5546201", "0.5519237", "0.5512131", "0.5511339", "0.5502821", "0.5473568", "0.546432", "0.5430084", "0.54158187", "0.5407375", "0.5397371", "0.5378444", "0.53723645" ]
0.8413449
0
HEAD is a shorthand for e.Request("HEAD", path, pathargs...).
HEAD — это сокращение для e.Request("HEAD", path, pathargs...).
func (e *Expect) HEAD(path string, pathargs ...interface{}) *Request { return e.Request(http.MethodHead, path, pathargs...) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Request) Head(path string) *Request {\n\treturn r.method(\"HEAD\", path)\n}", "func (r *Request) Head(path string, params ...url.Values) {\n\tcontentType := \"text/html\"\n\n\tif len(params) == 0 {\n\t\tr.Send(\"HEAD\", path, contentType)\n\t} else {\n\t\tr.Send(\"HEAD\", path, contentType, params[0])\n\t}\n}", "func Head(url string, data ...interface{}) (*ClientResponse, error) {\n\treturn DoRequest(\"HEAD\", url, data...)\n}", "func Head(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\trecord(\"HEAD\", path)\n\n\tinfoMutex.Lock()\n\tr.HEAD(path, Handler(alice.New(c...).ThenFunc(fn)))\n\tinfoMutex.Unlock()\n}", "func (r *Router) HEAD(url string, viewFn View) *Path {\n\treturn r.Path(fasthttp.MethodHead, url, viewFn)\n}", "func (F *Frisby) Head(url string) *Frisby {\n\tF.Method = \"HEAD\"\n\tF.Url = url\n\treturn F\n}", "func (rb *RequestBuilder) Head(url string) *Response {\n\treturn rb.DoRequest(http.MethodHead, url, nil)\n}", "func (tr *Transport) HEAD(\n\turl string,\n\tfn Handler,\n\toptions ...HandlerOption,\n) {\n\ttr.mux.Handler(\n\t\tnet_http.MethodHead,\n\t\turl,\n\t\tnewHandler(fn, append(tr.options, options...)...),\n\t)\n}", "func (r *Request) Head(url string) (*Response, error) {\n\treturn r.Execute(MethodHead, url)\n}", "func NewHead(url string) *Request { return NewRequest(\"HEAD\", url) }", "func (cl *Client) Head(c context.Context, url string, opts ...RequestOption) (*Response, error) {\n\treq, err := cl.NewRequest(c, http.MethodHead, url, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn cl.Do(c, req)\n}", "func (r *Router) HEAD(path string, h HandlerFunc) {\n\tr.router.HEAD(path, r.handle(h, r.getValidationForPath(path, \"HEAD\")))\n}", "func (c *Client) Head(url string) (*http.Response, error) {\n\treq, err := http.NewRequest(http.MethodHead, url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn c.Do(req)\n}", "func (f *Fastglue) HEAD(path string, h FastRequestHandler) {\n\tf.Router.HEAD(path, f.handler(h))\n}", "func (c *Client) Head(ctx context.Context, url string, data ...interface{}) (*Response, error) {\n\treturn c.DoRequest(ctx, http.MethodHead, url, data...)\n}", "func (serv *Server) HEAD(url string, handlers ...Handler) {\n\tserv.Handle(\"HEAD\", url, handlers...)\n}", "func (a *API) Head(path string) (resp *http.Response, err error) {\n\tu, err := url.ParseRequestURI(a.endpoint)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tu.Path = path\n\n\treturn a.Client.Head(u.String())\n}", "func (g *Group) HEAD(path string, handler Handler, middleware ...Middleware) *Group {\n\treturn g.Add(http.MethodHead, path, handler, middleware...)\n}", "func (c *Client) Head(url string) (*Response, error) {\n\treq, err := c.NewRequest(\"HEAD\", url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse, err := c.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn response, nil\n}", "func (r *Router) HEAD(path string, handle Handle) {\n\tr.Handle(http.MethodHead, path, handle)\n}", "func (e *Engine) HEAD(path string, handler Handler) {\n\te.registerRoute(http.MethodHead, path, handler)\n}", "func (c *Client) Head(ctx context.Context, hosts []string, path string) (http.Header, int, error) {\n\tresp, err := c.executeRequest(ctx, http.MethodHead, hosts, path, nil)\n\tif err != nil {\n\t\treturn nil, 0, errors.WithStack(err)\n\t}\n\tdefer resp.Body.Close()\n\treturn resp.Header, resp.StatusCode, nil\n}", "func Head(url string) (resp *http.Response, err error) {\n\treturn DefaultClient.Head(url)\n}", "func (c *Client) Head(url string) (response *http.Response, err error) {\n\treturn http.Head(url)\n}", "func (r *Router) HEAD(path string, handle HandlerFunc, middleware ...MiddlewareFunc) {\n\tr.Handle(\"HEAD\", path, handle, middleware...)\n}", "func Head(ctx context.Context, url string, options ...RequestOption) (*Response, error) {\n\tr, err := newRequest(ctx, http.MethodGet, url, nil, options...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn doRequest(http.DefaultClient, r)\n}", "func (m *Middleware) HEAD(path string, handler Handler) {\n\tm.engine.HEAD(path, m.apply(handler))\n}", "func (r *Mux) HEAD(path string, handler http.HandlerFunc) {\n\tr.HandleFunc(\"HEAD\", path, handler)\n}", "func (engine *Engine) HEAD(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn engine.handle(http.MethodHead, relativePath, handlers)\n}", "func Head(path string, fn httprouter.Handle) {\n\tr.Router.HEAD(path, fn)\n}", "func (d *Doer) Head(url string) (*http.Response, error) {\n\treq, err := d.newRequest(http.MethodHead, url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn d.do(req, nil)\n}", "func (router *Router) HEAD(relativePath string, handler Handler, decorators ...Decorator) {\n\trouter.createRouter(http.MethodHead, relativePath, handler, \"\", decorators...)\n}", "func Head(url string) (*http.Response, error) {\n\treturn DefaultClient.Head(url)\n}", "func (router *Router) Head(path string, handler http.Handler) {\n\trouter.Handle(\"HEAD\", path, handler)\n}", "func (s *Nap) Head(pathURL string) *Nap {\n\ts.method = MethodHead\n\treturn s.Path(pathURL)\n}", "func (r *bitroute) HEAD(path string, f func(router.Control)) {\n\tr.register(\"HEAD\", path, f)\n}", "func Head(url string, opts ...RequestOption) (*Response, error) {\n\treturn DefaultSession.Head(url, opts...)\n}", "func (o *Object) head(ctx context.Context) error {\n\tif o.fs.opt.NoHead {\n\t\to.size = -1\n\t\to.modTime = timeUnset\n\t\to.contentType = fs.MimeType(ctx, o)\n\t\treturn nil\n\t}\n\turl := o.url()\n\treq, err := http.NewRequestWithContext(ctx, \"HEAD\", url, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"stat failed: %w\", err)\n\t}\n\to.fs.addHeaders(req)\n\tres, err := o.fs.httpClient.Do(req)\n\tif err == nil && res.StatusCode == http.StatusNotFound {\n\t\treturn fs.ErrorObjectNotFound\n\t}\n\terr = statusError(res, err)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to stat: %w\", err)\n\t}\n\treturn o.decodeMetadata(ctx, res)\n}", "func (r *Route) Head(h http.Handler) *Route {\n\tr.Add(\"HEAD\", h)\n\n\treturn r\n}", "func (c *Client) Head(url string) (*http.Response, error) {\n\tb := c.breakerLookup(url)\n\tif b == nil {\n\t\treturn c.client.Head(url)\n\t}\n\n\tctx := getHeadCtx()\n\tdefer releaseHeadCtx(ctx)\n\n\tctx.Client = c.client\n\tctx.ErrorOnBadStatus = c.errOnBadStatus\n\tctx.URL = url\n\tif err := b.Call(ctx, breaker.WithTimeout(c.timeout)); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ctx.Response, ctx.Error\n}", "func (s *HTTPSet) Head(url string) (*http.Response, error) {\n\turl, err := s.replaceHost(url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn s.HTTPClient.Head(url)\n}", "func (group *RouterGroup) HEAD(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn group.handle(http.MethodHead, relativePath, handlers)\n}", "func (tr *Transport) Head(url string, fn HandlerFunc, options ...HandlerOption) {\n\ttr.mux.Handler(net_http.MethodHead, url, encapsulate(fn, tr.options, options))\n}", "func (node *Node) HEAD(functions ...interface{}) *Handler {\n\n\thandler := &Handler{}\n\n\tif len(functions) > 0 { handler.function = functions[0].(func (req web.RequestInterface) *web.ResponseStatus) }\n\n\tnode.addHandler(\"HEAD\", handler)\n\n\treturn handler\n}", "func (b *Builder) Head(url string) *Builder {\n\tb.Url = url\n\tb.Method = http.MethodHead\n\treturn b\n}", "func (group *RouterGroup) HEAD(path string, handlers ...HandlerFunc) {\n\tgroup.Handle(\"HEAD\", path, handlers)\n}", "func (app *App) HEAD(url string, handler ...Handler) *App {\n\tapp.routeANY = false\n\tapp.AppendReqAndResp(url, \"head\", handler)\n\treturn app\n}", "func (g *RouterGroup) HEAD(url string, handler ...Handler) *RouterGroup {\n\tg.app.routeANY = false\n\tg.AppendReqAndResp(url, \"head\", handler)\n\treturn g\n}", "func HeadObject(url string) (*http.Response, error) {\n\treq, err := http.NewRequest(\"HEAD\", url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn resp, nil\n}", "func (rg *RouteGroup) Head(path string, handlers ...Handler) *Route {\n\treturn rg.add(\"HEAD\", path, handlers)\n}", "func (r *Router) Head(path string, handle HandleFunc) {\n\tr.register(path, http.MethodHead, handle)\n}", "func (r *Route) Head(h interface{}) *Route {\n\treturn r.Handle(toHandler(h), \"HEAD\")\n}", "func (mx *Mux) Head(pattern string, handlerFn http.HandlerFunc) {\n\tmx.handle(mHEAD, pattern, handlerFn)\n}", "func (rg *RouteGroup) HEAD(path string, handlers ...Handler) *Route {\n\treturn rg.add(\"HEAD\", path, handlers)\n}", "func (r *Router) HEAD(route string, handler interface{}) *Router {\n\tr.Handle(MethodHEAD, route, handler)\n\treturn r\n}", "func (r *Router) HEAD(pattern string, handler func(Context)) Route {\n\treturn r.Handle(\"HEAD\", pattern, wrap(handler))\n}", "func (router *Router) HeadFunc(path string, handler http.HandlerFunc) {\n\trouter.Handle(\"HEAD\", path, handler)\n}", "func (r *Router) Head(pattern string, handler http.Handler) Route {\n\treturn r.Handle(\"HEAD\", pattern, handler)\n}", "func HeadBytes(url string, data ...interface{}) []byte {\n\treturn RequestBytes(\"HEAD\", url, data...)\n}", "func (this *Route) HEAD(handlers ...HTTPHandler) *Route {\n\treturn this.addHandler(\"head\", handlers...)\n}", "func (r *Router) Head(pattern string, handlers ...interface{}) *Router {\n\tc := r.pattern(pattern)\n\tc.Method = \"HEAD\"\n\tclone := r.clone(c)\n\tclone.handle(handlers)\n\treturn clone\n}", "func (group *RouterGroup) HEAD(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn group.Handler(\"HEAD\", relativePath, handlers...)\n}", "func (m *Mux) Head(pattern string, handler HandlerFunc) {\n\tm.Handle(http.MethodHead, pattern, handler)\n}", "func Head(url string) *THttpClient {\r\n\treturn NewHttpClient(url).Head(\"\")\r\n}", "func doGetHead(w http.ResponseWriter, r *http.Request) {\n\ts, err := newServerCGI(w, r)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\treg := regexp.MustCompile(\"^(get|head|removed)/([0-9A-Za-z_]+)/?([-0-9A-Za-z/]*)$\")\n\tm := reg.FindStringSubmatch(s.path())\n\tif m == nil {\n\t\tlog.Println(\"illegal url\", s.path())\n\t\treturn\n\t}\n\tmethod, datfile, stamp := m[1], m[2], m[3]\n\tca := thread.NewCache(datfile)\n\tbegin, end, id := s.parseStamp(stamp, math.MaxInt32)\n\tvar recs thread.RecordMap\n\tif method == \"removed\" {\n\t\trecs = ca.LoadRemovedRecords()\n\t} else {\n\t\trecs = ca.LoadRecords()\n\t}\n\tfor _, r := range recs {\n\t\tif r.InRange(begin, end, id) {\n\t\t\tif method == \"get\" {\n\t\t\t\tif err := r.Load(); err != nil {\n\t\t\t\t\tlog.Println(err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfmt.Fprintln(s.wr, r.Recstr())\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfmt.Fprintln(s.wr, strings.Replace(r.Idstr(), \"_\", \"<>\", -1))\n\t\t}\n\t}\n\tif method == \"get\" {\n\t\tthread.UpdatedRecord.Inform(datfile, id, begin, end)\n\t}\n}", "func (b *Baa) Head(pattern string, h ...HandlerFunc) RouteNode {\n\treturn b.Router().Add(\"HEAD\", pattern, h)\n}", "func HeadHandler(w http.ResponseWriter, r *http.Request) {\n\tFilesLock.RLock()\n\tval, ok := Files.Get(fileKey(r.URL))\n\tFilesLock.RUnlock()\n\n\tif !ok {\n\t\tw.WriteHeader(http.StatusNotFound)\n\t\treturn\n\t}\n\tf := val.(*File)\n\n\tw.Header().Set(\"Content-Type\", f.ContentType)\n\tw.Header().Set(\"Transfer-Encoding\", \"chunked\")\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tw.WriteHeader(http.StatusOK)\n}", "func (p *PatternServeMux) Head(pat string, h http.Handler) {\n\tp.Add(\"HEAD\", pat, h)\n}", "func head(httplink string, wg *sync.WaitGroup) {\n\twg.Add(1)\n\tdefer wg.Done()\n\toutput := Result{}\n\toutput.URL = httplink\n\ttimeout := time.Duration(time.Duration(timeoutSeconds) * time.Second)\n\n\tclient := http.Client{\n\t\tTimeout: timeout,\n\t\tCheckRedirect: redirectMiddleware,\n\t}\n\n\treq, err := http.NewRequest(\"HEAD\", httplink, nil)\n\tif err != nil {\n\t\terrorsProcessed++\n\t\toutput.Errors = append(output.Errors, fmt.Sprintf(\"%s\", err))\n\t\tresults = append(results, output)\n\t\treturn\n\t}\n\n\treq.Header.Set(\"User-Agent\", userAgent)\n\n\tres, err := client.Do(req)\n\tif err != nil {\n\t\terrorsProcessed++\n\t\tif res != nil {\n\t\t\tloc := res.Header.Get(\"Location\")\n\t\t\toutput.StatusCode = res.StatusCode\n\t\t\tif loc != \"\" {\n\t\t\t\tfull, err := absoluteURL(loc, httplink)\n\t\t\t\tif err == nil {\n\t\t\t\t\toutput.Redirect = full\n\t\t\t\t\tresults = append(results, output)\n\t\t\t\t\taddQueueLink(full, \"head\", httplink, 0, wg)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\toutput.Errors = append(output.Errors, fmt.Sprintf(\"%s\", err))\n\t\tresults = append(results, output)\n\t\treturn\n\t}\n\n\tdefer res.Body.Close()\n\n\t// some hosts block HEAD requests, so we do a standard GET instead\n\tif res.StatusCode == 404 || res.StatusCode == 405 {\n\t\tisOutbound := baseDomain != \"\" && getHost(httplink) != baseDomain\n\n\t\tif isOutbound {\n\t\t\tgetResponse(httplink, wg)\n\t\t\treturn\n\t\t}\n\t}\n\n\toutput.StatusCode = res.StatusCode\n\n\tif output.StatusCode != 200 {\n\t\terrorsProcessed++\n\t\toutput.Errors = append(output.Errors, fmt.Sprintf(\"returned status %d\", output.StatusCode))\n\t}\n\n\tresults = append(results, output)\n}", "func (r *Route) Head(handler http.Handler) *Route {\n\tr.handlers[http.MethodHead] = handler\n\treturn r\n}", "func (mx *Mux) Head(pattern string, handler interface{}) {\n\tmx.handle(HEAD, pattern, handler)\n}", "func HeadContent(url string, data ...interface{}) string {\n\treturn RequestContent(\"HEAD\", url, data...)\n}", "func (mm *Middleman) Head(path string, middleware Middleware) error {\r\n\treturn mm.addMiddleware(path, http.MethodHead, middleware)\r\n}", "func (client HTTPSuccessClient) Head404() (result autorest.Response, err error) {\n req, err := client.Head404Preparer()\n if err != nil {\n return result, autorest.NewErrorWithError(err, \"httpinfrastructuregroup.HTTPSuccessClient\", \"Head404\", nil , \"Failure preparing request\")\n }\n\n resp, err := client.Head404Sender(req)\n if err != nil {\n result.Response = resp\n return result, autorest.NewErrorWithError(err, \"httpinfrastructuregroup.HTTPSuccessClient\", \"Head404\", resp, \"Failure sending request\")\n }\n\n result, err = client.Head404Responder(resp)\n if err != nil {\n err = autorest.NewErrorWithError(err, \"httpinfrastructuregroup.HTTPSuccessClient\", \"Head404\", resp, \"Failure responding to request\")\n }\n\n return\n}", "func (g *Group) HEAD(path string, h Handler, gases ...Gas) {\n\tg.Air.HEAD(g.Prefix+path, h, append(g.Gases, gases...)...)\n}", "func (req *Request) Head() *ResultSet {\n\treturn req.do(http.MethodHead)\n}", "func (c *BaseController) Head(w http.ResponseWriter, r *Request) {\n\thttp.Error(w, \"Method Not Allowed\", 405)\n}", "func (c *Controller) Head() {\n\thttp.Error(c.Ctx.ResponseWriter, \"Method Not Allowed\", http.StatusMethodNotAllowed)\n}", "func (m *Mux) HeadFunc(path string, handler http.HandlerFunc) *Route {\n\treturn m.register(\"HEAD\", path, handler)\n}", "func (client HTTPSuccessClient) Head404Sender(req *http.Request) (*http.Response, error) {\n return autorest.SendWithSender(client, req)\n}", "func (c *Client) Head(name string, opts *HeadOpts) FileIterator {\n\treturn c.HeadWithContext(context.Background(), name, opts)\n}", "func (mr *MockRouterMockRecorder) HEAD(path, handler interface{}, options ...interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\tvarargs := append([]interface{}{path, handler}, options...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"HEAD\", reflect.TypeOf((*MockRouter)(nil).HEAD), varargs...)\n}", "func (rb *RequestBuilder) AsyncHead(url string, f func(*Response)) {\n\tgo func() {\n\t\tf(rb.Head(url))\n\t}()\n}", "func (ctl Controller) Head(ctx *gin.Context) {\n\n\tMethodNotAllowedJSON(ctx)\n}", "func (s *GDrive) Head(ctx context.Context, token string, filename string) (contentLength uint64, err error) {\n\tvar fileID string\n\tfileID, err = s.findID(filename, token)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar fi *drive.File\n\tif fi, err = s.service.Files.Get(fileID).Context(ctx).Fields(\"size\").Do(); err != nil {\n\t\treturn\n\t}\n\n\tcontentLength = uint64(fi.Size)\n\n\treturn\n}", "func (mr *MockRouterTxMockRecorder) HEAD(path, handler interface{}, options ...interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\tvarargs := append([]interface{}{path, handler}, options...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"HEAD\", reflect.TypeOf((*MockRouterTx)(nil).HEAD), varargs...)\n}", "func (m *MockRouter) HEAD(path string, handler interface{}, options ...interface{}) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{path, handler}\n\tfor _, a := range options {\n\t\tvarargs = append(varargs, a)\n\t}\n\tm.ctrl.Call(m, \"HEAD\", varargs...)\n}", "func (c *Client) HeadVar(url string, data ...interface{}) *gvar.Var {\n\treturn c.RequestVar(\"HEAD\", url, data...)\n}", "func HeadVar(url string, data ...interface{}) *gvar.Var {\n\treturn RequestVar(\"HEAD\", url, data...)\n}", "func (client HTTPSuccessClient) Head204() (result autorest.Response, err error) {\n req, err := client.Head204Preparer()\n if err != nil {\n return result, autorest.NewErrorWithError(err, \"httpinfrastructuregroup.HTTPSuccessClient\", \"Head204\", nil , \"Failure preparing request\")\n }\n\n resp, err := client.Head204Sender(req)\n if err != nil {\n result.Response = resp\n return result, autorest.NewErrorWithError(err, \"httpinfrastructuregroup.HTTPSuccessClient\", \"Head204\", resp, \"Failure sending request\")\n }\n\n result, err = client.Head204Responder(resp)\n if err != nil {\n err = autorest.NewErrorWithError(err, \"httpinfrastructuregroup.HTTPSuccessClient\", \"Head204\", resp, \"Failure responding to request\")\n }\n\n return\n}", "func (r *Route) HeadFunc(f http.HandlerFunc) *Route {\n\treturn r.Head(http.HandlerFunc(f))\n}", "func Ping(w http.ResponseWriter, r *http.Request) {\n\turl := r.FormValue(\"url\")\n\n\tfmt.Println(\"Ping\", url)\n\n\tresp, err := http.Head(url)\n\tif err != nil {\n\t\thttp.Error(w, \"Unable to connect\", 500)\n\t\treturn\n\t}\n\n\tw.WriteHeader(resp.StatusCode)\n}", "func (s *ProjectsService) GetHEAD(projectName string) (string, *Response, error) {\n\tu := fmt.Sprintf(\"projects/%s/HEAD\", url.QueryEscape(projectName))\n\treturn getStringResponseWithoutOptions(s.client, u)\n}", "func (m *MockRouterTx) HEAD(path string, handler interface{}, options ...interface{}) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{path, handler}\n\tfor _, a := range options {\n\t\tvarargs = append(varargs, a)\n\t}\n\tm.ctrl.Call(m, \"HEAD\", varargs...)\n}", "func (r *Router) HeadFunc(pattern string, fn http.HandlerFunc) Route {\n\treturn r.Head(pattern, http.HandlerFunc(fn))\n}", "func getFsEndpoint(ctx context.Context, client *http.Client, url string, opt *Options) (string, bool) {\n\t// If url ends with '/' it is already a proper url always assumed to be a directory.\n\tif url[len(url)-1] == '/' {\n\t\treturn url, false\n\t}\n\n\t// If url does not end with '/' we send a HEAD request to decide\n\t// if it is directory or file, and if directory appends the missing\n\t// '/', or if file returns the directory url to parent instead.\n\tcreateFileResult := func() (string, bool) {\n\t\tfs.Debugf(nil, \"If path is a directory you must add a trailing '/'\")\n\t\tparent, _ := path.Split(url)\n\t\treturn parent, true\n\t}\n\tcreateDirResult := func() (string, bool) {\n\t\tfs.Debugf(nil, \"To avoid the initial HEAD request add a trailing '/' to the path\")\n\t\treturn url + \"/\", false\n\t}\n\n\t// If HEAD requests are not allowed we just have to assume it is a file.\n\tif opt.NoHead {\n\t\tfs.Debugf(nil, \"Assuming path is a file as --http-no-head is set\")\n\t\treturn createFileResult()\n\t}\n\n\t// Use a client which doesn't follow redirects so the server\n\t// doesn't redirect http://host/dir to http://host/dir/\n\tnoRedir := *client\n\tnoRedir.CheckRedirect = func(req *http.Request, via []*http.Request) error {\n\t\treturn http.ErrUseLastResponse\n\t}\n\treq, err := http.NewRequestWithContext(ctx, \"HEAD\", url, nil)\n\tif err != nil {\n\t\tfs.Debugf(nil, \"Assuming path is a file as HEAD request could not be created: %v\", err)\n\t\treturn createFileResult()\n\t}\n\taddHeaders(req, opt)\n\tres, err := noRedir.Do(req)\n\n\tif err != nil {\n\t\tfs.Debugf(nil, \"Assuming path is a file as HEAD request could not be sent: %v\", err)\n\t\treturn createFileResult()\n\t}\n\tif res.StatusCode == http.StatusNotFound {\n\t\tfs.Debugf(nil, \"Assuming path is a directory as HEAD response is it does not exist as a file (%s)\", res.Status)\n\t\treturn createDirResult()\n\t}\n\tif res.StatusCode == http.StatusMovedPermanently ||\n\t\tres.StatusCode == http.StatusFound ||\n\t\tres.StatusCode == http.StatusSeeOther ||\n\t\tres.StatusCode == http.StatusTemporaryRedirect ||\n\t\tres.StatusCode == http.StatusPermanentRedirect {\n\t\tredir := res.Header.Get(\"Location\")\n\t\tif redir != \"\" {\n\t\t\tif redir[len(redir)-1] == '/' {\n\t\t\t\tfs.Debugf(nil, \"Assuming path is a directory as HEAD response is redirect (%s) to a path that ends with '/': %s\", res.Status, redir)\n\t\t\t\treturn createDirResult()\n\t\t\t}\n\t\t\tfs.Debugf(nil, \"Assuming path is a file as HEAD response is redirect (%s) to a path that does not end with '/': %s\", res.Status, redir)\n\t\t\treturn createFileResult()\n\t\t}\n\t\tfs.Debugf(nil, \"Assuming path is a file as HEAD response is redirect (%s) but no location header\", res.Status)\n\t\treturn createFileResult()\n\t}\n\tif res.StatusCode < 200 || res.StatusCode > 299 {\n\t\t// Example is 403 (http.StatusForbidden) for servers not allowing HEAD requests.\n\t\tfs.Debugf(nil, \"Assuming path is a file as HEAD response is an error (%s)\", res.Status)\n\t\treturn createFileResult()\n\t}\n\n\tfs.Debugf(nil, \"Assuming path is a file as HEAD response is success (%s)\", res.Status)\n\treturn createFileResult()\n}", "func printHeadTag(r *http.Response) {\n\tvar head string\n\tvar err error\n\tvar b = bytes.NewBuffer(nil)\n\tvar n int64\n\tvar openInd, closeInd int\n\t//if len(r.Body) == 0 {\n\t//\tfmt.Printf(\"getrequester.getHeadTag: no body\\n\")\n\t//\treturn\n\t//}\n\tif n, err = b.ReadFrom(r.Body); err != nil {\n\t\tfmt.Printf(\"getrequester.getHeadTag err=%v\\n\", err.Error())\n\t\thead = b.String()\n\t\tif head == \"\" {\n\t\t\tfmt.Printf(\"getrequester.getHeadTag: nothing was read from the body\\n\")\n\t\t} else {\n\t\t\tfmt.Printf(\"%v\\n\", head)\n\t\t}\n\t\treturn\n\t}\n\tif n == 0 {\n\t\tfmt.Printf(\"getrequester.getHeadTag: no body\\n\")\n\t\treturn\n\t}\n\tr.Body.Close()\n\topenInd = strings.Index(b.String(), \"<head>\")\n\tcloseInd = strings.Index(b.String(), \"</head>\")\n\tif openInd == -1 || closeInd == -1 {\n\t\tfmt.Printf(\"getrequester.getHeadTag no head tag (%v;%v)\", openInd, closeInd)\n\t\treturn\n\t}\n\thead = b.String()\n\thead = head[openInd : closeInd+6]\n\tfmt.Printf(\"%v\\n\", head)\n}", "func (client HTTPSuccessClient) Head404Responder(resp *http.Response) (result autorest.Response, err error) { \n err = autorest.Respond(\n resp,\n client.ByInspecting(),\n azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusNoContent,http.StatusNotFound),\n autorest.ByClosing())\n result.Response = resp\n return\n}", "func (ctx *Context) IsHead() bool {\r\n\treturn ctx.Is(\"HEAD\")\r\n}", "func (client HTTPSuccessClient) Head204Sender(req *http.Request) (*http.Response, error) {\n return autorest.SendWithSender(client, req)\n}" ]
[ "0.8339463", "0.796774", "0.79031473", "0.79007864", "0.7859185", "0.78095627", "0.7662336", "0.76048857", "0.75982046", "0.7593806", "0.7559749", "0.7555149", "0.75462085", "0.75420874", "0.7530385", "0.7517558", "0.7505431", "0.7505388", "0.746149", "0.7457079", "0.7431187", "0.74300724", "0.73983973", "0.73963344", "0.736028", "0.73429185", "0.7339016", "0.73286027", "0.73218334", "0.7321662", "0.73112243", "0.72904205", "0.7255", "0.723798", "0.7230453", "0.7223893", "0.7147914", "0.7133416", "0.70610267", "0.7056589", "0.7036722", "0.70081884", "0.6983289", "0.6974984", "0.691673", "0.6906471", "0.6840314", "0.6801512", "0.67911077", "0.67888016", "0.67760164", "0.67710376", "0.67649615", "0.67604434", "0.6702921", "0.6612381", "0.66112685", "0.6594372", "0.6563715", "0.6562698", "0.65618086", "0.6504534", "0.6500028", "0.6499687", "0.64650726", "0.6460968", "0.6457972", "0.6443077", "0.6431901", "0.6422665", "0.64080995", "0.6358015", "0.6314226", "0.630902", "0.6306513", "0.62763166", "0.6264894", "0.6201519", "0.6138083", "0.6049126", "0.6016663", "0.59580034", "0.586425", "0.58414173", "0.5830797", "0.58236074", "0.5818969", "0.5804552", "0.580145", "0.57315546", "0.5667795", "0.56630605", "0.565248", "0.56455916", "0.56309783", "0.56232595", "0.5570354", "0.55524206", "0.5551861", "0.5526659" ]
0.8708814
0
GET is a shorthand for e.Request("GET", path, pathargs...).
GET — это сокращение для e.Request("GET", path, pathargs...).
func (e *Expect) GET(path string, pathargs ...interface{}) *Request { return e.Request(http.MethodGet, path, pathargs...) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Request) Get(path string) *Request {\n\treturn r.method(\"GET\", path)\n}", "func GET(t *testing.T, path string) *httpexpect.Request {\n\tu, err := url.Parse(path)\n\trequire.Nil(t, err)\n\treturn newAPI(t).\n\t\tGET(u.Path).\n\t\tWithQueryString(u.RawQuery)\n}", "func (r *Request) Get(url string) *Request {\n\tr.method = http.MethodGet\n\tr.url = url\n\treturn r\n}", "func Get (url string, args map[string]string) (*http.Response, error) {\n\t// create a client\n\tclient, req, _ := GetHttpClient(url)\n\t// build the query\n\tif len(args) > 0 {\n\t\treq = buildQuery(req, args)\n\t}\n\t// execute the request\n\t//fmt.Println(req.URL.String())\n\treturn client.Do(req)\n}", "func (t *Tester) GET(path string, variables interface{}, pathargs ...interface{}) *Request {\n\trr := t.E.GET(path, pathargs...).WithHeaders(t.Headers).WithHeader(\"Cookie\", AccessTokenCookie).WithQueryObject(variables)\n\treturn &Request{rr}\n}", "func (r *Router) GET(url string, viewFn View) *Path {\n\treturn r.Path(fasthttp.MethodGet, url, viewFn)\n}", "func (r *Router) GET(path string, handler RequestHandler) {\n\tr.setPath(httpGET, path, handler)\n}", "func (c *baseClient) Get(path string) *baseClient {\n\tc.method = \"GET\"\n\treturn c.Path(path)\n}", "func (r *Request) Get(path string, params ...url.Values) {\n\tcontentType := \"text/html\"\n\n\tif len(params) == 0 {\n\t\tr.Send(\"GET\", path, contentType)\n\t} else {\n\t\tr.Send(\"GET\", path, contentType, params[0])\n\t}\n}", "func (client *Client) Get(path string) Response {\n\treturn client.processRequest(path, \"GET\")\n}", "func (c *Client) Get(path string) (f interface{}, err error) {\n\treturn c.do(\"GET\", path, nil)\n}", "func (c *Case) GET(p string) *RequestBuilder {\n\treturn &RequestBuilder{\n\t\tmethod: http.MethodGet,\n\t\tpath: p,\n\t\tcas: c,\n\t\tfail: c.fail,\n\t}\n}", "func (tr *Transport) GET(\n\turi string,\n\tfn Handler,\n\toptions ...HandlerOption,\n) {\n\ttr.mux.Handler(\n\t\tnet_http.MethodGet,\n\t\turi,\n\t\tnewHandler(fn, append(tr.options, options...)...),\n\t)\n}", "func (api *Api) Get(path string, endpoint http.HandlerFunc, queries ...string) {\n\tapi.Router.HandleFunc(path, endpoint).Methods(\"GET\").Queries(queries...)\n}", "func Get(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\tinfoMutex.Lock()\n\trecord(\"GET\", path)\n\tr.Get(path, alice.New(c...).ThenFunc(fn).(http.HandlerFunc))\n\tinfoMutex.Unlock()\n}", "func (a *APITest) Get(url string) *Request {\n\ta.request.method = http.MethodGet\n\ta.request.url = url\n\treturn a.request\n}", "func (c Client) get(path string, params url.Values, holder interface{}) error {\n\treturn c.request(\"GET\", path, params, &holder)\n}", "func Get(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\trecord(\"GET\", path)\n\n\tinfoMutex.Lock()\n\tr.GET(path, Handler(alice.New(c...).ThenFunc(fn)))\n\tinfoMutex.Unlock()\n}", "func (e *Engine) GET(path string, handler Handler) {\n\te.registerRoute(http.MethodGet, path, handler)\n}", "func Get(url string, r io.Reader, w io.Writer, clientGenerator func() *http.Client, reqTuner ...func(*http.Request)) error {\n\treturn Request(\"GET\", url, r, w, clientGenerator, reqTuner...)\n}", "func GetRequest(host, path string) (*http.Response, error) {\n\tfmt.Println(\"GET\", \"/\"+path)\n\tresp, err := http.Get(host + \"/\" + path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn resp, nil\n}", "func NewGet(url string) *Request { return NewRequest(\"GET\", url) }", "func (c *Client) Get(route string, queryValues map[string]string) (*RawResponse, error) {\n return c.doRequest(\"GET\", route, queryValues, nil)\n}", "func (c *Client) Get(url string, headers, queryParams map[string][]string) (response *http.Response, err error) {\n\treturn c.makeRequest(url, http.MethodGet, headers, queryParams, nil)\n}", "func Get(opts ...Option) ([]byte, error) {\n\treturn request(\"GET\", opts...)\n}", "func (c clientType) Get(path string) (*resty.Response, error) {\n\treturn c.execute(http.MethodGet, path, nil)\n}", "func (serv *Server) GET(url string, handlers ...Handler) {\n\tserv.Handle(\"GET\", url, handlers...)\n}", "func (req *Req) Get(u string) ([]byte, error) {\n\treturn req.request(\"GET\", u)\n}", "func (client *Client) Get(action string, params url.Values, header http.Header) (*Response, error) {\r\n\treturn client.Request(\"GET\", action, params, header, nil)\r\n}", "func (r *Router) GET(path string, h HandlerFunc) {\n\tr.router.GET(path, r.handle(h, r.getValidationForPath(path, \"GET\")))\n}", "func (s *Server) Get(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\ts.Router.HandleFunc(path, f).Methods(\"GET\")\n}", "func (app *App) GET(url string, handler ...Handler) *App {\n\tapp.routeANY = false\n\tapp.AppendReqAndResp(url, \"get\", handler)\n\treturn app\n}", "func (f *Fastglue) GET(path string, h FastRequestHandler) {\n\tf.Router.GET(path, f.handler(h))\n}", "func Get(path string, f func(http.ResponseWriter, *http.Request)) *Route {\n\treturn NewRoute().Path(path).Method(HttpGet).HandlerFunc(f)\n}", "func (g *Group) GET(path string, handler Handler, middleware ...Middleware) *Group {\n\treturn g.Add(http.MethodGet, path, handler, middleware...)\n}", "func (router *Router) GET(relativePath string, handler Handler, decorators ...Decorator) {\n\trouter.createRouter(http.MethodGet, relativePath, handler, \"\", decorators...)\n}", "func (h *Handler) Get(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\tpath = configuration.Instance.Service.Path + path\n\tlog.Println(\"Adding '\" + path + \"' as GET path\")\n\th.Router.HandleFunc(path, f).Methods(\"GET\")\n}", "func (rb *RequestBuilder) Get(url string) *Response {\n\treturn rb.DoRequest(http.MethodGet, url, nil)\n}", "func Get(url string, data ...interface{}) (*ClientResponse, error) {\n\treturn DoRequest(\"GET\", url, data...)\n}", "func (s *Nap) Get(pathURL string) *Nap {\n\ts.method = MethodGet\n\treturn s.Path(pathURL)\n}", "func (g *RouterGroup) GET(url string, handler ...Handler) *RouterGroup {\n\tg.app.routeANY = false\n\tg.AppendReqAndResp(url, \"get\", handler)\n\treturn g\n}", "func (m *Middleware) GET(path string, handler Handler) {\n\tm.engine.GET(path, m.apply(handler))\n}", "func (s *Server) GET(path string, handle http.HandlerFunc) {\n\ts.router.GET(path, s.wrapHandler(handle))\n}", "func (e *Engine) GET(path string, handler HandlerFunc) {\n\n\troute := Route{\n\t\tmethod: http.MethodGet,\n\t\thandler: handler,\n\t\tparam: map[int]string{},\n\t\tpath: path,\n\t}\n\tsPath := strings.Split(path, \"/\")\n\tre := regexp.MustCompile(`\\{\\w*\\}`)\n\tparams := re.FindAllString(path, -1)\n\n\tfor _, p := range params {\n\t\troute.path = strings.Replace(path, p, `\\w*`, -1)\n\t}\n\t//Revisit this logic. I have done string manipulation, just to unblock myself.\n\tfor i, p := range strings.Split(route.path, \"/\") {\n\t\tif p == `\\w*` {\n\t\t\troute.param[i] = strings.Trim(strings.Trim(sPath[i], \"{\"), \"}\")\n\t\t}\n\t}\n\n\trouteTable[route.path] = &route\n}", "func (e *Engine) GET(path string, fn Controller) {\n\te.gin.GET(path, adapt(fn))\n}", "func (c *Client) Get(ctx context.Context, url string, data ...interface{}) (*Response, error) {\n\treturn c.DoRequest(ctx, http.MethodGet, url, data...)\n}", "func (F *Frisby) Get(url string) *Frisby {\n\tF.Method = \"GET\"\n\tF.Url = url\n\treturn F\n}", "func (r *Router) GET(path string, handle HandlerFunc, middleware ...MiddlewareFunc) {\n\tr.Handle(\"GET\", path, handle, middleware...)\n}", "func (app *App) Get(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\tapp.Router.HandleFunc(path, f).Methods(\"GET\")\n}", "func Get(h http.Handler) http.Handler {\n\treturn HTTP(h, GET)\n}", "func (session *Session) Get(path string, params Params) (response []byte, err error) {\n\turlStr := session.getUrl(path, params)\n\tlog.Println(urlStr)\n\tresponse, err = session.sendGetRequest(urlStr)\n\treturn\n\n\t//res, err = MakeResult(response)\n\t//return\n\n}", "func (a *App) Get(path string, f func(w http.ResponseWriter, r *http.Request)) {\r\n\ta.Router.HandleFunc(path, f).Methods(\"GET\")\r\n}", "func (engine *Engine) GET(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn engine.handle(http.MethodGet, relativePath, handlers)\n}", "func Get(url string) (resp *http.Response, err error) {\n\treturn do(\"GET\", url, nil)\n}", "func (a *App) Get(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\ta.Router.HandleFunc(path, f).Methods(\"GET\")\n}", "func (a *App) Get(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\ta.Router.HandleFunc(path, f).Methods(\"GET\")\n}", "func (a *App) Get(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\ta.Router.HandleFunc(path, f).Methods(\"GET\")\n}", "func (r *bitroute) GET(path string, f func(router.Control)) {\n\tr.register(\"GET\", path, f)\n}", "func (mg *Module) GET(path string, handler gin.HandlerFunc) gin.IRoutes {\n\treturn mg.App.Router.GET(mg.MountPath+path, handler)\n}", "func (r Requester) Get(filters string) Requester {\n\treq, err := http.NewRequest(http.MethodGet, r.url+filters, nil)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tr.httpRequest = req\n\treturn r\n}", "func (r *Router) GET(path string, handler Handle) {\n\tr.Handle(\"GET\", path, handler)\n}", "func (r *Router) GET(path string, handle Handle) {\n\tr.Handle(http.MethodGet, path, handle)\n}", "func (r *Router) Get(path, title string, fn Handle) {\n\tr.addRoute(\"GET\", path, title, fn)\n}", "func (c *Client) Request(verb, spath string, ro *RequestOptions) (*http.Request, error) {\n\tlog.Printf(\"[INFO] request: %s %s\", verb, spath)\n\n\tif ro == nil {\n\t\tro = new(RequestOptions)\n\t}\n\n\tu := *c.URL\n\tu.Path = path.Join(c.URL.Path, spath)\n\n\tif c.Token != \"\" {\n\t\tif ro.Headers == nil {\n\t\t\tro.Headers = make(map[string]string)\n\t\t}\n\t\tro.Headers[\"Authorization\"] = fmt.Sprintf(\"Bearer %s\", c.Token)\n\t}\n\n\treturn c.rawRequest(verb, &u, ro)\n}", "func (c *Client) Get(path string, out interface{}) error {\n\treturn c.Send(\"GET\", path, nil, out)\n}", "func getRequest(client *Client, path string, query string, response interface{}) error {\n\treq := client.resty.R().SetResult(&response)\n\tif query != \"\" {\n\t\treq.SetQueryParam(\"query\", query)\n\t}\n\tr, err := req.Get(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif r.IsError() {\n\t\treturn fmt.Errorf(\"%s: %s\", r.Status(), r.Body())\n\t}\n\n\treturn nil\n}", "func Get(url string, data ...interface{}) (*Response, error) {\n\tr := NewRequest()\n\treturn r.Get(url, data...)\n}", "func (rg *RouteGroup) GET(path string, handlers ...Handler) *Route {\n\treturn rg.add(\"GET\", path, handlers)\n}", "func (tr *Transport) Get(url string, fn HandlerFunc, options ...HandlerOption) {\n\ttr.mux.Handler(net_http.MethodGet, url, encapsulate(fn, tr.options, options))\n}", "func (client *Client) Get(c context.Context, uri string, params interface{}, res interface{}) (err error) {\n\treq, err := client.NewRequest(xhttp.MethodGet, uri, params)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn client.client.Do(c, req, res)\n}", "func (session *Session) Get(path string, params Params) (res Result, err error) {\n\turlStr := session.app.BaseEndPoint + session.getRequestUrl(path, params)\n\n\tvar response []byte\n\tresponse, err = session.SendGetRequest(urlStr)\n\n\tif err != nil {\n\t\treturn\n\t}\n\n\tres, err = MakeResult(response)\n\treturn\n}", "func (b *Builder) Get(url string) *Builder {\n\tb.Url = url\n\tb.Method = http.MethodGet\n\treturn b\n}", "func Get(route string, do interface{}) *handler {\n\treturn handlerByMethod(&route, do, \"GET\")\n}", "func (c *Client) Get() *Request {\n\treturn NewRequest(c.httpClient, c.base, \"GET\", c.version, c.authstring, c.userAgent)\n}", "func (c *Client) Get(endpoint string, resource ...RequestResource) error {\n\twrapper := newWrapper(\"get\", endpoint, resource...)\n\treturn c.do(&wrapper)\n}", "func Get(path string, handler http.Handler) Route {\n\treturn NewRoute(\"GET\", path, handler)\n}", "func (a *API) Get(path string) (resp *http.Response, err error) {\n\tu, err := url.ParseRequestURI(a.endpoint)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tu.Path = path\n\n\treturn a.Client.Get(u.String())\n}", "func (fs *IPfsfs) Req(path string, arg string) (resp *http.Response, err error) {\n\tu := url.URL{}\n\tu.Scheme = \"http\"\n\tu.Host = ipfsHost\n\tu.Path = api + path\n\tif arg != \"\" {\n\t\tval := url.Values{}\n\t\tval.Set(\"arg\", arg)\n\t\tval.Set(\"encoding\", \"json\")\n\t\tu.RawQuery = val.Encode()\n\t}\n\tlogger.Debug(\"URL : %s\", u.String())\n\tresp, err = http.Get(u.String())\n\tif resp == nil {\n\t\treturn nil, err\n\t}\n\tif resp.StatusCode != 200 {\n\t\treturn resp, errors.New(resp.Status)\n\t}\n\tif err != nil {\n\t\treturn resp, err\n\t}\n\treturn resp, err\n}", "func (s *Server) Get(path string, fn http.HandlerFunc) {\n\thandler := s.handlers.ThenFunc(fn)\n\ts.router.Handler(http.MethodGet, path, handler)\n}", "func HTTPGet(params *HTTPRequest) (*http.Response, error) {\n\tparams.Method = \"GET\"\n\tprintHTTPRequest(params)\n\n\tu, err := url.Parse(params.URL)\n\tif err != nil {\n\t\tprintErrorLine(err)\n\t\treturn nil, err\n\t}\n\tif len(params.Query) > 0 {\n\t\tu.RawQuery = params.Query.Encode()\n\t}\n\n\tresp, err := http.Get(u.String())\n\tif err != nil {\n\t\tprintErrorLine(err)\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tif err := printHTTPResponse(params.URL, resp); err != nil {\n\t\tprintErrorLine(err)\n\t\treturn nil, err\n\t}\n\n\treturn resp, nil\n}", "func (r *RouterGroup) GET(path string, fn Controller) {\n\tr.gin.GET(path, adapt(fn))\n}", "func (f *Client) Get(path string, params GraphQueryString) *GraphRequest {\n\treturn f.NewGraphRequest(Get, path, params)\n}", "func (this *Route) GET(handlers ...HTTPHandler) *Route {\n\treturn this.addHandler(\"get\", handlers...)\n}", "func (c *Client) get(endpoint string, queries map[string]string) (*http.Response, error) {\n\t// Assemble request\n\treq, err := c.buildRequest(\"GET\", endpoint, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Add query strings\n\tif queries != nil {\n\t\tencodeQuery(req.URL, queries)\n\t}\n\n\tclient := buildHTTPSClient(c.verifySSL)\n\treturn client.Do(req)\n}", "func (r *Router) Get(path string, handlers ...Handler) {\n\tr.addToRoutes(http.MethodGet, path, handlers...)\n}", "func (r *Router) GET(partPath string, handlers ...HandlerFunc) {\n\tpath := path.Join(r.basePath, partPath)\n\thandlers = r.combineHandlers(handlers)\n\tr.addRoute(http.MethodGet, path, handlers)\n}", "func Get(path string, handler func(http.ResponseWriter, *http.Request)) {\n\tdefaultRoutes.get(path, handler)\n}", "func (r *Mux) GET(path string, handler http.HandlerFunc) {\n\tr.HandleFunc(\"GET\", path, handler)\n}", "func (cl *Client) Get(c context.Context, url string, opts ...RequestOption) (*Response, error) {\n\treq, err := cl.NewRequest(c, http.MethodGet, url, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn cl.Do(c, req)\n}", "func Get(path string, fn httprouter.Handle) {\n\tr.Router.GET(path, fn)\n}", "func (t transporter) Get(path string) (*http.Response, error) {\n\tresp, err := t.client.Get(t.scheme + path)\n\treturn resp, err\n}", "func Get(options RequestOptions) error {\n\thost, path := uriToHostAndPath(options.Uri)\n\toptions.Headers[\"Host\"] = host\n\trequest := fmt.Sprintf(\"GET %s HTTP/1.0\", path)\n\tprotocol := fmt.Sprintf(\"%s\\r\\n%s\\r\\n\", request, options.Headers)\n\treturn send(host, protocol, options)\n}", "func Get(ctx context.Context, url string, options ...RequestOption) (*Response, error) {\n\tr, err := newRequest(ctx, http.MethodGet, url, nil, options...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn doRequest(http.DefaultClient, r)\n}", "func (c *Client) Get(path string, resource, options interface{}) error {\n\treturn c.CreateAndDo(\"GET\", path, nil, options, nil, resource)\n}", "func (web *WebServer) Get(path string, handler http.HandlerFunc) {\n\tweb.router.Get(path, handler)\n}", "func (router *Router) Get(path string, handler http.Handler) {\n\trouter.Handle(\"GET\", path, handler)\n}", "func (group *RouterGroup) GET(path string, handlers ...HandlerFunc) {\n\tgroup.Handle(\"GET\", path, handlers)\n}", "func (APIResourceBase) Get(session *Session, url string, queries url.Values, body io.Reader) (APIStatus, interface{}) {\n\treturn FailSimple(http.StatusMethodNotAllowed), nil\n}", "func (n *NS) Get(url string) *route {\n\treturn &route{context: n.c, method: \"GET\", url: n.prefix + url, bCtrl: n.bCtrl, aCtrl: n.aCtrl}\n}", "func (c *Client) Get(path string, params map[string]string, res interface{}, auth bool) (err error) {\n\tif c.debug {\n\t\tfmt.Println(\"GET:\", auth, path, params)\n\t}\n\tif auth {\n\t\tc.Sign(path, \"\")\n\t}\n\n\tvar r *httpclient.Response\n\tr, err = c.api.Get(c.URL()+path, params)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer r.Body.Close()\n\n\terr = handleResponse(r, res, auth)\n\treturn\n}" ]
[ "0.81648576", "0.7915022", "0.7594921", "0.75366944", "0.7499703", "0.74763393", "0.73408014", "0.73338115", "0.7321939", "0.7278976", "0.7253074", "0.72435415", "0.72385293", "0.72086805", "0.7207457", "0.7175362", "0.7173006", "0.7165603", "0.7134777", "0.71175677", "0.7106533", "0.70983386", "0.70947814", "0.707551", "0.70506865", "0.7050413", "0.7046737", "0.70369107", "0.7016641", "0.7014082", "0.7012025", "0.69967544", "0.6987188", "0.69832975", "0.6976085", "0.6962892", "0.695707", "0.69510317", "0.69262695", "0.69193053", "0.6912874", "0.6892119", "0.6876617", "0.685673", "0.6842335", "0.6841285", "0.68399113", "0.6839215", "0.68363", "0.6823853", "0.682335", "0.6812193", "0.6798875", "0.6776956", "0.67650557", "0.67650557", "0.67650557", "0.67631924", "0.674381", "0.67418844", "0.6739588", "0.6724777", "0.66839474", "0.6679168", "0.66697454", "0.6665771", "0.6659088", "0.6645765", "0.6636608", "0.66345", "0.662029", "0.6612085", "0.6607359", "0.659871", "0.6596327", "0.65916485", "0.6591584", "0.65750796", "0.65747577", "0.6558734", "0.65563095", "0.6549486", "0.65378225", "0.6530636", "0.6513504", "0.65060604", "0.6505991", "0.65055275", "0.65021706", "0.64961976", "0.6481562", "0.64687866", "0.6460501", "0.6459771", "0.6446179", "0.64323723", "0.64132744", "0.6410876", "0.64103156", "0.6399102" ]
0.8767445
0
POST is a shorthand for e.Request("POST", path, pathargs...).
POST — это сокращение для e.Request("POST", path, pathargs...).
func (e *Expect) POST(path string, pathargs ...interface{}) *Request { return e.Request(http.MethodPost, path, pathargs...) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Request) Post(path string) *Request {\n\treturn r.method(\"POST\", path)\n}", "func (r *Request) Post(path, contentType string, data ...interface{}) {\n\tr.Send(\"POST\", path, contentType, data...)\n}", "func (client *Client) Post(path, data string, mods ...func(*Req)) (Res, error) {\n\treq := client.NewReq(\"POST\", path, strings.NewReader(data), mods...)\n\treturn client.Do(req)\n}", "func (r *Router) POST(path string, handler RequestHandler) {\n\tr.setPath(httpPOST, path, handler)\n}", "func (r *Router) POST(url string, viewFn View) *Path {\n\treturn r.Path(fasthttp.MethodPost, url, viewFn)\n}", "func (c clientType) Post(path string, body interface{}) (resp *resty.Response, err error) {\n\treturn c.execute(http.MethodPost, path, body)\n}", "func (r *Request) Post(url string) *Request {\n\tr.method = http.MethodPost\n\tr.url = url\n\treturn r\n}", "func (s *Nap) Post(pathURL string) *Nap {\n\ts.method = MethodPost\n\treturn s.Path(pathURL)\n}", "func Post(path string, f func(http.ResponseWriter, *http.Request)) *Route {\n\treturn NewRoute().Path(path).Method(HttpPost).HandlerFunc(f)\n}", "func (e *Engine) POST(path string, handler Handler) {\n\te.registerRoute(http.MethodPost, path, handler)\n}", "func (c *baseClient) Post(path string) *baseClient {\n\tc.method = \"POST\"\n\treturn c.Path(path)\n}", "func (s *Server) Post(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\ts.Router.HandleFunc(path, f).Methods(\"POST\")\n}", "func (g *Group) POST(path string, handler Handler, middleware ...Middleware) *Group {\n\treturn g.Add(http.MethodPost, path, handler, middleware...)\n}", "func (h *Handler) Post(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\tpath = configuration.Instance.Service.Path + path\n\tlog.Println(\"Adding '\" + path + \"' as POST path\")\n\th.Router.HandleFunc(path, f).Methods(\"POST\")\n}", "func (a *ApiServer) Post(path string, f func(w http.ResponseWriter, r *http.Request)) *ApiServer{\n\ta.Router.HandleFunc(path, f).Methods(\"POST\")\n\treturn a\n}", "func (router *Router) POST(relativePath string, handler Handler, decorators ...Decorator) {\n\trouter.createRouter(http.MethodPost, relativePath, handler, \"\", decorators...)\n}", "func (app *App) Post(path string, endpoint http.HandlerFunc, queries ...string) {\r\n\tapp.Router.HandleFunc(path, endpoint).Methods(\"POST\").Queries(queries...)\r\n}", "func (a *APITest) Post(url string) *Request {\n\tr := a.request\n\tr.method = http.MethodPost\n\tr.url = url\n\treturn r\n}", "func (t *Tester) POST(path string, variables interface{}, pathargs ...interface{}) *Request {\n\trr := t.E.POST(path, pathargs...).WithHeaders(t.Headers).WithHeader(\"Cookie\", AccessTokenCookie).WithForm(variables)\n\treturn &Request{rr}\n}", "func (app *App) Post(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\tapp.Router.HandleFunc(path, f).Methods(\"POST\")\n}", "func (a *App) Post(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\ta.Router.HandleFunc(path, f).Methods(\"POST\")\n}", "func (a *App) Post(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\ta.Router.HandleFunc(path, f).Methods(\"POST\")\n}", "func Post(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\tinfoMutex.Lock()\n\trecord(\"POST\", path)\n\tr.Post(path, alice.New(c...).ThenFunc(fn).(http.HandlerFunc))\n\tinfoMutex.Unlock()\n}", "func (a *App) Post(path string, f func(w http.ResponseWriter, r *http.Request)) {\r\n\ta.Router.HandleFunc(path, f).Methods(\"POST\")\r\n}", "func (api *Api) Post(path string, endpoint http.HandlerFunc, queries ...string) {\n\tapi.Router.HandleFunc(path, endpoint).Methods(\"POST\").Queries(queries...)\n}", "func (c *Client) Post(path string, in, out interface{}) error {\n\treturn c.Send(\"POST\", path, in, out)\n}", "func (f *Fastglue) POST(path string, h FastRequestHandler) {\n\tf.Router.POST(path, f.handler(h))\n}", "func Post(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\trecord(\"POST\", path)\n\n\tinfoMutex.Lock()\n\tr.POST(path, Handler(alice.New(c...).ThenFunc(fn)))\n\tinfoMutex.Unlock()\n}", "func (rb *RequestBuilder) Post(url string, body interface{}) *Response {\n\treturn rb.DoRequest(http.MethodPost, url, body)\n}", "func (web *WebServer) Post(path string, handler http.HandlerFunc) {\n\tweb.router.Post(path, handler)\n}", "func (c Client) post(path string, params url.Values, holder interface{}) error {\n\treturn c.request(\"POST\", path, params, &holder)\n}", "func (engine *Engine) POST(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn engine.handle(http.MethodPost, relativePath, handlers)\n}", "func (s *Server) Post(path string, fn http.HandlerFunc) {\n\thandler := s.handlers.ThenFunc(fn)\n\ts.router.Handler(http.MethodPost, path, handler)\n}", "func (r *bitroute) POST(path string, f func(router.Control)) {\n\tr.register(\"POST\", path, f)\n}", "func (r *Router) POST(path string, handle HandlerFunc, middleware ...MiddlewareFunc) {\n\tr.Handle(\"POST\", path, handle, middleware...)\n}", "func Post(path string, fn httprouter.Handle) {\n\tr.Router.POST(path, fn)\n}", "func (r *Router) POST(path string, handler Handle) {\n\tr.Handle(\"POST\", path, handler)\n}", "func (rg *RouteGroup) POST(path string, handlers ...Handler) *Route {\n\treturn rg.add(\"POST\", path, handlers)\n}", "func (c *Client) Post(path string, body io.Reader) (f interface{}, err error) {\n\treturn c.do(\"POST\", path, body)\n}", "func (c *Case) POST(p string) *RequestBuilder {\n\treturn &RequestBuilder{\n\t\tmethod: http.MethodPost,\n\t\tpath: p,\n\t\tcas: c,\n\t\tfail: c.fail,\n\t}\n}", "func (r *Request) Post(url string) (*Response, error) {\n\treturn r.Execute(MethodPost, url)\n}", "func (m *Middleware) POST(path string, handler Handler) {\n\tm.engine.POST(path, m.apply(handler))\n}", "func (r *Router) POST(path string, h HandlerFunc) {\n\tr.router.POST(path, r.handle(h, r.getValidationForPath(path, \"POST\")))\n}", "func (s *Server) POST(path string, handle http.HandlerFunc) {\n\ts.router.POST(path, s.wrapHandler(handle))\n}", "func (e *Engine) POST(path string, fn Controller) {\n\te.gin.POST(path, adapt(fn))\n}", "func (client *Client) Post(action string, params url.Values, header http.Header) (*Response, error) {\r\n\treturn client.Request(\"POST\", action, params, header, nil)\r\n}", "func Post(path string, handler http.Handler) Route {\n\treturn NewRoute(\"POST\", path, handler)\n}", "func Post(path string, handler func(http.ResponseWriter, *http.Request)) {\n\tdefaultRoutes.post(path, handler)\n}", "func Post(path string, data string) {\n\tres, err := postThis(path, data)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\tfmt.Printf(sep)\n\tfmt.Printf(\"POST result: %s\\n\", res)\n}", "func Post(url string, r io.Reader, w io.Writer, clientGenerator func() *http.Client, reqTuner ...func(*http.Request)) error {\n\treturn Request(\"POST\", url, r, w, clientGenerator, reqTuner...)\n}", "func (serv *Server) POST(url string, handlers ...Handler) {\n\tserv.Handle(\"POST\", url, handlers...)\n}", "func (router *Router) Post(path string, handler http.Handler) {\n\trouter.Handle(\"POST\", path, handler)\n}", "func Post(h http.Handler) http.Handler {\n\treturn HTTP(h, POST)\n}", "func (req *Req) Post(u string) ([]byte, error) {\n\treturn req.request(\"POST\", u)\n}", "func (rg *RouteGroup) Post(path string, handlers ...Handler) *Route {\n\treturn rg.add(\"POST\", path, handlers)\n}", "func (c *Client) Post(route string, queryValues map[string]string, body []byte) (*RawResponse, error) {\n return c.doRequest(\"POST\", route, queryValues, body)\n}", "func (group *RouterGroup) POST(path string, handlers ...HandlerFunc) {\n\tgroup.Handle(\"POST\", path, handlers)\n}", "func (r *Router) Post(path, title string, fn Handle) {\n\tr.addRoute(\"POST\", path, title, fn)\n}", "func (group *RouterGroup) POST(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn group.Handler(\"POST\", relativePath, handlers...)\n}", "func (r *Router) Post(path string, handler httpHandler) {\n\tr.POST(path, wrapHandler(handler))\n}", "func (s *Server) Post(path string, body interface{}) (*http.Response, error) {\n\turl, err := s.urlFor(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbodyBytes, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn http.Post(url, \"application/json\", bytes.NewReader(bodyBytes))\n}", "func (g *RouterGroup) POST(url string, handler ...Handler) *RouterGroup {\n\tg.app.routeANY = false\n\tg.AppendReqAndResp(url, \"post\", handler)\n\treturn g\n}", "func (r *Router) POST(path string, handle Handle) {\n\tr.Handle(http.MethodPost, path, handle)\n}", "func (session *Session) Post(path string, data Params) (res Result, err error) {\n\turlStr := session.app.BaseEndPoint + session.getRequestUrl(path, nil)\n\n\tvar response []byte\n\tresponse, err = session.SendPostRequest(urlStr, data)\n\n\tif err != nil {\n\t\treturn\n\t}\n\n\tres, err = MakeResult(response)\n\treturn\n}", "func (r *Router) Post(path string, handler http.Handler) {\n\tr.POST(path, wrapHandler(handler))\n}", "func (r *Router) Post(path string, handler http.Handler) {\n\tr.POST(path, wrapHandler(handler))\n}", "func (group *RouterGroup) POST(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn group.handle(http.MethodPost, relativePath, handlers)\n}", "func (f *Client) Post(path string, params GraphQueryString) *GraphRequest {\n\treturn f.NewGraphRequest(Post, path, params)\n}", "func (r *Route) Post(h http.Handler) *Route {\n\tr.Add(\"POST\", h)\n\n\treturn r\n}", "func (mm *Middleman) Post(path string, middleware Middleware) error {\r\n\treturn mm.addMiddleware(path, http.MethodPost, middleware)\r\n}", "func (r *RouterGroup) POST(path string, fn Controller) {\n\tr.gin.POST(path, adapt(fn))\n}", "func (n *NS) Post(url string) *route {\n\treturn &route{context: n.c, method: \"POST\", url: n.prefix + url, bCtrl: n.bCtrl, aCtrl: n.aCtrl}\n}", "func (r *Mux) POST(path string, handler http.HandlerFunc) {\n\tr.HandleFunc(\"POST\", path, handler)\n}", "func (c *Client) Post(ctx context.Context, url string, data ...interface{}) (*Response, error) {\n\treturn c.DoRequest(ctx, http.MethodPost, url, data...)\n}", "func Post(host, path string, params map[string]string, requiredCode int) error {\n\tresp, err := PostRequest(host, path, params)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = out(resp, requiredCode)\n\treturn err\n}", "func (self *Client) Post(dst interface{}, path string, data url.Values) error {\n\tvar addr *url.URL\n\tvar err error\n\tvar body *strings.Reader\n\n\tif addr, err = url.Parse(self.Prefix + strings.TrimLeft(path, \"/\")); err != nil {\n\t\treturn err\n\t}\n\n\tif data != nil {\n\t\tbody = strings.NewReader(data.Encode())\n\t}\n\n\treturn self.newRequest(dst, \"POST\", addr, body)\n}", "func Post(url string, data ...interface{}) (*ClientResponse, error) {\n\treturn DoRequest(\"POST\", url, data...)\n}", "func (a *API) Post(path string, bodyType string, body io.Reader) (resp *http.Response, err error) {\n\tu, err := url.ParseRequestURI(a.endpoint)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tu.Path = path\n\n\treturn a.Client.Post(u.String(), bodyType, body)\n}", "func (c *Client) Post(url string, headers, queryParams map[string][]string, data interface{}) (response *http.Response, err error) {\n\treturn c.makeRequest(url, http.MethodPost, headers, queryParams, data)\n}", "func (this *Route) POST(handlers ...HTTPHandler) *Route {\n\treturn this.addHandler(\"post\", handlers...)\n}", "func PostRequest(host, path string, params map[string]string) (*http.Response, error) {\n\tall := []string{}\n\tvalues := url.Values{}\n\tfor k, v := range params {\n\t\tall = append(all, k+\"='\"+v+\"'\")\n\t\tvalues[k] = []string{v}\n\t}\n\tfmt.Println(\"POST\", \"/\"+path, \"\", strings.Join(all, \", \"))\n\treturn http.PostForm(host+\"/\"+path, values)\n\n}", "func (a *App) POST(pattern string, handler Handler) {\n\ta.add(\"POST\", pattern, handler)\n}", "func (b *Builder) Post(url string) *Builder {\n\tb.Url = url\n\tb.Method = http.MethodPost\n\treturn b\n}", "func (app *App) POST(url string, handler ...Handler) *App {\n\tapp.routeANY = false\n\tapp.AppendReqAndResp(url, \"post\", handler)\n\treturn app\n}", "func (F *Frisby) Post(url string) *Frisby {\n\tF.Method = \"POST\"\n\tF.Url = url\n\treturn F\n}", "func Post(route string, do interface{}) *handler {\n\treturn handlerByMethod(&route, do, \"POST\")\n}", "func (r *Router) Post(path string, handle HandleFunc) {\n\tr.register(path, http.MethodPost, handle)\n}", "func (r *Request) PostForm(path string, data interface{}) {\n\tr.Post(path, \"application/x-www-form-urlencoded\", data)\n}", "func (r *Route) Post(handler http.Handler) *Route {\n\tr.handlers[http.MethodPost] = handler\n\treturn r\n}", "func (r *Router) Post(path string, handle requestHandler, config ...RouteConfig) {\n\tr.routers[\"POST\"] = append(r.routers[\"POST\"], newRouteHandler(path, handle, config...))\n}", "func (c *Client) Post(path string, data, resource interface{}) error {\n\treturn c.CreateAndDo(\"POST\", path, data, nil, nil, resource)\n}", "func (r *Router) POST(partPath string, handlers ...HandlerFunc) {\n\tpath := path.Join(r.basePath, partPath)\n\thandlers = r.combineHandlers(handlers)\n\tr.addRoute(http.MethodPost, path, handlers)\n}", "func (group *Groups) Post(path string, handler http.HandlerFunc) {\n\tgroup.webserver.router.Post(path, group.handler(handler))\n}", "func (t transporter) Post(path string, body io.Reader) (*http.Response, error) {\n\tresp, err := t.client.Post(t.scheme+path, \"application/json\", body)\n\treturn resp, err\n}", "func (client *Client) Post(c context.Context, uri string, params interface{}, res interface{}) (err error) {\n\treq, err := client.NewRequest(xhttp.MethodPost, uri, params)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn client.client.Do(c, req, res)\n}", "func (c *Client) Post() *Request {\n\treturn NewRequest(c.httpClient, c.base, \"POST\", c.version, c.authstring, c.userAgent)\n}", "func (tr *Transport) POST(\n\turl string,\n\tfn Handler,\n\toptions ...HandlerOption,\n) {\n\ttr.mux.Handler(\n\t\tnet_http.MethodPost,\n\t\turl,\n\t\tnewHandler(fn, append(tr.options, options...)...),\n\t)\n}", "func (tr *Transport) Post(url string, fn HandlerFunc, options ...HandlerOption) {\n\ttr.mux.Handler(net_http.MethodPost, url, encapsulate(fn, tr.options, options))\n}", "func (session *Session) Post(path string, urlParams, data Params) (response []byte, err error) {\n\turlStr := session.getUrl(path, urlParams)\n\n\tresponse, err = session.sendPostRequest(urlStr, data)\n\n\treturn\n\n\t//res, err = MakeResult(response)\n\t//return\n}", "func (c *Client) Post(rawurl string, in, out interface{}) error {\n\treturn c.Do(rawurl, \"POST\", in, out)\n}" ]
[ "0.8183926", "0.7732567", "0.76200134", "0.75784963", "0.75539345", "0.7427361", "0.7357585", "0.7335185", "0.7305281", "0.730186", "0.72804624", "0.727684", "0.7255811", "0.7240516", "0.72129816", "0.72095233", "0.7202608", "0.71791095", "0.71427095", "0.7142554", "0.71369547", "0.71369547", "0.71364075", "0.7135508", "0.7134434", "0.70815575", "0.7078616", "0.70781827", "0.706358", "0.7050629", "0.7049153", "0.7034477", "0.7032914", "0.70170915", "0.70155114", "0.7010572", "0.69836676", "0.69719934", "0.69632995", "0.6962234", "0.69483835", "0.69481456", "0.69337386", "0.69334674", "0.69150245", "0.6905602", "0.68927115", "0.6889825", "0.6877413", "0.6845533", "0.6844327", "0.6833629", "0.68273944", "0.6815093", "0.6814455", "0.6811714", "0.6809695", "0.68058634", "0.68048674", "0.6804152", "0.67972267", "0.678047", "0.6774031", "0.6771766", "0.67559665", "0.67559665", "0.675559", "0.6754227", "0.67530715", "0.67492473", "0.67371905", "0.67354983", "0.67280424", "0.672664", "0.67194295", "0.66998845", "0.6691052", "0.6683097", "0.6674177", "0.66611505", "0.663799", "0.6637488", "0.66347784", "0.66326404", "0.6625959", "0.6622738", "0.66174537", "0.6592155", "0.65898854", "0.6585473", "0.6584076", "0.65831906", "0.65479666", "0.6531224", "0.65080494", "0.64952433", "0.6492289", "0.6477051", "0.6466147", "0.6463049" ]
0.85327715
0
PUT is a shorthand for e.Request("PUT", path, pathargs...).
PUT — это сокращение для e.Request("PUT", path, pathargs...).
func (e *Expect) PUT(path string, pathargs ...interface{}) *Request { return e.Request(http.MethodPut, path, pathargs...) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Request) Put(path string) *Request {\n\treturn r.method(\"PUT\", path)\n}", "func (r *Request) Put(path, contentType string, data ...interface{}) {\n\tr.Send(\"PUT\", path, contentType, data...)\n}", "func (client *Client) Put(path string) Response {\n\treturn client.processRequest(path, \"PUT\")\n}", "func (r *Router) PUT(path string, handler RequestHandler) {\n\tr.setPath(httpPUT, path, handler)\n}", "func (c clientType) Put(path string, body interface{}) (resp *resty.Response, err error) {\n\treturn c.execute(http.MethodPut, path, body)\n}", "func (api *Api) Put(path string, endpoint http.HandlerFunc, queries ...string) {\n\tapi.Router.HandleFunc(path, endpoint).Methods(\"PUT\").Queries(queries...)\n}", "func (r *Router) PUT(url string, viewFn View) *Path {\n\treturn r.Path(fasthttp.MethodPut, url, viewFn)\n}", "func (g *Group) PUT(path string, handler Handler, middleware ...Middleware) *Group {\n\treturn g.Add(http.MethodPut, path, handler, middleware...)\n}", "func (c Client) put(path string, params url.Values, holder interface{}) error {\n\treturn c.request(\"PUT\", path, params, &holder)\n}", "func (r Requester) Update(path string, payload interface{}) Requester {\n\tb, err := json.Marshal(payload)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tbody := bytes.NewReader(b)\n\tr.httpRequest, err = http.NewRequest(http.MethodPut, r.url, body)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn r\n}", "func Put(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\tinfoMutex.Lock()\n\trecord(\"PUT\", path)\n\tr.Put(path, alice.New(c...).ThenFunc(fn).(http.HandlerFunc))\n\tinfoMutex.Unlock()\n}", "func (r *Router) PUT(path string, h HandlerFunc) {\n\tr.router.PUT(path, r.handle(h, r.getValidationForPath(path, \"PUT\")))\n}", "func Put(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\trecord(\"PUT\", path)\n\n\tinfoMutex.Lock()\n\tr.PUT(path, Handler(alice.New(c...).ThenFunc(fn)))\n\tinfoMutex.Unlock()\n}", "func (a *ApiServer) Put(path string, f func(w http.ResponseWriter, r *http.Request)) *ApiServer{\n\ta.Router.HandleFunc(path, f).Methods(\"PUT\")\n\treturn a\n}", "func (e *Engine) PUT(path string, fn Controller) {\n\te.gin.PUT(path, adapt(fn))\n}", "func (s *Server) Put(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\ts.Router.HandleFunc(path, f).Methods(\"PUT\")\n}", "func Put(url string, r io.Reader, w io.Writer, clientGenerator func() *http.Client, reqTuner ...func(*http.Request)) error {\n\treturn Request(\"PUT\", url, r, w, clientGenerator, reqTuner...)\n}", "func (e *Engine) PUT(path string, handler Handler) {\n\te.registerRoute(http.MethodPut, path, handler)\n}", "func (router *Router) PUT(relativePath string, handler Handler, decorators ...Decorator) {\n\trouter.createRouter(http.MethodPut, relativePath, handler, \"\", decorators...)\n}", "func (r *Router) PUT(path string, handle HandlerFunc, middleware ...MiddlewareFunc) {\n\tr.Handle(\"PUT\", path, handle, middleware...)\n}", "func (r *Request) Put(url string) *Request {\n\tr.method = http.MethodPut\n\tr.url = url\n\treturn r\n}", "func (r *bitroute) PUT(path string, f func(router.Control)) {\n\tr.register(\"PUT\", path, f)\n}", "func (h *Handler) Put(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\tpath = configuration.Instance.Service.Path + path\n\tlog.Println(\"Adding '\" + path + \"' as PUT path\")\n\th.Router.HandleFunc(path, f).Methods(\"PUT\")\n}", "func (f *Fastglue) PUT(path string, h FastRequestHandler) {\n\tf.Router.PUT(path, f.handler(h))\n}", "func (r *RouterGroup) PUT(path string, fn Controller) {\n\tr.gin.PUT(path, adapt(fn))\n}", "func (app *App) Put(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\tapp.Router.HandleFunc(path, f).Methods(\"PUT\")\n}", "func Put(url string, data ...interface{}) (*ClientResponse, error) {\n\treturn DoRequest(\"PUT\", url, data...)\n}", "func (m *Middleware) PUT(path string, handler Handler) {\n\tm.engine.PUT(path, m.apply(handler))\n}", "func (a *App) Put(path string, f func(w http.ResponseWriter, r *http.Request)) {\r\n\ta.Router.HandleFunc(path, f).Methods(\"PUT\")\r\n}", "func Put(path string, f func(http.ResponseWriter, *http.Request)) *Route {\n\treturn NewRoute().Path(path).Method(HttpPut).HandlerFunc(f)\n}", "func (a *App) Put(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\ta.Router.HandleFunc(path, f).Methods(\"PUT\")\n}", "func (a *App) Put(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\ta.Router.HandleFunc(path, f).Methods(\"PUT\")\n}", "func Put(path string, handler http.Handler) Route {\n\treturn NewRoute(\"PUT\", path, handler)\n}", "func (c *Client) Put(url string, headers, queryParams map[string][]string, data interface{}) (response *http.Response, err error) {\n\treturn c.makeRequest(url, http.MethodPut, headers, queryParams, data)\n}", "func (f *Client) Put(path string, params GraphQueryString) *GraphRequest {\n\treturn f.NewGraphRequest(Put, path, params)\n}", "func (c *Client) Put(path string, data, resource interface{}) error {\n\treturn c.CreateAndDo(\"PUT\", path, data, nil, nil, resource)\n}", "func (r *Router) PUT(path string, handler Handle) {\n\tr.Handle(\"PUT\", path, handler)\n}", "func (F *Frisby) Put(url string) *Frisby {\n\tF.Method = \"PUT\"\n\tF.Url = url\n\treturn F\n}", "func (r *Router) PUT(path string, handle Handle) {\n\tr.Handle(http.MethodPut, path, handle)\n}", "func NewPut(url string) *Request { return NewRequest(\"PUT\", url) }", "func (rg *RouteGroup) PUT(path string, handlers ...Handler) *Route {\n\treturn rg.add(\"PUT\", path, handlers)\n}", "func (client *RestClient) Put(path string, obj interface{}) error {\n\tres, err := client.R().SetBody(obj).Put(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif res.StatusCode() >= 400 {\n\t\treturn UnmarshalError(res)\n\t}\n\n\treturn nil\n}", "func (rb *RequestBuilder) Put(url string, body interface{}) *Response {\n\treturn rb.DoRequest(http.MethodPut, url, body)\n}", "func (engine *Engine) PUT(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn engine.handle(http.MethodPut, relativePath, handlers)\n}", "func Put(path string, fn httprouter.Handle) {\n\tr.Router.PUT(path, fn)\n}", "func (r *Router) Put(path, title string, fn Handle) {\n\tr.addRoute(\"PUT\", path, title, fn)\n}", "func (c *Client) Put() *Request {\n\treturn NewRequest(c.httpClient, c.base, \"PUT\", c.version, c.authstring, c.userAgent)\n}", "func (a *APITest) Put(url string) *Request {\n\tr := a.request\n\tr.method = http.MethodPut\n\tr.url = url\n\treturn r\n}", "func (r *Mux) PUT(path string, handler http.HandlerFunc) {\n\tr.HandleFunc(\"PUT\", path, handler)\n}", "func (APIResourceBase) Put(session *Session, url string, queries url.Values, body io.Reader) (APIStatus, interface{}) {\n\treturn FailSimple(http.StatusMethodNotAllowed), nil\n}", "func (app *App) PUT(url string, handler ...Handler) *App {\n\tapp.routeANY = false\n\tapp.AppendReqAndResp(url, \"put\", handler)\n\treturn app\n}", "func (c *Client) Put(rawurl string, in, out interface{}) error {\n\treturn c.Do(rawurl, \"PUT\", in, out)\n}", "func (self *Client) Put(dst interface{}, path string, data url.Values) error {\n\tvar addr *url.URL\n\tvar err error\n\tvar body *strings.Reader\n\n\tif addr, err = url.Parse(self.Prefix + strings.TrimLeft(path, \"/\")); err != nil {\n\t\treturn err\n\t}\n\n\tif data != nil {\n\t\tbody = strings.NewReader(data.Encode())\n\t}\n\n\treturn self.newRequest(dst, \"PUT\", addr, body)\n}", "func (r *Request) Put(url string) (*Response, error) {\n\treturn r.Execute(MethodPut, url)\n}", "func (router *Router) Put(path string, handler http.Handler) {\n\trouter.Handle(\"PUT\", path, handler)\n}", "func (c *Client) put(rawURL string, authenticate bool, expectedStatus int, in interface{}, out interface{}) error {\n\terr := c.do(rawURL, \"PUT\", authenticate, expectedStatus, in, out)\n\treturn errio.Error(err)\n}", "func (tr *Transport) PUT(\n\turl string,\n\tfn Handler,\n\toptions ...HandlerOption,\n) {\n\ttr.mux.Handler(\n\t\tnet_http.MethodPut,\n\t\turl,\n\t\tnewHandler(fn, append(tr.options, options...)...),\n\t)\n}", "func (group *RouterGroup) PUT(path string, handlers ...HandlerFunc) {\n\tgroup.Handle(\"PUT\", path, handlers)\n}", "func Put(url string, payload interface{}, headers map[string]string) (int, error) {\n\treturn doHttpCall(url, \"PUT\", payload, headers)\n}", "func (serv *Server) PUT(url string, handlers ...Handler) {\n\tserv.Handle(\"PUT\", url, handlers...)\n}", "func Put(c context.Context, path string, data []byte) error {\n\treturn FromContext(c).Put(path, data)\n}", "func (g *RouterGroup) PUT(url string, handler ...Handler) *RouterGroup {\n\tg.app.routeANY = false\n\tg.AppendReqAndResp(url, \"put\", handler)\n\treturn g\n}", "func (c *Client) Put(ctx context.Context, url string, data ...interface{}) (*Response, error) {\n\treturn c.DoRequest(ctx, http.MethodPut, url, data...)\n}", "func (c *TogglHttpClient) PutRequest(endpoint string, body interface{}) (*json.RawMessage, error) {\n\treturn request(c, \"PUT\", endpoint, body)\n}", "func (c *Client) Put(endpoint string, resource ...RequestResource) error {\n\twrapper := newWrapper(\"put\", endpoint, resource...)\n\treturn c.do(&wrapper)\n}", "func Put(route string, do interface{}) *handler {\n\treturn handlerByMethod(&route, do, \"PUT\")\n}", "func (node *Node) PUT(functions ...interface{}) *Handler {\n\n\thandler := &Handler{}\n\n\tif len(functions) > 0 { handler.function = functions[0].(func (req web.RequestInterface) *web.ResponseStatus) }\n\n\tnode.addHandler(\"PUT\", handler)\n\n\treturn handler\n}", "func (mm *Middleman) Put(path string, middleware Middleware) error {\r\n\treturn mm.addMiddleware(path, http.MethodPut, middleware)\r\n}", "func (s *Nap) Put(pathURL string) *Nap {\n\ts.method = MethodPut\n\treturn s.Path(pathURL)\n}", "func (a *App) PUT(pattern string, handler Handler) {\n\ta.add(\"PUT\", pattern, handler)\n}", "func (c *Client) Put(url string, reqBody, resType interface{}) error {\n\treturn c.CallAPI(\"PUT\", url, reqBody, resType, true)\n}", "func (cl *Client) Put(c context.Context, url string, opts ...RequestOption) (*Response, error) {\n\treq, err := cl.NewRequest(c, http.MethodPut, url, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn cl.Do(c, req)\n}", "func Put(url string, data ...interface{}) (*Response, error) {\n\tr := NewRequest()\n\treturn r.Put(url, data...)\n}", "func Put(url string, bodyType string, body io.Reader) (*http.Response, error) {\n\treq, err := http.NewRequest(\"PUT\", url, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Set(\"Content-Type\", bodyType)\n\treturn http.DefaultClient.Do(req)\n}", "func (r *Router) Put(path string, handle requestHandler, config ...RouteConfig) {\n\tr.routers[\"PUT\"] = append(r.routers[\"PUT\"], newRouteHandler(path, handle, config...))\n}", "func (r *Router) Put(path string, handler httpHandler) {\n\tr.PUT(path, wrapHandler(handler))\n}", "func (em *entityManager) Put(ctx context.Context, entityPath string, body []byte, mw ...MiddlewareFunc) (*http.Response, error) {\n\tctx, span := em.startSpanFromContext(ctx, \"sb.EntityManger.Put\")\n\tdefer span.End()\n\n\treturn em.Execute(ctx, http.MethodPut, entityPath, bytes.NewReader(body), mw...)\n}", "func (r *Route) Put(h http.Handler) *Route {\n\tr.Add(\"PUT\", h)\n\n\treturn r\n}", "func (group *RouterGroup) PUT(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn group.handle(http.MethodPut, relativePath, handlers)\n}", "func Put(path string, data string) {\n\tres, err := putThis(path, data)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\tfmt.Printf(sep)\n\tfmt.Printf(\"PUT result: %s\\n\", res)\n}", "func put(resource string, data []byte) ([]byte, error) {\n\thttpParams := &HTTPParams{\"PUT\", resource, \"application/json\", data}\n\treturn processRequest(httpParams)\n}", "func (n *NS) Put(url string) *route {\n\treturn &route{context: n.c, method: \"PUT\", url: n.prefix + url, bCtrl: n.bCtrl, aCtrl: n.aCtrl}\n}", "func (r *Router) Put(path string, handler http.Handler) {\n\tr.PUT(path, wrapHandler(handler))\n}", "func (r *Router) Put(path string, handler http.Handler) {\n\tr.PUT(path, wrapHandler(handler))\n}", "func (r *Router) Put(path string, handle HandleFunc) {\n\tr.register(path, http.MethodPut, handle)\n}", "func Put(h http.Handler) http.Handler {\n\treturn HTTP(h, PUT)\n}", "func (group *RouterGroup) PUT(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn group.Handler(\"PUT\", relativePath, handlers...)\n}", "func (c *Client) Put(url string, headers map[string][]string, body io.Reader) (client.Status, map[string][]string, io.ReadCloser, error) {\n\treturn c.Do(\"PUT\", url, headers, body)\n}", "func (c *Client) put(urlStr string, body []byte) (*http.Response, error) {\n\treturn c.doAlwaysFollowingRedirects(\"PUT\", urlStr, body)\n}", "func makePutRequest(link string, data *bytes.Buffer) string {\n client := &http.Client{}\n req, _ := http.NewRequest(\"PUT\", link, data)\n response, clientErr := client.Do(req)\n if clientErr != nil {\n fmt.Println(clientErr)\n }\n bodyBytes, _ := ioutil.ReadAll(response.Body)\n response.Body.Close()\n return string(bodyBytes)\n}", "func (g *Group) PUT(path string, h Handler, gases ...Gas) {\n\tg.Air.PUT(g.Prefix+path, h, append(g.Gases, gases...)...)\n}", "func (b *Builder) Put(url string) *Builder {\n\tb.Url = url\n\tb.Method = http.MethodPut\n\treturn b\n}", "func (s *WebService) Put(route string, handler interface{}) {\r\n\ts.addRoute(route, \"PUT\", handler)\r\n}", "func (r *Request) PutForm(path string, data interface{}) {\n\tr.Put(path, \"application/x-www-form-urlencoded\", data)\n}", "func Put(config *HTTPConfig) (*HTTPResult, error) {\n\treturn HandleRequest(\"PUT\", config)\n}", "func (r *Router) PUT(pattern string, handler func(Context)) Route {\n\treturn r.Handle(\"PUT\", pattern, wrap(handler))\n}", "func IsPUT(r *http.Request) bool {\n\treturn strings.Compare(r.Method, \"PUT\") == 0\n}", "func (rg *RouteGroup) Put(path string, handlers ...Handler) *Route {\n\treturn rg.add(\"PUT\", path, handlers)\n}", "func Put(uri string) error {\n\treq, err := http.NewRequest(\"PUT\", Host+uri, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tres, err := Client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer res.Body.Close()\n\n\tif res.StatusCode != 204 {\n\t\treturn fmt.Errorf(\"got %d\", res.StatusCode)\n\t}\n\n\treturn nil\n}", "func Put(ctx context.Context, url string, body Body, options ...RequestOption) (*Response, error) {\n\tr, err := newRequest(ctx, http.MethodPut, url, body, options...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tr.Header.Set(\"Content-Type\", body.ContentType())\n\treturn doRequest(http.DefaultClient, r)\n}" ]
[ "0.82787406", "0.7994318", "0.7698192", "0.7613152", "0.7606588", "0.75494", "0.7526452", "0.7382648", "0.73742276", "0.7360344", "0.735589", "0.73023254", "0.7295277", "0.7255101", "0.7236425", "0.72218215", "0.7220903", "0.72073925", "0.7194703", "0.7173302", "0.71618134", "0.71506995", "0.7142924", "0.7114693", "0.71133375", "0.7099384", "0.70991063", "0.70741767", "0.70646983", "0.70572865", "0.70505035", "0.70505035", "0.6991252", "0.69755644", "0.69719696", "0.6964554", "0.69634783", "0.69632566", "0.6945773", "0.6931826", "0.69221693", "0.6910999", "0.6909102", "0.68365324", "0.6829249", "0.6812156", "0.6801669", "0.67985475", "0.67925054", "0.6789405", "0.6769526", "0.6763695", "0.6761947", "0.6726006", "0.67154133", "0.6713628", "0.67086995", "0.6698083", "0.6691394", "0.66877127", "0.6679534", "0.66663885", "0.6658176", "0.66508794", "0.6641034", "0.6633264", "0.6615081", "0.65903634", "0.65814847", "0.6580279", "0.65649104", "0.65515816", "0.6548919", "0.653104", "0.652635", "0.6522962", "0.65187925", "0.65114015", "0.6506272", "0.6496171", "0.6490028", "0.6464805", "0.64541876", "0.64541876", "0.64315695", "0.642794", "0.6427653", "0.6420117", "0.6412596", "0.6365728", "0.6363343", "0.63616556", "0.6352011", "0.6324144", "0.63208926", "0.63090724", "0.63003916", "0.6299348", "0.6290136", "0.6283265" ]
0.880231
0
PATCH is a shorthand for e.Request("PATCH", path, pathargs...).
PATCH — это сокращение для e.Request("PATCH", path, pathargs...).
func (e *Expect) PATCH(path string, pathargs ...interface{}) *Request { return e.Request(http.MethodPatch, path, pathargs...) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Request) Patch(path string) *Request {\n\treturn r.method(\"PATCH\", path)\n}", "func (r *Router) PATCH(path string, handler RequestHandler) {\n\tr.setPath(httpPATCH, path, handler)\n}", "func (r *Router) PATCH(url string, viewFn View) *Path {\n\treturn r.Path(fasthttp.MethodPatch, url, viewFn)\n}", "func (r *Request) Patch(path, contentType string, data ...interface{}) {\n\tr.Send(\"PATCH\", path, contentType, data...)\n}", "func (r *Router) PATCH(path string, h HandlerFunc) {\n\tr.router.PATCH(path, r.handle(h, r.getValidationForPath(path, \"PATCH\")))\n}", "func (r *Router) PATCH(path string, handle HandlerFunc, middleware ...MiddlewareFunc) {\n\tr.Handle(\"PATCH\", path, handle, middleware...)\n}", "func (r *Router) PATCH(path string, handle Handle) {\n\tr.Handle(\"PATCH\", path, handle)\n}", "func (r *bitroute) PATCH(path string, f func(router.Control)) {\n\tr.register(\"PATCH\", path, f)\n}", "func (e *Engine) PATCH(path string, fn Controller) {\n\te.gin.PATCH(path, adapt(fn))\n}", "func (e *Engine) PATCH(path string, handler Handler) {\n\te.registerRoute(http.MethodPatch, path, handler)\n}", "func (tr *Transport) PATCH(\n\turl string,\n\tfn Handler,\n\toptions ...HandlerOption,\n) {\n\ttr.mux.Handler(\n\t\tnet_http.MethodPatch,\n\t\turl,\n\t\tnewHandler(fn, append(tr.options, options...)...),\n\t)\n}", "func (m *Middleware) PATCH(path string, handler Handler) {\n\tm.engine.PATCH(path, m.apply(handler))\n}", "func (r *RouterGroup) PATCH(path string, fn Controller) {\n\tr.gin.PATCH(path, adapt(fn))\n}", "func (serv *Server) PATCH(url string, handlers ...Handler) {\n\tserv.Handle(\"PATCH\", url, handlers...)\n}", "func (rg *RouteGroup) PATCH(path string, handlers ...Handler) *Route {\n\treturn rg.add(\"PATCH\", path, handlers)\n}", "func Patch(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\trecord(\"PATCH\", path)\n\n\tinfoMutex.Lock()\n\tr.PATCH(path, Handler(alice.New(c...).ThenFunc(fn)))\n\tinfoMutex.Unlock()\n}", "func PATCH(c *httputil.Client, data DataMultipartWriter, v interface{}, url string) error {\n\treturn Do(c, \"PATCH\", data, v, url)\n}", "func (router *Router) PATCH(relativePath string, handler Handler, decorators ...Decorator) {\n\trouter.createRouter(http.MethodPatch, relativePath, handler, \"\", decorators...)\n}", "func (r *Mux) PATCH(path string, handler http.HandlerFunc) {\n\tr.HandleFunc(\"PATCH\", path, handler)\n}", "func (api *Api) Patch(path string, endpoint http.HandlerFunc, queries ...string) {\n\tapi.Router.HandleFunc(path, endpoint).Methods(\"PATCH\").Queries(queries...)\n}", "func Patch(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\tinfoMutex.Lock()\n\trecord(\"PATCH\", path)\n\tr.Patch(path, alice.New(c...).ThenFunc(fn).(http.HandlerFunc))\n\tinfoMutex.Unlock()\n}", "func (engine *Engine) PATCH(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn engine.handle(http.MethodPatch, relativePath, handlers)\n}", "func (group *RouterGroup) PATCH(path string, handlers ...HandlerFunc) {\n\tgroup.Handle(\"PATCH\", path, handlers)\n}", "func (r *Router) PATCH(path string, handle Handle) {\n\tr.Handle(http.MethodPatch, path, handle)\n}", "func (node *Node) PATCH(functions ...interface{}) *Handler {\n\n\thandler := &Handler{}\n\n\tif len(functions) > 0 { handler.function = functions[0].(func (req web.RequestInterface) *web.ResponseStatus) }\n\n\tnode.addHandler(\"PATCH\", handler)\n\n\treturn handler\n}", "func Patch(url string, data ...interface{}) (*ClientResponse, error) {\n\treturn DoRequest(\"PATCH\", url, data...)\n}", "func (c *Client) Patch(url string, headers, queryParams map[string][]string, data interface{}) (response *http.Response, err error) {\n\treturn c.makeRequest(url, http.MethodPatch, headers, queryParams, data)\n}", "func (r *Request) Patch(url string) *Request {\n\tr.method = http.MethodPatch\n\tr.url = url\n\treturn r\n}", "func (rb *RequestBuilder) Patch(url string, body interface{}) *Response {\n\treturn rb.DoRequest(http.MethodPatch, url, body)\n}", "func (c *Client) Patch(ctx context.Context, url string, data ...interface{}) (*Response, error) {\n\treturn c.DoRequest(ctx, http.MethodPatch, url, data...)\n}", "func (c *Client) patch(rawURL string, authenticate bool, expectedStatus int, in interface{}, out interface{}) error {\n\terr := c.do(rawURL, \"PATCH\", authenticate, expectedStatus, in, out)\n\treturn errio.Error(err)\n}", "func (group *RouterGroup) PATCH(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn group.handle(http.MethodPatch, relativePath, handlers)\n}", "func (cl *Client) Patch(c context.Context, url string, opts ...RequestOption) (*Response, error) {\n\treq, err := cl.NewRequest(c, http.MethodPatch, url, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn cl.Do(c, req)\n}", "func (r *Router) PATCH(pattern string, handler func(Context)) Route {\n\treturn r.Handle(\"PATCH\", pattern, wrap(handler))\n}", "func (c *Client) Patch(url string, reqBody, resType interface{}) error {\n\treturn c.CallAPI(\"PATCH\", url, reqBody, resType, true)\n}", "func (a *APITest) Patch(url string) *Request {\n\ta.request.method = http.MethodPatch\n\ta.request.url = url\n\treturn a.request\n}", "func (c *Client) Patch(rawurl string, in, out interface{}) error {\n\treturn c.Do(rawurl, \"PATCH\", in, out)\n}", "func Patch(path string, handler http.Handler) Route {\n\treturn NewRoute(\"PATCH\", path, handler)\n}", "func (r *Router) PATCH(route string, handler interface{}) *Router {\n\tr.Handle(MethodPATCH, route, handler)\n\treturn r\n}", "func (F *Frisby) Patch(url string) *Frisby {\n\tF.Method = \"PATCH\"\n\tF.Url = url\n\treturn F\n}", "func (g *Group) PATCH(path string, h Handler, gases ...Gas) {\n\tg.Air.PATCH(g.Prefix+path, h, append(g.Gases, gases...)...)\n}", "func (r *Request) Patch(url string) (*Response, error) {\n\treturn r.Execute(MethodPatch, url)\n}", "func (this *Route) PATCH(handlers ...HTTPHandler) *Route {\n\treturn this.addHandler(\"patch\", handlers...)\n}", "func (rg *RouteGroup) Patch(path string, handlers ...Handler) *Route {\n\treturn rg.add(\"PATCH\", path, handlers)\n}", "func Patch(path string, fn httprouter.Handle) {\n\tr.Router.PATCH(path, fn)\n}", "func (c *Client) Patch(url string, headers map[string][]string, body io.Reader) (client.Status, map[string][]string, io.ReadCloser, error) {\n\treturn c.Do(\"PATCH\", url, headers, body)\n}", "func (APIResourceBase) Patch(session *Session, url string, queries url.Values, body io.Reader) (APIStatus, interface{}) {\n\treturn FailSimple(http.StatusMethodNotAllowed), nil\n}", "func Patch(ctx context.Context, url string, body Body, options ...RequestOption) (*Response, error) {\n\tr, err := newRequest(ctx, http.MethodPatch, url, body, options...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tr.Header.Set(\"Content-Type\", body.ContentType())\n\treturn doRequest(http.DefaultClient, r)\n}", "func (r *Router) Patch(path string, handler httpHandler) {\n\tr.PATCH(path, wrapHandler(handler))\n}", "func (r Requester) Update(path string, payload interface{}) Requester {\n\tb, err := json.Marshal(payload)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tbody := bytes.NewReader(b)\n\tr.httpRequest, err = http.NewRequest(http.MethodPut, r.url, body)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn r\n}", "func Patch(url string, opts ...RequestOption) (*Response, error) {\n\treturn DefaultSession.Patch(url, opts...)\n}", "func (mm *Middleman) Patch(path string, middleware Middleware) error {\r\n\treturn mm.addMiddleware(path, http.MethodPatch, middleware)\r\n}", "func (s *Nap) Patch(pathURL string) *Nap {\n\ts.method = MethodPatch\n\treturn s.Path(pathURL)\n}", "func Patch(route string, do interface{}) *handler {\n\treturn handlerByMethod(&route, do, \"PATCH\")\n}", "func (r *Route) Patch(h http.Handler) *Route {\n\tr.Add(\"PATCH\", h)\n\n\treturn r\n}", "func (tr *Transport) Patch(url string, fn HandlerFunc, options ...HandlerOption) {\n\ttr.mux.Handler(net_http.MethodPatch, url, encapsulate(fn, tr.options, options))\n}", "func (a *Router) Patch(pattern string, hs ...func(*Context) error) *Router {\n\treturn a.Handle(http.MethodPatch, pattern, hs...)\n}", "func (f5 *f5LTM) patch(url string, payload interface{}, result interface{}) error {\n\treturn f5.restRequestPayload(\"PATCH\", url, payload, result)\n}", "func (mr *MockRouterMockRecorder) PATCH(path, handler interface{}, options ...interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\tvarargs := append([]interface{}{path, handler}, options...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"PATCH\", reflect.TypeOf((*MockRouter)(nil).PATCH), varargs...)\n}", "func (m *MockRouter) PATCH(path string, handler interface{}, options ...interface{}) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{path, handler}\n\tfor _, a := range options {\n\t\tvarargs = append(varargs, a)\n\t}\n\tm.ctrl.Call(m, \"PATCH\", varargs...)\n}", "func (r *Request) PatchForm(path string, data interface{}) {\n\tr.Patch(path, \"application/x-www-form-urlencoded\", data)\n}", "func (ctl Controller) Patch(ctx *gin.Context) {\n\n\tMethodNotAllowedJSON(ctx)\n}", "func (r *Router) Patch(path string, handle HandleFunc) {\n\tr.register(path, http.MethodPatch, handle)\n}", "func (mr *MockRouterTxMockRecorder) PATCH(path, handler interface{}, options ...interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\tvarargs := append([]interface{}{path, handler}, options...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"PATCH\", reflect.TypeOf((*MockRouterTx)(nil).PATCH), varargs...)\n}", "func (m *MockRouterTx) PATCH(path string, handler interface{}, options ...interface{}) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{path, handler}\n\tfor _, a := range options {\n\t\tvarargs = append(varargs, a)\n\t}\n\tm.ctrl.Call(m, \"PATCH\", varargs...)\n}", "func PatchMethod(e *echo.Group, newFn newInstanceFn, pFn patchFn) {\n\te.PATCH(\"/:id\", func(c echo.Context) error {\n\t\tvar id int\n\n\t\tif err := Param(\"id\").InPath().Int(c, &id); err != nil {\n\t\t\treturn BadRequest(err)\n\t\t}\n\t\tresource := newFn()\n\t\tif err := c.Bind(resource); err != nil {\n\t\t\treturn BadRequest(err)\n\t\t}\n\n\t\tif err := pFn(resource); err != nil {\n\t\t\treturn InternalServerError(err)\n\t\t}\n\n\t\treturn c.NoContent(http.StatusNoContent)\n\t})\n\n}", "func (w *Worker) Patch(c *http.Client, url string, data interface{}, bind interface{}) (int, error) {\n\tbs, err := json.Marshal(data)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treq, err := http.NewRequest(\"PATCH\", url, bytes.NewReader(bs))\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\tres, err := c.Do(req)\n\tif err != nil {\n\t\tif res != nil {\n\t\t\tioutil.ReadAll(res.Body)\n\t\t\tres.Body.Close()\n\t\t}\n\t\treturn 0, err\n\t}\n\tdefer res.Body.Close()\n\terr = json.NewDecoder(res.Body).Decode(bind)\n\tif res.StatusCode == http.StatusNoContent || bind == nil {\n\t\treturn res.StatusCode, nil\n\t}\n\treturn res.StatusCode, err\n}", "func (b *Baa) Patch(pattern string, h ...HandlerFunc) RouteNode {\n\treturn b.Router().Add(\"PATCH\", pattern, h)\n}", "func (r *Router) Patch(pattern string, handler http.Handler) Route {\n\treturn r.Handle(\"PATCH\", pattern, handler)\n}", "func OptPatch() Option {\n\treturn RequestOption(webutil.OptPatch())\n}", "func (conn Connection) Patch(cmd string, content, result interface{}) (resp *http.Response, err error) {\n\treturn conn.Send(http.MethodPatch, cmd, content, result)\n}", "func (m *Mux) Patch(pattern string, handler HandlerFunc) {\n\tm.Handle(http.MethodPatch, pattern, handler)\n}", "func (avisess *AviSession) Patch(uri string, payload interface{}, patchOp string, response interface{}, options ...ApiOptionsParams) error {\n\tvar patchPayload = make(map[string]interface{})\n\tpatchPayload[patchOp] = payload\n\tglog.Infof(\" PATCH OP %v data %v\", patchOp, payload)\n\treturn avisess.restRequestInterfaceResponse(\"PATCH\", uri, patchPayload, response, options...)\n}", "func Patch(url string, requestBody []byte, requestHeaders map[string]string, authHeader string) (int, []byte, map[string][]string) {\n\tlogs.Alert(fmt.Sprintf(\"<------------------------- %s ------------------------->\\n\", \"start\"))\n\tlogs.Alert(fmt.Sprintf(\"[HTTP PATCH: %s]\", url))\n\n\tr, _ := http.NewRequest(\"PATCH\", url, bytes.NewBuffer(requestBody))\n\n\tif authHeader != \"\" {\n\t\tr.Header.Add(\"Authorization\", authHeader)\n\t}\n\n\tfor name, value := range requestHeaders {\n\t\tr.Header.Add(name, value)\n\t}\n\n\tclient := &http.Client{Transport: transport, Timeout: timeout}\n\tresp, err := client.Do(r)\n\n\tif err != nil {\n\t\tlogs.Alert(fmt.Sprintf(\"[Request Error --> %v]\", err))\n\t\treturn http.StatusInternalServerError, nil, nil\n\t}\n\n\tdefer resp.Body.Close()\n\tjsonBytes, _ := ioutil.ReadAll(resp.Body)\n\tlogs.Alert(fmt.Sprintf(\"[Status Code --> %d]\", resp.StatusCode))\n\tlogs.Alert(fmt.Sprintf(\"[Response Headers --> %v]\", resp.Header))\n\tlogs.Alert(fmt.Sprintf(\"[Response --> %s]\", string(jsonBytes)))\n\tlogs.Alert(fmt.Sprintf(\"<------------------------- %s ------------------------->\", \"end\"))\n\treturn resp.StatusCode, jsonBytes, resp.Header\n}", "func (conn Connection) Patch(cmd string, content, result interface{}) (effect *SideEffect, resp *http.Response, err error) {\n\treturn conn.Send(http.MethodPatch, cmd, content, result)\n}", "func (r *Route) Patch(h interface{}) *Route {\n\treturn r.Handle(toHandler(h), \"PATCH\")\n}", "func (r *Request) PatchJSON(path string, data interface{}) {\n\tb, err := json.Marshal(data)\n\tif err != nil {\n\t\tr.t.Fatalf(\"httptesting: PatchJSON:json.Marshal(%T): %v\", data, err)\n\t}\n\n\tr.Patch(path, \"application/json\", b)\n}", "func (r *Route) Patch(handler http.Handler) *Route {\n\tr.handlers[http.MethodPatch] = handler\n\treturn r\n}", "func (res *Resource) Patch(storage store.Update) {\n\tres.HandleFuncC(\n\t\tpat.Patch(patID),\n\t\tfunc(ctx context.Context, w http.ResponseWriter, r *http.Request) {\n\t\t\tres.patchHandler(ctx, w, r, storage)\n\t\t},\n\t)\n\n\tres.addRoute(patch, patID)\n}", "func (a *APITest) Patchf(format string, args ...interface{}) *Request {\n\treturn a.Patch(fmt.Sprintf(format, args...))\n}", "func (r *ExternalRequest) Update(ctx context.Context, reqObj *External) error {\n\treturn r.JSONRequest(ctx, \"PATCH\", \"\", reqObj, nil)\n}", "func TestPatch(t *testing.T) {\n\tconst case1Empty = \"/\"\n\tconst case2SetHeader = \"/set_header\"\n\tconst case3SendJSON = \"/send_json\"\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t// check method is PATCH before going to check other features\n\t\tif r.Method != PATCH {\n\t\t\tt.Errorf(\"Expected method %q; got %q\", PATCH, r.Method)\n\t\t}\n\t\tif r.Header == nil {\n\t\t\tt.Errorf(\"Expected non-nil request Header\")\n\t\t}\n\t\tswitch r.URL.Path {\n\t\tdefault:\n\t\t\tt.Errorf(\"No testing for this case yet : %q\", r.URL.Path)\n\t\tcase case1Empty:\n\t\t\tt.Logf(\"case %v \", case1Empty)\n\t\tcase case2SetHeader:\n\t\t\tt.Logf(\"case %v \", case2SetHeader)\n\t\t\tif r.Header.Get(\"API-Key\") != \"fookey\" {\n\t\t\t\tt.Errorf(\"Expected 'API-Key' == %q; got %q\", \"fookey\", r.Header.Get(\"API-Key\"))\n\t\t\t}\n\t\tcase case3SendJSON:\n\t\t\tt.Logf(\"case %v \", case3SendJSON)\n\t\t\tdefer r.Body.Close()\n\t\t\tbody, _ := ioutil.ReadAll(r.Body)\n\t\t\tif string(body) != `{\"query1\":\"test\",\"query2\":\"test\"}` {\n\t\t\t\tt.Error(`Expected Body with {\"query1\":\"test\",\"query2\":\"test\"}`, \"| but got\", string(body))\n\t\t\t}\n\t\t}\n\t}))\n\n\tdefer ts.Close()\n\n\tNew().Patch(ts.URL + case1Empty).\n\t\tEnd()\n\n\tNew().Patch(ts.URL+case2SetHeader).\n\t\tSetHeader(\"API-Key\", \"fookey\").\n\t\tEnd()\n\n\tNew().Patch(ts.URL + case3SendJSON).\n\t\tSendMapString(`{\"query1\":\"test\"}`).\n\t\tSendMapString(`{\"query2\":\"test\"}`).\n\t\tEnd()\n}", "func (p *PatternServeMux) Patch(pat string, h http.Handler) {\n\tp.Add(\"PATCH\", pat, h)\n}", "func (k *kubectlContext) Patch(args ...string) error {\n\tout, err := k.do(append([]string{\"patch\"}, args...)...)\n\tk.t.Log(string(out))\n\treturn err\n}", "func (c *BaseController) Patch(w http.ResponseWriter, r *Request) {\n\thttp.Error(w, \"Method Not Allowed\", 405)\n}", "func (r *FakeClient) Patch(\n\tctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption,\n) error {\n\t// TODO (covariance) implement me!\n\tpanic(\"not implemented\")\n}", "func (r *versionResolver) Patch(ctx context.Context, obj *restModel.APIVersion) (*restModel.APIPatch, error) {\n\tif !evergreen.IsPatchRequester(*obj.Requester) {\n\t\treturn nil, nil\n\t}\n\tapiPatch, err := data.FindPatchById(*obj.Id)\n\tif err != nil {\n\t\treturn nil, InternalServerError.Send(ctx, fmt.Sprintf(\"Couldn't find a patch with id '%s': %s\", *obj.Id, err.Error()))\n\t}\n\treturn apiPatch, nil\n}", "func (e *Expect) PUT(path string, pathargs ...interface{}) *Request {\n\treturn e.Request(http.MethodPut, path, pathargs...)\n}", "func (mx *Mux) Patch(pattern string, handlerFn http.HandlerFunc) {\n\tmx.handle(mPATCH, pattern, handlerFn)\n}", "func (c *Controller) Patch() {\n\thttp.Error(c.Ctx.ResponseWriter, \"Method Not Allowed\", http.StatusMethodNotAllowed)\n}", "func Patch(pattern string, handler func(Context)) {\n\tmux.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) {\n\t\tif r.Method != \"PATCH\" {\n\t\t\thttp.NotFound(w, r)\n\t\t\treturn\n\t\t}\n\n\t\thandler(Context{\n\t\t\tResponse: w,\n\t\t\tRequest: r,\n\t\t})\n\t})\n}", "func (router *Router) Patch(path string, handler Handle) *Router {\n\trouter.Mux.PATCH(path, handleProxy(handler))\n\treturn router\n}", "func (fkw *FakeClientWrapper) Patch(ctx context.Context, obj runtime.Object,\n\tpatch k8sCl.Patch, opts ...k8sCl.PatchOption) error {\n\treturn fkw.client.Patch(ctx, obj, patch, opts...)\n}", "func (c *SubresourceClient) Patch(namespace string, name string, data []byte) (e error) {\n\tif c.Error != \"\" {\n\t\te = fmt.Errorf(c.Error)\n\t}\n\treturn\n}", "func PatchBytes(url string, data ...interface{}) []byte {\n\treturn RequestBytes(\"PATCH\", url, data...)\n}", "func (client *MockClient) Patch(context ctx.Context, object ctrlClient.Object, patch ctrlClient.Patch, options ...ctrlClient.PatchOption) error {\n\treturn fmt.Errorf(\"Not implemented\")\n}", "func (r *ExtensionRequest) Update(ctx context.Context, reqObj *Extension) error {\n\treturn r.JSONRequest(ctx, \"PATCH\", \"\", reqObj, nil)\n}", "func (a *App) Patch(w http.ResponseWriter, r *http.Request) {\n\tw.Write([]byte(\"patching in testing mode. Get ready to send multipart-form data\"))\n}", "func (*HttpCffAction) PatchPath(ref string) string {\n\treturn fmt.Sprintf(\"/api/objects/http/cff_action/%s\", ref)\n}", "func (client HTTPSuccessClient) Patch202(booleanValue *bool) (result autorest.Response, err error) {\n req, err := client.Patch202Preparer(booleanValue)\n if err != nil {\n return result, autorest.NewErrorWithError(err, \"httpinfrastructuregroup.HTTPSuccessClient\", \"Patch202\", nil , \"Failure preparing request\")\n }\n\n resp, err := client.Patch202Sender(req)\n if err != nil {\n result.Response = resp\n return result, autorest.NewErrorWithError(err, \"httpinfrastructuregroup.HTTPSuccessClient\", \"Patch202\", resp, \"Failure sending request\")\n }\n\n result, err = client.Patch202Responder(resp)\n if err != nil {\n err = autorest.NewErrorWithError(err, \"httpinfrastructuregroup.HTTPSuccessClient\", \"Patch202\", resp, \"Failure responding to request\")\n }\n\n return\n}" ]
[ "0.8082939", "0.79485875", "0.7912536", "0.7824908", "0.763242", "0.76136535", "0.7507971", "0.7493006", "0.7487783", "0.74693745", "0.7466364", "0.74389553", "0.74365085", "0.7419845", "0.74184185", "0.7400768", "0.7369115", "0.7331139", "0.7320122", "0.73052347", "0.72978497", "0.7279466", "0.7256477", "0.7235181", "0.71369684", "0.71277636", "0.7123945", "0.7122819", "0.7110203", "0.70212674", "0.7000825", "0.6986983", "0.6974243", "0.6951236", "0.69376606", "0.6933343", "0.6923582", "0.69046843", "0.6896538", "0.6891865", "0.6875577", "0.6856909", "0.67946696", "0.6782048", "0.67761827", "0.6701242", "0.66883475", "0.6688292", "0.66098213", "0.6592049", "0.65908647", "0.65868753", "0.6577811", "0.6566974", "0.6542181", "0.65197635", "0.64779514", "0.6470891", "0.64128727", "0.64037466", "0.63904923", "0.6382211", "0.6359057", "0.6357", "0.63515407", "0.6339525", "0.629366", "0.62833375", "0.62475675", "0.62325436", "0.62140095", "0.6211714", "0.61983925", "0.6187708", "0.6164913", "0.6163976", "0.6156128", "0.6152", "0.6144881", "0.6138464", "0.6112108", "0.61105466", "0.609833", "0.6077597", "0.6069947", "0.60429096", "0.6040407", "0.6038182", "0.60255843", "0.60138416", "0.600529", "0.5986722", "0.5984741", "0.5978965", "0.5955159", "0.5943534", "0.5934052", "0.5923601", "0.5912267", "0.587179" ]
0.8773625
0
DELETE is a shorthand for e.Request("DELETE", path, pathargs...).
DELETE — это сокращение для e.Request("DELETE", path, pathargs...).
func (e *Expect) DELETE(path string, pathargs ...interface{}) *Request { return e.Request(http.MethodDelete, path, pathargs...) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Request) Delete(path string) *Request {\n\treturn r.method(\"DELETE\", path)\n}", "func (r Requester) Delete(path string) Requester {\n\treq, err := http.NewRequest(http.MethodDelete, r.url, nil)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tr.httpRequest = req\n\treturn r\n}", "func (r *Request) Delete(path, contentType string, data ...interface{}) {\n\tr.Send(\"DELETE\", path, contentType, data...)\n}", "func Delete(url string, r io.Reader, w io.Writer, clientGenerator func() *http.Client, reqTuner ...func(*http.Request)) error {\n\treturn Request(\"DELETE\", url, r, w, clientGenerator, reqTuner...)\n}", "func (c *Client) Delete(url string, headers, queryParams map[string][]string, data interface{}) (response *http.Response, err error) {\n\treturn c.makeRequest(url, http.MethodDelete, headers, queryParams, data)\n}", "func Delete(url string, data ...interface{}) (*ClientResponse, error) {\n\treturn DoRequest(\"DELETE\", url, data...)\n}", "func Delete(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\tinfoMutex.Lock()\n\trecord(\"DELETE\", path)\n\tr.Delete(path, alice.New(c...).ThenFunc(fn).(http.HandlerFunc))\n\tinfoMutex.Unlock()\n}", "func Delete(path string, fn http.HandlerFunc, c ...alice.Constructor) {\n\trecord(\"DELETE\", path)\n\n\tinfoMutex.Lock()\n\tr.DELETE(path, Handler(alice.New(c...).ThenFunc(fn)))\n\tinfoMutex.Unlock()\n}", "func (c Client) delete(path string, params url.Values, holder interface{}) error {\n\treturn c.request(\"DELETE\", path, params, &holder)\n}", "func (api *Api) Delete(path string, endpoint http.HandlerFunc, queries ...string) {\n\tapi.Router.HandleFunc(path, endpoint).Methods(\"DELETE\").Queries(queries...)\n}", "func (r *Router) DELETE(url string, viewFn View) *Path {\n\treturn r.Path(fasthttp.MethodDelete, url, viewFn)\n}", "func (g *Group) DELETE(path string, handler Handler, middleware ...Middleware) *Group {\n\treturn g.Add(http.MethodDelete, path, handler, middleware...)\n}", "func (r *Router) DELETE(path string, handler RequestHandler) {\n\tr.setPath(httpDELETE, path, handler)\n}", "func (r *Request) Delete(url string) *Request {\n\tr.method = http.MethodDelete\n\tr.url = url\n\treturn r\n}", "func (c *Client) Delete() *Request {\n\treturn NewRequest(c.httpClient, c.base, \"DELETE\", c.version, c.authstring, c.userAgent)\n}", "func (c *Client) Delete(ctx context.Context, url string, data ...interface{}) (*Response, error) {\n\treturn c.DoRequest(ctx, http.MethodDelete, url, data...)\n}", "func (self *Client) Delete(dst interface{}, path string, data url.Values) error {\n\tvar addr *url.URL\n\tvar err error\n\tvar body *strings.Reader\n\n\tif addr, err = url.Parse(self.Prefix + strings.TrimLeft(path, \"/\")); err != nil {\n\t\treturn err\n\t}\n\n\tif data != nil {\n\t\tbody = strings.NewReader(data.Encode())\n\t}\n\n\treturn self.newRequest(dst, \"DELETE\", addr, body)\n}", "func (c *baseClient) Delete(path string) *baseClient {\n\tc.method = \"DELETE\"\n\treturn c.Path(path)\n}", "func (a *APITest) Delete(url string) *Request {\n\ta.request.method = http.MethodDelete\n\ta.request.url = url\n\treturn a.request\n}", "func (a *ApiServer) Delete(path string, f func(w http.ResponseWriter, r *http.Request)) *ApiServer{\n\ta.Router.HandleFunc(path, f).Methods(\"DELETE\")\n\treturn a\n}", "func (APIResourceBase) Delete(session *Session, url string, queries url.Values, body io.Reader) (APIStatus, interface{}) {\n\treturn FailSimple(http.StatusMethodNotAllowed), nil\n}", "func Delete(url string, data ...interface{}) (*Response, error) {\n\tr := NewRequest()\n\treturn r.Delete(url, data...)\n}", "func (rb *RequestBuilder) Delete(url string) *Response {\n\treturn rb.DoRequest(http.MethodDelete, url, nil)\n}", "func Delete(path string, f func(http.ResponseWriter, *http.Request)) *Route {\n\treturn NewRoute().Path(path).Method(HttpDelete).HandlerFunc(f)\n}", "func (tr *Transport) DELETE(\n\turl string,\n\tfn Handler,\n\toptions ...HandlerOption,\n) {\n\ttr.mux.Handler(\n\t\tnet_http.MethodDelete,\n\t\turl,\n\t\tnewHandler(fn, append(tr.options, options...)...),\n\t)\n}", "func (cl *Client) Delete(c context.Context, url string, opts ...RequestOption) (*Response, error) {\n\treq, err := cl.NewRequest(c, http.MethodDelete, url, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn cl.Do(c, req)\n}", "func (s *Server) Delete(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\ts.Router.HandleFunc(path, f).Methods(\"DELETE\")\n}", "func (f *Fastglue) DELETE(path string, h FastRequestHandler) {\n\tf.Router.DELETE(path, f.handler(h))\n}", "func (r *Request) Delete(url string) (*Response, error) {\n\treturn r.Execute(MethodDelete, url)\n}", "func (rest *RESTService) ApiDELETE(w http.ResponseWriter, r *http.Request) {\n\n}", "func (router *Router) DELETE(relativePath string, handler Handler, decorators ...Decorator) {\n\trouter.createRouter(http.MethodDelete, relativePath, handler, \"\", decorators...)\n}", "func (c *TogglHttpClient) DeleteRequest(endpoint string, body interface{}) (*json.RawMessage, error) {\n\treturn request(c, \"DELETE\", endpoint, body)\n}", "func Delete(ctx context.Context, url string, body Body, options ...RequestOption) (*Response, error) {\n\tr, err := newRequest(ctx, http.MethodDelete, url, body, options...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tr.Header.Set(\"Content-Type\", body.ContentType())\n\treturn doRequest(http.DefaultClient, r)\n}", "func (r *bitroute) DELETE(path string, f func(router.Control)) {\n\tr.register(\"DELETE\", path, f)\n}", "func (e *Engine) DELETE(path string, handler Handler) {\n\te.registerRoute(http.MethodDelete, path, handler)\n}", "func (app *App) Delete(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\tapp.Router.HandleFunc(path, f).Methods(\"DELETE\")\n}", "func Delete(config *HTTPConfig) (*HTTPResult, error) {\n\treturn HandleRequest(\"DELETE\", config)\n}", "func (h *Handler) Delete(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\tpath = configuration.Instance.Service.Path + path\n\tlog.Println(\"Adding '\" + path + \"' as DELETE path\")\n\th.Router.HandleFunc(path, f).Methods(\"DELETE\")\n}", "func (a *App) Delete(path string, f func(w http.ResponseWriter, r *http.Request)) {\r\n\ta.Router.HandleFunc(path, f).Methods(\"DELETE\")\r\n}", "func Delete(h http.Handler) http.Handler {\n\treturn HTTP(h, DELETE)\n}", "func (a *App) Delete(path string, f func(w http.ResponseWriter, r *http.Request)) {\n\ta.Router.HandleFunc(path, f).Methods(\"DELETE\")\n}", "func (client *RestClient) Delete(path string) error {\n\tres, err := client.R().Delete(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif res.StatusCode() >= 400 {\n\t\treturn UnmarshalError(res)\n\t}\n\n\treturn nil\n}", "func (c *Client) Delete(endpoint string, resource ...RequestResource) error {\n\twrapper := newWrapper(\"delete\", endpoint, resource...)\n\treturn c.do(&wrapper)\n}", "func (s *DefaultClient) Del(endpoint string) (resp *http.Response, err error) {\n\t_, resp, err = s.http(http.MethodDelete, endpoint, nil)\n\treturn\n}", "func (engine *Engine) DELETE(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn engine.handle(http.MethodDelete, relativePath, handlers)\n}", "func (r *RouterGroup) DELETE(path string, fn Controller) {\n\tr.gin.DELETE(path, adapt(fn))\n}", "func (r *ExternalRequest) Delete(ctx context.Context) error {\n\treturn r.JSONRequest(ctx, \"DELETE\", \"\", nil, nil)\n}", "func (s *Server) DELETE(path string, handle http.HandlerFunc) {\n\ts.router.DELETE(path, s.wrapHandler(handle))\n}", "func (c *Client) Delete(path string) error {\n\treturn c.CreateAndDo(\"DELETE\", path, nil, nil, nil, nil)\n}", "func (c *Client) Delete(url string, headers map[string][]string) (client.Status, map[string][]string, io.ReadCloser, error) {\n\treturn c.Do(\"DELETE\", url, headers, nil)\n}", "func (r *Router) DELETE(path string, handle HandlerFunc, middleware ...MiddlewareFunc) {\n\tr.Handle(\"DELETE\", path, handle, middleware...)\n}", "func (req *Request) Delete(url string) (*Response, error) {\n\tresponse, err := req.Request.Delete(url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn NewResponse(response), nil\n}", "func Delete(url string, opts ...RequestOption) (*Response, error) {\n\treturn DefaultSession.Delete(url, opts...)\n}", "func (s *Server) Delete(path string) error {\n\turl, err := s.urlFor(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tclient := &http.Client{}\n\treq, err := http.NewRequest(\"DELETE\", url, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif resp.StatusCode != 204 {\n\t\treturn fmt.Errorf(\"got %d status code\", resp.StatusCode)\n\t}\n\n\treturn nil\n}", "func (r *Router) DELETE(path string, h HandlerFunc) {\n\tr.router.DELETE(path, r.handle(h, r.getValidationForPath(path, \"DELETE\")))\n}", "func (s *Nap) Delete(pathURL string) *Nap {\n\ts.method = MethodDelete\n\treturn s.Path(pathURL)\n}", "func (node *Node) DELETE(functions ...interface{}) *Handler {\n\n\thandler := &Handler{}\n\n\tif len(functions) > 0 { handler.function = functions[0].(func (req web.RequestInterface) *web.ResponseStatus) }\n\n\tnode.addHandler(\"DELETE\", handler)\n\n\treturn handler\n}", "func DeleteMethod(e *echo.Group, fn deleteFn) {\n\te.DELETE(\"/:id\", func(c echo.Context) error {\n\t\tvar id int\n\n\t\tif err := Param(\"id\").InPath().Int(c, &id); err != nil {\n\t\t\treturn BadRequest(err)\n\t\t}\n\t\tif err := fn(id); err != nil {\n\t\t\tswitch err {\n\t\t\tcase util.ErrNotFound:\n\t\t\t\treturn NotFound(err)\n\t\t\tdefault:\n\t\t\t\treturn InternalServerError(err)\n\t\t\t}\n\t\t}\n\t\treturn c.NoContent(http.StatusNoContent)\n\t})\n}", "func (v *DCHttpClient) Delete(\n\turl string, headers map[string]string) (response *DCHttpResponse, err error) {\n\treturn v.DoWithoutContent(http.MethodDelete, url, headers)\n}", "func (g *RouterGroup) DELETE(url string, handler ...Handler) *RouterGroup {\n\tg.app.routeANY = false\n\tg.AppendReqAndResp(url, \"delete\", handler)\n\treturn g\n}", "func Delete(url string) (*http.Response, error) {\n\treq, err := http.NewRequest(\"DELETE\", url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn http.DefaultClient.Do(req)\n}", "func Delete(path string, fn httprouter.Handle) {\n\tr.Router.DELETE(path, fn)\n}", "func (c *Client) Delete(path string) error {\n\treturn c.Send(\"DELETE\", path, nil, nil)\n}", "func (tr *Transport) Delete(url string, fn HandlerFunc, options ...HandlerOption) {\n\ttr.mux.Handler(net_http.MethodDelete, url, encapsulate(fn, tr.options, options))\n}", "func Delete(path string, handler http.Handler) Route {\n\treturn NewRoute(\"DELETE\", path, handler)\n}", "func (app *App) DELETE(url string, handler ...Handler) *App {\n\tapp.routeANY = false\n\tapp.AppendReqAndResp(url, \"delete\", handler)\n\treturn app\n}", "func (F *Frisby) Delete(url string) *Frisby {\n\tF.Method = \"DELETE\"\n\tF.Url = url\n\treturn F\n}", "func Delete(route string, do interface{}) *handler {\n\treturn handlerByMethod(&route, do, \"DELETE\")\n}", "func Delete(dest interface{}, uri string, data url.Values) error {\n\treturn DefaultClient.Delete(dest, uri, data)\n}", "func (conn Connection) Delete(cmd string, content, result interface{}) (effect *SideEffect, resp *http.Response, err error) {\n\treturn conn.Send(http.MethodDelete, cmd, content, result)\n}", "func Delete() {\n\treqUrl := \"https://jsonplaceholder.typicode.com/posts/1\"\n\n\tclient := http.Client{}\n\n\treq, err := http.NewRequest(http.MethodDelete, reqUrl, bytes.NewBuffer(make([]byte, 0)))\n\n\tcheckError(err)\n\n\tresp, respErr := client.Do(req)\n\n\tcheckError(respErr)\n\n\tfmt.Println(resp.StatusCode)\n}", "func DeleteRequest(client HTTPClient, paths []string) ([]lib.DeleteResult, []*lib.SearchResult) {\n\n\tif lib.IsVerbose {\n\t\tlib.PrettyList(\"DeleteRequest issued\", paths)\n\t}\n\n\titems := []*lib.SearchResult{}\n\tfor _, p := range paths {\n\t\tif it, err := GetPath(client, p); it != nil {\n\t\t\titems = append(items, it)\n\t\t\tif it.IsDir {\n\t\t\t\titems = append(items, FlattenChildren(it.Children)...)\n\t\t\t}\n\t\t} else if err != nil {\n\t\t\tlib.PrResultf(err.Error())\n\t\t}\n\t}\n\n\t// delete longest paths (deepest nested) items first\n\tsort.Slice(items, func(i, j int) bool {\n\t\treturn len(items[i].Path) > len(items[j].Path)\n\t})\n\t// files have to be deleted first\n\tsort.Slice(items, func(i, j int) bool {\n\t\treturn !items[i].IsDir && len(items[i].Path) < len(items[j].Path)\n\t})\n\n\tif lib.IsVerbose && len(items) > 0 {\n\t\tlib.PrNoticef(\"\\nMarked for removal\\n\")\n\t\tfor _, x := range items {\n\t\t\tlib.PrNoticef(\" - %s\\n\", x.Path)\n\t\t}\n\t\tfmt.Println()\n\t}\n\n\treqs, _ := soapDelete(items, chunkSize)\n\tvar res []lib.DeleteResult\n\tfor _, b := range reqs {\n\t\tr := doRequest(client, b, deleteList)\n\t\tparsed, err := parseSoapDelete(r)\n\t\tif err != nil {\n\t\t\tlib.PrFatalf(\"Error \\\"%s\\\" - %s\", deleteList, err.Error())\n\t\t}\n\t\tres = append(res, parsed...)\n\t}\n\n\treturn res, items\n}", "func (r *Router) DELETE(path string, handle Handle) {\n\tr.Handle(\"DELETE\", path, handle)\n}", "func (serv *Server) DELETE(url string, handlers ...Handler) {\n\tserv.Handle(\"DELETE\", url, handlers...)\n}", "func (r *Router) DELETE(path string, handle Handle) {\n\tr.Handle(http.MethodDelete, path, handle)\n}", "func (group *RouterGroup) DELETE(relativePath string, handlers ...HandlerFunc) IRoutes {\n\treturn group.handle(http.MethodDelete, relativePath, handlers)\n}", "func (rg *RouteGroup) DELETE(path string, handlers ...Handler) *Route {\n\treturn rg.add(\"DELETE\", path, handlers)\n}", "func (avisess *AviSession) Delete(uri string, params ...interface{}) error {\n\tvar payload, response interface{}\n\tif len(params) > 0 {\n\t\tpayload = params[0]\n\t\tif len(params) == 2 {\n\t\t\tresponse = params[1]\n\t\t}\n\t}\n\treturn avisess.restRequestInterfaceResponse(\"DELETE\", uri, payload, response)\n}", "func (f *FortiWebClient) DoDelete(path string) (*http.Response, error) {\n\n\tclient := &http.Client{}\n\n\treq, error := http.NewRequest(\"DELETE\",\n\t\tstrings.Join([]string{f.URL, path}, \"\"),\n\t\tstrings.NewReader(\"\"))\n\n\tif error != nil {\n\t\tfmt.Printf(\"The HTTP request failed with error %s\\n\", error)\n\t\treturn &http.Response{}, error\n\t}\n\treq.Header.Add(\"Authorization\", encodeBase64(f.Username, f.Password))\n\treturn client.Do(req)\n\n}", "func (conn Connection) Delete(cmd string, content, result interface{}) (resp *http.Response, err error) {\n\treturn conn.Send(http.MethodDelete, cmd, content, result)\n}", "func (g *Group) DELETE(path string, h Handler, gases ...Gas) {\n\tg.Air.DELETE(g.Prefix+path, h, append(g.Gases, gases...)...)\n}", "func (m *Middleware) DELETE(path string, handler Handler) {\n\tm.engine.DELETE(path, m.apply(handler))\n}", "func (this *Route) DELETE(handlers ...HTTPHandler) *Route {\n\treturn this.addHandler(\"delete\", handlers...)\n}", "func Delete(w http.ResponseWriter, r *http.Request){\n\n\t//pegando a url atraves da requisiçãp (.Get = pegar )\n\tidDoProduto := r.URL.Query().Get(\"id\") // pegando o id da url\n\n\tmodels.DeletaProduto(idDoProduto)\n\thttp.Redirect(w, r, \"/\", 301)\n}", "func (c *Client) Delete(d Document, extraArgs url.Values) (*Response, error) {\n\tr := Request{\n\t\tIndexList: []string{d.Index.(string)},\n\t\tTypeList: []string{d.Type},\n\t\tExtraArgs: extraArgs,\n\t\tMethod: \"DELETE\",\n\t\tID: d.ID.(string),\n\t}\n\n\treturn c.Do(&r)\n}", "func (req *Request) Delete() *ResultSet {\n\treturn req.do(http.MethodDelete)\n}", "func (c *Client) Delete(ctx context.Context, link string) error {\n\n\tauthKey, err := GetAccessTokenFromContext(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Missing token in context\")\n\t}\n\n\treq, err := http.NewRequest(\"DELETE\", link, nil)\n\n\tif err != nil {\n\t\tlog.Error(\"Cannot create request:\", err)\n\t\treturn err\n\t}\n\n\treq.Header.Add(\"X-Requested-With\", \"XMLHttpRequest\")\n\treq.Header.Add(\"authorization\", authKey)\n\treq.Header.Add(\"Accept\", \"application/json\")\n\tresp, err := c.httpClient.Do(req)\n\n\tif err != nil {\n\t\tlog.Error(\"POST request error:\", err)\n\t\treturn err\n\t}\n\t// this is required to properly empty the buffer for the next call\n\tdefer func() {\n\t\tio.Copy(ioutil.Discard, resp.Body)\n\t}()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tbody, err := ioutil.ReadAll(resp.Body)\n\t\tlog.Error(err, \": \", string(body))\n\t}\n\n\treturn err\n}", "func Delete(c messagebird.Client, id string) error {\n\treturn c.Request(nil, http.MethodDelete, path+\"/\"+id, nil)\n}", "func (c *Client) delete(rawURL string, authenticate bool, out interface{}) error {\n\terr := c.do(rawURL, \"DELETE\", authenticate, http.StatusOK, nil, out)\n\treturn errio.Error(err)\n}", "func Delete(uri string) error {\n\treq, err := http.NewRequest(\"DELETE\", Host+uri, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tres, err := Client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer res.Body.Close()\n\n\tif res.StatusCode != 204 {\n\t\treturn fmt.Errorf(\"got %d\", res.StatusCode)\n\t}\n\n\treturn nil\n}", "func (r *Mux) DELETE(path string, handler http.HandlerFunc) {\n\tr.HandleFunc(\"DELETE\", path, handler)\n}", "func Delete(url string) *THttpClient {\r\n\treturn NewHttpClient(url).Delete(\"\")\r\n}", "func DeleteRequest(w http.ResponseWriter, r *http.Request, p httprouter.Params) {\n\t a:= p.ByName(\"id\")\n\t ac,_ := strconv.Atoi(a)\n\t sess:=getSession();\n er := sess.DB(\"trip-planner\").C(\"locations\").Remove(bson.M{\"id\": ac})\n if er!=nil {\n \tpanic(er)\n }\n\tw.WriteHeader(200)\n}", "func (group *RouterGroup) DELETE(path string, handlers ...HandlerFunc) {\n\tgroup.Handle(\"DELETE\", path, handlers)\n}", "func deleteurl(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tparams := mux.Vars(r)\n\tinputOrderID := params[\"Id\"]\n\tvar url Myurl\n\tdb.Where(\"id = ? \", inputOrderID).Delete(&url)\n}", "func (a *Router) Delete(pattern string, hs ...func(*Context) error) *Router {\n\treturn a.Handle(http.MethodDelete, pattern, hs...)\n}", "func (b *Builder) Delete(url string) *Builder {\n\tb.Url = url\n\tb.Method = http.MethodDelete\n\treturn b\n}", "func (s *Service) DeleteRequest(identifiable DocIdentifiable) error {\n\t// TODO: accept ctx as param\n\treturn s.Delete(s.RequestsIndex, identifiable.DocID(), \"_doc\")\n}", "func (c HTTPClient) Delete(ids []string) error {\n\treturn nil\n}", "func Delete(url string, token string, client http.Client) (err error) {\n\treq, err := http.NewRequest(\"DELETE\", url, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treq.Header.Set(\"X-Auth-Token\", token)\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Expecting a successful delete\n\tif !(resp.StatusCode == 200 || resp.StatusCode == 202 || resp.StatusCode == 204) {\n\t\terr = fmt.Errorf(\"Unexpected server response status code on Delete '%s'\", resp.StatusCode)\n\t\treturn\n\t}\n\n\treturn nil\n}" ]
[ "0.80825806", "0.7741624", "0.7716973", "0.7485182", "0.7433246", "0.7414137", "0.73540527", "0.7320704", "0.7304203", "0.73019534", "0.72963434", "0.72934276", "0.7224465", "0.7186547", "0.714229", "0.71418566", "0.71270925", "0.71143883", "0.70936733", "0.7086868", "0.7071063", "0.7060108", "0.7027315", "0.69851565", "0.69616425", "0.6954369", "0.69483083", "0.6933997", "0.68739957", "0.68737864", "0.68659383", "0.6850121", "0.68398714", "0.6832747", "0.6831153", "0.6800856", "0.6793943", "0.6757773", "0.67573786", "0.67556155", "0.6727009", "0.67103297", "0.67025477", "0.6698605", "0.66715807", "0.6667399", "0.6658044", "0.66574633", "0.66495496", "0.66491216", "0.6644867", "0.6625097", "0.6624929", "0.661749", "0.6602546", "0.65906596", "0.6576986", "0.6564784", "0.65634686", "0.6553689", "0.65292054", "0.6527458", "0.6512667", "0.6505968", "0.6503139", "0.6498481", "0.6497543", "0.64932096", "0.6486415", "0.64801055", "0.6455186", "0.64481187", "0.6446819", "0.644607", "0.64351493", "0.642947", "0.6429444", "0.6428134", "0.64244795", "0.6421482", "0.6407305", "0.63989913", "0.6398394", "0.6366041", "0.63638324", "0.63635015", "0.6359844", "0.6358912", "0.63577706", "0.6336196", "0.63345915", "0.63290554", "0.63263243", "0.63038814", "0.6297294", "0.62844217", "0.62620705", "0.62591636", "0.6257922", "0.62563986" ]
0.86834985
0
GetDialect gets the name of the dialect that defines the Message
GetDialect получает имя диалекта, который определяет сообщение
func (m *Heartbeat) GetDialect() string { return "common" }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func GetDialect() SQLDialect { return def.GetDialect() }", "func (m *ComponentInformation) GetDialect() string {\n\treturn \"common\"\n}", "func (m *DigicamControl) GetDialect() string {\n\treturn \"ardupilotmega\"\n}", "func DbDialect() string {\n\treturn Db().Dialect().GetName()\n}", "func (m *AdapTuning) GetDialect() string {\n\treturn \"ardupilotmega\"\n}", "func (d Driver) Dialect() string {\n\t// If the underlying driver is wrapped with a telemetry driver.\n\tfor _, name := range []string{dialect.MySQL, dialect.SQLite, dialect.Postgres} {\n\t\tif strings.HasPrefix(d.dialect, name) {\n\t\t\treturn name\n\t\t}\n\t}\n\treturn d.dialect\n}", "func (in *Instance) GetDialect() SQLDialect {\n\treturn in.dialect\n}", "func GetDialect() Dialect {\n\treturn GetDialectByDriver(config.GetDatabases().GetDefault().Driver)\n}", "func (tx *txDriver) Dialect() string { return tx.drv.Dialect() }", "func (tx *txDriver) Dialect() string { return tx.drv.Dialect() }", "func (spec specification) DatabaseDialect() string {\n\treturn spec.DatabaseType\n}", "func (db *Database) GetDatabaseDialect() string {\n\treturn \"dynamodb\"\n}", "func (storage *Storage) Dialect() string {\n\treturn storage.exec.Dialect()\n}", "func (c PostgresConfig) Dialect() string {\n\treturn \"postgres\"\n}", "func DialectFor(name string) Dialect {\n\treturn dialect.For(name)\n}", "func PickDialect(name string) Dialect {\n\tfor _, d := range AllDialects {\n\t\tif strings.EqualFold(name, d.String()) || strings.EqualFold(name, d.Alias()) {\n\t\t\treturn d\n\t\t}\n\t}\n\treturn nil\n}", "func PickDialect(name string) Dialect {\n\tfor _, d := range AllDialects {\n\t\tif strings.EqualFold(name, d.Name()) || strings.EqualFold(name, d.Alias()) {\n\t\t\treturn d\n\t\t}\n\t}\n\treturn nil\n}", "func SetDialect(d string) error { return def.SetDialect(d) }", "func (database *Database) Dialect() schema.Dialect {\n\treturn database.dialect\n}", "func GetDialectByDriver(driver string) Dialect {\n\tswitch driver {\n\tcase \"mysql\":\n\t\treturn mysql{\n\t\t\tcommonDialect: commonDialect{delimiter: \"`\", delimiter2: \"`\"},\n\t\t}\n\tcase \"mssql\":\n\t\treturn mssql{\n\t\t\tcommonDialect: commonDialect{delimiter: \"[\", delimiter2: \"]\"},\n\t\t}\n\tcase \"postgresql\":\n\t\treturn postgresql{\n\t\t\tcommonDialect: commonDialect{delimiter: `\"`, delimiter2: `\"`},\n\t\t}\n\tcase \"sqlite\":\n\t\treturn sqlite{\n\t\t\tcommonDialect: commonDialect{delimiter: \"`\", delimiter2: \"`\"},\n\t\t}\n\tdefault:\n\t\treturn commonDialect{delimiter: \"`\", delimiter2: \"`\"}\n\t}\n}", "func (o BackupOutput) DatabaseDialect() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.DatabaseDialect }).(pulumi.StringOutput)\n}", "func (td *TruncateDataset) Dialect() SQLDialect {\n\treturn td.dialect\n}", "func (in *Instance) SetDialect(d string) error {\n\tswitch d {\n\tcase \"postgres\":\n\t\tin.dialect = &PostgresDialect{tableName: in.TableName}\n\tcase \"mysql\":\n\t\tin.dialect = &MySQLDialect{tableName: in.TableName}\n\tcase \"sqlite3\":\n\t\tin.dialect = &Sqlite3Dialect{tableName: in.TableName}\n\tcase \"mssql\":\n\t\tin.dialect = &SqlServerDialect{tableName: in.TableName}\n\tcase \"redshift\":\n\t\tin.dialect = &RedshiftDialect{tableName: in.TableName}\n\tcase \"tidb\":\n\t\tin.dialect = &TiDBDialect{tableName: in.TableName}\n\tdefault:\n\t\treturn fmt.Errorf(\"%q: unknown dialect\", d)\n\t}\n\n\treturn nil\n}", "func Dialect(dialect string) Option {\n\treturn func(o *Options) error {\n\t\to.Dialect = dialect\n\t\treturn nil\n\t}\n}", "func (sd *SelectDataset) Dialect() SQLDialect {\n\treturn sd.dialect\n}", "func Dialect(dialect string) Option {\n\treturn func(o *options) {\n\t\to.dialect = dialect\n\t}\n}", "func (tbl RecordTable) Dialect() driver.Dialect {\n\treturn tbl.di\n}", "func (s *Serializer) SetDialect(d Dialect) {\n\ts.d = d\n}", "func (spec specification) DatabaseDialectURL() string {\n\treturn fmt.Sprintf(\"%s://%s\", spec.DatabaseType, spec.DatabaseURL)\n}", "func (tbl AssociationTable) Dialect() dialect.Dialect {\n\treturn tbl.database.Dialect()\n}", "func DumpDialect(dialect string) func(*Dumper) error {\n\treturn func(d *Dumper) error {\n\t\th, err := helperForDialect(dialect)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\td.helper = h\n\t\treturn nil\n\t}\n}", "func dialectMsgDefToGo(in string) string {\n\tre := regexp.MustCompile(\"_[a-z]\")\n\tin = strings.ToLower(in)\n\tin = re.ReplaceAllStringFunc(in, func(match string) string {\n\t\treturn strings.ToUpper(match[1:2])\n\t})\n\treturn strings.ToUpper(in[:1]) + in[1:]\n}", "func (tbl DbCompoundTable) Dialect() schema.Dialect {\n\treturn tbl.database.Dialect()\n}", "func ForDriver(driver string) reform.Dialect {\n\t// for sqlite3_with_sleep\n\tif strings.HasPrefix(driver, \"sqlite3\") {\n\t\treturn sqlite3.Dialect\n\t}\n\n\tswitch driver {\n\tcase \"postgres\", \"pgx\":\n\t\treturn postgresql.Dialect\n\tcase \"mysql\":\n\t\treturn mysql.Dialect\n\tcase \"mssql\":\n\t\treturn mssql.Dialect //nolint:staticcheck\n\tcase \"sqlserver\":\n\t\treturn sqlserver.Dialect\n\tdefault:\n\t\treturn nil\n\t}\n}", "func NewDialectWriter(w io.Writer, opts Dialect) Writer {\n\topts.setDefaults()\n\treturn Writer{\n\t\topts: opts,\n\t\tw: bufio.NewWriter(w),\n\t}\n}", "func (c *ProcessorConfig) Dbname() string {\n\treturn c.PersisterPostgresDbname\n}", "func (d Dialect) GetMessage(frame mavlink2.Frame) (message mavlink2.Message, err error) {\n\tif parser, ok := ASLUAVParsers[frame.GetMessageID()]; ok {\n\t\tmessage, err = parser(frame)\n\t\treturn\n\t}\n\n\terr = mavlink2.ErrUnknownMessage\n\treturn\n}", "func InterpolateForDialect(query string, value []interface{}, d Dialect) (string, error) {\n\tbuf := new(bytes.Buffer)\n\terr := interpolate(query, value, d, buf)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn buf.String(), nil\n}", "func (td *TruncateDataset) SetDialect(dialect SQLDialect) *TruncateDataset {\n\tcd := td.copy(td.GetClauses())\n\tcd.dialect = dialect\n\treturn cd\n}", "func (sd *SelectDataset) SetDialect(dialect SQLDialect) *SelectDataset {\n\tcd := sd.copy(sd.GetClauses())\n\tcd.dialect = dialect\n\treturn cd\n}", "func (d Dialect) GetName() string {\n\treturn \"asluav\"\n}", "func (f *DialectMessageField) GetName() string {\n\treturn f.name\n}", "func NewMySQLDialect() *MySQLDialect {\n\treturn &MySQLDialect{}\n}", "func (p *Provider) GetDataFormat() (string, error) {\n\tf, err := p.GetDBHandle(internalDBName).Get(formatVersionKey)\n\treturn string(f), err\n}", "func (s *service) DbName(ctx *shared.Context, kind contract.ResourceKind) (string, error) {\n\tdbResource := s.dbResource(kind)\n\tdialect := dsc.GetDatastoreDialect(dbResource.DB.Config().DriverName)\n\treturn dialect.GetCurrentDatastore(dbResource.DB)\n}", "func NewWriter(w io.Writer) Writer {\n\treturn NewDialectWriter(w, Dialect{})\n}", "func (p *PushEventRepository) GetLanguage() string {\n\tif p == nil || p.Language == nil {\n\t\treturn \"\"\n\t}\n\treturn *p.Language\n}", "func getSchemaProvider(conf *Config, logger *log.Logger) (db.SchemaProvider, error) {\n\tdb, err := ConnectDatabase(conf)\n\tif err != nil {\n\t\tlogger.Println(err)\n\t\treturn nil, err\n\t}\n\n\tswitch conf.Dialect {\n\tcase \"mysql\":\n\t\treturn mysql.New(logger, db), nil\n\tdefault:\n\t\treturn nil, errors.New(fmt.Sprintf(\"database not found:%#v\", conf.Dialect))\n\t}\n}", "func (d Dialect) GetMeta(messageID uint32) (meta mavlink2.MessageMeta, err error) {\n\tvar ok bool\n\n\tif meta, ok = asluavMessages[messageID]; !ok {\n\t\terr = mavlink2.ErrUnknownMessage\n\t}\n\n\treturn\n}", "func (s *Scanner) GetSQLMode() mysql.SQLMode {\n\treturn s.sqlMode\n}", "func (td *TruncateDataset) WithDialect(dl string) *TruncateDataset {\n\tds := td.copy(td.GetClauses())\n\tds.dialect = GetDialect(dl)\n\treturn ds\n}", "func (factory) Name() string {\n\treturn tanLogDBName\n}", "func init() {\n\tRegisterDialect(\"snowflake\", &snowflake{})\n}", "func (g *GistFile) GetLanguage() string {\n\tif g == nil || g.Language == nil {\n\t\treturn \"\"\n\t}\n\treturn *g.Language\n}", "func GetUDPNetwork() string {\n\tif *enableTCP6 {\n\t\t// Enable both udp4 and udp6\n\t\treturn \"udp\"\n\t}\n\treturn \"udp4\"\n}", "func (mariadbFlavor) gtidMode(c *Conn) (string, error) {\n\treturn \"\", nil\n}", "func (m *ChatMessage) GetLocale()(*string) {\n return m.locale\n}", "func (d mySQLDialect) PlaceholderFormat() PlaceholderFormat { return Question }", "func (da *DefaultAdvisor) GetSQLID(sqlText string) string {\n\treturn da.parser.GetSQLID(sqlText)\n}", "func GetMLogLevel(module string) string {\n\tmloggers.RLock()\n\tdefer mloggers.RUnlock()\n\twl, ok := mloggers.loggers[module]\n\tif !ok {\n\t\treturn \"\"\n\t}\n\tswitch wl.option.Level {\n\tcase CRITICAL:\n\t\treturn \"critical\"\n\tcase ERROR:\n\t\treturn \"error\"\n\tcase WARNING:\n\t\treturn \"warning\"\n\tcase NOTICE:\n\t\treturn \"notice\"\n\tcase INFO:\n\t\treturn \"info\"\n\tcase DEBUG:\n\t\treturn \"debug\"\n\tdefault:\n\t\treturn \"\"\n\t}\n}", "func getTransport(transport string) TransportType {\n\tswitch TransportType(transport) {\n\tcase TransportHTTP, TransportHTTPS, TransportKafka, TransportJMS, TransportIronMQ, TransportAMQP,\n\t\tTransportQueue, TransportOther:\n\t\treturn TransportType(transport)\n\tdefault:\n\t\treturn TransportUnknown\n\t}\n}", "func (d sqlDatastoreDialect) GetCurrentDatastore(manager Manager) (string, error) {\n\tif d.schemaSQL == \"\" {\n\t\treturn \"\", nil\n\t}\n\tvar result = make([]interface{}, 0)\n\tsuccess, err := manager.ReadSingle(&result, d.schemaSQL, nil, nil)\n\tif err != nil || !success {\n\t\treturn \"\", err\n\t}\n\treturn normalizeName(toolbox.AsString(result[d.schemaResultsetIndex])), nil\n\n}", "func (x ApmApplicationEntity) GetLanguage() string {\n\treturn x.Language\n}", "func (native *OpenGL) GetShadingLanguageVersion() string {\n\treturn gl.GoStr(gl.GetString(gl.SHADING_LANGUAGE_VERSION))\n}", "func (fmd *FakeMysqlDaemon) GetGTIDMode(ctx context.Context) (gtidMode string, err error) {\n\treturn \"ON\", fmd.ExecuteSuperQueryList(ctx, []string{\n\t\t\"FAKE select @@global\",\n\t})\n}", "func GetSslmode(ctx *pulumi.Context) string {\n\tv, err := config.Try(ctx, \"postgresql:sslmode\")\n\tif err == nil {\n\t\treturn v\n\t}\n\tvar value string\n\tif d := internal.GetEnvOrDefault(nil, nil, \"PGSSLMODE\"); d != nil {\n\t\tvalue = d.(string)\n\t}\n\treturn value\n}", "func (c *ConfigurationData) GetPostgresSSLMode() string {\n\treturn c.v.GetString(varPostgresSSLMode)\n}", "func GetDatastore(conf map[string]string) (Datastore, error) {\n\tengine, ok := conf[\"DATASTORE\"]\n\tif !ok {\n\t\tlog.Fatal(\"Undefined SQL engine\")\n\t}\n\n\tengineFactory, ok := datastoreFactories[engine]\n\tif !ok {\n\t\tavailableDatastores := make([]string, len(datastoreFactories))\n\t\tfor k := range datastoreFactories {\n\t\t\tavailableDatastores = append(availableDatastores, k)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"Invalid Datastore name. Must be one of: %s\", strings.Join(availableDatastores, \", \"))\n\t}\n\n\treturn engineFactory(conf)\n}", "func (r *TopicRule) Sql() pulumi.StringOutput {\n\treturn (pulumi.StringOutput)(r.s.State[\"sql\"])\n}", "func (m *InvitedUserMessageInfo) GetMessageLanguage()(*string) {\n val, err := m.GetBackingStore().Get(\"messageLanguage\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func NewSQLDatastoreDialect(tablesSQL, sequenceSQL, schemaSQL, allSchemaSQL, keySQL, disableForeignKeyCheck, enableForeignKeyCheck, autoIncrementSQL, tableInfoSQL string, schmeaIndex int) *sqlDatastoreDialect {\n\treturn &sqlDatastoreDialect{tablesSQL, sequenceSQL, schemaSQL, allSchemaSQL, keySQL, disableForeignKeyCheck, enableForeignKeyCheck, autoIncrementSQL, tableInfoSQL, schmeaIndex}\n}", "func getGreeter(lang string) string {\n\tif lang == \"es\" {\n\t\treturn esGreeter\n\t}\n\tif lang == \"en\" {\n\t\treturn enGreeter\n\t}\n\treturn defaultGreeter\n}", "func GetLanguage() string {\n\treturn gotext.GetLanguage()\n}", "func getLanguage() string {\n\tvar language string\n\n\tlanguage = getLanguageViaEnv()\n\tif !isEmpty(language) {\n\t\treturn language\n\t}\n\n\tlanguage = getLanguageViaObjectiveC()\n\tif !isEmpty(language) {\n\t\treturn language\n\t}\n\n\tlanguage = getLanguageViaOsascript()\n\tif !isEmpty(language) {\n\t\treturn language\n\t}\n\n\treturn \"\"\n}", "func (x ApmApplicationEntityOutline) GetLanguage() string {\n\treturn x.Language\n}", "func (r *Repository) GetLanguage() string {\n\tif r == nil || r.Language == nil {\n\t\treturn \"\"\n\t}\n\treturn *r.Language\n}", "func GetPostgresSQLDBORM() (*gorm.DB, error) {\n\treturn sqlDbORM, sqlORMErr\n}", "func (mysqld *Mysqld) GetGTIDMode(ctx context.Context) (string, error) {\n\tconn, err := getPoolReconnect(ctx, mysqld.dbaPool)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer conn.Recycle()\n\n\treturn conn.GetGTIDMode()\n}", "func (mysqlFlavor) gtidMode(c *Conn) (string, error) {\n\tqr, err := c.ExecuteFetch(\"select @@global.gtid_mode\", 1, false)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif len(qr.Rows) != 1 || len(qr.Rows[0]) != 1 {\n\t\treturn \"\", vterrors.Errorf(vtrpc.Code_INTERNAL, \"unexpected result format for gtid_mode: %#v\", qr)\n\t}\n\treturn qr.Rows[0][0].ToString(), nil\n}", "func (s *MysqlSender) GetMessageRoomName() string {\n\treturn s.db.DefaultRoomName\n}", "func (ft *FieldType) GetCollate() string {\n\treturn ft.collate\n}", "func getSqlBuilderColumnType(columnMetaData metadata.Column) string {\n\tif columnMetaData.DataType.Kind != metadata.BaseType {\n\t\treturn \"String\"\n\t}\n\n\tswitch strings.ToLower(columnMetaData.DataType.Name) {\n\tcase \"boolean\":\n\t\treturn \"Bool\"\n\tcase \"smallint\", \"integer\", \"bigint\",\n\t\t\"tinyint\", \"mediumint\", \"int\", \"year\": //MySQL\n\t\treturn \"Integer\"\n\tcase \"date\":\n\t\treturn \"Date\"\n\tcase \"timestamp without time zone\",\n\t\t\"timestamp\", \"datetime\": //MySQL:\n\t\treturn \"Timestamp\"\n\tcase \"timestamp with time zone\":\n\t\treturn \"Timestampz\"\n\tcase \"time without time zone\",\n\t\t\"time\": //MySQL\n\t\treturn \"Time\"\n\tcase \"time with time zone\":\n\t\treturn \"Timez\"\n\tcase \"interval\":\n\t\treturn \"Interval\"\n\tcase \"user-defined\", \"enum\", \"text\", \"character\", \"character varying\", \"bytea\", \"uuid\",\n\t\t\"tsvector\", \"bit\", \"bit varying\", \"money\", \"json\", \"jsonb\", \"xml\", \"point\", \"line\", \"ARRAY\",\n\t\t\"char\", \"varchar\", \"nvarchar\", \"binary\", \"varbinary\",\n\t\t\"tinyblob\", \"blob\", \"mediumblob\", \"longblob\", \"tinytext\", \"mediumtext\", \"longtext\": // MySQL\n\t\treturn \"String\"\n\tcase \"real\", \"numeric\", \"decimal\", \"double precision\", \"float\",\n\t\t\"double\": // MySQL\n\t\treturn \"Float\"\n\tdefault:\n\t\tfmt.Println(\"- [SQL Builder] Unsupported sql column '\" + columnMetaData.Name + \" \" + columnMetaData.DataType.Name + \"', using StringColumn instead.\")\n\t\treturn \"String\"\n\t}\n}", "func getDatabaseStmt(dbName string) string {\n\treturn fmt.Sprintf(\"\"+\n\t\t\"--\\n\"+\n\t\t\"-- PostgreSQL database structure for %s\\n\"+\n\t\t\"--\\n\\n\",\n\t\tdbName)\n}", "func (t *websocketTransport) Name() string {\n\treturn transportWebsocket\n}", "func (sd *SelectDataset) WithDialect(dl string) *SelectDataset {\n\tds := sd.copy(sd.GetClauses())\n\tds.dialect = GetDialect(dl)\n\treturn ds\n}", "func (c *ConfigurationData) GetPostgresDatabase() string {\n\treturn c.v.GetString(varPostgresDatabase)\n}", "func (sql *SqlConnection) GetDB() *gorm.DB {\n\treturn sql.Db\n}", "func GetDatabaseConnection(env string) string {\n\tswitch env {\n\tcase \"development\":\n\t\treturn developmentDBConString\n\tcase \"test\":\n\t\treturn testDBString\n\tdefault:\n\t\treturn developmentDBConString\n\t}\n}", "func (c *connAttrs) Locale() string { c.mu.RLock(); defer c.mu.RUnlock(); return c._locale }", "func getEncryptionAlg(ciphersuite string) string {\n\tswitch ciphersuite {\n\tcase \"XSTREAM_X25519_HKDF_SHA256_AES128_SIV\":\n\t\treturn \"AES-SIV\"\n\tcase \"XSTREAM_X25519_HKDF_SHA256_AES128_PMAC_SIV\":\n\t\treturn \"AES-PMAC-SIV\"\n\tdefault:\n\t\tpanic(\"XSTREAM: unknown ciphersuite\")\n\t}\n}", "func (s *Sniffer) sniff() rune {\n\tds := dialects{}\n\tfor potential := range s.frequencyMap {\n\t\tp := dialect{\n\t\t\tdelimiter: potential,\n\t\t\tlikelihood: []float64{},\n\t\t}\n\t\tfor split, occurences := range s.frequencyMap[potential] {\n\t\t\tp.likelihood = append(p.likelihood, float64(split)/float64(occurences))\n\t\t}\n\t\tif len(p.likelihood) != 0 {\n\t\t\tsort.Float64s(p.likelihood)\n\t\t\tds = append(ds, p)\n\t\t}\n\t}\n\tsort.Sort(ds)\n\tif len(ds) == 0 {\n\t\treturn ','\n\t}\n\ts.delimiter = ds[0].delimiter\n\treturn s.delimiter\n}", "func GetSslMode(ctx *pulumi.Context) string {\n\treturn config.Get(ctx, \"postgresql:sslMode\")\n}", "func (g *GetLanguagePackStringRequest) GetLanguagePackID() (value string) {\n\tif g == nil {\n\t\treturn\n\t}\n\treturn g.LanguagePackID\n}", "func (builder *DsnBuilder) Build(dialect string) (string, error) {\n\n\t//Check if minimum configuration dsn is fulfilled\n\tif builder.Host == \"\" ||\n\t\tbuilder.Database == \"\" ||\n\t\tbuilder.Username == \"\" {\n\t\treturn \"\", errDBCredentialNotComplete\n\t}\n\n\tif dialect == dialectMysql {\n\t\treturn builder.mysql()\n\t}\n\n\tif dialect == dialectPostgres {\n\t\treturn builder.postgres()\n\t}\n\n\treturn \"\", errDialectNotFound\n}", "func (b *OGame) GetLanguage() string {\n\treturn b.language\n}", "func (native *OpenGL) GetVendorName() string {\n\treturn gl.GoStr(gl.GetString(gl.VENDOR))\n}", "func (c *Config) GetLogFormat() string {\n\treturn c.strings[logFormatVar]\n}", "func (d Document) Language() string { return d.language }", "func (o *Ga4ghExternalIdentifier) GetDatabase() string {\n\tif o == nil || o.Database == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Database\n}", "func init() {\n\taspect.RegisterDialect(\"postgres\", &PostGres{})\n}" ]
[ "0.7608149", "0.74324024", "0.740498", "0.7249795", "0.7157729", "0.68678474", "0.68317574", "0.66529614", "0.6647241", "0.6647241", "0.64546055", "0.64295083", "0.6380442", "0.6310046", "0.60854125", "0.6021765", "0.5968178", "0.59251004", "0.5889809", "0.5752133", "0.5731976", "0.5591744", "0.5538832", "0.5524229", "0.55226374", "0.5522166", "0.5433402", "0.53108436", "0.5274045", "0.5256751", "0.52005875", "0.52005726", "0.51473135", "0.5102981", "0.5061599", "0.48001698", "0.47264114", "0.46631083", "0.46337685", "0.45785227", "0.45074186", "0.44969156", "0.44951767", "0.44003114", "0.4388542", "0.4383574", "0.42590475", "0.42379272", "0.42348635", "0.4215264", "0.4171091", "0.4140905", "0.4087848", "0.40837526", "0.4065238", "0.40637866", "0.40578642", "0.40485215", "0.40470082", "0.4046347", "0.40416047", "0.40405807", "0.40382984", "0.40297735", "0.40278", "0.4011327", "0.3995982", "0.399014", "0.39839688", "0.39835554", "0.3978476", "0.3966788", "0.396398", "0.39621076", "0.39588654", "0.394435", "0.39419308", "0.39415714", "0.3939782", "0.39329574", "0.39267814", "0.3915313", "0.39079955", "0.3897559", "0.38961932", "0.38960654", "0.3892881", "0.38787568", "0.387418", "0.38713485", "0.38667816", "0.38662845", "0.3851794", "0.3851722", "0.38507453", "0.38468325", "0.3839326", "0.38363227", "0.38321948", "0.38276535" ]
0.7491343
1
HasExtensionFields returns true if the message definition contained extensions; false otherwise
HasExtensionFields возвращает true, если определение сообщения содержало расширения; false в противном случае
func (m *Heartbeat) HasExtensionFields() bool { return false }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *ComponentInformation) HasExtensionFields() bool {\n\treturn false\n}", "func (m *DigicamControl) HasExtensionFields() bool {\n\treturn false\n}", "func (m *AdapTuning) HasExtensionFields() bool {\n\treturn false\n}", "func HasAdaptationFieldExtension(pkt *packet.Packet) bool {\n\treturn pkt[5]&0x01 != 0\n}", "func (o *Post) HasExtensions() bool {\n\tif o != nil && o.Extensions != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (r *AttachmentPreview) HasExt() bool {\n\treturn r.hasExt\n}", "func (this *RTPPacket) HasExtension() bool {\n\treturn this.header.extension != 0\n}", "func (f *DialectMessageField) GetIsExtension() bool {\n\treturn f.isExtension\n}", "func (o *User) HasExtensions() bool {\n\tif o != nil && o.Extensions != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (message *Message) HasAttachments() bool {\n\treturn message.GetInteger(3591) & 0x10 != 0\n}", "func (d *Device) HasExtension(extension string) bool {\n\tfor _, v := range d.Extensions {\n\t\tif v == extension {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (o *IntrospectedOAuth2Token) HasExt() bool {\n\tif o != nil && o.Ext != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (me TxsdCounterSimpleContentExtensionType) IsMessage() bool { return me.String() == \"message\" }", "func (me TxsdType) IsExtended() bool { return me.String() == \"extended\" }", "func FieldHasPBEX(field *protogen.Field) bool {\n\tfop := field.Desc.Options().(*descriptorpb.FieldOptions)\n\tif field.Desc.IsList() || field.Desc.IsMap() {\n\t\tif proto.HasExtension(fop, E_MapRepeatedLenEq) ||\n\t\t\tproto.HasExtension(fop, E_MapRepeatedLenNotEq) ||\n\t\t\tproto.HasExtension(fop, E_MapRepeatedLenGt) ||\n\t\t\tproto.HasExtension(fop, E_MapRepeatedLenGte) ||\n\t\t\tproto.HasExtension(fop, E_MapRepeatedLenLt) ||\n\t\t\tproto.HasExtension(fop, E_MapRepeatedLenLte) {\n\t\t\treturn true\n\t\t}\n\t}\n\tswitch field.Desc.Kind() {\n\tcase protoreflect.BoolKind:\n\t\t//bool\n\t\tif proto.HasExtension(fop, E_BoolEq) {\n\t\t\treturn true\n\t\t}\n\tcase protoreflect.Int32Kind:\n\t\tfallthrough\n\tcase protoreflect.Sint32Kind:\n\t\tfallthrough\n\tcase protoreflect.Sfixed32Kind:\n\t\tfallthrough\n\t\t//int32 or []int32\n\tcase protoreflect.Int64Kind:\n\t\tfallthrough\n\tcase protoreflect.Sint64Kind:\n\t\tfallthrough\n\tcase protoreflect.Sfixed64Kind:\n\t\t//int64 or []int64\n\t\tif proto.HasExtension(fop, E_IntIn) ||\n\t\t\tproto.HasExtension(fop, E_IntNotIn) ||\n\t\t\tproto.HasExtension(fop, E_IntGt) ||\n\t\t\tproto.HasExtension(fop, E_IntGte) ||\n\t\t\tproto.HasExtension(fop, E_IntLt) ||\n\t\t\tproto.HasExtension(fop, E_IntLte) {\n\t\t\treturn true\n\t\t}\n\tcase protoreflect.Uint32Kind:\n\t\tfallthrough\n\tcase protoreflect.Fixed32Kind:\n\t\tfallthrough\n\t\t//uint32 or []uint32\n\tcase protoreflect.Uint64Kind:\n\t\tfallthrough\n\tcase protoreflect.Fixed64Kind:\n\t\t//uint64 or []uint64\n\t\tif proto.HasExtension(fop, E_UintIn) ||\n\t\t\tproto.HasExtension(fop, E_UintNotIn) ||\n\t\t\tproto.HasExtension(fop, E_UintGt) ||\n\t\t\tproto.HasExtension(fop, E_UintGte) ||\n\t\t\tproto.HasExtension(fop, E_UintLt) ||\n\t\t\tproto.HasExtension(fop, E_UintLte) {\n\t\t\treturn true\n\t\t}\n\tcase protoreflect.FloatKind:\n\t\t//float32 or []float32\n\t\tfallthrough\n\tcase protoreflect.DoubleKind:\n\t\t//float64 or []float64\n\t\tif proto.HasExtension(fop, E_FloatIn) ||\n\t\t\tproto.HasExtension(fop, E_FloatNotIn) ||\n\t\t\tproto.HasExtension(fop, E_FloatGt) ||\n\t\t\tproto.HasExtension(fop, E_FloatGte) ||\n\t\t\tproto.HasExtension(fop, E_FloatLt) ||\n\t\t\tproto.HasExtension(fop, E_FloatLte) {\n\t\t\treturn true\n\t\t}\n\tcase protoreflect.EnumKind:\n\t\t//enum or []enum\n\t\tif proto.HasExtension(fop, E_EnumIn) ||\n\t\t\tproto.HasExtension(fop, E_EnumNotIn) ||\n\t\t\tproto.HasExtension(fop, E_EnumGt) ||\n\t\t\tproto.HasExtension(fop, E_EnumGte) ||\n\t\t\tproto.HasExtension(fop, E_EnumLt) ||\n\t\t\tproto.HasExtension(fop, E_EnumLte) {\n\t\t\treturn true\n\t\t}\n\tcase protoreflect.BytesKind:\n\t\t//[]bytes or [][]bytes\n\t\tfallthrough\n\tcase protoreflect.StringKind:\n\t\t//string or []string\n\t\tif proto.HasExtension(fop, E_StringBytesIn) ||\n\t\t\tproto.HasExtension(fop, E_StringBytesNotIn) ||\n\t\t\tproto.HasExtension(fop, E_StringBytesRegMatch) ||\n\t\t\tproto.HasExtension(fop, E_StringBytesRegNotMatch) ||\n\t\t\tproto.HasExtension(fop, E_StringBytesLenEq) ||\n\t\t\tproto.HasExtension(fop, E_StringBytesLenNotEq) ||\n\t\t\tproto.HasExtension(fop, E_StringBytesLenGt) ||\n\t\t\tproto.HasExtension(fop, E_StringBytesLenGte) ||\n\t\t\tproto.HasExtension(fop, E_StringBytesLenLt) ||\n\t\t\tproto.HasExtension(fop, E_StringBytesLenLte) {\n\t\t\treturn true\n\t\t}\n\tcase protoreflect.MessageKind:\n\t\tif !field.Desc.IsMap() {\n\t\t\t//message or []message\n\t\t\tif proto.HasExtension(fop, E_MessageNotNil) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tkey := field.Message.Fields[0]\n\t\tvalue := field.Message.Fields[1]\n\t\tswitch key.Desc.Kind() {\n\t\tcase protoreflect.Int32Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Sint32Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Sfixed32Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Int64Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Sint64Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Sfixed64Kind:\n\t\t\tif proto.HasExtension(fop, E_MapKeyIntIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyIntNotIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyIntGt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyIntGte) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyIntLt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyIntLte) {\n\t\t\t\treturn true\n\t\t\t}\n\t\tcase protoreflect.Uint32Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Fixed32Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Uint64Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Fixed64Kind:\n\t\t\tif proto.HasExtension(fop, E_MapKeyUintIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyUintNotIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyUintGt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyUintGte) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyUintLt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyUintLte) {\n\t\t\t\treturn true\n\t\t\t}\n\t\tcase protoreflect.StringKind:\n\t\t\tif proto.HasExtension(fop, E_MapKeyStringIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyStringNotIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyStringRegMatch) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyStringRegNotMatch) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyStringLenEq) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyStringLenNotEq) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyStringLenGt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyStringLenGte) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyStringLenLt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapKeyStringLenLte) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\tswitch value.Desc.Kind() {\n\t\tcase protoreflect.EnumKind:\n\t\t\tif proto.HasExtension(fop, E_MapValueEnumIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueEnumNotIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueEnumGt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueEnumGte) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueEnumLt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueEnumLte) {\n\t\t\t\treturn true\n\t\t\t}\n\t\tcase protoreflect.BoolKind:\n\t\t\tif proto.HasExtension(fop, E_MapValueBoolEq) {\n\t\t\t\treturn true\n\t\t\t}\n\t\tcase protoreflect.Int32Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Sint32Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Sfixed32Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Int64Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Sint64Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Sfixed64Kind:\n\t\t\tif proto.HasExtension(fop, E_MapValueIntIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueIntNotIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueIntGt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueIntGte) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueIntLt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueIntLte) {\n\t\t\t\treturn true\n\t\t\t}\n\t\tcase protoreflect.Uint32Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Fixed32Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Uint64Kind:\n\t\t\tfallthrough\n\t\tcase protoreflect.Fixed64Kind:\n\t\t\tif proto.HasExtension(fop, E_MapValueUintIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueUintNotIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueUintGt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueUintGte) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueUintLt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueUintLte) {\n\t\t\t\treturn true\n\t\t\t}\n\t\tcase protoreflect.FloatKind:\n\t\t\tfallthrough\n\t\tcase protoreflect.DoubleKind:\n\t\t\tif proto.HasExtension(fop, E_MapValueFloatIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueFloatNotIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueFloatGt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueFloatGte) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueFloatLt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueFloatLte) {\n\t\t\t\treturn true\n\t\t\t}\n\t\tcase protoreflect.BytesKind:\n\t\t\tfallthrough\n\t\tcase protoreflect.StringKind:\n\t\t\tif proto.HasExtension(fop, E_MapValueStringBytesIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueStringBytesNotIn) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueStringBytesRegMatch) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueStringBytesRegNotMatch) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueStringBytesLenEq) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueStringBytesLenNotEq) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueStringBytesLenGt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueStringBytesLenGte) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueStringBytesLenLt) ||\n\t\t\t\tproto.HasExtension(fop, E_MapValueStringBytesLenLte) {\n\t\t\t\treturn true\n\t\t\t}\n\t\tcase protoreflect.MessageKind:\n\t\t\tif proto.HasExtension(fop, E_MapValueMessageNotNil) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}", "func (me TxsdType) IsExtended() bool { return me == \"extended\" }", "func (me TxsdCounterSimpleContentExtensionType) IsExtValue() bool { return me.String() == \"ext-value\" }", "func (o *InlineResponse20027Person) HasPhoneNumberOfficeExt() bool {\n\tif o != nil && o.PhoneNumberOfficeExt != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (me TxsdImpactSimpleContentExtensionType) IsExtValue() bool { return me.String() == \"ext-value\" }", "func (o *StoragePhysicalDisk) HasPhysicalDiskExtensions() bool {\n\tif o != nil && o.PhysicalDiskExtensions != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (x *fastReflection_MsgUpdateParamsResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgUpdateParamsResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgUpdateParamsResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func hasFileFields(i interface{}, tagname string) bool {\n\tfound := false\n\n\trefl.WalkTaggedFields(reflect.ValueOf(i), func(v reflect.Value, sf reflect.StructField, tag string) {\n\t\tif sf.Type == multipartFileType || sf.Type == multipartFileHeaderType ||\n\t\t\tsf.Type == multipartFilesType || sf.Type == multipartFileHeadersType {\n\t\t\tfound = true\n\n\t\t\treturn\n\t\t}\n\t}, tagname)\n\n\treturn found\n}", "func (x *fastReflection_SendEnabled) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.SendEnabled.denom\":\n\t\treturn x.Denom != \"\"\n\tcase \"cosmos.bank.v1beta1.SendEnabled.enabled\":\n\t\treturn x.Enabled != false\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.SendEnabled\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.SendEnabled does not contain field %s\", fd.FullName()))\n\t}\n}", "func (me TxsdContactType) IsExtValue() bool { return me.String() == \"ext-value\" }", "func (o *NotificationAllOf) HasFields() bool {\n\tif o != nil && o.Fields != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (o *StoragePhysicalDiskAllOf) HasPhysicalDiskExtensions() bool {\n\tif o != nil && o.PhysicalDiskExtensions != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (x *fastReflection_EvidenceList) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"tendermint.types.EvidenceList.evidence\":\n\t\treturn len(x.Evidence) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: tendermint.types.EvidenceList\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message tendermint.types.EvidenceList does not contain field %s\", fd.FullName()))\n\t}\n}", "func (o *User) HasOnPremisesExtensionAttributes() bool {\n\tif o != nil && o.OnPremisesExtensionAttributes != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (o *InlineObject1187) HasFields() bool {\n\tif o != nil && o.Fields != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (o *Post) HasMultiValueExtendedProperties() bool {\n\tif o != nil && o.MultiValueExtendedProperties != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (x *fastReflection_MsgUpdateParams) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.MsgUpdateParams.authority\":\n\t\treturn x.Authority != \"\"\n\tcase \"cosmos.distribution.v1beta1.MsgUpdateParams.params\":\n\t\treturn x.Params != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgUpdateParams\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgUpdateParams does not contain field %s\", fd.FullName()))\n\t}\n}", "func HasTemplateExt(paths string) bool {\n\tfor _, v := range beeTemplateExt {\n\t\tif strings.HasSuffix(paths, \".\"+v) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (o *MailFolder) HasMultiValueExtendedProperties() bool {\n\tif o != nil && o.MultiValueExtendedProperties != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (x *fastReflection_Metadata) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.Metadata.description\":\n\t\treturn x.Description != \"\"\n\tcase \"cosmos.bank.v1beta1.Metadata.denom_units\":\n\t\treturn len(x.DenomUnits) != 0\n\tcase \"cosmos.bank.v1beta1.Metadata.base\":\n\t\treturn x.Base != \"\"\n\tcase \"cosmos.bank.v1beta1.Metadata.display\":\n\t\treturn x.Display != \"\"\n\tcase \"cosmos.bank.v1beta1.Metadata.name\":\n\t\treturn x.Name != \"\"\n\tcase \"cosmos.bank.v1beta1.Metadata.symbol\":\n\t\treturn x.Symbol != \"\"\n\tcase \"cosmos.bank.v1beta1.Metadata.uri\":\n\t\treturn x.Uri != \"\"\n\tcase \"cosmos.bank.v1beta1.Metadata.uri_hash\":\n\t\treturn x.UriHash != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.Metadata\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.Metadata does not contain field %s\", fd.FullName()))\n\t}\n}", "func (o *VulnerabilitiesRequest) HasExtended() bool {\n\tif o != nil && o.Extended != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (o *Object) IsExtensible() Boolean {\n\treturn Boolean(o.extensible)\n}", "func (me TdtypeType) IsExtValue() bool { return me.String() == \"ext-value\" }", "func HasTemplateExt(paths string) bool {\n\tfor _, v := range templateExt {\n\t\tif strings.HasSuffix(paths, \".\"+v) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (x *fastReflection_Bech32PrefixRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.Bech32PrefixRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.Bech32PrefixRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_QueryModuleAccountsRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryModuleAccountsRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryModuleAccountsRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_ModuleOptions) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.autocli.v1.ModuleOptions.tx\":\n\t\treturn x.Tx != nil\n\tcase \"cosmos.autocli.v1.ModuleOptions.query\":\n\t\treturn x.Query != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.autocli.v1.ModuleOptions\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.autocli.v1.ModuleOptions does not contain field %s\", fd.FullName()))\n\t}\n}", "func (f *File) NeedsOneOfSupport() bool {\n\tfor _, m := range f.Messages {\n\t\tif m.HasOneOfFields() {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func (me TxsdRecordPatternSimpleContentExtensionType) IsExtValue() bool {\n\treturn me.String() == \"ext-value\"\n}", "func (x *fastReflection_QueryParamsRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryParamsRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryParamsRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.Params.send_enabled\":\n\t\treturn len(x.SendEnabled) != 0\n\tcase \"cosmos.bank.v1beta1.Params.default_send_enabled\":\n\t\treturn x.DefaultSendEnabled != false\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.Params\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.Params does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_ValidatorSlashEventRecord) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.ValidatorSlashEventRecord.validator_address\":\n\t\treturn x.ValidatorAddress != \"\"\n\tcase \"cosmos.distribution.v1beta1.ValidatorSlashEventRecord.height\":\n\t\treturn x.Height != uint64(0)\n\tcase \"cosmos.distribution.v1beta1.ValidatorSlashEventRecord.period\":\n\t\treturn x.Period != uint64(0)\n\tcase \"cosmos.distribution.v1beta1.ValidatorSlashEventRecord.validator_slash_event\":\n\t\treturn x.ValidatorSlashEvent != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.ValidatorSlashEventRecord\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.ValidatorSlashEventRecord does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_Bech32PrefixResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.Bech32PrefixResponse.bech32_prefix\":\n\t\treturn x.Bech32Prefix != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.Bech32PrefixResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.Bech32PrefixResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (f Flags) ExtFrame() bool {\n\treturn f&ExtFrame != 0\n}", "func (ve ValidationErrors) Extensions() map[string]interface{} {\n\tm := map[string]interface{}{\n\t\t\"message\": ve.Message,\n\t\t\"valid\": ve.Valid,\n\t\t\"fields\": ve.Errors,\n\t}\n\treturn m\n}", "func HasAddedFields(field string, fields ...string) Condition {\n\treturn func(_ context.Context, m ent.Mutation) bool {\n\t\tif _, exists := m.AddedField(field); !exists {\n\t\t\treturn false\n\t\t}\n\t\tfor _, field := range fields {\n\t\t\tif _, exists := m.AddedField(field); !exists {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t}\n}", "func (x *fastReflection_EventReceive) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"regen.ecocredit.v1alpha1.EventReceive.sender\":\n\t\treturn x.Sender != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventReceive.recipient\":\n\t\treturn x.Recipient != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventReceive.batch_denom\":\n\t\treturn x.BatchDenom != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventReceive.tradable_amount\":\n\t\treturn x.TradableAmount != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventReceive.retired_amount\":\n\t\treturn x.RetiredAmount != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventReceive.basket_denom\":\n\t\treturn x.BasketDenom != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: regen.ecocredit.v1alpha1.EventReceive\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message regen.ecocredit.v1alpha1.EventReceive does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_Supply) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.Supply.total\":\n\t\treturn len(x.Total) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.Supply\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.Supply does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_AddressBytesToStringRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.AddressBytesToStringRequest.address_bytes\":\n\t\treturn len(x.AddressBytes) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.AddressBytesToStringRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.AddressBytesToStringRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_MsgCommunityPoolSpendResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgCommunityPoolSpendResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgCommunityPoolSpendResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (delivery_instructions DeliveryInstructions) HasExtendedOptions() (bool, error) {\n\tif len(delivery_instructions) >= 1 {\n\t\t/*\n\t\t\t Check if the 2 bit of the Delivery Instructions\n\t\t\t is set using binary AND operator to determine\n\t\t\t if the Delivery Instructions has a extended options\n\n\t\t\t xxxxx1xx\t xxxxx0xx\n\t\t\t &00000100\t &00000100\n\t\t\t ---------\t ---------\n\t\t\t 00000100\t 00000000\n\n\t\t\t bit is set,\t\tbit is not set,\n\t\t\t extended options extended options\n\t\t\t included\t\tnot included\n\n\t\t\tExtended options is unimplemented in the Java router, a warning\n\t\t\tis logged as this is interesting behavior.\n\t\t*/\n\t\textended_options := (delivery_instructions[0] & 0x04) == 0x04\n\t\tif extended_options {\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"at\": \"(DeliveryInstructions) ExtendedOptions\",\n\t\t\t\t\"info\": \"this feature is unimplemented in the Java router\",\n\t\t\t}).Warn(\"DeliveryInstructions found with extended_options bit set\")\n\t\t}\n\t\treturn extended_options, nil\n\t}\n\treturn false, errors.New(\"DeliveryInstructions contains no data\")\n}", "func (x *fastReflection_EventCreateBatch) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"regen.ecocredit.v1alpha1.EventCreateBatch.class_id\":\n\t\treturn x.ClassId != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventCreateBatch.batch_denom\":\n\t\treturn x.BatchDenom != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventCreateBatch.issuer\":\n\t\treturn x.Issuer != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventCreateBatch.total_amount\":\n\t\treturn x.TotalAmount != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventCreateBatch.start_date\":\n\t\treturn x.StartDate != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventCreateBatch.end_date\":\n\t\treturn x.EndDate != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventCreateBatch.project_location\":\n\t\treturn x.ProjectLocation != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: regen.ecocredit.v1alpha1.EventCreateBatch\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message regen.ecocredit.v1alpha1.EventCreateBatch does not contain field %s\", fd.FullName()))\n\t}\n}", "func (me TxsdRecordPatternSimpleContentExtensionOffsetunit) IsExtValue() bool {\n\treturn me.String() == \"ext-value\"\n}", "func (x *fastReflection_EventCreateClass) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"regen.ecocredit.v1alpha1.EventCreateClass.class_id\":\n\t\treturn x.ClassId != \"\"\n\tcase \"regen.ecocredit.v1alpha1.EventCreateClass.admin\":\n\t\treturn x.Admin != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: regen.ecocredit.v1alpha1.EventCreateClass\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message regen.ecocredit.v1alpha1.EventCreateClass does not contain field %s\", fd.FullName()))\n\t}\n}", "func (o *MicrosoftGraphListItem) HasFields() bool {\n\tif o != nil && o.Fields != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (x *fastReflection_Output) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.Output.address\":\n\t\treturn x.Address != \"\"\n\tcase \"cosmos.bank.v1beta1.Output.coins\":\n\t\treturn len(x.Coins) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.Output\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.Output does not contain field %s\", fd.FullName()))\n\t}\n}", "func (me TxsdImpactSimpleContentExtensionType) IsExtortion() bool { return me.String() == \"extortion\" }", "func (x *fastReflection_Input) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.Input.address\":\n\t\treturn x.Address != \"\"\n\tcase \"cosmos.bank.v1beta1.Input.coins\":\n\t\treturn len(x.Coins) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.Input\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.Input does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_AddressStringToBytesResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.AddressStringToBytesResponse.address_bytes\":\n\t\treturn len(x.AddressBytes) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.AddressStringToBytesResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.AddressStringToBytesResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_MsgFundCommunityPoolResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgFundCommunityPoolResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgFundCommunityPoolResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (me TxsdRegistryHandleSimpleContentExtensionRegistry) IsExtValue() bool {\n\treturn me.String() == \"ext-value\"\n}", "func (me TdurationType) IsExtValue() bool { return me.String() == \"ext-value\" }", "func (ps *PlatformStrings) HasExt(ext string) bool {\n\treturn ps.firstExtFile(ext) != \"\"\n}", "func (data EditMessageData) NeedsMultipart() bool {\n\treturn len(data.Files) > 0\n}", "func (x *fastReflection_MsgWithdrawValidatorCommissionResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.MsgWithdrawValidatorCommissionResponse.amount\":\n\t\treturn len(x.Amount) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgWithdrawValidatorCommissionResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgWithdrawValidatorCommissionResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (o *Post) GetExtensionsOk() ([]MicrosoftGraphExtension, bool) {\n\tif o == nil || o.Extensions == nil {\n\t\tvar ret []MicrosoftGraphExtension\n\t\treturn ret, false\n\t}\n\treturn *o.Extensions, true\n}", "func MessageHasPBEX(message *protogen.Message) bool {\n\tchecked := make(map[string]*struct{})\n\treturn messagecheck(message, checked)\n}", "func (d UserData) HasEmailFormatted() bool {\n\treturn d.ModelData.Has(models.NewFieldName(\"EmailFormatted\", \"email_formatted\"))\n}", "func (me TxsdRecordPatternSimpleContentExtensionType) IsBinary() bool { return me.String() == \"binary\" }", "func (e *ExtensionField) Len() uint8 {\n\treturn uint8(len(e.Value))\n}", "func hasAnnotatedFields(t reflect.Type) bool {\n\tif t == nil {\n\t\treturn false\n\t}\n\n\tresult := false\n\n\tif t.Kind() == reflect.Ptr {\n\t\tt = t.Elem()\n\t}\n\n\tif t.Kind() != reflect.Struct {\n\t\treturn false\n\t}\n\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tfield := t.Field(i)\n\t\t_, hasCfgTag := getConfigTagDefinition(field)\n\t\tif hasCfgTag {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn result\n}", "func (o *MicrosoftGraphMailSearchFolder) HasMultiValueExtendedProperties() bool {\n\tif o != nil && o.MultiValueExtendedProperties != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (me TactionType) IsExtValue() bool { return me.String() == \"ext-value\" }", "func (x *fastReflection_QueryModuleAccountsResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryModuleAccountsResponse.accounts\":\n\t\treturn len(x.Accounts) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryModuleAccountsResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryModuleAccountsResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (p *CertProfile) IsAllowedExtention(oid csr.OID) bool {\n\tfor _, allowed := range p.AllowedExtensions {\n\t\tif allowed.Equal(oid) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (x *fastReflection_QueryParamsResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryParamsResponse.params\":\n\t\treturn x.Params != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryParamsResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryParamsResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (me TxsdTimeImpactSimpleContentExtensionMetric) IsExtValue() bool {\n\treturn me.String() == \"ext-value\"\n}", "func (x *fastReflection_QueryAccountsRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryAccountsRequest.pagination\":\n\t\treturn x.Pagination != nil\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryAccountsRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryAccountsRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_MsgCommunityPoolSpend) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.MsgCommunityPoolSpend.authority\":\n\t\treturn x.Authority != \"\"\n\tcase \"cosmos.distribution.v1beta1.MsgCommunityPoolSpend.recipient\":\n\t\treturn x.Recipient != \"\"\n\tcase \"cosmos.distribution.v1beta1.MsgCommunityPoolSpend.amount\":\n\t\treturn len(x.Amount) != 0\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgCommunityPoolSpend\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgCommunityPoolSpend does not contain field %s\", fd.FullName()))\n\t}\n}", "func (s Strategy) HasArrayField(t Entity) bool {\n\t//Fields []map[string]interface{}\n\n\tfor _, f := range t.Fields {\n\t\tif f[\"type\"] == \"Array\" {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (x *fastReflection_MsgWithdrawValidatorCommission) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission.validator_address\":\n\t\treturn x.ValidatorAddress != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission does not contain field %s\", fd.FullName()))\n\t}\n}", "func HasExtension(baseFileName string, extensions []string) bool {\n\n\tvar lowerExtension = filepath.Ext(baseFileName)\n\tfor _, extension := range extensions {\n\t\tif lowerExtension == strings.ToLower(extension) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func (me TxsdContactRole) IsExtValue() bool { return me.String() == \"ext-value\" }", "func (x *fastReflection_MsgFundCommunityPool) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.MsgFundCommunityPool.amount\":\n\t\treturn len(x.Amount) != 0\n\tcase \"cosmos.distribution.v1beta1.MsgFundCommunityPool.depositor\":\n\t\treturn x.Depositor != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgFundCommunityPool\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgFundCommunityPool does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_MsgSetWithdrawAddressResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgSetWithdrawAddressResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgSetWithdrawAddressResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_AddressStringToBytesRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.AddressStringToBytesRequest.address_string\":\n\t\treturn x.AddressString != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.AddressStringToBytesRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.AddressStringToBytesRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func protoKnownFieldsEqual(a, b proto.Message) bool {\n\treturn cmp.Equal(a, b, cmp.FilterPath(func(path cmp.Path) bool {\n\t\tif field, ok := path.Last().(cmp.StructField); ok {\n\t\t\treturn strings.HasPrefix(field.Name(), \"XXX_\")\n\t\t}\n\t\treturn false\n\t}, cmp.Ignore()))\n}", "func (f ExtensionField) IsSet() bool {\n\treturn f.typ != nil\n}", "func HasExt(fname, suffix string) bool {\n\treturn strings.HasSuffix(fname, \".\"+suffix) && (!strings.HasPrefix(fname, \".\") || strings.HasPrefix(fname, \"_\"))\n}", "func (s *Struct) HasRequiredFields() bool {\n\thasRequired := false\n\tfor _, fld := range s.Fields {\n\t\tif fld.Required() {\n\t\t\thasRequired = true\n\t\t}\n\t}\n\treturn hasRequired\n}", "func (x *fastReflection_QueryAccountRequest) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.QueryAccountRequest.address\":\n\t\treturn x.Address != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.QueryAccountRequest\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.QueryAccountRequest does not contain field %s\", fd.FullName()))\n\t}\n}", "func (o *InlineResponse20049Post) HasAttachmentsCount() bool {\n\tif o != nil && o.AttachmentsCount != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (f Unstructured) Has(v ...interface{}) bool {\n\thf, err := ParseUnstructured(v)\n\tif f.fields == nil {\n\t\treturn true\n\t}\n\tif err != nil {\n\t\treturn false\n\t}\n\tif hf.IsUndefined() {\n\t\treturn false\n\t}\n\tmissing := hf.FindField(func(fieldName string, fieldFragment Fragment) bool {\n\t\tif fieldFragment.IsUndefined() {\n\t\t\treturn !f.HasByName(fieldName)\n\t\t} else if !f.HasByName(fieldName) {\n\t\t\treturn true\n\t\t} else {\n\t\t\tcurrentFieldFragment := f.Field(fieldName)\n\t\t\tif currentFieldFragment == nil || currentFieldFragment.IsUndefined() {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn currentFieldFragment.Has(fieldFragment)\n\t\t}\n\t})\n\treturn missing == nil\n}", "func (o *InlineResponse200115) HasAttachmentsCount() bool {\n\tif o != nil && o.AttachmentsCount != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (x *fastReflection_AddressBytesToStringResponse) Has(fd protoreflect.FieldDescriptor) bool {\n\tswitch fd.FullName() {\n\tcase \"cosmos.auth.v1beta1.AddressBytesToStringResponse.address_string\":\n\t\treturn x.AddressString != \"\"\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.auth.v1beta1.AddressBytesToStringResponse\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.auth.v1beta1.AddressBytesToStringResponse does not contain field %s\", fd.FullName()))\n\t}\n}", "func (me TxsdIncidentPurpose) IsExtValue() bool { return me.String() == \"ext-value\" }" ]
[ "0.79747695", "0.7872464", "0.7571828", "0.70303", "0.6822041", "0.68168104", "0.6751157", "0.64307547", "0.6375237", "0.6172389", "0.612653", "0.5998885", "0.59975886", "0.59836483", "0.5968552", "0.5941892", "0.5920344", "0.5860863", "0.58554816", "0.58536065", "0.58418304", "0.5830382", "0.58228135", "0.5819621", "0.581702", "0.5773735", "0.57215524", "0.57182425", "0.5706566", "0.56965226", "0.5692613", "0.5692104", "0.5688242", "0.56801295", "0.5667234", "0.5662533", "0.5654253", "0.5648198", "0.5644192", "0.5638931", "0.56357586", "0.563104", "0.5619391", "0.5582203", "0.55632937", "0.55543476", "0.55408955", "0.55401057", "0.5539347", "0.55293447", "0.5515688", "0.54931533", "0.54930586", "0.548648", "0.5485151", "0.5484205", "0.5468848", "0.54644746", "0.5461033", "0.54400396", "0.5436135", "0.54250485", "0.54243475", "0.54230714", "0.54171944", "0.54128605", "0.5408543", "0.53981215", "0.53941077", "0.53896964", "0.5382091", "0.53816026", "0.5380112", "0.53669953", "0.5359285", "0.53549534", "0.5345112", "0.5339682", "0.533577", "0.53215015", "0.5319065", "0.5316847", "0.53118604", "0.5311724", "0.52987957", "0.5296461", "0.52925724", "0.5284583", "0.5271535", "0.52668494", "0.52583975", "0.52575475", "0.5252952", "0.5230242", "0.52243054", "0.5221319", "0.5219799", "0.5215897", "0.5214044", "0.52030206" ]
0.8061141
0
Version return the version string of Go runtime. This works well even though the runtime is devel version.
Версия возвращает строку версии среды выполнения Go. Это работает даже в том случае, если среда выполнения является разработочной версией.
func Version() string { b, err := exec.Command("go", "version").CombinedOutput() if err != nil { panic(err.Error()) } token := strings.Split(string(b), " ") if strings.HasPrefix(token[2], "go") { return token[2] } if !strings.HasPrefix(token[2], "devel") { panic("Can not detect go version") } d := strings.Join(token[4:len(token)-1], " ") t0, err := time.Parse(`Mon Jan _2 15:04:05 2006 -0700`, d) if err != nil { panic("Can not detect go version") } for i, v := range vers { t1, err := time.Parse(`2006-01-2 15:04:05 -0700`, v[0]) if err != nil { continue } if t1.After(t0) { return vers[i-1][1] } } return vers[len(vers)-1][1] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Version() string {\n\treturn runtime.Version()\n}", "func Version() (os string, rt string) {\n\tos = runtime.GOOS\n\tvar flavor string\n\tif ver, err := syscall.GetVersion(); err == nil {\n\t\tvar major, minor, build = byte(ver), uint8(ver >> 8), uint16(ver >> 16)\n\t\tswitch {\n\t\tcase major == 4:\n\t\t\tswitch minor {\n\t\t\tcase 0:\n\t\t\t\tflavor = \"NT\"\n\t\t\tcase 10:\n\t\t\t\tflavor = \"98\"\n\t\t\tcase 90:\n\t\t\t\tflavor = \"Me\"\n\t\t\t}\n\t\tcase major == 5:\n\t\t\tswitch {\n\t\t\tcase minor == 2:\n\t\t\t\tflavor = \"2003\"\n\t\t\tcase minor == 1 && build == 2600:\n\t\t\t\tflavor = \"XP\"\n\t\t\tcase minor == 0:\n\t\t\t\tflavor = \"2000\"\n\t\t\t}\n\t\tcase major == 6:\n\t\t\tswitch minor {\n\t\t\tcase 3:\n\t\t\t\tflavor = \"8.1\"\n\t\t\tcase 2:\n\t\t\t\tflavor = \"8\"\n\t\t\tcase 1:\n\t\t\t\tflavor = \"7\"\n\t\t\tcase 0:\n\t\t\t\tflavor = \"Vista\"\n\t\t\t}\n\t\t}\n\t\tos = fmt.Sprintf(\"%s %s: [Version %d.%d.%d]\",\n\t\t\tstrings.Title(runtime.GOOS), flavor,\n\t\t\tmajor, minor, build)\n\t}\n\trt = fmt.Sprintf(\"%s %s/%s\", runtime.Version(), runtime.GOOS, runtime.GOARCH)\n\treturn os, BOTVERSION + \" (\" + rt + \")\"\n}", "func (svc *Compiler) Version() string {\n\tval, err := svc.ctx.RunScript(\"svelte.VERSION\", \"version_call\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val.String()\n}", "func Version() string {\n\tapi := C.Create()\n\tdefer C.Free(api)\n\tversion := C.Version(api)\n\treturn C.GoString(version)\n}", "func String() string {\n\treturn Version\n}", "func Version() (string, error) {\n\t// Version detection on Wasm varies depending on the underlying runtime\n\t// (browser, node, etc), nor is there a standard via something like\n\t// WASI (see https://go.dev/issue/31105). For now, attempt a few simple\n\t// combinations for the convenience of reading logs at build.golang.org\n\t// and local development. It's not a goal to recognize all environments.\n\tif v, ok := node(); ok {\n\t\treturn \"Node.js \" + v, nil\n\t}\n\treturn \"\", fmt.Errorf(\"unrecognized environment\")\n}", "func Version() (version string) {\n\treturn GetVersion()\n}", "func GetVersion() string {\n\tif Version == \"\" {\n\t\ttm, err := strconv.ParseInt(compiled, 10, 64)\n\t\tif err != nil {\n\t\t\treturn \"unable to parse compiled time\"\n\t\t}\n\t\tVersion = fmt.Sprintf(\"%s (git+sha: %s, built: %s)\", release, gitsha, time.Unix(tm, 0).Format(\"02-01-2006\"))\n\t}\n\n\treturn Version\n}", "func Version() string {\n\tif len(version) == 0 {\n\t\treturn \"UNKNOWN_VERSION\"\n\t}\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn version\n}", "func Version() string {\n\treturn libs.Version()\n}", "func Version() string {\r\n\tonce.Do(func() {\r\n\t\tsemver := fmt.Sprintf(\"%d.%d.%d\", major, minor, patch)\r\n\t\tverBuilder := bytes.NewBufferString(semver)\r\n\t\tif tag != \"\" && tag != \"-\" {\r\n\t\t\tupdated := strings.TrimPrefix(tag, \"-\")\r\n\t\t\t_, err := verBuilder.WriteString(\"-\" + updated)\r\n\t\t\tif err == nil {\r\n\t\t\t\tverBuilder = bytes.NewBufferString(semver)\r\n\t\t\t}\r\n\t\t}\r\n\t\tversion = verBuilder.String()\r\n\t})\r\n\treturn version\r\n}", "func GetVersion() string {\n\tvar versionString bytes.Buffer\n\tfmt.Fprintf(&versionString, \"v%s\", versn)\n\tif env != \"\" {\n\t\tfmt.Fprintf(&versionString, \"-%s\", env)\n\t}\n\n\treturn versionString.String()\n}", "func Version() string {\n\treturn buildVersion\n}", "func (g *goVersion) String() string {\n\treturn g.golangVersion()\n}", "func GetVersion() string {\n\treturn __VERSION__\n}", "func GetVersion() string {\n\treturn VersionString\n}", "func GetVersion() string {\n\tif len(Version) == 0 {\n\t\treturn \"dev\"\n\t}\n\treturn Version\n}", "func GetVersion() string {\n\tif len(Version) == 0 {\n\t\treturn \"dev\"\n\t}\n\treturn Version\n}", "func Version() string {\n\tif buildDate == \"{DATE}\" {\n\t\tnow := time.Now().Format(time.RFC3339)\n\t\tbuildDate = now\n\t}\n\treturn fmt.Sprintf(\"%s. Built at: %s\", BuildData(), buildDate)\n}", "func Version() string {\n\treturn versionNumber\n}", "func Version() string {\n\treturn fmt.Sprintf(\"%s %s %s\", AppVendor, AppName, AppVersion)\n}", "func (ver Version) String() string {\n\tif ver.RawVersion != \"\" {\n\t\treturn ver.RawVersion\n\t}\n\tv := fmt.Sprintf(\"v%d.%d.%d\", ver.Major, ver.Minor, ver.Patch)\n\tif ver.PreRelease != \"\" {\n\t\tv += \"-\" + ver.PreRelease\n\t}\n\tif ver.GitHash != \"\" {\n\t\tv += \"(\" + ver.GitHash + \")\"\n\t}\n\t// TODO: Add metadata about the commit or build hash.\n\t// See https://golang.org/issue/29814\n\t// See https://golang.org/issue/33533\n\tvar metadata = strings.Join(ver.MetaData, \".\")\n\tif strings.Contains(ver.PreRelease, \"devel\") && metadata != \"\" {\n\t\tv += \"+\" + metadata\n\t}\n\treturn v\n}", "func (k *Keybase) version() string {\n\tcmdOut, err := k.Exec(\"version\", \"-S\", \"-f\", \"s\")\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\n\treturn string(cmdOut)\n}", "func versionString() string {\n\tvar version string\n\tif SHA != \"\" {\n\t\tversion = fmt.Sprintf(\"%s (%s)\", Version, SHA)\n\t} else {\n\t\tversion = fmt.Sprintf(\"%s-dev\", Version) // no SHA. '0.x.y-dev' indicates it is run from source without build script.\n\t}\n\tif BuildTime != \"\" {\n\t\ti, err := strconv.ParseInt(BuildTime, 10, 64)\n\t\tif err == nil {\n\t\t\ttm := time.Unix(i, 0)\n\t\t\tversion += fmt.Sprintf(\" built %s\", tm.Format(time.RFC822))\n\t\t}\n\t}\n\treturn fmt.Sprintf(\"dnscontrol %s\", version)\n}", "func GetVersion() string {\n\tversion := fmt.Sprintf(`Version : %s\nTag : %s\nBuildTime : %s\nGitHash : %s\nRunMode : %s\nDistribution: %s\nServiceName : %s\n`, CCVersion, CCTag, CCBuildTime, CCGitHash, CCRunMode, CCDistro, ServiceName)\n\treturn version\n}", "func GetVersion() string {\n\treturn version.GetVersion()\n}", "func Version() string {\n\tversion := C.GoString(C.lxc_get_version())\n\n\t// New liblxc versions append \"-devel\" when LXC_DEVEL is set.\n\tif strings.HasSuffix(version, \"-devel\") {\n\t\treturn fmt.Sprintf(\"%s (devel)\", version[:(len(version)-len(\"-devel\"))])\n\t}\n\n\treturn version\n}", "func GetVersion() string {\n\tversion, ok := os.LookupEnv(\"VERSION\")\n\tif !ok {\n\t\tversion = \"default\"\n\t}\n\treturn version\n}", "func GoVersion() string {\n\treturn goVersion\n}", "func (client *Client) Version() string {\n\tversion := C.Version(client.api)\n\treturn C.GoString(version)\n}", "func GetGoVersion() string {\n\tvar (\n\t\tcmdOut []byte\n\t\terr error\n\t)\n\n\tif cmdOut, err = exec.Command(\"go\", \"version\").Output(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn strings.Split(string(cmdOut), \" \")[2]\n}", "func (obj *script) Version() string {\n\treturn obj.version\n}", "func (r *Rkt) Version() (string, error) {\n\tver, err := r.Runner.CombinedOutput(\"rkt version\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// rkt Version: 1.24.0\n\t// appc Version: 0.8.10\n\tline := strings.Split(ver, \"\\n\")[0]\n\treturn strings.Replace(line, \"rkt Version: \", \"\", 1), nil\n}", "func (b *BaseCmd) GoVersion() (string, error) {\n\tgoVersionCommand := util.Command{\n\t\tName: \"go\",\n\t\tArgs: []string{\"version\"},\n\t}\n\n\tout, err := b.CommandRunner.RunWithoutRetry(&goVersionCommand)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tre := regexp.MustCompile(`\\d+(\\.\\d+)+`)\n\tgoVersion := re.FindString(out)\n\treturn goVersion, nil\n}", "func Version() string {\n\tvv := version{\n\t\tGitCommit: GitCommit,\n\t\tReleaseVersion: ReleaseVersion,\n\t\tBuildTime: BuildTime,\n\t}\n\tb, err := json.Marshal(vv)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn string(b)\n}", "func Version() string {\n\t// TODO: Implement version tracking\n\treturn \"0.0.1\"\n}", "func GetVersion() string {\n\treturn Version\n}", "func GetVersion() string {\n\treturn Version\n}", "func GetVersion() string {\n\treturn version\n}", "func GetVersion() string {\n\treturn version\n}", "func (obj *application) Version() string {\n\treturn obj.version\n}", "func Version() string {\n\treturn getData().Version\n}", "func (net *NetAPI) Version() (string, error) {\n\treq := net.requestManager.newRequest(\"net_version\")\n\tresp, err := net.requestManager.send(req)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn resp.Get(\"result\").(string), nil\n}", "func GetVersionString() string {\n\treturn fmt.Sprintf(\"Praefect, version %v\", version.GetVersion())\n}", "func VersionString() string {\n\treturn C.GoString(C.LZ4_versionString())\n}", "func Version() string {\n\treturn \"0.4.0\"\n}", "func (v Version) Version() VersionString {\n\treturn VersionString(v.String())\n}", "func (l *Libvirt) Version() (string, error) {\n\tver, err := l.ConnectGetLibVersion()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// The version is provided as an int following this formula:\n\t// version * 1,000,000 + minor * 1000 + micro\n\t// See src/libvirt-host.c # virConnectGetLibVersion\n\tmajor := ver / 1000000\n\tver %= 1000000\n\tminor := ver / 1000\n\tver %= 1000\n\tmicro := ver\n\n\tversionString := fmt.Sprintf(\"%d.%d.%d\", major, minor, micro)\n\treturn versionString, nil\n}", "func Version() string {\n\treturn C.GoString(C.worker_version())\n}", "func (b *Binary) Version() string {\n\treturn b.version\n}", "func (v ComponentVersion) String() string {\n\treturn v.Version\n}", "func Version() string {\n\tstr := C.GoString(C.mongocrypt_version(nil))\n\treturn str\n}", "func Version() (string, error) {\n\treturn makeRequest(\"version\")\n}", "func Version() GoVersion {\n\tvar version = GoVersion{Raw: runtime.Version()}\n\tif strings.HasPrefix(version.Raw, \"go\") {\n\t\tdivided := strings.Split(strings.TrimPrefix(version.Raw, \"go\"), \".\")\n\t\tconverted := make([]int, 3)\n\t\tfor i := range divided {\n\t\t\tconverted[i], _ = strconv.Atoi(divided[i])\n\t\t}\n\t\tversion.Major, version.Minor, version.Patch = converted[0], converted[1], converted[2]\n\t}\n\treturn version\n}", "func Version() string {\n\tvar hashStr string\n\tif CommitHash != \"\" {\n\t\thashStr = \"+\" + CommitHash\n\t}\n\n\tif currentVersion.label == \"\" {\n\t\treturn fmt.Sprintf(\"%d.%d.%d%s\", currentVersion.major, currentVersion.minor, currentVersion.patch, hashStr)\n\t}\n\n\treturn fmt.Sprintf(\"%d.%d.%d-%s%s\", currentVersion.major, currentVersion.minor, currentVersion.patch, currentVersion.label, hashStr)\n}", "func (c *Cron) GetVersion() string { return c.Version }", "func (cmd *CLI) Version() string {\n\treturn cmd.version\n}", "func (v Version) String() string {\n\treturn fmt.Sprintf(\"%d.%d.%d\", v.Major, v.Minor, v.Patch)\n}", "func (v Version) String() string {\n\treturn fmt.Sprintf(\"%d.%d.%d\", v.Major, v.Minor, v.Patch)\n}", "func (b *BIOS) Version() string {\n\treturn b.str(0x05)\n}", "func (o *VirtualizationIweHost) GetVersion() string {\n\tif o == nil || o.Version == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Version\n}", "func (c *CWebP) Version() (string, error) {\n\treturn version(c.BinWrapper)\n}", "func Version() string {\n\treturn C.GoString(C.yices_version)\n}", "func (d *Diag) Version() string {\n\treturn bufToString(d.SzVersionString[:])\n}", "func (u *Uname) Version() string {\n\treturn toString(u.Utsname.Version[:])\n}", "func Version() string {\n\tp := C.unqlite_lib_version()\n\treturn C.GoString(p)\n}", "func Version() string {\n\treturn fmt.Sprint(\"C v1.2\", \"->\", d.Version())\n}", "func (_PlasmaFramework *PlasmaFrameworkSession) Version() (string, error) {\n\treturn _PlasmaFramework.Contract.Version(&_PlasmaFramework.CallOpts)\n}", "func Version() string {\n\treturn \"1.0.6\"\n}", "func GetVersion() string {\n\treturn fmt.Sprintf(\"%s (git+sha %s)\", Release, GitSHA)\n}", "func (o EnvironmentDaprComponentOutput) Version() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *EnvironmentDaprComponent) pulumi.StringOutput { return v.Version }).(pulumi.StringOutput)\n}", "func (m *kubeGenericRuntimeManager) Version() (kubecontainer.Version, error) {\n\truntime, err := m.runtimeRegistry.GetPrimaryRuntimeService()\n\n\tif err == nil {\n\t\treturn m.RuntimeVersion(runtime.ServiceApi)\n\t}\n\n\treturn nil, err\n}", "func (v Version) String() string {\n\treturn fmt.Sprintf(\"%0d.%0d\", v.Major, v.Minor)\n}", "func GetVersion() string {\n\n\tcwd, _ := os.Getwd()\n\tcurrentFolderPathList := strings.Split(cwd, \"/\")\n\tlenFolder := len(currentFolderPathList)\n\tcurrFolder := currentFolderPathList[lenFolder-1]\n\n\tversionInformation := strings.Split(currFolder, \"-\")\n\n\t// In case we are not executing in the install directory, return\n\t// the version present in versionMetadata.json.\n\tif len(versionInformation) < 3 {\n\n\t\tviper.SetConfigName(\"version_metadata.json\")\n\t\tviper.SetConfigType(\"json\")\n\t\tviper.AddConfigPath(\".\")\n\t\terr := viper.ReadInConfig()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tversionNumber := fmt.Sprint(viper.Get(\"version_number\"))\n\t\tbuildNumber := fmt.Sprint(viper.Get(\"build_number\"))\n\n\t\tversion := versionNumber + \"-\" + buildNumber\n\n\t\treturn version\n\n\t}\n\n\tversionNumber := versionInformation[1]\n\tbuildNumber := versionInformation[2]\n\n\tversion := versionNumber + \"-\" + buildNumber\n\n\treturn version\n}", "func GetVersion(self *C.PyObject, args *C.PyObject) *C.PyObject {\n\tav, _ := version.New(version.AgentVersion, version.Commit)\n\n\tcStr := C.CString(av.GetNumber())\n\tpyStr := C.PyString_FromString(cStr)\n\tC.free(unsafe.Pointer(cStr))\n\treturn pyStr\n}", "func GetVersionString() string {\n\treturn C.GoString(C.glfwGetVersionString())\n}", "func GetVersionString() string {\n\treturn C.GoString(C.glfwGetVersionString())\n}", "func GetVersionString() string {\n\treturn C.GoString(C.glfwGetVersionString())\n}", "func (p *processor) Version() string {\n\treturn p.version\n}", "func (v Version) String() string {\n\ts := strconv.Itoa(v.Major) + \".\" + strconv.Itoa(v.Minor)\n\tif v.Patch > 0 {\n\t\ts += \".\" + strconv.Itoa(v.Patch)\n\t}\n\tif v.PreRelease != \"\" {\n\t\ts += v.PreRelease\n\t}\n\n\treturn s\n}", "func (standardGo) Version() float64 {\n\treturn 0\n}", "func Version() string { return hs.Version() }", "func (v Version) String() string {\n\tvs := fmt.Sprintf(\"%d.%d.%d\", v.major, v.minor, v.patch)\n\tif len(v.preRelease) > 0 {\n\t\tvs += \"-\" + v.PreRelease()\n\t}\n\tif len(v.metadata) > 0 {\n\t\tvs += Metadata + v.Metadata()\n\t}\n\treturn vs\n}", "func Version() string {\n\treturn \"0.1.0\"\n}", "func (_PlasmaFramework *PlasmaFrameworkSession) GetVersion() (string, error) {\n\treturn _PlasmaFramework.Contract.GetVersion(&_PlasmaFramework.CallOpts)\n}", "func BuildVersionString() string {\n\tprogram := \"k8s-device-plugin\"\n\n\tversion := \"v\" + CurrentVersion.String()\n\tif CommitHash != \"\" {\n\t\tversion += \"-\" + strings.ToUpper(CommitHash)\n\t}\n\n\tosArch := runtime.GOOS + \"/\" + runtime.GOARCH\n\n\tdate := BuildDate\n\tif date == \"\" {\n\t\tdate = \"unknown\"\n\t}\n\n\treturn fmt.Sprintf(\"%s %s %s BuildDate: %s\", program, version, osArch, date)\n\n}", "func (v Version) String() string {\n\treturn fmt.Sprintf(\"v%d.%d.%d\", v.Major, v.Minor, v.Patches)\n}", "func Version() string {\n\treturn fmt.Sprintf(\"%v (%v %v)\", version, revisionDate, revision)\n}", "func Version() string {\n\treturn \"0.0.0\"\n}", "func Version() string {\n\treturn \"0.0.0\"\n}", "func (v *Version) String() string {\n\treturn fmt.Sprintf(\"Version: %s%d.%d.%d%s\\nBuild Date: %s\\n Minimum Go Version: %s\",\n\t\tv.Prefix, v.Major, v.Minor, v.Maintenance, v.Suffix, v.BuildDate, v.MinGoVersion)\n}", "func (args) Version() string {\n\treturn config.App.Name\n}" ]
[ "0.7978932", "0.72473425", "0.7034545", "0.7000306", "0.69702375", "0.6904021", "0.6897579", "0.6790574", "0.6746335", "0.67396516", "0.67396516", "0.67396516", "0.67396516", "0.67396516", "0.67396516", "0.67396516", "0.67396516", "0.6696343", "0.66733056", "0.66323537", "0.66031915", "0.6582196", "0.65809083", "0.6568356", "0.6560023", "0.6560023", "0.649764", "0.6489279", "0.64859086", "0.64714783", "0.64679956", "0.64677846", "0.6467465", "0.64668083", "0.6428226", "0.64121115", "0.6395513", "0.6393308", "0.63847035", "0.63841283", "0.6375361", "0.63651156", "0.6364683", "0.63588756", "0.6314125", "0.6314125", "0.63036096", "0.63036096", "0.63016397", "0.6297762", "0.62926763", "0.6288678", "0.6286037", "0.62768966", "0.625972", "0.62565863", "0.6252536", "0.62406665", "0.62398314", "0.6239079", "0.62303156", "0.62289965", "0.62260514", "0.6219902", "0.62179995", "0.62136954", "0.62136954", "0.6196802", "0.61952275", "0.61940545", "0.6193231", "0.6187136", "0.6181898", "0.6180594", "0.6177836", "0.6174625", "0.6168357", "0.6162197", "0.6160898", "0.61538106", "0.6149502", "0.6141935", "0.6141343", "0.6141176", "0.6141176", "0.6141176", "0.61410856", "0.61354995", "0.6130814", "0.61307704", "0.6129618", "0.6121785", "0.6108645", "0.6100305", "0.6095202", "0.60926867", "0.6090945", "0.6090945", "0.6086161", "0.6074114" ]
0.75853413
1
WithMultiStatsHandler returns a DialOption that chains given stats.Handler(s). The first handler will be executed first, and then next afterwards. nil Handlers are ignored.
WithMultiStatsHandler возвращает DialOption, который цепляет заданные stats.Handler(s). Первый обработчик будет выполнен первым, а затем следующий. Nil-обработчики игнорируются.
func WithMultiStatsHandler(handlers ...stats.Handler) grpc.DialOption { mh := &multiStatsHandler{} for _, h := range handlers { if h == nil { continue } mh.delegates = append(mh.delegates, h) } switch len(mh.delegates) { case 0: // Effectively, this unsets the dial option for the stats handler. return grpc.WithStatsHandler(nil) case 1: // Avoid unnecessary delegation layer. return grpc.WithStatsHandler(mh.delegates[0]) } return grpc.WithStatsHandler(mh) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewMultiStatReporter(reporters ...StatsReporter) StatsReporter {\n\treturn multiStatReporter(reporters)\n}", "func (group *Group) Use(handler ...Handler) {\n\tfor _, h := range handler{\n\t\tgroup.handlers = append(group.handlers, h)\n\t}\n}", "func Use(handler http.HandlerFunc, mid ...func(http.Handler) http.HandlerFunc) http.HandlerFunc {\n\tfor _, m := range mid {\n\t\thandler = m(handler)\n\t}\n\treturn handler\n}", "func Chain(hs ...juggler.Handler) juggler.Handler {\n\treturn juggler.HandlerFunc(func(ctx context.Context, c *juggler.Conn, m message.Msg) {\n\t\tfor _, h := range hs {\n\t\t\th.Handle(ctx, c, m)\n\t\t}\n\t})\n}", "func NewStatsMux(s stats.Statter) *bone.Mux {\n\tmux := NewMux()\n\n\tvar h StatsHandler\n\tfor s != nil {\n\t\tif sh, ok := s.(StatsHandler); ok {\n\t\t\th = sh\n\t\t\tbreak\n\t\t}\n\n\t\ts = stats.Unwrap(s)\n\t}\n\n\tif h != nil {\n\t\tmux.Get(DefaultStatsPath, h.Handler())\n\t}\n\n\treturn mux\n}", "func MaketHTTPHandler(ctx context.Context, urls []URL, s Service, logger *logrus.Logger) http.Handler {\n\tr := mux.NewRouter()\n\tfor _, u := range urls {\n\t\tswitch {\n\t\tcase u.isHTTP():\n\t\t\tdirector := func(req *http.Request) {\n\t\t\t\tout, err := url.Parse(u.buildHTTP())\n\t\t\t\tif err != nil {\n\t\t\t\t\tlogger.Error(err)\n\t\t\t\t}\n\t\t\t\treq.URL.Scheme = out.Scheme\n\t\t\t\treq.URL.Host = out.Host\n\t\t\t\treq.URL.RawQuery = out.RawQuery\n\t\t\t}\n\t\t\tproxy := &httputil.ReverseProxy{Director: director}\n\t\t\tr.HandleFunc(u.Path, httpHandler(proxy)).Methods(u.Method)\n\t\tcase u.isNsq():\n\t\t\tr.HandleFunc(u.Path, nsqHandler(ctx, u, s)).Methods(u.Method)\n\t\t}\n\t}\n\tr.Handle(\"/metrics\", prometheus.Handler())\n\treturn r\n}", "func Apply(h http.Handler, adapters ...Adapter) http.Handler {\n\tfor i := len(adapters) - 1; 0 <= i; i-- {\n\t\th = adapters[i](h)\n\t}\n\treturn h\n}", "func Chain(handlers ...interface{}) http.Handler {\n\t// fake handler in order to wrap last handler call \"next\"\n\tvar f http.Handler = http.HandlerFunc(blobHandler)\n\t// apply middleware/handlers from the last to the first one\n\tfor i := len(handlers) - 1; i >= 0; i-- {\n\t\tswitch t := handlers[i].(type) {\n\t\t// build the handler from classic middleware func\n\t\tcase func(http.ResponseWriter, *http.Request, http.Handler):\n\t\t\tf = func(curr MiddlewareFunc, next http.Handler) http.HandlerFunc {\n\t\t\t\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\t\t\t\tcurr(w, r, next)\n\t\t\t\t}\n\t\t\t}(t, f)\n\t\tcase MiddlewareFunc:\n\t\t\tf = func(curr MiddlewareFunc, next http.Handler) http.HandlerFunc {\n\t\t\t\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\t\t\t\tcurr(w, r, next)\n\t\t\t\t}\n\t\t\t}(t, f)\n\t\t// wrap existing handler (or blobHandler) with a Middleware/func\n\t\tcase func(http.Handler) http.Handler:\n\t\t\tf = t(f)\n\t\tcase Middleware:\n\t\t\tf = t(f)\n\t\t// ordinary functions can also be provided as arguments, in such case they\n\t\t// will be called via adapter http.HandlerFunc\n\t\tcase func(w http.ResponseWriter, r *http.Request):\n\t\t\tf = func(curr, next http.Handler) http.HandlerFunc {\n\t\t\t\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\t\t\t\tcurr.ServeHTTP(w, r)\n\t\t\t\t\t// due to the blobHandler next will never be nil\n\t\t\t\t\tnext.ServeHTTP(w, r)\n\t\t\t\t}\n\t\t\t}(http.HandlerFunc(t), f)\n\t\t// since http.HandlerFunc implements http.Handler interface we can use type\n\t\t// http.Handler for both of them\n\t\tcase http.Handler:\n\t\t\tf = func(curr, next http.Handler) http.HandlerFunc {\n\t\t\t\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\t\t\t\tcurr.ServeHTTP(w, r)\n\t\t\t\t\tnext.ServeHTTP(w, r)\n\t\t\t\t}\n\t\t\t}(t, f)\n\t\tdefault:\n\t\t\t// everything else is not supported\n\t\t\tpanic(fmt.Sprintf(\"unsupported argument type \\\"%T\\\"\", t))\n\t\t}\n\t}\n\treturn f\n}", "func (mh *MultiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tmh.RLock()\n\tdefer mh.RUnlock()\n\treplies := make(chan *subResponseWriter)\n\tfor _, handler := range mh.handlers {\n\t\tgo func(handler http.Handler) {\n\t\t\tsrw := subResponseWriter{}\n\t\t\thandler.ServeHTTP(&srw, r)\n\t\t\treplies <- &srw\n\t\t}(handler)\n\t}\n\n\tbuf := bytes.NewBuffer(make([]byte, 0, 4096))\n\tstatus := 0\n\tfor _ = range mh.handlers {\n\t\treply := <-replies\n\t\treply.buf.WriteTo(buf)\n\t\tif reply.status != http.StatusOK {\n\t\t\tstatus = reply.status\n\t\t}\n\t}\n\tif status != 0 {\n\t\tw.WriteHeader(status)\n\t}\n\tbuf.WriteTo(w)\n}", "func HandlerStats(stats stats.Stats) server.HandlerWrapper {\n\t// return a handler wrapper\n\treturn func(h server.HandlerFunc) server.HandlerFunc {\n\t\t// return a function that returns a function\n\t\treturn func(ctx context.Context, req server.Request, rsp interface{}) error {\n\t\t\t// execute the handler\n\t\t\terr := h(ctx, req, rsp)\n\t\t\t// record the stats\n\t\t\tstats.Record(err)\n\t\t\t// return the error\n\t\t\treturn err\n\t\t}\n\t}\n}", "func Chain(he ...HandlerE) HandlerE {\n\tf := func(w http.ResponseWriter, r *http.Request) error {\n\t\tfor _, h := range he {\n\t\t\tif err := h.ServeHTTPe(w, r); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\treturn HandlerFuncE(f)\n}", "func NewHandlerMetrics(scope tally.Scope) *HandlerMetrics {\n\thandlerAPIScope := scope.SubScope(\"api\")\n\thandlerSuccessScope := scope.Tagged(map[string]string{\"result\": \"success\"})\n\thandlerFailScope := scope.Tagged(map[string]string{\"result\": \"fail\"})\n\treturn &HandlerMetrics{\n\t\tHead: scope.Gauge(\"head\"),\n\t\tTail: scope.Gauge(\"tail\"),\n\t\tSize: scope.Gauge(\"size\"),\n\t\tCapacity: scope.Gauge(\"capacity\"),\n\t\tUnexpectedClientError: scope.Counter(\"unexpectedClientError\"),\n\t\tPurgeEventError: scope.Counter(\"purgeEventError\"),\n\t\tInvalidStreamIDError: scope.Counter(\"invalidStreamIdError\"),\n\t\tAddEventAPI: handlerAPIScope.Counter(\"addEvent\"),\n\t\tAddEventSuccess: handlerSuccessScope.Counter(\"addEvent\"),\n\t\tAddEventFail: handlerFailScope.Counter(\"addEvent\"),\n\t\tAddEventDeDupe: handlerAPIScope.Counter(\"addEventDeDupe\"),\n\t\tInitStreamAPI: handlerAPIScope.Counter(\"initStream\"),\n\t\tInitStreamSuccess: handlerSuccessScope.Counter(\"initStream\"),\n\t\tInitStreamFail: handlerFailScope.Counter(\"initStream\"),\n\t\tWaitForEventsAPI: handlerAPIScope.Counter(\"waitForEvents\"),\n\t\tWaitForEventsSuccess: handlerSuccessScope.Counter(\"waitForEvents\"),\n\t\tWaitForEventsFailed: handlerFailScope.Counter(\"waitForEvents\"),\n\t}\n}", "func Chain(ms []Func, f http.HandlerFunc) http.HandlerFunc {\n\thandler := f\n\tfor _, m := range ms {\n\t\thandler = m(handler)\n\t}\n\treturn handler\n}", "func WrapHandlers(handlers ...HTTPWrapper) Option {\n\treturn func(g *GRPC) {\n\t\tg.allHTTPWrappers = handlers\n\t}\n}", "func Chain(handler http.Handler, middleware ...Middleware) http.Handler {\n\th := handler\n\tfor _, m := range middleware {\n\t\th = m(h)\n\t}\n\treturn h\n}", "func TestMultiHandlers(t *testing.T) {\n\t// New logger for output stderr\n\tlogStd := New(\"\", LevelDebug, os.Stderr)\n\tAddHandler(logStd)\n\n\t// New logger for output file\n\tfw, err := FileWriter(\"logs/test.log\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tlogFile := New(\"\", LevelDebug, fw)\n\tAddHandler(logFile)\n\n\t// Test\n\tDebug(\"MultiHandlers: Debug\")\n\tInfo(\"MultiHandlers: Info\")\n\tWarn(\"MultiHandlers: Warn\")\n\tError(\"MultiHandlers: Error\")\n\t//Panic(\"MultiHandlers: Panic\")\n\t//Fatal(\"MultiHandlers: Fatal\")\n}", "func (h *Handler) setMultiChannelFanoutHandler(nh *multichannelfanout.Handler) {\n\th.fanout.Store(nh)\n}", "func Use(h http.Handler, mws ...Middleware) http.Handler {\n\tfor _, m := range mws {\n\t\tif m != nil {\n\t\t\th = m(h)\n\t\t}\n\t}\n\treturn h\n}", "func (h *Handler) getMultiChannelFanoutHandler() *multichannelfanout.Handler {\n\treturn h.fanout.Load().(*multichannelfanout.Handler)\n}", "func (w *WaccVisitor) VisitStatMultiple(ctx *parser.StatMultipleContext) interface{} {\n\tstatsCtx := ctx.AllStat()\n\tstats := make([]ast.Statement, 0)\n\n\tfor _, statCtx := range statsCtx {\n\t\tstat := statCtx.Accept(w).(ast.Statement)\n\t\tswitch s := stat.(type) {\n\t\tcase ast.StatMultiple:\n\t\t\tfor _, st := range s {\n\t\t\t\tstats = append(stats, st)\n\t\t\t}\n\t\tdefault:\n\t\t\tstats = append(stats, stat)\n\t\t}\n\t}\n\n\treturn ast.NewStatMultiple(stats)\n}", "func New(next http.Handler, opts ...Option) http.Handler {\n\toptions := &Options{}\n\tfor _, fn := range opts {\n\t\tfn(options)\n\t}\n\n\treturn &logging{\n\t\tnext: next,\n\t\toptions: options,\n\t}\n}", "func Do(handler interface{}, params ...interface{}) {\n\tif DefaultAsync == nil {\n\t\tDefaultAsync = New(DefaultReqSize, DefaultBufSize)\n\t}\n\tDefaultAsync.Do(handler, params...)\n}", "func (h Handler) Use(mws ...Middleware) Handler {\n\tfor i := len(mws) - 1; i >= 0; i-- {\n\t\th = mws[i].Then(h)\n\t}\n\treturn h\n}", "func (s *Service) Use(h ...Handler) {\n if h != nil {\n for _, e := range h {\n s.pipeline = s.pipeline.Add(e)\n }\n }\n}", "func Handler(next http.Handler, l ...*log.Logger) http.Handler {\n\tfn := func(w http.ResponseWriter, r *http.Request) {\n\t\tpw := makePipeWriter(w)\n\t\tt1 := time.Now()\n\t\tnext.ServeHTTP(&pw, r)\n\t\tt2 := time.Now()\n\t\tif len(l) > 0 {\n\t\t\tl[0].Printf(\"%s %q %d %d %v\\n\",\n\t\t\t\tr.Method, r.URL.String(), pw.Status(), pw.Bytes(), t2.Sub(t1))\n\t\t} else {\n\t\t\tlog.Printf(\"%s %q %d %d %v\\n\",\n\t\t\t\tr.Method, r.URL.String(), pw.Status(), pw.Bytes(), t2.Sub(t1))\n\t\t}\n\t}\n\treturn http.HandlerFunc(fn)\n}", "func Durations(statsd io.Writer, key string, interval time.Duration, next http.Handler) http.Handler {\n\t// buffered - reporting is concurrent with the handler\n\tdurations := make(chan time.Duration, 1)\n\tgo reportDurations(statsd, key, time.Tick(interval), durations)\n\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tstart := time.Now()\n\t\tnext.ServeHTTP(w, r)\n\t\tdurations <- time.Now().Sub(start)\n\t})\n}", "func initHandlerFor(c *CompositeMultiHandler, output, basePath string, options *LogOptions) {\n\tif options.Ctx != nil {\n\t\toptions.SetExtendedOptions(\n\t\t\t\"noColor\", !options.Ctx.BoolDefault(\"log.colorize\", true),\n\t\t\t\"smallDate\", options.Ctx.BoolDefault(\"log.smallDate\", true),\n\t\t\t\"maxSize\", options.Ctx.IntDefault(\"log.maxsize\", 1024*10),\n\t\t\t\"maxAge\", options.Ctx.IntDefault(\"log.maxage\", 14),\n\t\t\t\"maxBackups\", options.Ctx.IntDefault(\"log.maxbackups\", 14),\n\t\t\t\"compressBackups\", !options.Ctx.BoolDefault(\"log.compressBackups\", true),\n\t\t)\n\t}\n\n\toutput = strings.TrimSpace(output)\n\tif funcHandler, found := LogFunctionMap[output]; found {\n\t\tfuncHandler(c, options)\n\t} else {\n\t\tswitch output {\n\t\tcase \"\":\n\t\t\tfallthrough\n\t\tcase \"off\":\n\t\t// No handler, discard data\n\t\tdefault:\n\t\t\t// Write to file specified\n\t\t\tif !filepath.IsAbs(output) {\n\t\t\t\toutput = filepath.Join(basePath, output)\n\t\t\t}\n\n\t\t\tif err := os.MkdirAll(filepath.Dir(output), 0755); err != nil {\n\t\t\t\tlog.Panic(err)\n\t\t\t}\n\n\t\t\tif strings.HasSuffix(output, \"json\") {\n\t\t\t\tc.SetJSONFile(output, options)\n\t\t\t} else {\n\t\t\t\t// Override defaults for a terminal file\n\t\t\t\toptions.SetExtendedOptions(\"noColor\", true)\n\t\t\t\toptions.SetExtendedOptions(\"smallDate\", false)\n\t\t\t\tc.SetTerminalFile(output, options)\n\t\t\t}\n\t\t}\n\t}\n}", "func (d *DBClient) StatsHandler(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\tstats := d.Counter.Flush()\n\n\tcount, err := d.Cache.RecordsCount()\n\n\tif err != nil {\n\t\tlog.Error(err)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n\n\tvar sr statsResponse\n\tsr.Stats = stats\n\tsr.RecordsCount = count\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\tb, err := json.Marshal(sr)\n\n\tif err != nil {\n\t\tlog.Error(err)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t} else {\n\t\tw.Write(b)\n\t\treturn\n\t}\n\n}", "func ChainHandler(h http.Handler, c ...alice.Constructor) http.Handler {\n\treturn alice.New(c...).Then(h)\n}", "func ChainHandler(h http.Handler, c ...alice.Constructor) http.Handler {\n\treturn alice.New(c...).Then(h)\n}", "func (c *FakeZkConn) Multi(ops ...interface{}) ([]zk.MultiResponse, error) {\n\tc.history.addToHistory(\"Multi\", ops)\n\treturn nil, nil\n}", "func WrapHandler(w ...server.HandlerWrapper) Option {\n\treturn func(o *Options) {\n\t\tvar wrappers []server.Option\n\n\t\tfor _, wrap := range w {\n\t\t\twrappers = append(wrappers, server.WrapHandler(wrap))\n\t\t}\n\n\t\t// Init once\n\t\to.Server.Init(wrappers...)\n\t}\n}", "func (manager *Manager) GetAllProxyStatsHandler() {\n\tticker := time.NewTicker(500 * time.Millisecond)\n\tvar oldstats []*config.ProxyBackendStatisticsUpdate\n\tfor {\n\t\tselect {\n\t\tcase <-ticker.C:\n\t\t\tnewstats := manager.GetAllProxyStats()\n\t\t\tfor _, new := range newstats {\n\t\t\t\tfor _, old := range oldstats {\n\t\t\t\t\tif old.Statistics.UUID == new.Statistics.UUID {\n\t\t\t\t\t\tif old.Statistics.ClientsConnects != new.Statistics.ClientsConnects {\n\t\t\t\t\t\t\tmanager.proxyBackendStatisticsUpdate <- new\n\t\t\t\t\t\t}\n\t\t\t\t\t} // uuid\n\t\t\t\t} // old\n\t\t\t} // new\n\t\t\toldstats = newstats\n\n\t\t}\n\t}\n}", "func (t TypedHandler) Combine(handlers ...TypedHandler) TypedHandler {\n\tcombined := append([]TypedHandler{t}, handlers...)\n\treturn TypedHandlers(combined...)\n}", "func Wrap(h http.Handler, o ...ServerOption) http.Handler {\n\tif h == nil {\n\t\tpanic(\"h == nil\")\n\t}\n\thandler := &handler{\n\t\thandler: h,\n\t\ttracer: apm.DefaultTracer(),\n\t\trequestName: ServerRequestName,\n\t}\n\tfor _, o := range o {\n\t\to(handler)\n\t}\n\tif handler.requestIgnorer == nil {\n\t\thandler.requestIgnorer = NewDynamicServerRequestIgnorer(handler.tracer)\n\t}\n\tif handler.recovery == nil {\n\t\thandler.recovery = NewTraceRecovery(handler.tracer)\n\t}\n\treturn handler\n}", "func NewMultiStrategy(filters []PeerFilter, peerIDs []peer.ID) *MultiStrategy {\n\treturn &MultiStrategy{\n\t\tfilters: filters,\n\t\tpeerIDs: peerIDs,\n\t}\n}", "func NewStatsHandlers(r *gin.Engine) *StatsHandlers {\n\treturn &StatsHandlers{renderer: r}\n}", "func (hm *handlerManager) Use(handler ...InvokeHandler) {\n\thm.AddInvokeHandler(handler...)\n}", "func NewHandler(opts ...Option) *Handler {\n\th := &Handler{\n\t\thc: func() *hoarding.Hoard {\n\t\t\treturn hoarding.NewHoarder(nil, func() bool {\n\t\t\t\treturn true\n\t\t\t})\n\t\t},\n\t}\n\n\tfor _, o := range opts {\n\t\th = o(h)\n\t}\n\n\treturn h\n}", "func (a *Client) MultipleMetrics(params *MultipleMetricsParams, authInfo runtime.ClientAuthInfoWriter) (*MultipleMetricsOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewMultipleMetricsParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"multipleMetrics\",\n\t\tMethod: \"POST\",\n\t\tPathPattern: \"/system/metrics/multiple\",\n\t\tProducesMediaTypes: []string{\"\"},\n\t\tConsumesMediaTypes: []string{\"\"},\n\t\tSchemes: []string{\"http\"},\n\t\tParams: params,\n\t\tReader: &MultipleMetricsReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*MultipleMetricsOK), nil\n\n}", "func Use(h http.HandlerFunc, middleware ...func(http.HandlerFunc) http.HandlerFunc) http.HandlerFunc {\n\tfor _, m := range middleware {\n\t\th = m(h)\n\t}\n\treturn h\n}", "func (c *Context) Use(h ...Handler) {\n if h != nil {\n for _, e := range h {\n c.pipeline = c.pipeline.Add(e)\n }\n }\n}", "func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler {\n\tr := options.BaseRouter\n\n\tif r == nil {\n\t\tr = chi.NewRouter()\n\t}\n\tif options.ErrorHandlerFunc == nil {\n\t\toptions.ErrorHandlerFunc = func(w http.ResponseWriter, r *http.Request, err error) {\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t}\n\t}\n\twrapper := ServerInterfaceWrapper{\n\t\tHandler: si,\n\t\tHandlerMiddlewares: options.Middlewares,\n\t\tErrorHandlerFunc: options.ErrorHandlerFunc,\n\t}\n\n\tr.Group(func(r chi.Router) {\n\t\tr.Get(options.BaseURL+\"/links\", wrapper.GetLinks)\n\t})\n\n\treturn r\n}", "func NewHandler(url string) (*Handler, error) {\n\tlog.WithField(\"URL\", url).Debug(\"connecting to NATS\")\n\tconn, err := nats.Connect(url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlog.Info(\"successful connection to NATS\")\n\n\tlog.Debug(\"creating all of the managers\")\n\tlog.Debug(\"initialzing user manager\")\n\tusermgr, err := NewUserManager(conn)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error when initializing user manager\")\n\t}\n\tlog.Debug(\"user manager initialization done\")\n\n\tlog.Debug(\"initialzing alerts manager\")\n\talertsmgr, err := NewAlertsManager(conn)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error when initializing alerts manager\")\n\t}\n\tlog.Debug(\"alerts manager initialization done\")\n\n\tlog.Debug(\"initialzing alert options manager\")\n\talertsoptsmgr, err := NewAlertsOptionsManager(conn)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error when initializing alert options manager\")\n\t}\n\tlog.Debug(\"alert options manager initialization done\")\n\n\tlog.Debug(\"initialzing checks manager\")\n\tchecksmgr, err := NewChecksManager(conn)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error when initializing checks manager\")\n\t}\n\tlog.Debug(\"checks manager initialization done\")\n\n\tlog.Debug(\"initialzing clients manager\")\n\tclientsmgr, err := NewClientsManager(conn)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error when initializing clients manager\")\n\t}\n\tlog.Debug(\"clients manager initialization done\")\n\n\tlog.Debug(\"initialzing commands manager\")\n\tcommandsmgr, err := NewCommandsManager(conn)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error when initializing commands manager\")\n\t}\n\tlog.Debug(\"commands manager initialization done\")\n\n\tlog.Debug(\"initialzing groups manager\")\n\tgroupsmgr, err := NewGroupsManager(conn)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error when initializing groups manager\")\n\t}\n\tlog.Debug(\"groups manager initialization done\")\n\n\tlog.Debug(\"initialzing servers manager\")\n\tserversmgr, err := NewServersManager(conn)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error when initializing servers manager\")\n\t}\n\tlog.Debug(\"servers manager initialization done\")\n\n\tlog.Debug(\"initialzing upload manager\")\n\tuploadsmgr, err := NewUploadsManager(conn)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error when initializing upload manager\")\n\t}\n\tlog.Debug(\"upload manager initialization done\")\n\n\tlog.Debug(\"Handler initialization done\")\n\treturn &Handler{\n\t\tConn: conn,\n\t\tUsers: usermgr,\n\t\tGroups: groupsmgr,\n\t\tAlerts: alertsmgr,\n\t\tAlertsOptions: alertsoptsmgr,\n\t\tChecks: checksmgr,\n\t\tCommands: commandsmgr,\n\t\tClients: clientsmgr,\n\t\tServers: serversmgr,\n\t\tUploads: uploadsmgr,\n\t}, nil\n}", "func NewHandler(server ServiceControllerServer, hh []*PrefixAndHandler, opts ...func(*Handler)) *Handler {\n\th := &Handler{\n\t\tServer: server,\n\t\tReportHandlers: hh,\n\t\treadf: ioutil.ReadAll,\n\t\tmarshal: proto.Marshal,\n\t\tunmarshal: proto.Unmarshal,\n\t}\n\tfor _, opt := range opts {\n\t\topt(h)\n\t}\n\treturn h\n}", "func multiResponseServer(responses []R) *httptest.Server {\n\tvar index = 0\n\treturn httptest.NewServer(\n\t\thttp.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tif index < len(responses) {\n\t\t\t\tresponses[index](w, r)\n\t\t\t\tindex += 1\n\t\t\t} else {\n\t\t\t\tresponses[len(responses)-1](w, r)\n\t\t\t}\n\t\t}))\n}", "func WithMetaHandler(h remote.MetaHandler) Option {\n\treturn Option{F: func(o *internal_server.Options, di *utils.Slice) {\n\t\tdi.Push(fmt.Sprintf(\"WithMetaHandler(%T)\", h))\n\n\t\to.MetaHandlers = append(o.MetaHandlers, h)\n\t}}\n}", "func aggregatePerSecondHandler(perSecondChannel chan *HttpReqResult) {\n\n\tfor {\n\n\t\tvar totalReq int = 0\n\t\tvar totalLatency int = 0\n\t\tuntil := time.Now().UnixNano() + 1000000000\n\t\tfor time.Now().UnixNano() < until {\n\t\t\tselect {\n\t\t\tcase msg := <-perSecondChannel:\n\t\t\t\ttotalReq++\n\t\t\t\ttotalLatency += int(msg.Latency/1000) // measure in microseconds\n\t\t\tdefault:\n\t\t\t// Can be trouble. Uses too much CPU if low, limits throughput if too high\n\t\t\t\ttime.Sleep(100*time.Microsecond)\n\t\t\t}\n\t\t}\n\t\t// concurrently assemble the result and send it off to the websocket.\n\t\tgo assembleAndSendResult(totalReq, totalLatency)\n\t}\n\n}", "func NewMultiLogger(timeFormat, prefix string, outs, errs []NamedWriter) *MultiLogger {\n\treturn createMultiLogger(timeFormat, prefix, outs, errs)\n}", "func New(fn Func, opts ...Option) *Handler {\n\toptions := options{\n\t\toutput: ioutil.Discard,\n\t\ttransport: http.DefaultTransport,\n\t}\n\tfor _, opt := range opts {\n\t\topt(&options)\n\t}\n\n\treturn &Handler{\n\t\tfn: fn,\n\t\toutput: options.output,\n\t\ttransport: options.transport,\n\t}\n}", "func NewHandler(cfg HandlerConfig, roundTripper http.RoundTripper, log log.Logger, reg prometheus.Registerer) http.Handler {\n\th := &Handler{\n\t\tcfg: cfg,\n\t\tlog: log,\n\t\troundTripper: roundTripper,\n\t}\n\n\tif cfg.QueryStatsEnabled {\n\t\th.querySeconds = promauto.With(reg).NewCounterVec(prometheus.CounterOpts{\n\t\t\tName: \"cortex_query_seconds_total\",\n\t\t\tHelp: \"Total amount of wall clock time spend processing queries.\",\n\t\t}, []string{\"user\"})\n\n\t\th.querySeries = promauto.With(reg).NewCounterVec(prometheus.CounterOpts{\n\t\t\tName: \"cortex_query_fetched_series_total\",\n\t\t\tHelp: \"Number of series fetched to execute a query.\",\n\t\t}, []string{\"user\"})\n\n\t\th.queryChunkBytes = promauto.With(reg).NewCounterVec(prometheus.CounterOpts{\n\t\t\tName: \"cortex_query_fetched_chunks_bytes_total\",\n\t\t\tHelp: \"Size of all chunks fetched to execute a query in bytes.\",\n\t\t}, []string{\"user\"})\n\n\t\th.queryDataBytes = promauto.With(reg).NewCounterVec(prometheus.CounterOpts{\n\t\t\tName: \"cortex_query_fetched_data_bytes_total\",\n\t\t\tHelp: \"Size of all data fetched to execute a query in bytes.\",\n\t\t}, []string{\"user\"})\n\n\t\th.rejectedQueries = promauto.With(reg).NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tName: \"cortex_rejected_queries_total\",\n\t\t\t\tHelp: \"The total number of queries that were rejected.\",\n\t\t\t},\n\t\t\t[]string{\"reason\", \"user\"},\n\t\t)\n\n\t\th.activeUsers = util.NewActiveUsersCleanupWithDefaultValues(func(user string) {\n\t\t\th.querySeconds.DeleteLabelValues(user)\n\t\t\th.querySeries.DeleteLabelValues(user)\n\t\t\th.queryChunkBytes.DeleteLabelValues(user)\n\t\t\th.queryDataBytes.DeleteLabelValues(user)\n\t\t\tif err := util.DeleteMatchingLabels(h.rejectedQueries, map[string]string{\"user\": user}); err != nil {\n\t\t\t\tlevel.Warn(log).Log(\"msg\", \"failed to remove cortex_rejected_queries_total metric for user\", \"user\", user, \"err\", err)\n\t\t\t}\n\t\t})\n\t\t// If cleaner stops or fail, we will simply not clean the metrics for inactive users.\n\t\t_ = h.activeUsers.StartAsync(context.Background())\n\t}\n\n\treturn h\n}", "func NewHandler(dashConfig config.Dash, options ...HandlerOption) (*Handler, error) {\n\tl, err := link.NewFromDashConfig(dashConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\th := &Handler{\n\t\tobjectStore: dashConfig.ObjectStore(),\n\t\tlink: l,\n\t\tpluginPrinter: dashConfig.PluginManager(),\n\t\tadjList: adjListStorage{},\n\t\tnodes: nodesStorage{},\n\t\tobjectStatus: NewHandlerObjectStatus(dashConfig.ObjectStore(), dashConfig.PluginManager()),\n\t}\n\n\tfor _, option := range options {\n\t\toption(h)\n\t}\n\n\treturn h, nil\n}", "func (s) TestHandlerTransport_HandleStreams_MultiWriteStatus(t *testing.T) {\n\ttestHandlerTransportHandleStreams(t, func(st *handleStreamTest, s *Stream) {\n\t\tif want := \"/service/foo.bar\"; s.method != want {\n\t\t\tt.Errorf(\"stream method = %q; want %q\", s.method, want)\n\t\t}\n\t\tst.bodyw.Close() // no body\n\n\t\tvar wg sync.WaitGroup\n\t\twg.Add(5)\n\t\tfor i := 0; i < 5; i++ {\n\t\t\tgo func() {\n\t\t\t\tdefer wg.Done()\n\t\t\t\tst.ht.WriteStatus(s, status.New(codes.OK, \"\"))\n\t\t\t}()\n\t\t}\n\t\twg.Wait()\n\t})\n}", "func NewStatsHandler(repository repository.ResponseRepository) StatsHandler {\n\treturn &statsHandler{repository: repository}\n}", "func Chain(ms ...Middleware) Middleware {\n\treturn func(handler Handler) Handler {\n\t\tfor i := len(ms) - 1; i >= 0; i-- {\n\t\t\thandler = ms[i](handler)\n\t\t}\n\n\t\treturn handler\n\t}\n}", "func decorateHandler(h http.HandlerFunc, ds ...Wrapper) http.HandlerFunc {\n\n\tfor _, decorate := range ds {\n\t\th = decorate(h)\n\t}\n\n\treturn h\n}", "func QueryMulti(start, end int64, cf string, metrics [][]string) []*model.GraphQueryResponse {\n\tresult := make([]*model.GraphQueryResponse, 0, len(metrics))\n\n\tvar wg sync.WaitGroup\n\tlock := new(sync.Mutex)\n\n\tfor _, pair := range metrics {\n\t\tif len(pair) != 2 {\n\t\t\tcontinue\n\t\t}\n\t\tendpoint := pair[0]\n\t\tcounter := pair[1]\n\n\t\twg.Add(1)\n\t\tgo func(endpoint, counter string) {\n\t\t\tdefer wg.Done()\n\t\t\tr, err := QueryOne(start, end, cf, endpoint, counter)\n\t\t\tif err != nil {\n\t\t\t\tlogger.Error(\"query one from graph fail: %v\", err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tlock.Lock()\n\t\t\tdefer lock.Unlock()\n\t\t\tresult = append(result, r)\n\n\t\t}(endpoint, counter)\n\t}\n\n\twg.Wait()\n\n\treturn result\n}", "func (c *middlewareChain) UseHandler(middlewares ...http.Handler) {\n\tfor i := range middlewares {\n\t\tc.Use(toMiddleware(middlewares[i]))\n\t}\n}", "func NewHandler(handler *multichannelfanout.Handler, logger *zap.Logger) *Handler {\n\th := &Handler{\n\t\tlogger: logger.With(zap.String(\"httpHandler\", \"swappable\")),\n\t}\n\th.setMultiChannelFanoutHandler(handler)\n\treturn h\n}", "func New(opts ...Option) *Handler {\n\th := &Handler{}\n\tfor _, option := range opts {\n\t\toption(h)\n\t}\n\tif h.router == nil {\n\t\th.router = &tree{}\n\t}\n\tif h.locales == nil {\n\t\th.locales = newLocaleMatcher([]language.Tag{language.English})\n\t}\n\tif h.decoder == nil {\n\t\th.decoder = NewContentTypeDecoder(map[string]Decoder{\n\t\t\t\"application/json\": &jsonDecoder{},\n\t\t})\n\t}\n\tif h.encoder == nil {\n\t\tencoder := &jsonEncoder{}\n\t\th.encoder = NewAcceptEncoder(map[string]Encoder{\n\t\t\t\"\": encoder,\n\t\t\t\"*/*\": encoder,\n\t\t\t\"application/*\": encoder,\n\t\t\t\"application/json\": encoder,\n\t\t})\n\t}\n\tif h.resolver == nil {\n\t\th.resolver = ResolverFunc(defaultResolver)\n\t}\n\tif h.pool == nil {\n\t\th.pool = &pool{free: make(chan *bytes.Buffer, 1<<6)}\n\t}\n\tif h.log == nil {\n\t\th.log = defaultLogger\n\t}\n\tif h.observer == nil {\n\t\th.observer = &discardObserver{}\n\t}\n\treturn h\n}", "func Multi(openers ...Opener) Opener {\n\treturn multi(openers)\n}", "func MakeStats(handler http.Handler, stats *Stats) http.Handler {\r\n return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\r\n \t//Save time everytime we get a request\r\n \tstart := time.Now()\r\n\r\n //Log connection\r\n log.Printf(\"%s %s\", r.RemoteAddr, r.URL)\r\n\r\n //Print all info for request\r\n //log.Printf(\"Request: %v\", r)\r\n\r\n \t//Route and fulfil request\r\n handler.ServeHTTP(w, r)\r\n\r\n //Only count hash requests in stats (even if request is broken) from client side\r\n //This does not count the background hash-write operations as user is not aware\r\n //of these as per requirement. If requirement changes, this will need to be changed\r\n if strings.Contains(r.URL.Path, \"hash\"){\r\n //Calculate request time\r\n end := time.Now()\r\n requestTime := end.Sub(start)\r\n\r\n //Update server stats - thread-safe\r\n stats.timeLock.Lock()\r\n stats.totalTime = stats.totalTime + requestTime\r\n stats.Requests++\r\n stats.AverageTime = float32(stats.totalTime / time.Millisecond) / float32(stats.Requests)\r\n stats.timeLock.Unlock()\r\n log.Printf(\"Request Complete: %v Average: %v\",requestTime,stats.AverageTime)\r\n } \r\n })\r\n}", "func Adapt(h http.Handler, adapters ...Adapter) http.Handler {\n\tfor i := len(adapters) - 1; i >= 0; i-- {\n\t\th = adapters[i](h)\n\t}\n\treturn h\n}", "func Metrics(before web.Handler) web.Handler {\n\n\t// Wrap this handler around the next one provided.\n\th := func(ctx context.Context, log *log.Logger, w http.ResponseWriter, r *http.Request, params map[string]string) error {\n\t\tctx, span := trace.StartSpan(ctx, \"internal.mid.Metrics\")\n\t\tdefer span.End()\n\n\t\t// If the context is missing this value, request the service\n\t\t// to be shutdown gracefully.\n\t\tv, ok := ctx.Value(web.KeyValues).(*web.Values)\n\t\tif !ok {\n\t\t\treturn web.Shutdown(\"web value missing from context\")\n\t\t}\n\n\t\terr := before(ctx, log, w, r, params)\n\n\t\t// Add one to the request counter.\n\t\tm.req.Add(1)\n\n\t\t// Include the current count for the number of goroutines.\n\t\tif m.req.Value()%100 == 0 {\n\t\t\tm.gr.Set(int64(runtime.NumGoroutine()))\n\t\t}\n\n\t\t// Add one to the errors counter if an error occured\n\t\t// on this reuqest.\n\t\tif v.Error {\n\t\t\tm.err.Add(1)\n\t\t}\n\n\t\treturn err\n\t}\n\n\treturn h\n}", "func NewMultiSorter(lesses ...LessFunc) *MultiSorter {\n\treturn &MultiSorter{lesses: lesses}\n}", "func use(h http.HandlerFunc, middleware ...func(http.HandlerFunc) http.HandlerFunc) http.HandlerFunc {\n\tfor _, m := range middleware {\n\t\th = m(h)\n\t}\n\n\treturn h\n}", "func ChainHandler(endHandler Handler, chains ...Chain) MuxHandler {\n\tif len(chains) == 0 {\n\t\treturn handlerWrapper(endHandler)\n\t}\n\n\treturn chains[0](ChainHandler(endHandler, chains[1:]...))\n}", "func (c *Client) Use(handlers ...grpc.UnaryClientInterceptor) *Client {\n\tfinalSize := len(c.handlers) + len(handlers)\n\tif finalSize >= int(_abortIndex) {\n\t\tpanic(\"rrpc: client use too many handlers\")\n\t}\n\tmergedHandlers := make([]grpc.UnaryClientInterceptor, finalSize)\n\tcopy(mergedHandlers, c.handlers)\n\tcopy(mergedHandlers[len(c.handlers):], handlers)\n\tc.handlers = mergedHandlers\n\treturn c\n}", "func Apply(handler Handler, middleware ...Middleware) Handler {\n\th := handler\n\tfor _, m := range middleware {\n\t\th = m(h)\n\t}\n\treturn h\n}", "func metricsHandler() fasthttp.RequestHandler {\n\treturn fasthttpadaptor.NewFastHTTPHandler(promhttp.Handler())\n}", "func SummaryHandler(res chan<- RpcRequest, minerInfo *MinerInformation, c *Client, wg *sync.WaitGroup) {\n\trequest := RpcRequest{\"{\\\"command\\\":\\\"summary\\\"}\", make(chan []byte), \"\"}\n\n\tvar response []byte\n\t//Creating an empty instance of everything\n\tsummary := SummaryResponse{[]StatusObject{StatusObject{}}, []SummaryObject{SummaryObject{}}, 0}\n\tsummaryRow := MinerRow{}\n\tsummaryRow.Name = c.Name\n\n\t//Save the default values\n\t//Lock it\n\tminerInfo.SumWrap.Mu.Lock()\n\t//Save the summary\n\tminerInfo.SumWrap.Summary = summary\n\tminerInfo.SumWrap.SummaryRow = summaryRow\n\t//Now unlock\n\tminerInfo.SumWrap.Mu.Unlock()\n\n\t//Signal that the thread is started\n\twg.Done()\n\n\tfor {\n\t\tsummary := SummaryResponse{[]StatusObject{StatusObject{}}, []SummaryObject{SummaryObject{}}, 0}\n\t\tres <- request\n\t\tresponse = <-request.ResultChan\n\n\t\t//If we got the response back unmarshal it\n\t\tif len(response) != 0 {\n\t\t\terr := json.Unmarshal(response, &summary)\n\n\t\t\t//Check for errors\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err.Error())\n\t\t\t}\n\n\t\t\t//Update the summaryrow\n\t\t\tsummaryRow = MinerRow{c.Name, summary.Summary[0].Accepted, summary.Summary[0].Rejected, summary.Summary[0].MHSAv, summary.Summary[0].BestShare}\n\t\t} else {\n\t\t\t//No response so wait somee extra before try again\n\t\t\tlog.Println(\"Failed to fetch new data from \" + c.Name)\n\t\t\tsummaryRow = MinerRow{c.Name, 0, 0, 0, 0}\n\t\t}\n\t\t//Lock it\n\t\tminerInfo.SumWrap.Mu.Lock()\n\t\t//Save the summary\n\t\tminerInfo.SumWrap.Summary = summary\n\t\tminerInfo.SumWrap.SummaryRow = summaryRow\n\t\t//Now unlock\n\t\tminerInfo.SumWrap.Mu.Unlock()\n\n\t\t//Check if we should sleep some extra\n\t\tif(len(response) == 0){\n\t\t\ttime.Sleep(time.Duration(c.RefreshInterval*2) * time.Second)\t\n\t\t}\n\t\t//Now sleep\n\t\ttime.Sleep(time.Duration(c.RefreshInterval) * time.Second)\n\t}\n}", "func appendHandlers(hs []func(http.Handler) http.Handler, ahs ...func(http.Handler) http.Handler) []func(http.Handler) http.Handler {\n\tlcur := len(hs)\n\tltot := lcur + len(ahs)\n\tif ltot > cap(hs) {\n\t\tnhs := make([]func(http.Handler) http.Handler, ltot)\n\t\tcopy(nhs, hs)\n\t\ths = nhs\n\t}\n\n\tcopy(hs[lcur:], ahs)\n\n\treturn hs\n}", "func (_m *HTTPMiddleware) HTTPMultipleAuth(next http.Handler) http.Handler {\n\tret := _m.Called(next)\n\n\tvar r0 http.Handler\n\tif rf, ok := ret.Get(0).(func(http.Handler) http.Handler); ok {\n\t\tr0 = rf(next)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(http.Handler)\n\t\t}\n\t}\n\n\treturn r0\n}", "func dialWebsocketMulti(addrs []string, path string, opts DialOpts) (*websocket.Conn, error) {\n\t// Dial all addresses at reasonable intervals.\n\ttry := parallel.NewTry(0, nil)\n\tdefer try.Kill()\n\tfor _, addr := range addrs {\n\t\terr := startDialWebsocket(try, addr, path, opts)\n\t\tif err == parallel.ErrStopped {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, errors.Trace(err)\n\t\t}\n\t\tselect {\n\t\tcase <-time.After(opts.DialAddressInterval):\n\t\tcase <-try.Dead():\n\t\t}\n\t}\n\ttry.Close()\n\tresult, err := try.Result()\n\tif err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\treturn result.(*websocket.Conn), nil\n}", "func StatsHandlerWithHandleRPCLabelsFunc(fn HandleRPCLabelFunc) StatsHandlerOption {\n\treturn newFuncStatsHandlerOption(func(o *statsHandlerOptions) {\n\t\to.handleRPCLabelFn = fn\n\t})\n}", "func (h Handlers) HandleRPC(ctx context.Context, s stats.RPCStats) {\n\tfor _, sh := range h.subHandlers {\n\t\tsh.HandleRPC(ctx, s)\n\t}\n}", "func Stats(xURL ...string) chan Stat {\n\tcStats := make(chan Stat)\n\tfor _, URL := range xURL {\n\t\tgo func(c chan Stat, u string) {\n\t\t\tc <- statFromURL(u)\n\t\t}(cStats, URL)\n\t}\n\treturn cStats\n}", "func Adapt(h http.Handler, adapters ...Adapter) http.Handler {\n\tfor _, adapter := range adapters {\n\t\th = adapter(h)\n\t}\n\treturn h\n}", "func Adapt(h http.Handler, adapters ...Adapter) http.Handler {\n\tfor _, adapter := range adapters {\n\t\th = adapter(h)\n\t}\n\treturn h\n}", "func Adapt(h http.Handler, adapters ...Adapter) http.Handler {\n\tfor _, adapter := range adapters {\n\t\th = adapter(h)\n\t}\n\treturn h\n}", "func Adapt(h http.Handler, adapters ...Adapter) http.Handler {\n\tfor _, adapter := range adapters {\n\t\th = adapter(h)\n\t}\n\treturn h\n}", "func (c Chain) Wrap(handler http.Handler) http.Handler {\n\tfor i := len(c) - 1; i >= 0; i-- {\n\t\thandler = c[i](handler)\n\t}\n\treturn handler\n}", "func (e *Exporter) Handler() http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tseconds, err := strconv.Atoi(r.Header.Get(\"X-Prometheus-Scrape-Timeout-Seconds\"))\n\t\t// To support also older ones vmagents.\n\t\tif err != nil {\n\t\t\tseconds = 10\n\t\t}\n\n\t\tvar client *mongo.Client\n\t\tctx, cancel := context.WithTimeout(r.Context(), time.Duration(seconds)*time.Second)\n\t\tdefer cancel()\n\n\t\tfilters := r.URL.Query()[\"collect[]\"]\n\n\t\trequestOpts := Opts{}\n\n\t\tif len(filters) == 0 {\n\t\t\trequestOpts = *e.opts\n\t\t}\n\n\t\tfor _, filter := range filters {\n\t\t\tswitch filter {\n\t\t\tcase \"diagnosticdata\":\n\t\t\t\trequestOpts.EnableDiagnosticData = true\n\t\t\tcase \"replicasetstatus\":\n\t\t\t\trequestOpts.EnableReplicasetStatus = true\n\t\t\tcase \"dbstats\":\n\t\t\t\trequestOpts.EnableDBStats = true\n\t\t\tcase \"topmetrics\":\n\t\t\t\trequestOpts.EnableTopMetrics = true\n\t\t\tcase \"indexstats\":\n\t\t\t\trequestOpts.EnableIndexStats = true\n\t\t\tcase \"collstats\":\n\t\t\t\trequestOpts.EnableCollStats = true\n\t\t\t}\n\t\t}\n\n\t\tclient, err = e.getClient(ctx)\n\t\tif err != nil {\n\t\t\te.logger.Errorf(\"Cannot connect to MongoDB: %v\", err)\n\t\t}\n\n\t\tif client != nil && e.getTotalCollectionsCount() <= 0 {\n\t\t\tcount, err := nonSystemCollectionsCount(ctx, client, nil, nil)\n\t\t\tif err == nil {\n\t\t\t\te.lock.Lock()\n\t\t\t\te.totalCollectionsCount = count\n\t\t\t\te.lock.Unlock()\n\t\t\t}\n\t\t}\n\n\t\t// Close client after usage.\n\t\tif !e.opts.GlobalConnPool {\n\t\t\tdefer func() {\n\t\t\t\tif client != nil {\n\t\t\t\t\terr := client.Disconnect(ctx)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\te.logger.Errorf(\"Cannot disconnect client: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}()\n\t\t}\n\n\t\tvar gatherers prometheus.Gatherers\n\n\t\tif !e.opts.DisableDefaultRegistry {\n\t\t\tgatherers = append(gatherers, prometheus.DefaultGatherer)\n\t\t}\n\n\t\tif client != nil {\n\t\t\t// Topology can change between requests, so we need to get it every time.\n\t\t\tti := newTopologyInfo(ctx, client, e.logger)\n\n\t\t\tregistry := e.makeRegistry(ctx, client, ti, requestOpts)\n\t\t\tgatherers = append(gatherers, registry)\n\t\t}\n\n\t\t// Delegate http serving to Prometheus client library, which will call collector.Collect.\n\t\th := promhttp.HandlerFor(gatherers, promhttp.HandlerOpts{\n\t\t\tErrorHandling: promhttp.ContinueOnError,\n\t\t\tErrorLog: e.logger,\n\t\t})\n\n\t\th.ServeHTTP(w, r)\n\t})\n}", "func NewHandler(_ context.Context, svr *server.Server) (http.Handler, apiutil.APIServiceGroup, error) {\n\tautoScalingHandler := http.NewServeMux()\n\trd := render.New(render.Options{\n\t\tIndentJSON: true,\n\t})\n\tautoScalingHandler.Handle(autoScalingPrefix, negroni.New(\n\t\tserverapi.NewRedirector(svr),\n\t\tnegroni.Wrap(NewHTTPHandler(svr, rd))),\n\t)\n\treturn autoScalingHandler, autoscalingServiceGroup, nil\n}", "func NewHandler(ctx context.Context, rsService store.RulesetService, cfg Config) http.Handler {\n\ts := service{\n\t\trulesets: rsService,\n\t}\n\n\tvar logger zerolog.Logger\n\n\tif cfg.Logger != nil {\n\t\tlogger = *cfg.Logger\n\t} else {\n\t\tlogger = zerolog.New(os.Stderr).With().Timestamp().Logger()\n\t}\n\n\tif cfg.Timeout == 0 {\n\t\tcfg.Timeout = 5 * time.Second\n\t}\n\n\tif cfg.WatchTimeout == 0 {\n\t\tcfg.WatchTimeout = 30 * time.Second\n\t}\n\n\trs := rulesetService{\n\t\tservice: &s,\n\t\ttimeout: cfg.Timeout,\n\t\twatchTimeout: cfg.WatchTimeout,\n\t}\n\n\t// router\n\tmux := http.NewServeMux()\n\tmux.Handle(\"/rulesets/\", &rs)\n\n\t// middlewares\n\tchain := []func(http.Handler) http.Handler{\n\t\thlog.NewHandler(logger),\n\t\thlog.AccessHandler(func(r *http.Request, status, size int, duration time.Duration) {\n\t\t\thlog.FromRequest(r).Info().\n\t\t\t\tStr(\"method\", r.Method).\n\t\t\t\tStr(\"url\", r.URL.String()).\n\t\t\t\tInt(\"status\", status).\n\t\t\t\tInt(\"size\", size).\n\t\t\t\tDur(\"duration\", duration).\n\t\t\t\tMsg(\"request received\")\n\t\t}),\n\t\thlog.RemoteAddrHandler(\"ip\"),\n\t\thlog.UserAgentHandler(\"user_agent\"),\n\t\thlog.RefererHandler(\"referer\"),\n\t\tfunc(http.Handler) http.Handler {\n\t\t\treturn mux\n\t\t},\n\t}\n\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t// playing the middleware chain\n\t\tvar cur http.Handler\n\t\tfor i := len(chain) - 1; i >= 0; i-- {\n\t\t\tcur = chain[i](cur)\n\t\t}\n\n\t\t// serving the request\n\t\tcur.ServeHTTP(w, r.WithContext(ctx))\n\t})\n}", "func (p *pipeline) AddFirst(handlers ...Handler) Pipeline {\n\t// checking handler.\n\tcheckHandler(handlers...)\n\n\tfor _, h := range handlers {\n\t\tp.addFirst(h)\n\t}\n\treturn p\n}", "func (fs Filters) Chain(h Handler) Handler {\n\twrappedFilters := make([]Handler, len(fs)+1)\n\twrappedFilters[len(fs)] = h\n\n\tfor i := len(fs) - 1; i >= 0; i-- {\n\t\ti := i\n\t\twrappedFilters[i] = HandlerFunc(func(r *Request) (*Response, error) {\n\t\t\treturn fs[i].Run(r, wrappedFilters[i+1])\n\t\t})\n\t}\n\n\treturn wrappedFilters[0]\n}", "func (c *Context) Next() {\n\tc.index++\n\ts := int8(len(c.handlers))\n\tfor ; c.index < s; c.index++ {\n\t\t// only check method on last handler, otherwise middlewares will never be effected if request method is not matched\n\t\t// 检测最后一个注册函数是否匹配method\n\t\tif c.index == s-1 && c.method != c.Request.Method {\n\t\t\tcode := http.StatusMethodNotAllowed\n\t\t\t//c.Error = ecode.MethodNotAllowed\n\t\t\thttp.Error(c.Writer, http.StatusText(code), code)\n\t\t\treturn\n\t\t}\n\t\tc.handlers[c.index](c)\n\t}\n}", "func newHandler(conn net.Conn, l logger, c *config, users map[string]string) (*handler, error) {\n\t// get current directory\n\tdir, err := os.Getwd()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// create a new handler object\n\th := &handler{\n\t\tconfig: c,\n\t\tconn: conn,\n\t\tlogger: l,\n\t\tdir: dir,\n\t\tusers: users,\n\t\tisLoggedIn: false,\n\t\tcommands: make(map[CommandCode]handleFunc),\n\t}\n\n\th.logMessage(fmt.Sprintf(\"Accepted connection from %v\", h.conn.RemoteAddr()))\n\n\t// initialize commands for not logged in state\n\th.initCommandTable()\n\n\t//initialize default data connection\n\tif h.config.pasv {\n\t\th.initPassiveDataConn()\n\t} else {\n\t\t// calculate default data port\n\t\thost, port, err := net.SplitHostPort(conn.RemoteAddr().String())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvar portNum int\n\t\t_, err = fmt.Sscanf(port, \"%d\", &portNum)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tportNum++\n\t\tport = fmt.Sprintf(\"%d\", portNum)\n\t\th.initActiveDataConn(net.JoinHostPort(host, port))\n\t}\n\n\treturn h, nil\n}", "func NewStatsHandler(tracker Tracker) *StatsHandler {\n\treturn &StatsHandler{\n\t\ttracker: tracker,\n\t}\n}", "func NewHandler() inputs.Handler {\n\treturn &Handler{\n\t\tin: make(chan inputs.Data, 20),\n\t\thosts: []string{},\n\t\tcreds: []scanners.Credential{},\n\t}\n}", "func (handler MetricsHandler) Any(c echo.Context) error {\n\tswitch c.Get(\"Method\").(string) {\n\tcase http.MethodPost:\n\t\treturn handler.Create(c)\n\t}\n\treturn RawResponse(c, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)\n}", "func NewHandler(c net.Client, priv *key.Pair, sh *key.Share, group *key.Group, s Store) *Handler {\n\tidx, exists := group.Index(priv.Public)\n\tif !exists {\n\t\t// XXX\n\t\tpanic(\"that's just plain wrong and I should be an error\")\n\t}\n\taddr := group.Nodes[idx].Addr\n\treturn &Handler{\n\t\tclient: c,\n\t\tgroup: group,\n\t\tshare: sh,\n\t\tpub: share.NewPubPoly(key.G2, key.G2.Point().Base(), sh.Commits),\n\t\tindex: idx,\n\t\tstore: s,\n\t\tclose: make(chan bool),\n\t\tcache: newSignatureCache(),\n\t\taddr: addr,\n\t}\n}", "func gumballOrderStatusHandlerAny(formatter *render.Render) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, req *http.Request) {\n\t\t\n\t\tparams := mux.Vars(req)\n\t\tvar uuid string = params[\"id\"]\n\t\tfmt.Println( \"Order Params ID: \", uuid )\n\n\t\tc1 := make(chan order)\n \tc2 := make(chan order)\n \tc3 := make(chan order)\n\n\t\tif uuid == \"\" {\n\t\t\tformatter.JSON(w, http.StatusBadRequest, \"Invalid Request. Order ID Missing.\")\n\t\t} else {\n\n\t\t\tgo getOrderServer1(uuid, c1) \n\t\t\tgo getOrderServer2(uuid, c2) \n\t\t\tgo getOrderServer3(uuid, c3) \n\n\t\t\tvar ord order\n\t\t \tselect {\n\t\t\t case ord = <-c1:\n\t\t\t fmt.Println(\"Received Server1: \", ord)\n\t\t\t case ord = <-c2:\n\t\t\t fmt.Println(\"Received Server2: \", ord)\n\t\t\t case ord = <-c3:\n\t\t\t fmt.Println(\"Received Server3: \", ord)\n\t\t }\n\n\t\t\tif ord == (order{}) {\n\t\t\t\tformatter.JSON(w, http.StatusBadRequest, \"\")\n\t\t\t} else {\n\t\t\t\tfmt.Println( \"Order: \", ord )\n\t\t\t\tformatter.JSON(w, http.StatusOK, ord)\n\t\t\t}\n\t\t}\n\t}\n}", "func (c *Chain) Append(handlers ...func(http.Handler) http.Handler) *Chain {\n\tc = New(appendHandlers(c.hs, handlers...)...)\n\n\treturn c\n}", "func (ctx *Context) Next() {\n\tfor {\n\t\tctx.handlerIndex++\n\t\tif ctx.handlerIndex >= len(ctx.handlers) {\n\t\t\tctx.handlerIndex--\n\t\t\tbreak\n\t\t}\n\t\thandler := ctx.handlers[ctx.handlerIndex]\n\t\tif handler != nil {\n\t\t\thandler(ctx)\n\t\t}\n\t}\n}", "func NewMOptionsWithHandler(o *options) OptionsWithHandler {\n\treturn OptionsWithHandler{\n\t\to,\n\t}\n}", "func NewHandler(s service) *chi.Mux {\n\tr := chi.NewRouter()\n\n\tcors := cors.New(cors.Options{\n\t\t// AllowedOrigins: []string{\"https://foo.com\"}, // Use this to allow specific origin hosts\n\t\tAllowedOrigins: []string{\"*\"},\n\t\t// AllowOriginFunc: func(r *http.Request, origin string) bool { return true },\n\t\tAllowedMethods: []string{\"GET\", \"POST\", \"OPTIONS\"},\n\t\tAllowedHeaders: []string{\"Accept\", \"Authorization\", \"Content-Type\", \"X-CSRF-Token\"},\n\t\tExposedHeaders: []string{\"Link\"},\n\t\tAllowCredentials: true,\n\t\tMaxAge: 300, // Maximum value not ignored by any of major browsers\n\t})\n\tr.Use(cors.Handler)\n\n\t// Public routes\n\tr.Group(func(r chi.Router) {\n\t\tr.Get(\"/list\", getPluginListHandler(s))\n\t\tr.Get(\"/{plugin}/{format}\", getFeedHandler(s))\n\t})\n\n\tr.Group(func(r chi.Router) {\n\t\tr.Use(s.authenticator)\n\t\tr.Post(\"/{plugin}/refresh\", refreshFeedHandler(s))\n\t})\n\n\treturn r\n}", "func TypedHandlers(handlers ...TypedHandler) TypedHandler {\n\tres := TypedHandler{}\n\tfor _, typed := range handlers {\n\t\tfor commandType, handler := range typed {\n\t\t\tres[commandType] = handler\n\t\t}\n\t}\n\treturn res\n}", "func useMiddlewareHandler(h http.Handler, mw ...Middleware) http.Handler {\n\tfor i := range mw {\n\t\th = mw[len(mw)-1-i](h)\n\t}\n\n\treturn h\n}" ]
[ "0.5196978", "0.49642527", "0.48838636", "0.4856744", "0.48155951", "0.46619335", "0.46383664", "0.46271682", "0.45905352", "0.45672196", "0.45584178", "0.454697", "0.4531779", "0.45313132", "0.45251963", "0.45178384", "0.449293", "0.4485742", "0.44678187", "0.446136", "0.44535813", "0.44512615", "0.4439239", "0.44390786", "0.44360256", "0.44236073", "0.44185078", "0.44125903", "0.44047254", "0.44047254", "0.43826517", "0.43795708", "0.43774635", "0.43573275", "0.43536732", "0.43265605", "0.43240866", "0.43221667", "0.43155286", "0.43057838", "0.42941722", "0.42907432", "0.42860067", "0.42617622", "0.42539892", "0.4250053", "0.42255098", "0.4224486", "0.41887972", "0.41849825", "0.41645217", "0.4162796", "0.41580683", "0.41565946", "0.4154822", "0.4154405", "0.41481423", "0.4147509", "0.41394636", "0.41335073", "0.41257665", "0.41237444", "0.4111412", "0.41114014", "0.41054228", "0.41010627", "0.40986156", "0.4093495", "0.4089154", "0.40883192", "0.4087917", "0.40833393", "0.40823528", "0.4079336", "0.4074269", "0.40740538", "0.40738222", "0.4073482", "0.4073482", "0.4073482", "0.4073482", "0.4072841", "0.40651622", "0.40588957", "0.4033902", "0.40329105", "0.40325567", "0.40322757", "0.4026548", "0.40239906", "0.4015926", "0.40154043", "0.40134728", "0.40106574", "0.4009921", "0.3995161", "0.3994925", "0.399085", "0.39876485", "0.39827886" ]
0.833905
0
Separated messages The first is message Other is key => value
Отдельные сообщения Первое сообщение Other — это ключ => значение
func separatedMessages(values ...interface{}) (string, []interface{}) { if len(values)%2 == 0 { return ``, values } return values[0].(string), values[1:] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func splitMessage(msg string, splitLen int) (msgs []string) {\n\t// This is quite short ;-)\n\tif splitLen < 10 {\n\t\tsplitLen = 10\n\t}\n\tfor len(msg) > splitLen {\n\t\tidx := indexFragment(msg[:splitLen])\n\t\tif idx < 0 {\n\t\t\tidx = splitLen\n\t\t}\n\t\tmsgs = append(msgs, msg[:idx] + \"...\")\n\t\tmsg = msg[idx:]\n\t}\n\treturn append(msgs, msg)\n}", "func parseMessage(buff []byte,len int) []string {\n\tanalMsg := make([]string, 0)\n\tstrNow := \"\"\n\tfor i := 0; i < len; i++ {\n\t\tif string(buff[i:i + 1]) == \":\" {\n\t\t\tanalMsg = append(analMsg, strNow)\n\t\t\tstrNow = \"\"\n\t\t} else {\n\t\t\tstrNow += string(buff[i:i + 1])\n\t\t}\n\t}\n\tanalMsg = append(analMsg, strNow)\n\treturn analMsg\n}", "func Decode(msg string) MessageTemp {\n var r = make([]string,15)\n r = strings.Split(msg, \";\")\n var result = MessageTemp{}\n for _,v := range r {\n key_value := strings.Split(v,\"=\")\n switch key_value[0] {\n case \"35\":\n if key_value[1]==\"8\"{ // 35=8; 股票交易相关信息\n result.order_type = \"trade\"\n } else if key_value[1]==\"9\"{ // 35=9; 用户相关信息\n result.order_type = \"user\"\n } else if key_value[1]==\"10\"{ //35=10; 查询order book\n result.order_type = \"view\"\n }\n case \"44\":\n result.price, _ = strconv.Atoi(key_value[1])\n case \"11\":\n result.stock_id, _ = strconv.Atoi(key_value[1])\n case \"38\":\n result.quantity, _ = strconv.Atoi(key_value[1])\n case \"54\":\n if key_value[1]==\"1\"{\n result.trade_type = \"buy\"\n } else if key_value[1]==\"2\"{\n result.trade_type = \"sell\"\n }\n case \"5001\":\n result.username = key_value[1]\n case \"5002\":\n result.password = key_value[1]\n }\n }\n //fmt.Println(result)\n return result\n}", "func Bytes(input []byte) *Message {\n\tlex := lexer{\n\t\tinput: input,\n\t}\n\tlex.next()\n\n\t// firstKeyPos is the position of the first key in the message\n\t//\n\t// consider the following example message:\n\t//\n\t// this is a message key=1 key=2 more message stuff key=3\n\t// ^\n\t// if a message has key=val and then text that |\n\t// does not match key=val, then the key=val is |\n\t// not parsed for example, the first key is here ----+\n\tvar firstKeyPos int\n\n\t// count kv pairs so that we can allocate once only\n\tvar kvCount int\n\n\t// iterate through the message looking for the position\n\t// before which we will not be looking for key/val pairs\n\tfor lex.token != tokEOF {\n\t\tfor lex.notMatch(tokKey, tokQuotedKey, tokEOF) {\n\t\t\tfirstKeyPos = 0\n\t\t\tlex.next()\n\t\t}\n\t\tif lex.token == tokEOF {\n\t\t\tbreak\n\t\t}\n\t\tfirstKeyPos = lex.pos\n\t\tfor lex.match(tokKey, tokQuotedKey) {\n\t\t\tkvCount += 2\n\t\t\tlex.next() // skip past key\n\t\t\tlex.next() // skip past value\n\t\t\tlex.skipWS()\n\t\t}\n\t}\n\n\tlex.rewind()\n\tlex.skipWS()\n\tmessage := newMessage()\n\tunquoteBuf := message.buf[:]\n\tvar unquoted []byte\n\n\tif firstKeyPos == 0 {\n\t\t// there are no key/value pairs\n\t\tmessage.Text = lex.input\n\t} else {\n\t\tif cap(message.List) < kvCount {\n\t\t\tmessage.List = make([][]byte, 0, kvCount)\n\t\t}\n\t\tvar pos int\n\t\tfor lex.pos < firstKeyPos {\n\t\t\tpos = lex.pos\n\t\t\tlex.next()\n\t\t}\n\t\tmessage.Text = lex.input[:pos]\n\t\tfor lex.match(tokKey, tokQuotedKey) {\n\t\t\tif lex.token == tokKey {\n\t\t\t\tmessage.List = append(message.List, lex.lexeme())\n\t\t\t} else {\n\t\t\t\tunquoted, unquoteBuf = unquote(lex.lexeme(), unquoteBuf)\n\t\t\t\tmessage.List = append(message.List, unquoted)\n\t\t\t}\n\t\t\tlex.next()\n\n\t\t\tswitch lex.token {\n\t\t\tcase tokQuoted:\n\t\t\t\tunquoted, unquoteBuf = unquote(lex.lexeme(), unquoteBuf)\n\t\t\t\tmessage.List = append(message.List, unquoted)\n\t\t\tdefault:\n\t\t\t\tmessage.List = append(message.List, lex.lexeme())\n\t\t\t}\n\n\t\t\tlex.next()\n\t\t\tlex.skipWS()\n\t\t}\n\t}\n\n\tmessage.Text = bytes.TrimSpace(message.Text)\n\tmessage.used = bufLength - len(unquoteBuf)\n\treturn message\n}", "func wordsMessage(str string) (buf []string, result string) {\n buf = make([]string, 5);\n var start, end, pos int;\n result = \"\";\n leng := len(str);\n for {\n for start < leng && str[start] == ' ' { start++; }\n if start == leng { break; }\n if str[start] == ':' { result = str[start+1:len(str)]; break; }\n for end = start+1; end < leng && str[end] != ' '; { end++; }\n if pos >= len(buf) {\n buf2 := make([]string, len(buf)*2);\n for i, x := range buf { buf2[i] = x; }\n buf = buf2;\n }\n buf[pos] = str[start:end];\n pos++;\n start = end;\n }\n buf = buf[0:pos];\n return;\n}", "func Msg(logger log.Logger, message string, keyvals ...interface{}) error {\n\tprepended := make([]interface{}, 0, len(keyvals)+2)\n\tprepended = append(prepended, structure.MessageKey, message)\n\tprepended = append(prepended, keyvals...)\n\treturn logger.Log(prepended...)\n}", "func _messsageDecode(b *[]byte) (*Message, error) {\n\n\tmessage := Message{}\n\n\tmsg := bytes.Split(*b, elemSep)\n\t// if the length of msg slice is less than the message is invalid\n\tif len(msg) < 2 {\n\t\treturn nil, errors.New(fmt.Sprintf(\"Invalid message : invalid msg len %d\", len(msg)))\n\t}\n\n\t// elemCount counts the number of elements added to the message like MsgType,Msg etc..\n\t// the elemCount should be equal to len(msg) after the loop coming\n\tvar elemCount int\n\n\t// loop until the last element\n\t// the last element is the payload\n\tfor index, element := range msg {\n\n\t\tif (index + 1) == len(msg) {\n\n\t\t\tmessage.Msg = element\n\t\t\telemCount++\n\t\t\tbreak\n\n\t\t}\n\n\t\telem := bytes.Split(element, keyValSep)\n\n\t\tif len(elem) < 2 {\n\t\t\treturn nil, errors.New(fmt.Sprintf(\"Invalid message : invalid length %d elemCounted %d\",len(elem),elemCount))\n\t\t}\n\n\t\t// find the approprite elem of message\n\t\t// if unknown elem is sent then this is an errors\n\t\tswitch string(elem[0]) {\n\n\t\tcase \"ClientID\":\n\n\t\t\tmessage.ClientID = string(elem[1])\n\t\t\telemCount++\n\n\t\tcase \"ReceiverID\":\n\n\t\t\tmessage.ReceiverID = string(elem[1])\n\t\t\telemCount++\n\n\t\tcase \"RoomID\":\n\n\t\t\tmessage.RoomID = string(elem[1])\n\t\t\telemCount++\n\n\t\tcase \"Info\":\n\n\t\t\tmessage.Info = string(elem[1])\n\t\t\telemCount++\n\n\t\tcase \"MsgType\":\n\n\t\t\tmsgType, err := strconv.ParseInt(string(elem[1]), 10, 16)\n\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tmessage.MsgType = int(msgType)\n\t\t\telemCount++\n\n\t\tdefault: // unknown elemetn which is a error\n\n\t\t\treturn nil, errors.New(fmt.Sprintf(\"Invalid message : Unknown Elem(%s)\", string(elem[0])))\n\n\t\t} // switch case ends\n\n\t} // for loop ends\n\n\tif elemCount != len(msg) {\n\t\treturn nil, errors.New(\"Invalid message\")\n\t}\n\n\t// Now we have a valid message\n\n\treturn &message, nil\n\n}", "func (s MessageState) MessageParts() []string {\n\treturn strings.Split(s.Event.Message.Content, \" \")\n}", "func flatten(entry logEntry) (string, error) {\n\tvar msgValue string\n\tvar errorValue error\n\tif len(entry.Values)%2 == 1 {\n\t\treturn \"\", errors.New(\"log entry cannot have odd number off keyAndValues\")\n\t}\n\n\tkeys := make([]string, 0, len(entry.Values)/2)\n\tvalues := make(map[string]interface{}, len(entry.Values)/2)\n\tfor i := 0; i < len(entry.Values); i += 2 {\n\t\tk, ok := entry.Values[i].(string)\n\t\tif !ok {\n\t\t\tpanic(fmt.Sprintf(\"key is not a string: %s\", entry.Values[i]))\n\t\t}\n\t\tvar v interface{}\n\t\tif i+1 < len(entry.Values) {\n\t\t\tv = entry.Values[i+1]\n\t\t}\n\t\tswitch k {\n\t\tcase \"msg\":\n\t\t\tmsgValue, ok = v.(string)\n\t\t\tif !ok {\n\t\t\t\tpanic(fmt.Sprintf(\"the msg value is not of type string: %s\", v))\n\t\t\t}\n\t\tcase \"error\":\n\t\t\terrorValue, ok = v.(error)\n\t\t\tif !ok {\n\t\t\t\tpanic(fmt.Sprintf(\"the error value is not of type error: %s\", v))\n\t\t\t}\n\t\tdefault:\n\t\t\tif _, ok := values[k]; !ok {\n\t\t\t\tkeys = append(keys, k)\n\t\t\t}\n\t\t\tvalues[k] = v\n\t\t}\n\t}\n\tstr := \"\"\n\tif entry.Prefix != \"\" {\n\t\tstr += fmt.Sprintf(\"[%s] \", entry.Prefix)\n\t}\n\tstr += msgValue\n\tif errorValue != nil {\n\t\tif msgValue != \"\" {\n\t\t\tstr += \": \"\n\t\t}\n\t\tstr += errorValue.Error()\n\t}\n\tfor _, k := range keys {\n\t\tprettyValue, err := pretty(values[k])\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tstr += fmt.Sprintf(\" %s=%s\", k, prettyValue)\n\t}\n\treturn str, nil\n}", "func group(msg *daemon.Msg) (messages []*emailq.Msg) {\n\thostMap := make(map[string][]string)\n\n\tfor _, to := range msg.To {\n\t\thost := strings.Split(to, \"@\")[1]\n\t\thostMap[host] = append(hostMap[host], to)\n\t}\n\n\tfor k, v := range hostMap {\n\t\tmessages = append(messages, &emailq.Msg{\n\t\t\tFrom: msg.From,\n\t\t\tHost: k,\n\t\t\tTo: v,\n\t\t\tData: msg.Data,\n\t\t})\n\t}\n\n\treturn messages\n}", "func group(msg *daemon.Msg) (messages []*emailq.Msg) {\n\thostMap := make(map[string][]string)\n\n\tfor _, to := range msg.To {\n\t\thost := strings.Split(to, \"@\")[1]\n\t\thostMap[host] = append(hostMap[host], to)\n\t}\n\n\tfor k, v := range hostMap {\n\t\tmessages = append(messages, &emailq.Msg{\n\t\t\tFrom: msg.From,\n\t\t\tHost: k,\n\t\t\tTo: v,\n\t\t\tData: msg.Data,\n\t\t})\n\t}\n\n\treturn messages\n}", "func processMsg(msg *sarama.ConsumerMessage) {\n\tvar str interface{}\n\tif err := json.Unmarshal(msg.Value, &str); err != nil {\n\t}\n\ts, _ := json.MarshalIndent(str, \"\", \" \")\n\n\tfmt.Printf(\"Offset: %d Key: %s\\n\", msg.Offset, msg.Key)\n\tfmt.Printf(\"%s\\n\", s)\n\tfmt.Printf(\"-----\\n\")\n}", "func SplitMessage(msg string) (subject, message string) {\n\tparts := strings.SplitN(msg, \"\\n\", 2)\n\tsubject = strings.TrimRight(parts[0], \"\\r\") // better safe than sorry\n\tif len(parts) == 1 {\n\t\treturn subject, \"\"\n\t}\n\tmessage = parts[1]\n\treturn\n}", "func lines2msg(lines []string) (msg *LogMsg, skipped, remlines []string) {\n\tif len(lines) == 0 {\n\t\treturn nil, nil, nil\n\t}\n\tskipped = make([]string, 0)\n\tmsg = &LogMsg{msg: \"\", kind: \"\"}\n\tok, n := false, -1\n\tfor i, line := range lines {\n\t\tif (msg.msg != \"\") && ((n > 0) || strings.HasPrefix(line, \" \")) {\n\t\t\tmsg.msg = msg.msg + \"\\n\" + line // amend with previous line\n\t\t\tn--\n\n\t\t} else if msg.msg != \"\" {\n\t\t\treturn msg, skipped, lines[i:]\n\n\t\t} else {\n\t\t\tmsg.msg = line\n\t\t\tif ok, n = msg.parseHeadLine(); !ok {\n\t\t\t\tmsg.msg = \"\"\n\t\t\t\tif strings.Trim(line, \"\\t \\r\\n\") != \"\" {\n\t\t\t\t\tskipped = append(skipped, line)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn msg, skipped, nil\n}", "func (kvs *keyValueServer) parseRequest(message string) []string {\n\tn := len(message)\n\ta := make([]string, 3)\n\tb := []byte(message)\n\tindex := 0\n\tstart := 0\n\tfor i := 0; i < n-1; i++ {\n\t\tif b[i] != ',' {\n\t\t\tcontinue\n\t\t}\n\t\ta[index] = string(b[start:i])\n\t\tindex++\n\t\tstart = i + 1\n\t}\n\ta[index] = string(b[start : n-1])\n\treturn a\n}", "func extractKvp(msg string) ([][]string, error) {\n\ttuples := [][]string{}\n\tlogger.Debugf(\"matching `%s`\", msg)\n\n\tfor i := 0; i < len(msg); {\n\t\tmatch := kvpRegex.FindStringSubmatchIndex(msg[i:])\n\n\t\tif match == nil {\n\t\t\treturn nil, errors.New(\"Parsing error: invalid kvp format\")\n\t\t}\n\n\t\tif match[0] != 0 {\n\t\t\treturn nil, errors.New(\"Parsing error: invalid kvp format\")\n\t\t}\n\n\t\tlogger.Debugf(\"Match? %v, `%s`\", match, msg[i+match[0]:i+match[1]])\n\n\t\ttuples = append(tuples, []string{msg[i+match[2] : i+match[3]], msg[i+match[4] : i+match[5]]})\n\n\t\tlogger.Debugf(\"%+v\", tuples)\n\n\t\ti += match[1]\n\t}\n\n\treturn tuples, nil\n}", "func ParseMessage_KLog(boot_ts time.Time, data string) (syslog5424.Message,error) {\n\tlog.SetFlags(log.Ltime | log.Lshortfile)\n\n\tpart\t:= FieldsFuncN(data, 4, get_klog_tokenizer())\n\n\tif (len(part) < 4){\n\t\tlog.Println(data)\n\t\tfor pi := range part {\n\t\t\tlog.Println(part[pi])\n\t\t}\n\t}\n\n\tswitch len(part) {\n\n\tcase 2:\n\t\tprio, err := strconv.Atoi(part[0])\n\t\tif err != nil {\n\t\t\treturn syslog5424.EmptyMessage(),errors.New(\"Wrong Priority :\"+string(part[0]))\n\t\t}\n\n\t\treturn\tsyslog5424.CreateMessage(\"-\", syslog5424.Priority(prio), part[2]),nil\n\n\tcase 3:\n\t\t// (kern) 0 * 8 + 6 (info)\n\t\treturn\tsyslog5424.CreateMessage(\"-\", syslog5424.Priority(6), part[2]).Delta(boot_ts, part[0], part[1]),nil\n\n\tcase 4:\n\t\tprio, err := strconv.Atoi(part[0])\n\t\tif err != nil {\n\t\t\treturn syslog5424.EmptyMessage(),errors.New(\"Wrong Priority :\"+string(part[0]))\n\t\t}\n\t\treturn\tsyslog5424.CreateMessage(\"-\", syslog5424.Priority(prio), part[3]).Delta(boot_ts, part[1], part[2]),nil\n\n\tdefault:\n\t\t// (kern) 0 * 8 + 6 (info)\n\t\treturn\tsyslog5424.CreateMessage(\"-\", syslog5424.Priority(6), data),nil\n\t}\n}", "func DeconstructConnMonVal(connmonval []byte) ([]byte,[]byte) {\n b := bytes.SplitN(connmonval,SEP,2)\n return b[0],b[1]\n}", "func parseMsg(message string, terms []string) ([]byte, []string, string, []*db.WebLink) {\n\tl := createMsgLexer(\"msgLex\", message, LexMsg)\n\tslashTag := \"\"\n\tweblinks := []*db.WebLink{}\n\tvar seen map[string]bool\n\tvar item lex.Item\n\tvar val string\n\tvar prefix string\n\tdomly := db.Domly{}\n\n\tfor {\n\t\titem = <-l.Items\n\t\tswitch item.Typ {\n\t\tcase ItemWord:\n\t\t\tprefix = db.WordTerm\n\t\tcase ItemEspraURI:\n\t\t\tprefix = db.EspraURITerm\n\t\tcase ItemHashTag:\n\t\t\tprefix = db.HashTagTerm\n\t\tcase ItemURI:\n\t\t\tprefix = db.URITerm\n\t\tcase ItemSlashTag:\n\t\t\tprefix = db.SlashTagTerm\n\t\t}\n\n\t\tval = prefix + strings.ToLower(item.Val)\n\t\tif !seen[val] {\n\t\t\tseen[val] = true\n\t\t}\n\t\tterms = append(terms, item.Val)\n\n\t}\n\treturn []byte(\"[]\"), terms, slashTag, weblinks\n}", "func mapper(key string) (string, string, string, string) {\n\tvals := strings.Split(key, \":\")\n\treturn vals[0], vals[1], vals[2], vals[3]\n}", "func stompParser(msg []byte) (StreamMessage, error) {\n\tbuf := bytes.NewBuffer(msg)\n\tmsgPart := 0\n\tvar sm StreamMessage\n\theaders := make(map[string]string)\n\tfor {\n\t\tline, err := buf.ReadBytes(eol)\n\t\tif err == io.EOF {\n\t\t\treturn sm, nil\n\t\t}\n\t\tif err != nil {\n\t\t\treturn sm, errors.Wrap(err, \"ReadBytes was not able to understand the message\")\n\t\t}\n\t\t// This means message body is coming next\n\t\tif bytes.Equal(line, []byte{10}) {\n\t\t\tmsgPart = -1\n\t\t\tcontinue\n\t\t}\n\t\t// This means there is no body message and we are done\n\t\tif bytes.Equal(line, []byte{0}) {\n\t\t\treturn sm, nil\n\t\t}\n\t\tif msgPart == 0 {\n\t\t\tsm.Command = cleanCommand(line)\n\t\t\tmsgPart++\n\t\t\tcontinue\n\t\t}\n\t\tif msgPart == -1 {\n\t\t\tswitch sm.Command {\n\t\t\tcase \"SEND\", \"MESSAGE\", \"ERROR\":\n\t\t\t\tvar b interface{}\n\t\t\t\tif err = json.Unmarshal(line, &b); err != nil {\n\t\t\t\t\treturn sm, errors.Wrap(err, \"Unable to unmarshal body\")\n\t\t\t\t}\n\t\t\t\tsm.Body = b\n\t\t\t\treturn sm, nil\n\t\t\tdefault:\n\t\t\t\treturn sm, nil\n\t\t\t}\n\t\t}\n\t\theader := strings.Trim(string(line), \"\\r\\n\\x00\")\n\t\tspLine := strings.Split(header, \":\")\n\t\theaders[spLine[0]] = spLine[1]\n\t\tbHeaders, err := json.Marshal(headers)\n\t\tif err != nil {\n\t\t\treturn sm, err\n\t\t}\n\t\tif err = json.Unmarshal(bHeaders, &sm.Headers); err != nil {\n\t\t\treturn sm, err\n\t\t}\n\t}\n}", "func MessageHandler(w http.ResponseWriter, r *http.Request) {\n\n\tvars := mux.Vars(r)\n\tkey := vars[\"key\"]\n\tdb, err := bolt.Open(\"messages.db\", 0777, nil)\n\n\tswitch r.Method {\n\tcase \"GET\":\n\t\treceiver := strings.Split(key, \"-\")[1]\n\t\tkey = strings.Split(key, \"-\")[0]\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t} else {\n\t\t\tdb.Update(func(tx *bolt.Tx) error {\n\t\t\t\tif receiver == \"\" {\n\t\t\t\t\tio.WriteString(w, \"[]\")\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\n\t\t\t\t//messagesBucket := tx.Bucket([]byte(key))\n\t\t\t\tmessagesBucket, _ := tx.CreateBucketIfNotExists([]byte(key))\n\t\t\t\tjsonStr := \"[\"\n\t\t\t\tmessagesBucket.ForEach(func(k, v []byte) error {\n\t\t\t\t\tvar messageItem message\n\t\t\t\t\tjson.Unmarshal(v, &messageItem)\n\t\t\t\t\tif (messageItem.Name == receiver && messageItem.From == key) || (messageItem.Name == key && messageItem.From == receiver) {\n\t\t\t\t\t\tjsonStr += string(v)\n\t\t\t\t\t\tjsonStr += \",\"\n\t\t\t\t\t}\n\t\t\t\t\treturn nil\n\t\t\t\t})\n\t\t\t\tjsonStr = strings.TrimSuffix(jsonStr, \",\")\n\t\t\t\tjsonStr += \"]\"\n\t\t\t\tio.WriteString(w, jsonStr)\n\t\t\t\treturn nil\n\t\t\t})\n\t\t}\n\tcase \"POST\":\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t} else {\n\t\t\tdb.Update(func(tx *bolt.Tx) error {\n\t\t\t\tdecoder := json.NewDecoder(r.Body)\n\t\t\t\tvar m message\n\t\t\t\terrdec := decoder.Decode(&m)\n\t\t\t\tif errdec != nil {\n\t\t\t\t\tpanic(errdec)\n\t\t\t\t}\n\n\t\t\t\tif key == \"\" {\n\t\t\t\t\tio.WriteString(w, \"Please provide the recipients name\")\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\n\t\t\t\tb, _ := json.Marshal(m)\n\t\t\t\tdata := string(b[:])\n\n\t\t\t\tmessagesBucket, _ := tx.CreateBucketIfNotExists([]byte(key))\n\t\t\t\tmessagesBucket.Put([]byte(m.Time), []byte(data))\n\n\t\t\t\tmessagesBucketOwn, _ := tx.CreateBucketIfNotExists([]byte(m.From))\n\t\t\t\tmessagesBucketOwn.Put([]byte(m.Time), []byte(data))\n\n\t\t\t\tio.WriteString(w, \"Success\")\n\t\t\t\treturn nil\n\t\t\t})\n\t\t}\n\t}\n\tdb.Close()\n}", "func formatIncomingMessage(incomingMessage *models.IncomingMessage) ([]models.DestinationMessage, error) {\n\n\tif incomingMessage == nil {\n\t\treturn nil, errors.New(\"Incoming message is empty\")\n\t}\n\n\tdestinationMessages := make([]models.DestinationMessage, len(incomingMessage.Message.Partitions))\n\n\tfor i := 0; i < len(incomingMessage.Message.Partitions); i++ {\n\t\tdestinationMessages[i].Data.Name = incomingMessage.Message.Partitions[i].Name\n\t\tdestinationMessages[i].Data.DriveType = incomingMessage.Message.Partitions[i].DriveType\n\t\tdestinationMessages[i].Data.UsedSpaceBytes = incomingMessage.Message.Partitions[i].Metric.UsedSpaceBytes\n\t\tdestinationMessages[i].Data.TotalSpaceBytes = incomingMessage.Message.Partitions[i].Metric.TotalSpaceBytes\n\t\tdestinationMessages[i].Data.CreateAtTimeUTC = incomingMessage.Message.CreateAtTimeUTC\n\t}\n\n\treturn destinationMessages, nil\n}", "func messagePairs(msgs []*message) <-chan messagePair {\n\tch := make(chan messagePair)\n\tgo func() {\n\t\tfor i := 0; i < len(msgs)-1; i++ {\n\t\t\tfor j := i + 1; j < len(msgs); j++ {\n\t\t\t\tch <- messagePair{msgs[i], msgs[j]}\n\t\t\t}\n\t\t}\n\t\tclose(ch)\n\t}()\n\treturn ch\n}", "func parse(b []byte) *Message {\n var servername, nick, user, host string\n var command, target, msg string\n words := bytes.Split(b, bytes.NewBufferString(\" \").Bytes())\n\n if len(words) >= 4 {\n if match, _ := regexp.Match(\"^:\", words[0]); match {\n if match, _ := regexp.Match(\"!|@\", words[0]); match {\n i := 1\n for words[0][i] != '!' { i++ }\n nick = bytes.NewBuffer(words[0][1:i]).String()\n j := i+1\n for words[0][j] != '@' { j++ }\n var wordstart int = i + 1\n if words[0][i+1] == '~' {\n wordstart = i+2\n }\n\n user = bytes.NewBuffer(words[0][wordstart:j]).String()\n k := j+1\n host = bytes.NewBuffer(words[0][k:len(words[0])]).String()\n } else {\n servername = bytes.NewBuffer(words[0][1:len(words[0])]).String()\n }\n }\n command = bytes.NewBuffer(words[1]).String()\n target = bytes.NewBuffer(words[2]).String()\n str := bytes.Join(words[3:len(words)], bytes.NewBufferString(\" \").Bytes())\n msg = bytes.NewBuffer(str[1:len(str)]).String()\n } else {\n if match, _ := regexp.Match(\"PING\", words[0]); match {\n command = \"PING\"\n host= bytes.NewBuffer(words[1][1:len(words[1])]).String()\n fmt.Println(host)\n }\n }\n\n return &Message{\n Servername: servername,\n Nickname: nick,\n Username: user,\n Hostname: host,\n Command: command,\n Target: target,\n Message: msg,\n }\n}", "func BuildMessage(content string) *Message {\n msg := new(Message)\n fields := strings.Split(content, \"][\")\n for idx, field := range fields {\n s := strings.Trim(field, \"[]\")\n switch idx {\n case 0:\n msg.Priority = s\n case 1:\n msg.Status = s\n case 2:\n msg.Endpoint = s\n case 3:\n case 4:\n msg.Content = s\n case 5:\n l := strings.Split(s, \" \")\n t := l[1:]\n ts := strings.Join(t, \"T\")\n msg.Timestamp = ts\n default:\n }\n }\n return msg\n}", "func GetMessageGroups(m string, gl int) []string {\n\tp := []string{}\n\n\tfor i := 0; i < gl; i++ {\n\t\tg := \"\"\n\t\tc := i\n\t\tfor c < len(m) {\n\t\t\tg += string(m[c])\n\t\t\tc += gl\n\t\t}\n\n\t\tp = append(p, g)\n\t}\n\n\treturn p\n}", "func (p SplitToBatch) ProcessMessage(m types.Message) ([]types.Message, types.Response) {\n\tvar splitParts [][]byte\n\tm.Iter(func(i int, b types.Part) error {\n\t\tsplitParts = append(splitParts, bytes.Split(b.Get(), []byte(\"\\n\"))...)\n\t\treturn nil\n\t})\n\n\treturn []types.Message{message.New(splitParts)}, nil\n}", "func (m *Message) extract(b []byte) {\n\tslices := bytes.Split(b, []byte{'|'})\n\ti := bytes.Index(b, []byte{'|'})\n\tm.Type = \"default\"\n\tif i != -1 {\n\t\t// well I know how I'd do it in python\n\t\t// this seems a little awkward\n\t\tm.dirtyfields = make(map[int]bool)\n\t\tif res, err := get(0, slices); err == nil {\n\t\t\tm.setField(0, string(res))\n\t\t}\n\t}\n\tif res, err := get(1, slices); err == nil {\n\t\tif string(res) != \"\" {\n\t\t\tm.setField(1, string(res))\n\t\t}\n\t}\n\tif res, err := get(2, slices); err == nil {\n\t\tm.setField(2, string(res))\n\t}\n\tif res, err := get(3, slices); err == nil {\n\t\tif t, err2 := strconv.Atoi(string(res)); err2 == nil {\n\t\t\tTimeout, _ := time.ParseDuration(fmt.Sprintf(\"%ds\", t))\n\t\t\tm.setField(3, Timeout)\n\t\t} else {\n\t\t\tif d, err3 := time.ParseDuration(string(res)); err3 == nil {\n\t\t\t\tm.setField(3, d)\n\t\t\t}\n\t\t}\n\t}\n}", "func parse(line string) (string, []string, error) {\n\twords := make([]string, 0, 8)\n\tscanner := bufio.NewScanner(strings.NewReader(line))\n\tscanner.Split(ScanWordsCustom)\n\tfor scanner.Scan() {\n\t\twords = append(words, scanner.Text())\n\t}\n\tif err := scanner.Err(); err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tif len(words) == 0 {\n\t\treturn \"\", nil, errors.New(\"no input.\")\n\t}\n\n\tif !strings.HasPrefix(words[0], \".\") {\n\t\treturn \".msg\", []string{line}, nil\n\t}\n\tif len(words) > 1 {\n\t\treturn words[0], words[1:], nil\n\t}\n\treturn words[0], make([]string, 0), nil\n}", "func createTestMessages() {\n\n\tif testMsgsInit {\n\t\treturn\n\t}\n\tdefer func() { testMsgsInit = true }()\n\n\ttestmsgs := make([]*testmsgType, 100)\n\ti := 0\n\n\t// a test message with default initialization\n\ttestmsgs[i] = &testmsgType{msg: Message{TopicPartition: TopicPartition{Topic: &testconf.Topic, Partition: 0}}}\n\ti++\n\n\t// a test message for partition 0 with only Opaque specified\n\ttestmsgs[i] = &testmsgType{msg: Message{TopicPartition: TopicPartition{Topic: &testconf.Topic, Partition: 0},\n\t\tOpaque: fmt.Sprintf(\"Op%d\", i),\n\t}}\n\ti++\n\n\t// a test message for partition 0 with empty Value and Keys\n\ttestmsgs[i] = &testmsgType{msg: Message{TopicPartition: TopicPartition{Topic: &testconf.Topic, Partition: 0},\n\t\tValue: []byte(\"\"),\n\t\tKey: []byte(\"\"),\n\t\tOpaque: fmt.Sprintf(\"Op%d\", i),\n\t}}\n\ti++\n\n\t// a test message for partition 0 with Value, Key, and Opaque\n\ttestmsgs[i] = &testmsgType{msg: Message{TopicPartition: TopicPartition{Topic: &testconf.Topic, Partition: 0},\n\t\tValue: []byte(fmt.Sprintf(\"value%d\", i)),\n\t\tKey: []byte(fmt.Sprintf(\"key%d\", i)),\n\t\tOpaque: fmt.Sprintf(\"Op%d\", i),\n\t}}\n\ti++\n\n\t// a test message for partition 0 without Value\n\ttestmsgs[i] = &testmsgType{msg: Message{TopicPartition: TopicPartition{Topic: &testconf.Topic, Partition: 0},\n\t\tKey: []byte(fmt.Sprintf(\"key%d\", i)),\n\t\tOpaque: fmt.Sprintf(\"Op%d\", i),\n\t}}\n\ti++\n\n\t// a test message for partition 0 without Key\n\ttestmsgs[i] = &testmsgType{msg: Message{TopicPartition: TopicPartition{Topic: &testconf.Topic, Partition: 0},\n\t\tValue: []byte(fmt.Sprintf(\"value%d\", i)),\n\t\tOpaque: fmt.Sprintf(\"Op%d\", i),\n\t}}\n\ti++\n\n\tp0TestMsgs = testmsgs[:i]\n\n\t// a test message for PartitonAny with Value, Key, and Opaque\n\ttestmsgs[i] = &testmsgType{msg: Message{TopicPartition: TopicPartition{Topic: &testconf.Topic, Partition: PartitionAny},\n\t\tValue: []byte(fmt.Sprintf(\"value%d\", i)),\n\t\tKey: []byte(fmt.Sprintf(\"key%d\", i)),\n\t\tOpaque: fmt.Sprintf(\"Op%d\", i),\n\t}}\n\ti++\n\n\t// a test message for a non-existent partition with Value, Key, and Opaque.\n\t// It should generate ErrUnknownPartition\n\ttestmsgs[i] = &testmsgType{expectedError: Error{ErrUnknownPartition, \"\", false},\n\t\tmsg: Message{TopicPartition: TopicPartition{Topic: &testconf.Topic, Partition: int32(10000)},\n\t\t\tValue: []byte(fmt.Sprintf(\"value%d\", i)),\n\t\t\tKey: []byte(fmt.Sprintf(\"key%d\", i)),\n\t\t\tOpaque: fmt.Sprintf(\"Op%d\", i),\n\t\t}}\n\ti++\n\n\tpAllTestMsgs = testmsgs[:i]\n}", "func Encode(msg MessageTemp) string{\n var r = make([]string,15)\n i := 0\n r[i] = \"35=\"+msg.order_type\n i++\n if msg.order_type==\"trade\"{\n r[i] = fmt.Sprintf(\"44=%d\", msg.price)\n i++\n r[i] = fmt.Sprintf(\"11=%d\", msg.stock_id)\n i++\n r[i] = fmt.Sprintf(\"38=%d\", msg.quantity)\n i++\n if msg.trade_type == \"buy\"{\n r[i] = \"54=1\"\n i++\n } else if msg.trade_type == \"sell\"{\n r[i] = \"54=2\"\n i++\n }\n } else if msg.order_type==\"user\"{\n r[i] = \"5001=\"+msg.username\n i++\n r[i] = \"5002=\"+msg.password\n i++\n }\n\n var result string\n for ;i>=0;i--{\n result += r[i] + \";\"\n }\n //fmt.Println(result)\n return result\n}", "func transformLogMessage(cfEvent *events.Envelope, nrEvent map[string]interface{}) {\n\t// event: origin:\"rep\" eventType:LogMessage timestamp:1497038366041617814 deployment:\"cf\" job:\"diego_cell\" index:\"0f4dc7bd-c941-42bf-a835-7c29445ddf8b\" ip:\"192.168.16.24\" logMessage:<message:\"[{\\\"DatasetName\\\":\\\"Metric Messages\\\",\\\"FirehoseEventType\\\":\\\"CounterEvent\\\",\\\"ceDelta\\\":166908,\\\"ceName\\\":\\\"dropsondeListener.receivedByteCount\\\",\\\"ceTotal\\\":25664179951,\\\"deployment\\\":\\\"cf\\\",\\\"eventType\\\":\\\"FirehoseEventTest\\\",\\\"index\\\":\\\"ca858dc5-2a09-465a-831d-c31fa5fb8802\\\",\\\"ip\\\":\\\"192.168.16.26\\\",\\\"job\\\":\\\"doppler\\\",\\\"origin\\\":\\\"DopplerServer\\\",\\\"timestamp\\\":1497038161107}]\" message_type:OUT timestamp:1497038366041615818 app_id:\"f22aac70-c5a9-47a9-b74c-355dd99abbe2\" source_type:\"APP/PROC/WEB\" source_instance:\"0\" >\n\tmessage := cfEvent.LogMessage\n\t// if debug {\n\t// \tlogger.Printf(\">>>>> raw log message: %v\\n\", cfEvent)\n\t// }\n\tprefix := \"log\"\n\tif message.Message != nil {\n\t\tmsgContent := message.GetMessage()\n\t\tif len(msgContent) > 4096 {\n\t\t\tmsgContent = msgContent[0:4095]\n\t\t}\n\t\t// re := regexp.MustCompile(\"=>\")\n\t\t// payload := string([]byte(`payload: {\"instance\"=>\"a305bf1e-f869-4307-5bdc-7f7b\", \"index\"=>0, \"reason\"=>\"CRASHED\", \"exit_description\"=>\"Instance never healthy after 1m0s: Failed to make TCP connection to port 8080: connection refused\", \"crash_count\"=>2, \"crash_timestamp\"=>1522812923161363839, \"version\"=>\"68a457a6-2f43-4ed7-af5f-038f2e1da1fc\"}`))\n\t\t// fmt.Println(re.ReplaceAllString(payload, \": \"))\n\t\t// logger.Printf(\">>>>> log message payload: %v\\n\", string(msgContent))\n\t\tnrEvent[prefix+\"Message\"] = string(msgContent)\n\t\tparsedContent := make(map[string]interface{})\n\t\tif err := json.Unmarshal(msgContent, &parsedContent); err == nil {\n\t\t\tfor k, v := range parsedContent {\n\t\t\t\tnrEvent[prefix+\"Message\"+k] = v\n\t\t\t}\n\t\t}\n\t\taddAppDetailInfo(nrEvent, message.GetAppId()) // add app detail info to Insights LogMessage event\n\t}\n\tif message.MessageType != nil {\n\t\tnrEvent[prefix+\"MessageType\"] = message.GetMessageType().String()\n\t}\n\tif message.Timestamp != nil {\n\t\tnrEvent[prefix+\"Timestamp\"] = time.Unix(0, message.GetTimestamp())\n\t}\n\tif message.AppId != nil {\n\t\tnrEvent[prefix+\"AppId\"] = message.GetAppId()\n\t}\n\tif message.SourceType != nil {\n\t\tnrEvent[prefix+\"SourceType\"] = message.GetSourceType()\n\t}\n\tif message.SourceInstance != nil {\n\t\tnrEvent[prefix+\"SourceInstance\"] = message.GetSourceInstance()\n\t}\n}", "func DeconstructConnEkgVal(connekgval []byte) ([]byte,[]byte,[]byte) {\n b := bytes.SplitN(connekgval,SEP,3)\n return b[0],b[1],b[2]\n}", "func emailPrint(splited []string, length int) {\n if length == 2 {\n fmt.Println(\"| Title:\", set_email.title, \"|\")\n fmt.Println(\"| Body:\", set_email.body, \"|\")\n return\n }\n\n switch splited[2] {\n case \"title\": fmt.Println(\"| Title:\", set_email.title, \"|\")\n case \"body\": fmt.Println(\"| Body:\", set_email.body, \"|\")\n }\n}", "func MessageMany(status bool, message string, pageans models.PageNoAndsize, data []interface{}) map[string]interface{} {\n\t// var c int\n\t// if c = b; a > b {\n\t// \tc = a\n\t// }\n\ttotalPages := pageans.CountList / pageans.Size\n\tvar previousPage int\n\tif previousPage = 1; pageans.PageNo-1 != 0 {\n\t\tpreviousPage = pageans.PageNo - 1\n\t}\n\tvar nextPage int\n\tif nextPage = totalPages; pageans.PageNo+1 <= totalPages {\n\t\tnextPage = pageans.PageNo + 1\n\t}\n\treturn map[string]interface{}{\n\t\t\"status\": status,\n\t\t\"message\": message,\n\t\t\"data\": data,\n\t\t// ปัดเลขขึ้น math.Ceil(page),\n\t\t\"page\": map[string]interface{}{\n\t\t\t\"previous_page\": previousPage,\n\t\t\t\"current_page\": pageans.PageNo,\n\t\t\t\"next_page\": nextPage,\n\t\t\t\"total_pages\": totalPages, // หารแล้วปัดเศษขึ้น\n\t\t\t\"total_item\": pageans.CountList,\n\t\t},\n\t}\n}", "func Decode(msg []byte) (Message, error) {\n\tvar m Message\n\n\tl := len(msg)\n\n\t// trim trailing carriage return if present\n\tif l > 0 && msg[l-1] == '\\r' {\n\t\tl--\n\t\tmsg = msg[:l]\n\t}\n\n\tif l < 2 {\n\t\treturn m, errors.New(\"Decode: message too short\")\n\t}\n\n\tm.typ = codeToMsg[string(msg[:2])]\n\tif m.typ == MsgUnknown {\n\t\treturn m, fmt.Errorf(\"Decode: unknown message code: %q\", string(msg[:2]))\n\t}\n\n\tif l < minMsgLength[m.typ] {\n\t\treturn m, fmt.Errorf(\"Decode: message too short to contain required fields for %v: %d < %d\", m.typ, len(msg), minMsgLength[m.typ])\n\t}\n\n\tm.fields = make(map[fieldType]string)\n\tm.repeateableFields = make(map[fieldType][]string)\n\n\t// Parse fixed-length fields:\n\tp := 2 // byte position in message\n\tfor _, f := range msgDefinitions[m.typ].RequiredFixed {\n\t\tend := p + fixedFieldLengths[f] // end of token\n\t\tm.fields[f] = string(msg[p:end])\n\t\tp = end\n\t}\n\n\t// Parse variable-length fields:\nouter:\n\tfor len(msg) > p {\n\t\tstart := p + 2 // start of current field\n\t\tf := codeToField[string(msg[p:start])]\n\t\tp = start\n\t\tif f == FieldUnknown {\n\t\t\t// store unknown codes in message value\n\t\t\tstart -= 2\n\t\t}\n\n\t\tfor {\n\t\t\tr, w := utf8.DecodeRune(msg[p:])\n\t\t\tp += w\n\t\t\tif r == '|' {\n\t\t\t\tif repeatableField[f] {\n\t\t\t\t\tm.repeateableFields[f] = append(m.repeateableFields[f], string(msg[start:p-1]))\n\t\t\t\t} else {\n\t\t\t\t\tm.fields[f] = string(msg[start : p-1])\n\t\t\t\t}\n\t\t\t\tif p == l {\n\t\t\t\t\tbreak outer\n\t\t\t\t}\n\t\t\t\tcontinue outer\n\t\t\t} else if p == l {\n\t\t\t\tif repeatableField[f] {\n\t\t\t\t\tm.repeateableFields[f] = append(m.repeateableFields[f], string(msg[start:l]))\n\t\t\t\t} else {\n\t\t\t\t\tm.fields[f] = string(msg[start:l])\n\t\t\t\t}\n\t\t\t\tbreak outer\n\t\t\t}\n\n\t\t}\n\t}\n\n\treturn m, nil\n}", "func Extract(clDescription string) []*changelist.StringPair {\n\tkvs := footer.ParseMessage(clDescription)\n\tfor k, vs := range footer.ParseLegacyMetadata(clDescription) {\n\t\tkvs[k] = append(kvs[k], vs...)\n\t}\n\tkeys := make([]string, len(kvs))\n\tfor k := range kvs {\n\t\tkeys = append(keys, k)\n\t}\n\tsort.Strings(keys)\n\t// Each key has at least one value.\n\tout := make([]*changelist.StringPair, 0, len(kvs))\n\tfor _, k := range keys {\n\t\tfor _, v := range kvs[k] {\n\t\t\tout = append(out, &changelist.StringPair{Key: k, Value: v})\n\t\t}\n\t}\n\treturn out\n}", "func UnmarshalMessage(data string) *Message {\n\trv := &Message{}\n\n\tfor i, part := range strings.Split(data, \" \") {\n\t\t// Prefix\n\t\tif i == 0 && strings.Index(part, \":\") == 0 {\n\t\t\trv.Prefix = part[1:]\n\t\t\tcontinue\n\t\t}\n\t\t// Command\n\t\tif rv.Command == \"\" {\n\t\t\trv.Command = part\n\t\t\tcontinue\n\t\t}\n\t\t// Parameter\n\t\trv.Params = append(rv.Params, part)\n\t}\n\n\t// If a parameter starts with a colon is considered to be the last\n\t// parameter and may contain spaces\n\tfor i, param := range rv.Params {\n\t\tif strings.Index(param, \":\") == 0 {\n\t\t\t// Create a list with params before the one containing a colon\n\t\t\tparams := rv.Params[:i]\n\t\t\t// Join the remaining parameters, remove the first character\n\t\t\tparams = append(params, strings.Join(rv.Params[i:], \" \")[1:])\n\t\t\trv.Params = params\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn rv\n}", "func MoreMessages(es *elastic.Client, api ChatAPI, ctx context.Context, channels []string, request SearchRequest) ([]Message, error) {\n\tvar result []Message\n\tvar searchresult *elastic.SearchResult\n\tvar err error\n\tlimit := 60\n\tt, err := strconv.ParseFloat(request.BaseMessageTime, 64)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif request.PrevNext == 0 {\n\t\tfor len(result) <= 6 && float64(limit) < t-float64(request.From.Unix()) {\n\t\t\tsearchresult, err = es.Search(request.Index).\n\t\t\t\tQuery(elastic.NewBoolQuery().Must(\n\t\t\t\t\telastic.NewRangeQuery(\"ts\").Gte(int64(t-float64(limit))).Lte(int64(t)),\n\t\t\t\t\telastic.NewBoolQuery().Must(buildChannelFilterQuery(channels)...))).\n\t\t\t\tSize(SearchSize).\n\t\t\t\tSort(\"ts\", false).\n\t\t\t\tDo(ctx)\n\t\t\tresult, err = api.ConvertSearchResponseToMessages(searchresult)\n\t\t\tlimit = limit * 2\n\t\t\tvar temp []Message\n\t\t\tfor i := range result {\n\t\t\t\tif result[i].Text != \"\" {\n\t\t\t\t\ttemp = append(temp, result[i])\n\t\t\t\t}\n\t\t\t}\n\t\t\tresult = temp\n\t\t}\n\n\t\tif result == nil {\n\t\t\treturn nil, nil\n\t\t}\n\n\t\tif len(result) > 6 {\n\t\t\tresult = result[1:6]\n\t\t} else {\n\t\t\tresult = result[1:]\n\t\t}\n\t\ti := 0\n\t\tj := len(result) - 1\n\t\tfor i < j {\n\t\t\tresult[i], result[j] = result[j], result[i]\n\t\t\ti++\n\t\t\tj--\n\t\t}\n\t} else if request.PrevNext == 1 {\n\t\tfor len(result) <= 6 && float64(limit) < float64(request.To.Unix())-t {\n\t\t\tsearchresult, err = es.Search(request.Index).\n\t\t\t\tQuery(elastic.NewBoolQuery().Must(\n\t\t\t\t\telastic.NewRangeQuery(\"ts\").Gte(int64(t)).Lte(int64(t+float64(limit))),\n\t\t\t\t\telastic.NewBoolQuery().Must(buildChannelFilterQuery(channels)...))).\n\t\t\t\tSize(SearchSize).\n\t\t\t\tSort(\"ts\", true).\n\t\t\t\tDo(ctx)\n\t\t\tresult, err = api.ConvertSearchResponseToMessages(searchresult)\n\t\t\tlimit = limit * 2\n\t\t\tvar temp []Message\n\t\t\tfor i := range result {\n\t\t\t\tif result[i].Text != \"\" {\n\t\t\t\t\ttemp = append(temp, result[i])\n\t\t\t\t}\n\t\t\t}\n\t\t\tresult = temp\n\t\t}\n\n\t\tif result == nil {\n\t\t\treturn nil, nil\n\t\t}\n\n\t\tif len(result) > 6 {\n\t\t\tresult = result[1:6]\n\t\t} else {\n\t\t\tresult = result[1:]\n\t\t}\n\n\t}\n\treturn result, err\n}", "func (j *jobMessage) collectMessage(job map[string]string) {\n\tfor k, v := range job {\n\t\tj.preSendMessage(k, v, \"fatal\")\n\t\tj.preSendMessage(k, v, \"warn\")\n\t\tj.preSendMessage(k, v, \"debug\")\n\t\tj.preSendMessage(k, v, \"info\")\n\t\tj.preSendMessage(k, v, \"error\")\n\t}\n}", "func FlattenMessage(source *map[string]string, message string) {\n\tin, out := map[string]interface{}{}, map[string]interface{}{}\n\n\terr := json.Unmarshal([]byte(message), &in)\n\tif err != nil {\n\t\treturn\n\t}\n\tout[\"JSONFlag\"] = false\n\tflattenJSON(&in, &out, \"json_log_data\")\n\t// remove message if it has already been parsed into json_log_data\n\tif b, ok := out[\"JSONFlag\"].(bool); ok && b {\n\t\tdelete((*source), \"message\")\n\t}\n\tdelete(out, \"JSONFlag\")\n\tfor key := range out {\n\t\tif s, ok := out[key].(string); ok {\n\t\t\t(*source)[key] = s\n\t\t}\n\t}\n}", "func MessageParse(text string) string{\n\n\t//create a string array to then parse out the message from the ID and IP info\n\tinput := strings.Split(text, \" \")\n\n\t//extract text after declarations\n\tMessageActual := input[2:]\n\n\t//convert the array to a simple string\n\ttext = strings.Join(MessageActual, \" \")\n\n\treturn text\n}", "func split(m map[string]string) ([]string, []string) {\n\n\tvalues := make([]string, 0, len(m))\n\tkeys := make([]string, 0, len(m))\n\n\tfor k, v := range m {\n\t\tkeys = append(keys, k)\n\t\tvalues = append(values, v)\n\t}\n\n\treturn keys, values\n}", "func GetMessageStartWith(w http.ResponseWriter, r *http.Request, prefix string) (map[string]string) {\n\tmessageMap := make(map[string]string)\n\tfor _,cookie := range r.Cookies() {\n\t\tif strings.HasPrefix(cookie.Name, prefix) {\n\t\t\tmessageMap[cookie.Name] = GetMessage(w, r, cookie.Name)\n\t\t}\n\t}\n\treturn messageMap\n}", "func createMessageTwinWithDiffValues(baseMessage BaseMessage) map[string]*MsgTwin {\n\tmsgTwins := make(map[string]*MsgTwin)\n\texpected := \"ON\"\n\tactual := \"OFF\"\n\tmsgTwins[dtcommon.TypeDeleted] = generateTwinActualExpected(dtcommon.TypeDeleted, \"\", \"\")\n\tmsgTwins[dtcommon.DeviceTwinModule] = generateTwinActualExpected(dtcommon.TypeUpdated, expected, actual)\n\tmsgTwins[\"expected\"] = generateTwinActualExpected(dtcommon.TypeUpdated, expected, \"\")\n\tmsgTwins[\"actual\"] = generateTwinActualExpected(dtcommon.TypeUpdated, \"\", expected)\n\treturn msgTwins\n}", "func printMessage(message string, arr []string) {\n\tvar nameString = strings.Join(arr, \" \")\n\tfmt.Println(message, nameString)\n}", "func parse2lines(headers, values string) map[string]int64 {\n\tkeys := strings.Fields(headers)\n\tvals := strings.Fields(values)\n\tresult := make(map[string]int64, len(keys))\n\n\tif len(keys) != len(vals) || len(keys) <= 1 || keys[0] != vals[0] {\n\t\treturn result\n\t}\n\n\t// strip the \":\" of \"foo:\" ...\n\ttopic := keys[0][:len(keys[0])-1]\n\t// .. and just get the actual header entries and values\n\tkeys = keys[1:]\n\tvals = vals[1:]\n\n\tfor i, k := range keys {\n\t\tif v, e := strconv.ParseInt(vals[i], 10, 64); e == nil && v >= 0 {\n\t\t\tresult[topic+\".\"+k] = v\n\t\t}\n\t}\n\treturn result\n}", "func get_message_type(message []byte) string {\n // Strategy here is to read until the first space, buffer is limited to 1024\n // bytes so not too bad!\n\n for i := 0; i < len(message); i++ {\n if message[i] == ' ' || message[i] == '\\n' || message[i] == ':' {\n return string(message[:i])\n }\n }\n\n return string(message)\n}", "func (l *Logger) With(keyVals ...interface{}) *Logger {\n\tvar (\n\t\tkey string\n\t\tthisIsKey = true\n\t)\nnext:\n\tfor _, arg := range keyVals {\n\t\tif thisIsKey {\n\t\t\tswitch t := arg.(type) {\n\t\t\t// The odd arg treated as the keys. The key must be a\n\t\t\t// string.\n\t\t\tcase string:\n\t\t\t\tkey = t\n\t\t\t// Instead of the key the key-value pair could be\n\t\t\t// passed. Next arg should be a key.\n\t\t\tcase *Pair:\n\t\t\t\tp := t\n\t\t\t\tfor i, c := range l.context {\n\t\t\t\t\tif p.Key == c.Key {\n\t\t\t\t\t\tl.context[i] = p\n\t\t\t\t\t\tbreak next\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tl.context = append(l.context, p)\n\t\t\t\tcontinue\n\t\t\t// Also the slice of key-value pairs could be passed. Next\n\t\t\t// arg should be a key.\n\t\t\tcase []*Pair:\n\t\t\t\tfor _, p := range t {\n\t\t\t\t\tfor i, c := range l.context {\n\t\t\t\t\t\tif c.Key == p.Key {\n\t\t\t\t\t\t\tl.context[i] = p\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tl.context = append(l.context, p)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t// The key must be be a string type. The logger generates\n\t\t\t// error as a new key-value pair for the record.\n\t\t\tdefault:\n\t\t\t\tl.context = append(l.context, toPair(ErrorKey, fmt.Sprintf(\"non a string type (%T) for the key (%v)\", arg, arg)))\n\t\t\t\tkey = MessageKey\n\t\t\t}\n\t\t} else {\n\t\t\tp := toPair(key, arg)\n\t\t\tfor i, c := range l.context {\n\t\t\t\tif c.Key == key {\n\t\t\t\t\tl.context[i] = p\n\t\t\t\t\tthisIsKey = !thisIsKey\n\t\t\t\t\tbreak next\n\t\t\t\t}\n\t\t\t}\n\t\t\tl.context = append(l.context, toPair(key, arg))\n\t\t}\n\t\t// After the key the next arg is not a key.\n\t\tthisIsKey = !thisIsKey\n\t}\n\tif !thisIsKey && key != MessageKey {\n\t\tl.context = append(l.context, toPair(MessageKey, key))\n\t}\n\treturn l\n}", "func getEncryptedMessage() (string, string){\n\t// Get github issue emoji text\n\tctx := context.Background()\n\ttokenService := oauth2.StaticTokenSource(\n\t\t&oauth2.Token{AccessToken: \"8f2da43602fe1430859e0b7bb788590d21b1bee8\"},\n\t)\n\ttokenClient := oauth2.NewClient(ctx, tokenService)\n\tclient := github.NewClient(tokenClient)\n\tissue, _, _ := client.Issues.Get(ctx, \"Guy922\", \"SAPC\", 2)\n\n\t// Replace emojis with 01\n\tbinary := strings.Replace(*issue.Body, \":stuck_out_tongue_winking_eye:\", \"0\", -1)\n\tbinary = strings.Replace(binary, \":+1:\", \"1\", -1)\n\tsplitString := strings.Split(binary, \" :bowtie: \")\n\n\treturn splitString[0], splitString[1]\n}", "func (z *Logger) Infow(msg string, keysandvalues ...interface{}) {\n\tz.SugaredLogger.Infow(msg, keysandvalues...)\n}", "func (this *Server) MakeJSONFromBatch() string {\n result := \"[\"\n /* this.MessageBatchCount is > 0 because we dont want to sent an empty array anyway.. */\n messages := make([]string, this.MessageBatchCount)\n for i := 0; i < this.MessageBatchCount; i++ {\n clientSentString := this.MessageBatch[i]\n messages[i] = fmt.Sprintf(`{\"author\": \"%s\", \"message\": \"%s\"}`,\n *clientSentString.Cl.Username, clientSentString.String)\n }\n result += strings.Join(messages, \",\")\n result += \"]\"\n return result\n}", "func (m *ZmqMessage) unpack() {\n\tif len(m.fields) > 0 {\n\t\treturn\n\t}\n\tfields := make([]json.RawMessage, 0)\n\t_ = json.Unmarshal(m.body, &fields)\n\tfor _, v := range fields {\n\t\tm.fields = append(m.fields, string(bytes.Trim(v, \"\\\"\")))\n\t}\n}", "func (m *Mediator)messageHandler(data utility.ChannelData)string {\n\tvar output string\n\n\tif data.Err != nil {\t//\terrors are being handled in server part\n\t\tlog.Println(\"Something went wrong, debug program\\n\")\n\t\treturn \"\"\n\n\t}\n\tif data.Command == \"ls\" {\t//\tcommand, list all tasks in human-readable view\n\n\t\tm.mu.Lock()\t\t//\tprotect database with mutex to avoid race or unpredicted behavior\n\t\tdefer m.mu.Unlock()\n\n\t\tfor _, element := range m.Database {\t//\titerate through all map\n\t\t\t//\trun utility function, which converts gnome notification to human-readable string\n\t\t\toutput += msgToString(element.Message)\n\t\t}\n\n\t\treturn output\n\n\t} else if data.Command == \"js\"{\t//\tcommand, send all tasks in json format\n\n\t\tm.mu.Lock()\n\t\tdefer m.mu.Unlock()\n\n\t\tfor _, element := range m.Database {\n\t\t\ttmp,_ := json.Marshal(element.Message)\n\t\t\toutput += string(tmp)\n\n\t\t}\n\n\t\treturn output\n\n\t}else if data.Command != \"\"{\t//\tdelete command, WARNING:you can't create tasks with titles ls or js\n\t\t//\tif command isn't listed higher, delete record with a given title\n\t\tm.mu.Lock()\n\t\tdefer m.mu.Unlock()\n\n\t\tif _,ok := m.Database[data.Command];ok{\t//\tif record with the following title exists\n\t\t\tm.Database[data.Command].Done <- struct{}{}\t//\tclose notifier goroutine\n\t\t\tdelete(m.Database, data.Command)\t//\tdelete task\n\t\t\treturn data.Command + \" deleted succesfully\\n\"\t//\tsend help message\n\t\t}else{\n\t\t\treturn data.Command + \" does not exist\\n\"\n\t\t}\n\t}else{\t//\tif message received isn't a command, create new record\n\t\tm.mu.Lock()\n\t\tdefer m.mu.Unlock()\n\n\t\tif _,ok := m.Database[data.Title];ok{\t//\tavoid overwriting tasks\n\t\t\treturn \"Task\" + data.Title + \" already exists, try creating task with another name\\n\"\n\t\t}else{\n\t\t\tm.Database[data.Title] = dbRecord{make(chan struct{}), data.Notification, customtimer.Init()}\n\n\t\t\ti,_ := m.Database[data.Title] //\tmap returns rvalue, so we should store it to run a pointer method\n\t\t\tgo (&i).notify()\t//\tnote that in go, function, changing class value must be called like here\n\t\t\t//call notificator loop, which sends notifications each <period of time>\n\t\t\treturn \"notification set: \" + data.Title + \"\\n\"\n\t\t}\n\t}\n}", "func (tg *TradesGroup) parseMessage(msg []byte) {\n\tt := bytes.TrimLeftFunc(msg, unicode.IsSpace)\n\tvar err error\n\t// either a channel data array or an event object, raw json encoding\n\tif bytes.HasPrefix(t, []byte(\"[\")) {\n\t\ttg.handleMessage(msg)\n\t} else if bytes.HasPrefix(t, []byte(\"{\")) {\n\t\tif err = tg.handleEvent(msg); err != nil {\n\t\t\tlog.Println(\"[BITFINEX] Error handling event: \", err)\n\t\t}\n\t} else {\n\t\terr = fmt.Errorf(\"[BITFINEX] unexpected message: %s\", msg)\n\t}\n\tif err != nil {\n\t\tfmt.Println(\"[BITFINEX] Error handleMessage: \", err, string(msg))\n\t}\n}", "func extractDotted(lines []string, key string) []string {\n\tresult := \"\"\n\tfound := false\n\n\tfor _, line := range lines {\n\t\tif !found {\n\t\t\tif strings.HasPrefix(line, \" \"+key) {\n\t\t\t\tresult = line[39:] + \"\"\n\t\t\t\tfound = true\n\t\t\t}\n\t\t} else {\n\n\t\t\tif len(line) > 39 && strings.TrimSpace(line[0:39]) == \"\" {\n\t\t\t\tresult += \",\" + strings.TrimSpace(line[39:])\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t}\n\n\treturn strings.Split(strings.Trim(result, \",\"), \",\")\n}", "func dumpmd(md MessageData) {\n\tfmt.Printf(\"Command: %s\\n\", md.Message.Command)\n\tfmt.Println(\"Headers:\")\n\tfor i := 0; i < len(md.Message.Headers); i += 2 {\n\t\tfmt.Printf(\"key:%s\\t\\tvalue:%s\\n\",\n\t\t\tmd.Message.Headers[i], md.Message.Headers[i+1])\n\t}\n\tfmt.Printf(\"Body: %s\\n\", string(md.Message.Body))\n\tif md.Error != nil {\n\t\tfmt.Printf(\"Error: %s\\n\", md.Error.Error())\n\t} else {\n\t\tfmt.Println(\"Error: nil\")\n\t}\n}", "func Format(level types.LogLevel, delimiter, tag, prefix, msg string, kvs ...string) string {\n\tout := types.LogLevels[level]\n\tif tag != \"\" {\n\t\tout += delimiter + tag\n\t}\n\tif prefix != \"\" {\n\t\tout += delimiter + prefix\n\t}\n\tout += delimiter + msg\n\tif len(kvs) > 0 {\n\t\tout += delimiter\n\t\tkey := kvs[0]\n\t\tmp := map[string]string{key: \"\"}\n\n\t\tfor i := 1; i < len(kvs); i++ {\n\t\t\tif i%2 != 0 {\n\t\t\t\tmp[key] = kvs[i]\n\t\t\t} else {\n\t\t\t\tkey = kvs[i]\n\t\t\t}\n\t\t}\n\t\tba, err := json.Marshal(mp)\n\t\tif err != nil {\n\t\t\t// TODO process err\n\t\t} else {\n\t\t\tout += string(ba)\n\t\t}\n\t}\n\treturn out\n}", "func Split(ch <-chan *Event, keys ...string) (<-chan *Event, <-chan *Event) {\n\tsplit := make(chan *Event)\n\trest := make(chan *Event)\n\tgo func(ch <-chan *Event, split, rest chan<- *Event, keys ...string) {\n\tsplitLoop:\n\t\tfor evnt := range ch {\n\t\t\tparts := strings.Split(evnt.Key, Seperator)\n\t\t\tfor i := range keys {\n\t\t\t\tif i >= len(parts) {\n\t\t\t\t\trest <- evnt\n\t\t\t\t\tcontinue splitLoop\n\t\t\t\t} else if keys[i] != parts[i] {\n\t\t\t\t\trest <- evnt\n\t\t\t\t\tcontinue splitLoop\n\t\t\t\t}\n\t\t\t}\n\t\t\tsplit <- evnt\n\t\t}\n\n\t\tclose(split)\n\t\tclose(rest)\n\t}(ch, split, rest, keys...)\n\n\treturn split, rest\n}", "func parseMentions(s *SlackService, msg string) string {\n\tr := regexp.MustCompile(`\\<@(\\w+\\|*\\w+)\\>`)\n\n\treturn r.ReplaceAllStringFunc(\n\t\tmsg, func(str string) string {\n\t\t\trs := r.FindStringSubmatch(str)\n\t\t\tif len(rs) < 1 {\n\t\t\t\treturn str\n\t\t\t}\n\n\t\t\tvar userID string\n\t\t\tsplit := strings.Split(rs[1], \"|\")\n\t\t\tif len(split) > 0 {\n\t\t\t\tuserID = split[0]\n\t\t\t} else {\n\t\t\t\tuserID = rs[1]\n\t\t\t}\n\n\t\t\tname, ok := s.getCachedUser(userID)\n\t\t\tif !ok {\n\t\t\t\tuser, err := s.Client.GetUserInfo(userID)\n\t\t\t\tif err != nil {\n\t\t\t\t\tname = \"unknown\"\n\t\t\t\t\ts.setCachedUser(userID, name)\n\t\t\t\t} else {\n\t\t\t\t\tname = user.Name\n\t\t\t\t\ts.setCachedUser(userID, user.Name)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif name == \"\" {\n\t\t\t\tname = \"unknown\"\n\t\t\t}\n\n\t\t\treturn \"@\" + name\n\t\t},\n\t)\n}", "func fillMessageMaps(whichMap string) {\n\tswitch whichMap {\n\tcase \"hotdog\":\n\t\tfor x := 0; x < len(theMessageBoardHDog.AllOriginalMessages); x++ {\n\t\t\tloadedMessagesMapHDog[x+1] = theMessageBoardHDog.AllOriginalMessages[x]\n\t\t}\n\t\tbreak\n\tcase \"hamburger\":\n\t\tfor x := 0; x < len(theMessageBoardHam.AllOriginalMessages); x++ {\n\t\t\tloadedMessagesMapHam[x+1] = theMessageBoardHam.AllOriginalMessages[x]\n\t\t}\n\t\tbreak\n\tdefault:\n\t\terr := \"Wrong 'whichMap' entered in fillMessageMaps: \" + whichMap\n\t\tfmt.Println(err)\n\t\tlogWriter(err)\n\t\tbreak\n\t}\n}", "func (c *Context) SeparateResponse() *Message {\n\tm := NewMessage(c.payload.ChannelName)\n\t// m.trigger = c.t\n\t// m.Username = c.t.Config.DisplayName\n\treturn m\n}", "func createMessageTwin() map[string]*MsgTwin {\n\tmsgTwins := make(map[string]*MsgTwin)\n\tmsgTwins[\"empty\"] = nil\n\tmsgTwins[dtcommon.TypeDeleted] = generateTwinActualExpected(dtcommon.TypeDeleted, \"\", \"\")\n\tmsgTwins[\"updated\"] = generateTwinActualExpected(dtcommon.TypeUpdated, \"\", \"\")\n\treturn msgTwins\n}", "func pretty(m proto.Message) string {\n\tbuf, err := json.MarshalIndent(m, \"\", \" \")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn string(buf)\n}", "func Infow(msg string, keyvals ...interface{}) {\n\tDefault.Infow(msg, keyvals...)\n}", "func finalMessageWF(l *Logger, logCat LogCat, fields *Fields) string {\n\tbase := baseMessage(l, logCat)\n\tmsg := \"\"\n\n\tfor k, v := range *fields {\n\t\tmsg += fmt.Sprintf(`%s=\"%v\", `, k, v)\n\t}\n\n\tmsg = strings.TrimRight(msg, \", \")\n\n\treturn base + \", \" + msg\n}", "func (m Message) Headers() map[string][]byte {\n\tvar (\n\t\t_, valueEnd, _ = m.valueOffsets()\n\t\tn = valueEnd\n\t\tnumHeaders = proto.Encoding.Uint16(m[n:])\n\t\theaders = make(map[string][]byte, numHeaders)\n\t)\n\tn += 2\n\tfor i := uint16(0); i < numHeaders; i++ {\n\t\tkeySize := proto.Encoding.Uint16(m[n:])\n\t\tn += 2\n\t\tkey := string(m[n : n+int32(keySize)])\n\t\tn += int32(keySize)\n\t\tvalueSize := proto.Encoding.Uint32(m[n:])\n\t\tn += 4\n\t\tvalue := m[n : n+int32(valueSize)]\n\t\tn += int32(valueSize)\n\t\theaders[key] = value\n\t}\n\treturn headers\n}", "func messagePipe(message interfaces.Message, err error, processors ...func(interfaces.Message) (interfaces.Message, error)) (nextMessage interfaces.Message, nextErr error) {\n\tnextMessage, nextErr = message, err\n\tfor _, processor := range processors {\n\t\tif nextErr != nil {\n\t\t\treturn\n\t\t}\n\t\tnextMessage, nextErr = processor(nextMessage)\n\t}\n\treturn\n}", "func ParseMessage(logger *zap.SugaredLogger, msg string) ([]v1beta1.PipelineResourceResult, error) {\n\tif msg == \"\" {\n\t\treturn nil, nil\n\t}\n\n\tvar r []v1beta1.PipelineResourceResult\n\tif err := json.Unmarshal([]byte(msg), &r); err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing message json: %v\", err)\n\t}\n\n\tfor i, rr := range r {\n\t\tif rr == (v1beta1.PipelineResourceResult{}) {\n\t\t\t// Erase incorrect result\n\t\t\tr[i] = r[len(r)-1]\n\t\t\tr = r[:len(r)-1]\n\t\t\tlogger.Errorf(\"termination message contains non taskrun or pipelineresource result keys\")\n\t\t}\n\t}\n\n\t// Remove duplicates (last one wins) and sort by key.\n\tm := map[string]v1beta1.PipelineResourceResult{}\n\tfor _, rr := range r {\n\t\tm[rr.Key] = rr\n\t}\n\tvar r2 []v1beta1.PipelineResourceResult\n\tfor _, v := range m {\n\t\tr2 = append(r2, v)\n\t}\n\tsort.Slice(r2, func(i, j int) bool { return r2[i].Key < r2[j].Key })\n\n\treturn r2, nil\n}", "func DoubleMessageInfo(l Log, msg string) {\n\tl.Info(msg)\n\tfmt.Println(msg)\n}", "func SplitKey(key string) []string {\r\n\treturn strings.Split(key, \":\")\r\n}", "func (d *Dispatcher) key(m *Message) string {\n\t// Message to runnable: Cmds\n\tif m.To != nil && m.To.Type == RunnableIdentifierType {\n\t\treturn fmt.Sprintf(\"to.runnable.%s.%s\", *m.To.Worker, *m.To.Name)\n\t}\n\n\t// Message from runnable: Events\n\tif m.From.Type == RunnableIdentifierType {\n\t\treturn fmt.Sprintf(\"from.runnable.%s.%s\", *m.From.Worker, *m.From.Name)\n\t}\n\treturn \"default\"\n}", "func MsgKey(s string) {\n\tmsgKey = s\n\tgenLevelSlices()\n}", "func parseRedisInfo(info string) map[string]string {\n\t// Feed every line into\n\tresult := strings.Split(info, \"\\r\\n\")\n\n\t// Load redis info values into array\n\tvalues := map[string]string{}\n\n\tfor _, value := range result {\n\t\t// Values are separated by :\n\t\tparts := parseRedisLine(value, \":\")\n\t\tif len(parts) == 2 {\n\t\t\tvalues[parts[0]] = parts[1]\n\t\t}\n\t}\n\treturn values\n}", "func splitKV(s, sep string) (string, string) {\n\tret := strings.SplitN(s, sep, 2)\n\treturn ret[0], ret[1]\n}", "func getTagListMessage(tags tagging.Tagging, urlStr string) tagListMessage {\n\tvar t tagListMessage\n\tvar tagStr string\n\tvar kvPairStr []string\n\ttagStr = strings.Replace(tags.String(), \"\\\\u0026\", \"&\", -1)\n\tt.URL = urlStr\n\tt.TagObj = tags\n\tif tagStr != \"\" {\n\t\tkvPairStr = strings.SplitN(tagStr, \"&\", -1)\n\t\tt.Status = \"success\"\n\t}\n\tfor _, kvPair := range kvPairStr {\n\t\tkvPairSplit := splitStr(kvPair, \"=\", 2)\n\t\tt.Tags = append(t.Tags, tagList{Key: kvPairSplit[0], Value: kvPairSplit[1]})\n\t}\n\n\treturn t\n}", "func (s *Server) processMessages() {\n\tfor i, m := range s.messages {\n\t\tif m.Process() {\n\t\t\ts.messages = append(s.messages[0:i], s.messages[i+1:]...)\n\t\t}\n\t}\n}", "func TraceMsg(logger log.Logger, message string, keyvals ...interface{}) {\n\tMsg(TraceLogger(logger), message, keyvals...)\n}", "func GetAllMessage(scope simpleapi.Scope) *simpleapi.Response {\n\n\t//new data instance\n\tdata := []Data{}\n\n\t//get custom data that hold Mapper\n\tCData := scope.GetCustomData().(*simplestorage.Mapper)\n\tDataMaps := CData.GetRefData()\n\n\tif len(*DataMaps) == 0 {\n\t\t//do not necessarilly send data or error detail...\n\t\t//...coz 204 not showing any data response in browser or Postman\n\t\treturn &simpleapi.Response{\n\t\t\tResponseCode: http.StatusNoContent,\n\t\t}\n\t}\n\n\tfor key, val := range *DataMaps {\n\t\tsingleData := Data{}\n\t\tsingleData.ID = key\n\t\tsingleData.Message = val.(string)\n\t\tdata = append(data, singleData)\n\t}\n\n\tdataResponse := map[string]interface{}{\n\t\t\"size\": len(*DataMaps),\n\t\t\"data\": data,\n\t}\n\t//return message passed and created\n\treturn &simpleapi.Response{\n\t\tResponseCode: http.StatusOK,\n\t\tData: dataResponse,\n\t}\n}", "func (ec *executionContext) _Message(sel []query.Selection, obj *Message) graphql.Marshaler {\n\tfields := graphql.CollectFields(ec.doc, sel, messageImplementors, ec.variables)\n\tout := graphql.NewOrderedMap(len(fields))\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString(\"Message\")\n\t\tcase \"id\":\n\t\t\tout.Values[i] = ec._Message_id(field, obj)\n\t\tcase \"text\":\n\t\t\tout.Values[i] = ec._Message_text(field, obj)\n\t\tcase \"createdBy\":\n\t\t\tout.Values[i] = ec._Message_createdBy(field, obj)\n\t\tcase \"createdAt\":\n\t\t\tout.Values[i] = ec._Message_createdAt(field, obj)\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\n\treturn out\n}", "func importMessage(msg ledgertools.Message) (*importer.Parsed, error) {\n\tif !strings.Contains(msg.From, fromMatcher) {\n\t\treturn nil, nil\n\t}\n\tif !strings.HasPrefix(msg.Subject, subjectPrefix) {\n\t\treturn nil, nil\n\t}\n\n\tdate, err := time.Parse(time.RFC1123Z, msg.Date)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"Parsing date in %v\", msg)\n\t}\n\tdate = date.In(mailimp.PacificTz)\n\n\t// build all these up by looking at the message text\n\tvar checkNumber string\n\tvar comments = make([]string, 0, len(commentMatchers))\n\tvar amount string\n\tvar instrument string\n\n\tsplitter := mailimp.NewLineSplitter(msg.TextPlain)\n\tfor {\n\t\tline, ok := splitter.Next()\n\t\tif !ok {\n\t\t\tbreak\n\t\t}\n\t\tfor _, m := range commentMatchers {\n\t\t\tif m.Match(line) != nil {\n\t\t\t\tcomments = append(comments, line)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif match := receiptMatcher.Match(line); match != nil {\n\t\t\tcheckNumber = match()\n\t\t\tcontinue\n\t\t}\n\n\t\tif match := chargeMatcher.Match(line); match != nil {\n\t\t\t// rest should like like 'Visa ***1234: $20.18'\n\t\t\ttokens := strings.SplitN(match(), \":\", 2)\n\t\t\tif len(tokens) == 2 {\n\t\t\t\tinstrument = tokens[0]\n\t\t\t\tamount = strings.TrimSpace(tokens[1])\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t}\n\n\t// Verify that we found everything we were expecting\n\tif checkNumber == \"\" {\n\t\treturn nil, errors.Errorf(\"Missing valid receipt line in %q\", msg.TextPlain)\n\t}\n\tif len(comments) != len(commentMatchers) {\n\t\treturn nil, errors.Errorf(\"Missing comments. Found %q in %q. Expected to find lines starting with %q\", comments, msg.TextPlain, commentMatchers)\n\t}\n\tif amount == \"\" || instrument == \"\" {\n\t\treturn nil, errors.Errorf(\"charge line in %q\", msg.TextPlain)\n\t}\n\n\treturn importer.NewParsed(\n\t\tdate,\n\t\tcheckNumber,\n\t\tpayee,\n\t\tcomments,\n\t\tamount,\n\t\tinstrument), nil\n}", "func flatten(seq []Event) string {\n\tvar buf bytes.Buffer\n\tfor _, e := range seq {\n\t\tbuf.WriteString(e.Message)\n\t}\n\treturn buf.String()\n}", "func createMessageTwinAndDeltaWithDiffValues() (map[string]*MsgTwin, map[string]string) {\n\tdelta := make(map[string]string)\n\texpected := \"ON\"\n\tactual := \"OFF\"\n\tdelta[\"twin\"] = expected\n\tdelta[\"expected\"] = expected\n\tresultTwin := make(map[string]*MsgTwin)\n\tresultTwin[\"twin\"] = generateTwinActualExpected(dtcommon.TypeUpdated, expected, actual)\n\tresultTwin[\"expected\"] = generateTwinActualExpected(dtcommon.TypeUpdated, expected, \"\")\n\treturn resultTwin, delta\n}", "func (t Topic) Split() (p, n string) {\n\tp, n, _ = t.SplitErr()\n\treturn\n}", "func lexServerMsg(message string) (l *msg.Line, err error) {\n\n\t// make a timestamp as early as possible\n\tt := time.Now()\n\n\t// grab prefix if present\n\tvar prefix string\n\tprefixEnd := -1\n\tif strings.HasPrefix(message, \":\") {\n\t\tprefixEnd = strings.Index(message, \" \")\n\t\tif prefixEnd == -1 {\n\t\t\terr = errors.New(\"Message with only a prefix\")\n\t\t\treturn\n\t\t}\n\t\tprefix = message[1:prefixEnd]\n\t}\n\n\t// grab trailing param if present\n\tvar trailing string\n\ttrailingStart := strings.Index(message, \" :\")\n\tif trailingStart >= 0 {\n\t\ttrailing = message[trailingStart+2:]\n\t} else {\n\t\ttrailingStart = len(message)\n\t}\n\n\ttmp := message[prefixEnd+1 : trailingStart]\n\tcmdAndParams := strings.Fields(tmp)\n\tif len(cmdAndParams) < 1 {\n\t\terr = errors.New(\"Cannot lex command\")\n\t\treturn\n\t}\n\n\tcommand := cmdAndParams[0]\n\tparams := cmdAndParams[1:]\n\tif trailing != \"\" {\n\t\tparams = append(params, trailing)\n\t}\n\n\tnick, ident, host, src, err := resolvePrefix(prefix)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tl = msg.NewLine(message)\n\tl.SetNick(nick)\n\tl.SetIdent(ident)\n\tl.SetHost(host)\n\tl.SetSrc(src)\n\n\tl.SetCmd(command)\n\tl.SetArgs(params)\n\tl.SetTime(t)\n\treturn\n\n}", "func historyDelete(splited []string, length int) {\n if length == 2 {\n connect.DeleteGlobalMessages()\n return\n }\n connect.DeleteLocalMessages(splited[2:])\n}", "func splitByLines(input string, limit int) (results []string) {\n\tif utf8.RuneCountInString(input) <= limit {\n\t\treturn []string{input}\n\t}\n\n\tmessageRunes := []rune(input)\n\tvar splitMessage [][]rune\n\n\tstartIndex := 0\n\tfor {\n\t\tcutIndex := startIndex + limit - 1\n\t\tif cutIndex > len(messageRunes)-1 {\n\t\t\tcutIndex = len(messageRunes) - 1\n\t\t}\n\t\tfullLine := false\n\t\tfor i := cutIndex; i >= startIndex; i-- {\n\t\t\tif messageRunes[i] == '\\n' {\n\t\t\t\tsplitMessage = append(splitMessage, messageRunes[startIndex:i+1])\n\t\t\t\tstartIndex = i + 1\n\t\t\t\tfullLine = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !fullLine {\n\t\t\tsplitMessage = append(splitMessage, messageRunes[startIndex:cutIndex+1])\n\t\t\tstartIndex = cutIndex + 1\n\t\t}\n\t\tif startIndex == len(messageRunes) {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor _, v := range splitMessage {\n\t\tmsg := strings.Trim(string(v), \" \\n\")\n\t\tif len(msg) != 0 {\n\t\t\tresults = append(results, msg)\n\t\t}\n\t}\n\treturn\n}", "func finalMessage(l *Logger, logCat LogCat, v ...interface{}) string {\n\tbase := baseMessage(l, logCat)\n\tmsg := fmt.Sprint(v...)\n\twrappedMsg := fmt.Sprintf(`message=\"%s\"`, msg)\n\n\treturn base + \", \" + wrappedMsg\n}", "func (m *Mapper) Map(topic string, jsonData []byte) (string, *Message, error) {\n\tvar data map[string]interface{}\n\n\tif err := json.Unmarshal(jsonData, &data); err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\tvar mapping *mapping\n\tfor i, r := range m.regexes {\n\t\tif r == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tmatches := r.FindStringSubmatch(topic)\n\t\tif matches == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tgroups := r.SubexpNames()\n\t\tfor j := 1; j < len(matches); j++ {\n\t\t\tif len(matches[j]) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Assign matched value with the group name to the data\n\t\t\tdata[groups[j]] = matches[j]\n\t\t}\n\n\t\tmapping = &m.config.Mappings[i]\n\n\t\tbreak\n\t}\n\n\tif mapping == nil {\n\t\treturn \"\", nil, fmt.Errorf(\"mapping not found\")\n\t}\n\n\tmessage := Message{}\n\tfor k, v := range mapping.Values {\n\t\tval := m.mapKv(k, v, &data)\n\n\t\tif err := m.validateKv(k, val, mapping); err != nil {\n\t\t\treturn \"\", nil, fmt.Errorf(\"validation error: %v (value: %v)\", err, val)\n\t\t}\n\n\t\tmessage[k] = val\n\t}\n\n\treturn mapping.Table, &message, nil\n}", "func createMessageFromAttachments(atts []slack.Attachment) []string {\n\tvar msgs []string\n\tfor _, att := range atts {\n\t\tfor i := len(att.Fields) - 1; i >= 0; i-- {\n\t\t\tmsgs = append(msgs,\n\t\t\t\tfmt.Sprintf(\n\t\t\t\t\t\"%s %s\",\n\t\t\t\t\tatt.Fields[i].Title,\n\t\t\t\t\tatt.Fields[i].Value,\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\n\t\tif att.Text != \"\" {\n\t\t\tmsgs = append(msgs, att.Text)\n\t\t}\n\n\t\tif att.Title != \"\" {\n\t\t\tmsgs = append(msgs, att.Title)\n\t\t}\n\t}\n\n\treturn msgs\n}", "func (l *Logger) Infow(msg string, keysAndValues ...interface{}) {\n\tl.sgLogger.Infow(msg, keysAndValues...)\n\t_ = l.lg.Sync()\n}", "func parseTask(msg string) (string, []string) {\n\tslice := strings.Split(msg, string(MagicRune))\n\treturn slice[0], slice[1:]\n}", "func MessageData(msg map[string]interface{}, data []byte) map[string]interface{} {\n\tmsg[\"data\"] = string(data)\n\treturn msg\n}", "func createMessageTwinAndDeltaWithSameValues() (map[string]*MsgTwin, map[string]string) {\n\tvalue := \"ON\"\n\tdeltas := make(map[string]string)\n\tresultTwins := make(map[string]*MsgTwin)\n\tresultTwins[\"twins\"] = generateTwinActualExpected(dtcommon.TypeUpdated, value, value)\n\treturn resultTwins, deltas\n}", "func FormatMessage(input string) string {\n\tre_leadclose_whtsp := regexp.MustCompile(`^[\\s\\p{Zs}]+|[\\s\\p{Zs}]+$`)\n\tre_inside_whtsp := regexp.MustCompile(`[\\s\\p{Zs}]{2,}`)\n\tfinal := re_leadclose_whtsp.ReplaceAllString(input, \"\")\n\tfinal = re_inside_whtsp.ReplaceAllString(final, \" \")\n\treturn final\n}", "func (j *jobMessage) preSendMessage(key string, val string, match string) {\n\tif bytes.Contains([]byte(key), []byte(match)) {\n\t\t//j.FatalMessageChan[key] <- val\n\t}\n}", "func (b *builder) handleMessage(m *proto.Message) error {\n\tw := &strings.Builder{}\n\tb.format(w, 0, m.Comment, \"type %s struct {\\n\", m.Name)\n\tfor _, e := range m.Elements {\n\t\tswitch e.(type) {\n\t\tcase *proto.NormalField:\n\t\t\tf := e.(*proto.NormalField)\n\t\t\tif err := b.handleMessageField(w, f); err != nil {\n\t\t\t\treturn b.formatError(f.Position, \"error with message field: %v\", err)\n\t\t\t}\n\t\tcase *proto.Enum:\n\t\t\t// Handle the nested enum. This will create a new\n\t\t\t// top level enum as Gunk doesn't currently support\n\t\t\t// nested data structures.\n\t\t\tb.handleEnum(e.(*proto.Enum))\n\t\tcase *proto.Comment:\n\t\t\tb.format(w, 1, e.(*proto.Comment), \"\")\n\t\tcase *proto.MapField:\n\t\t\tmf := e.(*proto.MapField)\n\t\t\tif err := b.handleMessageField(w, mf); err != nil {\n\t\t\t\treturn b.formatError(mf.Position, \"error with message field: %v\", err)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn b.formatError(m.Position, \"unexpected type %T in message\", e)\n\t\t}\n\t}\n\tb.format(w, 0, nil, \"}\")\n\tb.translatedDeclarations = append(b.translatedDeclarations, w.String())\n\treturn nil\n}", "func parseRedisLine(s string, delimeter string) []string {\n\treturn strings.Split(s, delimeter)\n}", "func adaptMessages(input []*sqs.Message) []*Message {\n\toutput := make([]*Message, len(input))\n\tfor i, message := range input {\n\t\toutput[i] = &Message{Body: *message.Body, Handle: *message.ReceiptHandle}\n\t}\n\treturn output\n}" ]
[ "0.60143024", "0.59999645", "0.5932631", "0.5673276", "0.5591553", "0.5550244", "0.5549246", "0.54947376", "0.5455329", "0.54386246", "0.54386246", "0.5306209", "0.52722335", "0.52561706", "0.5222443", "0.5213995", "0.51282877", "0.51198953", "0.5119838", "0.5110843", "0.5098942", "0.5071867", "0.50605315", "0.50545955", "0.5017296", "0.50135577", "0.4996839", "0.4968499", "0.49634495", "0.49473456", "0.49247816", "0.49069285", "0.48941052", "0.488829", "0.48732528", "0.48683074", "0.4860757", "0.4843458", "0.48241094", "0.48124376", "0.4801854", "0.47942224", "0.4735097", "0.4730886", "0.47233015", "0.4722893", "0.47083968", "0.47068492", "0.4700014", "0.46956858", "0.46901092", "0.46862552", "0.4680981", "0.46796483", "0.4679168", "0.46631065", "0.46630692", "0.46620286", "0.46413913", "0.4633506", "0.4622767", "0.46145013", "0.46086586", "0.4607632", "0.46063644", "0.46061423", "0.45842257", "0.45773283", "0.45716074", "0.45629343", "0.4562566", "0.4561657", "0.45616308", "0.4554311", "0.4553444", "0.4549934", "0.45447", "0.45445105", "0.45344087", "0.45339552", "0.45262775", "0.45219928", "0.4519851", "0.45079103", "0.45058423", "0.45025283", "0.4501782", "0.45017564", "0.45005792", "0.44967088", "0.44903642", "0.44880554", "0.44871658", "0.4480615", "0.44690743", "0.4464722", "0.4457372", "0.4453176", "0.44524089", "0.44523403" ]
0.729302
0
preGenerate pre generate key until 1000
preGenerate предварительно сгенерировать ключ до 1000
func (g *Genkey) preGenerate() { var ( i int ) time.Sleep(errorSleep) for i = 0; i < 10; i++ { go func() { var ( key int64 keys []int64 err error ) for { if keys, err = g.client.Ids(100); err != nil { log.Errorf("preGenerate() error(%v) retry", err) time.Sleep(errorSleep) continue } for _, key = range keys { g.keys <- key } } }() } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func genKey(code string, t time.Time) string {\n\treturn fmt.Sprintf(\"%s#%s\", code, t.Format(time.RFC3339))\n}", "func Auto() (pkey []byte, err error) {\n\treturn Generate(defaultBits)\n}", "func generateKey(length int) (key []byte, err error) {\n\tdefer func(start time.Time) {\n\t\tvalue.RecordDataKeyGeneration(start, err)\n\t}(time.Now())\n\tkey = make([]byte, length)\n\tif _, err = rand.Read(key); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn key, nil\n}", "func generatePrivKey() []byte {\n\tpriv := make([]byte, 32)\n\ts := rand.NewSource(time.Now().UnixNano())\n\tr := rand.New(s)\n\tfor i := 0; i < 31; i++ {\n\t\tpriv[i] = byte(r.Intn(256))\n\t}\n\treturn priv\n}", "func (r *RatchetState) genkeys() {\n\th := hmac.New(crypto.SHA256.New, r.dynamic[:])\n\th.Write(r.static[:])\n\tres := h.Sum(nil)\n\tcopy(r.privateKey[:], res)\n\tcurve25519.ScalarBaseMult(&r.PublicKey, &r.privateKey)\n}", "func (s *State) genkeys() {\n\th := hmac.New(sha256.New, s.dynamic[:])\n\th.Write(s.static[:])\n\tres := h.Sum(nil)\n\tcopy(s.privateKey[:], res)\n\tcurve25519.ScalarBaseMult(&s.PublicKey, &s.privateKey)\n}", "func generateKey(c redis.Conn) (string, error) {\n\tvar (\n\t\tkey string\n\t\terr error\n\t)\n\t// loop to exclude collisions\n\tfor i := 0; i < maxCollisions; i++ {\n\t\tkey, err = getKey()\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\t// check that key doesn't exist before\n\t\texists, err := redis.Bool(c.Do(\"HEXISTS\", key, fieldContent))\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif !exists {\n\t\t\treturn key, nil\n\t\t}\n\t}\n\treturn \"\", fmt.Errorf(\"can not get an unique key [%v] after %v attemps\", KeyLen, maxCollisions)\n}", "func keygen() (string, string) {\n priv, _ := config.GenerateRandomBytes(32)\n addr := config.PrivateToAddress(priv)\n return \"0x\"+addr, fmt.Sprintf(\"%x\", priv)\n}", "func (c *HashRing) generateKey(ip string, i int) string {\n\treturn ip + \"#\" + strconv.Itoa(i)\n}", "func Generatecreate(\n\tklen, vlen, loadn, insertn,\n\tseed int64) func(k, v []byte) ([]byte, []byte) {\n\n\tvar text [1024]byte\n\n\tloadn = int64(loadn * rndscale)\n\tintn := (insertn * rndscale)\n\trnd := rand.New(rand.NewSource(seed))\n\tbitmap := make([]byte, ((intn / 8) + 1))\n\n\treturn func(key, value []byte) ([]byte, []byte) {\n\t\tascii, key := makeuniquekey(rnd, bitmap, loadn, intn, klen, text[:0], key)\n\t\t//fmt.Printf(\"create %q\\n\", key)\n\t\tvalue = makevalue(vlen, ascii, value)\n\t\treturn key, value\n\t}\n}", "func (p *siprng) rekey() {\n\tvar k [16]byte\n\tif _, err := io.ReadFull(rand.Reader, k[:]); err != nil {\n\t\tpanic(err.Error())\n\t}\n\tp.k0 = binary.LittleEndian.Uint64(k[0:8])\n\tp.k1 = binary.LittleEndian.Uint64(k[8:16])\n\tp.ctr = 1\n}", "func getKey(keySize int) string {\r\n\trand.Seed(time.Now().UnixNano())\r\n\tchars := []rune(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" +\r\n\t\t\"abcdefghijklmnopqrstuvwxyz\" +\r\n\t\t\"0123456789\")\r\n\t\t\r\n\t// keySize is # obf bits, this function generates in bytes, so /8\r\n\tlength := keySize / 8\r\n\tvar b strings.Builder\r\n\tfor i := 0; i < length; i++ {\r\n\t\tb.WriteRune(chars[rand.Intn(len(chars))])\r\n\t}\r\n\tstr := b.String()\r\n\treturn str\r\n}", "func getRepeatingKey(k []byte, ptx []byte) []byte {\n\treturn bytes.Repeat(k, len(ptx))\n}", "func genkey() {\n\t// Key generation takes a long time, so it's polite to check the user's\n\t// request makes sense first.\n\testablishDir(true)\n\tif _, err := os.Lstat(privateKeyPath); err == nil {\n\t\texitPrintf(\"Error: The private key file (%s) already exists.\\n\",\n\t\t\tprivateKeyPath)\n\t}\n\n\tfmt.Fprintf(os.Stderr, \"Generating a new private key (%s)...\", privateKeyPath)\n\tprivateKey.Generate(rand.Reader)\n\tfmt.Fprintf(os.Stderr, \"\\n\")\n\n\tsaveKey(privateKeyPath, &privateKey)\n}", "func generateSkey() string {\n myTime := fmt.Sprintf(\"%d\", time.Now().Unix())\n str := utils.Md5String(myTime)\n return str[0:6]\n}", "func GenKey(this js.Value, inputs []js.Value) (interface{}, error) {\n\tclaimer, err := credentials.NewClaimer(SysParams)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn claimer, nil\n}", "func UnsafeAuto() (pkey []byte, err error) {\n\treturn Generate(128)\n}", "func generateTwofishKey() (key twofishKey) {\n\tfastrand.Read(key[:])\n\treturn\n}", "func GenerateKey(n int) (string, error) {\n\tbuf := make([]byte, n)\n\t_, err := rand.Read(buf)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn base64.URLEncoding.EncodeToString(buf), nil\n\n}", "func genKeyAndSendCipher(kx *KX, pk *[sntrup4591761.PublicKeySize]byte, ek *[32]byte) (*[32]byte, error) {\n\tc, k, err := sntrup4591761.Encapsulate(rand.Reader, pk)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif ek != nil {\n\t\terr = kx.writeWithKey(c[:], ek)\n\t} else {\n\t\t_, err = xdr.Marshal(kx.Conn, c)\n\t}\n\treturn k, err\n}", "func generate_keys(key string, round_keys *([]string)) {\n\t// The PC1 table\n\tpc1 := [56]int{\n\t\t57, 49, 41, 33, 25, 17, 9,\n\t\t1, 58, 50, 42, 34, 26, 18,\n\t\t10, 2, 59, 51, 43, 35, 27,\n\t\t19, 11, 3, 60, 52, 44, 36,\n\t\t63, 55, 47, 39, 31, 23, 15,\n\t\t7, 62, 54, 46, 38, 30, 22,\n\t\t14, 6, 61, 53, 45, 37, 29,\n\t\t21, 13, 5, 28, 20, 12, 4,\n\t}\n\t// The PC2 table\n\tpc2 := [48]int{\n\t\t14, 17, 11, 24, 1, 5,\n\t\t3, 28, 15, 6, 21, 10,\n\t\t23, 19, 12, 4, 26, 8,\n\t\t16, 7, 27, 20, 13, 2,\n\t\t41, 52, 31, 37, 47, 55,\n\t\t30, 40, 51, 45, 33, 48,\n\t\t44, 49, 39, 56, 34, 53,\n\t\t46, 42, 50, 36, 29, 32,\n\t}\n\t// 1. Compressing the key using the PC1 table\n\tperm_key := \"\"\n\tfor i := 0; i < 56; i++ {\n\t\tperm_key += string(key[pc1[i]-1])\n\t}\n\t// 2. Dividing the key into two equal halves\n\t// left := perm_key.substr(0, 28)\n\tleft := perm_key[0:28]\n\tright := perm_key[28:56]\n\tfor i := 0; i < 16; i++ {\n\t\t// 3.1. For rounds 1, 2, 9, 16 the key_chunks\n\t\t// are shifted by one.\n\t\tif i == 0 || i == 1 || i == 8 || i == 15 {\n\t\t\tleft = shift_left_once(left)\n\t\t\tright = shift_left_once(right)\n\t\t} else {\n\t\t\t// 3.2. For other rounds, the key_chunks\n\t\t\t// are shifted by two\n\t\t\tleft = shift_left_twice(left)\n\t\t\tright = shift_left_twice(right)\n\t\t}\n\t\t// Combining the two chunks\n\t\tcombined_key := left + right\n\t\tround_key := \"\"\n\t\t// Finally, using the PC2 table to transpose the key bits\n\t\tfor i := 0; i < 48; i++ {\n\t\t\tround_key += string(combined_key[pc2[i]-1])\n\t\t}\n\t\t(*round_keys)[i] = round_key\n\t}\n\n}", "func generateRandomKey(length uint8) string {\n\tif length == 0 {\n\t\tlength = 20\n\t}\n\n\trandomKey := random.New().String(length, random.Uppercase+random.Numeric)\n\treturn randomKey\n}", "func TestLazyInvocation(t *testing.T) {\n\tksStorage := memstore.NewMemoryKeySequenceStorage(0, 0)\n\n\tma, _ := protocol.NewMA([]byte{0, 1, 2, 3, 4})\n\tnetID := uint32(0)\n\tidentifier := \"neteui\"\n\t// Start by allocating keys directly\n\tname := fmt.Sprintf(\"%s/%04x/%s\", ma.String(), netID, identifier)\n\tch, err := ksStorage.AllocateKeys(name, 1, 1)\n\tif err != nil {\n\t\tt.Fatal(\"Got error allocating keys (first time)\")\n\t}\n\tfirstID := uint64(0)\n\tfor v := range ch {\n\t\tfirstID = v\n\t}\n\tkg1, _ := NewEUIKeyGenerator(ma, netID, ksStorage)\n\tkg2, _ := NewEUIKeyGenerator(ma, netID, ksStorage)\n\n\t// This ensures the keygen has started all of its goroutines\n\tkg1.NewID(\"foo1\")\n\tkg2.NewID(\"foo2\")\n\n\t// Repeat allocation. The ID should be the next in sequence\n\tch, err = ksStorage.AllocateKeys(name, 1, 1)\n\tif err != nil {\n\t\tt.Fatal(\"Got error allocating keys (second time)\")\n\t}\n\tlastID := uint64(0)\n\tfor v := range ch {\n\t\tlastID = v\n\t}\n\n\tif lastID != (firstID + 1) {\n\t\tt.Fatalf(\"Expected next sequence to start at %d but it started at %d\", (firstID + 1), lastID)\n\t}\n}", "func GenerateKeys() {\n\thashKey := hex.EncodeToString(securecookie.GenerateRandomKey(16))\n\tfmt.Println(hashKey)\n\n\tblockKey := hex.EncodeToString(securecookie.GenerateRandomKey(16))\n\tfmt.Println(blockKey)\n}", "func GenerateKey() ([]byte) {\n\tkey := make([]byte, 24)\n\t_, err := rand.Read(key)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\treturn key\n}", "func GenerateKey(password, identifier string, bits int) (result string, err string) {\n\tr, e := chevronlib.GenerateKey(password, identifier, bits)\n\tresult = r\n\tif e != nil {\n\t\terr = e.Error()\n\t}\n\n\treturn\n}", "func randomKey(n int) string {\n\trand.Seed(time.Now().UnixNano())\n\n\t// Note that the letters i, l, and o are missing.\n\tvar letters = []rune(\"abcdefghjkmnpqrstuvwxyz0123456789\")\n\n\tkey := make([]rune, n)\n\tfor i := range key {\n\t\tkey[i] = letters[rand.Intn(len(letters))]\n\t}\n\n\treturn string(key)\n}", "func (bl *blackList) genKey(ip string, port int) string {\n\tkey := ip\n\tif port >= 0 {\n\t\tkey = genAddress(ip, port)\n\t}\n\treturn key\n}", "func (c *Client) keyGen(session SSHSession) (*bytes.Buffer, error) {\n\tscriptBytes, err := internal.Asset(\"client/scripts/keygen.sh\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create deploy key.\n\tresult, stderr, err := session.Run(string(scriptBytes))\n\n\tif err != nil {\n\t\tlog.Println(stderr.String())\n\t\treturn nil, err\n\t}\n\n\treturn result, nil\n}", "func RandomKeyGenerator(strSize int, randType string) string {\n\tvar dictionary string\n\n\tif randType == _const.AlphaNum {\n\t\tdictionary = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\t}\n\n\tif randType == _const.Alpha {\n\t\tdictionary = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n\t}\n\n\tif randType == _const.Number {\n\t\tdictionary = \"0123456789\"\n\t}\n\n\tvar bytes = make([]byte, strSize)\n\t_, _ = rand.Read(bytes)\n\tfor k, v := range bytes {\n\t\tbytes[k] = dictionary[v%byte(len(dictionary))]\n\t}\n\treturn string(bytes)\n}", "func GeneratePK(bits int) (key *PrivateKey, err error) {\n\tvar rsaKey *rsa.PrivateKey\n\trsaKey, err = rsa.GenerateKey(rand.Reader, bits)\n\tif err == nil {\n\t\tkey = &PrivateKey{rsaKey: rsaKey}\n\t}\n\treturn\n}", "func randomKey() string {\n\tvar buffer bytes.Buffer\n\tpossibles := \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\"\n\tfor i := 0; i < 64; i++ {\n\t\tbuffer.Write([]byte{possibles[rand.Intn(len(possibles))]})\n\t}\n\treturn buffer.String()\n}", "func generateKey() {\n\tpassphrase := os.Getenv(passphraseEnvironmentVariable)\n\tif passphrase == \"\" {\n\t\tprintErrorAndExit(fmt.Errorf(\"skicka: SKICKA_PASSPHRASE \" +\n\t\t\t\"environment variable not set.\\n\"))\n\t}\n\n\t// Derive a 64-byte hash from the passphrase using PBKDF2 with 65536\n\t// rounds of SHA256.\n\tsalt := getRandomBytes(32)\n\thash := pbkdf2.Key([]byte(passphrase), salt, 65536, 64, sha256.New)\n\tif len(hash) != 64 {\n\t\tlog.Fatalf(\"incorrect key size returned by pbkdf2 %d\\n\", len(hash))\n\t}\n\n\t// We'll store the first 32 bytes of the hash to use to confirm the\n\t// correct passphrase is given on subsequent runs.\n\tpassHash := hash[:32]\n\t// And we'll use the remaining 32 bytes as a key to encrypt the actual\n\t// encryption key. (These bytes are *not* stored).\n\tkeyEncryptKey := hash[32:]\n\n\t// Generate a random encryption key and encrypt it using the key\n\t// derived from the passphrase.\n\tkey := getRandomBytes(32)\n\tiv := getRandomBytes(16)\n\tencryptedKey := encryptBytes(keyEncryptKey, iv, key)\n\n\tfmt.Printf(\"; Add the following lines to the [encryption] section\\n\")\n\tfmt.Printf(\"; of your ~/.skicka.config file.\\n\")\n\tfmt.Printf(\"\\tsalt=%s\\n\", hex.EncodeToString(salt))\n\tfmt.Printf(\"\\tpassphrase-hash=%s\\n\", hex.EncodeToString(passHash))\n\tfmt.Printf(\"\\tencrypted-key=%s\\n\", hex.EncodeToString(encryptedKey))\n\tfmt.Printf(\"\\tencrypted-key-iv=%s\\n\", hex.EncodeToString(iv))\n}", "func (this *RedisSequencer) initKey() (bool, error) {\n\t//create key only if it not exists.\n\tret := this.client.SetNX(this.getName(), this.getStart(), 0)\n\tif ret.Err() != nil {\n\t\treturn false, ret.Err()\n\t}\n\treturn ret.Val(), nil\n}", "func keyGen(key string, keyPrefix string, programName string, withProgramName bool) string {\n\tif programName != \"\" && withProgramName {\n\t\tif keyPrefix == \"\" {\n\t\t\treturn fmt.Sprintf(\"%s.%s\", programName, key)\n\t\t}\n\n\t\treturn fmt.Sprintf(\"%s.%s_%s\", programName, keyPrefix, key)\n\t} else {\n\t\tif keyPrefix == \"\" {\n\t\t\treturn key\n\t\t}\n\n\t\treturn fmt.Sprintf(\"%s_%s\", keyPrefix, key)\n\t}\n}", "func genWebActionSecureKey() int64 {\n\tr := rand.New(rand.NewSource(time.Now().Unix()))\n\n\t// Truncate integer for API GW interoperability\n\treturn r.Int63() & MAX_JS_INT\n}", "func (*produceRequest) Key() int16 { return 0 }", "func key(i int) roachpb.Key {\n\tif i < 0 || i > 99999 {\n\t\tpanic(\"key out of bounds\")\n\t}\n\treturn []byte(fmt.Sprintf(\"%05d\", i))\n}", "func GenerateInviteKey() (code string) {\n\tmut.Lock()\n\tdefer mut.Unlock()\n\tcode = strconv.Itoa(randIntRange(1000, 9999))\n\tvalidKeys = append(validKeys, code)\n\treturn code\n}", "func BuildPrimaryKey(key string, isRand bool) string {\n h := md5.New()\n if isRand {\n curT := time.Now().UnixNano()\n ra := rand.New(rand.NewSource(curT))\n key = key + fmt.Sprintf(\"%s\", curT) + fmt.Sprintf(\"%s\", ra.Intn(1000))\n }\n h.Write([]byte(key))\n return fmt.Sprintf(\"%s\", hex.EncodeToString(h.Sum(nil)))\n}", "func main() {\n\ttoAddrs := make([]common.Address, len(toKeys))\n\tfor i, key := range toKeys {\n\t\ttoAddrs[i] = KeyToAddr(key)\n\t}\n\trepeateNonce(3000, 0, 1000, toAddrs, fromKeys)\n}", "func GenerateBase32(length int) string {\n\tbase := new(big.Int)\n\tbase.SetString(\"32\", 10)\n\n\tbase32 := \"234567abcdefghijklmnopqrstuvwxyz\"\n\ttempKey := \"\"\n\tfor i := 0; i < length; i++ {\n\t\tindex, _ := rand.Int(rand.Reader, base)\n\t\ttempKey += string(base32[int(index.Int64())])\n\t}\n\treturn tempKey\n}", "func Benchmark_Generate4096BitKey(b *testing.B) {\n\tname := \"Test key user\"\n\tcomment := \"Generated programatically as a test\"\n\temail := \"test.user@example.org\"\n\n\tfor n := 0; n < b.N; n++ {\n\t\t_, _, err := GenerateRSAKeyPair(4096, name, comment, email)\n\t\tif err != nil {\n\t\t\tb.Errorf(\"Expected nil error generating a 4096-bit RSA key, got: %v\", err)\n\t\t}\n\t}\n}", "func GenerateKey(curve elliptic.Curve, rand io.Reader) ([]byte, *big.Int, *big.Int, error)", "func randomKey(l int64) string {\n\tk := make([]byte, l)\n\tif _, err := io.ReadFull(rand.Reader, k); err != nil {\n\t\treturn \"\"\n\t}\n\treturn hex.EncodeToString(k)\n}", "func (d *Daos) GenerateUniqueID(key string) string {\n\t// Instance of DB\n\t// INFO: dependent on mongo package\n\tdb := d.GetDB()\n\tdefer db.Session.Close()\n\tresult := counter{}\n\tif _, err := db.C(collectionCounter).Find(bson.M{\"key\": key}).Apply(mgo.Change{\n\t\tUpdate: bson.M{\"$set\": bson.M{\"key\": key}, \"$inc\": bson.M{\"value\": 1}},\n\t\tUpsert: true,\n\t\tReturnNew: true,\n\t}, &result); err != nil {\n\t\tfmt.Println(\"Autoincrement error(1) : \", err.Error())\n\t\treturn \"\"\n\t}\n\tvar collReg CollectionRegistory\n\tif err := db.C(\"collectionregister\").Find(bson.M{\"code\": key}).One(&collReg); err != nil {\n\t\tfmt.Println(\"reg error : \", err.Error())\n\t\treturn \"\"\n\t}\n\tdig := fmt.Sprintf(\"%dd\", collReg.Digits)\n\tstr := \"%v%0\" + dig + \"%v\"\n\tfmt.Println(dig, str)\n\treturn fmt.Sprintf(str, collReg.Prefix, result.Value, collReg.SUffix)\n}", "func KeyGen(key string, keyPrefix string, programName string, withProgramName bool) string {\n\tfinalKey := keyGen(key, keyPrefix, programName, withProgramName)\n\treturn escapeKey(finalKey)\n}", "func GenKey(ip, port string) (kyber.Scalar, kyber.Point) {\n\tpriKey := crypto.Ed25519Curve.Scalar().SetInt64(int64(GetUniqueIDFromIPPort(ip, port))) // TODO: figure out why using a random hash value doesn't work for private key (schnorr)\n\tpubKey := pki.GetPublicKeyFromScalar(priKey)\n\n\treturn priKey, pubKey\n}", "func TestKeygenWithTooLargeNetID(t *testing.T) {\n\tstorage := memstore.NewMemoryKeySequenceStorage(0, 0)\n\n\t// 25 bytes are used for the ID\n\t// MA-S is 36 bits, 64-36-25=3 bits for NetID\n\tmaSmall, err := protocol.NewMA([]byte{1, 2, 3, 4, 5})\n\tif err != nil {\n\t\tt.Fatal(\"Could not create MA-S EUI: \", err)\n\t}\n\n\t_, err = NewEUIKeyGenerator(maSmall, protocol.MaxNetworkBitsMAS+1, storage)\n\tif err == nil {\n\t\tt.Error(\"Expected error when creating key generator with too big NetID and MA-S EUI\")\n\t}\n\t// Then something that will fit exactly\n\t_, err = NewEUIKeyGenerator(maSmall, protocol.MaxNetworkBitsMAS, storage)\n\tif err != nil {\n\t\tt.Error(\"Couldn't create key generator with MA-S/3 bit NetID: \", err)\n\t}\n\n\t// MA-M is 28 bits, 64-28-25=11 bits for NetID\n\tmaMedium, err := protocol.NewMA([]byte{1, 2, 3, 4})\n\tif err != nil {\n\t\tt.Fatal(\"Could not create MA-M EUI: \", err)\n\t}\n\n\t// Create something with too big NetID\n\t_, err = NewEUIKeyGenerator(maMedium, protocol.MaxNetworkBitsMAM+1, storage)\n\tif err == nil {\n\t\tt.Error(\"Expected error when creating key generator with too big NetID and MA-M EUI\")\n\t}\n\t// ...then something that will fit exactly\n\t_, err = NewEUIKeyGenerator(maMedium, protocol.MaxNetworkBitsMAM, storage)\n\tif err != nil {\n\t\tt.Error(\"Expected MA-M EIU and 11 bit NetID to fit: \", err)\n\t}\n\n\t// MA-L is 24 bits, 64-24-25=15 bits for NetID\n\tmaLarge, err := protocol.NewMA([]byte{1, 2, 3})\n\tif err != nil {\n\t\tt.Fatal(\"Could not create MA-L EUI: \", err)\n\t}\n\n\t_, err = NewEUIKeyGenerator(maLarge, protocol.MaxNetworkBitsMAL+1, storage)\n\tif err == nil {\n\t\tt.Error(\"Expected error when using NetID > 15 bits\")\n\t}\n\t_, err = NewEUIKeyGenerator(maLarge, protocol.MaxNetworkBitsMAL, storage)\n\tif err != nil {\n\t\tt.Error(\"Expected MA-L and 15 bit NetID to fit: \", err)\n\t}\n}", "func KeyGenerate_ed(msgprex string,ch chan interface{},id int,cointype string) bool {\n if id < 0 || id >= RpcMaxWorker || id >= len(workers) {\n\tres := RpcDcrmRes{Ret:\"\",Tip:\"dcrm back-end internal error:no find worker id\",Err:GetRetErr(ErrGetWorkerIdError)}\n\tch <- res\n\treturn false\n }\n\n w := workers[id]\n GroupId := w.groupid \n fmt.Println(\"========KeyGenerate_ed============\",\"GroupId\",GroupId)\n if GroupId == \"\" {\n\tres := RpcDcrmRes{Ret:\"\",Tip:\"get group id fail\",Err:fmt.Errorf(\"get group id fail.\")}\n\tch <- res\n\treturn false\n }\n \n ns,_ := GetGroup(GroupId)\n if ns != NodeCnt {\n\tlogs.Debug(\"KeyGenerate_ed,get nodes info error.\")\n\tres := RpcDcrmRes{Ret:\"\",Tip:\"dcrm back-end internal error:the group is not ready\",Err:GetRetErr(ErrGroupNotReady)}\n\tch <- res\n\treturn false \n }\n\t\t\n rand := cryptorand.Reader\n var seed [32]byte\n\n if _, err := io.ReadFull(rand, seed[:]); err != nil {\n\t fmt.Println(\"Error: io.ReadFull(rand, seed)\")\n }\n\n // 1.2 privateKey' = SHA512(seed)\n var sk [64]byte\n var pk [32]byte\n\n seedDigest := sha512.Sum512(seed[:])\n\n seedDigest[0] &= 248\n seedDigest[31] &= 127\n seedDigest[31] |= 64\n\n copy(sk[:], seedDigest[:])\n\n // 1.3 publicKey\n var temSk [32]byte\n copy(temSk[:], sk[:32])\n\n var A ed.ExtendedGroupElement\n ed.GeScalarMultBase(&A, &temSk)\n\n A.ToBytes(&pk)\n\n CPk, DPk := ed.Commit(pk)\n zkPk := ed.Prove(temSk)\n \n ids := GetIds(cointype,GroupId)\n \n mp := []string{msgprex,cur_enode}\n enode := strings.Join(mp,\"-\")\n s0 := \"EDC11\"\n s1 := string(CPk[:])\n ss := enode + common.Sep + s0 + common.Sep + s1\n logs.Debug(\"================kg ed round one,send msg,code is EDC11==================\")\n SendMsgToDcrmGroup(ss,GroupId)\n \n _,tip,cherr := GetChannelValue(ch_t,w.bedc11)\n if cherr != nil {\n\tlogs.Debug(\"get w.bedc11 timeout.\")\n\tres := RpcDcrmRes{Ret:\"\",Tip:tip,Err:fmt.Errorf(\"get ed c11 timeout.\")}\n\tch <- res\n\treturn false \n }\n\n if w.msg_edc11.Len() != (NodeCnt-1) {\n\tlogs.Debug(\"get w.msg_edc11 fail.\")\n\tres := RpcDcrmRes{Ret:\"\",Tip:\"dcrm back-end internal error:get all msg_edc11 fail\",Err:fmt.Errorf(\"get all ed c11 fail.\")}\n\tch <- res\n\treturn false\n }\n var cpks = make(map[string][32]byte)\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\tif IsCurNode(enodes,cur_enode) {\n\t cpks[cur_enode] = CPk \n\t continue\n\t}\n\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\t\n\titer := w.msg_edc11.Front()\n\tfor iter != nil {\n\t data := iter.Value.(string)\n\t m := strings.Split(data,common.Sep)\n\t ps := strings.Split(m[0],\"-\")\n\t if strings.EqualFold(ps[1],en[0]) {\n\t\tvar t [32]byte\n\t\tva := []byte(m[2])\n\t\tcopy(t[:], va[:32])\n\t\tcpks[en[0]] = t\n\t\tbreak\n\t }\n\t iter = iter.Next()\n\t}\n }\n\n s0 = \"EDZK\"\n s1 = string(zkPk[:])\n ss = enode + common.Sep + s0 + common.Sep + s1\n logs.Debug(\"================kg ed round one,send msg,code is EDZK==================\")\n SendMsgToDcrmGroup(ss,GroupId)\n \n _,tip,cherr = GetChannelValue(ch_t,w.bedzk)\n if cherr != nil {\n\tlogs.Debug(\"get w.bedzk timeout.\")\n\tres := RpcDcrmRes{Ret:\"\",Tip:tip,Err:fmt.Errorf(\"get ed zk timeout.\")}\n\tch <- res\n\treturn false \n }\n\n if w.msg_edzk.Len() != (NodeCnt-1) {\n\tlogs.Debug(\"get w.msg_edzk fail.\")\n\tres := RpcDcrmRes{Ret:\"\",Tip:\"dcrm back-end internal error:get w.msg_edzk fail\",Err:fmt.Errorf(\"get all ed zk fail.\")}\n\tch <- res\n\treturn false\n }\n\n var zks = make(map[string][64]byte)\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\tif IsCurNode(enodes,cur_enode) {\n\t zks[cur_enode] = zkPk\n\t continue\n\t}\n\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\t\n\titer := w.msg_edzk.Front()\n\tfor iter != nil {\n\t data := iter.Value.(string)\n\t m := strings.Split(data,common.Sep)\n\t ps := strings.Split(m[0],\"-\")\n\t if strings.EqualFold(ps[1],en[0]) {\n\t\tvar t [64]byte\n\t\tva := []byte(m[2])\n\t\tcopy(t[:], va[:64])\n\t\tzks[en[0]] = t\n\t\tbreak\n\t }\n\t iter = iter.Next()\n\t}\n }\n\n s0 = \"EDD11\"\n s1 = string(DPk[:])\n ss = enode + common.Sep + s0 + common.Sep + s1\n logs.Debug(\"================kg ed round one,send msg,code is EDD11==================\")\n SendMsgToDcrmGroup(ss,GroupId)\n \n _,tip,cherr = GetChannelValue(ch_t,w.bedd11)\n if cherr != nil {\n\tlogs.Debug(\"get w.bedd11 timeout.\")\n\tres := RpcDcrmRes{Ret:\"\",Tip:tip,Err:fmt.Errorf(\"get ed d11 timeout.\")}\n\tch <- res\n\treturn false \n }\n\n if w.msg_edd11.Len() != (NodeCnt-1) {\n\tlogs.Debug(\"get w.msg_edd11 fail.\")\n\tres := RpcDcrmRes{Ret:\"\",Tip:\"dcrm back-end internal error:get msg_edd11 fail\",Err:fmt.Errorf(\"get all ed d11 fail.\")}\n\tch <- res\n\treturn false\n }\n var dpks = make(map[string][64]byte)\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\tif IsCurNode(enodes,cur_enode) {\n\t dpks[cur_enode] = DPk\n\t continue\n\t}\n\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\t\n\titer := w.msg_edd11.Front()\n\tfor iter != nil {\n\t data := iter.Value.(string)\n\t m := strings.Split(data,common.Sep)\n\t ps := strings.Split(m[0],\"-\")\n\t if strings.EqualFold(ps[1],en[0]) {\n\t\tvar t [64]byte\n\t\tva := []byte(m[2])\n\t\tcopy(t[:], va[:64])\n\t\tdpks[en[0]] = t\n\t\tbreak\n\t }\n\t iter = iter.Next()\n\t}\n }\n\n //1.4\n //fixid := []string{\"36550725515126069209815254769857063254012795400127087205878074620099758462980\",\"86773132036836319561089192108022254523765345393585629030875522375234841566222\",\"80065533669343563706948463591465947300529465448793304408098904839998265250318\"}\n var uids = make(map[string][32]byte)\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\t//num,_ := new(big.Int).SetString(fixid[k],10)\n\tvar t [32]byte\n\t//copy(t[:], num.Bytes())\n\tcopy(t[:], id.Bytes())\n\tif len(id.Bytes()) < 32 {\n\t l := len(id.Bytes())\n\t for j:= l;j<32;j++ {\n\t\tt[j] = byte(0x00)\n\t }\n\t}\n\tuids[en[0]] = t\n }\n\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\tCPkFlag := ed.Verify(cpks[en[0]],dpks[en[0]])\n\tif !CPkFlag {\n\t fmt.Println(\"Error: Commitment(PK) Not Pass at User: %s\",en[0])\n\t res := RpcDcrmRes{Ret:\"\",Tip:\"dcrm back-end internal error:commitment check fail in req ed pubkey\",Err:fmt.Errorf(\"Commitment(PK) Not Pass at User.\")}\n\t ch <- res\n\t return false\n\t}\n }\n\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\tdpk := dpks[en[0]]\n\tvar t [32]byte\n\tcopy(t[:], dpk[32:])\n\tzkPkFlag := ed.Verify_zk(zks[en[0]], t)\n\tif !zkPkFlag {\n\t\tfmt.Println(\"Error: ZeroKnowledge Proof (Pk) Not Pass at User: %s\", en[0])\n\t\tres := RpcDcrmRes{Ret:\"\",Tip:\"dcrm back-end internal error:zeroknowledge check fail\",Err:fmt.Errorf(\"ZeroKnowledge Proof (Pk) Not Pass.\")}\n\t\tch <- res\n\t\treturn false\n\t}\n }\n\n // 2.5 calculate a = SHA256(PkU1, {PkU2, PkU3})\n var a [32]byte\n var aDigest [64]byte\n var PkSet []byte\n\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\tdpk := dpks[en[0]]\n\tPkSet = append(PkSet[:], (dpk[32:])...)\n }\n h := sha512.New()\n dpk := dpks[cur_enode]\n h.Write(dpk[32:])\n h.Write(PkSet)\n h.Sum(aDigest[:0])\n ed.ScReduce(&a, &aDigest)\n\n // 2.6 calculate ask\n var ask [32]byte\n var temSk2 [32]byte\n copy(temSk2[:], sk[:32])\n ed.ScMul(&ask, &a, &temSk2)\n \n // 2.7 calculate vss\n /*var inputid [][32]byte\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype)\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\tid := []byte(uids[en[0]])\n\tinputid = append(inputid,id[:])\n }*/\n\n _, cfsBBytes, shares := ed.Vss2(ask,ThresHold, NodeCnt,uids)\n\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\n\tif enodes == \"\" {\n\t logs.Debug(\"=========KeyGenerate_ed,don't find proper enodes========\")\n\t res := RpcDcrmRes{Ret:\"\",Tip:\"dcrm back-end internal error:get enode by uid fail\",Err:GetRetErr(ErrGetEnodeByUIdFail)}\n\t ch <- res\n\t return false\n\t}\n\t\n\tif IsCurNode(enodes,cur_enode) {\n\t continue\n\t}\n\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\tfor k,v := range shares {\n\t if strings.EqualFold(k,en[0]) {\n\t\ts0 := \"EDSHARE1\"\n\t\ts1 := string(v[:])\n\t\tss := enode + common.Sep + s0 + common.Sep + s1\n\t\tlogs.Debug(\"================kg ed round two,send msg,code is EDSHARE1==================\")\n\t\tSendMsgToPeer(enodes,ss)\n\t\tbreak\n\t }\n\t}\n }\n\n _,tip,cherr = GetChannelValue(ch_t,w.bedshare1)\n if cherr != nil {\n\tlogs.Debug(\"get w.bedshare1 timeout in keygenerate.\")\n\tres := RpcDcrmRes{Ret:\"\",Tip:tip,Err:fmt.Errorf(\"get ed share1 fail.\")}\n\tch <- res\n\treturn false \n }\n logs.Debug(\"================kg ed round two,receiv msg,code is EDSHARE1.==================\")\n\n if w.msg_edshare1.Len() != (NodeCnt-1) {\n\tlogs.Debug(\"get w.msg_edshare1 fail.\")\n\tres := RpcDcrmRes{Ret:\"\",Tip:\"dcrm back-end internal error:get all msg_edshare1 fail\",Err:fmt.Errorf(\"get all ed share1 fail.\")}\n\tch <- res\n\treturn false\n }\n\n var edshares = make(map[string][32]byte)\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\tif IsCurNode(enodes,cur_enode) {\n\t edshares[cur_enode] = shares[cur_enode]\n\t continue\n\t}\n\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\t\n\titer := w.msg_edshare1.Front()\n\tfor iter != nil {\n\t data := iter.Value.(string)\n\t m := strings.Split(data,common.Sep)\n\t ps := strings.Split(m[0],\"-\")\n\t if strings.EqualFold(ps[1],en[0]) {\n\t\tvar t [32]byte\n\t\tva := []byte(m[2]) \n\t\tcopy(t[:], va[:32])\n\t\tedshares[en[0]] = t\n\t\tbreak\n\t }\n\t iter = iter.Next()\n\t}\n }\n\n s0 = \"EDCFSB\"\n ss = enode + common.Sep + s0 + common.Sep\n for _,v := range cfsBBytes {\n\tvv := string(v[:])\n\tss = ss + vv + common.Sep\n }\n ss = ss + \"NULL\"\n\n logs.Debug(\"================kg ed round two,send msg,code is EDCFSB==================\")\n SendMsgToDcrmGroup(ss,GroupId)\n\n _,tip,cherr = GetChannelValue(ch_t,w.bedcfsb)\n if cherr != nil {\n\tlogs.Debug(\"get w.bedcfsb timeout.\")\n\tres := RpcDcrmRes{Ret:\"\",Tip:tip,Err:fmt.Errorf(\"get ed cfsb timeout.\")}\n\tch <- res\n\treturn false \n }\n\n if w.msg_edcfsb.Len() != (NodeCnt-1) {\n\tlogs.Debug(\"get w.msg_edcfsb fail.\")\n\tres := RpcDcrmRes{Ret:\"\",Tip:\"dcrm back-end internal error:get all msg_edcfsb fail\",Err:fmt.Errorf(\"get all ed cfsb fail.\")}\n\tch <- res\n\treturn false\n }\n var cfsbs = make(map[string][][32]byte)\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\tif IsCurNode(enodes,cur_enode) {\n\t cfsbs[cur_enode] = cfsBBytes\n\t continue\n\t}\n\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\t\n\titer := w.msg_edcfsb.Front()\n\tfor iter != nil {\n\t data := iter.Value.(string)\n\t m := strings.Split(data,common.Sep)\n\t ps := strings.Split(m[0],\"-\")\n\t if strings.EqualFold(ps[1],en[0]) {\n\t\tmm := m[2:]\n\t\tvar cfs [][32]byte\n\t\tfor _,tmp := range mm {\n\t\t if tmp == \"NULL\" {\n\t\t\tbreak\n\t\t }\n\t\t var t [32]byte\n\t\t va := []byte(tmp)\n\t\t copy(t[:], va[:32])\n\t\t cfs = append(cfs,t)\n\t\t}\n\t\tcfsbs[en[0]] = cfs\n\t\tbreak\n\t }\n\t iter = iter.Next()\n\t}\n }\n\n // 3.1 verify share\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\t\n\tshareUFlag := ed.Verify_vss(edshares[en[0]],uids[cur_enode],cfsbs[en[0]])\n\n\tif !shareUFlag {\n\t\tfmt.Println(\"Error: VSS Share Verification Not Pass at User: %s\",en[0])\n\t\tres := RpcDcrmRes{Ret:\"\",Tip:\"dcrm back-end internal error:VSS Share verification fail\",Err:fmt.Errorf(\"VSS Share Verification Not Pass.\")}\n\t\tch <- res\n\t\treturn false\n\t}\n }\n\n // 3.2 verify share2\n var a2 [32]byte\n var aDigest2 [64]byte\n\n var PkSet2 []byte\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\tvar temPk [32]byte\n\tt := dpks[en[0]]\n\tcopy(temPk[:], t[32:])\n\tPkSet2 = append(PkSet2[:], (temPk[:])...)\n }\n \n h = sha512.New()\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\tvar temPk [32]byte\n\tt := dpks[en[0]]\n\tcopy(temPk[:], t[32:])\n\n\th.Reset()\n\th.Write(temPk[:])\n\th.Write(PkSet2)\n\th.Sum(aDigest2[:0])\n\ted.ScReduce(&a2, &aDigest2)\n\n\tvar askB, A ed.ExtendedGroupElement\n\tA.FromBytes(&temPk)\n\ted.GeScalarMult(&askB, &a2, &A)\n\n\tvar askBBytes [32]byte\n\taskB.ToBytes(&askBBytes)\n\n\tt2 := cfsbs[en[0]]\n\ttt := t2[0]\n\tif !bytes.Equal(askBBytes[:], tt[:]) {\n\t\tfmt.Println(\"Error: VSS Coefficient Verification Not Pass at User: %s\",en[0])\n\t\tres := RpcDcrmRes{Ret:\"\",Tip:\"dcrm back-end internal error:VSS Coefficient verification fail\",Err:fmt.Errorf(\"VSS Coefficient Verification Not Pass.\")}\n\t\tch <- res\n\t\treturn false\n\t}\n }\n\n // 3.3 calculate tSk\n var tSk [32]byte\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\tt := edshares[en[0]]\n\ted.ScAdd(&tSk, &tSk, &t)\n }\n\n // 3.4 calculate pk\n var finalPk ed.ExtendedGroupElement\n var finalPkBytes [32]byte\n\n i := 0\n for _,id := range ids {\n\tenodes := GetEnodesByUid(id,cointype,GroupId)\n\ten := strings.Split(string(enodes[8:]),\"@\")\n\tvar temPk [32]byte\n\tt := dpks[en[0]]\n\tcopy(temPk[:], t[32:])\n\n\th.Reset()\n\th.Write(temPk[:])\n\th.Write(PkSet2)\n\th.Sum(aDigest2[:0])\n\ted.ScReduce(&a2, &aDigest2)\n\n\tvar askB, A ed.ExtendedGroupElement\n\tA.FromBytes(&temPk)\n\ted.GeScalarMult(&askB, &a2, &A)\n\n\tif i == 0 {\n\t\tfinalPk = askB\n\t} else {\n\t\ted.GeAdd(&finalPk, &finalPk, &askB)\n\t}\n\n\ti++\n }\n \n finalPk.ToBytes(&finalPkBytes)\n\n //save the local db\n //sk:pk:tsk:pkfinal\n save := string(sk[:]) + common.Sep11 + string(pk[:]) + common.Sep11 + string(tSk[:]) + common.Sep11 + string(finalPkBytes[:])\n \n w.edsave.PushBack(save)\n w.edpk.PushBack(string(finalPkBytes[:]))\n\n return true\n}", "func GenerateKey() []byte {\n\treturn RandAsciiBytes(KeySize)\n}", "func generateKey(args []string) string {\n\treturn strings.Join(args, \" \")\n}", "func GenerateBargainKey(addr string) string {\n\treturn fmt.Sprintf(\"bargain_addr_%s\", addr)\n}", "func generateKey() (crypto.PrivateKey, error) {\n\tseed := make([]byte, crypto.KeyGenSeedMinLenECDSASecp256k1)\n\tn, err := rand.Read(seed)\n\tif err != nil || n != crypto.KeyGenSeedMinLenECDSASecp256k1 {\n\t\treturn nil, err\n\t}\n\treturn utils.GenerateUnstakedNetworkingKey(seedFixture(n))\n}", "func Generate(start int64) string {\n\n\texpiry := start + 6000\n\n\tmessage := fmt.Sprintf(\"st=%d~exp=%d~acl=/*\", start, expiry)\n\n\takamaiEncryptionKey := \"05fc1a01cac94bc412fc53120775f9ee\"\n\n\thexedAkamaiEncryptionKey, err := hex.DecodeString(akamaiEncryptionKey)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\thmacInstance := hmac.New(sha256.New, hexedAkamaiEncryptionKey)\n\thmacInstance.Write([]byte(message))\n\thmacedMessage := hex.EncodeToString(hmacInstance.Sum(nil))\n\n\treturn fmt.Sprintf(\"%s~hmac=%s\", message, hmacedMessage)\n}", "func genTokenKey(key string, prefix string) string {\n return RedisKeyPrefix + prefix + key\n}", "func cpuperf() (int64, error) {\n\tvar diff time.Duration = 0\n\tvar i int64 = 0\n\tstart := time.Now()\n\n\tfor {\n\t\tif _, err := scrypt.Key(nil, nil, 128, 1, 1, 0); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\ti += 512\n\t\tdiff = time.Since(start)\n\t\tif diff > 10*time.Millisecond {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn i * int64(time.Second) / int64(diff), nil\n}", "func GenKeys(n int, prealloc string) GenOption {\n\treturn func(gc *GenesisCfg) error {\n\t\tif gc.KeysToGen > 0 {\n\t\t\treturn fmt.Errorf(\"repeated genkeys not supported\")\n\t\t}\n\t\tgc.KeysToGen = n\n\t\tfor i := 0; i < n; i++ {\n\t\t\tgc.PreallocatedFunds = append(gc.PreallocatedFunds, prealloc)\n\t\t}\n\t\treturn nil\n\t}\n}", "func genPubkey() ([]byte, []byte) {\n\t_, pub := btcec.PrivKeyFromBytes(btcec.S256(), randomBytes(32))\n\tpubkey := pub.SerializeCompressed()\n\tpkHash := btcutil.Hash160(pubkey)\n\treturn pubkey, pkHash\n}", "func generateKeyPairName() string {\n\tid := fmt.Sprintf(\"%x\", rand.Int())\n\treturn securityGroupNamePrefix + id\n}", "func GenerateCoinKey(addr string) string {\n\treturn fmt.Sprintf(\"coin_addr_%s\", addr)\n}", "func (s *streamKey) generateID(now time.Time) string {\n\tts := uint64(now.UnixNano()) / 1_000_000\n\n\tnext := fmt.Sprintf(\"%d-%d\", ts, 0)\n\tif s.lastAllocatedID != \"\" && streamCmp(s.lastAllocatedID, next) >= 0 {\n\t\tlast, _ := parseStreamID(s.lastAllocatedID)\n\t\tnext = fmt.Sprintf(\"%d-%d\", last[0], last[1]+1)\n\t}\n\n\tlastID := s.lastIDUnlocked()\n\tif streamCmp(lastID, next) >= 0 {\n\t\tlast, _ := parseStreamID(lastID)\n\t\tnext = fmt.Sprintf(\"%d-%d\", last[0], last[1]+1)\n\t}\n\n\ts.lastAllocatedID = next\n\treturn next\n}", "func generateKey(cID, taskID string) (string, error) {\n\tif cutil.IsEmptyStr(cID) {\n\t\treturn \"\", errors.Wrapf(errorType.ErrEmptyValue, \"cID\")\n\t}\n\n\tif cutil.IsEmptyStr(taskID) {\n\t\treturn \"\", errors.Wrapf(errorType.ErrEmptyValue, \"taskID\")\n\t}\n\n\treturn fmt.Sprintf(\"%s%s%s\", cID, \"@\", taskID), nil\n}", "func generateSerialNumber() (*big.Int, error) {\n\tserialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)\n\treturn rand.Int(rand.Reader, serialNumberLimit)\n}", "func overrideGenerateKey(c *gc.C) testing.Restorer {\n\trestorer := testing.PatchValue(ssh.RSAGenerateKey, func(random io.Reader, bits int) (*rsa.PrivateKey, error) {\n\t\tif pregeneratedKey != nil {\n\t\t\treturn pregeneratedKey, nil\n\t\t}\n\t\tkey, err := generateRSAKey(random)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tpregeneratedKey = key\n\t\treturn key, nil\n\t})\n\treturn restorer\n}", "func GenerateWithPrefix(size int, prefix string) string {\n\tsize = size - 1 - len(prefix)\n\n\trandom := prefix + randomString(size)\n\tcontrolDigit := strconv.Itoa(generateControlDigit(random))\n\n\treturn random + controlDigit\n}", "func GenerateAPIKey() string {\n\treturn uniuri.NewLenChars(16, []byte(\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"))\n}", "func RandProcKey() ProcKey {\n\treturn ProcKey(uuid.New())\n}", "func KeyGen(k int) Key {\n\te := big.NewInt(e)\n\tp, pp := GeneratePrime(k / 2)\n\tq, qq := GeneratePrime(k / 2)\n\tn := big.NewInt(0).Mul(p, q)\n\n\tnn := big.NewInt(0).Mul(pp, qq)\n\td := big.NewInt(0).ModInverse(e, nn)\n\treturn Key{e: e, d: d, n: n}\n}", "func GenerateMultiPrimeKey(random io.Reader, nprimes int, bits int) (*rsa.PrivateKey, error)", "func (c *Client) Generate(srv string) (string, error) {\n\tv := strings.Split(srv, \":\")\n\tif len(v) != 2 {\n\t\treturn \"\", fmt.Errorf(\"srp: invalid server public key\")\n\t}\n\n\tsalt, err := hex.DecodeString(v[0])\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"srp: invalid server public key\")\n\t}\n\n\tB, ok1 := big.NewInt(0).SetString(v[1], 16)\n\tif !ok1 {\n\t\treturn \"\", fmt.Errorf(\"srp: invalid server public key\")\n\t}\n\n\tpf := c.s.pf\n\tzero := big.NewInt(0)\n\tz := big.NewInt(0).Mod(B, pf.N)\n\tif zero.Cmp(z) == 0 {\n\t\treturn \"\", fmt.Errorf(\"srp: invalid server public key\")\n\t}\n\n\tu := c.s.hashint(pad(c.xA, pf.n), pad(B, pf.n))\n\tif u.Cmp(zero) == 0 {\n\t\treturn \"\", fmt.Errorf(\"srp: invalid server public key\")\n\t}\n\n\t// S := ((B - kg^x) ^ (a + ux)) % N\n\n\t//x := c.s.hashint(c.i, c.p, salt)\n\tx, err := c.s.genX(c.p, salt)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tt0 := big.NewInt(0).Exp(pf.g, x, pf.N)\n\tt0 = t0.Mul(t0, c.k)\n\n\tt1 := big.NewInt(0).Sub(B, t0)\n\tt2 := big.NewInt(0).Add(c.a, big.NewInt(0).Mul(u, x))\n\tS := big.NewInt(0).Exp(t1, t2, pf.N)\n\n\tc.xK = c.s.hashbyte(S.Bytes())\n\tc.xM = c.s.hashbyte(c.xK, c.xA.Bytes(), B.Bytes(), c.i, salt, pf.N.Bytes(), pf.g.Bytes())\n\n\t//fmt.Printf(\"Client %d:\\n\\tx=%x\\n\\tS=%x\\n\\tK=%x\\n\\tM=%x\\n\", c.n *8, x, S, c.xK, c.xM)\n\n\treturn hex.EncodeToString(c.xM), nil\n}", "func GenerateBargainTrackKey(addr string) string {\n\treturn fmt.Sprintf(\"bargain_track_addr_%s\", addr)\n}", "func generateKeys() (pub, priv key, err error) {\n\treturn box.GenerateKey(rand.Reader)\n}", "func genKey() *Key {\n\tprivKey := crypto.GenPrivKeyEd25519()\n\treturn &Key{\n\t\tAddress: privKey.PubKey().Address(),\n\t\tPubKey: privKey.PubKey(),\n\t\tPrivKey: privKey,\n\t}\n}", "func BenchmarkKeygen(b *testing.B) {\n\tseqStorage := memstore.NewMemoryKeySequenceStorage(0, 0)\n\tma, _ := protocol.NewMA([]byte{5, 4, 3, 2, 1})\n\tnetID := uint32(1)\n\tmemkeyGenerator, _ := NewEUIKeyGenerator(ma, netID, seqStorage)\n\n\tfor i := 0; i < b.N; i++ {\n\t\t_, err := memkeyGenerator.NewAppEUI()\n\t\tif err != nil {\n\t\t\tb.Fatal(\"Got error retrieving key: \", err)\n\t\t}\n\t}\n}", "func GenSessionKey() string {\n\n b := make([]byte, 16)\n\n t := time.Now().Unix()\n tmpid := uint16(atomic.AddUint32(&uuid, 1))\n\n b[0] = byte(255)\n b[1] = byte(0)\n b[2] = byte(tmpid)\n b[3] = byte(tmpid >> 8)\n\n b[4] = byte(t)\n b[5] = byte(t >> 8)\n b[6] = byte(t >> 16)\n b[7] = byte(t >> 24)\n\n c, _ := rc4.NewCipher([]byte{0x0c, b[2], b[3], b[0]})\n c.XORKeyStream(b[8:], b[:8])\n\n guid := fmt.Sprintf(\"%x-%x-%x-%x-%x\", b[:4], b[4:6], b[6:8], b[8:12], b[12:])\n h := md5.New()\n io.WriteString(h, guid)\n io.WriteString(h, MD5key)\n\n return fmt.Sprintf(\"%x-%x-%x-%x-%x--%x\", b[:4], b[4:6], b[6:8], b[8:12], b[12:], h.Sum(nil))\n}", "func genServiceKey() ([]byte, error) {\n\tpriv, _, err := crypto.GenerateEd25519Key(crand.Reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tseed, err := seedFromEd25519PrivateKey(priv)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn seed, err\n}", "func GenerateOneTimePK(pkP publicKeyPair, hasher hash.Hash, Curve elliptic.Curve) (Px, Py, Rx, Ry *big.Int) {\n\n\tif Curve == nil {\n\t\tCurve = defaultCurve\n\t}\n\n\tif hasher == nil {\n\t\thasher = defaultHasher\n\t} else if hasher.Size() != 32 {\n\t\tpanic(\"only hashes with outputsize of 32 bytes allowed!\", )\n\t}\n\n\thasher.Reset()\n\tr := RandFieldElement(Curve)\n\t// X1,y1 = Hs(rA)G\n\tPx, Py = Curve.ScalarMult(pkP.Ax, pkP.Ay, r.Bytes())\n\tre := hasher.Sum(append(Px.Bytes()[:], Py.Bytes()[:]...))\n\tra := new(big.Int).SetBytes(re[:])\n\tra.Mod(ra, Curve.Params().N)\n\tPx, Py = Curve.ScalarBaseMult(ra.Bytes())\n\t//+BG\n\tPx, Py = Curve.Add(Px, Py, pkP.Bx, pkP.By)\n\tRx, Ry = Curve.ScalarBaseMult(r.Bytes())\n\treturn\n}", "func (cust *custInfo) getReqId() string{\n rand.Seed(time.Now().UTC().UnixNano())\n //fmt.Println(\"seqn\",seqn)\n seqn := strconv.Itoa(rand.Intn(500))\n cust.reqId = cust.customerId + \":\" + \"1\" + \":\" + seqn\n return cust.reqId\n}", "func generateTradeId() int {\n\tr := rand.Intn(10000)\n\treturn r\n}", "func GenKey() ([]byte, error) {\n\tkey, err := exec.Command(\"wg\", \"genkey\").Output()\n\treturn bytes.Trim(key, \"\\n\"), err\n}", "func TestRandomKeyGen(t *testing.T) {\n\tkey, err := NewRandomKey(os.Getpagesize())\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer key.Wipe()\n\n\tif didCompress(key.data) {\n\t\tt.Errorf(\"Random key (%d bytes) should not be compressible\", key.Len())\n\t}\n}", "func (h *HOTP) Generate(count int64, key string, opts CryptorOpts) (string, error) {\n\tc, err := h.generate(count, []byte(key), opts)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn strconv.Itoa(c), nil\n}", "func GenerateTwofishKey() (key TwofishKey, err error) {\n\t_, err = rand.Read(key[:])\n\treturn\n}", "func Next() int64 {\n\tkeygen.Lock()\n\tkey := keygen.random.Int63()\n\tkeygen.Unlock()\n\treturn key\n}", "func initialize() {\n\t// generate the HMAC key\n\t_, err := rand.Read(k)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\t// calculate blockPossValue\n\tblockPossValue = subIndexSize + 1\n}", "func nextID() string {\n\tbs := make([]byte, 20)\n\tn, err := rand.Read(bs)\n\tif err != nil || n == 0 {\n\t\tlogger.Log(\"generateID\", fmt.Sprintf(\"n=%d, err=%v\", n, err))\n\t\treturn \"\"\n\t}\n\treturn strings.ToLower(hex.EncodeToString(bs))\n}", "func (a *Authenticator) GenerateSeqNumberAndSubKey(keyType int32, keySize int) error {\n\tseq, err := rand.Int(rand.Reader, big.NewInt(math.MaxUint32))\n\tif err != nil {\n\t\treturn err\n\t}\n\ta.SeqNumber = seq.Int64() & 0x3fffffff\n\t//Generate subkey value\n\tsk := make([]byte, keySize, keySize)\n\trand.Read(sk)\n\ta.SubKey = EncryptionKey{\n\t\tKeyType: keyType,\n\t\tKeyValue: sk,\n\t}\n\treturn nil\n}", "func generateKey(curve elliptic.Curve) (private []byte, public []byte, err error) {\n\tvar x, y *big.Int\n\tprivate, x, y, err = elliptic.GenerateKey(curve, rand.Reader)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tpublic = elliptic.Marshal(curve, x, y)\n\treturn\n}", "func GenerateKeys() (*big.Int, [2]*big.Int, error) {\n\tprivateKey, publicKeyG1, err := cloudflare.RandomG1(rand.Reader)\n\tpublicKey := bn256.G1ToBigIntArray(publicKeyG1)\n\n\treturn privateKey, publicKey, err\n}", "func (c *chat) key() int64 {\n\tc.Lock()\n\tdefer c.Unlock()\n\n\t// generates new possible key value\n\tvar key = time.Now().UnixNano()\n\n\t// generated key become actual if the previous key is absent\n\tif c.prev == 0 {\n\t\tc.prev = key\n\t\t// returns actual key\n\t\treturn c.prev\n\t}\n\n\t// calculates minimum next possible key value\n\tc.prev = c.prev + c.latency\n\n\t// generated key become actual if generated key greater than the minimum possible key\n\tif key > c.prev {\n\t\tc.prev = key\n\t}\n\n\t// returns actual key\n\treturn c.prev\n}", "func getKey() (string, error) {\n\tretries := 100\n\ti := 0\n\tb := make([]byte, 10)\n\trand.Read(b)\n\tfor i < retries {\n\t\tkey := fmt.Sprintf(\"%x\", md5.Sum(b))[:10]\n\t\tif exists := client.Exists(key).Val(); !exists {\n\t\t\treturn key, nil\n\t\t}\n\t}\n\treturn \"\", errors.New(\"max retry limit reached\")\n}", "func newKey() key {\n\treturn &[32]byte{}\n}", "func initKeyRenewal(registry *KeyRegistry, period time.Duration, cutoffTime time.Time) (func(), error) {\n\t// Create a new key if it's the first key,\n\t// or if it's older than cutoff time.\n\tif len(registry.keys) == 0 || registry.mostRecentKey.creationTime.Before(cutoffTime) {\n\t\tif _, err := registry.generateKey(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// wrapper function to log error thrown by generateKey function\n\tkeyGenFunc := func() {\n\t\tif _, err := registry.generateKey(); err != nil {\n\t\t\tlog.Printf(\"Failed to generate new key : %v\\n\", err)\n\t\t}\n\t}\n\tif period == 0 {\n\t\treturn keyGenFunc, nil\n\t}\n\n\t// If key rotation is enabled, we'll rotate the key when the most recent\n\t// key becomes stale (older than period).\n\tmostRecentKeyAge := time.Since(registry.mostRecentKey.creationTime)\n\tinitialDelay := period - mostRecentKeyAge\n\tif initialDelay < 0 {\n\t\tinitialDelay = 0\n\t}\n\treturn ScheduleJobWithTrigger(initialDelay, period, keyGenFunc), nil\n}", "func Generate(params Setting, wg *sync.WaitGroup) string {\n\n\tdefer wg.Done()\n\tminLen := params.MinLength\n\tminSpecials := params.MinSpecialCharacters\n\tminDigits := params.MinDigits\n\tminLowers := params.MinLowercase\n\tminUppers := params.MinUppercase\n\tparamsLen := minSpecials + minDigits + minLowers + minUppers\n\n\t// it may happen (and is allowed) that the number of required digits, specials,\n\t// lowers, uppers is higher than the minimum length, then the new mininum is the sum of lenghts\n\tlog.Debug(\"min required length: \", minLen, \", lenth of the required params: \", paramsLen)\n\n\trand.Seed(time.Now().UTC().UnixNano())\n\n\tspecials := randChars(int(minSpecials), AllowedChars.Specials)\n\tdigits := randChars(int(minDigits), AllowedChars.Digits)\n\tlowerLetters := randChars(int(minLowers), AllowedChars.LowerLetters)\n\tupperLetters := randChars(int(minUppers), AllowedChars.UpperLetters)\n\n\tvar allChars CharsSet\n\tallChars = append(allChars, AllowedChars.Specials...)\n\tallChars = append(allChars, AllowedChars.Digits...)\n\tallChars = append(allChars, AllowedChars.LowerLetters...)\n\tallChars = append(allChars, AllowedChars.UpperLetters...)\n\n\tvar charsMix CharsSet\n\tcharsMix = append(charsMix, digits...)\n\tcharsMix = append(charsMix, specials...)\n\tcharsMix = append(charsMix, lowerLetters...)\n\tcharsMix = append(charsMix, upperLetters...)\n\n\tlog.Debug(\"concatenated (pre-shuffled & pre-reviewed): \", string(charsMix), \" [length: \", len(string(charsMix)), \"]\")\n\n\tif minLen > paramsLen {\n\t\tgapSize := int(minLen - paramsLen)\n\t\tgap := make(CharsSet, gapSize)\n\n\t\tfor i := 0; i < gapSize; i++ {\n\t\t\tgap[i] = allChars[rand.Intn(len(allChars))]\n\t\t}\n\n\t\tlog.Debug(\"gap: \", string(gap), \" [length: \", len(string(gap)), \"]\")\n\t\tcharsMix = append(charsMix, gap...)\n\t\tlog.Debug(\"with the gap: \", string(charsMix), \" [length: \", len(string(charsMix)), \"]\")\n\t}\n\n\tlog.Debug(\"concatenated (pre-shuffled): \", string(charsMix), \" [length: \", len(string(charsMix)), \"]\")\n\n\t//shuffle\n\tfor i := range charsMix {\n\t\tj := rand.Intn(i + 1)\n\t\tcharsMix[i], charsMix[j] = charsMix[j], charsMix[i]\n\t}\n\tlog.Debug(\"final (shuffled) password: \", string(charsMix), \" [length: \", len(string(charsMix)), \"]\")\n\n\treturn string(charsMix)\n}", "func generateSecureKey() string {\n\tk := make([]byte, 32)\n\tio.ReadFull(rand.Reader, k)\n\treturn fmt.Sprintf(\"%x\", k)\n}", "func GenHashKey() string {\n\tid := uuid.New()\n\treturn hex.EncodeToString(id[:])\n}", "func GenerateKey() (Key, bool) {\n\tvar key Key = make([]byte, KeySize)\n\n\t_, err := io.ReadFull(PRNG, key)\n\treturn key, err == nil\n}", "func Keygen() (ed25519.Scalar, ed25519.Point) {\n\tsecret_key := ed25519.Random()\n\tpublic_key := H.Mul(secret_key)\n\treturn secret_key, public_key\n}", "func GenerateAccountKey(addr string) string {\n\treturn fmt.Sprintf(\"account_addr_%s\", addr)\n}" ]
[ "0.6533145", "0.6520306", "0.6415669", "0.6267787", "0.6250052", "0.62185055", "0.6217248", "0.61889654", "0.6179897", "0.61647594", "0.6148303", "0.6131615", "0.61281455", "0.6078433", "0.6077706", "0.6039833", "0.60331726", "0.6031663", "0.6017027", "0.6016135", "0.6014589", "0.59470814", "0.59456843", "0.5916867", "0.5915129", "0.5900797", "0.5900726", "0.5860515", "0.58601105", "0.585791", "0.5845136", "0.58375424", "0.5837392", "0.5833206", "0.5824748", "0.58157307", "0.580256", "0.5793309", "0.57920164", "0.5768744", "0.57202095", "0.5713919", "0.57134664", "0.57132864", "0.5705587", "0.57030493", "0.5702683", "0.56914103", "0.56867725", "0.5684144", "0.56688225", "0.5667356", "0.56669927", "0.56558245", "0.56490046", "0.5647882", "0.56426394", "0.5631439", "0.5628046", "0.5626477", "0.56258553", "0.5618794", "0.5611992", "0.5607025", "0.5602667", "0.559719", "0.5589766", "0.55877906", "0.5585398", "0.5578843", "0.5570887", "0.5570861", "0.5563635", "0.5559426", "0.5559346", "0.55490243", "0.55445987", "0.5543894", "0.55412406", "0.55258346", "0.5522105", "0.5518322", "0.55101323", "0.5507205", "0.5497343", "0.54966223", "0.54918927", "0.54896945", "0.5488914", "0.5477648", "0.54772216", "0.54616946", "0.5459364", "0.54578006", "0.5457564", "0.5454841", "0.5452493", "0.5450109", "0.5448519", "0.54479724" ]
0.7289817
0
nextWeight computes the first possible collation weights following elems for the given level.
nextWeight вычисляет первый возможный набор весов сложения, следующий за elems для заданного уровня.
func nextWeight(level colltab.Level, elems []rawCE) []rawCE { if level == colltab.Identity { next := make([]rawCE, len(elems)) copy(next, elems) return next } next := []rawCE{makeRawCE(elems[0].w, elems[0].ccc)} next[0].w[level]++ if level < colltab.Secondary { next[0].w[colltab.Secondary] = defaultSecondary } if level < colltab.Tertiary { next[0].w[colltab.Tertiary] = defaultTertiary } // Filter entries that cannot influence ordering. for _, ce := range elems[1:] { skip := true for i := colltab.Primary; i < level; i++ { skip = skip && ce.w[i] == 0 } if !skip { next = append(next, ce) } } return next }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (e WeightedEdgePair) Weight() float64 { return e.W }", "func (sw *SW) Next() interface{} {\n\tsw.mtx.RLock()\n\tdefer sw.mtx.RUnlock()\n\n\tif sw.elems == nil || len(sw.elems) == 0 {\n\t\treturn nil\n\t}\n\n\tvar total int\n\tnext := &smoothElem{}\n\tfor _, elem := range sw.elems {\n\t\ttotal += elem.effectiveWeight\n\t\telem.currentWeight += elem.effectiveWeight\n\n\t\tif elem.effectiveWeight < elem.weight { // automatic recovery\n\t\t\telem.effectiveWeight++\n\t\t}\n\n\t\tif next == nil || next.currentWeight < elem.currentWeight {\n\t\t\tnext = elem\n\t\t}\n\t}\n\n\tnext.currentWeight -= total\n\treturn next.elem\n}", "func (fields List) Weight() int {\n\tif fields.p == nil {\n\t\treturn 0\n\t}\n\tx, n := uvarint(*(*[]byte)(unsafe.Pointer(&bytes{fields.p, 10, 10})))\n\treturn x + n\n}", "func (w Weighted) Weight() float64 { return float64(w) }", "func Weighted(w0 float64, v0 byte, w1 float64, v1 byte) byte {\n\treturn byte(math.Round((w0*float64(v0) + w1*float64(v1)) / (w0 + w1)))\n}", "func compareWeights(a, b []rawCE) (result int, level colltab.Level) {\n\tfor level := colltab.Primary; level < colltab.Identity; level++ {\n\t\tvar va, vb int\n\t\tfor ia, ib := 0, 0; ia < len(a) || ib < len(b); ia, ib = ia+1, ib+1 {\n\t\t\tia, va = nextVal(a, ia, level)\n\t\t\tib, vb = nextVal(b, ib, level)\n\t\t\tif va != vb {\n\t\t\t\tif va < vb {\n\t\t\t\t\treturn -1, level\n\t\t\t\t} else {\n\t\t\t\t\treturn 1, level\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 0, colltab.Identity\n}", "func (node *LiteralNode) Weight() int {\n\treturn 1\n}", "func Weighted(weights ...int) func() int {\n\trepartition := []int{}\n\tfor i, weight := range weights {\n\t\tfor j := 0; j < weight; j++ {\n\t\t\trepartition = append(repartition, i)\n\t\t}\n\t}\n\tlimit := int64(len(repartition))\n\treturn func() int {\n\t\treturn repartition[int(src.Int63()%limit)]\n\t}\n}", "func (v *Variations) NextWeightedRand() string {\n\trand.Seed(time.Now().UnixNano())\n\n\t// Get a sum total of the probabities of all variations.\n\tvar total int64\n\tfor _, i := range *v {\n\t\ttotal += i\n\t}\n\n\t// Pick a random int between 0 and the total sum.\n\tr := rand.Int63n(total)\n\n\t// Range through the possible variations and subtract the probability\n\t// weight from the random number. If r goes below zero, select the key.\n\tvar k string\n\tvar i int64\n\tfor k, i = range *v {\n\t\tr -= i\n\t\tif r < 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn k\n}", "func (b *Builder) zipWeight() {\n\tmsize := b.size\n\tnewBase := make([]int, msize)\n\tcopy(newBase[:b.size], b.trie.Base[:b.size])\n\tb.trie.Base = newBase\n\n\tnewCheck := make([]int, msize, msize)\n\tcopy(newCheck[:b.size], b.trie.Check[:b.size])\n\tb.trie.Check = newCheck\n}", "func WeightedChoice(choices []Choice) (Choice, error) {\n\t// Based on this algorithm:\n\t// http://eli.thegreenplace.net/2010/01/22/weighted-random-generation-in-python/\n\tvar ret Choice\n\tsum := 0\n\tfor _, c := range choices {\n\t\tsum += c.Weight\n\t}\n\tr, err := IntRange(0, sum)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\tfor _, c := range choices {\n\t\tr -= c.Weight\n\t\tif r < 0 {\n\t\t\treturn c, nil\n\t\t}\n\t}\n\terr = errors.New(\"Internal error - code should not reach this point\")\n\treturn ret, err\n}", "func (this *NodeWeight) Weight() float32 {\n\tavgSpeed := float32(0.0)\n\tfor _, s := range this.speed {\n\t\tavgSpeed += s\n\t}\n\tavgSpeed = avgSpeed / float32(len(this.speed))\n\n\tavgInterval := float32(0.0)\n\tnow := time.Now().UnixNano() / int64(time.Millisecond)\n\tfor _, t := range this.reqTime {\n\t\tavgInterval += float32(now - t)\n\t}\n\tavgInterval = avgInterval / float32(len(this.reqTime))\n\tw := avgSpeed + avgInterval\n\treturn w\n}", "func (rw *RandW) Next() (item interface{}) {\n\tif rw.n == 0 {\n\t\treturn nil\n\t}\n\tif rw.sumOfWeights <= 0 {\n\t\treturn nil\n\t}\n\trandomWeight := rw.r.Intn(rw.sumOfWeights) + 1\n\tfor _, item := range rw.items {\n\t\trandomWeight = randomWeight - item.Weight\n\t\tif randomWeight <= 0 {\n\t\t\treturn item.Item\n\t\t}\n\t}\n\n\treturn rw.items[len(rw.items)-1].Item\n}", "func (g SimplePoint) Weight() int {\n\treturn 2 * 8\n}", "func packweight() int {\n\tk := c[GOLD] / 1000\n\tj := 25\n\tfor iven[j] == 0 && j > 0 {\n\t\tj--\n\t}\n\tfor i := 0; i <= j; i++ {\n\t\tswitch iven[i] {\n\t\tcase 0:\n\t\tcase OSSPLATE, OPLATEARMOR:\n\t\t\tk += 40\n\t\tcase OPLATE:\n\t\t\tk += 35\n\t\tcase OHAMMER:\n\t\t\tk += 30\n\t\tcase OSPLINT:\n\t\t\tk += 26\n\t\tcase OSWORDofSLASHING, OCHAIN, OBATTLEAXE, O2SWORD:\n\t\t\tk += 23\n\t\tcase OLONGSWORD, OSWORD, ORING, OFLAIL:\n\t\t\tk += 20\n\t\tcase OLANCE, OSTUDLEATHER:\n\t\t\tk += 15\n\t\tcase OLEATHER, OSPEAR:\n\t\t\tk += 8\n\t\tcase OORBOFDRAGON, OBELT:\n\t\t\tk += 4\n\t\tcase OSHIELD:\n\t\t\tk += 7\n\t\tcase OCHEST:\n\t\t\tk += 30 + ivenarg[i]\n\t\tdefault:\n\t\t\tk++\n\t\t}\n\t}\n\treturn k\n}", "func (node *BinaryNode) Weight() int {\n\treturn 1 + node.left.Weight() + node.right.Weight()\n}", "func (e *FakeChainSelector) Weight(ctx context.Context, ts *types.TipSet) (big.Int, error) {\n\treturn e.Weigh(ctx, ts)\n}", "func Dec8_bin_RuneWeight(r rune) int32 {\n\tweight, ok := dec8_bin_Weights[r]\n\tif ok {\n\t\treturn weight\n\t} else if r >= 0 && r <= 163 {\n\t\treturn r + 0\n\t} else {\n\t\treturn 2147483647\n\t}\n}", "func (w *Weighted) NextBits(density, scale uint64) (out Uint128) {\n\tw.lastOffset.Inc()\n\treturn w.Bits(w.lastOffset, density, scale)\n}", "func Latin1_bin_RuneWeight(r rune) int32 {\n\tweight, ok := latin1_bin_Weights[r]\n\tif ok {\n\t\treturn weight\n\t} else if r >= 0 && r <= 127 {\n\t\treturn r + 0\n\t} else {\n\t\treturn 2147483647\n\t}\n}", "func RandWeighted(weights []float64) (n int) {\n\tsum := 0.\n\tfor _, w := range weights {\n\t\tsum += w\n\t}\n\tf := rand.Float64() * sum\n\tc := 0.\n\tfor v, w := range weights {\n\t\tc += w\n\t\tif c >= f {\n\t\t\treturn v\n\t\t}\n\t}\n\treturn len(weights) - 1\n}", "func weighted_reward(w map[int]float64, allocation vrp.Allocation) float64 {\n\tvar reward float64\n\tfor id, _ := range allocation {\n\t\treward += w[id] * allocation[id]\n\t}\n\treturn reward\n}", "func Geostd8_bin_RuneWeight(r rune) int32 {\n\tweight, ok := geostd8_bin_Weights[r]\n\tif ok {\n\t\treturn weight\n\t} else if r >= 0 && r <= 127 {\n\t\treturn r + 0\n\t} else {\n\t\treturn 2147483647\n\t}\n}", "func (ki keyInfo) Weight() int {\n\treturn ki.size\n}", "func (o RecordWeightedRoutingPolicyOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v RecordWeightedRoutingPolicy) int { return v.Weight }).(pulumi.IntOutput)\n}", "func (me *Chain) TrainWeighted(tokens []string, weight uint64) {\n\n\tme.wordStats.Add(float64(len(tokens)))\n\n\tkey := me.newKey()\n\n\tfor _, token := range tokens {\n\n\t\tindex := me.matchNode(key)\n\n\t\tif index == -1 {\n\t\t\tnewNode := newChainNode(key)\n\t\t\tme.nodes = append(me.nodes, newNode)\n\t\t\tindex = len(me.nodes) - 1\n\t\t}\n\n\t\tme.nodes[index].TrainWeighted(token, weight)\n\n\t\tkey = me.pushKey(key, token)\n\t}\n\n\tindex := me.matchNode(key)\n\n\tif index == -1 {\n\t\tnewNode := newChainNode(key)\n\t\tme.nodes = append(me.nodes, newNode)\n\t\tindex = len(me.nodes) - 1\n\t}\n\n\tme.nodes[index].TrainWeighted(\"\", weight)\n}", "func (self *Weights) topWeight() (weight,error) {\n\tif len(self.Scale) == 0 {\n\t\treturn 0, ENOWEIGHTSDEFINED\n\t} else { \n\t\treturn self.Scale[len(self.Scale)-1].W,nil\n\t}\n}", "func (lb *smoothWeightedRR) Next() interface{} {\n\ti := lb.nextWeightedItem()\n\tif i == nil {\n\t\treturn nil\n\t}\n\n\treturn i.item\n}", "func (g UndirectWeighted) Weight(xid, yid int64) (w float64, ok bool) {\n\tfe := g.G.Edge(xid, yid)\n\tre := g.G.Edge(yid, xid)\n\n\tf, fOk := g.G.Weight(xid, yid)\n\tif !fOk {\n\t\tf = g.Absent\n\t}\n\tr, rOK := g.G.Weight(yid, xid)\n\tif !rOK {\n\t\tr = g.Absent\n\t}\n\tok = fOk || rOK\n\n\tif g.Merge == nil {\n\t\treturn (f + r) / 2, ok\n\t}\n\treturn g.Merge(f, r, fe, re), ok\n}", "func (p program) entireWeight() (sum int) {\n\tif len(p.children) > 0 {\n\t\tfor i := range p.children {\n\t\t\tsum += p.children[i].entireWeight()\n\t\t}\n\t\treturn p.weight + sum\n\t}\n\treturn p.weight\n}", "func (self *Weights) addIndexWeight(i int, w weight) {\n\tif self.Scale == nil {\n\t\tself.Scale = make([]ScaleEntry,0,500)\n\t}\n\tl := len(self.Scale)\n\tif l == 0 {\n\t\tself.Scale = append(self.Scale,ScaleEntry{I:i,W:w})\n\t} else {\n\t\tself.Scale= append(self.Scale,ScaleEntry{I:i,W:(self.Scale[l-1].W+w)})\n\t}\n}", "func (node *VariableNode) Weight() int {\n\treturn 1\n}", "func (g Graph) ConnectivityWeight(v Vertex) uint8 {\n\tweight := uint8(0)\n\n\tfor i := 0; i < int(g.Size); i++ {\n\t\tfor j := i + 1; j < int(g.Size); j++ {\n\t\t\tshortestPath := g.Path(Vertex(i), Vertex(j))\n\n\t\t\tfor _, p := range shortestPath {\n\t\t\t\tif p == v {\n\t\t\t\t\tweight++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn weight\n}", "func (s *BaseMySqlParserListener) EnterLevelInWeightListElement(ctx *LevelInWeightListElementContext) {\n}", "func (e *edge) Weight() float64 {\n\treturn 1\n}", "func (c Categorical) Reweight(idx int, w float64) {\n\tif w < 0 {\n\t\tpanic(\"categorical: negative weight\")\n\t}\n\tw, c.weights[idx] = c.weights[idx]-w, w\n\tidx++\n\tfor idx > 0 {\n\t\tc.heap[idx-1] -= w\n\t\tidx >>= 1\n\t}\n\tif c.heap[0] <= 0 {\n\t\tpanic(\"categorical: sum of the weights non-positive\")\n\t}\n}", "func (g *LGraph) Weight(sv, ev interface{}) (int, error) {\n\tif err := g.checkExist(sv); err != nil {\n\t\treturn -1, err\n\t}\n\tif err := g.checkExist(ev); err != nil {\n\t\treturn -1, err\n\t}\n\te := g.Edge(sv, ev)\n\tif e == nil {\n\t\treturn -1, errors.New(\"Nil edge\")\n\t}\n\treturn e.weight, nil\n}", "func (v *Validator) Weight() uint64 {\n\treturn v.Wght\n}", "func WeightedChoice(weights []float64) (idx int, err error) {\n\tvar (\n\t\tsum = 0.0\n\t\trnd float64\n\t)\n\t// get sum of weights\n\tfor _, w := range weights {\n\t\tif w > 0 {\n\t\t\tsum += w\n\t\t}\n\t}\n\tif sum <= 0 {\n\t\terr = errInvalidWeights\n\t\treturn\n\t}\n\n\t// get random value\n\tif rnd, err = Float64(); err != nil {\n\t\treturn\n\t}\n\tsum *= rnd\n\n\t// find the random pos\n\tfor i, w := range weights {\n\t\tif w > 0 {\n\t\t\tsum -= w\n\t\t\tif sum < 0 {\n\t\t\t\tidx = i\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tidx = len(weights) - 1\n\treturn\n}", "func (a *AlgorithmDefault) WeightingRelation(\n\tword1ID int,\n\tword2ID int,\n\trank *Rank,\n) float32 {\n\trelationQty := rank.Relation.Node[word1ID][word2ID].Qty\n\n\treturn float32(relationQty)\n}", "func (ts *Typefaces) Weight() []int {\n\tresult := []int{}\n\tfor _, v := range ts.Fonts {\n\t\tif v.Weight < 1 {\n\t\t\tcontinue\n\t\t}\n\n\t\tif !isUniqueInt(result, v.Weight) {\n\t\t\tcontinue\n\t\t}\n\n\t\tresult = append(result, v.Weight)\n\t}\n\treturn result\n}", "func Weight(v float64) predicate.Opt {\n\treturn predicate.Opt(func(s *sql.Selector) {\n\t\ts.Where(sql.EQ(s.C(FieldWeight), v))\n\t})\n}", "func (s *BaseMySqlParserListener) EnterLevelWeightRange(ctx *LevelWeightRangeContext) {}", "func (c *WeightedCache) Weight() int {\n\treturn c.weight\n}", "func (t *Tangle) Weight(s *site.Site) int {\n\tbound := make(map[*site.Site]bool)\n\t// Setting up exclusion list\n\texcl := make(map[hash.Hash]bool)\n\n\tinject := func(l []*site.Site) {\n\t\tfor _, v := range l {\n\t\t\tbound[v] = true\n\t\t}\n\t}\n\n\tinject(s.Validates)\n\tfor len(bound) != 0 {\n\t\tfor st := range bound {\n\t\t\tdelete(bound, st)\n\t\t\texcl[st.Hash()] = true\n\t\t\tfor _, v := range st.Validates {\n\t\t\t\tif !excl[v.Hash()] {\n\t\t\t\t\tbound[v] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// Calculating weight\n\trvl := make(map[hash.Hash][]*site.Site)\n\tinject(t.Tips())\n\tfor len(bound) != 0 {\n\t\tfor st := range bound {\n\t\t\tdelete(bound, st)\n\t\t\tfor _, v := range st.Validates {\n\t\t\t\tif !excl[v.Hash()] {\n\t\t\t\t\tbound[v] = true\n\t\t\t\t\trvl[v.Hash()] = append(rvl[v.Hash()], st)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tw := s.Hash().Weight()\n\tinject(rvl[s.Hash()])\n\tfor len(bound) != 0 {\n\t\tfor st := range bound {\n\t\t\tdelete(bound, st)\n\t\t\texcl[st.Hash()] = true\n\t\t\tw += st.Hash().Weight()\n\t\t\tfor _, v := range rvl[st.Hash()] {\n\t\t\t\tif !excl[v.Hash()] {\n\t\t\t\t\tbound[v] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn w\n}", "func weightedRand(max int, talentCo float64) float64 {\n\tnum := posWeightedRand(max)\n\n\tif rand.Float64() > talentCo {\n\t\treturn num - (2 * num)\n\t}\n\n\treturn num\n}", "func (o ElastigroupInstanceTypesWeightOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v ElastigroupInstanceTypesWeight) int { return v.Weight }).(pulumi.IntOutput)\n}", "func (s *BaseMySqlParserListener) EnterLevelWeightList(ctx *LevelWeightListContext) {}", "func getWeight(route *l3.Route) uint32 {\n\tif route.Weight == 0 {\n\t\treturn defaultWeight\n\t}\n\treturn route.Weight\n}", "func convertLargeWeights(elems []rawCE) (res []rawCE, err error) {\n\tconst (\n\t\tcjkPrimaryStart = 0xFB40\n\t\trarePrimaryStart = 0xFB80\n\t\totherPrimaryStart = 0xFBC0\n\t\tillegalPrimary = 0xFFFE\n\t\thighBitsMask = 0x3F\n\t\tlowBitsMask = 0x7FFF\n\t\tlowBitsFlag = 0x8000\n\t\tshiftBits = 15\n\t)\n\tfor i := 0; i < len(elems); i++ {\n\t\tce := elems[i].w\n\t\tp := ce[0]\n\t\tif p < cjkPrimaryStart {\n\t\t\tcontinue\n\t\t}\n\t\tif p > 0xFFFF {\n\t\t\treturn elems, fmt.Errorf(\"found primary weight %X; should be <= 0xFFFF\", p)\n\t\t}\n\t\tif p >= illegalPrimary {\n\t\t\tce[0] = illegalOffset + p - illegalPrimary\n\t\t} else {\n\t\t\tif i+1 >= len(elems) {\n\t\t\t\treturn elems, fmt.Errorf(\"second part of double primary weight missing: %v\", elems)\n\t\t\t}\n\t\t\tif elems[i+1].w[0]&lowBitsFlag == 0 {\n\t\t\t\treturn elems, fmt.Errorf(\"malformed second part of double primary weight: %v\", elems)\n\t\t\t}\n\t\t\tnp := ((p & highBitsMask) << shiftBits) + elems[i+1].w[0]&lowBitsMask\n\t\t\tswitch {\n\t\t\tcase p < rarePrimaryStart:\n\t\t\t\tnp += commonUnifiedOffset\n\t\t\tcase p < otherPrimaryStart:\n\t\t\t\tnp += rareUnifiedOffset\n\t\t\tdefault:\n\t\t\t\tp += otherOffset\n\t\t\t}\n\t\t\tce[0] = np\n\t\t\tfor j := i + 1; j+1 < len(elems); j++ {\n\t\t\t\telems[j] = elems[j+1]\n\t\t\t}\n\t\t\telems = elems[:len(elems)-1]\n\t\t}\n\t}\n\treturn elems, nil\n}", "func RandomWeighted(from []Mineral) (Mineral, error) {\n\tnames := make(map[string]int)\n\n\tfor _, m := range from {\n\t\tnames[m.Name] = m.Commonality\n\t}\n\n\tname, err := random.StringFromThresholdMap(names)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"Failed to get random weighted mineral: %w\", err)\n\t\treturn Mineral{}, err\n\t}\n\n\tfor _, m := range from {\n\t\tif m.Name == name {\n\t\t\treturn m, nil\n\t\t}\n\t}\n\n\terr = fmt.Errorf(\"Couldn't find named mineral\")\n\n\treturn Mineral{}, err\n}", "func RandomWeighted(from []Mineral) (Mineral, error) {\n\tnames := make(map[string]int)\n\n\tfor _, m := range from {\n\t\tnames[m.Name] = m.Commonality\n\t}\n\n\tname, err := random.StringFromThresholdMap(names)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"Failed to get random weighted mineral: %w\", err)\n\t\treturn Mineral{}, err\n\t}\n\n\tfor _, m := range from {\n\t\tif m.Name == name {\n\t\t\treturn m, nil\n\t\t}\n\t}\n\n\terr = fmt.Errorf(\"Couldn't find named mineral\")\n\n\treturn Mineral{}, err\n}", "func NextLevelP(topic []byte, sep byte, wldcd byte) (nlvl []byte, rem []byte, err error) {\n\tvar (\n\t\tstate byte = LCHR\n\t)\n\tfor i, c := range topic {\n\t\tswitch c {\n\t\tcase sep:\n\t\t\tif i == 0 {\n\t\t\t\terr = errors.New(\"messages: invalid position for seperator.\")\n\t\t\t\treturn nlvl, rem, err\n\t\t\t}\n\t\t\tif state == LWLCD {\n\t\t\t\t// // TODO: NOTE: handle wildcard\n\t\t\t}\n\t\t\tstate = LBRK\n\t\t\tnlvl = topic[:i]\n\t\t\trem = topic[i+1:]\n\t\t\terr = nil\n\t\t\treturn nlvl, rem, err\n\t\tcase wldcd:\n\t\t\tif i != 0 {\n\t\t\t\terr = errors.New(\"invalid wildcard position\")\n\t\t\t\treturn nlvl, rem, err\n\t\t\t}\n\t\t\tstate = LWLCD\n\t\tdefault:\n\t\t\tstate = LCHR\n\t\t}\n\t}\n\tnlvl = topic\n\terr = nil\n\n\treturn nlvl, rem, err\n}", "func enableWeights(tags []Tag) []Tag {\n\tvar dst []Tag\n\tfor _, v := range tags {\n\t\tdst = append(dst, Tag{v.Word, 1})\n\t\tfor i := 0; i < v.Weight-1; i++ {\n\t\t\tdst = append(dst, Tag{v.Word, 1})\n\t\t}\n\t}\n\treturn dst\n}", "func WeightedShuffle(weights []float64, yieldFunc ShuffleIndexFunc) (err error) {\n\ttype weightNode struct {\n\t\tindex int\n\t\tweight float64\n\t}\n\tvar (\n\t\trnd float64\n\t\tsum float64\n\t\tel *list.Element\n\t\twl = list.New()\n\t)\n\n\t// check if it's an empty or invalid weight list\n\tif len(weights) == 0 {\n\t\terr = errInvalidWeights\n\t\treturn\n\t}\n\tfor i, w := range weights {\n\t\tif w <= 0 {\n\t\t\terr = errInvalidWeights\n\t\t\treturn\n\t\t}\n\t\t_ = wl.PushBack(weightNode{index: i, weight: w})\n\t}\n\n\tfor range weights {\n\t\tsum = 0.0\n\t\tfor el = wl.Front(); el != nil; el = el.Next() {\n\t\t\tw := el.Value.(weightNode)\n\t\t\tsum += w.weight\n\t\t}\n\n\t\t// get random value\n\t\tif rnd, err = Float64(); err != nil {\n\t\t\tbreak\n\t\t}\n\t\tsum *= rnd\n\n\t\t// find the random pos\n\t\tfor el = wl.Front(); el != nil; el = el.Next() {\n\t\t\twn := el.Value.(weightNode)\n\t\t\tif sum -= wn.weight; sum < 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif el == nil {\n\t\t\tel = wl.Back()\n\t\t}\n\n\t\t// yield it and remove for next iteration\n\t\twn := wl.Remove(el).(weightNode)\n\t\tif err = yieldFunc(wn.index); err != nil {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif err == QuitShuffle {\n\t\terr = nil\n\t}\n\treturn\n}", "func checkWeight(e *Elevator) {\n\tmaxWeight := 500 //Maximum weight an elevator can carry in KG\n\trandomWeight := rand.Intn(100) + maxWeight //This random simulates the weight from a weight sensor\n\tfor randomWeight > maxWeight { //Logic of loading\n\t\te.weightSensorStatus = sensorOn //Detect a full elevator\n\t\tfmt.Println(\" ! Elevator capacity reached, waiting until the weight is lower before continue...\")\n\t\trandomWeight -= 100 //I'm supposing the random number is 600, I'll subtract 101 so it will be less than 500 (the max weight I proposed) for the second time it runs\n\t}\n\te.weightSensorStatus = sensorOff\n\tfmt.Println(\" Elevator capacity is OK\")\n}", "func (m *Memtable) pickLevel() int {\n\tvar r uint64\n\tfor r == 0 {\n\t\tr = uint64(m.rnd.Int63n(int64(1) << maxLevel))\n\t}\n\treturn bits.TrailingZeros64(r)\n}", "func (n *Node) Weight(weight int) *Node {\n\treturn n.setAttr(\"weight\", strconv.Itoa(weight))\n}", "func (fp FileParser) Weights() map[string]m.SortCodeData {\n\tjobs := make(chan LineRecord)\n\tresults := make(chan m.SortCodeRange)\n\n\tgo readFile(fp.weightsBytes, jobs)\n\tgo parseWeightsLine(jobs, results)\n\n\t// Process all the sort code ranges\n\tfor result := range results {\n\t\tfp.addSortCodeRange(result)\n\t}\n\n\treturn fp.weights\n}", "func (fuo *FriendshipUpdateOne) AddWeight(i int) *FriendshipUpdateOne {\n\tfuo.mutation.AddWeight(i)\n\treturn fuo\n}", "func edgeWeight(weight path.Weighting, uid, vid int64) float64 {\n\tw, ok := weight(uid, vid)\n\tif !ok {\n\t\tpanic(\"D* Lite: unexpected invalid weight\")\n\t}\n\treturn w\n}", "func (c *Client) Weight(ctx context.Context, weight uint64) error {\n\trequest := protocol.Message{}\n\trequest.Init(4096)\n\tresponse := protocol.Message{}\n\tresponse.Init(4096)\n\n\tprotocol.EncodeWeight(&request, weight)\n\n\tif err := c.protocol.Call(ctx, &request, &response); err != nil {\n\t\treturn err\n\t}\n\n\tif err := protocol.DecodeEmpty(&response); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (g Graph) FullWeightOfVertex(v int) float64 {\n count := 0;\n weight := 0.0\n for count < len(*g.full) {\n v1temp := (*g.full)[count].v1_index\n v2temp := (*g.full)[count].v2_index\n if (v == v1temp || v == v2temp){\n weight = weight + (*g.full)[count].weight\n }\n \n count = count + 1\n }\n return weight\n}", "func LevelWidth(n Nodes, l Level) Nodes {\n\tif l < 0 {\n\t\tpanic(\"can't see below\")\n\t}\n\tfor l > 0 {\n\t\tn = (n + 1) / 2\n\t\tl--\n\t}\n\treturn n\n}", "func (h *handlerImpl) getPathWeight(adjMatrix adjacencyMatrix, path []int, ht types.HourType, computeTimeCost bool) int {\n\tif len(path) == 0 {\n\t\treturn math.MinInt32\n\t}\n\n\tif _, ok := adjMatrix[path[0]]; !ok {\n\t\treturn math.MinInt32\n\t}\n\n\tpathWeight := 0\n\tprevLine := \"\"\n\tnextLine := \"\"\n\tfor i := 0; i < len(path)-1; i++ {\n\t\tif _, ok := adjMatrix[path[i+1]]; !ok {\n\t\t\treturn math.MinInt32\n\t\t}\n\n\t\tif _, ok := adjMatrix[path[i]][path[i+1]]; ok {\n\t\t\tinterchangeCost := 0\n\t\t\tif computeTimeCost {\n\t\t\t\tnextLine = h.getTrainLine(path[i], path[i+1])\n\t\t\t\tif prevLine != \"\" && nextLine != prevLine {\n\t\t\t\t\tinterchangeCost = interchangeCostMap[ht]\n\t\t\t\t}\n\t\t\t\tprevLine = nextLine\n\t\t\t}\n\t\t\tpathWeight = pathWeight + h.getEdgeWeight(adjMatrix, path[i], path[i+1], ht) + interchangeCost\n\t\t} else {\n\t\t\treturn math.MaxInt32\n\t\t}\n\t}\n\n\treturn pathWeight\n}", "func (l *SkipList) randLevel() int {\n\tvar level int\n\tfor level = 0; r.Int31n(probability) == 1 && level < maxLevel; level++ {\n\t\tif level > l.level {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn level\n}", "func (v *VerticalContainer) Weight() float64 {\n\treturn v.Wt\n}", "func (s *Solution) decide(scale Scale) (int, Weight, int) {\n\tz := s.GetZeroCoin()\n\tscale.SetZeroCoin(z)\n\n\tresults := [3]Weight{}\n\n\tresults[0] = scale.Weigh(s.Weighings[0].Left().AsCoins(z), s.Weighings[0].Right().AsCoins(z))\n\tresults[1] = scale.Weigh(s.Weighings[1].Left().AsCoins(z), s.Weighings[1].Right().AsCoins(z))\n\tresults[2] = scale.Weigh(s.Weighings[2].Left().AsCoins(z), s.Weighings[2].Right().AsCoins(z))\n\n\tif s.encoding.Flip != nil {\n\t\tresults[*s.encoding.Flip] = Heavy - results[*s.encoding.Flip]\n\t}\n\n\ta := results[0]\n\tb := results[1]\n\tc := results[2]\n\n\ti := int(a*9 + b*3 + c - 13) // must be between 0 and 26, inclusive.\n\to := abs(i)\n\tif len(s.Coins) == 12 {\n\t\tif o < 1 || o > 12 {\n\t\t\t// this can only happen if flip hasn't be set correctly.\n\t\t\tpanic(fmt.Errorf(\"index out of bounds: %d, %v\", o, []Weight{a, b, c}))\n\t\t}\n\t\to = o - 1\n\t} else {\n\t\to = i + 13\n\t}\n\n\tf := s.Coins[o]\n\tw := s.Weights[o]\n\n\tif i > 0 {\n\t\tw = Heavy - w\n\t}\n\n\treturn f, w, o\n}", "func (g *testExpectedGraph) Weight(xid, yid int64) (w float64, ok bool) {\n\tif xid == yid {\n\t\treturn self, true\n\t}\n\tif to, ok := g.from[xid]; ok {\n\t\tif e, ok := to[yid]; ok {\n\t\t\treturn e.Weight(), true\n\t\t}\n\t}\n\treturn absent, false\n}", "func (n *TreeNode) Weight() Value {\n\treturn n.weight\n}", "func (n *Node) Weight() int {\n\treturn n.Weight_\n}", "func (a *AlgorithmChain) WeightingRelation(\n\tword1ID int,\n\tword2ID int,\n\trank *Rank,\n) float32 {\n\trelationQty := rank.Relation.Node[word1ID][word2ID].Qty\n\tword1Qty := rank.Words[word1ID].Qty\n\tword2Qty := rank.Words[word2ID].Qty\n\n\tqDiff := float32(math.Abs(float64(word1Qty)-float64(word2Qty))) / 100\n\tweight := float32(relationQty) + qDiff\n\n\treturn weight\n}", "func (e Edge) GetWeight() float64 {\n return e.weight\n}", "func (g defaultImportGrouper) Weight(path string) int {\n\tswitch {\n\tcase path == \"C\":\n\t\treturn importGroupC\n\tcase isStdlibPackage(path):\n\t\treturn importGroupStd\n\tcase g != \"\" && g.isSubPkg(path):\n\t\treturn importGroupCurrent\n\tcase strings.HasPrefix(path, \".\"):\n\t\treturn importGroupRelative\n\tdefault:\n\t\treturn importGroup3rdParty\n\t}\n}", "func (self *Weights) choose() (int,error) {\n\ttw,err := self.topWeight()\n\tif err != nil {\n\t\treturn -1,ENOWEIGHTSDEFINED\n\t}\n\tif tw == 0 {\n\t\treturn -1,EWEIGHTNOTFOUND\n\t}\n\treturn self.find(weight(rand.Int63n(int64(tw))))\n}", "func getClassWeight(node *goquery.Selection) float64 {\n\tweight := 0.0\n\tif str, b := node.Attr(\"class\"); b {\n\t\tif rxNegative.MatchString(str) {\n\t\t\tweight -= 25\n\t\t}\n\n\t\tif rxPositive.MatchString(str) {\n\t\t\tweight += 25\n\t\t}\n\t}\n\n\tif str, b := node.Attr(\"id\"); b {\n\t\tif rxNegative.MatchString(str) {\n\t\t\tweight -= 25\n\t\t}\n\n\t\tif rxPositive.MatchString(str) {\n\t\t\tweight += 25\n\t\t}\n\t}\n\n\treturn weight\n}", "func (s *Mobius) weight_tag(w map[int]float64) string {\n\tvar tag string\n\tfor _, id := range s.app_ids {\n\t\ttag += fmt.Sprintf(\"%0.2f_\", w[id])\n\t}\n\treturn tag\n}", "func Swe7_swedish_ci_RuneWeight(r rune) int32 {\n\tweight, ok := swe7_swedish_ci_Weights[r]\n\tif ok {\n\t\treturn weight\n\t} else {\n\t\treturn 2147483647\n\t}\n}", "func (a dapArc) Weight() float64 {\n\treturn float64(a)\n}", "func (wd *WeightDevice) LeafWeightString() string {\n\treturn fmt.Sprintf(\"%d:%d %d\", wd.Major, wd.Minor, wd.LeafWeight)\n}", "func wisNaiveRecursive(vertices []vertex) int {\r\n\tvar maxWIS int\r\n\tif len(vertices) == 0 {\r\n\t\treturn 0\r\n\t} else if len(vertices) == 1 {\r\n\t\treturn vertices[0].weight\r\n\t}\r\n\ts1 := wisNaiveRecursive(vertices[:len(vertices)-1])\r\n\ts2 := wisNaiveRecursive(vertices[:len(vertices)-2])\r\n\tif s1 >= s2+vertices[len(vertices)-1].weight {\r\n\t\tmaxWIS = s1\r\n\t} else {\r\n\t\tmaxWIS = s2+vertices[len(vertices)-1].weight\r\n\t}\r\n\treturn maxWIS\r\n}", "func (fu *FriendshipUpdate) AddWeight(i int) *FriendshipUpdate {\n\tfu.mutation.AddWeight(i)\n\treturn fu\n}", "func (s *BaseMySqlParserListener) EnterWeightFunctionCall(ctx *WeightFunctionCallContext) {}", "func (o WeightedBackendServiceResponseOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v WeightedBackendServiceResponse) int { return v.Weight }).(pulumi.IntOutput)\n}", "func (r *readability) getClassWeight(node *goquery.Selection) float64 {\n\tweight := 0.0\n\tif str, b := node.Attr(\"class\"); b {\n\t\tif negative.MatchString(str) {\n\t\t\tweight -= 25\n\t\t}\n\n\t\tif positive.MatchString(str) {\n\t\t\tweight += 25\n\t\t}\n\t}\n\n\tif str, b := node.Attr(\"id\"); b {\n\t\tif negative.MatchString(str) {\n\t\t\tweight -= 25\n\t\t}\n\n\t\tif positive.MatchString(str) {\n\t\t\tweight += 25\n\t\t}\n\t}\n\n\treturn weight\n}", "func applyLocalityWeight(\n\tlocality *core.Locality,\n\tloadAssignment *endpoint.ClusterLoadAssignment,\n\tdistribute []*v1alpha3.LocalityLoadBalancerSetting_Distribute) {\n\tif distribute == nil {\n\t\treturn\n\t}\n\n\t// Support Locality weighted load balancing\n\t// (https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/locality_weight#locality-weighted-load-balancing)\n\t// by providing weights in LocalityLbEndpoints via load_balancing_weight.\n\t// By setting weights across different localities, it can allow\n\t// Envoy to weight assignments across different zones and geographical locations.\n\tfor _, localityWeightSetting := range distribute {\n\t\tif localityWeightSetting != nil &&\n\t\t\tutil.LocalityMatch(locality, localityWeightSetting.From) {\n\t\t\tmisMatched := map[int]struct{}{}\n\t\t\tfor i := range loadAssignment.Endpoints {\n\t\t\t\tmisMatched[i] = struct{}{}\n\t\t\t}\n\t\t\tfor locality, weight := range localityWeightSetting.To {\n\t\t\t\t// index -> original weight\n\t\t\t\tdestLocMap := map[int]uint32{}\n\t\t\t\ttotalWeight := uint32(0)\n\t\t\t\tfor i, ep := range loadAssignment.Endpoints {\n\t\t\t\t\tif _, exist := misMatched[i]; exist {\n\t\t\t\t\t\tif util.LocalityMatch(ep.Locality, locality) {\n\t\t\t\t\t\t\tdelete(misMatched, i)\n\t\t\t\t\t\t\tif ep.LoadBalancingWeight != nil {\n\t\t\t\t\t\t\t\tdestLocMap[i] = ep.LoadBalancingWeight.Value\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdestLocMap[i] = 1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttotalWeight += destLocMap[i]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// in case wildcard dest matching multi groups of endpoints\n\t\t\t\t// the load balancing weight for a locality is divided by the sum of the weights of all localities\n\t\t\t\tfor index, originalWeight := range destLocMap {\n\t\t\t\t\tdestWeight := float64(originalWeight*weight) / float64(totalWeight)\n\t\t\t\t\tif destWeight > 0 {\n\t\t\t\t\t\tloadAssignment.Endpoints[index].LoadBalancingWeight = &wrappers.UInt32Value{\n\t\t\t\t\t\t\tValue: uint32(math.Ceil(destWeight)),\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// remove groups of endpoints in a locality that miss matched\n\t\t\tfor i := range misMatched {\n\t\t\t\tloadAssignment.Endpoints[i].LbEndpoints = nil\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n}", "func (o SRVRecordRecordOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v SRVRecordRecord) int { return v.Weight }).(pulumi.IntOutput)\n}", "func (self *Weights) find(w weight) (int,error) {\n\ti := sort.Search(len(self.Scale), func(i int) bool { return self.Scale[i].W >= w })\n\tif i < len(self.Scale) {\n\t\treturn self.Scale[i].I,nil\n\t} else {\n\t\treturn -1,EWEIGHTNOTFOUND\n\t}\n}", "func (o ServiceLoadMetricDescriptionOutput) Weight() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ServiceLoadMetricDescription) *string { return v.Weight }).(pulumi.StringPtrOutput)\n}", "func main() {\n\tmaxWeight := []int {415, 5, 210, 435, 120, 75}\n\n\tfor _, v := range maxWeight {\n\t\tquiver(knapsack(len(boards) - 1, v))\n\t\tfmt.Printf(\"(%s %v)\\n\\n\\n===\\n\\n\", \"maximum weight\", v)\n\t}\n}", "func (g Graph) FullWeight() float64 {\n count := 0;\n weight := 0.0\n for count < len(*g.full) {\n weight = weight + (*g.full)[count].weight \n count = count + 1\n }\n return weight\n}", "func (o SrvRecordRecordOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v SrvRecordRecord) int { return v.Weight }).(pulumi.IntOutput)\n}", "func (etf *Etf) computeWeightDirection(x, y gocv.Vecf) float32 {\n\treturn float32(math.Abs(float64(etf.computeDot(x, y))))\n}", "func WeightGTE(v float64) predicate.Opt {\n\treturn predicate.Opt(func(s *sql.Selector) {\n\t\ts.Where(sql.GTE(s.C(FieldWeight), v))\n\t})\n}", "func clientWeightCalculator(number int) int {\n\tvar weight int\n\tif number == 0 {\n\t\treturn 0\n\t}\n\tfor i := 1; i<=number; i++ {\n\t\tweight = weight + 10\n\t}\n\treturn weight\n}", "func (o *V0037Node) GetWeight() int32 {\n\tif o == nil || o.Weight == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.Weight\n}", "func (o GetRecordResultOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v GetRecordResult) int { return v.Weight }).(pulumi.IntOutput)\n}", "func (h *HorizontalContainer) Weight() float64 {\n\treturn h.Wt\n}", "func (o WeightedBackendServiceOutput) Weight() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v WeightedBackendService) *int { return v.Weight }).(pulumi.IntPtrOutput)\n}", "func (e *Edge) Weight() float64 {\n\treturn e.weight\n}" ]
[ "0.5805395", "0.5767882", "0.562097", "0.5619211", "0.55570513", "0.5546121", "0.5489472", "0.53985757", "0.5363531", "0.53404033", "0.5303844", "0.5233217", "0.52004", "0.5160009", "0.51417226", "0.5127784", "0.51159465", "0.509564", "0.5075816", "0.5062415", "0.50532717", "0.50293684", "0.502531", "0.4969791", "0.49587104", "0.49514928", "0.49496427", "0.49495584", "0.49484044", "0.49304476", "0.49279588", "0.49266183", "0.49234858", "0.49218872", "0.49197903", "0.4914268", "0.49094215", "0.48818392", "0.48744738", "0.48499337", "0.48495135", "0.48309073", "0.48250222", "0.4819079", "0.48133433", "0.47936785", "0.4769412", "0.47539896", "0.47524425", "0.474386", "0.4733673", "0.4733673", "0.47332403", "0.47234073", "0.47188112", "0.47053555", "0.46848086", "0.46844637", "0.4683525", "0.4679324", "0.46787104", "0.46777555", "0.46750072", "0.46696544", "0.46686083", "0.46664262", "0.46571007", "0.4643231", "0.46382", "0.46367532", "0.4605873", "0.45927206", "0.45878568", "0.45813292", "0.4578174", "0.4559224", "0.4551408", "0.4550654", "0.4549627", "0.45482764", "0.45437065", "0.4542827", "0.45401993", "0.4533768", "0.45329192", "0.45287338", "0.45217994", "0.45187536", "0.45099998", "0.44947615", "0.4472694", "0.44685113", "0.44672894", "0.44648334", "0.4460632", "0.44605827", "0.44438964", "0.44425854", "0.44402444", "0.4409115" ]
0.787631
0
compareWeights returns 1 if a b, or 0 otherwise. It also returns the collation level at which the difference is found.
compareWeights возвращает 1, если a b, или 0 в противном случае. Также возвращается уровень сортировки, на котором обнаружено различие.
func compareWeights(a, b []rawCE) (result int, level colltab.Level) { for level := colltab.Primary; level < colltab.Identity; level++ { var va, vb int for ia, ib := 0, 0; ia < len(a) || ib < len(b); ia, ib = ia+1, ib+1 { ia, va = nextVal(a, ia, level) ib, vb = nextVal(b, ib, level) if va != vb { if va < vb { return -1, level } else { return 1, level } } } } return 0, colltab.Identity }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CMPW(amr, imr operand.Op) { ctx.CMPW(amr, imr) }", "func compare(a, b *TrieKey, prematchedBits uint) (a_match, b_match, reversed bool, common, child uint) {\n\t// Figure out which is the longer prefix and reverse them if b is shorter\n\treversed = b.Length < a.Length\n\tif reversed {\n\t\tb_match, a_match, common, child = contains(b, a, prematchedBits)\n\t} else {\n\t\ta_match, b_match, common, child = contains(a, b, prematchedBits)\n\t}\n\treturn\n}", "func calculateWeightStatus(ro *v1alpha1.Rollout, canaryHash, stableHash string, desiredWeight int32, weightDestinations ...v1alpha1.WeightDestination) (bool, *v1alpha1.TrafficWeights) {\n\tweights := v1alpha1.TrafficWeights{\n\t\tCanary: v1alpha1.WeightDestination{\n\t\t\tWeight: desiredWeight,\n\t\t\tPodTemplateHash: canaryHash,\n\t\t\tServiceName: ro.Spec.Strategy.Canary.CanaryService,\n\t\t},\n\t}\n\tstableWeight := 100 - desiredWeight\n\tfor _, weightDest := range weightDestinations {\n\t\tweights.Additional = append(weights.Additional, weightDest)\n\t\tstableWeight -= weightDest.Weight\n\t}\n\tweights.Stable.Weight = stableWeight\n\tweights.Stable.PodTemplateHash = stableHash\n\tweights.Stable.ServiceName = ro.Spec.Strategy.Canary.StableService\n\n\tprevWeights := ro.Status.Canary.Weights\n\tmodified := prevWeights == nil ||\n\t\tprevWeights.Canary != weights.Canary ||\n\t\tprevWeights.Stable != weights.Stable ||\n\t\t!reflect.DeepEqual(prevWeights.Additional, weights.Additional)\n\treturn modified, &weights\n}", "func orderComparator(a, b interface{}) int {\n\taWeight := a.(decimal.Decimal)\n\tbWeight := b.(decimal.Decimal)\n\n\treturn aWeight.Cmp(bWeight)\n}", "func (a byWeight) Less(i, j int) bool {\n\treturn (a[i].Weight > a[j].Weight) || (a[i].Weight == a[j].Weight && a[i].clusterName < a[j].clusterName)\n}", "func WeightedOperations(\n\tappParams simtypes.AppParams, cdc codec.JSONCodec, k keeper.Keeper, ak authkeeper.AccountKeeperI, bk bankkeeper.ViewKeeper, nk namekeeper.Keeper,\n) simulation.WeightedOperations {\n\tvar (\n\t\tweightMsgAddAttribute int\n\t\tweightMsgUpdateAttribute int\n\t\tweightMsgDeleteAttribute int\n\t\tweightMsgDeleteDistinctAttribute int\n\t)\n\n\tappParams.GetOrGenerate(cdc, OpWeightMsgAddAttribute, &weightMsgAddAttribute, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgAddAttribute = simappparams.DefaultWeightMsgAddAttribute\n\t\t},\n\t)\n\n\tappParams.GetOrGenerate(cdc, OpWeightMsgUpdateAttribute, &weightMsgUpdateAttribute, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgUpdateAttribute = simappparams.DefaultWeightMsgUpdateAttribute\n\t\t},\n\t)\n\n\tappParams.GetOrGenerate(cdc, OpWeightMsgDeleteAttribute, &weightMsgDeleteAttribute, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgDeleteAttribute = simappparams.DefaultWeightMsgDeleteAttribute\n\t\t},\n\t)\n\n\tappParams.GetOrGenerate(cdc, OpWeightMsgDeleteDistinctAttribute, &weightMsgDeleteDistinctAttribute, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgDeleteDistinctAttribute = simappparams.DefaultWeightMsgDeleteDistinctAttribute\n\t\t},\n\t)\n\n\treturn simulation.WeightedOperations{\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightMsgAddAttribute,\n\t\t\tSimulateMsgAddAttribute(k, ak, bk, nk),\n\t\t),\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightMsgUpdateAttribute,\n\t\t\tSimulateMsgUpdateAttribute(k, ak, bk, nk),\n\t\t),\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightMsgDeleteAttribute,\n\t\t\tSimulateMsgDeleteAttribute(k, ak, bk, nk),\n\t\t),\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightMsgDeleteDistinctAttribute,\n\t\t\tSimulateMsgDeleteDistinctAttribute(k, ak, bk, nk),\n\t\t),\n\t}\n}", "func (a *AlgorithmDefault) WeightingRelation(\n\tword1ID int,\n\tword2ID int,\n\trank *Rank,\n) float32 {\n\trelationQty := rank.Relation.Node[word1ID][word2ID].Qty\n\n\treturn float32(relationQty)\n}", "func levenshtein(a string, b string) int {\n\n\t// Handle empty string cases\n\tif len(a) == 0 {\n\t\treturn len(b)\n\t}\n\tif len(b) == 0 {\n\t\treturn len(a)\n\t}\n\n\t// DP matrix\n\tmat := make([][]int, len(a))\n\tfor i := range mat {\n\t\tmat[i] = make([]int, len(b))\n\t}\n\n\t// Initialize base cases\n\tfor i := 0; i < len(a); i++ {\n\t\tmat[i][0] = i\n\t}\n\tfor i := 0; i < len(b); i++ {\n\t\tmat[0][i] = i\n\t}\n\n\t// Fill out optimal edit distance matrix\n\tfor i := 1; i < len(a); i++ {\n\t\tfor j := 1; j < len(b); j++ {\n\t\t\tcost := 0\n\t\t\tif a[i] != b[j] {\n\t\t\t\tcost = 1\n\t\t\t}\n\n\t\t\t// Compute cheapest way of getting to this index\n\t\t\tabove := mat[i-1][j] + 1\n\t\t\tleft := mat[i][j-1] + 1\n\t\t\tdiag := mat[i-1][j-1] + cost\n\n\t\t\t// Sort and take idx 0 to get minimum\n\t\t\tarr := []int{above, left, diag}\n\t\t\tsort.Ints(arr)\n\t\t\tmin := arr[0]\n\t\t\tmat[i][j] = min\n\t\t}\n\t}\n\treturn mat[len(a)-1][len(b)-1]\n}", "func (e *Election) cmp(a, b int) int {\n\tcnt := 0\n\n\tfor _, v := range e.V {\n\t\tfor i := 0; i < len(v.C); i++ {\n\t\t\tx := v.C[strconv.Itoa(i)]\n\t\t\tif x == a {\n\t\t\t\tcnt -= v.W\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif x == b {\n\t\t\t\tcnt += v.W\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\treturn cnt\n}", "func distcmp(target, a, b common.Hash) int {\n\tfor i := range target {\n\t\tda := a[i] ^ target[i]\n\t\tdb := b[i] ^ target[i]\n\t\tif da > db {\n\t\t\treturn 1\n\t\t} else if da < db {\n\t\t\treturn -1\n\t\t}\n\t}\n\treturn 0\n}", "func distcmp(target, a, b bgmcommon.Hash) int {\n\tfor i := range target {\n\t\tda := a[i] ^ target[i]\n\t\tdb := b[i] ^ target[i]\n\t\tif da > db {\n\t\t\treturn 1\n\t\t} else if da < db {\n\t\t\treturn -1\n\t\t}\n\t}\n\treturn 0\n}", "func (g *testExpectedGraph) Weight(xid, yid int64) (w float64, ok bool) {\n\tif xid == yid {\n\t\treturn self, true\n\t}\n\tif to, ok := g.from[xid]; ok {\n\t\tif e, ok := to[yid]; ok {\n\t\t\treturn e.Weight(), true\n\t\t}\n\t}\n\treturn absent, false\n}", "func compareReplicationStates(s1, s2 string) (int, error) {\n\tw1, err := ParseReplicationState(s1, nil)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tw2, err := ParseReplicationState(s2, nil)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tif w1.ClusterID != w2.ClusterID {\n\t\treturn 0, fmt.Errorf(\"can't compare replication states with different ClusterIDs\")\n\t}\n\n\tswitch {\n\tcase w1.LocalIndex >= w2.LocalIndex && w1.ReplicatedIndex >= w2.ReplicatedIndex:\n\t\treturn 1, nil\n\t// We've already handled the case where both are equal above, so really we're\n\t// asking here if one or both are lesser.\n\tcase w1.LocalIndex <= w2.LocalIndex && w1.ReplicatedIndex <= w2.ReplicatedIndex:\n\t\treturn -1, nil\n\t}\n\n\treturn 0, nil\n}", "func (uc *unicodeCICollator) Compare(a, b string) int {\n\ta = truncateTailingSpace(a)\n\tb = truncateTailingSpace(b)\n\t// weight of a, b. weight in unicode_ci may has 8 uint16s. xn indicate first 4 u16s, xs indicate last 4 u16s\n\tan, bn := uint64(0), uint64(0)\n\tas, bs := uint64(0), uint64(0)\n\t// rune of a, b\n\tar, br := rune(0), rune(0)\n\t// decode index of a, b\n\tai, bi := 0, 0\n\tfor {\n\t\tif an == 0 {\n\t\t\tif as == 0 {\n\t\t\t\tfor an == 0 && ai < len(a) {\n\t\t\t\t\tar, ai = decodeRune(a, ai)\n\t\t\t\t\tan, as = convertRuneUnicodeCI(ar)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tan = as\n\t\t\t\tas = 0\n\t\t\t}\n\t\t}\n\n\t\tif bn == 0 {\n\t\t\tif bs == 0 {\n\t\t\t\tfor bn == 0 && bi < len(b) {\n\t\t\t\t\tbr, bi = decodeRune(b, bi)\n\t\t\t\t\tbn, bs = convertRuneUnicodeCI(br)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbn = bs\n\t\t\t\tbs = 0\n\t\t\t}\n\t\t}\n\n\t\tif an == 0 || bn == 0 {\n\t\t\treturn sign(int(an) - int(bn))\n\t\t}\n\n\t\tif an == bn {\n\t\t\tan, bn = 0, 0\n\t\t\tcontinue\n\t\t}\n\n\t\tfor an != 0 && bn != 0 {\n\t\t\tif (an^bn)&0xFFFF == 0 {\n\t\t\t\tan >>= 16\n\t\t\t\tbn >>= 16\n\t\t\t} else {\n\t\t\t\treturn sign(int(an&0xFFFF) - int(bn&0xFFFF))\n\t\t\t}\n\t\t}\n\t}\n}", "func (e WeightedEdgePair) Weight() float64 { return e.W }", "func DifferentIndex(childrenWeights []int) (int, int) {\n\tif len(childrenWeights) == 0 {\n\t\treturn -1, 0\n\t}\n\tsortedWeights := make([]int, len(childrenWeights))\n\tcopy(sortedWeights, childrenWeights)\n\tsort.Ints(sortedWeights)\n\tcorrectValue := sortedWeights[len(sortedWeights)/2]\n\tfor i, v := range childrenWeights {\n\t\tif v != correctValue {\n\t\t\treturn i, correctValue\n\t\t}\n\t}\n\treturn -1, correctValue\n}", "func (a *AlgorithmChain) WeightingRelation(\n\tword1ID int,\n\tword2ID int,\n\trank *Rank,\n) float32 {\n\trelationQty := rank.Relation.Node[word1ID][word2ID].Qty\n\tword1Qty := rank.Words[word1ID].Qty\n\tword2Qty := rank.Words[word2ID].Qty\n\n\tqDiff := float32(math.Abs(float64(word1Qty)-float64(word2Qty))) / 100\n\tweight := float32(relationQty) + qDiff\n\n\treturn weight\n}", "func (t PostgresTyper) MostWeight(left, right string) string {\n\tif left == right {\n\t\treturn left\n\t}\n\n\tif typeWeight[left] > typeWeight[right] {\n\t\treturn left\n\t}\n\n\treturn right\n}", "func (this Graph) getWeightBetween(v1, v2 graph.VertexInterface) float64 {\n for _, side := range v1.GetEdgesFast() {\n for _, edge := range side() {\n if edge.GetOtherVertex(v1) == v2 {\n return edge.GetWeight()\n }\n }\n }\n return -1\n}", "func compare(s1, s2 uint16) int {\n\tif s1 == s2 {\n\t\treturn 0\n\t}\n\tif ((s2 - s1) & 0x8000) != 0 {\n\t\treturn 1\n\t}\n\treturn -1\n}", "func compare(s1, s2 uint16) int {\n\tif s1 == s2 {\n\t\treturn 0\n\t}\n\tif ((s2 - s1) & 0x8000) != 0 {\n\t\treturn 1\n\t}\n\treturn -1\n}", "func (etf *Etf) computeWeightDirection(x, y gocv.Vecf) float32 {\n\treturn float32(math.Abs(float64(etf.computeDot(x, y))))\n}", "func Weighted(w0 float64, v0 byte, w1 float64, v1 byte) byte {\n\treturn byte(math.Round((w0*float64(v0) + w1*float64(v1)) / (w0 + w1)))\n}", "func Latin1_bin_RuneWeight(r rune) int32 {\n\tweight, ok := latin1_bin_Weights[r]\n\tif ok {\n\t\treturn weight\n\t} else if r >= 0 && r <= 127 {\n\t\treturn r + 0\n\t} else {\n\t\treturn 2147483647\n\t}\n}", "func getMinLetterWeightDifference(weight float64) string {\n\tminDiff := math.MaxFloat32\n\tletter := \"\"\n\tfor k, v := range frequencyOrder {\n\t\tif minDiff > math.Abs(weight-v) {\n\t\t\tminDiff = math.Abs(weight - v)\n\t\t\tletter = k\n\t\t}\n\t}\n\treturn letter\n}", "func (g *gbkBinCollator) Compare(a, b string) int {\n\ta = truncateTailingSpace(a)\n\tb = truncateTailingSpace(b)\n\n\t// compare the character one by one.\n\tfor len(a) > 0 && len(b) > 0 {\n\t\taLen, bLen := runeLen(a[0]), runeLen(b[0])\n\t\taGbk, err := g.e.Bytes(hack.Slice(a[:aLen]))\n\t\t// if convert error happened, we use '?'(0x3F) replace it.\n\t\t// It should not happen.\n\t\tif err != nil {\n\t\t\taGbk = []byte{0x3F}\n\t\t}\n\t\tbGbk, err := g.e.Bytes(hack.Slice(b[:bLen]))\n\t\tif err != nil {\n\t\t\tbGbk = []byte{0x3F}\n\t\t}\n\n\t\tcompare := bytes.Compare(aGbk, bGbk)\n\t\tif compare != 0 {\n\t\t\treturn compare\n\t\t}\n\t\ta = a[aLen:]\n\t\tb = b[bLen:]\n\t}\n\n\treturn sign(len(a) - len(b))\n}", "func WeightedOperations(\n\tappParams simtypes.AppParams, cdc codec.JSONMarshaler,\n\tk keeper.Keeper, ak authkeeper.AccountKeeper, bk bankkeeper.Keeper,\n) sim.WeightedOperations {\n\tvar weightMsgCreateRelationship int\n\tappParams.GetOrGenerate(cdc, OpWeightMsgCreateRelationship, &weightMsgCreateRelationship, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgCreateRelationship = params.DefaultWeightMsgCreateRelationship\n\t\t},\n\t)\n\n\tvar weightMsgDeleteRelationship int\n\tappParams.GetOrGenerate(cdc, OpWeightMsgDeleteRelationship, &weightMsgDeleteRelationship, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgDeleteRelationship = params.DefaultWeightMsgDeleteRelationship\n\t\t},\n\t)\n\n\tvar weightMsgBlockUser int\n\tappParams.GetOrGenerate(cdc, OpWeightMsgBlockUser, &weightMsgBlockUser, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgBlockUser = params.DefaultWeightMsgBlockUser\n\t\t},\n\t)\n\n\tvar weightMsgUnblockUser int\n\tappParams.GetOrGenerate(cdc, OpWeightMsgUnBlockUser, &weightMsgUnblockUser, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgBlockUser = params.DefaultWeightMsgUnblockUser\n\t\t},\n\t)\n\n\treturn sim.WeightedOperations{\n\t\tsim.NewWeightedOperation(\n\t\t\tweightMsgCreateRelationship,\n\t\t\tSimulateMsgCreateRelationship(k, ak, bk),\n\t\t),\n\t\tsim.NewWeightedOperation(\n\t\t\tweightMsgDeleteRelationship,\n\t\t\tSimulateMsgDeleteRelationship(k, ak, bk),\n\t\t),\n\t\tsim.NewWeightedOperation(\n\t\t\tweightMsgBlockUser,\n\t\t\tSimulateMsgBlockUser(k, ak, bk),\n\t\t),\n\t\tsim.NewWeightedOperation(\n\t\t\tweightMsgUnblockUser,\n\t\t\tSimulateMsgUnblockUser(k, ak, bk),\n\t\t),\n\t}\n}", "func compare(x, y Tuple) int {\n\txn := x.Size()\n\tyn := y.Size()\n\tfor i := 0; i < xn && i < yn; i++ {\n\t\tcmp := bytes.Compare(x.GetRaw(i), y.GetRaw(i))\n\t\tif cmp != 0 {\n\t\t\treturn cmp\n\t\t}\n\t}\n\treturn ints.Compare(xn, yn)\n}", "func WeightedOperations(\n\tappParams simtypes.AppParams,\n\tcdc codec.JSONCodec,\n\tk keeper.Keeper,\n\tak types.AccountKeeper,\n\tbk types.BankKeeper,\n) simulation.WeightedOperations {\n\tvar weightIssueClass, weightMint, weightEdit, weightBurn, weightTransfer, weightTransferClass int\n\n\tappParams.GetOrGenerate(\n\t\tcdc, OpWeightMsgIssueClass, &weightIssueClass, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightIssueClass = 50\n\t\t},\n\t)\n\n\tappParams.GetOrGenerate(\n\t\tcdc, OpWeightMsgMintNFT, &weightMint, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMint = 100\n\t\t},\n\t)\n\n\tappParams.GetOrGenerate(\n\t\tcdc, OpWeightMsgEditNFT, &weightEdit, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightEdit = 50\n\t\t},\n\t)\n\n\tappParams.GetOrGenerate(\n\t\tcdc, OpWeightMsgTransferNFT, &weightTransfer, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightTransfer = 50\n\t\t},\n\t)\n\n\tappParams.GetOrGenerate(\n\t\tcdc, OpWeightMsgBurnNFT, &weightBurn, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightBurn = 10\n\t\t},\n\t)\n\tappParams.GetOrGenerate(\n\t\tcdc, OpWeightMsgTransferClass, &weightTransferClass, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightTransferClass = 10\n\t\t},\n\t)\n\n\treturn simulation.WeightedOperations{\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightIssueClass,\n\t\t\tSimulateMsgIssueClass(k, ak, bk),\n\t\t),\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightMint,\n\t\t\tSimulateMsgMintNFT(k, ak, bk),\n\t\t),\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightEdit,\n\t\t\tSimulateMsgEditNFT(k, ak, bk),\n\t\t),\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightTransfer,\n\t\t\tSimulateMsgTransferNFT(k, ak, bk),\n\t\t),\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightBurn,\n\t\t\tSimulateMsgBurnNFT(k, ak, bk),\n\t\t),\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightTransferClass,\n\t\t\tSimulateMsgTransferClass(k, ak, bk),\n\t\t),\n\t}\n}", "func WeightedOperations(\n\tappParams simulation.AppParams, cdc *codec.Codec, ak govtypes.AccountKeeper,\n\tk keeper.Keeper) simulation.WeightedOperations {\n\tvar (\n\t\tweightMsgCreate int\n\t\tweightMsgUpdate int\n\t)\n\n\tappParams.GetOrGenerate(\n\t\tcdc, OpWeightMsgCreate, &weightMsgCreate, nil, func(r *rand.Rand) {\n\t\t\tweightMsgCreate = simappparams.DefaultWeightMsgCreateProvider\n\t\t},\n\t)\n\n\tappParams.GetOrGenerate(\n\t\tcdc, OpWeightMsgUpdate, &weightMsgUpdate, nil, func(r *rand.Rand) {\n\t\t\tweightMsgUpdate = simappparams.DefaultWeightMsgUpdateProvider\n\t\t},\n\t)\n\n\treturn simulation.WeightedOperations{\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightMsgCreate,\n\t\t\tSimulateMsgCreate(ak, k),\n\t\t),\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightMsgUpdate,\n\t\t\tSimulateMsgUpdate(ak, k),\n\t\t),\n\t}\n}", "func CaselessDiffCount(a, b string) (runesDifferent int) {\n\taLen := len(a)\n\tbLen := len(b)\n\tif aLen != bLen {\n\t\treturn -1\n\t}\n\n\tvar charA, charB uint\n\tfor x := 0; x < aLen; x++ {\n\t\tcharA = uint(a[x])\n\t\tcharB = uint(b[x])\n\n\t\tif charA-LowerA <= lowerDiff {\n\t\t\tcharA = charA - 0x20\n\t\t}\n\t\tif charB-LowerA <= lowerDiff {\n\t\t\tcharB = charB - 0x20\n\t\t}\n\t\tif charA != charB {\n\t\t\trunesDifferent++\n\t\t}\n\t}\n\treturn\n}", "func (g UndirectWeighted) Weight(xid, yid int64) (w float64, ok bool) {\n\tfe := g.G.Edge(xid, yid)\n\tre := g.G.Edge(yid, xid)\n\n\tf, fOk := g.G.Weight(xid, yid)\n\tif !fOk {\n\t\tf = g.Absent\n\t}\n\tr, rOK := g.G.Weight(yid, xid)\n\tif !rOK {\n\t\tr = g.Absent\n\t}\n\tok = fOk || rOK\n\n\tif g.Merge == nil {\n\t\treturn (f + r) / 2, ok\n\t}\n\treturn g.Merge(f, r, fe, re), ok\n}", "func (w Weighted) Weight() float64 { return float64(w) }", "func fuzzyVersionComparison(v1, v2 string) int {\n\tv1 = stripLeadingV(v1)\n\tv2 = stripLeadingV(v2)\n\tfor s1, s2 := v1, v2; len(s1) > 0 && len(s2) > 0; {\n\t\tnum1, cmpTo1, skip1 := parseVersionParts(s1)\n\t\tnum2, cmpTo2, skip2 := parseVersionParts(s2)\n\n\t\tns1 := s1[:cmpTo1]\n\t\tns2 := s2[:cmpTo2]\n\t\tdiff := num1 - num2\n\t\tswitch {\n\t\tcase diff > 0: // ns1 has longer numeric part\n\t\t\tns2 = leftPad(ns2, diff)\n\t\tcase diff < 0: // ns2 has longer numeric part\n\t\t\tns1 = leftPad(ns1, -diff)\n\t\t}\n\n\t\tif cmp := strings.Compare(ns1, ns2); cmp != 0 {\n\t\t\treturn cmp\n\t\t}\n\n\t\ts1 = s1[skip1:]\n\t\ts2 = s2[skip2:]\n\t}\n\t// everything is equal so far, the longest wins\n\tif len(v1) > len(v2) {\n\t\treturn 1\n\t}\n\tif len(v2) > len(v1) {\n\t\treturn -1\n\t}\n\treturn 0\n}", "func convertLargeWeights(elems []rawCE) (res []rawCE, err error) {\n\tconst (\n\t\tcjkPrimaryStart = 0xFB40\n\t\trarePrimaryStart = 0xFB80\n\t\totherPrimaryStart = 0xFBC0\n\t\tillegalPrimary = 0xFFFE\n\t\thighBitsMask = 0x3F\n\t\tlowBitsMask = 0x7FFF\n\t\tlowBitsFlag = 0x8000\n\t\tshiftBits = 15\n\t)\n\tfor i := 0; i < len(elems); i++ {\n\t\tce := elems[i].w\n\t\tp := ce[0]\n\t\tif p < cjkPrimaryStart {\n\t\t\tcontinue\n\t\t}\n\t\tif p > 0xFFFF {\n\t\t\treturn elems, fmt.Errorf(\"found primary weight %X; should be <= 0xFFFF\", p)\n\t\t}\n\t\tif p >= illegalPrimary {\n\t\t\tce[0] = illegalOffset + p - illegalPrimary\n\t\t} else {\n\t\t\tif i+1 >= len(elems) {\n\t\t\t\treturn elems, fmt.Errorf(\"second part of double primary weight missing: %v\", elems)\n\t\t\t}\n\t\t\tif elems[i+1].w[0]&lowBitsFlag == 0 {\n\t\t\t\treturn elems, fmt.Errorf(\"malformed second part of double primary weight: %v\", elems)\n\t\t\t}\n\t\t\tnp := ((p & highBitsMask) << shiftBits) + elems[i+1].w[0]&lowBitsMask\n\t\t\tswitch {\n\t\t\tcase p < rarePrimaryStart:\n\t\t\t\tnp += commonUnifiedOffset\n\t\t\tcase p < otherPrimaryStart:\n\t\t\t\tnp += rareUnifiedOffset\n\t\t\tdefault:\n\t\t\t\tp += otherOffset\n\t\t\t}\n\t\t\tce[0] = np\n\t\t\tfor j := i + 1; j+1 < len(elems); j++ {\n\t\t\t\telems[j] = elems[j+1]\n\t\t\t}\n\t\t\telems = elems[:len(elems)-1]\n\t\t}\n\t}\n\treturn elems, nil\n}", "func WeightedOperations(\n\tappParams simtypes.AppParams, cdc codec.JSONMarshaler,\n\tk keeper.Keeper, ak authkeeper.AccountKeeper, bk bankkeeper.Keeper,\n) sim.WeightedOperations {\n\n\tvar weightMsgCreateSubspace int\n\tappParams.GetOrGenerate(cdc, OpWeightMsgCreateSubspace, &weightMsgCreateSubspace, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgCreateSubspace = params.DefaultWeightMsgCreateSubspace\n\t\t},\n\t)\n\n\tvar weightMsgEditSubspace int\n\tappParams.GetOrGenerate(cdc, OpWeightMsgEditSubspace, &weightMsgEditSubspace, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgEditSubspace = params.DefaultWeightMsgEditSubspace\n\t\t},\n\t)\n\n\tvar weightMsgAddAdmin int\n\tappParams.GetOrGenerate(cdc, OpWeightMsgAddAdmin, &weightMsgAddAdmin, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgAddAdmin = params.DefaultWeightMsgAddAmin\n\t\t},\n\t)\n\n\tvar weightMsgRemoveAdmin int\n\tappParams.GetOrGenerate(cdc, OpWeightMsgRemoveAdmin, &weightMsgRemoveAdmin, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgRemoveAdmin = params.DefaultWeightMsgRemoveAdmin\n\t\t},\n\t)\n\n\tvar weightMsgRegisterUser int\n\tappParams.GetOrGenerate(cdc, OpWeightMsgRegisterUser, &weightMsgRegisterUser, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgRegisterUser = params.DefaultWeightMsgRegisterUser\n\t\t},\n\t)\n\n\tvar weightMsgUnregisterUser int\n\tappParams.GetOrGenerate(cdc, OpWeightMsgUnregisterUser, &weightMsgUnregisterUser, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgUnregisterUser = params.DefaultWeightMsgUnregisterUser\n\t\t},\n\t)\n\n\tvar weightMsgBanUser int\n\tappParams.GetOrGenerate(cdc, OpWeightMsgBanUser, &weightMsgBanUser, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgBanUser = params.DefaultWeightMsgBanUser\n\t\t},\n\t)\n\n\tvar weightMsgUnbanUser int\n\tappParams.GetOrGenerate(cdc, OpWeightMsgUnbanUser, &weightMsgUnbanUser, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgUnbanUser = params.DefaultWeightMsgUnbanUser\n\t\t},\n\t)\n\n\treturn sim.WeightedOperations{\n\t\tsim.NewWeightedOperation(\n\t\t\tweightMsgCreateSubspace,\n\t\t\tSimulateMsgCreateSubspace(k, ak, bk),\n\t\t),\n\t\tsim.NewWeightedOperation(\n\t\t\tweightMsgEditSubspace,\n\t\t\tSimulateMsgEditSubspace(k, ak, bk),\n\t\t),\n\t\tsim.NewWeightedOperation(\n\t\t\tweightMsgAddAdmin,\n\t\t\tSimulateMsgRegisterUser(k, ak, bk),\n\t\t),\n\t\tsim.NewWeightedOperation(\n\t\t\tweightMsgAddAdmin,\n\t\t\tSimulateMsgAddAdmin(k, ak, bk),\n\t\t),\n\t\tsim.NewWeightedOperation(\n\t\t\tweightMsgRemoveAdmin,\n\t\t\tSimulateMsgRemoveAdmin(k, ak, bk),\n\t\t),\n\t\tsim.NewWeightedOperation(\n\t\t\tweightMsgRegisterUser,\n\t\t\tSimulateMsgRegisterUser(k, ak, bk),\n\t\t),\n\t\tsim.NewWeightedOperation(\n\t\t\tweightMsgUnregisterUser,\n\t\t\tSimulateMsgUnregisterUser(k, ak, bk),\n\t\t),\n\t\tsim.NewWeightedOperation(\n\t\t\tweightMsgBanUser,\n\t\t\tSimulateMsgBanUser(k, ak, bk),\n\t\t),\n\t\tsim.NewWeightedOperation(\n\t\t\tweightMsgUnbanUser,\n\t\t\tSimulateMsgUnbanUser(k, ak, bk),\n\t\t),\n\t}\n}", "func (a key) compare(b key) int {\n\tif a.A < b.A {\n\t\treturn -1\n\t} else if a.A > b.A {\n\t\treturn 1\n\t}\n\n\tif a.B < b.B {\n\t\treturn -1\n\t} else if a.B > b.B {\n\t\treturn 1\n\t}\n\n\treturn 0\n}", "func (b *Builder) zipWeight() {\n\tmsize := b.size\n\tnewBase := make([]int, msize)\n\tcopy(newBase[:b.size], b.trie.Base[:b.size])\n\tb.trie.Base = newBase\n\n\tnewCheck := make([]int, msize, msize)\n\tcopy(newCheck[:b.size], b.trie.Check[:b.size])\n\tb.trie.Check = newCheck\n}", "func (s *Solution) decide(scale Scale) (int, Weight, int) {\n\tz := s.GetZeroCoin()\n\tscale.SetZeroCoin(z)\n\n\tresults := [3]Weight{}\n\n\tresults[0] = scale.Weigh(s.Weighings[0].Left().AsCoins(z), s.Weighings[0].Right().AsCoins(z))\n\tresults[1] = scale.Weigh(s.Weighings[1].Left().AsCoins(z), s.Weighings[1].Right().AsCoins(z))\n\tresults[2] = scale.Weigh(s.Weighings[2].Left().AsCoins(z), s.Weighings[2].Right().AsCoins(z))\n\n\tif s.encoding.Flip != nil {\n\t\tresults[*s.encoding.Flip] = Heavy - results[*s.encoding.Flip]\n\t}\n\n\ta := results[0]\n\tb := results[1]\n\tc := results[2]\n\n\ti := int(a*9 + b*3 + c - 13) // must be between 0 and 26, inclusive.\n\to := abs(i)\n\tif len(s.Coins) == 12 {\n\t\tif o < 1 || o > 12 {\n\t\t\t// this can only happen if flip hasn't be set correctly.\n\t\t\tpanic(fmt.Errorf(\"index out of bounds: %d, %v\", o, []Weight{a, b, c}))\n\t\t}\n\t\to = o - 1\n\t} else {\n\t\to = i + 13\n\t}\n\n\tf := s.Coins[o]\n\tw := s.Weights[o]\n\n\tif i > 0 {\n\t\tw = Heavy - w\n\t}\n\n\treturn f, w, o\n}", "func checkWeights(ctx context.Context, t *testing.T, sws ...srvWeight) {\n\tt.Helper()\n\n\tc := sws[0].srv.Client\n\n\t// Replace the weights with approximate counts of RPCs wanted given the\n\t// iterations performed.\n\tweightSum := 0\n\tfor _, sw := range sws {\n\t\tweightSum += sw.w\n\t}\n\tfor i := range sws {\n\t\tsws[i].w = rrIterations * sws[i].w / weightSum\n\t}\n\n\tfor attempts := 0; attempts < 10; attempts++ {\n\t\tserverCounts := make(map[string]int)\n\t\tfor i := 0; i < rrIterations; i++ {\n\t\t\tvar peer peer.Peer\n\t\t\tif _, err := c.EmptyCall(ctx, &testpb.Empty{}, grpc.Peer(&peer)); err != nil {\n\t\t\t\tt.Fatalf(\"Error from EmptyCall: %v; timed out waiting for weighted RR behavior?\", err)\n\t\t\t}\n\t\t\tserverCounts[peer.Addr.String()]++\n\t\t}\n\t\tif len(serverCounts) != len(sws) {\n\t\t\tcontinue\n\t\t}\n\t\tsuccess := true\n\t\tfor _, sw := range sws {\n\t\t\tc := serverCounts[sw.srv.Address]\n\t\t\tif c < sw.w-2 || c > sw.w+2 {\n\t\t\t\tsuccess = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif success {\n\t\t\tt.Logf(\"Passed iteration %v; counts: %v\", attempts, serverCounts)\n\t\t\treturn\n\t\t}\n\t\tt.Logf(\"Failed iteration %v; counts: %v; want %+v\", attempts, serverCounts, sws)\n\t\ttime.Sleep(5 * time.Millisecond)\n\t}\n\tt.Fatalf(\"Failed to route RPCs with proper ratio\")\n}", "func caseInsensitiveCompare(a, b string) int {\n\tfor i := 0; i < len(a) && i < len(b); i++ {\n\t\tif a[i] >= 'A' && a[i] <= 'Z' {\n\t\t\tif b[i] >= 'A' && b[i] <= 'Z' {\n\t\t\t\t// both are uppercase, do nothing\n\t\t\t\tif a[i] < b[i] {\n\t\t\t\t\treturn -1\n\t\t\t\t} else if a[i] > b[i] {\n\t\t\t\t\treturn 1\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// a is uppercase, convert a to lowercase\n\t\t\t\tif a[i]+32 < b[i] {\n\t\t\t\t\treturn -1\n\t\t\t\t} else if a[i]+32 > b[i] {\n\t\t\t\t\treturn 1\n\t\t\t\t}\n\t\t\t}\n\t\t} else if b[i] >= 'A' && b[i] <= 'Z' {\n\t\t\t// b is uppercase, convert b to lowercase\n\t\t\tif a[i] < b[i]+32 {\n\t\t\t\treturn -1\n\t\t\t} else if a[i] > b[i]+32 {\n\t\t\t\treturn 1\n\t\t\t}\n\t\t} else {\n\t\t\t// neither are uppercase\n\t\t\tif a[i] < b[i] {\n\t\t\t\treturn -1\n\t\t\t} else if a[i] > b[i] {\n\t\t\t\treturn 1\n\t\t\t}\n\t\t}\n\t}\n\tif len(a) < len(b) {\n\t\treturn -1\n\t}\n\treturn 0\n}", "func WeightedOperations(\n\tappParams simtypes.AppParams,\n\tcdc codec.JSONMarshaler,\n\tk keeper.Keeper,\n\tak types.AccountKeeper,\n\tbk types.BankKeeper,\n) simulation.WeightedOperations {\n\n\tvar weightIssue, weightEdit, weightMint, weightTransfer int\n\tappParams.GetOrGenerate(\n\t\tcdc, OpWeightMsgIssueToken, &weightIssue, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightIssue = 100\n\t\t},\n\t)\n\n\tappParams.GetOrGenerate(\n\t\tcdc, OpWeightMsgEditToken, &weightEdit, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightEdit = 50\n\t\t},\n\t)\n\n\tappParams.GetOrGenerate(\n\t\tcdc, OpWeightMsgMintToken, &weightMint, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMint = 50\n\t\t},\n\t)\n\n\tappParams.GetOrGenerate(\n\t\tcdc, OpWeightMsgTransferTokenOwner, &weightTransfer, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightTransfer = 50\n\t\t},\n\t)\n\n\treturn simulation.WeightedOperations{\n\t\t//simtypes.NewWeightedOperation(\n\t\t//\tweightIssue,\n\t\t//\tSimulateIssueToken(k, ak),\n\t\t//),\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightEdit,\n\t\t\tSimulateEditToken(k, ak, bk),\n\t\t),\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightMint,\n\t\t\tSimulateMintToken(k, ak, bk),\n\t\t),\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightTransfer,\n\t\t\tSimulateTransferTokenOwner(k, ak, bk),\n\t\t),\n\t}\n}", "func (e *FakeChainSelector) Weight(ctx context.Context, ts *types.TipSet) (big.Int, error) {\n\treturn e.Weigh(ctx, ts)\n}", "func (node *BinaryNode) Weight() int {\n\treturn 1 + node.left.Weight() + node.right.Weight()\n}", "func (c *Context) CMPW(amr, imr operand.Op) {\n\tc.addinstruction(x86.CMPW(amr, imr))\n}", "func (node *LiteralNode) Weight() int {\n\treturn 1\n}", "func Compare(a Value, b Value) (int, error) {\n\tswitch a.Kind() {\n\tcase Float:\n\t\tswitch b.Kind() {\n\t\tcase Float, Int, Uint:\n\t\t\tr := a.Float() - b.Float()\n\t\t\tif r > 0 {\n\t\t\t\treturn 1, nil\n\t\t\t}\n\t\t\tif r < 0 {\n\t\t\t\treturn -1, nil\n\t\t\t}\n\t\t\treturn 0, nil\n\t\t}\n\tcase Int:\n\t\tswitch b.Kind() {\n\t\tcase Float:\n\t\t\tr := a.Float() - b.Float()\n\t\t\tif r > 0 {\n\t\t\t\treturn 1, nil\n\t\t\t}\n\t\t\tif r < 0 {\n\t\t\t\treturn -1, nil\n\t\t\t}\n\t\t\treturn 0, nil\n\t\tcase Int, Uint:\n\t\t\tr := a.Int() - b.Int()\n\t\t\tif r > 0 {\n\t\t\t\treturn 1, nil\n\t\t\t}\n\t\t\tif r < 0 {\n\t\t\t\treturn -1, nil\n\t\t\t}\n\t\t\treturn 0, nil\n\t\t}\n\tcase Uint:\n\t\tswitch b.Kind() {\n\t\tcase Float:\n\t\t\tr := a.Float() - b.Float()\n\t\t\tif r > 0 {\n\t\t\t\treturn 1, nil\n\t\t\t}\n\t\t\tif r < 0 {\n\t\t\t\treturn -1, nil\n\t\t\t}\n\t\t\treturn 0, nil\n\t\tcase Int:\n\t\t\tr := a.Int() - b.Int()\n\t\t\tif r > 0 {\n\t\t\t\treturn 1, nil\n\t\t\t}\n\t\t\tif r < 0 {\n\t\t\t\treturn -1, nil\n\t\t\t}\n\t\t\treturn 0, nil\n\t\tcase Uint:\n\t\t\tr := a.Uint() - b.Uint()\n\t\t\tif r > 0 {\n\t\t\t\treturn 1, nil\n\t\t\t}\n\t\t\tif r < 0 {\n\t\t\t\treturn -1, nil\n\t\t\t}\n\t\t\treturn 0, nil\n\t\t}\n\tcase String:\n\t\tif b.Kind() == String {\n\t\t\tas := a.String()\n\t\t\tbs := b.String()\n\t\t\tif as < bs {\n\t\t\t\treturn -1, nil\n\t\t\t}\n\t\t\tif as > bs {\n\t\t\t\treturn 1, nil\n\t\t\t}\n\t\t\treturn 0, nil\n\t\t}\n\t}\n\treturn 0, fmt.Errorf(\"not comparable %T, %T\", a, b)\n}", "func (ngram *nGram) Compare(license1, license2 *License) float64 {\n\treturn license1.similarity(license2)\n}", "func compare(a, b []byte) int {\n\n\ti := 0\n\tj := len(b) - 1\n\n\tfor j >= 0 {\n\t\tif a[i] > b[j] {\n\t\t\treturn 1\n\t\t}\n\t\tif a[i] < b[j] {\n\t\t\treturn -1\n\t\t}\n\t\ti++\n\t\tj--\n\t}\n\treturn 0\n}", "func nextWeight(level colltab.Level, elems []rawCE) []rawCE {\n\tif level == colltab.Identity {\n\t\tnext := make([]rawCE, len(elems))\n\t\tcopy(next, elems)\n\t\treturn next\n\t}\n\tnext := []rawCE{makeRawCE(elems[0].w, elems[0].ccc)}\n\tnext[0].w[level]++\n\tif level < colltab.Secondary {\n\t\tnext[0].w[colltab.Secondary] = defaultSecondary\n\t}\n\tif level < colltab.Tertiary {\n\t\tnext[0].w[colltab.Tertiary] = defaultTertiary\n\t}\n\t// Filter entries that cannot influence ordering.\n\tfor _, ce := range elems[1:] {\n\t\tskip := true\n\t\tfor i := colltab.Primary; i < level; i++ {\n\t\t\tskip = skip && ce.w[i] == 0\n\t\t}\n\t\tif !skip {\n\t\t\tnext = append(next, ce)\n\t\t}\n\t}\n\treturn next\n}", "func (t *Tangle) Weight(s *site.Site) int {\n\tbound := make(map[*site.Site]bool)\n\t// Setting up exclusion list\n\texcl := make(map[hash.Hash]bool)\n\n\tinject := func(l []*site.Site) {\n\t\tfor _, v := range l {\n\t\t\tbound[v] = true\n\t\t}\n\t}\n\n\tinject(s.Validates)\n\tfor len(bound) != 0 {\n\t\tfor st := range bound {\n\t\t\tdelete(bound, st)\n\t\t\texcl[st.Hash()] = true\n\t\t\tfor _, v := range st.Validates {\n\t\t\t\tif !excl[v.Hash()] {\n\t\t\t\t\tbound[v] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// Calculating weight\n\trvl := make(map[hash.Hash][]*site.Site)\n\tinject(t.Tips())\n\tfor len(bound) != 0 {\n\t\tfor st := range bound {\n\t\t\tdelete(bound, st)\n\t\t\tfor _, v := range st.Validates {\n\t\t\t\tif !excl[v.Hash()] {\n\t\t\t\t\tbound[v] = true\n\t\t\t\t\trvl[v.Hash()] = append(rvl[v.Hash()], st)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tw := s.Hash().Weight()\n\tinject(rvl[s.Hash()])\n\tfor len(bound) != 0 {\n\t\tfor st := range bound {\n\t\t\tdelete(bound, st)\n\t\t\texcl[st.Hash()] = true\n\t\t\tw += st.Hash().Weight()\n\t\t\tfor _, v := range rvl[st.Hash()] {\n\t\t\t\tif !excl[v.Hash()] {\n\t\t\t\t\tbound[v] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn w\n}", "func WeightedOperations(\n\tregistry codectypes.InterfaceRegistry,\n\tappParams simtypes.AppParams,\n\tcdc codec.JSONCodec,\n\ttxGen client.TxConfig,\n\tak types.AccountKeeper,\n\tbk types.BankKeeper,\n\tk keeper.Keeper,\n\tsk types.StakingKeeper,\n) simulation.WeightedOperations {\n\tvar weightMsgUnjail int\n\tappParams.GetOrGenerate(OpWeightMsgUnjail, &weightMsgUnjail, nil, func(_ *rand.Rand) {\n\t\tweightMsgUnjail = DefaultWeightMsgUnjail\n\t})\n\n\treturn simulation.WeightedOperations{\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightMsgUnjail,\n\t\t\tSimulateMsgUnjail(codec.NewProtoCodec(registry), txGen, ak, bk, k, sk),\n\t\t),\n\t}\n}", "func enableWeights(tags []Tag) []Tag {\n\tvar dst []Tag\n\tfor _, v := range tags {\n\t\tdst = append(dst, Tag{v.Word, 1})\n\t\tfor i := 0; i < v.Weight-1; i++ {\n\t\t\tdst = append(dst, Tag{v.Word, 1})\n\t\t}\n\t}\n\treturn dst\n}", "func WeightLTE(v float64) predicate.Opt {\n\treturn predicate.Opt(func(s *sql.Selector) {\n\t\ts.Where(sql.LTE(s.C(FieldWeight), v))\n\t})\n}", "func CalcLevenshteinDist(firstWord string, secondWord string, display bool) int {\n\ta := []rune(\" \" + firstWord)\n\tb := []rune(\" \" + secondWord)\n\ttable := tableSetUp(len(a), len(b))\n\tfor r := 1; r < len(a); r++ {\n\t\tfor c := 1; c < len(b); c++ {\n\t\t\t//find local minimum\n\t\t\tupperLeft := (*table)[r-1][c-1]\n\t\t\tabove := (*table)[r-1][c]\n\t\t\tleft := (*table)[r][c-1]\n\t\t\tmin := customMin(upperLeft, above, left)\n\n\t\t\tif a[r] == b[c] {\n\t\t\t\t(*table)[r][c] = min\n\t\t\t} else {\n\t\t\t\t(*table)[r][c] = min + 1\n\t\t\t}\n\t\t}\n\t}\n\tif display {\n\t\tdisplayDynamicTable(table, a, b)\n\t}\n\n\treturn (*table)[len(a) - 1][len(b) - 1]\n}", "func Dec8_bin_RuneWeight(r rune) int32 {\n\tweight, ok := dec8_bin_Weights[r]\n\tif ok {\n\t\treturn weight\n\t} else if r >= 0 && r <= 163 {\n\t\treturn r + 0\n\t} else {\n\t\treturn 2147483647\n\t}\n}", "func Compare(pathA, pathB string) ([]*Diff, error) {\n\n\tout := make([]*Diff, 0)\n\n\tconnA, err := sqlite.Conn(pathA)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tconnB, err := sqlite.Conn(pathB)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tallA, err := connA.SelectAll()\n\tallB, err := connB.SelectAll()\n\n\tkeysBFound := map[string]bool{}\n\tkeysB := map[string]*sqlite.Record{}\n\tfor i := range allB {\n\t\tkeysB[allB[i].ID] = allB[i]\n\t}\n\n\tfor i := range allA {\n\t\ta := allA[i]\n\n\t\tb, find := keysB[allA[i].ID]\n\t\tif !find {\n\t\t\tdiff := &Diff{\n\t\t\t\tDiff: ANoB,\n\t\t\t\tRecords: []*sqlite.Record{a},\n\t\t\t}\n\t\t\tout = append(out, diff)\n\t\t\tcontinue\n\t\t}\n\n\t\tdiff := &Diff{\n\t\t\tDiff: Ok,\n\t\t\tRecords: []*sqlite.Record{a, b},\n\t\t}\n\n\t\tkeysBFound[b.ID] = true\n\n\t\tif a.Body.Hash != a.Body.Hash {\n\t\t\tdiff.Diff = Body\n\t\t}\n\t\tout = append(out, diff)\n\t}\n\n\tfor i := range allB {\n\t\tif !keysBFound[allB[i].ID] {\n\t\t\tdiff := &Diff{\n\t\t\t\tDiff: BNoA,\n\t\t\t\tRecords: []*sqlite.Record{allB[i]},\n\t\t\t}\n\t\t\tout = append(out, diff)\n\t\t}\n\t}\n\n\tfmt.Printf(\"allA: %d\\n\", len(allA))\n\tfmt.Printf(\"allB: %d\\n\", len(allB))\n\n\treturn out, err\n}", "func (A Matrix) Compare(B Matrix) int {\n\tma, na := A.Dimensions()\n\tmb, nb := B.Dimensions()\n\tif ma != mb || na != nb {\n\t\tpanic(\"dimension mismatch\")\n\t}\n\n\tfor i := 0; i < ma; i++ {\n\t\tfor j := 0; j < na; j++ {\n\t\t\tswitch {\n\t\t\tcase A[i][j] < B[i][j]:\n\t\t\t\treturn -1\n\t\t\tcase B[i][j] < A[i][j]:\n\t\t\t\treturn 1\n\t\t\t}\n\t\t}\n\t}\n\n\treturn 0\n}", "func (*JoinNode) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) {\n\t// Joins make use of coercibility, but they don't return anything themselves\n\treturn sql.Collation_binary, 7\n}", "func (g Graph) ConnectivityWeight(v Vertex) uint8 {\n\tweight := uint8(0)\n\n\tfor i := 0; i < int(g.Size); i++ {\n\t\tfor j := i + 1; j < int(g.Size); j++ {\n\t\t\tshortestPath := g.Path(Vertex(i), Vertex(j))\n\n\t\t\tfor _, p := range shortestPath {\n\t\t\t\tif p == v {\n\t\t\t\t\tweight++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn weight\n}", "func compareStrings(l, r *EvalResult) int {\n\tcoll, err := mergeCollations(l, r)\n\tif err != nil {\n\t\tthrowEvalError(err)\n\t}\n\tcollation := collations.Local().LookupByID(coll)\n\tif collation == nil {\n\t\tpanic(\"unknown collation after coercion\")\n\t}\n\treturn collation.Collate(l.bytes(), r.bytes(), false)\n}", "func CompareStrings(a, b string) float64 {\n\treturn jellyfish.JaroWinkler(a, b)\n}", "func (c *WeightedCache) Weight() int {\n\treturn c.weight\n}", "func CompareInsensitive(a, b string) bool {\n\t// a quick optimization. If the two strings have a different\n\t// length then they certainly are not the same\n\tif len(a) != len(b) {\n\t\treturn false\n\t}\n\n\tfor i := 0; i < len(a); i++ {\n\t\t// if the characters already match then we don't need to\n\t\t// alter their case. We can continue to the next rune\n\t\tif a[i] == b[i] {\n\t\t\tcontinue\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\t// The string length has been traversed without a mismatch\n\t// therefore the two match\n\treturn true\n}", "func compare_wordSubsets(a string,word_record [26]int)bool{\n\tvar a_record [26]int\n\tfor _,c := range a{\n\t\ta_record[c - 'a']++\n\t}\n\tfor i := 0;i < 26;i++{\n\t\tif word_record[i] == 0{\n\t\t\tcontinue\n\t\t}\n\t\tif a_record[i] == 0 || a_record[i] < word_record[i]{\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func (o RecordWeightedRoutingPolicyOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v RecordWeightedRoutingPolicy) int { return v.Weight }).(pulumi.IntOutput)\n}", "func (self *Sax) compare_letters(la, lb rune) float64 {\n return self.compareDict[string(la) + string(lb)]\n}", "func WeightedMinkowskiDistance(firstVector, secondVector, weightVector []float64, p float64) (float64, error) {\n\tdistance := 0.\n\tfor ii := range firstVector {\n\t\tdistance += weightVector[ii] * math.Pow(math.Abs(firstVector[ii]-secondVector[ii]), p)\n\t}\n\treturn math.Pow(distance, 1/p), nil\n}", "func (t byDiffDesc) Less(i, j int) bool {\n\treturn t[i].diff() > t[j].diff() ||\n\t\t(t[i].diff() == t[j].diff() && t[i].weight > t[j].weight)\n}", "func compare(a, b []byte) int {\n\n\tif len(a) != len(b) {\n\t\tpanic(\"different in length\")\n\t}\n\n\tfor i := range a {\n\t\tif a[i] < b[i] {\n\t\t\treturn less\n\t\t}\n\t}\n\n\tif a[len(a)-1] == b[len(a)-1] {\n\t\treturn equal\n\t}\n\n\treturn greater\n}", "func Geostd8_bin_RuneWeight(r rune) int32 {\n\tweight, ok := geostd8_bin_Weights[r]\n\tif ok {\n\t\treturn weight\n\t} else if r >= 0 && r <= 127 {\n\t\treturn r + 0\n\t} else {\n\t\treturn 2147483647\n\t}\n}", "func comparator(resultA []int64, resultB []int64) (numberofMatches int) {\n\n\tdefer measureTime(time.Now(), \"comparator\")\n\tnumberofMatches = 0\n\n\tfor ic := 0; ic < numberofPairs; ic++ { //\tComparator Code here =>\n\n\t\tresultA16LSB := resultA[ic] & 0x0000FFFF\n\t\tresultB16LSB := resultB[ic] & 0x0000FFFF\n\t\t/*\n\t\t\tif ic < 5 {\n\t\t\t\tfmt.Printf(\"resultA bits: => %032b\\n\", resultA[ic])\n\t\t\t\tfmt.Printf(\"resultB bits: => %032b\\n\", resultB[ic])\n\t\t\t\tfmt.Println(\"--------------------------------------------------\")\n\n\t\t\t\tfmt.Printf(\"resultA16LSB: => %032b\\n\", resultA16LSB)\n\t\t\t\tfmt.Printf(\"resultB16LSB: => %032b\\n\", resultB16LSB)\n\t\t\t\tfmt.Println(\"--------------------------------------------------\")\n\t\t\t}\n\t\t*/\n\t\tif resultB16LSB == resultA16LSB {\n\t\t\tnumberofMatches++\n\t\t\t//\tfmt.Println(numberofMatches)\n\t\t}\n\t}\n\treturn numberofMatches\n}", "func (v *VersionVector) Compare(other *VersionVector) CausalOrder {\n\tv.l.RLock()\n\tdefer v.l.RUnlock()\n\n\tif dotsEql(v.dots, other.dots) {\n\t\treturn OrderEqual\n\t}\n\n\tif v.DescendsFrom(other) {\n\t\treturn OrderGreater\n\t}\n\n\tif other.DescendsFrom(v) {\n\t\treturn OrderLess\n\t}\n\n\treturn OrderNone\n}", "func (v Version) Cmp(w Version) int {\n\tv0, v1, v2 := parseVersion(string(v))\n\tw0, w1, w2 := parseVersion(string(w))\n\tswitch {\n\tcase v0 > w0:\n\t\treturn 1\n\tcase v0 < w0:\n\t\treturn -1\n\tcase v1 > w1:\n\t\treturn 1\n\tcase v1 < w1:\n\t\treturn -1\n\tcase v2 > w2:\n\t\treturn 1\n\tcase v2 < w2:\n\t\treturn -1\n\t}\n\treturn 0\n}", "func (fields List) Weight() int {\n\tif fields.p == nil {\n\t\treturn 0\n\t}\n\tx, n := uvarint(*(*[]byte)(unsafe.Pointer(&bytes{fields.p, 10, 10})))\n\treturn x + n\n}", "func compareGeo(a, b float64) float64 {\n\tcompare := a - b\n\tif math.Abs(compare) <= geoTolerance {\n\t\treturn 0\n\t}\n\treturn compare\n}", "func compareVC(leftVC []int, rightVC []int, view []string) []int {\r\n\tleftSum := 0\r\n\trightSum := 0\r\n\tfor i := 0; i < len(view); i++ {\r\n\t\tleftSum += leftVC[i]\r\n\t\trightSum += rightVC[i]\r\n\t}\r\n\tif leftSum > rightSum {\r\n\t\treturn leftVC\r\n\t}\r\n\treturn rightVC\r\n}", "func (n node) compareTo(than string) int {\n\t// Corner case to shortcut if two strings are equal\n\tif n.key == than {\n\t\treturn 0\n\t}\n\tvar result int\n\tvar small string\n\tif len(n.key) < len(than) {\n\t\tsmall = n.key\n\t} else {\n\t\tsmall = than\n\t}\n\tfor x := 0; x < len(small); x++ {\n\t\tresult = int(n.key[x]) - int(than[x])\n\t\tif result == 0 {\n\t\t\tcontinue\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\t// Had to fix a corner case where the smaller word was just\n\t// the first part of the Than word.\n\tif result == 0 {\n\t\tif small == n.key {\n\t\t\treturn -1\n\t\t}\n\t\treturn 1\n\t}\n\treturn result\n}", "func (servers byPriorityWeight) Less(i, j int) bool {\n\treturn servers[i].Priority < servers[j].Priority ||\n\t\t(servers[i].Priority == servers[j].Priority && servers[i].Weight < servers[j].Weight)\n}", "func TestCompareNumerics(t *testing.T) {\n\ttests := []testCase{\n\t\t{\n\t\t\tname: \"decimal and float are equal\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &EqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewFloat64(189.6), sqltypes.NewDecimal(\"189.6\")},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and float with negative values are equal\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &EqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewFloat64(-98.1839), sqltypes.NewDecimal(\"-98.1839\")},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and float with negative values are not equal (1)\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &F, op: &EqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewFloat64(-98.9381), sqltypes.NewDecimal(\"-98.1839\")},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and float with negative values are not equal (2)\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &NotEqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewFloat64(-98.9381), sqltypes.NewDecimal(\"-98.1839\")},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and integer are equal (1)\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &EqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewInt64(8979), sqltypes.NewDecimal(\"8979\")},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and integer are equal (2)\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &EqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"8979.0000\"), sqltypes.NewInt64(8979)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and unsigned integer are equal (1)\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &EqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewUint64(901), sqltypes.NewDecimal(\"901\")},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and unsigned integer are equal (2)\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &EqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"901.00\"), sqltypes.NewUint64(901)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and unsigned integer are not equal (1)\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &NotEqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"192.129\"), sqltypes.NewUint64(192)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and unsigned integer are not equal (2)\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &F, op: &EqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"192.129\"), sqltypes.NewUint64(192)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is greater than integer\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &GreaterThanOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"1.01\"), sqltypes.NewInt64(1)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is greater-equal to integer\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &GreaterEqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"1.00\"), sqltypes.NewInt64(1)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is less than integer\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &LessThanOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\".99\"), sqltypes.NewInt64(1)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is less-equal to integer\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &LessEqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"1.00\"), sqltypes.NewInt64(1)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is greater than float\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &GreaterThanOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"849.896\"), sqltypes.NewFloat64(86.568)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is not greater than float\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &F, op: &GreaterThanOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"15.23\"), sqltypes.NewFloat64(8689.5)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is greater-equal to float (1)\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &GreaterEqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"65\"), sqltypes.NewFloat64(65)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is greater-equal to float (2)\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &GreaterEqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"65\"), sqltypes.NewFloat64(60)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is less than float\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &LessThanOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"0.998\"), sqltypes.NewFloat64(0.999)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is less-equal to float\",\n\t\t\tv1: NewColumn(0, defaultCollation), v2: NewColumn(1, defaultCollation),\n\t\t\tout: &T, op: &LessEqualOp{},\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"1.000101\"), sqltypes.NewFloat64(1.00101)},\n\t\t},\n\t}\n\n\tfor i, tcase := range tests {\n\t\tt.Run(fmt.Sprintf(\"%d %s\", i, tcase.name), func(t *testing.T) {\n\t\t\ttcase.run(t)\n\t\t})\n\t}\n}", "func WeightedOperations(\n\tregistry cdctypes.InterfaceRegistry,\n\tappParams simtypes.AppParams,\n\t_ codec.JSONCodec,\n\ttxCfg client.TxConfig,\n\tak nft.AccountKeeper,\n\tbk nft.BankKeeper,\n\tk keeper.Keeper,\n) simulation.WeightedOperations {\n\tvar weightMsgSend int\n\n\tappParams.GetOrGenerate(OpWeightMsgSend, &weightMsgSend, nil,\n\t\tfunc(_ *rand.Rand) {\n\t\t\tweightMsgSend = WeightSend\n\t\t},\n\t)\n\n\treturn simulation.WeightedOperations{\n\t\tsimulation.NewWeightedOperation(\n\t\t\tweightMsgSend,\n\t\t\tSimulateMsgSend(codec.NewProtoCodec(registry), txCfg, ak, bk, k),\n\t\t),\n\t}\n}", "func applyLocalityWeight(\n\tlocality *core.Locality,\n\tloadAssignment *endpoint.ClusterLoadAssignment,\n\tdistribute []*v1alpha3.LocalityLoadBalancerSetting_Distribute) {\n\tif distribute == nil {\n\t\treturn\n\t}\n\n\t// Support Locality weighted load balancing\n\t// (https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/locality_weight#locality-weighted-load-balancing)\n\t// by providing weights in LocalityLbEndpoints via load_balancing_weight.\n\t// By setting weights across different localities, it can allow\n\t// Envoy to weight assignments across different zones and geographical locations.\n\tfor _, localityWeightSetting := range distribute {\n\t\tif localityWeightSetting != nil &&\n\t\t\tutil.LocalityMatch(locality, localityWeightSetting.From) {\n\t\t\tmisMatched := map[int]struct{}{}\n\t\t\tfor i := range loadAssignment.Endpoints {\n\t\t\t\tmisMatched[i] = struct{}{}\n\t\t\t}\n\t\t\tfor locality, weight := range localityWeightSetting.To {\n\t\t\t\t// index -> original weight\n\t\t\t\tdestLocMap := map[int]uint32{}\n\t\t\t\ttotalWeight := uint32(0)\n\t\t\t\tfor i, ep := range loadAssignment.Endpoints {\n\t\t\t\t\tif _, exist := misMatched[i]; exist {\n\t\t\t\t\t\tif util.LocalityMatch(ep.Locality, locality) {\n\t\t\t\t\t\t\tdelete(misMatched, i)\n\t\t\t\t\t\t\tif ep.LoadBalancingWeight != nil {\n\t\t\t\t\t\t\t\tdestLocMap[i] = ep.LoadBalancingWeight.Value\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdestLocMap[i] = 1\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttotalWeight += destLocMap[i]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// in case wildcard dest matching multi groups of endpoints\n\t\t\t\t// the load balancing weight for a locality is divided by the sum of the weights of all localities\n\t\t\t\tfor index, originalWeight := range destLocMap {\n\t\t\t\t\tdestWeight := float64(originalWeight*weight) / float64(totalWeight)\n\t\t\t\t\tif destWeight > 0 {\n\t\t\t\t\t\tloadAssignment.Endpoints[index].LoadBalancingWeight = &wrappers.UInt32Value{\n\t\t\t\t\t\t\tValue: uint32(math.Ceil(destWeight)),\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// remove groups of endpoints in a locality that miss matched\n\t\t\tfor i := range misMatched {\n\t\t\t\tloadAssignment.Endpoints[i].LbEndpoints = nil\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n}", "func (w *WagnerFischer) Weights(weightInsert, weightReplace, weightAdd int) *WagnerFischer {\n\tw.weightInsert = weightInsert\n\tw.weightReplace = weightReplace\n\tw.weightAdd = weightAdd\n\n\treturn w\n}", "func cmp(a, b float64) int {\n\tconst epsilon = 0.00001 // The tolerance.\n\tswitch diff := (a - b) / b; { // a-b ensures that the diff will always be negative when a < b.\n\tcase diff < -epsilon: // Check tolerance if a < b.\n\t\treturn -1\n\tcase diff > epsilon: // Check tolerance if a > b.\n\t\treturn 1\n\t}\n\treturn 0\n}", "func Utf8mb3_slovak_ci_RuneWeight(r rune) int32 {\n\tweight, ok := common_utf_slovak_ci_Weights()[r]\n\tif ok {\n\t\treturn weight\n\t} else if r >= 9003 && r <= 9168 {\n\t\treturn r - 8070\n\t} else if r >= 9475 && r <= 9632 {\n\t\treturn r - 8323\n\t} else if r >= 10496 && r <= 10626 {\n\t\treturn r - 8775\n\t} else if r >= 10765 && r <= 10867 {\n\t\treturn r - 8800\n\t} else if r >= 10872 && r <= 10971 {\n\t\treturn r - 8803\n\t} else if r >= 10240 && r <= 10495 {\n\t\treturn r - 8022\n\t} else if r >= 5121 && r <= 5499 {\n\t\treturn r + 552\n\t} else if r >= 5543 && r <= 5740 {\n\t\treturn r + 560\n\t} else if r >= 40960 && r <= 42124 {\n\t\treturn r - 34149\n\t} else if r >= 20241 && r <= 20358 {\n\t\treturn r - 11992\n\t} else if r >= 20416 && r <= 20523 {\n\t\treturn r - 11992\n\t} else if r >= 20524 && r <= 20698 {\n\t\treturn r - 11992\n\t} else if r >= 21571 && r <= 21693 {\n\t\treturn r - 11992\n\t} else if r >= 21694 && r <= 21895 {\n\t\treturn r - 11992\n\t} else if r >= 22121 && r <= 22230 {\n\t\treturn r - 11992\n\t} else if r >= 22320 && r <= 22592 {\n\t\treturn r - 11992\n\t} else if r >= 22900 && r <= 23375 {\n\t\treturn r - 11991\n\t} else if r >= 23665 && r <= 23833 {\n\t\treturn r - 11991\n\t} else if r >= 23889 && r <= 23994 {\n\t\treturn r - 11991\n\t} else if r >= 24062 && r <= 24177 {\n\t\treturn r - 11991\n\t} else if r >= 24605 && r <= 24724 {\n\t\treturn r - 11990\n\t} else if r >= 25164 && r <= 25289 {\n\t\treturn r - 11990\n\t} else if r >= 25343 && r <= 25467 {\n\t\treturn r - 11990\n\t} else if r >= 25505 && r <= 25754 {\n\t\treturn r - 11990\n\t} else if r >= 25797 && r <= 25902 {\n\t\treturn r - 11990\n\t} else if r >= 26793 && r <= 27138 {\n\t\treturn r - 11987\n\t} else if r >= 27156 && r <= 27347 {\n\t\treturn r - 11987\n\t} else if r >= 28187 && r <= 28316 {\n\t\treturn r - 11987\n\t} else if r >= 28452 && r <= 28651 {\n\t\treturn r - 11987\n\t} else if r >= 28671 && r <= 28778 {\n\t\treturn r - 11987\n\t} else if r >= 28890 && r <= 29001 {\n\t\treturn r - 11987\n\t} else if r >= 30466 && r <= 30682 {\n\t\treturn r - 11987\n\t} else if r >= 30707 && r <= 30827 {\n\t\treturn r - 11987\n\t} else if r >= 31521 && r <= 31680 {\n\t\treturn r - 11987\n\t} else if r >= 31681 && r <= 31806 {\n\t\treturn r - 11987\n\t} else if r >= 32048 && r <= 32160 {\n\t\treturn r - 11987\n\t} else if r >= 32415 && r <= 32565 {\n\t\treturn r - 11987\n\t} else if r >= 32908 && r <= 33240 {\n\t\treturn r - 11987\n\t} else if r >= 33402 && r <= 33509 {\n\t\treturn r - 11987\n\t} else if r >= 33591 && r <= 33737 {\n\t\treturn r - 11987\n\t} else if r >= 33880 && r <= 34030 {\n\t\treturn r - 11987\n\t} else if r >= 34045 && r <= 34253 {\n\t\treturn r - 11987\n\t} else if r >= 34411 && r <= 34746 {\n\t\treturn r - 11987\n\t} else if r >= 34747 && r <= 34847 {\n\t\treturn r - 11987\n\t} else if r >= 35328 && r <= 35498 {\n\t\treturn r - 11987\n\t} else if r >= 35744 && r <= 35894 {\n\t\treturn r - 11987\n\t} else if r >= 36336 && r <= 36522 {\n\t\treturn r - 11987\n\t} else if r >= 36791 && r <= 36899 {\n\t\treturn r - 11987\n\t} else if r >= 37429 && r <= 37636 {\n\t\treturn r - 11987\n\t} else if r >= 37707 && r <= 38020 {\n\t\treturn r - 11987\n\t} else if r >= 38021 && r <= 38262 {\n\t\treturn r - 11987\n\t} else if r >= 39410 && r <= 39530 {\n\t\treturn r - 11987\n\t} else if r >= 39792 && r <= 40023 {\n\t\treturn r - 11987\n\t} else if r >= 40060 && r <= 40164 {\n\t\treturn r - 11987\n\t} else if r >= 40165 && r <= 40372 {\n\t\treturn r - 11987\n\t} else if r >= 13312 && r <= 19893 {\n\t\treturn r + 15583\n\t} else if r >= 1970 && r <= 2304 {\n\t\treturn r + 33723\n\t} else if r >= 6517 && r <= 6623 {\n\t\treturn r + 30534\n\t} else if r >= 6657 && r <= 7423 {\n\t\treturn r + 30502\n\t} else if r >= 7533 && r <= 7679 {\n\t\treturn r + 30394\n\t} else if r >= 11022 && r <= 11903 {\n\t\treturn r + 27432\n\t} else if r >= 42183 && r <= 55295 {\n\t\treturn r - 2617\n\t} else if r >= 57345 && r <= 63743 {\n\t\treturn r - 4665\n\t} else if r >= 64107 && r <= 64255 {\n\t\treturn r - 5026\n\t} else {\n\t\treturn 2147483647\n\t}\n}", "func (cur *cursor) compare(other *cursor) int {\n\treturn compareCursors(cur, other)\n}", "func weighted_reward(w map[int]float64, allocation vrp.Allocation) float64 {\n\tvar reward float64\n\tfor id, _ := range allocation {\n\t\treward += w[id] * allocation[id]\n\t}\n\treturn reward\n}", "func (m *MinWise) Similarity(m2 *MinWise) float64 {\n\n\tif len(m.minimums) != len(m2.minimums) {\n\t\tpanic(\"minhash minimums size mismatch\")\n\t}\n\n\tintersect := 0\n\n\tfor i := range m.minimums {\n\t\tif m.minimums[i] == m2.minimums[i] {\n\t\t\tintersect++\n\t\t}\n\t}\n\n\treturn float64(intersect) / float64(len(m.minimums))\n}", "func compare(a, b []byte) int {\n\treturn bytes.Compare(a, b)\n}", "func edgeWeight(weight path.Weighting, uid, vid int64) float64 {\n\tw, ok := weight(uid, vid)\n\tif !ok {\n\t\tpanic(\"D* Lite: unexpected invalid weight\")\n\t}\n\treturn w\n}", "func WeightEQ(v float64) predicate.Opt {\n\treturn predicate.Opt(func(s *sql.Selector) {\n\t\ts.Where(sql.EQ(s.C(FieldWeight), v))\n\t})\n}", "func TestCompareNumerics(t *testing.T) {\n\ttests := []testCase{\n\t\t{\n\t\t\tname: \"decimal and float are equal\",\n\t\t\tv1: NewColumn(0, sqltypes.Float64, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Decimal, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.EqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewFloat64(189.6), sqltypes.NewDecimal(\"189.6\")},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and float with negative values are equal\",\n\t\t\tv1: NewColumn(0, sqltypes.Float64, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Decimal, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.EqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewFloat64(-98.1839), sqltypes.NewDecimal(\"-98.1839\")},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and float with negative values are not equal (1)\",\n\t\t\tv1: NewColumn(0, sqltypes.Float64, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Decimal, collations.CollationBinaryID),\n\t\t\tout: &F, op: sqlparser.EqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewFloat64(-98.9381), sqltypes.NewDecimal(\"-98.1839\")},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and float with negative values are not equal (2)\",\n\t\t\tv1: NewColumn(0, sqltypes.Float64, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Decimal, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.NotEqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewFloat64(-98.9381), sqltypes.NewDecimal(\"-98.1839\")},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and integer are equal (1)\",\n\t\t\tv1: NewColumn(0, sqltypes.Int64, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Decimal, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.EqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewInt64(8979), sqltypes.NewDecimal(\"8979\")},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and integer are equal (2)\",\n\t\t\tv1: NewColumn(0, sqltypes.Decimal, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Int64, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.EqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"8979.0000\"), sqltypes.NewInt64(8979)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and unsigned integer are equal (1)\",\n\t\t\tv1: NewColumn(0, sqltypes.Uint64, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Decimal, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.EqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewUint64(901), sqltypes.NewDecimal(\"901\")},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and unsigned integer are equal (2)\",\n\t\t\tv1: NewColumn(0, sqltypes.Decimal, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Uint64, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.EqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"901.00\"), sqltypes.NewUint64(901)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and unsigned integer are not equal (1)\",\n\t\t\tv1: NewColumn(0, sqltypes.Decimal, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Uint64, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.NotEqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"192.129\"), sqltypes.NewUint64(192)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal and unsigned integer are not equal (2)\",\n\t\t\tv1: NewColumn(0, sqltypes.Decimal, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Uint64, collations.CollationBinaryID),\n\t\t\tout: &F, op: sqlparser.EqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"192.129\"), sqltypes.NewUint64(192)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is greater than integer\",\n\t\t\tv1: NewColumn(0, sqltypes.Decimal, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Int64, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.GreaterThanOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"1.01\"), sqltypes.NewInt64(1)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is greater-equal to integer\",\n\t\t\tv1: NewColumn(0, sqltypes.Decimal, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Int64, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.GreaterEqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"1.00\"), sqltypes.NewInt64(1)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is less than integer\",\n\t\t\tv1: NewColumn(0, sqltypes.Decimal, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Int64, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.LessThanOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\".99\"), sqltypes.NewInt64(1)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is less-equal to integer\",\n\t\t\tv1: NewColumn(0, sqltypes.Decimal, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Int64, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.LessEqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"1.00\"), sqltypes.NewInt64(1)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is greater than float\",\n\t\t\tv1: NewColumn(0, sqltypes.Decimal, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Float64, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.GreaterThanOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"849.896\"), sqltypes.NewFloat64(86.568)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is not greater than float\",\n\t\t\tv1: NewColumn(0, sqltypes.Decimal, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Float64, collations.CollationBinaryID),\n\t\t\tout: &F, op: sqlparser.GreaterThanOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"15.23\"), sqltypes.NewFloat64(8689.5)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is greater-equal to float (1)\",\n\t\t\tv1: NewColumn(0, sqltypes.Decimal, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Float64, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.GreaterEqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"65\"), sqltypes.NewFloat64(65)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is greater-equal to float (2)\",\n\t\t\tv1: NewColumn(0, sqltypes.Decimal, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Float64, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.GreaterEqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"65\"), sqltypes.NewFloat64(60)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is less than float\",\n\t\t\tv1: NewColumn(0, sqltypes.Decimal, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Float64, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.LessThanOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"0.998\"), sqltypes.NewFloat64(0.999)},\n\t\t},\n\t\t{\n\t\t\tname: \"decimal is less-equal to float\",\n\t\t\tv1: NewColumn(0, sqltypes.Decimal, collations.CollationBinaryID), v2: NewColumn(1, sqltypes.Float64, collations.CollationBinaryID),\n\t\t\tout: &T, op: sqlparser.LessEqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewDecimal(\"1.000101\"), sqltypes.NewFloat64(1.00101)},\n\t\t},\n\t\t{\n\t\t\tname: \"different int types are equal for 8 bit\",\n\t\t\tv1: NewColumn(0, sqltypes.Int8, collations.CollationBinaryID), v2: NewLiteralInt(0),\n\t\t\tout: &T, op: sqlparser.EqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewInt8(0)},\n\t\t},\n\t\t{\n\t\t\tname: \"different int types are equal for 32 bit\",\n\t\t\tv1: NewColumn(0, sqltypes.Int32, collations.CollationBinaryID), v2: NewLiteralInt(0),\n\t\t\tout: &T, op: sqlparser.EqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewInt32(0)},\n\t\t},\n\t\t{\n\t\t\tname: \"different int types are equal for float32 bit\",\n\t\t\tv1: NewColumn(0, sqltypes.Float32, collations.CollationBinaryID), v2: NewLiteralFloat(1.0),\n\t\t\tout: &T, op: sqlparser.EqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.MakeTrusted(sqltypes.Float32, []byte(\"1.0\"))},\n\t\t},\n\t\t{\n\t\t\tname: \"different unsigned int types are equal for 8 bit\",\n\t\t\tv1: NewColumn(0, sqltypes.Uint8, collations.CollationBinaryID), v2: NewLiteralInt(0),\n\t\t\tout: &T, op: sqlparser.EqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.MakeTrusted(sqltypes.Uint8, []byte(\"0\"))},\n\t\t},\n\t\t{\n\t\t\tname: \"different unsigned int types are equal for 32 bit\",\n\t\t\tv1: NewColumn(0, sqltypes.Uint32, collations.CollationBinaryID), v2: NewLiteralInt(0),\n\t\t\tout: &T, op: sqlparser.EqualOp,\n\t\t\trow: []sqltypes.Value{sqltypes.NewUint32(0)},\n\t\t},\n\t}\n\n\tfor i, tcase := range tests {\n\t\tt.Run(fmt.Sprintf(\"%d %s\", i, tcase.name), func(t *testing.T) {\n\t\t\ttcase.run(t)\n\t\t})\n\t}\n}", "func (k *joinKey) less(other joinKey) bool {\n\ta, b := k, other\n\tfor i := 0; i < len(k.values); i++ {\n\t\tif b.values[i].IsNull() {\n\t\t\treturn true\n\t\t} else if a.values[i].IsNull() {\n\t\t\treturn false\n\t\t}\n\n\t\tswitch a.columns[i].Type {\n\t\tcase flux.TBool:\n\t\t\tif av, bv := a.values[i].Bool(), b.values[i].Bool(); av != bv {\n\t\t\t\treturn bv\n\t\t\t}\n\t\tcase flux.TInt:\n\t\t\tif av, bv := a.values[i].Int(), b.values[i].Int(); av != bv {\n\t\t\t\treturn av < bv\n\t\t\t}\n\t\tcase flux.TUInt:\n\t\t\tif av, bv := a.values[i].UInt(), b.values[i].UInt(); av != bv {\n\t\t\t\treturn av < bv\n\t\t\t}\n\t\tcase flux.TFloat:\n\t\t\tif av, bv := a.values[i].Float(), b.values[i].Float(); av != bv {\n\t\t\t\treturn av < bv\n\t\t\t}\n\t\tcase flux.TString:\n\t\t\tif av, bv := a.values[i].Str(), b.values[i].Str(); av != bv {\n\t\t\t\treturn av < bv\n\t\t\t}\n\t\tcase flux.TTime:\n\t\t\tif av, bv := a.values[i].Time(), b.values[i].Time(); av != bv {\n\t\t\t\treturn av < bv\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}", "func _compare(i Instruction, ls *LuaState, op CompareOp) {\n\ta, b, c := i.ABC()\n\n\tls.getRK(b)\n\tls.getRK(c)\n\tif luaCompare(ls, -2, -1, op) != (a != 0) {\n\t\tls.addPC(1)\n\t}\n\tluaPop(ls, 2)\n}", "func (ki keyInfo) Weight() int {\n\treturn ki.size\n}", "func DiffBits(c1, c2 [32]byte) int {\n\tvar count int\n\tfor i := range c1 {\n\t\tcount += popcount.PopCount(uint64(c1[i] ^ c2[i]))\n\t}\n\treturn count\n}", "func (v *Validator) Weight() uint64 {\n\treturn v.Wght\n}", "func Difference(word1, word2 string) int {\n\tif word1 == word2 {\n\t\treturn 100\n\t}\n\tsoundex1 := Encode(word1)\n\tsoundex2 := Encode(word2)\n\tsum := differenceSoundex(soundex1, soundex2) + differenceSoundex(soundex2, soundex1)\n\tif sum == 0 {\n\t\treturn 0\n\t}\n\treturn sum / 2\n}", "func (rf RecordFlags) Compare(rf2 RecordFlags) int {\n\tif c := len(rf) - len(rf2); c != 0 {\n\t\treturn c\n\t}\n\n\treturn strings.Compare(rf.String(), rf2.String())\n}", "func web_strcmp(\nj[]rune,/* first string */\nk[]rune/* second string */)int{\ni:=0\nfor;i<len(j)&&i<len(k)&&j[i]==k[i];i++{}\nif i==len(k){\nif i==len(j){\nreturn equal\n}else{\nreturn extension\n}\n}else{\nif i==len(j){\nreturn prefix\n}else if j[i]<k[i]{\nreturn less\n}else{\nreturn greater\n}\n}\nreturn equal\n}" ]
[ "0.5189569", "0.51442885", "0.5119967", "0.50551087", "0.5029887", "0.49232233", "0.49166036", "0.49087584", "0.48527613", "0.48441088", "0.4839668", "0.482278", "0.48217055", "0.4813844", "0.48036337", "0.47875902", "0.4784142", "0.47828326", "0.47776183", "0.47706735", "0.47706735", "0.4768426", "0.47515598", "0.4719694", "0.46975273", "0.4687943", "0.46842358", "0.46570045", "0.4656776", "0.46520096", "0.46498236", "0.46495458", "0.46450338", "0.46416715", "0.46169046", "0.45840293", "0.45831683", "0.45825988", "0.45782158", "0.45560268", "0.45554227", "0.4548621", "0.45359957", "0.45359167", "0.45240378", "0.45158142", "0.4507366", "0.45061654", "0.45002466", "0.44992658", "0.44782263", "0.44770378", "0.44519207", "0.4442309", "0.44396335", "0.44355485", "0.44143668", "0.440727", "0.43907097", "0.43830776", "0.4373957", "0.43632376", "0.43600592", "0.43475452", "0.43410364", "0.4330462", "0.43289804", "0.4318009", "0.43132427", "0.4312128", "0.4310591", "0.4300969", "0.42974275", "0.42925507", "0.42913857", "0.42909077", "0.4274813", "0.42595026", "0.42466408", "0.42453247", "0.42451403", "0.42429474", "0.42377454", "0.42319906", "0.42301425", "0.42289218", "0.42275026", "0.42157546", "0.4210495", "0.42053935", "0.41963062", "0.41922417", "0.41915667", "0.41865522", "0.41841432", "0.4182464", "0.4180723", "0.41719556", "0.41716486", "0.4171471" ]
0.8061941
0
Anagrams returns all anagrams of the input string using words from the lineseparated word list found at dpath
Anagrams возвращает все анаграммы входной строки, используя слова из списка слов, разделенных строками, найденного по пути dpath
func Anagrams(s string, dpath string) ([]string, error) { d, err := readDict(dpath) if err != nil { panic(err) } l := strings.ReplaceAll(s, " ", "") l = util.SortString(l) res := []string{} return *findAnagrams(l, &res, d, s), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func groupAnagrams(strs []string) [][]string {\n var result [][]string\n if len(strs)==0{\n return result\n }\n resultMap := make(map[string][]string)\n count := make([]string,26)\n for _, str := range strs{\n fillArrayWithZero(count)\n for _, c := range str{\n val := count[c-'a']\n iVal,_ := strconv.Atoi(val)\n count[c-'a']=strconv.Itoa(iVal+1) \n }\n key :=strings.Join(count,\"\")\n resultMap[key]=append(resultMap[key], str) \n }\n for _,val := range resultMap{\n result = append(result, val)\n }\n return result\n}", "func findAnagrams(s string, p string) []int {\n \n}", "func groupAnagramsOptimal(strs []string) [][]string {\n result := make([][]string, 0)\n\n if len(strs) == 0 {\n return result\n }\n\n tracker := make(map[string][]string)\n\n for _, s := range strs {\n count := make([]int, 26)\n for _, char := range s {\n count[char - 'a']++\n }\n\n sb := \"\"\n for i := 0; i < 26; i++ {\n sb += \"#\"\n sb += string(count[i])\n }\n\n tracker[sb] = append(tracker[sb], s)\n }\n\n for _, val := range tracker {\n result = append(result, val)\n }\n\n return result\n}", "func GroupAnagrams(strs []string) [][]string {\n groups := [][]string{}\n strHash := map[string][]string{}\n for _, str := range strs {\n sArr := strings.Split(str, \"\"); sort.Strings(sArr); s := strings.Join(sArr, \"\")\n if _, ok := strHash[s]; !ok { strHash[s] = []string{} }\n strHash[s] = append(strHash[s], str)\n }\n for _, sArr := range strHash {\n groups = append(groups, sArr)\n }\n return groups\n}", "func ProblemDay6() {\n\n\ttest1 := []string{\"eat\", \"tea\", \"tan\", \"ate\", \"nat\", \"bat\"}\n\n\tfmt.Println(groupAnagrams(test1))\n\n}", "func Anagrams(words []string) int {\n\tm := make(map[string]int)\n\tfor _, w := range words {\n\t\tsorted := SortString(w)\n\t\tm[sorted]++\n\t}\n\tcount := 0\n\tfor _, i := range m {\n\t\tif i == 1 {\n\t\t\tcount++\n\t\t}\n\t}\n\treturn count\n}", "func anagramList(words []string) map[string]map[string]bool {\n\tanagrams := make(map[string]map[string]bool)\n\tfor _, w := range words {\n\t\tw = strings.ToLower(w)\n\t\twordKey := sortWord(w)\n\t\tif anagrams[wordKey] != nil {\n\t\t\tanagrams[wordKey][w] = true\n\t\t} else {\n\t\t\tanagrams[wordKey] = make(map[string]bool)\n\t\t\tanagrams[wordKey][w] = true\n\t\t}\n\t}\n\treturn anagrams\n}", "func groupAnagrams(strs []string) [][]string {\n\tif len(strs) <= 1 {\n\t\treturn [][]string{strs}\n\t}\n\thash := make(map[string][]string)\n\tfor _, str := range strs {\n\t\trStr := []rune(str)\n\t\tsort.Slice(rStr, func(i, j int) bool {\n\t\t\treturn rStr[i] < rStr[j]\n\t\t})\n\t\thash[string(rStr)] = append(hash[string(rStr)], str)\n\t}\n\tvar res [][]string\n\tfor key := range hash {\n\t\tres = append(res, hash[key])\n\t}\n\treturn res\n}", "func findAnagrams(s string, p string) []int {\n\tls := len(s)\n\tlp := len(p)\n\tms := [26]int{}\n\tmp := [26]int{}\n\tres := []int{}\n\tfor _, v := range p {\n\t\tmp[v-'a'] += 1\n\t}\n\tfor i := 0; i < ls; i++ {\n\t\tif i >= lp {\n\t\t\tms[s[i-lp]-'a'] -= 1\n\t\t}\n\t\tms[s[i]-'a']+=1\n\t\tif ms == mp {\n\t\t\tres = append(res, i-lp+1)\n\t\t}\n\t}\n\treturn res\n}", "func groupAnagrams(strs []string) [][]string {\n\tvar set = make(map[[math.MaxUint8]int][]string)\n\tfor _, str := range strs {\n\t\tvar charSet = [math.MaxUint8]int{}\n\t\tfor _, letter := range []byte(str) {\n\t\t\tcharSet[letter]++\n\t\t}\n\t\tif _, ok := set[charSet]; !ok {\n\t\t\tset[charSet] = []string{str}\n\t\t} else {\n\t\t\tset[charSet] = append(set[charSet], str)\n\t\t}\n\t}\n\tres := make([][]string, 0, len(set))\n\tfor _, v := range set {\n\t\tres = append(res, v)\n\t}\n\treturn res\n}", "func groupAnagrams(strs []string) [][]string {\n\tmp := map[string][]string{}\n\tfor _, str := range strs {\n\t\tkey := std2(str)\n\t\tmp[key] = append(mp[key], str)\n\t}\n\t//make(Type, len, cap)\n\tans := make([][]string, 0, len(mp))\n\tfor _, v := range mp {\n\t\tans = append(ans, v)\n\t}\n\treturn ans\n\n}", "func groupAnagrams(strs []string) [][]string {\n\tstrToStrs := make(map[string][]string)\n\tfor _, str := range strs {\n\t\tbs := []byte(str)\n\t\tsort.Sort(byteSlice(bs))\n\t\tstrToStrs[string(bs)] = append(strToStrs[string(bs)], str)\n\t}\n\n\tvar ans [][]string\n\tfor _, group := range strToStrs {\n\t\tans = append(ans, group)\n\t}\n\n\treturn ans\n}", "func findAnagrams(s string, p string) []int {\n\tm := make(map[byte]int)\n\tfor i := range p {\n\t\tm[p[i]]++\n\t}\n\tresult := make([]int, 0)\n\tcount := len(m)\n\n\tbegin, end := 0, 0\n\n\tfor end < len(s) {\n\t\tif _, ok := m[s[end]]; ok {\n\t\t\tm[s[end]]--\n\t\t\tif m[s[end]] == 0 {\n\t\t\t\tcount--\n\t\t\t}\n\t\t}\n\t\tend++\n\n\t\tfor count == 0 {\n\t\t\tif _, ok := m[s[begin]]; ok {\n\t\t\t\tm[s[begin]]++\n\t\t\t\tif m[s[begin]] > 0 {\n\t\t\t\t\tcount++\n\t\t\t\t}\n\t\t\t}\n\t\t\tif end-begin == len(p) {\n\t\t\t\tresult = append(result, begin)\n\t\t\t}\n\t\t\tbegin++\n\t\t}\n\t}\n\treturn result\n}", "func GroupAnagrams(strs []string) [][]string {\n\treturn groupAnagrams(strs)\n}", "func groupAnagrams2(strs []string) [][]string {\n\thash := make(map[string]int)\n\tvar result [][]string\n\tkey := make([]rune, 26)\n\tfor _, str := range strs {\n\t\tfor _, r := range str {\n\t\t\tkey[r-'a']++\n\t\t}\n\t\tstrKey := string(key)\n\t\tif index, ok := hash[strKey]; ok {\n\t\t\tresult[index] = append(result[index], str)\n\t\t} else {\n\t\t\thash[strKey] = len(result)\n\t\t\tresult = append(result, []string{str})\n\t\t}\n\t}\n\treturn result\n}", "func computeGroupAnagram1(input []string) (groupAnagram map[string][]string, err string) {\n\n\tif input == nil {\n\t\treturn nil, \"ERROR: empty input\"\n\t}\n\n\tgroupAnagram = make(map[string][]string)\n\t//Sort each word in the input list and add the map, to group\n\tfor _, v := range input {\n\t\tsortWord := sortString(v)\n\t\tgroupAnagram[sortWord] = append(groupAnagram[sortWord], v)\n\n\t}\n\treturn groupAnagram, \"\"\n}", "func AnagramsReader(r io.Reader) int {\n\tbufR := bufio.NewReader(r)\n\tn := ReadConstraintN(bufR)\n\twords := make([]string, n)\n\tfor i := 0; i < n; i++ {\n\t\tline, err := bufR.ReadBytes('\\n')\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\twords[i] = string(line)\n\t}\n\treturn Anagrams(words)\n}", "func AlienDictonary(words []string) {\n\tdict := make(map[string][]string)\n\tfor i := 0; i < len(words); i++ {\n\t\tcurrent := string(words[i])\n\t\tfor j := 0; j < len(current); j++ {\n\t\t\t_, found := dict[string(current[j])]\n\t\t\tif !found {\n\t\t\t\tdict[string(current[j])] = []string{}\n\t\t\t}\n\n\t\t}\n\t}\n\tinEdges := make(map[string]int)\n\tfor key := range dict {\n\t\tinEdges[key] = 0\n\t}\n\tfor i := 1; i < len(words); i++ {\n\t\tfirst := words[i-1]\n\t\tsecond := words[i]\n\t\tl := int(math.Min(float64(len(first)), float64(len(second))))\n\t\tfor j := 0; j < l; j++ {\n\t\t\tif first[j] != second[j] {\n\t\t\t\tdict[string(first[j])] = append(dict[string(first[j])], string(second[j]))\n\t\t\t\tinEdges[string(second[j])]++\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tq := []string{}\n\tfor key := range inEdges {\n\t\tif inEdges[key] == 0 {\n\t\t\tq = append(q, key)\n\t\t}\n\t}\n\tans := \"\"\n\tfor len(q) > 0 {\n\t\tremoved := q[0]\n\t\tq = q[1:]\n\t\tans += removed\n\t\tcurrent := dict[removed]\n\t\tfor i := 0; i < len(current); i++ {\n\t\t\tinEdges[string(current[i])]--\n\t\t\tif inEdges[string(current[i])] == 0 {\n\t\t\t\tq = append(q, string(current[i]))\n\t\t\t}\n\t\t}\n\n\t}\n\tfmt.Println(ans)\n}", "func TestFindAllAnagramsinaString(t *testing.T) {\n\tvar cases = []struct {\n\t\ts string\n\t\tp string\n\t\toutput []int\n\t}{\n\t\t{\n\t\t\ts: \"cbaebabacd\",\n\t\t\tp: \"abc\",\n\t\t\toutput: []int{0, 6},\n\t\t},\n\t\t{\n\t\t\ts: \"abab\",\n\t\t\tp: \"ab\",\n\t\t\toutput: []int{0, 1, 2},\n\t\t},\n\t}\n\tfor _, c := range cases {\n\t\tx := findAnagrams(c.s, c.p)\n\t\tif !reflect.DeepEqual(x, c.output) {\n\t\t\tt.Fail()\n\t\t}\n\t}\n}", "func anagrams(s1 string, s2 string) bool {\n\tr1 := []rune(s1)\n\tr2 := []rune(s2)\n\tsort.Sort(sortableRunes(r1))\n\tsort.Sort(sortableRunes(r2))\n\n\tif string(r1) == string(r2) {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func Detect(word string, candidates []string) (anagrams []string) {\n\tfor _, cand := range candidates {\n\t\tif isAnagram(word, cand) {\n\t\t\tanagrams = append(anagrams, cand)\n\t\t}\n\t}\n\treturn\n}", "func computeGroupAnagram2(input []string) (map[string][]string, string) {\n\n\tif input == nil {\n\t\treturn nil, \"ERROR: empty input\"\n\t}\n\n\tgroupAnagram := make(map[string][]string)\n\n\t//Count the number of character occurrence of the word, and use that as the key in the map.\n\tfor _, word := range input {\n\n\t\tcountLetters := make([]int, 26)\n\t\tfor _, letter := range word {\n\n\t\t\tcountLetters[letter-'a'] += 1\n\n\t\t}\n\n\t\tstr := make([]string, 26)\n\t\t//Constant time loop - to create the key\n\t\tfor i := 0; i < 26; i += 1 {\n\t\t\tstr[i] = strconv.Itoa(countLetters[i])\n\t\t}\n\t\tkey := strings.Join(str, \"\")\n\n\t\tgroupAnagram[key] = append(groupAnagram[key], word)\n\t}\n\treturn groupAnagram, \"\"\n}", "func TestAllAnagrams1(t *testing.T) {\n\ta := allAnagrams(\"god\")\n\tfmt.Printf(\"%v\\n\", a)\n\tassert.Equal(t, 6, len(a))\n}", "func Anagram(a string) []string {\n\tn := len(a)\n\treturn printAnagramUtil([]rune(a), n, n)\n}", "func (a *AnagramMap) AnagramSentence(sent []string) []string {\n\tvar ret []string\n\tfmt.Println(sent)\n\tfor _, s := range sent {\n\t\tfmt.Println(s)\n\t\tret = append(ret, a.AnagramOfWord(s))\n\t}\n\treturn ret\n}", "func main() {\n\n\t//fmt.Println(groupAnagrams([]string{\"eat\", \"tea\", \"tan\", \"ate\", \"nat\", \"bat\"}))\n\tfmt.Println(std(\"eatttttttt\"))\n\tfmt.Println(std2(\"eatttttttt\"))\n}", "func findLadders(beginWord string, endWord string, wordList []string) [][]string {\n\n}", "func Detect(word string, candidates []string) []string {\n\tanagrams := []string{}\n\twordFrequencies := Frequencies(word)\n\tfor _, candidate := range candidates {\n\t\tif !strings.EqualFold(word, candidate) &&\n\t\t\treflect.DeepEqual(Frequencies(candidate), wordFrequencies) {\n\t\t\tanagrams = append(anagrams, candidate)\n\t\t}\n\t}\n\treturn anagrams\n}", "func groupAnagrams3(strs []string) [][]string {\n\tif len(strs) <= 1 {\n\t\treturn [][]string{strs}\n\t}\n\thash := make(map[int32]int)\n\tvar result [][]string\n\tfor _, str := range strs {\n\t\tvar mul int32 = 1\n\t\tvar sum int32 = 0\n\t\tfor _, r := range str {\n\t\t\tmul *= r\n\t\t\tsum += r\n\t\t}\n\t\tsum += mul\n\t\tif index, ok := hash[sum]; ok {\n\t\t\tresult[index] = append(result[index], str)\n\t\t} else {\n\t\t\thash[sum] = len(result)\n\t\t\tresult = append(result, []string{str})\n\t\t}\n\t}\n\treturn result\n}", "func SplitIntoNGrams(nGram int, query string) []Term {\n\trunes := []rune(query)\n\n\tif len(runes) < nGram {\n\t\treturn []Term{}\n\t}\n\n\tresult := make([]Term, 0, len(runes)-nGram+1)\n\n\tfor i := 0; i < len(runes)-nGram+1; i++ {\n\t\tresult = appendUnique(result, string(runes[i:i+nGram]))\n\t}\n\n\treturn result\n}", "func main() {\n\tc := AnagramsReader(os.Stdin)\n\tfmt.Println(c)\n}", "func (a *AnagramMap) AnagramOfWord(word string) string {\n\tword = strings.ToLower(word)\n\twordKey := sortWord(word)\n\twordMap := a.Mapping[wordKey]\n\tif len(wordMap) <= 1 {\n\t\treturn word\n\t} else {\n\t\tuniqueWords := make([]string, 0)\n\t\tfor k, _ := range wordMap {\n\t\t\tif k != word {\n\t\t\t\tuniqueWords = append(uniqueWords, k)\n\t\t\t}\n\t\t}\n\n\t\tt := time.Now()\n\t\tr := rand.New(rand.NewSource(t.UnixNano()))\n\t\tw := uniqueWords[r.Intn(len(uniqueWords))]\n\t\treturn w\n\t}\n}", "func sherlockAndAnagrams(s string) int32 {\n\t// Write your code here\n\tvar answer int32 = 0\n\n\t//increase of anagram elements size from 1 to exlusive len(s)\n\tfor anagramSize := 1; anagramSize < len(s); anagramSize++ {\n\n\t\t//Declare slice of maps of runes sets with counter of every rune inclusion\n\t\t//\n\t\t//Explanation: because we looks for unordered anagrams,\n\t\t//the best way to compare them is to count number of its runes.\n\t\t//\n\t\t//For ex.:\n\t\t// \"iffa\" = i:1,f:2,a:1\n\t\t// \"fifa\" =f:2,i:1,a:1 ==> map of iffa runes = map of fifa runes\n\t\t//\n\t\t//Because only same-sized anagrams can be matched, we should renew\n\t\t//slice on every step of anagram incrise\n\t\tanagram := []map[string]int{}\n\n\t\t//Iter over S with all-sized anagrams\n\n\t\tfor anagramPos := 0; anagramPos <= len(s)-anagramSize; anagramPos++ {\n\t\t\ttempMap := make(map[string]int)\n\n\t\t\t//Fill map with s[rune] = counter\n\t\t\tfor i := 0; i < anagramSize; i++ {\n\t\t\t\ttempMap[string(s[anagramPos+i])]++\n\n\t\t\t\t// fmt.Println(\"tempMap\", tempMap) //for debug\n\t\t\t}\n\n\t\t\t//Check is there equal maps in our slice\n\t\t\tfor _, m := range anagram {\n\n\t\t\t\tif reflect.DeepEqual(m, tempMap) {\n\t\t\t\t\tanswer++\n\n\t\t\t\t\t// fmt.Println(\"match found!\", answer) //for debug\n\t\t\t\t}\n\t\t\t}\n\t\t\tanagram = append(anagram, tempMap)\n\n\t\t\t// fmt.Println(\"map slice\", anagram) //for debug\n\t\t}\n\t}\n\n\treturn answer\n}", "func main() {\n\tfmt.Println(anagram(\"funeral\", \"realfun\"))\n}", "func AnagramKey(s string) string {\n\tchars := map[rune]int{}\n\trunes := []rune(s)\n\n\tfor _, rune := range s {\n\t\tchars[rune]++\n\t}\n\n\tsort.Sort(utils.SortedRunes(runes))\n\n\tout := []byte{}\n\tfor _, rune := range runes {\n\t\tout = strconv.AppendInt(out, int64(chars[rune]), 10)\n\t\tout = append(out, byte(rune))\n\t}\n\n\treturn string(out)\n}", "func IsAnagram(str1, str2 string) bool {\n\tif len(str1) != len(str2) {\n\t\treturn false\n\t}\n\n\tstr1 = strings.ToLower(str1)\n\tstr2 = strings.ToLower(str2)\n\n\tset1 := datastructure.NewSet()\n\tset2 := datastructure.NewSet()\n\n\tfor _, char := range str1 {\n\t\tset1.List[int(char)] = struct{}{}\n\t}\n\n\tfor _, char := range str2 {\n\t\tset2.List[int(char)] = struct{}{}\n\t}\n\n\treturn set1.Intersects(set2)\n}", "func isAnagram(s1, s2 string) bool {\n\n\tif len(s1) != len(s2) { // if s1 and s2 are not the same length\n\t\treturn false // they cannot be anagrams\n\t}\n\n\truneCount := map[rune]int{} // data structure to count each rune\n\n\tfor _, r := range s1 { // for each rune in s1\n\t\truneCount[r]++ // count the occurrences of the rune\n\t}\n\n\tfor _, r := range s2 { // for each rune in s2\n\t\tif runeCount[r] > 0 { // if it existed in s1\n\t\t\truneCount[r]-- // and there are the same number in each, okay\n\t\t} else { // if the rune wasn't in s1 or there are more occurrences in s2\n\t\t\t// fmt.Printf(\"%v and %v are not anagrams\\n\", s1, s2)\n\t\t\treturn false // they cannot be anagrams\n\t\t}\n\t}\n\t// fmt.Printf(\"!!%v and %v are anagrams!!\\n\", s1, s2)\n\treturn true // if all occurrences of each rune are equal, we have an anagram\n}", "func hashAnagram(s string) string {\n\tbuf := make([]byte, 26) // could be []rune here\n\tfor i := 0; i < len(s); i++ {\n\t\tbuf[s[i]-'a']++\n\t}\n\treturn string(buf)\n}", "func anagram1(x string, y string) bool {\n\tif lenCheck(x, y) {\n\t\t//Continue anagram check\n\t\t//TODO: map characters\n\t\tamapX := sortWord(x)\n\t\tamapY := sortWord(y)\n\t\tif amapX == amapY {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func anagram(sm map[rune]int, candidate string, index int, indexChan chan int, finChan chan bool) {\n\tcm := make(map[rune]int)\n\tfor _, r := range candidate {\n\t\tif _, ok := cm[r]; !ok {\n\t\t\tcm[r] = 1\n\t\t} else {\n\t\t\tcm[r]++\n\t\t\tif cm[r] > sm[r] {\n\t\t\t\tfinChan <- true\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\tif same(sm, cm) {\n\t\tindexChan <- index\n\t}\n\n\tfinChan <- true\n}", "func Detect(input string, list []string) []string {\n\tret := make([]string, 0)\n\tfor _, c := range list {\n\t\tif isAnagram(input, c) {\n\t\t\tret = append(ret, c)\n\t\t}\n\t}\n\treturn ret\n}", "func (ungenerated *Text) generateMarkov() Text {\r\n\tmyMap := map[string][]string{}\r\n\tlines := strings.Split(ungenerated.textdata, \"\\n\")\r\n\tfor _, line := range lines {\r\n\t\twords := strings.Split(line, \" \")\r\n\t\tfor i, word := range words {\r\n\t\t\tif i < (len(words) - 1) {\r\n\t\t\t\tmyMap[word] = append(myMap[word], words[i+1])\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tungenerated.datamap = myMap\r\n\treturn *ungenerated\r\n}", "func hashAnagram2(s string) string {\n\t// count\n\tvar buf [26]int\n\tfor i := 0; i < len(s); i++ {\n\t\tbuf[s[i]-'a']++\n\t}\n\n\t// hash\n\tvar sb strings.Builder\n\tfor i := 0; i < 26; i++ {\n\t\tif buf[i] > 0 {\n\t\t\tsb.WriteByte(byte('a' + i))\n\t\t\tsb.WriteString(strconv.Itoa(buf[i]))\n\t\t}\n\t}\n\treturn sb.String()\n}", "func sherlockAndAnagrams(s string) int32 {\n\trs := []rune(s)\n\tans := make(map[string]int)\n\tsl := len(rs)\n\tret := 0\n\tfor l := 1; l <= sl; l++ {\n\t\tfor i := 0; i+l <= sl; i++ {\n\t\t\tsub := make([]rune, l)\n\t\t\tcopy(sub, rs[i:i+l])\n\t\t\tsort.Slice(sub, func(m, n int) bool {\n\t\t\t\treturn sub[m] < sub[n]\n\t\t\t})\n\t\t\tans[string(sub)]++\n\t\t}\n\t}\n\tfor _, v := range ans {\n\t\tret += v * (v - 1) / 2\n\t}\n\treturn int32(ret)\n}", "func sherlockAndAnagrams(s string) int32 {\n\trunes := []rune(s)\n\tvar c int32 = 0\n\tfor end := 1; end < len(runes); end++ {\n\t\tfor start := 0; start <= len(runes) - end; start++ {\n\t\t\tsubstring := string(runes[start:start+end])\n\t\t\tfor j := start + 1; j < len(runes) - end + 1; j++ {\n\t\t\t\tsubstring2 := string(runes[j:j+end])\n\t\t\t\tif (checkAna(substring, substring2, len(substring))) {\n\t\t\t\t\tc++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn c\n\n}", "func isAnagram(needle, haystack string) bool {\n\t// if they're a different length it is obviously not an angram\n\tif len(needle) != len(haystack) {\n\t\treturn false\n\t}\n\n\tneedle_freq := make(map[string]int)\n\thaystack_freq := make(map[string]int)\n\n\t// at this point the needle and haystack are the same length, so this loop is safe\n\tfor i := 0; i < len(needle); i++ {\n\t\tneedle_freq[needle[i:i+1]] += 1\n\t\thaystack_freq[haystack[i:i+1]] += 1\n\t}\n\n\t// go through needle_freq and compare to haystack_freq\n\tfor str, freq := range needle_freq {\n\t\thay_str_freq, ok := haystack_freq[str]\n\t\t// if it's not in the haystack, can't be an anagram\n\t\t// if the freq of `str` in both aren't identical, not an anagram\n\t\tif !ok || hay_str_freq != freq {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "func isValid2(row string) bool {\n\twords := strings.Split(row, \" \")\n\tfor i := 0; i < len(words); i++ {\n\t\tfor j := i + 1; j < len(words); j++ {\n\t\t\tif IsAnagram(words[i], words[j]) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true\n}", "func isAnagram(s string, t string) bool {\n\tif len(s) != len(t) {\n\t\treturn false\n\t}\n\n\tsm := make(map[rune]int)\n\ttm := make(map[rune]int)\n\n\tfor i := 0; i < len(s); i++ {\n\t\tsw := rune(s[i])\n\t\ttw := rune(t[i])\n\t\tsm[sw]++\n\t\ttm[tw]++\n\t}\n\tfor key, count := range sm {\n\t\tif c := tm[key]; c != count {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "func Detect(subject string, candidates []string) (anagrams []string) {\n\t// Channels on which goroutines communicate information; one for indexes of\n\t// anagrams, one to indicate completion.\n\tic := make(chan int)\n\tfc := make(chan bool)\n\n\t// Map each rune in the subject to the number of occurences in subject.\n\tsm := make(map[rune]int)\n\tfor _, r := range strings.ToLower(subject) {\n\t\tif _, ok := sm[r]; !ok {\n\t\t\tsm[r] = 1\n\t\t} else {\n\t\t\tsm[r]++\n\t\t}\n\t}\n\n\t// Remember the number of candidates.\n\tnumCandidates := len(candidates)\n\n\t// Start goroutines to detect anagrams.\n\tfor i, c := range candidates {\n\t\t// Do not start goroutines for identical or diferent-length candidates.\n\t\tif strings.ToLower(c) == strings.ToLower(subject) || len(c) != len(subject) {\n\t\t\tnumCandidates--\n\t\t\tcontinue\n\t\t}\n\n\t\tgo anagram(sm, strings.ToLower(c), i, ic, fc)\n\t}\n\n\t// If zero goroutines started, detection algorithm is commplete.\n\tif numCandidates == 0 {\n\t\treturn\n\t}\n\n\t// Listen for feedback from goroutines started above.\n\tcount := 0\n\tfor {\n\t\tselect {\n\t\tcase ai := <-ic:\n\t\t\tanagrams = append(anagrams, strings.ToLower(candidates[ai]))\n\t\tcase <-fc:\n\t\t\tcount++\n\t\t\tif count == numCandidates {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}", "func isAlienDictionary(words []string, order string) bool {\n\n\n\t//create a int list to have the ASCII value of the Alien Dictionary\n\tlistAlien := make([]int, 26)\n\tfor i, v := range order {\n\t\tlistAlien[v - 'a'] = i\n\t}\n\n\t//Iterate through the list of words and have two pointers to compare each word\n\tfor i := 0; i < len(words) - 1; i += 1{\n\t\tword1, word2 := words[i], words[i+1]\n\t\t//We need to check till the min len of word, to avoid overflow\n\t\tminLen := minStrLen(word1, word2)\n\t\t//Used to check if array till an index are same\n\t\tvar j int\n\n\t\tfor j = 0; j < minLen; j += 1{\n\n\t\t\t//if each character in the word does not match\n\t\t\tif word1[j] != word2[j]{\n\t\t\t\t//character as per Alien dictionary are not in lexical order\n\t\t\t\tif listAlien[word1[j] - 'a'] > listAlien[word2[j] - 'a']{\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t//If character are same till a length like \"abc\" & \"abcd\"\n\t\tif j == minLen && len(word1) > len(word2){\n\t\t\treturn false\n\t\t}\n\n\t}\n\treturn true\n}", "func isAnagram(s string, t string) bool {\n\tif len(s) != len(t) {\n\t\treturn false\n\t}\n\tstatistics := [26]uint{}\n\tfor i := 0; i < len(s); i++ {\n\t\tstatistics[s[i]-'a'] += 1\n\t\tstatistics[t[i]-'a'] -= 1\n\t}\n\tfor _, count := range statistics {\n\t\tif count != 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func Abbreviate(phrase string) string {\n\tvar buffer bytes.Buffer\n\n\tvar words = strings.FieldsFunc(phrase, func(r rune) bool {\n\t\treturn !unicode.IsLetter(r)\n\t})\n\n\tfor _, word := range words {\n\t\tbuffer.WriteString(string(word[0]))\n\t}\n\n\treturn strings.ToUpper(buffer.String())\n}", "func Detect_if_anagram(str1 string , str2 string) bool {\n\n\tvar length1 = len(str1)\n\tvar length2 = len(str2)\n\n\tif length1 != length2 {\n\t\t\t\treturn false\n\t} else {\n\t\t\t\tstr1 := Sort_String(str1)\n\t\t\t\tstr2 := Sort_String(str2)\n\n\t\t\t\tfmt.Println(\"1. \" , str1)\n\t\t\t\tfmt.Println(\"2. \" , str2)\n\n\t\t\t\tif str1 == str2 {\n\t\t\t\t\treturn true\n\t\t\t\t} else {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t return true\n\t}\n}", "func isAnagram(s string, t string) bool {\n\t// hash\n\tif len(s) != len(t) {\n\t\treturn false\n\t}\n\tmemo := make(map[uint8]int)\n\tfor i := 0; i < len(s); i++ {\n\t\tmemo[s[i]]++\n\t\tmemo[t[i]]--\n\t}\n\tfor _, v := range memo {\n\t\tif v != 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func IsAnagram(a, b string) bool {\n\ta, b = strings.ReplaceAll(a, \" \", \"\"), strings.ReplaceAll(b, \" \", \"\")\n\n\tif len(a) != len(b) {\n\t\treturn false\n\t}\n\n\tx, y := strings.Split(strings.ToLower(a), \"\"), strings.Split(strings.ToLower(b), \"\")\n\tsort.Strings(x)\n\tsort.Strings(y)\n\n\treturn strings.Join(x, \"\") == strings.Join(y, \"\")\n}", "func bigramWordByAppend(str string) []string {\n\tss := strings.Split(str, \" \")\n\n\t// Handle unexpected string input:\n\t// ss = \"\" => []string{\"\"}\n\t// ss = \"foobar\" => []string{\"foobar\"}\n\tif len(ss) <= 1 {\n\t\treturn ss\n\t}\n\n\tvar tmp string\n\tvar bigram []string\n\tfor i, s := range ss {\n\t\tif i != 0 {\n\t\t\tbigram = append(bigram, strings.Join([]string{tmp, s}, \" \"))\n\t\t}\n\t\ttmp = s\n\t}\n\treturn bigram\n}", "func generateAdjectiveNounPair() []string {\n\tvar ret []string\n\treg, err := regexp.Compile(\"[^a-zA-Z]+\")\n\tisError(err)\n\n\tadj := reg.ReplaceAllLiteralString(strings.Title(pickRandomWord(adjectives)), \"\")\n\tnou := reg.ReplaceAllLiteralString(strings.Title(pickRandomWord(nouns)), \"\")\n\tret = append(ret, []string{adj, nou}...)\n\treturn ret\n}", "func readWords(input io.Reader) metaphoneDict {\n\tdict := newMetaphoneDict()\n\trd := bufio.NewReader(input)\n\tfor {\n\t\tif word, err := rd.ReadString('\\n'); err == nil {\n\t\t\tword = strings.TrimSpace(word)\n\t\t\tif !*allowNamesInWordList {\n\t\t\t\trune, _ := utf8.DecodeRuneInString(word)\n\t\t\t\tif unicode.IsUpper(rune) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tif strings.Index(word, \" \") != -1 || len(word) < minWordLength {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tmp := *doubleMetaphone(word)\n\t\t\tdict.Push(mp)\n\t\t\tif mp.metaphone != mp.secondary {\n\t\t\t\t// Secondary phonetic representation\n\t\t\t\tdict.Push(metaphoneWord{word, mp.literal,\n\t\t\t\t\tmp.secondary, mp.metaphone})\n\t\t\t}\n\t\t} else {\n\t\t\tif err != os.EOF {\n\t\t\t\tfmt.Printf(\"Error: %s\\n\", err)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\tsort.Sort(dict)\n\treturn dict\n}", "func isAnagram(s string, t string) bool {\n\tif len(s) != len(t) {\n\t\treturn false\n\t}\n\tvar char26 [26]int\n\tfor i := range s {\n\t\tchar26[s[i]-'a']++\n\t\tchar26[t[i]-'a']--\n\t}\n\tfor i := range char26 {\n\t\tif char26[i] != 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func (nGramMap NGramMap) addDistinctiveNGrams(words []string, n int,\n\tdistinctiveWords map[string]int, threshold int) error {\n\tnGrams, err := createNGrams(words, n)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, gram := range nGrams {\n\t\tif gram.IsDistinctive(distinctiveWords, threshold) {\n\t\t\tnGramMap[gram.Key()]++\n\t\t}\n\t}\n\treturn nil\n}", "func Wordmap(word string) {\n\n\tlistOfLines := reuse.ReadLineByLineFromFile(\"iq/text.dat\")\n\n\t// map of word\n\tmapW := make(map[string][]structLoc)\n\n\tfor i, line := range listOfLines {\n\n\t\tpattern := \"[\\\\/\\\\:\\\\,\\\\.\\\\s]+\"\n\t\tlistOfwords := reuse.Tokenize(line,pattern)\n\n\t\tfor _, word := range listOfwords {\n\t\t\tindices := reuse.GetColPos(line, word)\n\n\t\t\tif mapW[word] == nil {\n\t\t\t\tarrStructLoc := make([]structLoc, 0)\n\t\t\t\tarrStructLoc = addToArrStructLoc(i, indices, arrStructLoc)\n\t\t\t\tmapW[word] = arrStructLoc\n\t\t\t} else {\n\t\t\t\tarrStructLoc := mapW[word]\n\t\t\t\tarrStructLoc = addToArrStructLoc(i, indices, arrStructLoc)\n\t\t\t\tmapW[word] = arrStructLoc\n\t\t\t}\n\t\t}\n\t}\n\tfmt.Println(mapW[word])\n}", "func bigramWordByJoin(str string) []string {\n\tss := strings.Split(str, \" \")\n\n\t// Handle unexpected string input:\n\t// ss = \"\" => []string{\"\"}\n\t// ss = \"foobar\" => []string{\"foobar\"}\n\tif len(ss) <= 1 {\n\t\treturn ss\n\t}\n\n\tbigram := make([]string, len(ss)-1)\n\tfor i := 0; i < len(ss)-1; i++ {\n\t\tbigram[i] = strings.Join([]string{ss[i], ss[i+1]}, \" \")\n\t}\n\treturn bigram\n}", "func main() {\n\ts := \"anagram\"\n\tt := \"nagaram\"\n\n\tfmt.Println(isAnagram(s, t))\n}", "func create_lists(words []string) ([676]wordlists, [676]wordlists) {\n sp := [676]wordlists{}\n ep := [676]wordlists{}\n\n // initialize list with start and end pair of literals\n for i:='a'; i<='z'; i++ {\n for j:='a'; j<='z'; j++ {\n sp[26*(i-'a') + (j-'a')].char = string(i) + string(j)\n ep[26*(i-'a') + (j-'a')].char = string(i) + string(j)\n }\n }\n\n var index uint16\n for i:=0; i<len(words); i++ {\n wlen := len(words[i])\n if wlen >= 2 {\n index = 26*(uint16(words[i][0])-'a') + (uint16(words[i][1])-'a')\n sp[index].word = append(sp[index].word, words[i])\n\n index = 26*(uint16(words[i][wlen-2])-'a') + (uint16(words[i][wlen-1])-'a')\n ep[index].word = append(ep[index].word, words[i])\n }\n }\n\n return sp, ep\n}", "func isAnagram(a, b string) bool {\n\tif len(a) != len(b) {\n\t\treturn false\n\t}\n\n\taMap := make(map[rune]int) // count of each rune in a\n\tfor _, r := range a {\n\t\taMap[r]++\n\t}\n\n\t// Ensure that each rune r in b is also in a and that\n\t// the current count or r in b is < the count in a.\n\tbMap := make(map[rune]int)\n\tfor _, r := range b {\n\t\tbMap[r]++\n\t\tif n, ok := aMap[r]; !ok || n < bMap[r] {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "func Abbreviate(s string) string {\n\tphrase:= strings.Replace(s, \"_\", \" \", -1)\n\tphrase = strings.Replace(phrase, \"-\", \" \", -1)\n\twords := strings.Fields(phrase)\n\n\tabbreviation:=\"\"\n\tfor _, element := range words{\n\t\tabbreviation += strings.ToUpper(string(element[0]))\n\t}\n\treturn abbreviation\n}", "func ladderLength(beginWord string, endWord string, wordList []string) int {\n\tdict := make(map[string]bool) // 把word存入字典\n\tfor _, word := range wordList {\n\t\tdict[word] = true // 可以利用字典快速添加、删除和查找单词\n\t}\n\tif _, ok := dict[endWord]; !ok {\n\t\treturn 0\n\t}\n\t// queue := []string{beginWord} 定义辅助队列\n\tvar queue []string\n\tqueue = append(queue, beginWord)\n\n\tl := len(beginWord)\n\tsteps := 0\n\n\tfor len(queue) > 0 {\n\t\tsteps++\n\t\tsize := len(queue)\n\t\tfor i := size; i > 0; i-- { // 当前层级节点\n\t\t\ts := queue[0] // 原始单词\n\t\t\tqueue = queue[1:]\n\t\t\tchs := []rune(s)\n\t\t\tfor i := 0; i < l; i++ { // 对单词的每一位进行修改\n\t\t\t\tch := chs[i] // 对当前单词的一位\n\t\t\t\tfor c := 'a'; c <= 'z'; c++ { // 尝试从a-z\n\t\t\t\t\tif c == ch { // 跳过本身比如hot修改为hot\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tchs[i] = c\n\t\t\t\t\tt := string(chs)\n\t\t\t\t\tif t == endWord { // 找到结果\n\t\t\t\t\t\treturn steps + 1\n\t\t\t\t\t}\n\t\t\t\t\tif _, ok := dict[t]; !ok { // 不在dict中,跳过\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tdelete(dict, t) // 从字典中删除该单词,因为已经访问过,若重复访问路径一定不是最短的\n\t\t\t\t\tqueue = append(queue, t) // 将新的单词添加到队列\n\t\t\t\t}\n\t\t\t\tchs[i] = ch // 单词的第i位复位,再进行下面的操作\n\t\t\t}\n\t\t}\n\t}\n\treturn 0\n}", "func IsAnagram(s1 string, s2 string) bool {\n\n\tif len(s1) != len(s2) {\n\t\treturn false\n\t}\n\n\tchars1 := strings.Split(s1, \"\")\n\tchars2 := strings.Split(s2, \"\")\n\n\tsort.Strings(chars1)\n\tsort.Strings(chars2)\n\n\tif strings.Join(chars1, \"\") == strings.Join(chars2, \"\") {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (this AnagramsStrings) Less(i, j int) bool {\n\t// If length of the two strings are not equal, then return the result\n\t// based on their lengths.\n\tif len(this[i]) < len(this[j]) {\n\t\treturn true\n\t} else if len(this[i]) > len(this[j]) {\n\t\treturn false\n\t}\n\n\t// Sort the strings and compare each character one by one.\n\tiBytes, jBytes := []byte(this[i]), []byte(this[j])\n\tiInts := make([]int, len(iBytes))\n\tjInts := make([]int, len(jBytes))\n\n\tfor i := 0; i < len(iBytes); i++ {\n\t\tiInts[i] = int(iBytes[i])\n\t\tjInts[i] = int(jBytes[i])\n\t}\n\n\tsort.Ints(iInts)\n\tsort.Ints(jInts)\n\n\tfor i := 0; i < len(iInts); i++ {\n\t\tif iInts[i] < jInts[i] {\n\t\t\treturn true\n\t\t} else if iInts[i] > jInts[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn false\n}", "func Abbreviate(s string) string {\n\t// re := regexp.MustCompile(\"[ \\\\-_]+\")\n\t// words := re.Split(s, -1)\n\ts = strings.ReplaceAll(s, \"-\", \" \")\n\ts = strings.ReplaceAll(s, \"_\", \"\")\n\twords := strings.Fields(s)\n\n\tvar ret = []string{}\n\tfor i := range words {\n\t\tret = append(ret, strings.ToUpper(string(words[i][0])))\n\t}\n\treturn strings.Join(ret, \"\")\n}", "func wordWalker(str string, f func(*wordInfo)) {\n\trunes := []rune(str)\n\tw, i := 0, 0 // index of start of word, scan\n\thasCommonInitial := false\n\tfor i+1 <= len(runes) {\n\t\teow := false // whether we hit the end of a word\n\t\tswitch {\n\t\tcase i+1 == len(runes):\n\t\t\teow = true\n\t\tcase isDelimiter(runes[i+1]):\n\t\t\t// underscore; shift the remainder forward over any run of underscores\n\t\t\teow = true\n\t\t\tn := 1\n\t\t\tfor i+n+1 < len(runes) && isDelimiter(runes[i+n+1]) {\n\t\t\t\tn++\n\t\t\t}\n\n\t\t\t// Leave at most one underscore if the underscore is between two digits\n\t\t\tif i+n+1 < len(runes) && unicode.IsDigit(runes[i]) && unicode.IsDigit(runes[i+n+1]) {\n\t\t\t\tn--\n\t\t\t}\n\n\t\t\tcopy(runes[i+1:], runes[i+n+1:])\n\t\t\trunes = runes[:len(runes)-n]\n\t\tcase unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]):\n\t\t\t// lower->non-lower\n\t\t\teow = true\n\t\t}\n\t\ti++\n\n\t\t// [w,i) is a word.\n\t\tword := string(runes[w:i])\n\t\tif !eow && commonInitialisms[word] && !unicode.IsLower(runes[i]) {\n\t\t\t// through\n\t\t\t// split IDFoo → ID, Foo\n\t\t\t// but URLs → URLs\n\t\t} else if !eow {\n\t\t\tif commonInitialisms[word] {\n\t\t\t\thasCommonInitial = true\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tmatchCommonInitial := false\n\t\tif commonInitialisms[strings.ToUpper(word)] {\n\t\t\thasCommonInitial = true\n\t\t\tmatchCommonInitial = true\n\t\t}\n\n\t\tf(&wordInfo{\n\t\t\tWord: word,\n\t\t\tMatchCommonInitial: matchCommonInitial,\n\t\t\tHasCommonInitial: hasCommonInitial,\n\t\t})\n\t\thasCommonInitial = false\n\t\tw = i\n\t}\n}", "func RecommendSimilarWords(key string) {\n\tleft := -1\n\tright := len(dictArray)\n\tvar mid int\n\tfor math.Abs(float64(right-left)) > 1 {\n\t\tmid = (left + right) / 2\n\t\tif checkKey(mid, key) {\n\t\t\tright = mid\n\t\t} else {\n\t\t\tleft = mid\n\t\t}\n\t}\n\n\t// 前後のワードを5個ずつとってくる\n\t// ~10個までになるように候補のワードを絞る\n\tvar candidateWords []string\n\tstart := int(math.Max(float64(mid-5), 0))\n\tend := int(math.Min(float64(mid+5), float64(len(dictArray))))\n\tfor i := start; i < mid; i++ {\n\t\tif dictArray[i][0] != key[0] {\n\t\t\tcontinue\n\t\t}\n\t\tcandidateWords = append(candidateWords, dictArray[i])\n\t}\n\n\tfor i := mid; i < end; i++ {\n\t\tif dictArray[i][0] != key[0] {\n\t\t\tcontinue\n\t\t}\n\t\tcandidateWords = append(candidateWords, dictArray[i])\n\t}\n\tprintCandidateWords(key, candidateWords)\n\n}", "func wordWalker(str string, f func(*wordInfo)) {\n\trunes := []rune(strings.TrimFunc(str, isDelimiter))\n\tw, i := 0, 0 // index of start of word, scan\n\thasCommonInitial := false\n\tfor i+1 <= len(runes) {\n\t\teow := false // whether we hit the end of a word\n\t\tswitch {\n\t\tcase i+1 == len(runes):\n\t\t\teow = true\n\t\tcase isDelimiter(runes[i+1]):\n\t\t\t// underscore; shift the remainder forward over any run of underscores\n\t\t\teow = true\n\t\t\tn := 1\n\t\t\tfor i+n+1 < len(runes) && isDelimiter(runes[i+n+1]) {\n\t\t\t\tn++\n\t\t\t}\n\n\t\t\t// Leave at most one underscore if the underscore is between two digits\n\t\t\tif i+n+1 < len(runes) && unicode.IsDigit(runes[i]) && unicode.IsDigit(runes[i+n+1]) {\n\t\t\t\tn--\n\t\t\t}\n\n\t\t\tcopy(runes[i+1:], runes[i+n+1:])\n\t\t\trunes = runes[:len(runes)-n]\n\t\tcase unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]):\n\t\t\t// lower->non-lower\n\t\t\teow = true\n\t\t}\n\t\ti++\n\n\t\t// [w,i) is a word.\n\t\tword := string(runes[w:i])\n\t\tif !eow && commonInitialisms[word] && !unicode.IsLower(runes[i]) {\n\t\t\t// through\n\t\t\t// split IDFoo → ID, Foo\n\t\t\t// but URLs → URLs\n\t\t} else if !eow {\n\t\t\tif commonInitialisms[word] {\n\t\t\t\thasCommonInitial = true\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tmatchCommonInitial := false\n\t\tif commonInitialisms[strings.ToUpper(word)] {\n\t\t\thasCommonInitial = true\n\t\t\tmatchCommonInitial = true\n\t\t}\n\n\t\tf(&wordInfo{\n\t\t\tWord: word,\n\t\t\tMatchCommonInitial: matchCommonInitial,\n\t\t\tHasCommonInitial: hasCommonInitial,\n\t\t})\n\t\thasCommonInitial = false\n\t\tw = i\n\t}\n}", "func readwords() {\n\tvar nwords, nletters float64\n\tfor _, w := range wordlist {\n\t\tnwords += w.num\n\t\tnletters += float64(len(w.word)) * w.num\n\t}\n\t// The zhuyin alphabet, one-indexed so that the zero value can denote blanks in incomplete triads.\n\talphabet := []rune(\"\\000ㄅㄆㄇㄈㄉㄊㄋㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙㄧㄨㄩㄚㄛㄜㄝㄞㄟㄠㄡㄢㄣㄤㄥㄦ˙¯ˊˇˋ\")\n\tcode := make(map[rune]letter)\n\tfor i, l := range alphabet {\n\t\tcode[l] = letter(i)\n\t}\n\tfor _, w := range wordlist {\n\t\tc := []letter{0, 0}\n\t\tfor _, l := range w.word {\n\t\t\tfreq[code[l]] += w.num / nletters\n\t\t\tif code[l] != blanktone {\n\t\t\t\tc = append(c, code[l])\n\t\t\t}\n\t\t}\n\t\tc = append(c, 0, 0)\n\t\tfor i := 0; i < len(c)-2; i++ {\n\t\t\tt[c[i]][c[i+1]][c[i+2]] += w.num\n\t\t}\n\t}\n\tfor i := 1; i <= 42; i++ {\n\t\tfor j := 1; j <= 42; j++ {\n\t\t\tfor k := 1; k <= 42; k++ {\n\t\t\t\tt[i][j][k] = (t[i][j][k] + t[i][j][0]*t[0][0][k]/nwords + t[i][0][0]*t[0][j][k]/nwords + t[i][0][0]*t[0][j][0]*t[0][0][k]/(nwords*nwords)) / nletters\n\t\t\t\tletterpair[i][j] += t[i][j][k]\n\t\t\t\tletterpair[j][k] += t[i][j][k]\n\t\t\t}\n\t\t}\n\t}\n}", "func Abbreviate(s string) string {\n\tupperPhrase := strings.ToUpper(s)\n\n\tacronym := \"\"\n\n\tfor _, word := range phraseBreaker(upperPhrase) {\n\t\tacronym += firstLetter(word)\n\n\t}\n\n\treturn acronym\n}", "func Abbreviate(s string) string {\n\tvar words []string\n\tvar result strings.Builder\n\n\tf := func(r rune) bool {\n\t\treturn unicode.IsSpace(r) || r == '-'\n\t}\n\n\twords = strings.FieldsFunc(s, f)\n\tfor _, w := range words {\n\t\tfor _, l := range w {\n\t\t\tif !unicode.IsLetter(l) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tresult.WriteString(strings.ToUpper(string(l)))\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn result.String()\n}", "func freqAnalyze(text string) freqDistr {\n\twords := map[string]int{}\n\n\tspaceReplace := func(r rune) rune {\n\t\tswitch r {\n\n\t\tcase '.', ',', '!', '?', ':', ';', '-', '—', '\\r', '\\n', '\\t':\n\t\t\treturn ' '\n\t\t}\n\t\treturn unicode.ToLower(r)\n\t}\n\n\tsplits := strings.Split(strings.Map(spaceReplace, text), \" \")\n\n\tfor _, s := range splits {\n\t\tif s != \"\" {\n\t\t\twords[s]++\n\t\t}\n\t}\n\treturn words\n}", "func Generate(ddb *dynamodb.DynamoDB, verbose bool) error {\n\twords, err := giraffe.GetEnWords()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"getting wordlist\")\n\t}\n\tfor g := range giraffe.Giraffes(words) {\n\t\tfor idx := 0; idx < 10; idx++ {\n\t\t\tfor _, pattern := range patterns {\n\t\t\t\tif pattern == \"\" {\n\t\t\t\t\tpattern = \"/\"\n\t\t\t\t}\n\t\t\t\tvar key = g.Key\n\t\t\t\tvar err error\n\t\t\t\tif pattern != \"/\" {\n\t\t\t\t\tpattern = fmt.Sprintf(pattern, idx)\n\t\t\t\t\tkey, err = key.DeriveFrom(\"/\", pattern)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn errors.Wrap(err, \"deriving key\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\taddr, err := address.Generate(address.KindUser, key.PubKeyBytes())\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrap(err, \"generating address\")\n\t\t\t\t}\n\t\t\t\terr = Add(\n\t\t\t\t\tddb,\n\t\t\t\t\tBadAddress{\n\t\t\t\t\t\tAddress: addr,\n\t\t\t\t\t\tPath: pattern,\n\t\t\t\t\t\tReason: fmt.Sprintf(\n\t\t\t\t\t\t\t\"derives from 12-word phrase with identical words: %s\",\n\t\t\t\t\t\t\tg.Word,\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t\tfalse,\n\t\t\t\t)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrap(err, \"sending to DDB\")\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func bigramWordByConcat(str string) []string {\n\tss := strings.Split(str, \" \")\n\n\t// Handle unexpected string input:\n\t// ss = \"\" => []string{\"\"}\n\t// ss = \"foobar\" => []string{\"foobar\"}\n\tif len(ss) <= 1 {\n\t\treturn ss\n\t}\n\n\tbigram := make([]string, len(ss)-1)\n\tfor i := 0; i < len(ss)-1; i++ {\n\t\tbigram[i] = ss[i] + \" \" + ss[i+1]\n\t}\n\treturn bigram\n}", "func Abbreviate(s string) string {\n\tvar acronym strings.Builder\n\tstartOfWord := false\n\tfor index, letter := range s {\n\t\tif index == 0 {\n\t\t\tacronym.WriteRune(letter)\n\t\t} else if startOfWord && ((letter >= 'A' && letter <= 'Z') || (letter >= 'a' && letter <= 'z')) {\n\t\t\tstartOfWord = false\n\t\t\tif letter >= 'a' && letter <= 'z' {\n\t\t\t\tacronym.WriteRune(letter - 'a' + 'A')\n\t\t\t} else {\n\t\t\t\tacronym.WriteRune(letter)\n\t\t\t}\n\t\t} else if !startOfWord && !((letter >= 'A' && letter <= 'Z') || (letter >= 'a' && letter <= 'z')) && letter != '\\'' {\n\t\t\tstartOfWord = true\n\t\t}\n\t}\n\treturn acronym.String()\n}", "func TestAllWordsUnique(t *testing.T) {\n\tinputString := \"Do you know what this word means?\"\n\tfa := NewFrequencyAnalyzer(inputString)\n\n\tactualWords := fa.Search()\n\texpectedWords := []string{\"do\", \"you\", \"know\", \"what\", \"this\", \"word\", \"means\"}\n\tassert.Equal(t, expectedWords, actualWords)\n}", "func main() {\n\targs := os.Args\n\tapp := args[0]\n\tsc := bufio.NewScanner(os.Stdin)\n\tminWordLength := flag.Int(\"min-length\", 1, \"minimum length of words to keep (default is 1)\")\n\tshowLineNumber := flag.Bool(\"show-line-number\", false, \"allow display of prefix with line number\")\n\tconvertToCase := flag.String(\"convert-to-case\", \"\", \"convert case of all words. Can be one of (U,u,upper or L,l,lower)\")\n\tflag.Parse()\n\tcount := 1\n\n\tfor sc.Scan() {\n\t\tif len(strings.TrimSpace(sc.Text())) > 0 {\n\t\t\t// should match any utf8 letter including any diacritics\n\t\t\t// this regex will always match a rune like : à, regardless of how it is encoded !\n\t\t\t// https://www.regular-expressions.info/unicode.html\n\t\t\treWords := regexp.MustCompile(\"(\\\\p{L}\\\\p{M}*)+\")\n\t\t\twords := reWords.FindAllString(sc.Text(), -1)\n\t\t\tonlyBiggerWords := []string{}\n\t\t\tfor _, word := range words {\n\t\t\t\tif utf8.RuneCountInString(strings.TrimSpace(word)) >= *minWordLength {\n\t\t\t\t\tswitch *convertToCase {\n\t\t\t\t\tcase \"upper\", \"u\", \"U\":\n\t\t\t\t\t\tonlyBiggerWords = append(onlyBiggerWords, strings.ToUpper(word))\n\t\t\t\t\tcase \"lower\", \"l\", \"L\":\n\t\t\t\t\t\tonlyBiggerWords = append(onlyBiggerWords, strings.ToLower(word))\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tonlyBiggerWords = append(onlyBiggerWords, word)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif len(onlyBiggerWords) > 0 {\n\t\t\t\tif *showLineNumber {\n\t\t\t\t\twList := strings.Join(onlyBiggerWords, \" \")\n\t\t\t\t\tfmt.Printf(\"%d : %s \\n\", count, wList)\n\t\t\t\t} else {\n\t\t\t\t\twList := strings.Join(onlyBiggerWords, \"\\n\")\n\t\t\t\t\tfmt.Printf(\"%s\\n\", wList)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcount += 1\n\t\t\t//fmt.Println(wList)\n\t\t} else {\n\t\t\tif count < 2 {\n\t\t\t\t//TODO find a solution to display help when no data is present without polutin output if first line is empty\n\t\t\t\tgolog.Warn(\"# %s should be used in a pipe like this : cat your_utf8_text.txt | getwords --min-length=2 --show-line-number=0\", app)\n\t\t\t}\n\t\t}\n\t}\n\tif err := sc.Err(); err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"error:\", err)\n\t\tos.Exit(1)\n\t}\n}", "func Abbreviate(s string) string {\n\tfinalAcronym := make([]string, 4)\n\tisAlpha := regexp.MustCompile(`^[A-Za-z]+`).MatchString\n\n\tfor _, word := range strings.FieldsFunc(s, SplitHelper) {\n\t\tfirstLetter := string(word[0])\n\n\t\tfor i := 1; len(word)-1 > i && !isAlpha(firstLetter); i++ {\n\t\t\tfirstLetter = string(word[i])\n\t\t}\n\n\t\tfinalAcronym = append(finalAcronym, strings.ToUpper(firstLetter))\n\t}\n\treturn strings.Join(finalAcronym, \"\")\n}", "func createNGrams(words []string, n int) ([]NGram, error) {\n\tif n < 0 {\n\t\treturn nil, errors.New(\"n of n-gram needs to be > 0\")\n\t}\n\t// n reduces total number of n-grams but even if n equals the number of\n\t// words, one n-gram is created.\n\tnumberOfNGrams := len(words) - (n - 1)\n\tnGramList := make([]NGram, numberOfNGrams)\n\tfor i := 0; i < numberOfNGrams; i++ {\n\t\tnGram := make(NGram, n)\n\t\tfor j := 0; j < n; j++ {\n\t\t\tnGram[j] = words[i+j]\n\t\t}\n\t\tnGramList[i] = nGram\n\t}\n\treturn nGramList, nil\n}", "func IsAnagram(a, b string) bool {\n\tba := ByteSlice(a)\n\tbb := ByteSlice(b)\n\tsort.Sort(ba)\n\tsort.Sort(bb)\n\tif bytes.Equal(ba, bb) {\n\t\treturn true\n\t} else {\n\t\treturn false\n\t}\n}", "func (h Headlines) AverageWords() int {\n\tif len(h) == 0 {\n\t\treturn 0\n\t}\n\n\tlength := 0\n\tfor _, str := range h {\n\t\tlength += WordCount(str)\n\t}\n\n\treturn int(Round(float64(length)/float64(len(h)), 1, 0))\n}", "func palindromePairs(words []string) [][]int {\n var ret [][]int\n root := &TrieNode{idx:-1, match:make(map[int]bool)}\n for i, word := range words { addWord(root, word, i) }\n for i, word := range words { \n matchSet := searchWord(root, word)\n for idx, _ := range matchSet {\n if idx != i { ret = append(ret, []int{idx, i}) }\n }\n }\n return ret\n}", "func NewDictionary(strs ...string) *DFA {\n\tb := NewBuilder()\n\tsort.Strings(strs)\n\tfor _, str := range strs {\n\t\tif err := b.Add(str, 1); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\treturn b.Build()\n}", "func Biunigrams(s string) []string {\n\ttokens := make([]string, 0, 32)\n\n\tfor bigram := range toBigrams(s) {\n\t\ttokens = append(tokens, fmt.Sprintf(\"%c%c\", bigram.a, bigram.b))\n\t}\n\tfor unigram := range toUnigrams(s) {\n\t\ttokens = append(tokens, fmt.Sprintf(\"%c\", unigram))\n\t}\n\n\treturn tokens\n}", "func Biunigrams(s string) []string {\n\ttokens := make([]string, 0, 32)\n\n\tfor bigram := range toBigrams(s) {\n\t\ttokens = append(tokens, fmt.Sprintf(\"%c%c\", bigram.a, bigram.b))\n\t}\n\tfor unigram := range toUnigrams(s) {\n\t\ttokens = append(tokens, fmt.Sprintf(\"%c\", unigram))\n\t}\n\n\treturn tokens\n}", "func IsIsogram(input string) bool {\n\ninput = strings.ToLower(input)\n\nindex := make(map[string]bool)\n\nfor i:= 0 ; i < len(input) ; i++ {\n //skip any non alphabets\n if !strings.ContainsAny(string(input[i]),\"abcdefghijklmnopqrstuvwxyz\") {\n continue;\n }\n _,letterFound:=index[string(input[i])]\n if letterFound {\n return false\n } else {\n index[string(input[i])] = true\n }\n}\n return true\n}", "func main() {\n\treader := bufio.NewReader(os.Stdin)\n\tfmt.Print(\"Enter encoded text: \")\n\t// Read the encoded string and convert it to upper case\n\tenc, _ := reader.ReadString('\\n')\n\tenc = strings.ToUpper(enc)\n\n\t// Get the list of possible solutions\n\tsolutions := caesar.Decode(enc)\n\n\t// Now we want to count the english words in\n\t// every sentence, so we can guess the correct one\n\tsolutionsCount := make(map[string]int)\n\tfor _, solution := range solutions {\n\t\tsolutionsCount[solution] = 0\n\t\twords := strings.Split(solution, string(32))\n\t\tfor _, word := range words {\n\t\t\tval, err := checkWord(word)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif val == true {\n\t\t\t\tsolutionsCount[solution]++\n\t\t\t}\n\t\t}\n\n\t}\n\tfor k, v := range solutionsCount {\n\t\tif v == 0 {\n\t\t\tdelete(solutionsCount, k)\n\t\t}\n\t}\n\n\ts := sortedKeys(solutionsCount)\n\tif len(s) == 0 {\n\t\tfmt.Println(\"Could not find any solution to this encryption\")\n\n\t\treturn\n\t}\n\n\tfmt.Printf(\"The solution is likely to be: \\n\\n %s \\n\\n\", s[0])\n\tif len(s) > 1 {\n\t\tfmt.Printf(\"but it could also be one of the following: \\n\\n\")\n\t\tfor i := 1; i < len(s); i++ {\n\t\t\tfmt.Printf(\"%s \\n\", s[i])\n\t\t}\n\t}\n}", "func ListDiagrams(dir string) ([]string, error) {\n\tvar diagrams []string\n\n\tcwd, err := filepath.Abs(filepath.Dir(\"\"))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tpath := cwd + dir\n\tfiles, err := ioutil.ReadDir(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, file := range files {\n\t\tdiagrams = append(diagrams, file.Name())\n\t}\n\n\treturn diagrams, nil\n}", "func isAnagram(given, toCheck string) bool {\n\tgiven, toCheck = strings.ToLower(given), strings.ToLower(toCheck)\n\tif given == toCheck {\n\t\treturn false\n\t}\n\tif len(given) != len(toCheck) {\n\t\treturn false\n\t}\n\tprod1, prod2 := 1, 1\n\tfor i, c := range given {\n\t\tprod1 *= letters[c]\n\t\tprod2 *= letters[rune(toCheck[i])]\n\t}\n\n\tif prod1 != prod2 {\n\t\treturn false\n\t}\n\treturn true\n}", "func isAnagram(s string, t string) bool {\n\tsLength := len(s)\n\tif sLength != len(t) {\n\t\treturn false\n\t}\n\tif sLength == 0 {\n\t\treturn true\n\t}\n\tvar sNumber, tNumber rune\n\tvar xor rune\n\tfor _, c := range s {\n\t\tsNumber = sNumber + c*c\n\t\txor = xor ^ c\n\t}\n\n\tfor _, c := range t {\n\t\ttNumber = tNumber + c*c\n\t\txor = xor ^ c\n\t}\n\treturn tNumber == sNumber && xor == 0\n}", "func wordPattern(ptns string, str string) bool {\r\n ptn2wrd := make(map[byte]string)\r\n wrd2ptn := make(map[string]byte)\r\n \r\n words := strings.Split(str, \" \")\r\n if len(ptns) != len(words) {\r\n return false\r\n }\r\n for i := 0; i < len(ptns); i++ {\r\n u, v := ptns[i], words[i]\r\n \r\n if wrd, ok := ptn2wrd[u]; ok {\r\n if wrd != v || wrd2ptn[wrd] != u {\r\n return false\r\n }\r\n } else if ptn, ok := wrd2ptn[v]; ok {\r\n if ptn != u || ptn2wrd[ptn] != v {\r\n return false\r\n }\r\n } else {\r\n ptn2wrd[u] = v\r\n wrd2ptn[v] = u \r\n }\r\n }\r\n return true\r\n}", "func Anime(originalTerm string, maxLength int) []*arn.Anime {\n\tterm := strings.ToLower(stringutils.RemoveSpecialCharacters(originalTerm))\n\tresults := make([]*Result, 0, maxLength)\n\n\tcheck := func(text string) float64 {\n\t\tif text == \"\" {\n\t\t\treturn 0\n\t\t}\n\n\t\treturn stringutils.AdvancedStringSimilarity(term, strings.ToLower(stringutils.RemoveSpecialCharacters(text)))\n\t}\n\n\tadd := func(anime *arn.Anime, similarity float64) {\n\t\tsimilarity += float64(anime.Popularity.Total()) * popularityDamping\n\n\t\tif anime.Type != \"tv\" && anime.Type != \"movie\" {\n\t\t\tsimilarity -= 0.3\n\t\t}\n\n\t\tresults = append(results, &Result{\n\t\t\tobj: anime,\n\t\t\tsimilarity: similarity,\n\t\t})\n\t}\n\n\tfor anime := range arn.StreamAnime() {\n\t\tif anime.IsDraft {\n\t\t\tcontinue\n\t\t}\n\n\t\tif anime.ID == originalTerm {\n\t\t\treturn []*arn.Anime{anime}\n\t\t}\n\n\t\t// Canonical title\n\t\tsimilarity := check(anime.Title.Canonical)\n\n\t\tif similarity >= MinStringSimilarity {\n\t\t\tadd(anime, similarity)\n\t\t\tcontinue\n\t\t}\n\n\t\t// English\n\t\tsimilarity = check(anime.Title.English)\n\n\t\tif similarity >= MinStringSimilarity {\n\t\t\tadd(anime, similarity)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Romaji\n\t\tsimilarity = check(anime.Title.Romaji)\n\n\t\tif similarity >= MinStringSimilarity {\n\t\t\tadd(anime, similarity)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Synonyms\n\t\tfor _, synonym := range anime.Title.Synonyms {\n\t\t\tsimilarity := check(synonym)\n\n\t\t\tif similarity >= MinStringSimilarity {\n\t\t\t\tadd(anime, similarity)\n\t\t\t\tgoto nextAnime\n\t\t\t}\n\t\t}\n\n\t\t// Japanese\n\t\tsimilarity = check(anime.Title.Japanese)\n\n\t\tif similarity >= MinStringSimilarity {\n\t\t\tadd(anime, similarity)\n\t\t\tcontinue\n\t\t}\n\n\tnextAnime:\n\t}\n\n\t// Sort\n\tsort.Slice(results, func(i, j int) bool {\n\t\treturn results[i].similarity > results[j].similarity\n\t})\n\n\t// Limit\n\tif len(results) >= maxLength {\n\t\tresults = results[:maxLength]\n\t}\n\n\t// Final list\n\tfinal := make([]*arn.Anime, len(results))\n\n\tfor i, result := range results {\n\t\tfinal[i] = result.obj.(*arn.Anime)\n\t}\n\n\treturn final\n}", "func StringNGrams(scope *Scope, data tf.Output, data_splits tf.Output, separator string, ngram_widths []int64, left_pad string, right_pad string, pad_width int64, preserve_short_sequences bool) (ngrams tf.Output, ngrams_splits tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\tattrs := map[string]interface{}{\"separator\": separator, \"ngram_widths\": ngram_widths, \"left_pad\": left_pad, \"right_pad\": right_pad, \"pad_width\": pad_width, \"preserve_short_sequences\": preserve_short_sequences}\n\topspec := tf.OpSpec{\n\t\tType: \"StringNGrams\",\n\t\tInput: []tf.Input{\n\t\t\tdata, data_splits,\n\t\t},\n\t\tAttrs: attrs,\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0), op.Output(1)\n}", "func Analyze(paragraph string) []Sentence {\n\tvar result = make([]Sentence, 0, len(paragraph)/50)\n\n\tfor segment := range Segment(paragraph) {\n\t\tresult = append(result, segment)\n\t}\n\n\treturn result\n}", "func Abbreviate(str string) string {\n\tstr = strings.Replace(str, \"-\", \" \", -1)\n\twords := strings.Fields(str)\n\tresult := \"\"\n\tfor _, word := range words {\n\t\tresult += string([]byte{word[0]})\n\t}\n\n\treturn strings.ToUpper(result)\n}" ]
[ "0.68058455", "0.6737168", "0.6650204", "0.6594094", "0.6563233", "0.65479094", "0.64732206", "0.63604116", "0.6302019", "0.62427104", "0.6218595", "0.62174195", "0.61713296", "0.6131854", "0.610174", "0.60827327", "0.59945303", "0.5972863", "0.59696966", "0.5967249", "0.59406555", "0.5924145", "0.5838357", "0.5765662", "0.57173556", "0.56684375", "0.5612463", "0.552017", "0.551933", "0.55005556", "0.5484518", "0.54531395", "0.5415263", "0.5390453", "0.5333279", "0.52702165", "0.5229373", "0.5210411", "0.51154935", "0.5115123", "0.5101794", "0.5097666", "0.5008164", "0.5008064", "0.49930522", "0.49895218", "0.49578604", "0.4951184", "0.4946316", "0.4905726", "0.48844847", "0.4858204", "0.4853614", "0.4847406", "0.48085514", "0.48066595", "0.48046303", "0.48041704", "0.47989187", "0.47588575", "0.4758218", "0.4754865", "0.4747906", "0.47010076", "0.469485", "0.46863067", "0.4682287", "0.46703172", "0.46678364", "0.4660959", "0.46601304", "0.4648277", "0.46352825", "0.46244365", "0.4618412", "0.46120486", "0.45939943", "0.45720854", "0.45709965", "0.45622417", "0.4561944", "0.4538783", "0.4522622", "0.45013735", "0.44963223", "0.44951642", "0.44865912", "0.44838306", "0.4478152", "0.4478152", "0.44774675", "0.4468109", "0.44619504", "0.44521824", "0.44465458", "0.4438777", "0.4428821", "0.4428508", "0.44276157", "0.44243833" ]
0.8158142
0
Int promises that the zero value is a 0, but in gmp the zero value is a crash. To bridge the gap, the init bool says whether this is a valid gmp value. doinit initializes f.i if it needs it. This is not inherent to FFI, just a mismatch between Go's convention of making zero values useful and gmp's decision not to.
Int гарантирует, что нулевое значение является 0, но в gmp нулевое значение приводит к сбою. Чтобы устранить разрыв, флаг init bool указывает, является ли это допустимым значением gmp. doinit инициализирует f.i, если это необходимо. Это не является врожденной особенностью FFI, просто несоответствие между обычаем Go делать нулевые значения полезными и решением gmp не использовать их.
func (f *Float) doinit() { if f.init { return } if f.prec != 0 { C.mpf_init2(&f.i[0], C.mp_bitcnt_t(f.prec)) } else { C.mpf_init(&f.i[0]) } f.init = true }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func gmpInit(ctx phpv.Context, args []*phpv.ZVal) (*phpv.ZVal, error) {\n\tvar num *phpv.ZVal\n\tvar base *phpv.ZInt\n\n\t_, err := core.Expand(ctx, args, &num, &base)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar i *big.Int\n\n\tswitch num.GetType() {\n\tcase phpv.ZtNull, phpv.ZtBool, phpv.ZtInt, phpv.ZtFloat:\n\t\tnum, err = num.As(ctx, phpv.ZtInt)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ti = big.NewInt(int64(num.Value().(phpv.ZInt)))\n\tdefault:\n\t\tnum, err = num.As(ctx, phpv.ZtString)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ti = &big.Int{}\n\t\tif base == nil {\n\t\t\t_, ok := i.SetString(string(num.AsString(ctx)), 0)\n\t\t\tif !ok {\n\t\t\t\treturn nil, errors.New(\"failed to parse integer\")\n\t\t\t}\n\t\t} else {\n\t\t\t_, ok := i.SetString(string(num.AsString(ctx)), int(*base))\n\t\t\tif !ok {\n\t\t\t\treturn nil, errors.New(\"failed to parse integer\")\n\t\t\t}\n\t\t}\n\t}\n\n\treturn returnInt(ctx, i)\n}", "func (c *Int32) Init(valid time.Duration) {\n\tc.updated = atomic_clock.New()\n\tc.valid = valid\n}", "func init() {\n\tvar i int\n\tsizeOfInt = unsafe.Sizeof(i)\n}", "func (i *Int64) Initialize(val int64) {\n\t*i.get() = val\n}", "func TestNilInt(t *testing.T) {\n\ty := GetIntFlag(\"example\").Value()\n\tassert.Nil(t, y)\n}", "func Init(flags ...InitFlag) InitFlag {\n\tvar f InitFlag\n\tfor i := range flags {\n\t\tf |= flags[i]\n\t}\n\treturn InitFlag(C.IMG_Init(C.int(f)))\n}", "func (s *syncMapInt64) init() {\n\ts.m = make(map[int]int64)\n}", "func (n Noop) Init(_ int) error {\n\treturn nil\n}", "func hasInit(b *testing.B) {\n\tif hasIntSet64Data == nil {\n\t\thasIntSet64Data, hasIntSet32Data, hasIntMapData = generateSets(*max_range, *count)\n\t\tb.ResetTimer()\n\t}\n}", "func (f *Foo) init() {\n\t*f = 1337\n}", "func (n null) Int() int64 {\n\tpanic(ErrInvalidConvNilToInt)\n}", "func init() {\n\tif unsafe.Sizeof(false) != 1 {\n\t\tpanic(\"nsd20463/atomicbool assumes bools fit in 1 byte\")\n\t}\n}", "func (v asmInt) FitsIn(bytes uint) bool {\r\n\t// In fact, 64-bit declarations in JWasm don't limit the value at all.\r\n\tif bytes >= 8 {\r\n\t\treturn true\r\n\t}\r\n\treturn v.n >= -int64(1<<(bytes*8)) &&\r\n\t\tv.n <= int64((1<<(bytes*8)-1))\r\n}", "func Init[T any, I initialiser[T]](ptr *T, init I) T {\n\tif ptr == nil {\n\t\tpanic(fmt.Sprintf(\"nil pointer exception with pointers.Init for %T\", *new(T)))\n\t}\n\tif val, ok := initAtomic[T, I](ptr, init); ok {\n\t\treturn val\n\t}\n\tif val, ok := initFastPath[T](ptr); ok {\n\t\treturn val\n\t}\n\tvar key = pointersync.Key(ptr)\n\tdefer initLocks.Sync(key)()\n\tif ptr != nil && !isZero(*ptr) {\n\t\treturn *ptr\n\t}\n\t*ptr = initialise[T, I](init)\n\treturn *ptr\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func zeroval(ival int) {\n\tival = 0\n}", "func (this *MachO_MachoFlags) LazyInit() (v bool, err error) {\n\tif (this._f_lazyInit) {\n\t\treturn this.lazyInit, nil\n\t}\n\tthis.lazyInit = bool((this.Value & 64) != 0)\n\tthis._f_lazyInit = true\n\treturn this.lazyInit, nil\n}", "func EmptyInit(value bool) EmptyAttr {\n\treturn func(m optionalAttr) {\n\t\tm[\"init\"] = value\n\t}\n}", "func isZeroInt(n *int) bool {\n\treturn n != nil && *n == 0\n}", "func InitMpz(mpz *MpzT) {\n\tC.init_mpzp(C.uintptr_t(uintptr(unsafe.Pointer(mpz))))\n}", "func (t systemIntType) Zero() interface{} {\n\treturn int64(0)\n}", "func (t systemIntType) Zero() interface{} {\n\treturn int64(0)\n}", "func addInit(b *testing.B) {\n\tif addIntSet64Data == nil {\n\t\taddIntSet64Data, addIntSet32Data, addIntMapData = generateSets(*max_range, *count)\n\t\taddValue = getValue(addIntSet64Data, *max_range)\n\t\tb.ResetTimer()\n\t}\n}", "func IFBInit() error {\n\treturn execModProbe(ifbModuleName, \"numifbs=0\")\n}", "func imgInit() int {\n\tlog.Printf(\"imgInit()\")\n\tvar f = mod.NewProc(\"img_init\")\n\tret, _, _ := f.Call()\n\treturn int(ret)\n}", "func ZeroInt(v interface{}) int {\n\ti, err := Int64(v)\n\tif err != nil {\n\t\treturn 0\n\t}\n\treturn int(i)\n}", "func (fdl *FDLimiter) Init(fdlim int) {\n\tfdl.lk.Lock()\n\tif fdlim <= 0 {\n\t\tpanic(\"FDLimiter, bad limit\")\n\t}\n\tfdl.limit = fdlim\n\tfdl.count = 0\n\tfdl.ch = make(chan int)\n\tfdl.lk.Unlock()\n}", "func Init() error {\n\treturn Error(C.hackrf_init())\n}", "func (ms Int64DataPoint) InitEmpty() {\n\t*ms.orig = &otlpmetrics.Int64DataPoint{}\n}", "func (i NullInt) IsZero() bool {\n\treturn !i.Valid\n}", "func Init() PTR {\n\treturn PTR(C.init())\n}", "func (this *unsignedFixed) zero() bool {\n\tm := this.mantissa\n\tresult := m == 0\n\treturn result\n}", "func IsInit() bool {\n\treturn false\n}", "func (i *Integer) Reset() {\n\ti.Value = 0\n\ti.Initialized = false\n\tIntegerPool.Put(i)\n}", "func NilAsZeroValue() {\n\tfmt.Println(\"NilAsZeroValue\")\n\tvar s []string = nil\n\tvar p *int\n\tvar ch chan int\n\tvar fn func()\n\tvar i interface{}\n\tvar m map[string]string\n\n\tif s == nil {\n\t\tfmt.Println(\"Zero Value for Slice is nil\")\n\t}\n\tif p == nil {\n\t\tfmt.Println(\"Zero Value for pointer is nil\")\n\t}\n\tif ch == nil {\n\t\tfmt.Println(\"Zero Value for channel is nil\")\n\t}\n\tif fn == nil {\n\t\tfmt.Println(\"Zero Value for func is nil\")\n\t}\n\tif i == nil {\n\t\tfmt.Println(\"Zero Value for interface is nil\")\n\t}\n\tif m == nil {\n\t\tfmt.Println(\"Zero Value for map is nil\")\n\t}\n}", "func NilInt() Int {\n\treturn Int{0, false}\n}", "func (o Int64) ElseZero() (value int64) {\n\tvar zero int64\n\treturn o.Else(zero)\n}", "func (f *FDTable) init() {\n\tf.initNoLeakCheck()\n\tf.InitRefs()\n\tf.fdBitmap = bitmap.New(uint32(math.MaxUint16))\n}", "func (s *GenerializedSystem)Init(f GenerializedFunctioner,r GenerializedRestrictioner,b bool,size int){\n\ts.fun = f\n\ts.restrict = r \n\ts.isMin = b\n\ts.size = size\n}", "func cinit() {\n\tC.djavul_cinit()\n}", "func (g *Gorc) Init() {\n\tg.Lock()\n\tg.count = 0\n\tg.waitMillis = 100 * time.Millisecond\n\tg.Unlock()\n}", "func init() {\n\ti = New()\n}", "func InitMpq(mpq *MpqT) {\n\tC.init_mpqp(C.uintptr_t(uintptr(unsafe.Pointer(mpq))))\n}", "func (client *Client) flagForInit() {\n\tclient.shouldInit = true\n}", "func (i Int) IsZero() bool {\n\treturn i.i.Sign() == 0\n}", "func Init(workercount int) {\n\t_ = fdlimit.Raise()\n\tglobal = New(workercount)\n}", "func init() {\n\ti := 0x1\n\tb := (*[intSize]byte)(unsafe.Pointer(&i))\n\tif b[0] == 1 {\n\t\t// LittleEndian is the little-endian implementation of ByteOrder\n\t\tNativeEndian = binary.LittleEndian\n\t} else {\n\t\t// BigEndian is the Big-endian implementation of ByteOrder\n\t\tNativeEndian = binary.BigEndian\n\t}\n}", "func (i NullInt) ValueOrZero() int64 {\n\tif !i.Valid {\n\t\treturn 0\n\t}\n\treturn i.Int64\n}", "func IntNoNonePtr(s int) *int {\n\tif s == 0 {\n\t\treturn nil\n\t}\n\treturn &s\n}", "func NewInt(i int64, valid bool) NullInt {\n\treturn NullInt{\n\t\tNullInt64: sql.NullInt64{\n\t\t\tInt64: i,\n\t\t\tValid: valid,\n\t\t},\n\t}\n}", "func (i *Iter) Init(f Form, src []byte) {\n\ti.p = 0\n\tif len(src) == 0 {\n\t\ti.setDone()\n\t\ti.rb.nsrc = 0\n\t\treturn\n\t}\n\ti.multiSeg = nil\n\ti.rb.init(f, src)\n\ti.next = i.rb.f.nextMain\n\ti.asciiF = nextASCIIBytes\n\ti.info = i.rb.f.info(i.rb.src, i.p)\n\ti.rb.ss.first(i.info)\n}", "func itob(v int) bool {\n\treturn v != 0\n}", "func init() {\n\tvar _ = remototypes.File{}\n\tvar _ = strconv.Itoa(0)\n\tvar _ = ioutil.Discard\n}", "func BenchmarkBigIntIsZero(b *testing.B) {\n\tv1 := new(big.Int).SetBytes(benchmarkVals()[0])\n\n\tb.ReportAllocs()\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\t_ = v1.Sign() == 0\n\t}\n}", "func (p *IntVector) Init(len int) *IntVector {\n\tp.Vector.Init(len);\n\treturn p;\n}", "func (s *Smpval) Int() int64 {\n\treturn s.i\n}", "func DoInit(\n\tfilepath string,\n\tquitter chan bool,\n\tdatabaseError chan error) (TData, error) {\n\tthis, err := Init(filepath)\n\tif err != nil {\n\t\treturn TData{}, err\n\t}\n\tgo this.StartSync(quitter, databaseError)\n\treturn this, nil\n}", "func FD_ZERO(p *syscall.FdSet) {\n\tfor i := range p.Bits {\n\t\tp.Bits[i] = 0\n\t}\n}", "func ValueInit(t Type) *Value {\n\tin := libc.Malloc(24) // 8bytes x 3\n\tlibc.Memset(in, 0, 24)\n\tout := Candy().Guify(\"g_value_init\", in, t).String()\n\tobj := NewValue(Candy(), out)\n\treturn obj\n}", "func InitIntNode(i int) *IntNode {\n\tnode := &IntNode{new(Node)}\n\tnode.SetValue(i)\n\treturn node\n}", "func Int(i *int) int {\n\tif i == nil {\n\t\treturn 0\n\t}\n\treturn *i\n}", "func (t *UniToler) Init(absTol, relTol float64, relativeWindow int, initVal float64) {\n\tif relTol > 0 {\n\t\tif len(t.hist) < relativeWindow {\n\t\t\tt.hist = make([]float64, relativeWindow)\n\t\t} else {\n\t\t\tt.hist = t.hist[:relativeWindow]\n\t\t}\n\t\tt.last = 0\n\t\tt.hist[0] = initVal\n\t}\n\tt.recent = initVal\n\tt.relTol = relTol\n\tt.absTol = absTol\n\tt.filled = false\n}", "func (s *IfStmt) Init() Node {\n\tif s.IfStmt.Init == nil {\n\t\treturn nil\n\t}\n\treturn s.findChildByAstNode(s.IfStmt.Init)\n}", "func x_cgo_init(g *G, setg uintptr) {\n\tvar size size_t\n\n\tsetg_func = setg\n\tsize = pthread_get_stacksize_np(pthread_self())\n\tg.stacklo = uintptr(unsafe.Add(unsafe.Pointer(&size), -size+4096))\n\n\t//TODO: support ios\n\t//#if TARGET_OS_IPHONE\n\t//\tdarwin_arm_init_mach_exception_handler();\n\t//\tdarwin_arm_init_thread_exception_port();\n\t//\tinit_working_dir();\n\t//#endif\n}", "func zero(x int) {\n\tfmt.Printf(\"in zero, &x: %p\\n\", &x)\n\tx = 0\n}", "func IsZero(v reflect.Value) bool {\n\t//switch v.Kind() {\n\t//case reflect.Bool:\n\t//\treturn !v.Bool()\n\t//case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t//\treturn v.Int() == 0\n\t//case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t//\treturn v.Uint() == 0\n\t//case reflect.Float32, reflect.Float64:\n\t//\treturn math.Float64bits(v.Float()) == 0\n\t//case reflect.Complex64, reflect.Complex128:\n\t//\tc := v.Complex()\n\t//\treturn math.Float64bits(real(c)) == 0 && math.Float64bits(imag(c)) == 0\n\t//case reflect.Array:\n\t//\treturn isZeroArray(v)\n\t//case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:\n\t//\treturn v.IsNil()\n\t//case reflect.UnsafePointer:\n\t//\treturn isNil(v)\n\t//case reflect.String:\n\t//\treturn v.Len() == 0\n\t//case reflect.Struct:\n\t//\treturn isZeroStruct(v)\n\t//default:\n\t//\t// This should never happens, but will act as a safeguard for\n\t//\t// later, as a default value doesn't makes sense here.\n\t//\tpanic(fmt.Sprintf(\"reflect.Value.IsZero, kind=%b\", v.Kind()))\n\t//}\n\tswitch v.Kind() {\n\tcase reflect.Bool:\n\t\treturn !v.Bool()\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\treturn v.Int() == 0\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\treturn v.Uint() == 0\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn math.Float64bits(v.Float()) == 0\n\tcase reflect.Complex64, reflect.Complex128:\n\t\tc := v.Complex()\n\t\treturn math.Float64bits(real(c)) == 0 && math.Float64bits(imag(c)) == 0\n\tcase reflect.Array:\n\t\tfor i := 0; i < v.Len(); i++ {\n\t\t\tif !v.Index(i).IsZero() {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t\t// return isZeroArray(v)\n\tcase reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:\n\t\treturn IsNil(v)\n\tcase reflect.UnsafePointer:\n\t\treturn IsNil(v)\n\tcase reflect.String:\n\t\treturn v.Len() == 0\n\tcase reflect.Struct:\n\t\tfor i := 0; i < v.NumField(); i++ {\n\t\t\tif !v.Field(i).IsZero() {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t\t// return isZeroStruct(v)\n\tdefault:\n\t\t// This should never happens, but will act as a safeguard for\n\t\t// later, as a default value doesn't makes sense here.\n\t\t// panic(fmt.Sprintf(\"reflect.Value.IsZero, kind=%b\", v.Kind()))\n\t\treturn false\n\t}\n}", "func IntAtomic() {\n\tvar i int64\n\tdone := make(chan bool)\n\tgo func() {\n\t\tatomic.StoreInt64(&i, 9)\n\t\tdone <- true\n\t}()\n\tatomic.StoreInt64(&i, 7)\n\t<-done\n\tfmt.Println(i)\n}", "func mapiterinit(t unsafe.Pointer, m unsafe.Pointer, it *hiter)", "func checkInit(t *testing.T, stub *shim.MockStub, args [][]byte) {\n\tres := stub.MockInit(\"1\", args)\n\tif res.Status != shim.OK {\n\t\tfmt.Println(\"Init failed\", string(res.Message))\n\t\tt.FailNow()\n\t}\n}", "func (v Value) TryInt() (n int64, ok bool) {\n\tn, ok = v.iface.(int64)\n\treturn\n}", "func (i *UInt64) IsZero() bool {\n\treturn uint64(*i) == uint64(0)\n}", "func Int64NoNonePtr(s int64) *int64 {\n\tif s == 0 {\n\t\treturn nil\n\t}\n\treturn &s\n}", "func init() {\n\tg_ = Default()\n}", "func (m monome) isZero() bool { return m.coeff == 0 }", "func TestZero(t *testing.T) {\n\t// test Limit() on zero object\n\tvar s segment.Sieve\n\tn := s.Limit()\n\tif n != 0 {\n\t\tt.Error(\"zero object Limit() = \", n)\n\t}\n\t// test Iterate succeeds on zero object\n\tif !s.Iterate(0, 0, func(uint64) bool {\n\t\treturn false\n\t}) {\n\t\tt.Error(\"Iterate fails on zero object\")\n\t}\n\t// test Iterate fails on request > limit\n\tif s.Iterate(0, 1, func(uint64) bool {\n\t\treturn false\n\t}) {\n\t\tt.Error(\"Iterate attempts request > limit on zero object\")\n\t}\n}", "func (uni *Uniform1fv) Init(name string, count int) {\n\n\tuni.name = name\n\tuni.v = make([]float32, count)\n}", "func (i *InvariantsChecker) Init() {\n\ti.initStatus = colexecop.OperatorInitialized\n\ti.Input.Init()\n}", "func checkInit(t *testing.T, stub *shim.MockStub, args [][]byte) {\n\t\n\tres := stub.MockInit(\"1\", args)\n\tif res.Status != shim.OK {\n\t\tfmt.Println(\"Init failed\", string(res.Message))\n\t\tt.FailNow()\n\t}\n}", "func BenchmarkBigIntZero(b *testing.B) {\n\tv1 := new(big.Int).SetBytes(benchmarkVals()[0])\n\n\tb.ReportAllocs()\n\tb.ResetTimer()\n\tfor i := 0; i < b.N; i++ {\n\t\tv1.SetUint64(0)\n\t}\n}", "func (p *intPool) getZero() *big.Int {\n\tif p.pool.len() > 0 {\n\t\treturn p.pool.pop().SetUint64(0)\n\t}\n\treturn new(big.Int)\n}", "func (f Fixed) Int() int64 {\n\tif f.IsNaN() {\n\t\treturn 0\n\t}\n\treturn f.fp / scale\n}", "func (s *Smpval) SetInt(i int64) bool {\n\tif s.flag == Int && s.val.CanSet() {\n\t\ts.val.SetInt(i)\n\t\ts.i = s.val.Int()\n\t\treturn true\n\t}\n\treturn false\n}", "func (ft *FieldType) Init(tp byte) {\n\tft.tp = tp\n\tft.flen = UnspecifiedLength\n\tft.decimal = UnspecifiedLength\n}", "func (c *Int) ToZero() {\n\tc.mu.Lock()\n\tc.v = 0\n\tc.mu.Unlock()\n}", "func (d *Default) Init() error {\n\treturn nil\n}", "func unionWithInit(b *testing.B) {\n\tif unionIntSet64Data1 == nil {\n\t\tunionIntSet64Data1, unionIntSet32Data1, unionIntMapData1 = generateSets(*max_range, *count)\n\t\tunionIntSet64Data2, unionIntSet32Data2, unionIntMapData2 = generateSets(*max_range, *count)\n\t\tb.ResetTimer()\n\t}\n}", "func InotifyInit(t *kernel.Task, sysno uintptr, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) {\n\targs[0].Value = 0\n\treturn InotifyInit1(t, sysno, args)\n}", "func GitInit(tb testing.TB) {\n\ttb.Helper()\n\tout, err := fakeGit(\"init\")\n\trequire.NoError(tb, err)\n\trequire.Contains(tb, out, \"Initialized empty Git repository\")\n\trequire.NoError(tb, err)\n\tGitCheckoutBranch(tb, \"main\")\n\t_, _ = fakeGit(\"branch\", \"-D\", \"master\")\n}", "func (egs *ExampleGenServer) Init(p *ergo.Process, args ...interface{}) (state interface{}) {\n\tfmt.Printf(\"Init: args %v \\n\", args)\n\tegs.process = p\n\tInitialState := &State{\n\t\tvalue: args[0].(int), // 100\n\t}\n\treturn InitialState\n}", "func t1f0(b bool) int {\n\tif b {\n\t\treturn 1\n\t}\n\treturn 0\n}", "func FromNullInt(i sql.NullInt64) int64 {\n\tif i.Valid {\n\t\treturn i.Int64\n\t}\n\n\treturn 0\n}", "func (ob *PyObject) Int() int {\n\treturn int(C.PyLong_AsUnsignedLongLong(ob.rawptr))\n}", "func dupInit(b *testing.B) {\n\tif dupIntSet64Data == nil {\n\t\tdupIntSet64Data, dupIntSet32Data, dupIntMapData = generateSets(*max_range, *count)\n\t\tb.ResetTimer()\n\t}\n}", "func CoInitialize(p uintptr) (err error) {\n\t// p is ignored and won't be used.\n\t// Avoid any variable not used errors.\n\tp = uintptr(0)\n\treturn coInitialize()\n}", "func (ini *Init) InitCount() int {\n\ti := atomic.LoadUint64(&ini.initCount)\n\treturn int(i)\n}", "func (n *Number) Zero() bool {\n\tif n.isInteger {\n\t\treturn n.integer.Cmp(&big.Int{}) == 0\n\t} else {\n\t\treturn n.floating == 0\n\t}\n}", "func (f *Feature) StartZero() uint64 {\n\tif f.Pos == 0 {\n\t\treturn 0\n\t}\n\treturn f.Pos - 1\n}", "func (i NullInt) Ptr() *int64 {\n\tif !i.Valid {\n\t\treturn nil\n\t}\n\treturn &i.Int64\n}" ]
[ "0.6102218", "0.5942012", "0.5883882", "0.5667407", "0.5602605", "0.5529715", "0.55246204", "0.5441465", "0.54351246", "0.54031265", "0.54008603", "0.5350783", "0.5315941", "0.5255503", "0.52292323", "0.52292323", "0.52292323", "0.52292323", "0.5211608", "0.51354223", "0.51123446", "0.5104661", "0.5097506", "0.5097506", "0.50440764", "0.5043817", "0.50302964", "0.5009999", "0.4988847", "0.4985998", "0.4985862", "0.49841726", "0.49734697", "0.49702713", "0.4966584", "0.49489203", "0.49095327", "0.4844414", "0.4841402", "0.48388523", "0.48304936", "0.48110884", "0.48050442", "0.4799645", "0.47774532", "0.47764757", "0.4766022", "0.47629532", "0.47600973", "0.47529915", "0.47461733", "0.47399753", "0.47383073", "0.473358", "0.4732979", "0.47290328", "0.47029543", "0.4692581", "0.4688819", "0.46869937", "0.46860334", "0.46765038", "0.4674004", "0.46705264", "0.46677956", "0.46651492", "0.46649623", "0.46647197", "0.46556312", "0.46541858", "0.46392488", "0.46320856", "0.4608557", "0.46066177", "0.46037728", "0.45891163", "0.45803615", "0.4579432", "0.45778438", "0.4571975", "0.45689583", "0.45650104", "0.45619756", "0.45575225", "0.45562717", "0.45551693", "0.4552987", "0.45476395", "0.45394155", "0.45350507", "0.45344365", "0.45339763", "0.4528519", "0.45283443", "0.4509177", "0.45074338", "0.45059684", "0.45034015", "0.45024675", "0.45015" ]
0.71814644
0
Set sets f = x and returns f.
Устанавливает f = x и возвращает f.
func (f *Float) Set(x *Float) *Float { f.doinit() C.mpf_set(&f.i[0], &x.i[0]) return f }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *mShifterMockShift) Set(f func(p context.Context, p1 insolar.PulseNumber) (r error)) *ShifterMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.ShiftFunc = f\n\treturn m.mock\n}", "func (hf *handleFunc) Set(f func(w http.ResponseWriter, r *http.Request)) {\n\thf.mu.Lock()\n\tdefer hf.mu.Unlock()\n\thf.f = f\n}", "func (m *mHeavySyncMockReset) Set(f func(p context.Context, p1 insolar.ID, p2 insolar.PulseNumber) (r error)) *HeavySyncMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.ResetFunc = f\n\treturn m.mock\n}", "func (z *Float) Set(x *Float) *Float {}", "func (m *mModifierMockSet) Set(f func(p context.Context, p1 Drop) (r error)) *ModifierMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.SetFunc = f\n\treturn m.mock\n}", "func (m *mTesterMockFatalf) Set(f func(p string, p1 ...interface{})) *TesterMock {\n\tm.mock.FatalfFunc = f\n\treturn m.mock\n}", "func (m *mActiveNodeMockGetSignatureVerifier) Set(f func() (r cryptkit.SignatureVerifier)) *ActiveNodeMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetSignatureVerifierFunc = f\n\treturn m.mock\n}", "func (f *transformingValue) Set(s string) error {\n\treturn f.Value.Set(f.fn(s))\n}", "func (m *mActiveNodeMockGetNodeID) Set(f func() (r insolar.ShortNodeID)) *ActiveNodeMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetNodeIDFunc = f\n\treturn m.mock\n}", "func (m *mParcelMockPulse) Set(f func() (r insolar.PulseNumber)) *ParcelMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.PulseFunc = f\n\treturn m.mock\n}", "func (m *mOutboundMockGetRelayID) Set(f func() (r insolar.ShortNodeID)) *OutboundMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetRelayIDFunc = f\n\treturn m.mock\n}", "func (m *mIndexCollectionAccessorMockForJet) Set(f func(p context.Context, p1 insolar.JetID) (r map[insolar.ID]LifelineMeta)) *IndexCollectionAccessorMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.ForJetFunc = f\n\treturn m.mock\n}", "func (m *mIndexCollectionAccessorMockForPulseAndJet) Set(f func(p context.Context, p1 insolar.PulseNumber, p2 insolar.JetID) (r map[insolar.ID]Lifeline)) *IndexCollectionAccessorMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.ForPulseAndJetFunc = f\n\treturn m.mock\n}", "func (m *mParcelMockGetCaller) Set(f func() (r *insolar.Reference)) *ParcelMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetCallerFunc = f\n\treturn m.mock\n}", "func (m *mParcelMockGetSign) Set(f func() (r []byte)) *ParcelMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetSignFunc = f\n\treturn m.mock\n}", "func (m *mCryptographyServiceMockSign) Set(f func(p []byte) (r *insolar.Signature, r1 error)) *CryptographyServiceMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.SignFunc = f\n\treturn m.mock\n}", "func (m *mStateSwitcherMockSwitchToState) Set(f func(p context.Context, p1 State, p2 interface{})) *StateSwitcherMock {\n\tm.mock.SwitchToStateFunc = f\n\tm.mockExpectations = nil\n\treturn m.mock\n}", "func (m *mHeavySyncMockStart) Set(f func(p context.Context, p1 insolar.ID, p2 insolar.PulseNumber) (r error)) *HeavySyncMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.StartFunc = f\n\treturn m.mock\n}", "func (m *mSignatureKeyHolderMockRead) Set(f func(p []byte) (r int, r1 error)) *SignatureKeyHolderMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.ReadFunc = f\n\treturn m.mock\n}", "func (m *mSignatureKeyHolderMockGetSignatureKeyType) Set(f func() (r SignatureKeyType)) *SignatureKeyHolderMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetSignatureKeyTypeFunc = f\n\treturn m.mock\n}", "func (m *mParcelMockGetSender) Set(f func() (r insolar.Reference)) *ParcelMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetSenderFunc = f\n\treturn m.mock\n}", "func (m *mSignatureKeyHolderMockFoldToUint64) Set(f func() (r uint64)) *SignatureKeyHolderMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.FoldToUint64Func = f\n\treturn m.mock\n}", "func (m *mStateSwitcherMockGetState) Set(f func() (r State)) *StateSwitcherMock {\n\tm.mock.GetStateFunc = f\n\n\treturn m.mock\n}", "func (m *mSignatureKeyHolderMockWriteTo) Set(f func(p io.Writer) (r int64, r1 error)) *SignatureKeyHolderMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.WriteToFunc = f\n\treturn m.mock\n}", "func (m *mRecentIndexStorageMockAddObjectWithTLL) Set(f func(p context.Context, p1 insolar.ID, p2 int)) *RecentIndexStorageMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.AddObjectWithTLLFunc = f\n\treturn m.mock\n}", "func (m *mRecentIndexStorageMockAddObject) Set(f func(p context.Context, p1 insolar.ID)) *RecentIndexStorageMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.AddObjectFunc = f\n\treturn m.mock\n}", "func (m *mSignatureKeyHolderMockGetSignatureKeyMethod) Set(f func() (r SignatureMethod)) *SignatureKeyHolderMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetSignatureKeyMethodFunc = f\n\treturn m.mock\n}", "func (m *mActiveNodeMockGetIndex) Set(f func() (r member.Index)) *ActiveNodeMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetIndexFunc = f\n\treturn m.mock\n}", "func (m *mHeavySyncMockStoreBlobs) Set(f func(p context.Context, p1 insolar.PulseNumber, p2 [][]byte) (r error)) *HeavySyncMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.StoreBlobsFunc = f\n\treturn m.mock\n}", "func (m *mActiveNodeMockGetDeclaredPower) Set(f func() (r member.Power)) *ActiveNodeMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetDeclaredPowerFunc = f\n\treturn m.mock\n}", "func (mmIssuePendingExecution *mDelegationTokenFactoryMockIssuePendingExecution) Set(f func(msg mm_insolar.Message, pulse mm_insolar.PulseNumber) (d1 mm_insolar.DelegationToken, err error)) *DelegationTokenFactoryMock {\n\tif mmIssuePendingExecution.defaultExpectation != nil {\n\t\tmmIssuePendingExecution.mock.t.Fatalf(\"Default expectation is already set for the DelegationTokenFactory.IssuePendingExecution method\")\n\t}\n\n\tif len(mmIssuePendingExecution.expectations) > 0 {\n\t\tmmIssuePendingExecution.mock.t.Fatalf(\"Some expectations are already set for the DelegationTokenFactory.IssuePendingExecution method\")\n\t}\n\n\tmmIssuePendingExecution.mock.funcIssuePendingExecution = f\n\treturn mmIssuePendingExecution.mock\n}", "func (m *mHostNetworkMockSendRequest) Set(f func(p network.Request, p1 core.RecordRef) (r network.Future, r1 error)) *HostNetworkMock {\n\tm.mock.SendRequestFunc = f\n\tm.mockExpectations = nil\n\treturn m.mock\n}", "func (mmValue *mIteratorMockValue) Set(f func() (ba1 []byte, err error)) *IteratorMock {\n\tif mmValue.defaultExpectation != nil {\n\t\tmmValue.mock.t.Fatalf(\"Default expectation is already set for the Iterator.Value method\")\n\t}\n\n\tif len(mmValue.expectations) > 0 {\n\t\tmmValue.mock.t.Fatalf(\"Some expectations are already set for the Iterator.Value method\")\n\t}\n\n\tmmValue.mock.funcValue = f\n\treturn mmValue.mock\n}", "func (m *mStateSwitcherMocksetState) Set(f func(p State)) *StateSwitcherMock {\n\tm.mock.setStateFunc = f\n\tm.mockExpectations = nil\n\treturn m.mock\n}", "func (m *mOutboundMockCanAccept) Set(f func(p Inbound) (r bool)) *OutboundMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.CanAcceptFunc = f\n\treturn m.mock\n}", "func (m *mParcelMockSetSender) Set(f func(p insolar.Reference)) *ParcelMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.SetSenderFunc = f\n\treturn m.mock\n}", "func (m *mActiveNodeMockIsJoiner) Set(f func() (r bool)) *ActiveNodeMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.IsJoinerFunc = f\n\treturn m.mock\n}", "func (m *mHeavySyncMockStoreDrop) Set(f func(p context.Context, p1 insolar.JetID, p2 []byte) (r error)) *HeavySyncMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.StoreDropFunc = f\n\treturn m.mock\n}", "func (m *mSignatureKeyHolderMockFixedByteSize) Set(f func() (r int)) *SignatureKeyHolderMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.FixedByteSizeFunc = f\n\treturn m.mock\n}", "func (m *mActiveNodeMockGetOpMode) Set(f func() (r member.OpMode)) *ActiveNodeMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetOpModeFunc = f\n\treturn m.mock\n}", "func (m *mSignatureKeyHolderMockGetSignMethod) Set(f func() (r SignMethod)) *SignatureKeyHolderMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetSignMethodFunc = f\n\treturn m.mock\n}", "func (m *mParcelMockType) Set(f func() (r insolar.MessageType)) *ParcelMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.TypeFunc = f\n\treturn m.mock\n}", "func (s *SessionStorer) Set(f string, u []byte) {\n\ts.SetInvoked = true\n\ts.SetFn(f, u)\n}", "func (m *mOutboundMockGetEndpointType) Set(f func() (r NodeEndpointType)) *OutboundMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetEndpointTypeFunc = f\n\treturn m.mock\n}", "func (mmGetSourceID *mPacketParserMockGetSourceID) Set(f func() (s1 insolar.ShortNodeID)) *PacketParserMock {\n\tif mmGetSourceID.defaultExpectation != nil {\n\t\tmmGetSourceID.mock.t.Fatalf(\"Default expectation is already set for the PacketParser.GetSourceID method\")\n\t}\n\n\tif len(mmGetSourceID.expectations) > 0 {\n\t\tmmGetSourceID.mock.t.Fatalf(\"Some expectations are already set for the PacketParser.GetSourceID method\")\n\t}\n\n\tmmGetSourceID.mock.funcGetSourceID = f\n\treturn mmGetSourceID.mock\n}", "func (mmKey *mIteratorMockKey) Set(f func() (ba1 []byte)) *IteratorMock {\n\tif mmKey.defaultExpectation != nil {\n\t\tmmKey.mock.t.Fatalf(\"Default expectation is already set for the Iterator.Key method\")\n\t}\n\n\tif len(mmKey.expectations) > 0 {\n\t\tmmKey.mock.t.Fatalf(\"Some expectations are already set for the Iterator.Key method\")\n\t}\n\n\tmmKey.mock.funcKey = f\n\treturn mmKey.mock\n}", "func (m *mHeavySyncMockStoreIndices) Set(f func(p context.Context, p1 insolar.ID, p2 insolar.PulseNumber, p3 []insolar.KV) (r error)) *HeavySyncMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.StoreIndicesFunc = f\n\treturn m.mock\n}", "func (mmForkSequence *mForkingDigesterMockForkSequence) Set(f func() (f1 ForkingDigester)) *ForkingDigesterMock {\n\tif mmForkSequence.defaultExpectation != nil {\n\t\tmmForkSequence.mock.t.Fatalf(\"Default expectation is already set for the ForkingDigester.ForkSequence method\")\n\t}\n\n\tif len(mmForkSequence.expectations) > 0 {\n\t\tmmForkSequence.mock.t.Fatalf(\"Some expectations are already set for the ForkingDigester.ForkSequence method\")\n\t}\n\n\tmmForkSequence.mock.funcForkSequence = f\n\treturn mmForkSequence.mock\n}", "func (m *mActiveNodeMockGetStatic) Set(f func() (r StaticProfile)) *ActiveNodeMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetStaticFunc = f\n\treturn m.mock\n}", "func (m *mSignatureKeyHolderMockAsByteString) Set(f func() (r string)) *SignatureKeyHolderMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.AsByteStringFunc = f\n\treturn m.mock\n}", "func (m *mCryptographyServiceMockVerify) Set(f func(p crypto.PublicKey, p1 insolar.Signature, p2 []byte) (r bool)) *CryptographyServiceMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.VerifyFunc = f\n\treturn m.mock\n}", "func (m *mUnsyncListMockCalculateHash) Set(f func() (r []byte, r1 error)) *UnsyncListMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.CalculateHashFunc = f\n\treturn m.mock\n}", "func (mmFoldToUint64 *mDigestHolderMockFoldToUint64) Set(f func() (u1 uint64)) *DigestHolderMock {\n\tif mmFoldToUint64.defaultExpectation != nil {\n\t\tmmFoldToUint64.mock.t.Fatalf(\"Default expectation is already set for the DigestHolder.FoldToUint64 method\")\n\t}\n\n\tif len(mmFoldToUint64.expectations) > 0 {\n\t\tmmFoldToUint64.mock.t.Fatalf(\"Some expectations are already set for the DigestHolder.FoldToUint64 method\")\n\t}\n\n\tmmFoldToUint64.mock.funcFoldToUint64 = f\n\treturn mmFoldToUint64.mock\n}", "func (mmFixedByteSize *mDigestHolderMockFixedByteSize) Set(f func() (i1 int)) *DigestHolderMock {\n\tif mmFixedByteSize.defaultExpectation != nil {\n\t\tmmFixedByteSize.mock.t.Fatalf(\"Default expectation is already set for the DigestHolder.FixedByteSize method\")\n\t}\n\n\tif len(mmFixedByteSize.expectations) > 0 {\n\t\tmmFixedByteSize.mock.t.Fatalf(\"Some expectations are already set for the DigestHolder.FixedByteSize method\")\n\t}\n\n\tmmFixedByteSize.mock.funcFixedByteSize = f\n\treturn mmFixedByteSize.mock\n}", "func (m *mSignatureKeyHolderMockEquals) Set(f func(p SignatureKeyHolder) (r bool)) *SignatureKeyHolderMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.EqualsFunc = f\n\treturn m.mock\n}", "func (mmUpdate *mStorageMockUpdate) Set(f func(ctx context.Context, pulse insolar.PulseNumber, actual bool, ids ...insolar.JetID) (err error)) *StorageMock {\n\tif mmUpdate.defaultExpectation != nil {\n\t\tmmUpdate.mock.t.Fatalf(\"Default expectation is already set for the Storage.Update method\")\n\t}\n\n\tif len(mmUpdate.expectations) > 0 {\n\t\tmmUpdate.mock.t.Fatalf(\"Some expectations are already set for the Storage.Update method\")\n\t}\n\n\tmmUpdate.mock.funcUpdate = f\n\treturn mmUpdate.mock\n}", "func (m *mHeavySyncMockStoreRecords) Set(f func(p context.Context, p1 insolar.ID, p2 insolar.PulseNumber, p3 [][]byte)) *HeavySyncMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.StoreRecordsFunc = f\n\treturn m.mock\n}", "func (mmClone *mStorageMockClone) Set(f func(ctx context.Context, from insolar.PulseNumber, to insolar.PulseNumber, keepActual bool) (err error)) *StorageMock {\n\tif mmClone.defaultExpectation != nil {\n\t\tmmClone.mock.t.Fatalf(\"Default expectation is already set for the Storage.Clone method\")\n\t}\n\n\tif len(mmClone.expectations) > 0 {\n\t\tmmClone.mock.t.Fatalf(\"Some expectations are already set for the Storage.Clone method\")\n\t}\n\n\tmmClone.mock.funcClone = f\n\treturn mmClone.mock\n}", "func (mmCopyOfDigest *mDigestHolderMockCopyOfDigest) Set(f func() (d1 Digest)) *DigestHolderMock {\n\tif mmCopyOfDigest.defaultExpectation != nil {\n\t\tmmCopyOfDigest.mock.t.Fatalf(\"Default expectation is already set for the DigestHolder.CopyOfDigest method\")\n\t}\n\n\tif len(mmCopyOfDigest.expectations) > 0 {\n\t\tmmCopyOfDigest.mock.t.Fatalf(\"Some expectations are already set for the DigestHolder.CopyOfDigest method\")\n\t}\n\n\tmmCopyOfDigest.mock.funcCopyOfDigest = f\n\treturn mmCopyOfDigest.mock\n}", "func (mmWriteTo *mDigestHolderMockWriteTo) Set(f func(w io.Writer) (n int64, err error)) *DigestHolderMock {\n\tif mmWriteTo.defaultExpectation != nil {\n\t\tmmWriteTo.mock.t.Fatalf(\"Default expectation is already set for the DigestHolder.WriteTo method\")\n\t}\n\n\tif len(mmWriteTo.expectations) > 0 {\n\t\tmmWriteTo.mock.t.Fatalf(\"Some expectations are already set for the DigestHolder.WriteTo method\")\n\t}\n\n\tmmWriteTo.mock.funcWriteTo = f\n\treturn mmWriteTo.mock\n}", "func (m *mOutboundMockAsByteString) Set(f func() (r string)) *OutboundMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.AsByteStringFunc = f\n\treturn m.mock\n}", "func (mmUpdateState *mGatewayMockUpdateState) Set(f func(ctx context.Context, pulseNumber insolar.PulseNumber, nodes []insolar.NetworkNode, cloudStateHash []byte)) *GatewayMock {\n\tif mmUpdateState.defaultExpectation != nil {\n\t\tmmUpdateState.mock.t.Fatalf(\"Default expectation is already set for the Gateway.UpdateState method\")\n\t}\n\n\tif len(mmUpdateState.expectations) > 0 {\n\t\tmmUpdateState.mock.t.Fatalf(\"Some expectations are already set for the Gateway.UpdateState method\")\n\t}\n\n\tmmUpdateState.mock.funcUpdateState = f\n\treturn mmUpdateState.mock\n}", "func (f *Fieldx) Set(v interface{}) error {\n\tif !f.IsExport() {\n\t\treturn ErrNotExported\n\t}\n\n\tif !f.value.CanSet() {\n\t\treturn errNotSettable\n\t}\n\n\tvv := reflect.ValueOf(v)\n\tif f.Kind() != vv.Kind() {\n\t\treturn fmt.Errorf(\"xstruct: value kind not match, want: %s but got %s\", f.Kind(), vv.Kind())\n\t}\n\n\tf.value.Set(vv)\n\n\treturn nil\n}", "func (m *mTesterMockFatal) Set(f func(p ...interface{})) *TesterMock {\n\tm.mock.FatalFunc = f\n\treturn m.mock\n}", "func (mmGetTargetID *mPacketParserMockGetTargetID) Set(f func() (s1 insolar.ShortNodeID)) *PacketParserMock {\n\tif mmGetTargetID.defaultExpectation != nil {\n\t\tmmGetTargetID.mock.t.Fatalf(\"Default expectation is already set for the PacketParser.GetTargetID method\")\n\t}\n\n\tif len(mmGetTargetID.expectations) > 0 {\n\t\tmmGetTargetID.mock.t.Fatalf(\"Some expectations are already set for the PacketParser.GetTargetID method\")\n\t}\n\n\tmmGetTargetID.mock.funcGetTargetID = f\n\treturn mmGetTargetID.mock\n}", "func (mmSaveUser *mStorageMockSaveUser) Set(f func(ctx context.Context, user *db_storage.User) (err error)) *StorageMock {\n\tif mmSaveUser.defaultExpectation != nil {\n\t\tmmSaveUser.mock.t.Fatalf(\"Default expectation is already set for the storage.SaveUser method\")\n\t}\n\n\tif len(mmSaveUser.expectations) > 0 {\n\t\tmmSaveUser.mock.t.Fatalf(\"Some expectations are already set for the storage.SaveUser method\")\n\t}\n\n\tmmSaveUser.mock.funcSaveUser = f\n\treturn mmSaveUser.mock\n}", "func (m *mParcelMockDelegationToken) Set(f func() (r insolar.DelegationToken)) *ParcelMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.DelegationTokenFunc = f\n\treturn m.mock\n}", "func (mmInvoke *mContainerMockInvoke) Set(f func(function interface{}) (err error)) *ContainerMock {\n\tif mmInvoke.defaultExpectation != nil {\n\t\tmmInvoke.mock.t.Fatalf(\"Default expectation is already set for the Container.Invoke method\")\n\t}\n\n\tif len(mmInvoke.expectations) > 0 {\n\t\tmmInvoke.mock.t.Fatalf(\"Some expectations are already set for the Container.Invoke method\")\n\t}\n\n\tmmInvoke.mock.funcInvoke = f\n\treturn mmInvoke.mock\n}", "func (m *mIndexBucketModifierMockSetBucket) Set(f func(p context.Context, p1 insolar.PulseNumber, p2 IndexBucket) (r error)) *IndexBucketModifierMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.SetBucketFunc = f\n\treturn m.mock\n}", "func (m *mHostNetworkMockRegisterRequestHandler) Set(f func(p types.PacketType, p1 network.RequestHandler)) *HostNetworkMock {\n\tm.mock.RegisterRequestHandlerFunc = f\n\tm.mockExpectations = nil\n\treturn m.mock\n}", "func (mmForID *mStorageMockForID) Set(f func(ctx context.Context, pulse insolar.PulseNumber, recordID insolar.ID) (j1 insolar.JetID, b1 bool)) *StorageMock {\n\tif mmForID.defaultExpectation != nil {\n\t\tmmForID.mock.t.Fatalf(\"Default expectation is already set for the Storage.ForID method\")\n\t}\n\n\tif len(mmForID.expectations) > 0 {\n\t\tmmForID.mock.t.Fatalf(\"Some expectations are already set for the Storage.ForID method\")\n\t}\n\n\tmmForID.mock.funcForID = f\n\treturn mmForID.mock\n}", "func (mmRun *mGatewayMockRun) Set(f func(ctx context.Context, pulse insolar.Pulse)) *GatewayMock {\n\tif mmRun.defaultExpectation != nil {\n\t\tmmRun.mock.t.Fatalf(\"Default expectation is already set for the Gateway.Run method\")\n\t}\n\n\tif len(mmRun.expectations) > 0 {\n\t\tmmRun.mock.t.Fatalf(\"Some expectations are already set for the Gateway.Run method\")\n\t}\n\n\tmmRun.mock.funcRun = f\n\treturn mmRun.mock\n}", "func (z *Rat) Set(x *Rat) *Rat {}", "func (m *mUnsyncListMockGetActiveNode) Set(f func(p core.RecordRef) (r core.Node)) *UnsyncListMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetActiveNodeFunc = f\n\treturn m.mock\n}", "func (m *mHeavySyncMockStop) Set(f func(p context.Context, p1 insolar.ID, p2 insolar.PulseNumber) (r error)) *HeavySyncMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.StopFunc = f\n\treturn m.mock\n}", "func (mmVerify *mDelegationTokenFactoryMockVerify) Set(f func(parcel mm_insolar.Parcel) (b1 bool, err error)) *DelegationTokenFactoryMock {\n\tif mmVerify.defaultExpectation != nil {\n\t\tmmVerify.mock.t.Fatalf(\"Default expectation is already set for the DelegationTokenFactory.Verify method\")\n\t}\n\n\tif len(mmVerify.expectations) > 0 {\n\t\tmmVerify.mock.t.Fatalf(\"Some expectations are already set for the DelegationTokenFactory.Verify method\")\n\t}\n\n\tmmVerify.mock.funcVerify = f\n\treturn mmVerify.mock\n}", "func (mmGetPulseNumber *mPacketParserMockGetPulseNumber) Set(f func() (n1 pulse.Number)) *PacketParserMock {\n\tif mmGetPulseNumber.defaultExpectation != nil {\n\t\tmmGetPulseNumber.mock.t.Fatalf(\"Default expectation is already set for the PacketParser.GetPulseNumber method\")\n\t}\n\n\tif len(mmGetPulseNumber.expectations) > 0 {\n\t\tmmGetPulseNumber.mock.t.Fatalf(\"Some expectations are already set for the PacketParser.GetPulseNumber method\")\n\t}\n\n\tmmGetPulseNumber.mock.funcGetPulseNumber = f\n\treturn mmGetPulseNumber.mock\n}", "func (mmGetUser *mStorageMockGetUser) Set(f func(ctx context.Context, userID int64) (up1 *db_storage.User, err error)) *StorageMock {\n\tif mmGetUser.defaultExpectation != nil {\n\t\tmmGetUser.mock.t.Fatalf(\"Default expectation is already set for the storage.GetUser method\")\n\t}\n\n\tif len(mmGetUser.expectations) > 0 {\n\t\tmmGetUser.mock.t.Fatalf(\"Some expectations are already set for the storage.GetUser method\")\n\t}\n\n\tmmGetUser.mock.funcGetUser = f\n\treturn mmGetUser.mock\n}", "func (mmGetPacketSignature *mPacketParserMockGetPacketSignature) Set(f func() (s1 cryptkit.SignedDigest)) *PacketParserMock {\n\tif mmGetPacketSignature.defaultExpectation != nil {\n\t\tmmGetPacketSignature.mock.t.Fatalf(\"Default expectation is already set for the PacketParser.GetPacketSignature method\")\n\t}\n\n\tif len(mmGetPacketSignature.expectations) > 0 {\n\t\tmmGetPacketSignature.mock.t.Fatalf(\"Some expectations are already set for the PacketParser.GetPacketSignature method\")\n\t}\n\n\tmmGetPacketSignature.mock.funcGetPacketSignature = f\n\treturn mmGetPacketSignature.mock\n}", "func (m *mOutboundMockGetIPAddress) Set(f func() (r packets.NodeAddress)) *OutboundMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetIPAddressFunc = f\n\treturn m.mock\n}", "func (m *mHostNetworkMockGetNodeID) Set(f func() (r core.RecordRef)) *HostNetworkMock {\n\tm.mock.GetNodeIDFunc = f\n\n\treturn m.mock\n}", "func (m *mConsensusNetworkMockRegisterRequestHandler) Set(f func(p types.PacketType, p1 network.ConsensusRequestHandler)) *ConsensusNetworkMock {\n\tm.mock.RegisterRequestHandlerFunc = f\n\tm.mockExpectations = nil\n\treturn m.mock\n}", "func (m *mStateSwitcherMockSetPulsar) Set(f func(p *Pulsar)) *StateSwitcherMock {\n\tm.mock.SetPulsarFunc = f\n\tm.mockExpectations = nil\n\treturn m.mock\n}", "func (m *mRecentIndexStorageMockGetObjects) Set(f func() (r map[insolar.ID]int)) *RecentIndexStorageMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.GetObjectsFunc = f\n\treturn m.mock\n}", "func (mmAddNext *mForkingDigesterMockAddNext) Set(f func(digest longbits.FoldableReader)) *ForkingDigesterMock {\n\tif mmAddNext.defaultExpectation != nil {\n\t\tmmAddNext.mock.t.Fatalf(\"Default expectation is already set for the ForkingDigester.AddNext method\")\n\t}\n\n\tif len(mmAddNext.expectations) > 0 {\n\t\tmmAddNext.mock.t.Fatalf(\"Some expectations are already set for the ForkingDigester.AddNext method\")\n\t}\n\n\tmmAddNext.mock.funcAddNext = f\n\treturn mmAddNext.mock\n}", "func (mmOnPulseFromConsensus *mGatewayMockOnPulseFromConsensus) Set(f func(ctx context.Context, p1 insolar.Pulse)) *GatewayMock {\n\tif mmOnPulseFromConsensus.defaultExpectation != nil {\n\t\tmmOnPulseFromConsensus.mock.t.Fatalf(\"Default expectation is already set for the Gateway.OnPulseFromConsensus method\")\n\t}\n\n\tif len(mmOnPulseFromConsensus.expectations) > 0 {\n\t\tmmOnPulseFromConsensus.mock.t.Fatalf(\"Some expectations are already set for the Gateway.OnPulseFromConsensus method\")\n\t}\n\n\tmmOnPulseFromConsensus.mock.funcOnPulseFromConsensus = f\n\treturn mmOnPulseFromConsensus.mock\n}", "func (mmLock *mIndexLockerMockLock) Set(f func(id insolar.ID)) *IndexLockerMock {\n\tif mmLock.defaultExpectation != nil {\n\t\tmmLock.mock.t.Fatalf(\"Default expectation is already set for the IndexLocker.Lock method\")\n\t}\n\n\tif len(mmLock.expectations) > 0 {\n\t\tmmLock.mock.t.Fatalf(\"Some expectations are already set for the IndexLocker.Lock method\")\n\t}\n\n\tmmLock.mock.funcLock = f\n\treturn mmLock.mock\n}", "func (m *mConsensusNetworkMockSendRequest) Set(f func(p network.Request, p1 core.RecordRef) (r error)) *ConsensusNetworkMock {\n\tm.mock.SendRequestFunc = f\n\tm.mockExpectations = nil\n\treturn m.mock\n}", "func (mmGetFavChannelID *mExtractorClientMockGetFavChannelID) Set(f func() (i1 int64, err error)) *ExtractorClientMock {\n\tif mmGetFavChannelID.defaultExpectation != nil {\n\t\tmmGetFavChannelID.mock.t.Fatalf(\"Default expectation is already set for the extractorClient.GetFavChannelID method\")\n\t}\n\n\tif len(mmGetFavChannelID.expectations) > 0 {\n\t\tmmGetFavChannelID.mock.t.Fatalf(\"Some expectations are already set for the extractorClient.GetFavChannelID method\")\n\t}\n\n\tmmGetFavChannelID.mock.funcGetFavChannelID = f\n\treturn mmGetFavChannelID.mock\n}", "func (mmGetReceiverID *mPacketParserMockGetReceiverID) Set(f func() (s1 insolar.ShortNodeID)) *PacketParserMock {\n\tif mmGetReceiverID.defaultExpectation != nil {\n\t\tmmGetReceiverID.mock.t.Fatalf(\"Default expectation is already set for the PacketParser.GetReceiverID method\")\n\t}\n\n\tif len(mmGetReceiverID.expectations) > 0 {\n\t\tmmGetReceiverID.mock.t.Fatalf(\"Some expectations are already set for the PacketParser.GetReceiverID method\")\n\t}\n\n\tmmGetReceiverID.mock.funcGetReceiverID = f\n\treturn mmGetReceiverID.mock\n}", "func (m *mParcelMockAllowedSenderObjectAndRole) Set(f func() (r *insolar.Reference, r1 insolar.DynamicRole)) *ParcelMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.AllowedSenderObjectAndRoleFunc = f\n\treturn m.mock\n}", "func (mmGetState *mGatewayMockGetState) Set(f func() (n1 insolar.NetworkState)) *GatewayMock {\n\tif mmGetState.defaultExpectation != nil {\n\t\tmmGetState.mock.t.Fatalf(\"Default expectation is already set for the Gateway.GetState method\")\n\t}\n\n\tif len(mmGetState.expectations) > 0 {\n\t\tmmGetState.mock.t.Fatalf(\"Some expectations are already set for the Gateway.GetState method\")\n\t}\n\n\tmmGetState.mock.funcGetState = f\n\treturn mmGetState.mock\n}", "func (mmState *mClientMockState) Set(f func() (ba1 []byte)) *ClientMock {\n\tif mmState.defaultExpectation != nil {\n\t\tmmState.mock.t.Fatalf(\"Default expectation is already set for the Client.State method\")\n\t}\n\n\tif len(mmState.expectations) > 0 {\n\t\tmmState.mock.t.Fatalf(\"Some expectations are already set for the Client.State method\")\n\t}\n\n\tmmState.mock.funcState = f\n\treturn mmState.mock\n}", "func (m *mSignatureKeyHolderMockAsBytes) Set(f func() (r []byte)) *SignatureKeyHolderMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.AsBytesFunc = f\n\treturn m.mock\n}", "func (mmAll *mStorageMockAll) Set(f func(ctx context.Context, pulse insolar.PulseNumber) (ja1 []insolar.JetID)) *StorageMock {\n\tif mmAll.defaultExpectation != nil {\n\t\tmmAll.mock.t.Fatalf(\"Default expectation is already set for the Storage.All method\")\n\t}\n\n\tif len(mmAll.expectations) > 0 {\n\t\tmmAll.mock.t.Fatalf(\"Some expectations are already set for the Storage.All method\")\n\t}\n\n\tmmAll.mock.funcAll = f\n\treturn mmAll.mock\n}", "func (mmGetDigestSize *mForkingDigesterMockGetDigestSize) Set(f func() (i1 int)) *ForkingDigesterMock {\n\tif mmGetDigestSize.defaultExpectation != nil {\n\t\tmmGetDigestSize.mock.t.Fatalf(\"Default expectation is already set for the ForkingDigester.GetDigestSize method\")\n\t}\n\n\tif len(mmGetDigestSize.expectations) > 0 {\n\t\tmmGetDigestSize.mock.t.Fatalf(\"Some expectations are already set for the ForkingDigester.GetDigestSize method\")\n\t}\n\n\tmmGetDigestSize.mock.funcGetDigestSize = f\n\treturn mmGetDigestSize.mock\n}", "func (dt *StdTask) SetFunc(f func(id int64)) {\n dt.F = f\n}", "func (m *mParcelMockContext) Set(f func(p context.Context) (r context.Context)) *ParcelMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.ContextFunc = f\n\treturn m.mock\n}", "func (mmDone *mFlagMockDone) Set(f func(ctx context.Context, isDone func() bool)) *FlagMock {\n\tif mmDone.defaultExpectation != nil {\n\t\tmmDone.mock.t.Fatalf(\"Default expectation is already set for the Flag.Done method\")\n\t}\n\n\tif len(mmDone.expectations) > 0 {\n\t\tmmDone.mock.t.Fatalf(\"Some expectations are already set for the Flag.Done method\")\n\t}\n\n\tmmDone.mock.funcDone = f\n\treturn mmDone.mock\n}", "func (f Field) Set(x, y int, b bool) {\n\tf.s[y][x] = b\n}" ]
[ "0.6997543", "0.6944354", "0.68723893", "0.6836697", "0.6810442", "0.6802553", "0.67897075", "0.6762525", "0.6760551", "0.67147166", "0.6617839", "0.6598485", "0.65970314", "0.6589452", "0.65852654", "0.6581722", "0.65531677", "0.65484816", "0.6532592", "0.6514801", "0.6511436", "0.6504638", "0.6502308", "0.65022653", "0.64979494", "0.64901507", "0.6485143", "0.64821976", "0.6478481", "0.6451519", "0.64407474", "0.64360714", "0.64152324", "0.6392145", "0.6384799", "0.637073", "0.6370595", "0.63641816", "0.6360958", "0.63608295", "0.63594496", "0.6357302", "0.63570553", "0.6336978", "0.6331151", "0.63292223", "0.6318058", "0.6315303", "0.62829477", "0.6282127", "0.6280453", "0.6273241", "0.6268852", "0.6244348", "0.6240667", "0.62333626", "0.6223475", "0.6220123", "0.6219742", "0.621623", "0.62034595", "0.62001806", "0.6196031", "0.6191577", "0.6187235", "0.61865354", "0.6181943", "0.61745894", "0.6171664", "0.61700237", "0.61663175", "0.61528045", "0.6148918", "0.6147377", "0.6145432", "0.6143484", "0.6140721", "0.61368775", "0.61322707", "0.61305493", "0.6119668", "0.61146504", "0.6112424", "0.611157", "0.6110264", "0.6105213", "0.60996175", "0.60892195", "0.6084557", "0.6079498", "0.6078307", "0.6071924", "0.6067897", "0.6066008", "0.6062382", "0.60609037", "0.60534894", "0.6043509", "0.60433185", "0.6033482" ]
0.7359609
0
SetFloat64 sets f = x and returns f.
SetFloat64 устанавливает f = x и возвращает f.
func (f *Float) SetFloat64(x float64) *Float { f.doinit() C.mpf_set_d(&f.i[0], C.double(x)) return f }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (z *Float) SetFloat64(x float64) *Float {}", "func (z *Rat) SetFloat64(f float64) *Rat {}", "func (feature Feature) SetFieldFloat64(index int, value float64) {\n\tC.OGR_F_SetFieldDouble(feature.cval, C.int(index), C.double(value))\n}", "func (z *Big) SetFloat64(x float64) *Big {\n\tif x == 0 {\n\t\tvar sign form\n\t\tif math.Signbit(x) {\n\t\t\tsign = signbit\n\t\t}\n\t\treturn z.setZero(sign, 0)\n\t}\n\tif math.IsNaN(x) {\n\t\tvar sign form\n\t\tif math.Signbit(x) {\n\t\t\tsign = signbit\n\t\t}\n\t\treturn z.setNaN(0, qnan|sign, 0)\n\t}\n\tif math.IsInf(x, 0) {\n\t\tif math.IsInf(x, 1) {\n\t\t\tz.form = pinf\n\t\t} else {\n\t\t\tz.form = ninf\n\t\t}\n\t\treturn z\n\t}\n\n\t// The gist of the following is lifted from math/big/rat.go, but adapted for\n\t// base-10 decimals.\n\n\tconst expMask = 1<<11 - 1\n\tbits := math.Float64bits(x)\n\tmantissa := bits & (1<<52 - 1)\n\texp := int((bits >> 52) & expMask)\n\tif exp == 0 { // denormal\n\t\texp -= 1022\n\t} else { // normal\n\t\tmantissa |= 1 << 52\n\t\texp -= 1023\n\t}\n\n\tif mantissa == 0 {\n\t\treturn z.SetUint64(0)\n\t}\n\n\tshift := 52 - exp\n\tfor mantissa&1 == 0 && shift > 0 {\n\t\tmantissa >>= 1\n\t\tshift--\n\t}\n\n\tz.exp = 0\n\tz.form = finite | form(bits>>63)\n\n\tif shift > 0 {\n\t\tz.unscaled.SetUint64(uint64(shift))\n\t\tz.unscaled.Exp(c.FiveInt, &z.unscaled, nil)\n\t\tarith.Mul(&z.unscaled, &z.unscaled, mantissa)\n\t\tz.exp = -shift\n\t} else {\n\t\t// TODO(eric): figure out why this doesn't work for _some_ numbers. See\n\t\t// https://github.com/ericlagergren/decimal/issues/89\n\t\t//\n\t\t// z.compact = mantissa << uint(-shift)\n\t\t// z.precision = arith.Length(z.compact)\n\n\t\tz.compact = c.Inflated\n\t\tz.unscaled.SetUint64(mantissa)\n\t\tz.unscaled.Lsh(&z.unscaled, uint(-shift))\n\t}\n\treturn z.norm()\n}", "func (c *Configurator) Float64F(name string, value float64, usage string) *float64 {\n\tp := new(float64)\n\n\tc.Float64VarF(p, name, value, usage)\n\n\treturn p\n}", "func Float64F(name string, value float64, usage string) *float64 {\n\treturn Global.Float64F(name, value, usage)\n}", "func (instance *Instance) SetFloat64(fieldName string, value float64) error {\n\tfieldNameCStr := C.CString(fieldName)\n\tdefer C.free(unsafe.Pointer(fieldNameCStr))\n\n\tretcode := int(C.RTI_Connector_set_number_into_samples(unsafe.Pointer(instance.output.connector.native), instance.output.nameCStr, fieldNameCStr, C.double(value)))\n\treturn checkRetcode(retcode)\n}", "func (cv *ConVar) SetFloat64(value float64) error {\n\treturn cv.write(reflect.Float64, value, 2)\n}", "func (z *Float) SetUint64(x uint64) *Float {}", "func (c *Configurator) Float64VarF(p *float64, name string, value float64, usage string) {\n\tc.flag().Float64Var(p, name, value, usage)\n}", "func Float64(f *float64) float64 {\n\tif f == nil {\n\t\treturn 0\n\t}\n\treturn *f\n}", "func (f Float) Float64() float64 {\n\tpanic(\"not yet implemented\")\n}", "func Float64VarF(p *float64, name string, value float64, usage string) {\n\tGlobal.Float64VarF(p, name, value, usage)\n}", "func (fs *FlagSet) Float64Var(name string, def float64, usage string) *Float64Value {\n\tv := &Float64Value{\n\t\tname: name,\n\t\tfs: fs.fs,\n\t}\n\tfs.fs.Float64Var(&v.value, name, def, usage)\n\treturn v\n}", "func (z *Float) SetInt64(x int64) *Float {}", "func (f *Float) SetInt64(x int64) *Float {\n\tf.doinit()\n\tC.mpf_set_si(&f.i[0], C.long(x))\n\treturn f\n}", "func (f *Float64Value) Set(s string) error {\n\tv, err := strconv.ParseFloat(s, 64)\n\t*f = Float64Value(v)\n\treturn err\n}", "func (s *StressFlag) Float64(name string, def float64, usage string) *float64 {\n\tv := def\n\treturn &v\n}", "func (c *Configurator) Float64(name string, value float64, usage string) *float64 {\n\tp := new(float64)\n\n\tc.Float64Var(p, name, value, usage)\n\n\treturn p\n}", "func Float64(v *Value, def float64) float64 {\n\tf, err := v.Float64()\n\tif err != nil {\n\t\treturn def\n\t}\n\treturn f\n}", "func Float64(name string, value float64, usage string) *float64 {\n\treturn ex.FlagSet.Float64(name, value, usage)\n}", "func (f *Flagger) Float64(name, shorthand string, value float64, usage string) {\n\tf.cmd.Flags().Float64P(name, shorthand, value, usage)\n\tf.cfg.BindPFlag(name, f.cmd.Flags().Lookup(name))\n}", "func Float64(name string, value float64, usage string) *float64 {\n\treturn Global.Float64(name, value, usage)\n}", "func (s *Streamer) Float64(f float64) *Streamer {\n\tif s.Error != nil {\n\t\treturn s\n\t}\n\tif math.IsInf(f, 0) {\n\t\ts.Error = ErrFloatIsInfinity\n\t\treturn s\n\t}\n\tif math.IsNaN(f) {\n\t\ts.Error = ErrFloatIsNan\n\t\treturn s\n\t}\n\ts.onVal()\n\tfmt := byte('f')\n\tabs := math.Abs(f)\n\tif abs != 0 {\n\t\tif f > 0 {\n\t\t\tif f < 1e-6 || f >= 1e21 {\n\t\t\t\tfmt = 'e'\n\t\t\t}\n\t\t} else {\n\t\t\tif f > -1e-6 || f <= -1e21 {\n\t\t\t\tfmt = 'e'\n\t\t\t}\n\t\t}\n\t}\n\ts.buffer = strconv.AppendFloat(s.buffer, f, fmt, -1, 64)\n\tif fmt == 'e' {\n\t\tn := len(s.buffer)\n\t\tif n > 4 && s.buffer[n-4] == 'e' &&\n\t\t\ts.buffer[n-3] == '-' &&\n\t\t\ts.buffer[n-2] == '0' {\n\t\t\ts.buffer[n-2] = s.buffer[n-1]\n\t\t\ts.buffer = s.buffer[:n-1]\n\t\t}\n\t}\n\treturn s\n}", "func (cl *CommandLineInterface) Float64FlagOnFlagSet(flagSet *pflag.FlagSet, name string, shorthand *string, defaultValue *float64, description string) {\n\tif defaultValue == nil {\n\t\tcl.nilDefaults[name] = true\n\t\tdefaultValue = cl.Float64Me(0.0)\n\t}\n\tif shorthand != nil {\n\t\tcl.Flags[name] = flagSet.Float64P(name, string(*shorthand), *defaultValue, description)\n\t\treturn\n\t}\n\tcl.Flags[name] = flagSet.Float64(name, *defaultValue, description)\n}", "func (lus *LastUpdatedSelect) Float64X(ctx context.Context) float64 {\n\tv, err := lus.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func FloatFloat64(val float64) (out *big.Float, err error) {\n\tout = new(big.Float).SetFloat64(val)\n\treturn\n}", "func (f *Float) Set(x *Float) *Float {\n\tf.doinit()\n\tC.mpf_set(&f.i[0], &x.i[0])\n\treturn f\n}", "func Float64(name string, value float64, usage string) *float64 {\n\tp := new(float64);\n\tFloat64Var(p, name, value, usage);\n\treturn p;\n}", "func setFloat(data [2]string, f func(float64)) error {\n\tval, err := strconv.ParseFloat(strings.TrimSpace(data[1]), 64)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"code %s: %s\", data[0], err.Error())\n\t}\n\tf(val)\n\treturn nil\n}", "func (x *Rat) Float64() (f float64, exact bool) {}", "func (c *Color) SetFloat64(r, g, b, a float64) {\n\tc.SetUInt8(uint8(r*255.0), uint8(g*255.0), uint8(b*255.0), uint8(a*255.0))\n}", "func (nims *NetInterfaceModeSelect) Float64X(ctx context.Context) float64 {\n\tv, err := nims.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (wfs *WithFieldsSelect) Float64X(ctx context.Context) float64 {\n\tv, err := wfs.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (ss *ServerSelect) Float64X(ctx context.Context) float64 {\n\tv, err := ss.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (fds *FurnitureDetailSelect) Float64X(ctx context.Context) float64 {\n\tv, err := fds.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (v *Value) Float64() float64 {\n\tswitch {\n\tcase v.fvalOk:\n\tcase v.ivalOk:\n\t\tv.fval = float64(v.ival)\n\t\tv.fvalOk = true\n\tcase v.svalOk:\n\t\t// Perform a best-effort conversion from string to float64.\n\t\tv.fval = 0.0\n\t\tstrs := matchFloat.FindStringSubmatch(v.sval)\n\t\tif len(strs) >= 2 {\n\t\t\tv.fval, _ = strconv.ParseFloat(strs[1], 64)\n\t\t}\n\t\tv.fvalOk = true\n\t}\n\treturn v.fval\n}", "func (v *Float64Value) Set(target *float64) {\n\tif v.fs.Changed(v.name) {\n\t\t*target = v.value\n\t}\n}", "func (p *PoolAllocator) Float64() Floating {\n\ts := p.f64.Get().(*f64)\n\ts.channels = channels(p.Channels)\n\ts.buffer = s.buffer[:p.Length*p.Channels]\n\treturn s\n}", "func Float64(f *float64, title, id, class string, min, max, step float64, valid Validator) (jquery.JQuery, error) {\n\tj := jq(\"<input>\").AddClass(ClassPrefix + \"-float64\").AddClass(class)\n\tj.SetAttr(\"title\", title).SetAttr(\"id\", id)\n\tj.SetAttr(\"type\", \"number\")\n\tif !math.IsNaN(min) {\n\t\tj.SetAttr(\"min\", min)\n\t}\n\tif !math.IsNaN(max) {\n\t\tj.SetAttr(\"max\", max)\n\t}\n\tif !math.IsNaN(step) {\n\t\tj.SetAttr(\"step\", step)\n\t}\n\tj.SetAttr(\"value\", *f)\n\tj.SetData(\"prev\", *f)\n\tj.Call(jquery.CHANGE, func(event jquery.Event) {\n\t\tval := event.Target.Get(\"value\").String()\n\t\tnewF, e := strconv.ParseFloat(val, 64)\n\t\tif e != nil {\n\t\t\tpanic(fmt.Errorf(\"value '%s' has invalid type, expected a number\", val))\n\t\t}\n\t\tj.SetVal(newF)\n\t\t// Need to check for min and max ourselves because html min and max are easy to get around\n\t\tisValid := valid == nil || valid.Validate(newF)\n\t\tisToLow := !math.IsNaN(min) && newF < min\n\t\tisToHigh := !math.IsNaN(max) && newF > max\n\t\tif !isValid || isToLow || isToHigh {\n\t\t\tnewF = j.Data(\"prev\").(float64)\n\t\t\tj.SetVal(newF)\n\t\t}\n\t\t*f = newF\n\t\tj.SetData(\"prev\", newF)\n\t})\n\treturn j, nil\n}", "func (rls *RuleLimitSelect) Float64X(ctx context.Context) float64 {\n\tv, err := rls.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (uls *UserLogSelect) Float64X(ctx context.Context) float64 {\n\tv, err := uls.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func FloatSet(z *big.Float, x *big.Float,) *big.Float", "func (form *FormData) Float64(key string, target *float64, defaultValue float64) *FormData {\n\treturn form.mustValue(key, target, defaultValue)\n}", "func Float64Val(f *float64) float64 {\n\tif f == nil {\n\t\treturn 0.0\n\t}\n\treturn *f\n}", "func (lbs *LatestBlockSelect) Float64X(ctx context.Context) float64 {\n\tv, err := lbs.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (ous *OrgUnitSelect) Float64X(ctx context.Context) float64 {\n\tv, err := ous.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (v Float) Float64() float64 {\n\treturn v.v\n}", "func (z *Big) SetFloat(x *big.Float) *Big {\n\tif x.IsInf() {\n\t\tif x.Signbit() {\n\t\t\tz.form = ninf\n\t\t} else {\n\t\t\tz.form = pinf\n\t\t}\n\t\treturn z\n\t}\n\n\tneg := x.Signbit()\n\tif x.Sign() == 0 {\n\t\tif neg {\n\t\t\tz.form |= signbit\n\t\t}\n\t\tz.compact = 0\n\t\tz.precision = 1\n\t\treturn z\n\t}\n\n\tz.exp = 0\n\tx0 := new(big.Float).Copy(x).SetPrec(big.MaxPrec)\n\tx0.Abs(x0)\n\tif !x.IsInt() {\n\t\tfor !x0.IsInt() {\n\t\t\tx0.Mul(x0, c.TenFloat)\n\t\t\tz.exp--\n\t\t}\n\t}\n\n\tif mant, acc := x0.Uint64(); acc == big.Exact {\n\t\tz.compact = mant\n\t\tz.precision = arith.Length(mant)\n\t} else {\n\t\tz.compact = c.Inflated\n\t\tx0.Int(&z.unscaled)\n\t\tz.precision = arith.BigLength(&z.unscaled)\n\t}\n\tz.form = finite\n\tif neg {\n\t\tz.form |= signbit\n\t}\n\treturn z\n}", "func MakeFloat64(x float64) Value {\n\treturn constant.MakeFloat64(x)\n}", "func (c *Const) Float64() float64 {\n\tf, _ := constant.Float64Val(c.Value)\n\treturn f\n}", "func (ups *UnsavedPostSelect) Float64X(ctx context.Context) float64 {\n\tv, err := ups.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func UseFloat64(f *float64) float64 {\n\tif f == nil {\n\t\treturn 0\n\t}\n\treturn *f\n}", "func (ws *WorkflowSelect) Float64X(ctx context.Context) float64 {\n\tv, err := ws.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func NewFloat(x float64) *Float { return new(Float).SetFloat64(x) }", "func (i *InsertFactBuilder) OFloat64(f float64, unitID uint64) *InsertFactBuilder {\n\ti.fact.Object = AFloat64(f, unitID)\n\treturn i\n}", "func SetFloat64Value(cfg *viper.Viper, name string, v *float64) {\n\tif cfg.IsSet(name) {\n\t\t*v = cfg.GetFloat64(name)\n\t}\n}", "func (bw *BufWriter) Float64(f float64) {\n\tif bw.Error != nil {\n\t\treturn\n\t}\n\tbw.stringBuf, bw.Error = Float64(f, bw.stringBuf[:0])\n\tif bw.Error != nil {\n\t\treturn\n\t}\n\t_, bw.Error = bw.writer.Write(bw.stringBuf)\n}", "func (sis *SubItemSelect) Float64X(ctx context.Context) float64 {\n\tv, err := sis.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (ws *WifiSelect) Float64X(ctx context.Context) float64 {\n\tv, err := ws.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (wews *WorkflowEventsWaitSelect) Float64X(ctx context.Context) float64 {\n\tv, err := wews.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (c *Configurator) Float64Var(p *float64, name string, value float64, usage string) {\n\tc.env().Float64Var(p, name, value, usage)\n\tc.flag().Float64Var(p, name, value, usage)\n}", "func (f Float64) Float64(_ context.Context) (*float64, error) {\n\tif f > 0 {\n\t\tvalue := float64(f)\n\t\treturn &value, nil\n\t}\n\treturn nil, nil\n}", "func (rs *RentSelect) Float64X(ctx context.Context) float64 {\n\tv, err := rs.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (fs *ForumSelect) Float64X(ctx context.Context) float64 {\n\tv, err := fs.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func Float64(v float64) *float64 {\n\treturn &v\n}", "func Float64(v float64) *float64 {\n\treturn &v\n}", "func Float64(v float64) *float64 {\n\treturn &v\n}", "func Float64(v float64) *float64 {\n\treturn &v\n}", "func Float64(v float64) *float64 {\n\treturn &v\n}", "func (gs *GoodsSelect) Float64X(ctx context.Context) float64 {\n\tv, err := gs.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (wts *WorkerTypeSelect) Float64X(ctx context.Context) float64 {\n\tv, err := wts.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (rs *RemedySelect) Float64X(ctx context.Context) float64 {\n\tv, err := rs.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (feature Feature) SetFieldFloat64List(index int, value []float64) {\n\tC.OGR_F_SetFieldDoubleList(\n\t\tfeature.cval,\n\t\tC.int(index),\n\t\tC.int(len(value)),\n\t\t(*C.double)(unsafe.Pointer(&value[0])),\n\t)\n}", "func (nss *NamespaceSecretSelect) Float64X(ctx context.Context) float64 {\n\tv, err := nss.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func Float64Var(p *float64, name string, value float64, usage string) {\n\tex.FlagSet.Float64Var(p, name, value, usage)\n}", "func (es *EntitySelect) Float64X(ctx context.Context) float64 {\n\tv, err := es.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (ws *WidgetSelect) Float64X(ctx context.Context) float64 {\n\tv, err := ws.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (z *Float) Set(x *Float) *Float {}", "func (hs *HarborSelect) Float64X(ctx context.Context) float64 {\n\tv, err := hs.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (z *Float64) Set(y *Float64) *Float64 {\n\tz.l = y.l\n\tz.r = y.r\n\treturn z\n}", "func (bs *BrowserSelect) Float64X(ctx context.Context) float64 {\n\tv, err := bs.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (h *Float64GaugeHandle) Set(ctx context.Context, value float64) {\n\th.RecordOne(ctx, NewFloat64MeasurementValue(value))\n}", "func GetFloat64(key string, defaultValue float64) float64 {\n\treturn archaius.GetFloat64(key, defaultValue)\n}", "func (s *selector) Float64X(ctx context.Context) float64 {\n\tv, err := s.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (c Context) Float64(key string, f float64) Context {\n\tc.l.context = appendFloat64(c.l.context, key, f)\n\treturn c\n}", "func GetFloat64(v interface{}) float64 {\n\treturn cache2.GetFloat64(v)\n}", "func Float64() float64 {\n\tmu.Lock()\n\tres := r.Float64()\n\tmu.Unlock()\n\treturn res\n}", "func Float64(f *frm.Field, inp ...string) {\n\tnum, err := strconv.ParseFloat(strings.TrimSpace(inp[0]), 64)\n\tf.Value = num\n\tif err != nil {\n\t\t//Return error if input string failed to convert.\n\t\tf.Err = err.Error()\n\t\treturn\n\t}\n\n\tif !f.Required && num == 0 {\n\t\t//f.ValueFloat64 is zero by default so assigning zero isn't required\n\t\treturn\n\t}\n\n\tif f.Min != nil && num < f.Min.(float64) || f.Max != nil && num > f.Max.(float64) {\n\t\tf.Err = fmt.Sprintf(\"Must be between %v and %v.\", f.Min, f.Max)\n\t\treturn\n\t}\n\n\tif rem := toFixed(math.Mod(num, float64(f.Step)), 6); rem != 0 {\n\t\tf.Err = fmt.Sprintf(\"Please enter a valid value. The two nearest values are %v and %v.\", num-rem, num-rem+float64(f.Step))\n\t}\n}", "func (des *DentalExpenseSelect) Float64X(ctx context.Context) float64 {\n\tv, err := des.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (x *Float) Float64() (float64, Accuracy) {\n\t// possible: panic(\"unreachable\")\n}", "func (wfs *WithFieldsSelect) Float64(ctx context.Context) (_ float64, err error) {\n\tvar v []float64\n\tif v, err = wfs.Float64s(ctx); err != nil {\n\t\treturn\n\t}\n\tswitch len(v) {\n\tcase 1:\n\t\treturn v[0], nil\n\tcase 0:\n\t\terr = &NotFoundError{withfields.Label}\n\tdefault:\n\t\terr = fmt.Errorf(\"ent: WithFieldsSelect.Float64s returned %d results when one was expected\", len(v))\n\t}\n\treturn\n}", "func (s *Smpval) SetFloat(f float64) bool {\n\tif s.flag == Float && s.val.CanSet() {\n\t\ts.val.SetFloat(f)\n\t\ts.f = s.val.Float()\n\t\treturn true\n\t}\n\treturn false\n}", "func (lus *LastUpdatedSelect) Float64(ctx context.Context) (_ float64, err error) {\n\tvar v []float64\n\tif v, err = lus.Float64s(ctx); err != nil {\n\t\treturn\n\t}\n\tswitch len(v) {\n\tcase 1:\n\t\treturn v[0], nil\n\tcase 0:\n\t\terr = &NotFoundError{lastupdated.Label}\n\tdefault:\n\t\terr = fmt.Errorf(\"ent: LastUpdatedSelect.Float64s returned %d results when one was expected\", len(v))\n\t}\n\treturn\n}", "func (vs *VehicleSelect) Float64X(ctx context.Context) float64 {\n\tv, err := vs.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (w *Writer) Float64(n float64) {\n\tw.buf = strconv.AppendFloat(w.buf, float64(n), 'g', -1, 64)\n}", "func (kss *KqiSourceSelect) Float64X(ctx context.Context) float64 {\n\tv, err := kss.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (irs *InstanceRuntimeSelect) Float64X(ctx context.Context) float64 {\n\tv, err := irs.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (oups *OrgUnitPositionSelect) Float64X(ctx context.Context) float64 {\n\tv, err := oups.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (das *DrugAllergySelect) Float64X(ctx context.Context) float64 {\n\tv, err := das.Float64(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}" ]
[ "0.8342938", "0.7686479", "0.74044406", "0.7318797", "0.72632647", "0.7162008", "0.70200455", "0.6996254", "0.6969324", "0.68820095", "0.6860794", "0.6838876", "0.6828565", "0.68112725", "0.67913413", "0.67847276", "0.6707692", "0.6673483", "0.6649437", "0.6638445", "0.6635289", "0.6626136", "0.6597599", "0.6597538", "0.65898097", "0.6588858", "0.65847737", "0.65765554", "0.6547731", "0.6527069", "0.65032786", "0.6488646", "0.6476064", "0.6471817", "0.6445718", "0.64445347", "0.6438429", "0.6430286", "0.6420958", "0.64071167", "0.6370351", "0.63627595", "0.6356654", "0.6354152", "0.6333643", "0.6331123", "0.63294554", "0.63122636", "0.6304543", "0.6299676", "0.6296096", "0.62861717", "0.6281666", "0.6275125", "0.62748945", "0.62742496", "0.6273722", "0.62736964", "0.6270786", "0.62618953", "0.62607026", "0.6256282", "0.62557006", "0.6251011", "0.6243906", "0.62412894", "0.62412894", "0.62412894", "0.62412894", "0.62412894", "0.62366235", "0.62339115", "0.62217885", "0.62195516", "0.621224", "0.62045914", "0.6198015", "0.6195679", "0.61917126", "0.61916584", "0.6184697", "0.6182889", "0.6182163", "0.6173758", "0.61676025", "0.61439997", "0.6141855", "0.61266875", "0.6115024", "0.6114511", "0.6114153", "0.6109333", "0.61054546", "0.61039025", "0.6099645", "0.60944253", "0.60917157", "0.6082114", "0.60789675", "0.6065443" ]
0.85616565
0
SetString interprets s as a number in the given base and sets f to that value. The base must be in the range [2,36]. SetString returns an error if s cannot be parsed or the base is invalid.
SetString интерпретирует s как число в заданной системе счисления и устанавливает f в этом значение. Система счисления должна быть в диапазоне [2,36]. SetString возвращает ошибку, если s не может быть проанализирован или система счисления недействительна.
func (f *Float) SetString(s string, base int) error { f.doinit() if base < 2 || base > 36 { return os.ErrInvalid } p := C.CString(s) defer C.free(unsafe.Pointer(p)) if C.mpf_set_str(&f.i[0], p, C.int(base)) < 0 { return os.ErrInvalid } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (z *Int) SetString(s string, base int) (*Int, bool) {}", "func IntSetString(z *big.Int, s string, base int) (*big.Int, bool)", "func SetString(z *big.Int, s string, base int) (*big.Int, bool) {\n\treturn z.SetString(s, base)\n}", "func (e *Eth) SetString(s string, base int) (*Eth, bool) {\n\tw, ok := e.ToInt().SetString(s, base)\n\treturn (*Eth)(w), ok\n}", "func FloatSetString(z *big.Float, s string) (*big.Float, bool)", "func (f *Float32Value) Set(s string) error {\n\tv, err := strconv.ParseFloat(s, 32)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*f = Float32Value(float32(v))\n\treturn err\n}", "func (b *baseValue) Set(s string) error {\n\tif err := b.validationFunc(s); err != nil {\n\t\treturn err\n\t}\n\tb.value = s\n\treturn nil\n}", "func (z *Element22) SetString(s string) *Element22 {\n\tx, ok := new(big.Int).SetString(s, 10)\n\tif !ok {\n\t\tpanic(\"Element22.SetString failed -> can't parse number in base10 into a big.Int\")\n\t}\n\treturn z.SetBigInt(x)\n}", "func (me *TSAFPTUNNumber) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (l *Link) SetString(s string, base int) (*Link, bool) {\n\tw, ok := (*big.Int)(l).SetString(s, base)\n\treturn (*Link)(w), ok\n}", "func (f *Float64Value) Set(s string) error {\n\tv, err := strconv.ParseFloat(s, 64)\n\t*f = Float64Value(v)\n\treturn err\n}", "func (b *Array) SetString(s string, base int) (*Array, bool) {\n\t_, succ := b.Int.SetString(s, base)\n\treturn b, succ\n}", "func setBigRatFromFloatString(s string) (br BigRat, err error) {\n\t// Be safe: Verify that it is floating-point, because otherwise\n\t// we need to honor ibase.\n\tif !strings.ContainsAny(s, \".eE\") {\n\t\t// Most likely a number like \"08\".\n\t\tErrorf(\"bad number syntax: %s\", s)\n\t}\n\tvar ok bool\n\tr, ok := big.NewRat(0, 1).SetString(s)\n\tif !ok {\n\t\treturn BigRat{}, errors.New(\"floating-point number syntax\")\n\t}\n\treturn BigRat{r}, nil\n}", "func (me *TSAFTaxonomyCode) Set(s string) { (*xsdt.Integer)(me).Set(s) }", "func (me *TSAFPTPortugueseVatNumber) Set(s string) { (*xsdt.Integer)(me).Set(s) }", "func (i *IntValue) Set(s string) error {\n\tv, err := strconv.ParseInt(s, 0, 64)\n\t*i = IntValue(v)\n\treturn err\n}", "func ParseFloat(s string, base int, prec uint, mode RoundingMode) (f *Float, b int, err error) {}", "func setFloat(data [2]string, f func(float64)) error {\n\tval, err := strconv.ParseFloat(strings.TrimSpace(data[1]), 64)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"code %s: %s\", data[0], err.Error())\n\t}\n\tf(val)\n\treturn nil\n}", "func ParseFloat(s string, base int, prec uint, mode big.RoundingMode,) (*big.Float, int, error)", "func (s *Size) Set(str string) error {\n\tswitch str[len(str)-1] {\n\tcase 'b', 'B':\n\t\tstr = str[:len(str)-1]\n\t}\n\n\tfactor := 0\n\tswitch str[len(str)-1] {\n\tcase 'k', 'K':\n\t\tfactor = 10\n\t\tstr = str[:len(str)-1]\n\tcase 'm', 'M':\n\t\tfactor = 20\n\t\tstr = str[:len(str)-1]\n\tcase 'g', 'G':\n\t\tfactor = 30\n\t\tstr = str[:len(str)-1]\n\t}\n\n\tt, err := strconv.Atoi(str)\n\tif err != nil {\n\t\treturn err\n\t}\n\t*s = Size(t << factor)\n\treturn nil\n}", "func (e *Encoder) SetBase(i int) {\n\tif i < 2 {\n\t\ti = 2\n\t}\n\te.base = i\n}", "func (u256 *Uint256) Set(s string) error {\n\t// TODO It would be really nice to give more guidance here, e.g. the number\n\t// TODO is too big vs simply invalid.\n\tint, ok := math.ParseBig256(s)\n\tif !ok || len(s) == 0 || int.Sign() == -1 {\n\t\treturn fmt.Errorf(\n\t\t\t\"[%v] must be a positive 256-bit or smaller hex or decimal string\",\n\t\t\ts,\n\t\t)\n\t}\n\n\tu256.Uint = int\n\treturn nil\n}", "func parseInt(s string, base int) (Value, error) {\n\tvar n int64\n\tvar err error\n\tvar cutoff, maxVal int64\n\tvar sign bool\n\ti := 0\n\n\tif len(s) < 1 {\n\t\terr = strconv.ErrSyntax\n\t\tgoto Error\n\t}\n\n\tswitch s[0] {\n\tcase '-':\n\t\tsign = true\n\t\ts = s[1:]\n\tcase '+':\n\t\ts = s[1:]\n\t}\n\n\tif len(s) < 1 {\n\t\terr = strconv.ErrSyntax\n\t\tgoto Error\n\t}\n\n\t// Look for hex prefix.\n\tif s[0] == '0' && len(s) > 1 && (s[1] == 'x' || s[1] == 'X') {\n\t\tif base == 0 || base == 16 {\n\t\t\tbase = 16\n\t\t\ts = s[2:]\n\t\t}\n\t}\n\n\tswitch {\n\tcase len(s) < 1:\n\t\terr = strconv.ErrSyntax\n\t\tgoto Error\n\n\tcase 2 <= base && base <= 36:\n\t// valid base; nothing to do\n\n\tcase base == 0:\n\t\t// Look for hex prefix.\n\t\tswitch {\n\t\tcase s[0] == '0' && len(s) > 1 && (s[1] == 'x' || s[1] == 'X'):\n\t\t\tif len(s) < 3 {\n\t\t\t\terr = strconv.ErrSyntax\n\t\t\t\tgoto Error\n\t\t\t}\n\t\t\tbase = 16\n\t\t\ts = s[2:]\n\t\tdefault:\n\t\t\tbase = 10\n\t\t}\n\n\tdefault:\n\t\terr = errors.New(\"invalid base \" + strconv.Itoa(base))\n\t\tgoto Error\n\t}\n\n\t// Cutoff is the smallest number such that cutoff*base > maxInt64.\n\t// Use compile-time constants for common cases.\n\tswitch base {\n\tcase 10:\n\t\tcutoff = math.MaxInt64/10 + 1\n\tcase 16:\n\t\tcutoff = math.MaxInt64/16 + 1\n\tdefault:\n\t\tcutoff = math.MaxInt64/int64(base) + 1\n\t}\n\n\tmaxVal = math.MaxInt64\n\tfor ; i < len(s); i++ {\n\t\tif n >= cutoff {\n\t\t\t// n*base overflows\n\t\t\treturn parseLargeInt(float64(n), s[i:], base, sign)\n\t\t}\n\t\tv := digitVal(s[i])\n\t\tif v >= base {\n\t\t\tbreak\n\t\t}\n\t\tn *= int64(base)\n\n\t\tn1 := n + int64(v)\n\t\tif n1 < n || n1 > maxVal {\n\t\t\t// n+v overflows\n\t\t\treturn parseLargeInt(float64(n)+float64(v), s[i+1:], base, sign)\n\t\t}\n\t\tn = n1\n\t}\n\n\tif i == 0 {\n\t\terr = strconv.ErrSyntax\n\t\tgoto Error\n\t}\n\n\tif sign {\n\t\tn = -n\n\t}\n\treturn intToValue(n), nil\n\nError:\n\treturn _NaN, err\n}", "func SetValueFromStr(value reflect.Value, s string) error {\n\tswitch value.Interface().(type) {\n\tcase bool:\n\t\tval, err := strconv.ParseBool(s)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tvalue.SetBool(val)\n\tcase float32:\n\t\tval, err := strconv.ParseFloat(s, 32)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tvalue.SetFloat(val)\n\tcase float64:\n\t\tval, err := strconv.ParseFloat(s, 64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tvalue.SetFloat(val)\n\tcase int, int32:\n\t\tval, err := strconv.ParseInt(s, 10, 32)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tvalue.SetInt(val)\n\tcase int8:\n\t\tval, err := strconv.ParseInt(s, 10, 8)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tvalue.SetInt(val)\n\tcase int16:\n\t\tval, err := strconv.ParseInt(s, 10, 16)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tvalue.SetInt(val)\n\tcase int64:\n\t\tval, err := strconv.ParseInt(s, 10, 64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tvalue.SetInt(val)\n\tcase uint, uint32:\n\t\tval, err := strconv.ParseUint(s, 10, 32)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tvalue.SetUint(val)\n\tcase uint8:\n\t\tval, err := strconv.ParseUint(s, 10, 8)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tvalue.SetUint(val)\n\tcase uint16:\n\t\tval, err := strconv.ParseUint(s, 10, 16)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tvalue.SetUint(val)\n\tcase uint64:\n\t\tval, err := strconv.ParseUint(s, 10, 16)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tvalue.SetUint(val)\n\tcase string:\n\t\tvalue.SetString(s)\n\tcase []byte:\n\t\tvalue.SetBytes([]byte(s))\n\tcase []int32:\n\t\tvar val []int32\n\t\tvar err = json.Unmarshal([]byte(s), &val)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tvalue.Set(reflect.ValueOf(val))\n\tdefault:\n\t\treturn fmt.Errorf(\"unkown-type :%v\", reflect.TypeOf(value))\n\t}\n\treturn nil\n}", "func (v *T) Set(s string) error {\n\tintV, err := strconv.ParseUint(s, 10, 32)\n\tif err != nil {\n\t\treturn err\n\t}\n\t*v = T(intV)\n\treturn nil\n}", "func (v *Value10) Set(s string) error {\n\tz, err := Parse10(s)\n\tif err == nil {\n\t\t*v = Value10(z)\n\t}\n\treturn err\n}", "func (c *Color) SetString(str string, base color.Color) error {\n\tif len(str) == 0 { // consider it null\n\t\tc.SetToNil()\n\t\treturn nil\n\t}\n\t// pr := prof.Start(\"Color.SetString\")\n\t// defer pr.End()\n\tlstr := strings.ToLower(str)\n\tswitch {\n\tcase lstr[0] == '#':\n\t\treturn c.ParseHex(str)\n\tcase strings.HasPrefix(lstr, \"hsl(\"):\n\t\tval := lstr[4:]\n\t\tval = strings.TrimRight(val, \")\")\n\t\tformat := \"%d,%d,%d\"\n\t\tvar h, s, l int\n\t\tfmt.Sscanf(val, format, &h, &s, &l)\n\t\tc.SetHSL(float32(h), float32(s)/100.0, float32(l)/100.0)\n\tcase strings.HasPrefix(lstr, \"rgb(\"):\n\t\tval := lstr[4:]\n\t\tval = strings.TrimRight(val, \")\")\n\t\tval = strings.Trim(val, \"%\")\n\t\tvar r, g, b, a int\n\t\ta = 255\n\t\tformat := \"%d,%d,%d\"\n\t\tif strings.Count(val, \",\") == 4 {\n\t\t\tformat = \"%d,%d,%d,%d\"\n\t\t\tfmt.Sscanf(val, format, &r, &g, &b, &a)\n\t\t} else {\n\t\t\tfmt.Sscanf(val, format, &r, &g, &b)\n\t\t}\n\t\tc.SetUInt8(uint8(r), uint8(g), uint8(b), uint8(a))\n\tcase strings.HasPrefix(lstr, \"rgba(\"):\n\t\tval := lstr[5:]\n\t\tval = strings.TrimRight(val, \")\")\n\t\tval = strings.Trim(val, \"%\")\n\t\tvar r, g, b, a int\n\t\tformat := \"%d,%d,%d,%d\"\n\t\tfmt.Sscanf(val, format, &r, &g, &b, &a)\n\t\tc.SetUInt8(uint8(r), uint8(g), uint8(b), uint8(a))\n\tcase strings.HasPrefix(lstr, \"pref(\"):\n\t\tval := lstr[5:]\n\t\tval = strings.TrimRight(val, \")\")\n\t\tclr := ThePrefs.PrefColor(val)\n\t\tif clr != nil {\n\t\t\t*c = *clr\n\t\t}\n\tdefault:\n\t\tif hidx := strings.Index(lstr, \"-\"); hidx > 0 {\n\t\t\tcmd := lstr[:hidx]\n\t\t\tpctstr := lstr[hidx+1:]\n\t\t\tpct, gotpct := kit.ToFloat32(pctstr)\n\t\t\tswitch cmd {\n\t\t\tcase \"lighter\":\n\t\t\t\tcvtPctStringErr(gotpct, pctstr)\n\t\t\t\tif base != nil {\n\t\t\t\t\tc.SetColor(base)\n\t\t\t\t}\n\t\t\t\tc.SetColor(c.Lighter(pct))\n\t\t\t\treturn nil\n\t\t\tcase \"darker\":\n\t\t\t\tcvtPctStringErr(gotpct, pctstr)\n\t\t\t\tif base != nil {\n\t\t\t\t\tc.SetColor(base)\n\t\t\t\t}\n\t\t\t\tc.SetColor(c.Darker(pct))\n\t\t\t\treturn nil\n\t\t\tcase \"highlight\":\n\t\t\t\tcvtPctStringErr(gotpct, pctstr)\n\t\t\t\tif base != nil {\n\t\t\t\t\tc.SetColor(base)\n\t\t\t\t}\n\t\t\t\tc.SetColor(c.Highlight(pct))\n\t\t\t\treturn nil\n\t\t\tcase \"samelight\":\n\t\t\t\tcvtPctStringErr(gotpct, pctstr)\n\t\t\t\tif base != nil {\n\t\t\t\t\tc.SetColor(base)\n\t\t\t\t}\n\t\t\t\tc.SetColor(c.Samelight(pct))\n\t\t\t\treturn nil\n\t\t\tcase \"saturate\":\n\t\t\t\tcvtPctStringErr(gotpct, pctstr)\n\t\t\t\tif base != nil {\n\t\t\t\t\tc.SetColor(base)\n\t\t\t\t}\n\t\t\t\tc.SetColor(c.Saturate(pct))\n\t\t\t\treturn nil\n\t\t\tcase \"pastel\":\n\t\t\t\tcvtPctStringErr(gotpct, pctstr)\n\t\t\t\tif base != nil {\n\t\t\t\t\tc.SetColor(base)\n\t\t\t\t}\n\t\t\t\tc.SetColor(c.Pastel(pct))\n\t\t\t\treturn nil\n\t\t\tcase \"clearer\":\n\t\t\t\tcvtPctStringErr(gotpct, pctstr)\n\t\t\t\tif base != nil {\n\t\t\t\t\tc.SetColor(base)\n\t\t\t\t}\n\t\t\t\tc.SetColor(c.Clearer(pct))\n\t\t\t\treturn nil\n\t\t\tcase \"opaquer\":\n\t\t\t\tcvtPctStringErr(gotpct, pctstr)\n\t\t\t\tif base != nil {\n\t\t\t\t\tc.SetColor(base)\n\t\t\t\t}\n\t\t\t\tc.SetColor(c.Opaquer(pct))\n\t\t\t\treturn nil\n\t\t\tcase \"blend\":\n\t\t\t\tif base != nil {\n\t\t\t\t\tc.SetColor(base)\n\t\t\t\t}\n\t\t\t\tclridx := strings.Index(pctstr, \"-\")\n\t\t\t\tif clridx < 0 {\n\t\t\t\t\terr := fmt.Errorf(\"gi.Color.SetString -- blend color spec not found -- format is: blend-PCT-color, got: %v -- PCT-color is: %v\", lstr, pctstr)\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tpctstr = lstr[hidx+1 : clridx]\n\t\t\t\tpct, gotpct = kit.ToFloat32(pctstr)\n\t\t\t\tcvtPctStringErr(gotpct, pctstr)\n\t\t\t\tclrstr := lstr[clridx+1:]\n\t\t\t\tothc, err := ColorFromString(clrstr, base)\n\t\t\t\tc.SetColor(c.Blend(pct, &othc))\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tswitch lstr {\n\t\tcase \"none\", \"off\":\n\t\t\tc.SetToNil()\n\t\t\treturn nil\n\t\tcase \"transparent\":\n\t\t\tc.SetUInt8(0xFF, 0xFF, 0xFF, 0)\n\t\t\treturn nil\n\t\tcase \"inverse\":\n\t\t\tif base != nil {\n\t\t\t\tc.SetColor(base)\n\t\t\t}\n\t\t\tc.SetColor(c.Inverse())\n\t\t\treturn nil\n\t\tdefault:\n\t\t\treturn c.SetName(lstr)\n\t\t}\n\t}\n\treturn nil\n}", "func FloatParse(z *big.Float, s string, base int) (*big.Float, int, error)", "func RatSetString(z *big.Rat, s string) (*big.Rat, bool)", "func setInt(data [2]string, f func(int)) error {\n\tval, err := strconv.ParseInt(strings.TrimSpace(data[1]), 10, 64)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"code %s: %s\", data[0], err.Error())\n\t}\n\tf(int(val))\n\treturn nil\n}", "func (me *TPositiveFloatType) Set(s string) { (*xsdt.Float)(me).Set(s) }", "func (i *uintValue) Set(s string) error {\n\tv, err := strconv.ParseUint(s, i.base, strconv.IntSize)\n\tif err != nil {\n\t\treturn err\n\t}\n\t*i.val = uint(v)\n\treturn err\n}", "func (ds *DigitString) SetDigitString(number string) error {\n\tif _, err := strconv.Atoi(number); err != nil {\n\t\treturn fmt.Errorf(\"invalid input is not a number: %s\", number)\n\t}\n\tds.digitString = number\n\treturn nil\n}", "func (f *transformingValue) Set(s string) error {\n\treturn f.Value.Set(f.fn(s))\n}", "func (me *TNumberOrPercentageType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (val *float32Value) Set(str string) error {\n\tv, err := strconv.ParseFloat(str, 32)\n\t*val = float32Value(v)\n\treturn errs.Wrap(err)\n}", "func (me *TNumbersType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (me *TFontFamilyValueType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (me *TSAFdecimalType) Set(s string) { (*xsdt.Decimal)(me).Set(s) }", "func (sf *String) Set(x string) error {\n\tsf.Value = x\n\tsf.set = true\n\treturn nil\n}", "func (me *TSAFmonetaryType) Set(s string) { (*xsdt.Decimal)(me).Set(s) }", "func (me *TNumberOptionalNumberType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func setPrimitive(val reflect.Value, s string) (err error) {\n\n\tswitch val.Type().Kind() {\n\t\tcase reflect.Bool:\n\t\t\tswitch strings.ToLower(s) {\n\t\t\t\tcase \"n\", \"no\", \"f\", \"false\", \"off\":\n\t\t\t\t\tval.SetBool(false)\n\t\t\t\tcase \"y\", \"yes\", \"t\", \"true\", \"on\", \"\":\n\t\t\t\t\tval.SetBool(true)\n\t\t\t\tdefault:\n\t\t\t\t\terr = fmt.Errorf(\"not a boolean value\")\n\t\t\t}\n\t\tcase reflect.Uint64:\n\t\t\tvar i uint64\n\t\t\tif i, err = convUint(s, 64); err == nil {\n\t\t\t\tval.SetUint(i)\n\t\t\t}\n\t\tcase reflect.Int64:\n\t\t\tswitch val.Type().String() {\n\t\t\tdefault:\n\t\t\t\tvar i int64\n\t\t\t\tif i, err = convInt(s, 64); err == nil {\n\t\t\t\t\tval.SetInt(i)\n\t\t\t\t}\n\t\t\t}\n\t\tcase reflect.Uint32:\n\t\t\tvar i uint64\n\t\t\tif i, err = convUint(s, 32); err == nil {\n\t\t\t\tval.SetUint(i)\n\t\t\t}\n\t\tcase reflect.Uint:\n\t\t\tvar i uint64\n\t\t\tif i, err = convUint(s, 0); err == nil {\n\t\t\t\tval.SetUint(i)\n\t\t\t}\n\t\tcase reflect.Int:\n\t\t\tvar i int64\n\t\t\tif i, err = convInt(s, 0); err == nil {\n\t\t\t\tval.SetInt(i)\n\t\t\t}\n\t\tcase reflect.Float64:\n\t\t\tvar fl float64\n\t\t\tif fl, err = convFloat(s); err == nil {\n\t\t\t\tval.SetFloat(fl)\n\t\t\t}\n\t\tcase reflect.String:\n\t\t\tif len(s) > 0 && s[0] == '\"' {\n\t\t\t\ts, err = strconv.Unquote(s)\n\t\t\t\tif err == nil {\n\t\t\t\t\tval.SetString(s)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tval.SetString(s)\n\t\tdefault:\n\t\t\terr = fmt.Errorf(\"unsupported type %s\",\n\t\t\t\t\t\tval.Type().String())\n\t}\n\treturn\n}", "func (i *Integer) FromString(s string) (err error) {\n\t_, ok := i.value.SetString(s, 10)\n\tif !ok {\n\t\terr = fmt.Errorf(\"'%s' is not a 10-based number\", s)\n\t}\n\treturn\n}", "func (n Number) BaseStringSigned(b int) string {\n\tres := n.BigIntSigned().Text(b)\n\tprefix, ok := map[int]string{2: \"0b\", 8: \"0\", 10: \"\", 16: \"0x\"}[b]\n\tif !ok {\n\t\tpanic(\"unknown base: \" + strconv.Itoa(b))\n\t}\n\tif strings.HasPrefix(res, \"-\") {\n\t\treturn res[:1] + prefix + res[1:]\n\t} else {\n\t\treturn prefix + res\n\t}\n}", "func (me *TBaselineShiftValueType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (me *TshapeEnumType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (t *TimeFormat) Set(s string) error {\n\tswitch s {\n\tcase \"unix-epoch\", \"0\":\n\t\t*t = FormatUnixEpoch\n\tcase \"rfc3339\", \"1\":\n\t\t*t = FormatRFC3339\n\tdefault:\n\t\treturn errors.New(`invalid TimeFormat: \"` + s + `\"`)\n\t}\n\treturn nil\n}", "func (me *TxsdFiscalYear) Set(s string) { (*xsdt.Integer)(me).Set(s) }", "func smallestGoodBase(n string) string {\n \n}", "func SetString(key string, val string) error {\n\terr := SetStringWithExpire(key, val, 0)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (z *E6) SetString(s1, s2, s3, s4, s5, s6 string) *E6 {\n\tz.B0.SetString(s1, s2)\n\tz.B1.SetString(s3, s4)\n\tz.B2.SetString(s5, s6)\n\treturn z\n}", "func (me *TunitsEnumType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (s *ss) convertFloat(str string, n int) float64 {\n\tif p := indexRune(str, 'p'); p >= 0 {\n\t\t// Atof doesn't handle power-of-2 exponents,\n\t\t// but they're easy to evaluate.\n\t\tf, err := strconv.ParseFloat(str[:p], n)\n\t\tif err != nil {\n\t\t\t// Put full string into error.\n\t\t\tif e, ok := err.(*strconv.NumError); ok {\n\t\t\t\te.Num = str\n\t\t\t}\n\t\t\ts.error(err)\n\t\t}\n\t\tm, err := strconv.Atoi(str[p+1:])\n\t\tif err != nil {\n\t\t\t// Put full string into error.\n\t\t\tif e, ok := err.(*strconv.NumError); ok {\n\t\t\t\te.Num = str\n\t\t\t}\n\t\t\ts.error(err)\n\t\t}\n\t\treturn math.Ldexp(f, m)\n\t}\n\tf, err := strconv.ParseFloat(str, n)\n\tif err != nil {\n\t\ts.error(err)\n\t}\n\treturn f\n}", "func (c Currency) Setf(f float64) Currency {\n\tfDPf := f * c.dpf\n\tr := int64(f * c.dpf)\n\tc.Valid = true\n\treturn c.Set(rnd(r, fDPf-float64(r)))\n}", "func (me *TStrokeMiterLimitValueType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (l *settableString) Set(s string) error {\n\tl.s = s\n\tl.isSet = true\n\treturn nil\n}", "func (me *TFontSizeValueType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (me *TSAFPTCNCode) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (me *TstyleStateEnumType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (v *Value2) Set(s string) error {\n\tz, err := Parse2(s)\n\tif err == nil {\n\t\t*v = Value2(z)\n\t}\n\treturn err\n}", "func setData(d *data, s string, x int) {\n\tswitch s {\n\tcase \"g\":\n\t\td.g = x\t\n\tcase \"m\":\n\t\td.m = x\n\tcase \"a\":\n\t\td.a = x\n\t}\n}", "func (me *TLengthsType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func ConvertFromDec(numS string, toBase int) (string, error) {\n\tif toBase < 2 {\n\t\treturn \"\", fmt.Errorf(\"Invalid base: %v\", toBase)\n\t}\n\tif numS == \"\" {\n\t\treturn \"\", fmt.Errorf(\"Nothing to convert\")\n\t}\n\t// Converting string to the number bigger than int64.\n\tbNum := big.NewInt(0)\n\tbNum, ok := bNum.SetString(numS, 10)\n\tif ok != true {\n\t\treturn \"\", fmt.Errorf(\"Invalid number: %v\", numS)\n\t}\n\tbZero := big.NewInt(0)\n\t// If original number is equal to \"0...0\".\n\tif bNum.Cmp(bZero) == 0 {\n\t\treturn \"0\", nil\n\t}\n\t// If the number is negativ: flagNeg = 1 and \"saving\" the negative sign.\n\tif bNum.Cmp(bZero) == -1 {\n\t\tflagNeg = 1\n\t\tbNum.Neg(bNum)\n\t}\n\t// Converting the number to needed base (toBase).\n\tvar newNum string\n\tbToBase := big.NewInt(int64(toBase))\n\tbReminder := big.NewInt(0)\n\tfor bNum.Cmp(bZero) != 0 {\n\t\tbNum.DivMod(bNum, bToBase, bReminder)\n\t\treminderHex := numToLetter(bReminder.Int64(), toBase)\n\t\tnewNum += reminderHex\n\t}\n\n\tif flagNeg != 0 {\n\t\t// If original number was negative - making new one negative too.\n\t\tnewNum += \"-\"\n\t\tflagNeg = 0\n\t}\n\t// Reversing the number.\n\tnumRunes := []rune(newNum)\n\tleft := 0\n\tright := len(numRunes) - 1\n\tfor left < len(numRunes)/2 {\n\t\tnumRunes[left], numRunes[right] = numRunes[right], numRunes[left]\n\t\tleft++\n\t\tright--\n\t}\n\n\treturn string(numRunes), nil\n}", "func (r *Replacement) Set(s string) error {\n\tparts := strings.Split(s, \":\")\n\tif len(parts) != 2 {\n\t\treturn errors.Errorf(\"invalid number of dash-separated parts in binary replacement; expected 2, got %d\", len(parts))\n\t}\n\tif err := r.Addr.Set(parts[0]); err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\tbuf, err := hex.DecodeString(parts[1])\n\tif err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\tr.Buf = buf\n\treturn nil\n}", "func (me *TFontSizeAdjustValueType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func ParseInt(s String, base Int) Int {\n\tresult, _ := strconv.ParseInt(string(s), int(base), 0)\n\treturn Int(result)\n}", "func (me *TLengthType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (v *Base) parseNumber(s string) (ok bool) {\n\tnum, err := strconv.ParseFloat(s, 64)\n\tif err == nil {\n\t\t*v = Base(num)\n\t\treturn v.IsValid()\n\t}\n\treturn false\n}", "func (z *E12) SetString(s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11 string) *E12 {\n\tz.C0.SetString(s0, s1, s2, s3, s4, s5)\n\tz.C1.SetString(s6, s7, s8, s9, s10, s11)\n\treturn z\n}", "func (me *TSAFPTAccountingPeriod) Set(s string) { (*xsdt.Integer)(me).Set(s) }", "func (me *TxsdTaxAccountingBasis) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (me *TxsdTspanTypeLengthAdjust) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (me *TaltitudeModeEnumType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func SetString(filename, JSONpath, value string) error {\n\tjf, err := NewFile(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn jf.SetString(JSONpath, value)\n}", "func (m *Money) Setf(f float64) *Money {\n\tfDPf := f * DPf\n\tr := int64(f * DPf)\n\treturn m.Set(Rnd(r, fDPf-float64(r)))\n}", "func (me *TcolorModeEnumType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func SetFromString(id string) ConfigOption {\n\t// YYMMDD GGGG C 8 L\n\t// |\n\t// legacy bit, always there, ignore.\n\tconst (\n\t\tdateIndex = 0\n\t\tdateLength = 6\n\t\tgenderIndex = 6\n\t\tgenderLength = 4\n\t\tcitizenIndex = 10\n\t\tcitizenLength = 1\n\t\tluhnIndex = 12\n\t\tluhnLength = 1\n\t\tidLength = 13\n\t)\n\n\treturn func(idNumber *IDNumber) error {\n\t\tif len(id) != idLength {\n\t\t\treturn ErrIncorrectIDStringLength\n\t\t}\n\t\tdateString := id[dateIndex : dateIndex+dateLength]\n\t\tt, err := time.Parse(\"060102\", dateString)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tidNumber.birthdate = t\n\n\t\tgenderCode, err := strconv.ParseInt(id[genderIndex:genderIndex+genderLength], 10, 32)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tidNumber.gender = GenderCode(genderCode)\n\n\t\tcitizenship, err := strconv.ParseInt(id[citizenIndex:citizenIndex+citizenLength], 10, 32)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tidNumber.citizenship = Citizenship(citizenship)\n\n\t\tluhnNumber, err := strconv.ParseInt(id[luhnIndex:luhnIndex+luhnLength], 10, 32)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tidNumber.luhnValue = int(luhnNumber)\n\t\treturn nil\n\t}\n}", "func formSample(s string) int{\n\tres,err := strconv.ParseInt(s,16,32)\n\tif err!=nil{\n\t\tpanic(err)\n\t}\n\treturn int(res)\n}", "func (me *TcolorType) Set(s string) { (*xsdt.HexBinary)(me).Set(s) }", "func (n Number) BaseStringUnsigned(b int) string {\n\tres := n.BigIntUnsigned().Text(b)\n\tprefix, ok := map[int]string{2: \"0b\", 8: \"0\", 10: \"\", 16: \"0x\"}[b]\n\tif !ok {\n\t\tpanic(\"unknown base: \" + strconv.Itoa(b))\n\t}\n\treturn prefix + res\n}", "func (me *TMaskValueType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (val *uint16Value) Set(str string) error {\n\tv, err := strconv.ParseUint(str, 0, 16)\n\t*val = uint16Value(v)\n\treturn errs.Wrap(err)\n}", "func tzsetNum(s string, min, max int) (num int, rest string, ok bool) {\n\tif len(s) == 0 {\n\t\treturn 0, \"\", false\n\t}\n\tnum = 0\n\tfor i, r := range s {\n\t\tif r < '0' || r > '9' {\n\t\t\tif i == 0 || num < min {\n\t\t\t\treturn 0, \"\", false\n\t\t\t}\n\t\t\treturn num, s[i:], true\n\t\t}\n\t\tnum *= 10\n\t\tnum += int(r) - '0'\n\t\tif num > max {\n\t\t\treturn 0, \"\", false\n\t\t}\n\t}\n\tif num < min {\n\t\treturn 0, \"\", false\n\t}\n\treturn num, \"\", true\n}", "func (me *TScriptType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func ConvertBase(uuid int64, base int64) (*string, error) {\n\t\n\tif uuid <= 0 || uuid >= 56800235584 { // 56800235584 is the max number that can be converted to base62 with 6 characters\n\t\treturn nil, errors.New(\"Cannot convert non-positive integers\")\n\t}\n\tif base <= 0 || base > 62 {\n\t\treturn nil, errors.New(\"Base must be in (0,62]\")\n\t}\n\n\tidx := 0\n\tnewBaseChars := []byte{'a','a','a','a','a','a'}\n\tdividend := uuid\n\tremainder := int64(0)\n\t// each time the base goes into the dividend add character in new base equal to the value of the remainder\n\tfor dividend > 0 && idx < 6 {\n\t\tremainder = int64(math.Mod(float64(dividend), float64(base)))\n\t\tdividend = dividend / base\n\t\t// change least significant characters first\n\t\tnewBaseChars[5-idx] = baseConversionChars[remainder]\n\t\tidx += 1\n\t}\n\n\tnewBaseStr := string(newBaseChars)\n\treturn &newBaseStr, nil\n}", "func (me *TSVGColorType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (me *TxsdComponentTransferFunctionAttributesType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func ParseBigInt(s string, base int) (*big.Int, error) {\n\tif base < 0 || base > 16 {\n\t\treturn nil, errors.New(\"ParseBigInt: invalid base\")\n\t}\n\ts = strings.Replace(s, \"\\n\", \"\", -1)\n\tz, ok := new(big.Int).SetString(s, base)\n\tif !ok {\n\t\treturn nil, errors.New(\"ParseBigInt: invalid string\")\n\t}\n\treturn z, nil\n}", "func ParseBigInt(s string, base int) (*big.Int, error) {\n\tif base < 0 || base > 16 {\n\t\treturn nil, errors.New(\"ParseBigInt: invalid base\")\n\t}\n\ts = strings.Replace(s, \"\\n\", \"\", -1)\n\tz, ok := new(big.Int).SetString(s, base)\n\tif !ok {\n\t\treturn nil, errors.New(\"ParseBigInt: invalid string\")\n\t}\n\treturn z, nil\n}", "func (z *Numeric) SetInt(x int) *Numeric {\n\tif x == 0 {\n\t\treturn z.SetZero()\n\t}\n\n\tif x < 0 {\n\t\tz.sign = numericNegative\n\t} else {\n\t\tz.sign = numericPositive\n\t}\n\n\tz.weight = -1\n\tz.digits = make([]int16, 0, 1) // as x!=0 there is at least 1 1000-base digit\n\tfor x != 0 {\n\t\td := mathh.AbsInt16(int16(x % numericBase))\n\t\tx /= numericBase\n\t\tif d != 0 || len(z.digits) > 0 { // avoid tailing zero\n\t\t\tz.digits = append([]int16{d}, z.digits...)\n\t\t}\n\t\tz.weight++\n\t}\n\n\treturn z\n}", "func (u *Util) StringToFloat(value interface{}) (number float32, err error) {\n number = -999\n if s,ok := value.(string); ok {\n price, err := strconv.ParseFloat(s, 32)\n if err == nil { number = float32(price) }\n } else {\n err = errors.New(\"variable is not string\")\n }\n return number, err\n}", "func (v *Uint64) Set(s string) error {\n\tx, err := ParseUint64(s)\n\tif err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\t*v = x\n\treturn nil\n}", "func (me *TdisplayModeEnumType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func FloatSetInt(z *big.Float, x *big.Int,) *big.Float", "func (obj *Value) SetString(v string) {\n\tobj.Candy().Guify(\"g_value_set_string\", obj, v)\n}", "func (f *fingerprint) setString(str string) {\n\tfor i, s := range strings.Split(str, \",\") {\n\t\tswitch i {\n\t\tcase 0: // question section domain name\n\t\t\tf.Query.Name = s\n\t\tcase 1: // Qclass\n\t\t\tf.Query.Qclass = 0\n\t\t\tif c, ok := dns.Str_class[s]; ok {\n\t\t\t\tf.Query.Qclass = c\n\t\t\t}\n\t\tcase 2: // Qtype\n\t\t\tf.Query.Qtype = 0\n\t\t\tif c, ok := dns.Str_rr[s]; ok {\n\t\t\t\tf.Query.Qtype = c\n\t\t\t}\n\t\tcase 3:\n\t\t\tif op, ok := dns.Str_opcode[s]; ok {\n\t\t\t\tf.Opcode = op\n\t\t\t} else { // number\n\t\t\t\tf.Opcode = valueOfString(s)\n\t\t\t}\n\t\tcase 4:\n\t\t\tif op, ok := dns.Str_rcode[s]; ok {\n\t\t\t\tf.Rcode = op\n\t\t\t} else { // number\n\t\t\t\tf.Rcode = valueOfString(s)\n\t\t\t}\n\t\tcase 5:\n\t\t\tf.Response = s == strings.ToUpper(\"qr\")\n\t\tcase 6:\n\t\t\tf.Authoritative = s == strings.ToUpper(\"aa\")\n\t\tcase 7:\n\t\t\tf.Truncated = s == strings.ToUpper(\"tc\")\n\t\tcase 8:\n\t\t\tf.RecursionDesired = s == strings.ToUpper(\"rd\")\n\t\tcase 9:\n\t\t\tf.RecursionAvailable = s == strings.ToUpper(\"ra\")\n\t\tcase 10:\n\t\t\tf.AuthenticatedData = s == strings.ToUpper(\"ad\")\n\t\tcase 11:\n\t\t\tf.CheckingDisabled = s == strings.ToUpper(\"cd\")\n\t\tcase 12:\n\t\t\tf.Zero = s == strings.ToUpper(\"z\")\n\t\tcase 13:\n\t\t\tf.Question = valueOfString(s)\n\t\tcase 14:\n\t\t\tf.Answer = valueOfString(s)\n\t\tcase 15:\n\t\t\tf.Ns = valueOfString(s)\n\t\tcase 16:\n\t\t\tf.Extra = valueOfString(s)\n\t\tcase 17:\n\t\t\tf.Do = s == strings.ToUpper(\"do\")\n\t\tcase 18:\n\t\t\tf.UDPSize = valueOfString(s)\n\t\tcase 19:\n\t\t\tf.Nsid = s == strings.ToUpper(\"nsid\")\n\t\tdefault:\n\t\t\tpanic(\"unhandled fingerprint field\")\n\t\t}\n\t}\n\treturn\n}", "func (me *TSAFPTPortugueseTaxExemptionCode) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (v *Value) SetString(val string) {\n\tcstr := C.CString(val)\n\tdefer C.free(unsafe.Pointer(cstr))\n\tC.g_value_set_string(v.Native(), (*C.gchar)(cstr))\n}", "func (me *TMaxFileSizeType) Set(s string) { (*xsdt.PositiveInteger)(me).Set(s) }" ]
[ "0.6672757", "0.6561317", "0.6524928", "0.64725137", "0.6220122", "0.58207285", "0.58039266", "0.5787626", "0.57356185", "0.57275665", "0.5620785", "0.5603762", "0.55734444", "0.55207187", "0.55129176", "0.5493494", "0.5485165", "0.547474", "0.54543877", "0.5406057", "0.5394313", "0.53738254", "0.53677326", "0.5321433", "0.53190374", "0.5313714", "0.53054225", "0.5272251", "0.52499354", "0.5234234", "0.522856", "0.52031964", "0.50759256", "0.5074584", "0.50706506", "0.5069626", "0.5043252", "0.50094", "0.49650148", "0.49497935", "0.49254078", "0.49198326", "0.48729604", "0.48643687", "0.4858232", "0.48404703", "0.4834144", "0.482352", "0.4814166", "0.48100245", "0.48045284", "0.4800981", "0.47958604", "0.4787759", "0.4783241", "0.4777293", "0.47685868", "0.47601312", "0.47573727", "0.474782", "0.47474506", "0.47425514", "0.47406274", "0.4733597", "0.47294998", "0.47237056", "0.47180897", "0.47107753", "0.47031698", "0.47002536", "0.46922314", "0.4681208", "0.46658477", "0.46627", "0.46554106", "0.46537763", "0.46420187", "0.4630648", "0.4625263", "0.4616011", "0.46101448", "0.46067593", "0.4601623", "0.45986348", "0.45948458", "0.4593854", "0.45933938", "0.4579355", "0.45782053", "0.45782053", "0.45774227", "0.45663947", "0.45659694", "0.45500526", "0.4546981", "0.45437682", "0.45395273", "0.45388493", "0.45385382", "0.45347345" ]
0.7630867
0
Mul sets f = x y and returns f.
Mul sets f = x y и возвращает f.
func (f *Float) Mul(x, y *Float) *Float { x.doinit() y.doinit() f.doinit() C.mpf_mul(&f.i[0], &x.i[0], &y.i[0]) return f }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (z *Float64) Mul(x, y *Float64) *Float64 {\n\ta := (x.l * y.l) + (y.r * x.r)\n\tb := (x.r * y.l) + (y.r * x.l)\n\tz.SetPair(a, b)\n\treturn z\n}", "func feMul(out *fieldElement, a *fieldElement, b *fieldElement)", "func (z *Float) Mul(x, y *Float) *Float {\n\t// possible: panic(ErrNaN{\"multiplication of zero with infinity\"})\n}", "func (z *Big) Mul(x, y *Big) *Big { return z.Context.Mul(z, x, y) }", "func (p *FloatPrice) Mul(q FloatPrice) *FloatPrice {\n\treturn p.SetFloat64(p.Float64() * q.Float64())\n}", "func Mul(x, y meta.ConstValue) meta.ConstValue {\n\tswitch x.Type {\n\tcase meta.Integer:\n\t\tswitch y.Type {\n\t\tcase meta.Integer:\n\t\t\treturn meta.NewIntConst(x.GetInt() * y.GetInt())\n\t\tcase meta.Float:\n\t\t\treturn meta.NewFloatConst(float64(x.GetInt()) * y.GetFloat())\n\t\t}\n\tcase meta.Float:\n\t\tswitch y.Type {\n\t\tcase meta.Integer:\n\t\t\treturn meta.NewFloatConst(x.GetFloat() * float64(y.GetInt()))\n\t\tcase meta.Float:\n\t\t\treturn meta.NewFloatConst(x.GetFloat() * y.GetFloat())\n\t\t}\n\t}\n\treturn meta.UnknownValue\n}", "func op_f64_mul(expr *CXExpression, fp int) {\n\tinp1, inp2, out1 := expr.Inputs[0], expr.Inputs[1], expr.Outputs[0]\n\toutB1 := FromF64(ReadF64(fp, inp1) * ReadF64(fp, inp2))\n\tWriteMemory(GetFinalOffset(fp, out1), outB1)\n}", "func (x f26dot6) mul(y f26dot6) f26dot6 {\n\treturn f26dot6(int64(x) * int64(y) >> 6)\n}", "func (z *Int) Mul(x, y *Int) *Int {}", "func (z *E2) Mul(x, y *E2) *E2 {\n\tmulGenericE2(z, x, y)\n\treturn z\n}", "func (z *Rat) Mul(x, y *Rat) *Rat {}", "func Command_Mul(script *rex.Script, params []*rex.Value) {\n\tif len(params) != 2 {\n\t\trex.ErrorParamCount(\"float:mul\", \"2\")\n\t}\n\n\tscript.RetVal = rex.NewValueFloat64(params[0].Float64() * params[1].Float64())\n\treturn\n}", "func Mul(x, y Number) Number {\n\treturn Number{\n\t\tReal: x.Real * y.Real,\n\t\tE1mag: x.Real*y.E1mag + x.E1mag*y.Real,\n\t\tE2mag: x.Real*y.E2mag + x.E2mag*y.Real,\n\t\tE1E2mag: x.Real*y.E1E2mag + x.E1mag*y.E2mag + x.E2mag*y.E1mag + x.E1E2mag*y.Real,\n\t}\n}", "func FloatMul(z *big.Float, x, y *big.Float,) *big.Float", "func Mul(x, y int) int {\n\treturn x * y\n}", "func (x Vector64) Mul(y float64) Vector64 {\n\tfor i := 0; i < len(x); i++ {\n\t\tx[i] *= y\n\t}\n\treturn x\n}", "func (s *Scalar) Multiply(x, y *Scalar) *Scalar {\n\ts.s.Mul(&x.s, &y.s)\n\treturn s\n}", "func mul(x, y int) int {\n\treturn x * y\n}", "func NewMul(x, y value.Value) *InstMul {\n\tinst := &InstMul{X: x, Y: y}\n\t// Compute type.\n\tinst.Type()\n\treturn inst\n}", "func Mul(z, x, y *Elt)", "func (v *Vec3i) SetMul(other Vec3i) {\n\tv.X *= other.X\n\tv.Y *= other.Y\n\tv.Z *= other.Z\n}", "func (z *Perplex) Mul(x, y *Perplex) *Perplex {\n\ta := new(big.Int).Set(&x.l)\n\tb := new(big.Int).Set(&x.r)\n\tc := new(big.Int).Set(&y.l)\n\td := new(big.Int).Set(&y.r)\n\ttemp := new(big.Int)\n\tz.l.Add(\n\t\tz.l.Mul(a, c),\n\t\ttemp.Mul(d, b),\n\t)\n\tz.r.Add(\n\t\tz.r.Mul(d, a),\n\t\ttemp.Mul(b, c),\n\t)\n\treturn z\n}", "func Mul(t1 TermT, t2 TermT) TermT {\n\treturn TermT(C.yices_mul(C.term_t(t1), C.term_t(t2)))\n}", "func Mul(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Mul\",\n\t\tInput: []tf.Input{\n\t\t\tx, y,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func Multiply(a cty.Value, b cty.Value) (cty.Value, error) {\n\treturn MultiplyFunc.Call([]cty.Value{a, b})\n}", "func (f F128d16) Mul(value F128d16) F128d16 {\n\treturn F128d16{data: f.data.Mul(value.data).Div(multiplierF128d16)}\n}", "func (cal *Calculate) mul(value float64) (result float64) {\n\tif len(cal.Arg) == 2 {\n\t\treturn (cal.Arg[0] * cal.Arg[1])\n\t} else if len(cal.Arg) == 1 {\n\t\treturn (value * cal.Arg[0])\n\t}\n\n\tlog.Fatalln(\"Please check the data format of the calculation unit\")\n\treturn\n}", "func (f Fixed) Mul(f0 Fixed) Fixed {\n\tif f.IsNaN() || f0.IsNaN() {\n\t\treturn NaN\n\t}\n\n\tfp_a := f.fp / scale\n\tfp_b := f.fp % scale\n\n\tfp0_a := f0.fp / scale\n\tfp0_b := f0.fp % scale\n\n\tvar result int64\n\n\tif fp0_a != 0 {\n\t\tresult = fp_a*fp0_a*scale + fp_b*fp0_a\n\t}\n\tif fp0_b != 0 {\n\t\tresult = result + (fp_a * fp0_b) + ((fp_b)*fp0_b)/scale\n\t}\n\n\treturn Fixed{fp: result}\n}", "func (c Currency) Mulf(f float64) Currency {\n\ti := c.m * int64(f*c.guardf*c.dpf)\n\tr := i / c.guard / c.dp\n\treturn c.Set(rnd(r, float64(i)/c.guardf/c.dpf-float64(r)))\n}", "func (n *bigNumber) mul(x *bigNumber, y *bigNumber) *bigNumber {\n\t//it does not work in place, that why the temporary bigNumber is necessary\n\treturn karatsubaMul(n, x, y)\n}", "func (f1 Frac) Mul(f2 Frac) Frac {\n\tf := Frac{n: f1.n * f2.n, d: f1.d * f2.d}\n\n\tf.normalizeSignage()\n\n\treturn f\n}", "func (g *Graph) Mul(x1 Node, x2 Node) Node {\n\treturn g.NewOperator(fn.NewMul(x1, x2), x1, x2)\n}", "func Multiply(a float64, b float64) float64 {\n return a*b;\n}", "func RatMul(z *big.Rat, x, y *big.Rat,) *big.Rat", "func (z *BiComplex) Mul(x, y *BiComplex) *BiComplex {\n\ta := new(Complex).Set(&x.l)\n\tb := new(Complex).Set(&x.r)\n\tc := new(Complex).Set(&y.l)\n\td := new(Complex).Set(&y.r)\n\ttemp := new(Complex)\n\tz.l.Sub(\n\t\tz.l.Mul(a, c),\n\t\ttemp.Mul(b, d),\n\t)\n\tz.r.Add(\n\t\tz.r.Mul(a, d),\n\t\ttemp.Mul(b, c),\n\t)\n\treturn z\n}", "func (c *Calculator) Mul() {\n\tif opValue, err := c.getOperationValue(); err != nil {\n\t\tc.returnError()\n\t} else {\n\t\tlog.Printf(\"%f * %f = \", value, opValue)\n\t\tvalue *= opValue\n\t\tlog.Printf(\"%f\\n\", value)\n\t\tc.returnResult()\n\t}\n}", "func Mul(a, b Expr) Expr {\n\treturn &mulOp{&simpleOperator{a, b, scanner.MUL}}\n}", "func (x Rational) Multiply(y Rational) Rational {\n\treturn NewRational(x.numerator*y.numerator, x.denominator*y.denominator)\n}", "func multiply(a, b float64) float64 {\n\treturn a * b\n}", "func Mul(a, b *big.Float) *big.Float {\n\treturn ZeroBigFloat().Mul(a, b)\n}", "func (f Fixed) Mul(f0 Fixed) Fixed {\n\tif f.IsNaN() || f0.IsNaN() {\n\t\treturn NaN\n\t}\n\n\tfp_a := f.fp / scale\n\tfp_b := f.fp % scale\n\n\tfp0_a := f0.fp / scale\n\tfp0_b := f0.fp % scale\n\n\tvar result uint64\n\n\tif fp0_a != 0 {\n\t\tresult = fp_a*fp0_a*scale + fp_b*fp0_a\n\t}\n\tif fp0_b != 0 {\n\t\tresult = result + (fp_a * fp0_b) + ((fp_b)*fp0_b)/scale\n\t}\n\n\t// check overflow\n\tif (fp_a >= 1 && fp_b >= 1) && (fp0_a > 1 && fp0_b > 1) {\n\t\tif result/f.fp != fp0_a {\n\t\t\tpanic(errOverflow)\n\t\t}\n\t}\n\treturn Fixed{fp: result}\n}", "func Multiply(a, b float64) float64 {\n\treturn a * b\n}", "func Multiply(a, b float64) float64 {\n\treturn a * b\n}", "func Mul(a, b int) int {\n\treturn a * b\n}", "func Multiply(a float64, b float64) float64 {\n\treturn a * b\n}", "func (z *E12) Mul(x, y *E12) *E12 {\n\tvar a, b, c E6\n\ta.Add(&x.C0, &x.C1)\n\tb.Add(&y.C0, &y.C1)\n\ta.Mul(&a, &b)\n\tb.Mul(&x.C0, &y.C0)\n\tc.Mul(&x.C1, &y.C1)\n\tz.C1.Sub(&a, &b).Sub(&z.C1, &c)\n\tz.C0.MulByNonResidue(&c).Add(&z.C0, &b)\n\treturn z\n}", "func (m Mat2f) Mul(other Mat2f) Mat2f {\n\treturn Mat2f{\n\t\tm[0]*other[0] + m[2]*other[1],\n\t\tm[1]*other[0] + m[3]*other[1],\n\n\t\tm[0]*other[2] + m[2]*other[3],\n\t\tm[1]*other[2] + m[3]*other[3]}\n}", "func (f Fraction) Multiply(multiplicand Fraction) (product Fraction) {\n\ttmp := f.normalize()\n\tproduct = Fraction{\n\t\ttmp.numerator * multiplicand.numerator, tmp.denominator * multiplicand.denominator,\n\t}\n\treturn product.normalize()\n}", "func (u *Update) Mul(obj types.M) *Update {\n\tu.update[\"$mul\"] = obj\n\treturn u\n}", "func (c *Clac) Mul() error {\n\treturn c.applyFloat(2, func(vals []value.Value) (value.Value, error) {\n\t\treturn binary(vals[1], \"*\", vals[0])\n\t})\n}", "func (v1 Vector2) Mul(v2 Vector2) Vector2 {\n\tv1.MulThis(v2)\n\treturn v1\n}", "func (s *SourceControl) Multiply(args *FactorArgs, reply *int) error {\n\t*reply = args.A * args.B\n\treturn nil\n}", "func MULPS(mx, x operand.Op) { ctx.MULPS(mx, x) }", "func (c Currency) Mul(d Currency) Currency {\n\t// @todo c.m*d.m will overflow int64\n\tr := utils.Round(float64(c.m*d.m)/c.dpf, .5, 0)\n\treturn c.Set(int64(r))\n}", "func mul(m ast.Mul, isparam map[ast.Variable]bool) (Operation, error) {\n\t// Expect the second operand to always be a variable.\n\tif _, ok := m.Y.(ast.Variable); !ok {\n\t\treturn nil, errutil.AssertionFailure(\"expect second multiply operand to be variable\")\n\t}\n\n\t// Check for a const multiply.\n\tif c, ok := m.X.(ast.Constant); ok {\n\t\treturn ConstMul(c), nil\n\t}\n\n\t// Check for parameter multiply.\n\tif v, ok := m.X.(ast.Variable); ok && isparam[v] {\n\t\treturn ParamMul(v), nil\n\t}\n\n\tif v, ok := m.Y.(ast.Variable); ok && isparam[v] {\n\t\treturn ParamMul(v), nil\n\t}\n\n\t// Fallback to a generic multiply.\n\treturn Mul{}, nil\n}", "func (m USD) Multiply(f float64) USD {\n\tx := (float64(m) * f) + 0.5\n\treturn USD(x)\n}", "func (u *Update) Mul(obj utils.M) *Update {\n\tu.update[\"$mul\"] = obj\n\treturn u\n}", "func (t Tuple) Mul(scalar float64) Tuple {\n\treturn Tuple{t.X * scalar, t.Y * scalar, t.Z * scalar, t.W * scalar}\n}", "func (o Mul) F(t float64, x []float64) float64 {\n\tif o.Fa != nil && o.Fb != nil {\n\t\treturn o.Fa.F(t, x) * o.Fb.F(t, x)\n\t}\n\tchk.Panic(\"mul: fa and fb functions are <nil>\\n\")\n\treturn 0\n}", "func Multiply() {\n\tMatch('*')\n\tFactor()\n\tEmitLn(\"MULS (SP)+,D0\")\n}", "func (wv *Spectrum) Mul(other Spectrum) {\n\t// if wv.Lambda != other.Lambda IS ERROR\n\twv.C[0] *= other.C[0]\n\twv.C[1] *= other.C[1]\n\twv.C[2] *= other.C[2]\n\twv.C[3] *= other.C[3]\n}", "func (a Vec2) Mul(b Vec2) Vec2 {\n\treturn Vec2{a.X * b.X, a.Y * b.Y}\n}", "func Mul(a, b Expr) Expr {\n\treturn &arithmeticOperator{&simpleOperator{a, b, scanner.MUL}}\n}", "func (expr Expression) Multiply() (float64, error) {\n\treturn (expr.FirstOperand.Value * expr.SecondOperand.Value), nil\n}", "func MULPD(mx, x operand.Op) { ctx.MULPD(mx, x) }", "func (p *Int64) Mul(q, r *Int64) *Int64 {\n\tx := new(Int64).Set(q)\n\ty := new(Int64).Set(r)\n\tz := NewInt64()\n\tvar l uint64\n\tfor n, a := range x.c {\n\t\tfor m, b := range y.c {\n\t\t\tl = n + m\n\t\t\tif coeff, ok := z.Coeff(l); ok {\n\t\t\t\tz.SetCoeff(l, coeff+(a*b))\n\t\t\t} else {\n\t\t\t\tz.SetCoeff(l, a*b)\n\t\t\t}\n\t\t}\n\t}\n\treturn p.Set(z)\n}", "func Multiply(a, operand int) int { return operand * a }", "func Multiply(v *Vec, mul float64) *Vec {\n\treturn &Vec{\n\t\tv.X / mul,\n\t\tv.Y / mul,\n\t}\n}", "func (t *Tuple) Mul(scalar float64) *Tuple {\n\treturn &Tuple{\n\t\tt.x * scalar,\n\t\tt.y * scalar,\n\t\tt.z * scalar,\n\t\tt.w * scalar,\n\t}\n\n}", "func basicMul(z, x, y fermat) {\n\t// initialize z\n\tfor i := 0; i < len(z); i++ {\n\t\tz[i] = 0\n\t}\n\tfor i, d := range y {\n\t\tif d != 0 {\n\t\t\tz[len(x)+i] = addMulVVW(z[i:i+len(x)], x, d)\n\t\t}\n\t}\n}", "func Mul(x, y *big.Int) *big.Int {\n\treturn new(big.Int).Mul(x, y)\n}", "func (z *Int) Mul(x, y *Int) {\n\n\tvar (\n\t\talfa = &Int{} // Aggregate results\n\t\tbeta = &Int{} // Calculate intermediate\n\t)\n\t// The numbers are internally represented as [ a, b, c, d ]\n\t// We do the following operations\n\t//\n\t// d1 * d2\n\t// d1 * c2 (upshift 64)\n\t// d1 * b2 (upshift 128)\n\t// d1 * a2 (upshift 192)\n\t//\n\t// c1 * d2 (upshift 64)\n\t// c1 * c2 (upshift 128)\n\t// c1 * b2 (upshift 192)\n\t//\n\t// b1 * d2 (upshift 128)\n\t// b1 * c2 (upshift 192)\n\t//\n\t// a1 * d2 (upshift 192)\n\t//\n\t// And we aggregate results into 'alfa'\n\n\t// One optimization, however, is reordering.\n\t// For these ones, we don't care about if they overflow, thus we can use native multiplication\n\t// and set the result immediately into `a` of the result.\n\t// b1 * c2 (upshift 192)\n\t// a1 * d2 (upshift 192)\n\t// d1 * a2 (upshift 192)\n\t// c1 * b2 11(upshift 192)\n\n\t// Remaining ops:\n\t//\n\t// d1 * d2\n\t// d1 * c2 (upshift 64)\n\t// d1 * b2 (upshift 128)\n\t//\n\t// c1 * d2 (upshift 64)\n\t// c1 * c2 (upshift 128)\n\t//\n\t// b1 * d2 (upshift 128)\n\n\talfa.mulIntoLower128(x[0], y[0])\n\talfa.mulIntoUpper128(x[0], y[2])\n\talfa[3] += x[0]*y[3] + x[1]*y[2] + x[2]*y[1] + x[3]*y[0] // Top ones, ignore overflow\n\n\tbeta.mulIntoMiddle128(x[0], y[1])\n\talfa.Add(alfa, beta)\n\n\tbeta.Clear().mulIntoMiddle128(x[1], y[0])\n\talfa.Add(alfa, beta)\n\n\tbeta.Clear().mulIntoUpper128(x[1], y[1])\n\talfa.addHigh128(beta[3], beta[2])\n\n\tbeta.Clear().mulIntoUpper128(x[2], y[0])\n\talfa.addHigh128(beta[3], beta[2])\n\tz.Copy(alfa)\n\n}", "func (m *Money) Mulf(f float64) *Money {\n\ti := m.M * int64(f*Guardf*DPf)\n\tr := i / Guard / DP\n\treturn m.Set(Rnd(r, float64(i)/Guardf/DPf-float64(r)))\n}", "func MULSD(mx, x operand.Op) { ctx.MULSD(mx, x) }", "func (v *Vector2) MultiplyWithScalar(s float64) {\r\n\tv.x *= s\r\n\tv.y *= s\r\n}", "func mult(f1, f2, p []complex128) {\n\tfor idx := range f1 {\n\t\tp[idx] = f1[idx] * f2[idx]\n\t}\n}", "func (c *calculon) Multiply(ctx context.Context, arg calculator.Operand) (calculator.Result, error) {\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\tc.current *= arg.Value\n\treturn calculator.Result{c.current}, nil\n}", "func mul(x byte, y byte) byte {\n\tif x == 0 || y == 0 {\n\t\treturn 0\n\t}\n\treturn expOp[logOp[x]+logOp[y]]\n}", "func IntMul(z *big.Int, x, y *big.Int,) *big.Int", "func rcMul(p *TCompiler, code *TCode) (*value.Value, error) {\n\tv := value.Mul(p.regGet(code.B), p.regGet(code.C))\n\tp.regSet(code.A, v)\n\tp.moveNext()\n\treturn v, nil\n}", "func mul(a, b big.Int) big.Int {\n\treturn *big.NewInt(1).Mul(&a, &b)\n}", "func Mul(a, b interface{}, opts ...FuncOpt) (retVal Tensor, err error) {\n\tad, adok := a.(*Dense)\n\tbd, bdok := b.(*Dense)\n\n\tswitch {\n\tcase adok && bdok:\n\t\treturn ad.Mul(bd, opts...)\n\tcase adok && !bdok:\n\t\treturn ad.Scale(b, opts...)\n\tcase !adok && bdok:\n\t\treturn bd.Scale(a, opts...)\n\t}\n\tpanic(\"Unreachable\")\n}", "func (m *Money) Mul(n *Money) *Money {\n\treturn m.Set(m.M * n.M / DP)\n}", "func MulGenerator(a, b MatrixFixture) *MatrixFixture {\n\texpr := a.expr.Mul(b.expr)\n\tif expr.Err() != nil {\n\t\treturn nil\n\t}\n\n\tm := &MatrixFixture{\n\t\tname: \"(\" + a.name + \") * (\" + b.name + \")\",\n\t\tr: a.r,\n\t\tc: b.c,\n\t\texpr: expr,\n\t\twant: blasmul(a.want, b.want),\n\t}\n\treturn m\n}", "func (i I) Multiply(i2 I) I {\n\ti.X *= i2.X\n\ti.Y *= i2.Y\n\treturn i\n}", "func (p Point2) Mul(ps ...Point2) Point2 {\n\tfor _, p2 := range ps {\n\t\tp[0] *= p2[0]\n\t\tp[1] *= p2[1]\n\t}\n\treturn p\n}", "func multiply(x, y int) int {\n\treturn x * y\n}", "func (p thinPoly) x4Mul(f, g thinPoly) thinPoly {\n\tp.Zero()\n\tfor i := 0; i < 4; i++ {\n\t\tfor j := 0; j < 4; j++ {\n\t\t\tp[i+j] += Freeze(f[i] * g[j])\n\t\t}\n\t}\n\treturn p\n}", "func MULQ(mr operand.Op) { ctx.MULQ(mr) }", "func (r *ImageRef) Multiply(multiplier *ImageRef) error {\n\tout, err := vipsMultiply(r.image, multiplier.image)\n\tif err != nil {\n\t\treturn err\n\t}\n\tr.setImage(out)\n\treturn nil\n}", "func Mul(multiplicand, multiplier *big.Int) *big.Int {\n\treturn I().Mul(multiplicand, multiplier)\n}", "func Multiply(x, y int64) int64 {\n\tif y == 0 {\n\t\treturn 0\n\t}\n\treturn add(x, Multiply(x, y-1))\n}", "func MULW(mr operand.Op) { ctx.MULW(mr) }", "func ValueMul(a, b reflect.Value) (reflect.Value, error) {\n\taBkind := GetBaseKind(a)\n\tbBkind := GetBaseKind(b)\n\n\tswitch aBkind {\n\tcase reflect.Int64:\n\t\tswitch bBkind {\n\t\tcase reflect.Int64:\n\t\t\treturn reflect.ValueOf(a.Int() * b.Int()), nil\n\t\tcase reflect.Uint64:\n\t\t\treturn reflect.ValueOf(a.Int() * int64(b.Uint())), nil\n\t\tcase reflect.Float64:\n\t\t\treturn reflect.ValueOf(float64(a.Int()) * b.Float()), nil\n\t\tdefault:\n\t\t\treturn reflect.ValueOf(nil), errors.Errorf(\"Can not do multiplication math operator between %s and %s\", a.Kind().String(), b.Kind().String())\n\t\t}\n\tcase reflect.Uint64:\n\t\tswitch bBkind {\n\t\tcase reflect.Int64:\n\t\t\treturn reflect.ValueOf(int64(a.Uint()) * b.Int()), nil\n\t\tcase reflect.Uint64:\n\t\t\treturn reflect.ValueOf(a.Uint() * b.Uint()), nil\n\t\tcase reflect.Float64:\n\t\t\treturn reflect.ValueOf(float64(a.Uint()) * b.Float()), nil\n\t\tdefault:\n\t\t\treturn reflect.ValueOf(nil), errors.Errorf(\"Can not do multiplication math operator between %s and %s\", a.Kind().String(), b.Kind().String())\n\t\t}\n\tcase reflect.Float64:\n\t\tswitch bBkind {\n\t\tcase reflect.Int64:\n\t\t\treturn reflect.ValueOf(a.Float() * float64(b.Int())), nil\n\t\tcase reflect.Uint64:\n\t\t\treturn reflect.ValueOf(a.Float() * float64(b.Uint())), nil\n\t\tcase reflect.Float64:\n\t\t\treturn reflect.ValueOf(a.Float() * b.Float()), nil\n\t\tdefault:\n\t\t\treturn reflect.ValueOf(nil), errors.Errorf(\"Can not do multiplication math operator between %s and %s\", a.Kind().String(), b.Kind().String())\n\t\t}\n\tdefault:\n\t\treturn reflect.ValueOf(nil), errors.Errorf(\"Can not do multiplication math operator between %s and %s\", a.Kind().String(), b.Kind().String())\n\t}\n}", "func Multiply(x, y int) int {\n\treturn x * y\n}", "func Multiply(x, y int) int {\n\treturn x * y\n}", "func Mul(x, y *Money) *Money {\n\tz := Money{}\n\treturn &z\n}", "func (op *OpMult) Eval(x, y float32) float32 {\n\treturn op.LeftChild.Eval(x, y) * op.RightChild.Eval(x, y)\n}", "func (ub *UpdateBuilder) Mul(field string, value interface{}) string {\n\tf := Escape(field)\n\treturn fmt.Sprintf(\"%s = %s * %s\", f, f, ub.args.Add(value))\n}", "func (q Quat) Mul(other Quat) Quat {\n\treturn Quat{q.W * other.W, q.X * other.X, q.Y * other.Y, q.Z * other.Z}\n}" ]
[ "0.7242088", "0.7237525", "0.70135707", "0.68834496", "0.6832727", "0.68206954", "0.6773969", "0.6773326", "0.67665404", "0.67589134", "0.6689138", "0.666826", "0.66305107", "0.6610131", "0.65832794", "0.6563603", "0.65572894", "0.6524023", "0.64834917", "0.6467111", "0.6460558", "0.6436789", "0.64347976", "0.635574", "0.6311343", "0.6295828", "0.62951237", "0.6264279", "0.6230882", "0.62296766", "0.6228932", "0.62033993", "0.61963373", "0.61863375", "0.61768883", "0.61739904", "0.616625", "0.6160538", "0.615077", "0.6144207", "0.612113", "0.61120445", "0.61120445", "0.61056125", "0.61049175", "0.6078752", "0.60519475", "0.6022539", "0.5985107", "0.5978488", "0.59746575", "0.59653115", "0.5965001", "0.59573853", "0.5956941", "0.594605", "0.5935844", "0.59273463", "0.59115547", "0.5900028", "0.5898584", "0.5897943", "0.58942586", "0.58932143", "0.589214", "0.5891633", "0.588862", "0.5879884", "0.58502656", "0.58421797", "0.58273286", "0.5813921", "0.58125156", "0.57738924", "0.5772892", "0.5757238", "0.57474726", "0.57357097", "0.5726966", "0.57201713", "0.57190925", "0.57179725", "0.5717096", "0.5716105", "0.5710835", "0.5707108", "0.570471", "0.570051", "0.5665468", "0.5664678", "0.5662578", "0.56557715", "0.5632823", "0.5630823", "0.5625072", "0.5625072", "0.56234276", "0.56219995", "0.5621537", "0.5609597" ]
0.7852031
0
Div sets f = x / y and returns f.
Div устанавливает f = x / y и возвращает f.
func (f *Float) Div(x, y *Float) *Float { x.doinit() y.doinit() f.doinit() C.mpf_div(&f.i[0], &x.i[0], &y.i[0]) return f }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Div(x, y int) int {\n\treturn x / y\n}", "func Divide(x, y int) float64 {\n\treturn float64(x) / float64(y)\n}", "func Command_Div(script *rex.Script, params []*rex.Value) {\n\tif len(params) != 2 {\n\t\trex.ErrorParamCount(\"float:div\", \"2\")\n\t}\n\n\tscript.RetVal = rex.NewValueFloat64(params[0].Float64() / params[1].Float64())\n\treturn\n}", "func (f Fixed) Div(f0 Fixed) Fixed {\n\tif f.IsNaN() || f0.IsNaN() {\n\t\treturn NaN\n\t}\n\treturn NewF(f.Float() / f0.Float())\n}", "func Div(a float64, b float64) (float64, error) {\n\tif b == 0 {\n\t\treturn 0.0, errors.New(\"Can't devide by zero\")\n\t}\n\n\treturn a / b, nil\n}", "func Divide(a float64, b float64) float64 {\n\treturn a / b\n}", "func (f Fixed) Div(f0 Fixed) Fixed {\n\tif f.IsNaN() || f0.IsNaN() {\n\t\treturn NaN\n\t}\n\treturn NewFromFloat(f.Float() / f0.Float())\n}", "func div(x, y int) (answer int, err error) {\n\tif y == 0 {\n\t\terr = fmt.Errorf(\"Cannot Divid by zero\")\n\t} else {\n\t\tanswer = x / y\n\t}\n\treturn\n}", "func (f1 Frac) Div(f2 Frac) Frac {\n\treturn f1.Mul(f2.Reciprocal())\n}", "func (x f26dot6) div(y f26dot6) f26dot6 {\n\treturn f26dot6((int64(x) << 6) / int64(y))\n}", "func division(x, y int) (int, error, error) {\n\tif y == 0 {\n\t\treturn 0, nil, errors.New(\"Cannot divide by zero!\")\n\t}\n\tif x%y != 0 {\n\t\tremainder := errors.New(\"There is a remainder!\")\n\t\treturn x / y, remainder, nil\n\t} else {\n\t\treturn x / y, nil, nil\n\t}\n\n}", "func Divide(a cty.Value, b cty.Value) (cty.Value, error) {\n\treturn DivideFunc.Call([]cty.Value{a, b})\n}", "func Div( a *context.Value, b *context.Value ) (*context.Value,error) {\n if a != nil && b != nil {\n if b.IsZero() {\n return nil, errors.New( \"Division by zero\")\n }\n\n switch a.OperationType( b ) {\n case context.VAR_BOOL:\n return context.IntValue( a.Int() / b.Int() ), nil\n case context.VAR_INT:\n return context.FloatValue( a.Float() / b.Float() ), nil\n case context.VAR_FLOAT:\n return context.FloatValue( a.Float() / b.Float() ), nil\n case context.VAR_COMPLEX:\n return context.ComplexValue( a.Complex() / b.Complex() ), nil\n }\n }\n\n return nil, errors.New( \"Unsupported type for div\" )\n}", "func (z *Int) Div(x, y *Int) *Int {\n\tif y.IsZero() || y.Gt(x) {\n\t\treturn z.Clear()\n\t}\n\tif x.Eq(y) {\n\t\treturn z.SetOne()\n\t}\n\t// Shortcut some cases\n\tif x.IsUint64() {\n\t\treturn z.SetUint64(x.Uint64() / y.Uint64())\n\t}\n\n\t// At this point, we know\n\t// x/y ; x > y > 0\n\t// See Knuth, Volume 2, section 4.3.1, Algorithm D.\n\n\t// Normalize by shifting divisor left just enough so that its high-order\n\t// bit is on and u left the same amount.\n\t// function nlz do the caculating of the amount and shl do the left operation.\n\ts := nlz(y)\n\txn := shl(x, s, true)\n\tyn := shl(y, s, false)\n\n\t// divKnuth do the division of normalized dividend and divisor with Knuth Algorithm D.\n\tq := divKnuth(xn, yn)\n\n\tz.Clear()\n\tfor i := 0; i < len(q); i++ {\n\t\tz[i/2] = z[i/2] | uint64(q[i])<<(32*(uint64(i)%2))\n\t}\n\n\treturn z\n}", "func (c *Calculator) Div() {\n\tif opValue, err := c.getOperationValue(); err != nil || opValue == 0 {\n\t\tc.returnError()\n\t} else {\n\t\tlog.Printf(\"%f / %f = \", value, opValue)\n\t\tvalue /= opValue\n\t\tlog.Printf(\"%f\\n\", value)\n\t\tc.returnResult()\n\t}\n}", "func Divide() {\n\tMatch('/')\n\tFactor()\n\tEmitLn(\"MOVE (SP)+,D1\")\n\tEmitLn(\"DIVS D1,D0\")\n}", "func (z *Int) Div(x, y *Int) *Int {}", "func (z *Float64) Divide(y *Float64, a float64) *Float64 {\n\tz.l = y.l / a\n\tz.r = y.r / a\n\treturn z\n}", "func Div(valueA gcv.Value, valueB gcv.Value) gcv.Value {\n\tif valueA.Type() == gcv.Complex || valueB.Type() == gcv.Complex {\n\t\treturn gcv.MakeValue(valueA.Complex() / valueB.Complex())\n\t}\n\treturn gcv.MakeValue(valueA.Real() / valueB.Real())\n}", "func Div(a, b int) (int, error) {\n\tif b == 0 {\n\t\treturn 0, errors.New(\"can't divide by 0\")\n\t}\n\n\treturn a / b, nil\n\n}", "func (cal *Calculate) div(value float64) (result float64) {\n\tif len(cal.Arg) == 2 {\n\t\treturn (cal.Arg[0] / cal.Arg[1])\n\t} else if len(cal.Arg) == 1 {\n\n\t\treturn (value / cal.Arg[0])\n\t}\n\n\tlog.Fatalln(\"Please check the data format of the calculation unit\")\n\treturn\n}", "func Divide(a, operand int) int { return operand / a }", "func (c *Clac) Div() error {\n\treturn c.applyFloat(2, func(vals []value.Value) (value.Value, error) {\n\t\treturn binary(vals[1], \"/\", vals[0])\n\t})\n}", "func Div(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Div\",\n\t\tInput: []tf.Input{\n\t\t\tx, y,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func (a Vec2) Div(b Vec2) Vec2 {\n\treturn Vec2{a.X / b.X, a.Y / b.Y}\n}", "func op_f64_div(expr *CXExpression, fp int) {\n\tinp1, inp2, out1 := expr.Inputs[0], expr.Inputs[1], expr.Outputs[0]\n\toutB1 := FromF64(ReadF64(fp, inp1) / ReadF64(fp, inp2))\n\tWriteMemory(GetFinalOffset(fp, out1), outB1)\n}", "func Divide(a, b int) int {\n\treturn a / b\n}", "func Divide(a, b int) int {\n\treturn a / b\n}", "func (f Fixed8) Div(i int64) Fixed8 {\n\treturn f / Fixed8FromInt64(i)\n}", "func Div(a, b Expr) Expr {\n\treturn &divOp{&simpleOperator{a, b, scanner.DIV}}\n}", "func div(a, b int32) int32 {\n\tif a >= 0 {\n\t\treturn (a + (b >> 1)) / b\n\t}\n\treturn -((-a + (b >> 1)) / b)\n}", "func cdiv(a, b int) int { return (a + b - 1) / b }", "func Divide(a, b int) (float64, error) {\n\tif b == 0 {\n\t\treturn 0, errors.New(\"You cannot divide by zero\")\n\t}\n\n\treturn float64(a) / float64(b), nil\n}", "func SafeDiv(x float64, y float64) float64 {\n\tif IsZero(y) {\n\t\treturn 0\n\t}\n\n\treturn x / y\n}", "func DIVSD(mx, x operand.Op) { ctx.DIVSD(mx, x) }", "func FloorDiv(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"FloorDiv\",\n\t\tInput: []tf.Input{\n\t\t\tx, y,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func (expr Expression) Divide() (float64, error) {\n\tif expr.SecondOperand.Value == 0 {\n\t\treturn 0, errors.New(\"division by zero\")\n\t}\n\n\treturn (expr.FirstOperand.Value / expr.SecondOperand.Value), nil\n}", "func (c *calculon) Divide(ctx context.Context, arg calculator.Operand) (calculator.Result, error) {\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\tif arg.Value == 0 {\n\t\treturn calculator.Result{}, calculator.InvalidArgumentError(map[string]string{\"value\": \"cannot be 0\"})\n\t}\n\tc.current /= arg.Value\n\treturn calculator.Result{c.current}, nil\n}", "func Div(a, b *big.Float) *big.Float {\n\treturn ZeroBigFloat().Quo(a, b)\n}", "func DivFloat(o float32, p float32)float32{\r\n\treturn(o/p)\r\n}", "func (f F128d16) Div(value F128d16) F128d16 {\n\treturn F128d16{data: f.data.Mul(multiplierF128d16).Div(value.data)}\n}", "func Div(a, b Expr) Expr {\n\treturn &arithmeticOperator{&simpleOperator{a, b, scanner.DIV}}\n}", "func calcDiv(rOpd, lOpd formulaArg, opdStack *Stack) error {\n\tlOpdVal := lOpd.ToNumber()\n\tif lOpdVal.Type != ArgNumber {\n\t\treturn errors.New(lOpdVal.Value())\n\t}\n\trOpdVal := rOpd.ToNumber()\n\tif rOpdVal.Type != ArgNumber {\n\t\treturn errors.New(rOpdVal.Value())\n\t}\n\tif rOpdVal.Number == 0 {\n\t\treturn errors.New(formulaErrorDIV)\n\t}\n\topdStack.Push(newNumberFormulaArg(lOpdVal.Number / rOpdVal.Number))\n\treturn nil\n}", "func ValueDiv(a, b reflect.Value) (reflect.Value, error) {\n\taBkind := GetBaseKind(a)\n\tbBkind := GetBaseKind(b)\n\n\tswitch aBkind {\n\tcase reflect.Int64:\n\t\tswitch bBkind {\n\t\tcase reflect.Int64:\n\t\t\treturn reflect.ValueOf(a.Int() / b.Int()), nil\n\t\tcase reflect.Uint64:\n\t\t\treturn reflect.ValueOf(a.Int() / int64(b.Uint())), nil\n\t\tcase reflect.Float64:\n\t\t\treturn reflect.ValueOf(float64(a.Int()) / b.Float()), nil\n\t\tdefault:\n\t\t\treturn reflect.ValueOf(nil), errors.Errorf(\"Can not do division math operator between %s and %s\", a.Kind().String(), b.Kind().String())\n\t\t}\n\tcase reflect.Uint64:\n\t\tswitch bBkind {\n\t\tcase reflect.Int64:\n\t\t\treturn reflect.ValueOf(int64(a.Uint()) / b.Int()), nil\n\t\tcase reflect.Uint64:\n\t\t\treturn reflect.ValueOf(a.Uint() / b.Uint()), nil\n\t\tcase reflect.Float64:\n\t\t\treturn reflect.ValueOf(float64(a.Uint()) / b.Float()), nil\n\t\tdefault:\n\t\t\treturn reflect.ValueOf(nil), errors.Errorf(\"Can not do division math operator between %s and %s\", a.Kind().String(), b.Kind().String())\n\t\t}\n\tcase reflect.Float64:\n\t\tswitch bBkind {\n\t\tcase reflect.Int64:\n\t\t\treturn reflect.ValueOf(a.Float() / float64(b.Int())), nil\n\t\tcase reflect.Uint64:\n\t\t\treturn reflect.ValueOf(a.Float() / float64(b.Uint())), nil\n\t\tcase reflect.Float64:\n\t\t\treturn reflect.ValueOf(a.Float() / b.Float()), nil\n\t\tdefault:\n\t\t\treturn reflect.ValueOf(nil), errors.Errorf(\"Can not do division math operator between %s and %s\", a.Kind().String(), b.Kind().String())\n\t\t}\n\tdefault:\n\t\treturn reflect.ValueOf(nil), errors.Errorf(\"Can not do division math operator between %s and %s\", a.Kind().String(), b.Kind().String())\n\t}\n}", "func NewFDiv(x, y value.Value) *InstFDiv {\n\tinst := &InstFDiv{X: x, Y: y}\n\t// Compute type.\n\tinst.Type()\n\treturn inst\n}", "func DIVPD(mx, x operand.Op) { ctx.DIVPD(mx, x) }", "func (z *Element22) Div(x, y *Element22) *Element22 {\n\tvar yInv Element22\n\tyInv.Inverse(y)\n\tz.Mul(x, &yInv)\n\treturn z\n}", "func (v Vec3i) Div(other Vec3i) Vec3i {\n\treturn Vec3i{v.X / other.X, v.Y / other.Y, v.Z / other.Z}\n}", "func (p Point) Div(other Point) Point {\n\treturn Pt(p.X/other.X, p.Y/other.Y)\n}", "func DIVSS(mx, x operand.Op) { ctx.DIVSS(mx, x) }", "func (rn *RangedNumber) Div(other *RangedNumber) *RangedNumber {\n\treturn rn.Set(rn.min/other.min, rn.max/other.max)\n}", "func divide(divisor int, dividends ...int) (float64, error) {\n\tif divisor == 0 {\n\t\treturn 0, errors.New(\"Division by zero\")\n\t} else {\n\t\tdividend := 0\n\t\tfor _, d := range dividends {\n\t\t\tdividend += d\n\t\t}\n\t\treturn float64(dividend / divisor), nil\n\t}\n}", "func Divisor(numeroA int, numeroB int) (resultado int) {\n\tresultado = numeroA / numeroB\n\treturn\n}", "func division(x, y uint) ([]uint, []uint, []uint) {\n\t// Digits before decimal point\n\tinteg := []uint{0}\n\n\t// Digits after decimal point including any recurrence\n\tfract := []uint{}\n\n\t// Track state of caculation to detect recurrence\n\tstate := make(map[uint]*struct{})\n\tindex := make(map[uint]int)\n\n\t// First, see if we have digits before the decimal point.\n\tif x/y != 0 {\n\t\tinteg = euler.UintToDigits(x / y)\n\t\tx = x % y\n\t}\n\n\t// Compute the fractional part. We will accumulate digits\n\t// in a slice and keep track of the leading digits.\n\n\t// Increasing here sets up to calculate the first digit, so\n\t// does not add a leading zero.\n\tif x > 0 && x/y == 0 {\n\t\tx *= 10\n\t}\n\n\t// Index of the current digit in the calculation\n\ti := 0\n\n\t// If further increases are needed, add more leading zeros\n\tfor x > 0 && x/y == 0 {\n\t\tx *= 10\n\t\tfract = append(fract, 0)\n\t\ti++\n\t}\n\n\tfor {\n\t\t// Increase x as needed and add zero digits\n\t\tfor x > 0 && x/y == 0 {\n\t\t\tx *= 10\n\t\t\tfract = append(fract, 0)\n\t\t}\n\n\t\t// Check if we've returned to a previous state, where the\n\t\t// current divisor has been seen before. Return the point\n\t\t// where the recurrence began. If we don't break out here\n\t\t// this would recur forever.\n\t\tif state[x] != nil {\n\t\t\t// Calculate the point the recurrence starts and\n\t\t\t// return slices for each part.\n\t\t\tr := index[x]\n\t\t\treturn integ, fract[:r], fract[r:]\n\t\t}\n\n\t\t// Record the current state\n\t\tstate[x] = &struct{}{}\n\t\tindex[x] = i\n\n\t\t// Div mod\n\t\tn := x / y\n\t\tm := x % y\n\n\t\t// Save digit\n\t\tfract = append(fract, n)\n\n\t\t// If no remainder, we're done\n\t\tif m == 0 {\n\t\t\tbreak\n\t\t}\n\n\t\t// Continue the calculation with the remainder * 10\n\t\tx = m * 10\n\n\t\ti++\n\t}\n\n\t// No recurrence was found, return digits.\n\treturn integ, fract, []uint{}\n}", "func d(a int, b int) int {\n\treturn a/b\n}", "func (g *Group) Div(divisor int) Group {\n\tg.GrainDishes /= divisor\n\tg.VegetableDishes /= divisor\n\tg.FishAndMealDishes /= divisor\n\tg.Milk /= divisor\n\tg.Fruit /= divisor\n\treturn *g\n}", "func Divide(a, b float64) (result float64, err error) {\n\tif b != 0 {\n\t\treturn a / b, err\n\t}\n\terr = errors.New(\"you cannot divide by 0\")\n\n\treturn 555, err\n}", "func DIVL(mr operand.Op) { ctx.DIVL(mr) }", "func Divide(v *Vec, div float64) *Vec {\n\treturn &Vec{\n\t\tv.X / div,\n\t\tv.Y / div,\n\t}\n}", "func gfDivide(a, b gfElement) gfElement {\n\tif a == gfZero {\n\t\treturn gfZero\n\t} else if b == gfZero {\n\t\tlog.Panicln(\"Divide by zero\")\n\t}\n\n\treturn gfMultiply(a, gfInverse(b))\n}", "func (p Point2) Div(ps ...Point2) Point2 {\n\tfor _, p2 := range ps {\n\t\tp[0] /= p2[0]\n\t\tp[1] /= p2[1]\n\t}\n\treturn p\n}", "func (c Currency) Div(d Currency) Currency {\n\tf := (c.guardf * c.dpf * float64(c.m)) / float64(d.m) / c.guardf\n\ti := int64(f)\n\treturn c.Set(rnd(i, f-float64(i)))\n}", "func DIVB(mr operand.Op) { ctx.DIVB(mr) }", "func DivFactor(numerator, denominator Factorization) Factorization {\n\tvar f Factorization\n\tvar p PrimeFactor\n\tfor _, nv := range numerator {\n\t\tp.exp = nv.exp\n\t\tp.prime = nv.prime\n\t\tfor _, dv := range denominator {\n\t\t\tif nv.prime == dv.prime {\n\t\t\t\tif nv.exp < dv.exp {\n\t\t\t\t\tfmt.Println(\"ERROR\")\n\t\t\t\t\tos.Exit(1)\n\t\t\t\t}\n\t\t\t\tp.exp = nv.exp - dv.exp\n\t\t\t}\n\t\t}\n\t\tif p.exp != 0 {\n\t\t\tf = append(f, p)\n\t\t}\n\t}\n\n\treturn f\n}", "func Divide(a, b int) (int, error) {\n\tif b == 0 {\n\t\treturn 0, errors.New(\"cannot divide by 0\")\n\t}\n\treturn a / b, nil\n}", "func Div(x, y *big.Int) *big.Int {\n\treturn new(big.Int).Div(x, y)\n}", "func (q Quat) Div(other Quat) Quat {\n\treturn Quat{q.W / other.W, q.X / other.X, q.Y / other.Y, q.Z / other.Z}\n}", "func Divide(a, b int64) (int64, int64, error) {\n\tif b == 0 {\n\t\treturn 0, 0, ErrDivideByZero\n\t}\n\treturn a / b, a % b, nil\n}", "func (n *Uint256) Div(divisor *Uint256) *Uint256 {\n\treturn n.Div2(n, divisor)\n}", "func DIVPS(mx, x operand.Op) { ctx.DIVPS(mx, x) }", "func (s *server) Divide(ctx context.Context, in *pb.DivideRequest) (*pb.DivideReply, error) {\n\treturn &pb.DivideReply{N1: in.N1 / in.N2}, nil\n}", "func NewDivExpr(scanner parser.Scanner, a, b Expr) Expr {\n\treturn newArithExpr(scanner, a, b, \"/\", func(a, b float64) float64 { return a / b })\n}", "func (v *Vec3i) SetDiv(other Vec3i) {\n\tv.X /= other.X\n\tv.Y /= other.Y\n\tv.Z /= other.Z\n}", "func (v Posit8x4) Div(x Posit8x4) Posit8x4 {\n\tout := Posit8x4{impl: make([]Posit8, 4)}\n\tfor i, posit := range v.impl {\n\t\tout.impl[i] = posit.Div(x.impl[i])\n\t}\n\treturn out\n}", "func (g *Graph) Div(x1 Node, x2 Node) Node {\n\treturn g.NewOperator(fn.NewDiv(x1, x2), x1, x2)\n}", "func (a *Vec4) Divide(s float32) {\n\ta.X /= s\n\ta.Y /= s\n\ta.Z /= s\n\ta.W /= s\n}", "func division(dividend, divisor int) int {\n\tsign := 1\n\tif (dividend < 0 && divisor > 0) || (dividend > 0 && divisor < 0) {\n\t\tsign = -1\n\t}\n\n\tdividend = abs(dividend)\n\tdivisor = abs(divisor)\n\n\tquotient := 0\n\tfor dividend > divisor {\n\t\tdividend -= divisor\n\t\tquotient++\n\t}\n\n\treturn sign * quotient\n}", "func DivMod(a int, b int, div *int, mod *int) {\n\t*div = a / b\n\t*mod = a % b\n}", "func DIVW(mr operand.Op) { ctx.DIVW(mr) }", "func RealDiv(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"RealDiv\",\n\t\tInput: []tf.Input{\n\t\t\tx, y,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func (gf *GaloisField) Divide(a, b int) int {\n\tif b == 0 {\n\t\tpanic(\"divide by zero\")\n\t} else if a == 0 {\n\t\treturn 0\n\t}\n\treturn gf.ALogTbl[(gf.LogTbl[a]-gf.LogTbl[b])%(gf.Size-1)]\n}", "func (p Point) Div(k int) Point {\n\treturn Point{X: p.X / k, Y: p.Y / k}\n}", "func Div(hi, lo, y uint) (quo, rem uint) {\n\tif UintSize == 32 {\n\t\tq, r := Div32(uint32(hi), uint32(lo), uint32(y))\n\t\treturn uint(q), uint(r)\n\t}\n\tq, r := Div64(uint64(hi), uint64(lo), uint64(y))\n\treturn uint(q), uint(r)\n}", "func divmod(a, b int) (q int, r int) {\n\tif b == 0 {\n\t\treturn\n\t}\n\tq = a / b\n\tr = a % b\n\treturn\n}", "func (p Point) Div(k int) Point {\n\treturn Point{p.X / k, p.Y / k}\n}", "func (p Point) Div(k int) Point { return Point{p.X / k, p.Y / k} }", "func (b ValExprBuilder) Div(expr interface{}) ValExprBuilder {\n\treturn b.makeBinaryExpr('/', expr)\n}", "func Div(dividend, divisor *big.Int) *big.Int { return I().Div(dividend, divisor) }", "func divmod(x, m uint64) (quo, rem uint64) {\n\tquo = x / m\n\trem = x % m\n\treturn\n}", "func DIVQ(mr operand.Op) { ctx.DIVQ(mr) }", "func IntDiv(arg, arg2 int64) (quotient int64) {\n\tquotient = arg / arg2\n\treturn\n}", "func (i I) Divide(i2 I) I {\n\ti.X /= i2.X\n\ti.Y /= i2.Y\n\treturn i\n}", "func (v Posit16x2) Div(x Posit16x2) Posit16x2 {\n\tout := Posit16x2{impl: make([]Posit16, 2)}\n\tfor i, posit := range v.impl {\n\t\tout.impl[i] = posit.Div(x.impl[i])\n\t}\n\treturn out\n}", "func Divide(a int, b int) (int, error) {\n\t// cannot divide by 0\n\tif b == 0 {\n\t\t// use in-built errors interface to return error message\n\t\treturn 0, errors.New(\"cannot divide by 0\")\n\t}\n\t// otherwise perform calculation\n\treturn (a / b), nil\n}", "func (p *Point) Div(to *Point, progress float64) *Point {\n\treturn &Point{\n\t\tX: p.X*progress + to.X*(1-progress),\n\t\tY: p.Y*progress + to.Y*(1-progress),\n\t}\n}", "func (d Decimal) Div(d2 Decimal) Decimal {\n\treturn d.DivRound(d2, int32(DivisionPrecision))\n}", "func (d Decimal) Div(d2 Decimal) Decimal {\n\treturn d.DivRound(d2, int32(DivisionPrecision))\n}", "func (s Slot) Div(x uint64) Slot {\n\tres, err := s.SafeDiv(x)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn res\n}", "func Division(t1 TermT, t2 TermT) TermT {\n\treturn TermT(C.yices_division(C.term_t(t1), C.term_t(t2)))\n}", "func div(x byte, y byte) byte {\n\tif x == 0 || y == 0 {\n\t\treturn 0\n\t}\n\treturn expOp[0xff+logOp[x]-logOp[y]]\n}" ]
[ "0.79124904", "0.78728545", "0.7719235", "0.75640553", "0.75489855", "0.74454725", "0.74383354", "0.73700964", "0.7330844", "0.73209095", "0.7217562", "0.7189715", "0.7181681", "0.7181149", "0.7108846", "0.7078168", "0.7078131", "0.7065987", "0.70544964", "0.7045082", "0.7041542", "0.7021016", "0.6984764", "0.69839543", "0.6909516", "0.6893689", "0.6858438", "0.6858438", "0.6857073", "0.68196505", "0.6803497", "0.67783546", "0.6775974", "0.677397", "0.6770472", "0.67629385", "0.6724931", "0.6702249", "0.66859895", "0.66648555", "0.66547036", "0.66535634", "0.66210586", "0.65907806", "0.6587033", "0.6586689", "0.64833635", "0.6439238", "0.6438553", "0.64374495", "0.6433771", "0.6431263", "0.64231443", "0.6418868", "0.640959", "0.6402519", "0.63980925", "0.63949853", "0.63761044", "0.6368021", "0.6343336", "0.6336698", "0.63285637", "0.63134384", "0.6309537", "0.6309116", "0.6307739", "0.6305218", "0.6302653", "0.6296199", "0.6295083", "0.62919873", "0.62891555", "0.6266237", "0.6254058", "0.62486064", "0.6237452", "0.6226788", "0.6216987", "0.62144417", "0.62002647", "0.6195784", "0.6186398", "0.6175921", "0.61686444", "0.6153406", "0.6153047", "0.61470354", "0.6119127", "0.610901", "0.6106404", "0.6105649", "0.60895246", "0.6083601", "0.60560435", "0.60461587", "0.60461587", "0.60428256", "0.60390097", "0.6022055" ]
0.8076266
0
Sqrt sets f = Sqrt(x) and returns f.
Sqrt устанавливает f = Sqrt(x) и возвращает f.
func (f *Float) Sqrt(x *Float) *Float { x.doinit() f.doinit() C.mpf_sqrt(&f.i[0], &x.i[0]) return f }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Sqrt (x float64) float64 {\n \n // Find the whole number sqrt.\n wholeSqrt := newtonSqrtFunc ( x, 0.0, x / 2.0, 1.0 )\n\n // Find one decimal point sqrt.\n return newtonSqrtFunc ( x, wholeSqrt, wholeSqrt + 1, 0.01 )\n}", "func Sqrt(f float64) (float64, error) {\n\tif f < 0 {\n\t\terr := fmt.Errorf(\"square root of negative number: %v\", f)\n\t\treturn 0, &ErrImaginaryNumber{\"value\", err}\n\t}\n\treturn math.Sqrt(f), nil\n}", "func Sqrt(x float64) float64 {\n\treturn math.Sqrt(x)\n}", "func Sqrt(x int) int {\n\treturn neogointernal.Opcode1(\"SQRT\", x).(int)\n}", "func (z *Float) Sqrt(x *Float) *Float {\n\t// following IEEE754-2008 (section 7.2)\n\t// possible: panic(ErrNaN{\"square root of negative operand\"})\n}", "func Sqrt(x float64) (float64, error) {\n\tif x < 0 {\n\t\treturn 0, ErrNegativeSqrt(x)\n\t}\n\tconst epsilon = 1.0e-15\n\tz := 1.0\n\told := x * x\n\tfor delta := old - z; delta > epsilon; {\n\t\told = z\n\t\tz -= (z*z - x) / (2 * z)\n\t\tdelta = math.Abs(old - z)\n\t}\n\treturn z, nil\n}", "func Sqrt(arg float64) float64 {\n\treturn math.Sqrt(arg)\n}", "func Sqrt(a float64) (float64, error) {\n\tif a < 0 {\n\t\treturn 0, fmt.Errorf(\"%f is invalid input for Sqrt, it's negative number\", a)\n\t}\n\treturn math.Sqrt(a), nil\n}", "func Sqrt(f float64) (float64, error) {\n\tif f < 0 {\n\t\treturn 0, errors.New(\"Received a negative number\")\n\t}\n\treturn 42, nil\n}", "func Sqrt(a float64) (result float64, err error) {\n\tif a >= 0 {\n\t\treturn math.Sqrt(a), err\n\t}\n\terr = errors.New(\"you need to enter a number greater than 0\")\n\n\treturn 777, err\n}", "func Sqrt(sqrt int) float64 {\n //this converts the int value of user input to float64\n newSqrt := float64(sqrt)\n //calculates the value\n return math.Sqrt(newSqrt)\n}", "func sqrt(x float64) (float64, error) {\n\tif x < 0 {\n\t\treturn 0, errors.New(\"undefined for negative numbers\")\n\t}\n\treturn math.Sqrt(x), nil\n}", "func Sqrt(z, x *decimal.Big) *decimal.Big {\n\tif xs := x.Sign(); xs <= 0 {\n\t\tif xs == 0 {\n\t\t\treturn z.SetMantScale(0, 0)\n\t\t}\n\t\tz.SetNaN(false)\n\t\treturn signal(z,\n\t\t\tdecimal.InvalidOperation,\n\t\t\terrors.New(\"math.Sqrt: cannot take square root of negative number\"),\n\t\t)\n\t}\n\tif snan := x.IsNaN(true); snan || x.IsNaN(false) {\n\t\tx.SetNaN(snan)\n\t\treturn signal(z,\n\t\t\tdecimal.InvalidOperation, decimal.ErrNaN{\"square root of NaN\"})\n\t}\n\tif x.IsInf(1) {\n\t\treturn z.SetInf(false)\n\t}\n\n\tzcp := z.Context.Precision()\n\n\t// Fast path #1: use math.Sqrt if our decimal is small enough. 0 and 22\n\t// are implementation details of the Float64 method. If Float64 is altered,\n\t// change them.\n\tif zcp <= 16 && (x.Scale() >= 0 && x.Scale() < 22) {\n\t\treturn z.SetFloat64(math.Sqrt(x.Float64())).Round(zcp)\n\t}\n\n\t// Fast path #2: x is a small perfect square.\n\tif x.IsInt() && !x.IsBig() {\n\t\tswitch xc := x.Int64(); xc & 0xF {\n\t\tcase 0, 1, 4, 9:\n\t\t\t// \"Show that floating point sqrt(x*x) >= x for all long x.\"\n\t\t\t// https://math.stackexchange.com/a/238885/153292\n\t\t\tsqrt := int64(math.Sqrt(float64(xc)))\n\t\t\tif sqrt*sqrt == xc {\n\t\t\t\treturn z.SetMantScale(sqrt, 0)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Source for the following algorithm:\n\t//\n\t// T. E. Hull and A. Abrham. 1985. Properly rounded variable precision\n\t// square root. ACM Trans. Math. Softw. 11, 3 (September 1985), 229-237.\n\t// DOI: https://doi.org/10.1145/214408.214413\n\n\tvar (\n\t\txp = int32(x.Precision())\n\n\t\t// The algorithm requires a normalized ``f ∈ [0.1, 1)'' Of the two ways\n\t\t// to normalize f, adjusting its scale is the quickest. However, it then\n\t\t// requires us to increment approx's scale by e/2 instead of simply\n\t\t// setting it to e/2.\n\t\tf = new(decimal.Big).Copy(x).SetScale(xp)\n\n\t\t// It also means we have to adjust e to equal out the sale adjustment.\n\t\te = xp - x.Scale()\n\n\t\ttmp decimal.Big\n\t\tapprox = alias(z, x)\n\t)\n\n\tif e&1 == 0 {\n\t\tapprox.Add(approx1, tmp.Mul(approx2, f)) // approx := .259 + .819f\n\t} else {\n\t\tf.Quo(f, ten) // f := f/10\n\t\te++ // e := e + 1\n\t\tapprox.Add(approx3, tmp.Mul(approx4, f)) // approx := 0.819 + 2.59*f\n\t}\n\n\tvar (\n\t\tmaxp = zcp + 2\n\t\tp int32 = 3\n\t)\n\n\tfor p < maxp {\n\t\t// p := min(2*p - 2, maxp)\n\t\tif p = 2*p - 2; p > maxp {\n\t\t\tp = maxp\n\t\t}\n\t\t// precision p\n\t\ttmp.Context.SetPrecision(p)\n\t\t// approx := .5*(approx + f/approx)\n\t\tapprox.Mul(ptFive, tmp.Add(approx, tmp.Quo(f, approx)))\n\t}\n\n\t// The paper also specifies an additional code block for adjusting approx.\n\t// This code never went into the branches that modified approx, rounding\n\t// to half even does the same thing. The GDA spec requires us to use\n\t// rounding mode half even (speleotrove.com/decimal/daops.html#refsqrt)\n\t// anyway.\n\n\tapprox.Context.RoundingMode = decimal.ToNearestEven\n\treturn z.Set(approx.SetScale(approx.Scale() - e/2).Round(zcp))\n}", "func Sqrt(x float64) (float64, error) {\n\tif x < 0 {\n\t\treturn 0, ErrNegativeSqrt(x)\n\t}\n\t\n\tz := 1.0\n\tvar y float64\n\titers := 0\n\tsens := 1e-10\n\tfmt.Println(\"Printing iterations of Newton's Method:\")\n\tfor {\n\t\ty -= (z*z - x) / (2*z)\n\t\tif Abs(z - y) < sens {\n\t\t\tbreak\n\t\t}\n\t\titers++\n\t\tz = y\n\t\tfmt.Println(z)\n\t}\n\t\n\tfmt.Println(\"Number of iterations:\", iters)\n\treturn z, nil\n}", "func Sqrt(x float64) float64 {\n\t//Z is our starting value for testing the x value.\n\tz := float64(1)\n\n\t//D is our delta value, its the difference so we know when our loop ends.\n\td := float64(1)\n\n\t//The loop will continue while the delta value is higher than 10^-10. Aka there is barely a difference\n\tfor d > 10E-10 {\n\t\t//z0 will be used to compare new and old z values.\n\t\tz0 := z\n\n\t\t//Using Newtons method used to approximate the square root of a value.\n\t\t//This algorithm was provided in the exercise.\n\t\tz = z - (z*z-x)/(2*z)\n\n\t\t//Delta is the difference between our old z value and the new we got from\n\t\t//Newtons method above.\n\t\td = z - z0\n\n\t\t//Delta can become both a negative value and a positive, here we make the value\n\t\t//Positive if it is negative already so the loop can continue.\n\t\tif d < 0 {\n\t\t\t//\td = -d\n\t\t\td = math.Abs(d) //There is two ways of making the delta value positive, the math function or the above\n\t\t}\n\t}\n\n\t//Returns Square root of x\n\treturn z\n}", "func Sqrt(number float64) (float64, error) {\n\tif number < 0 {\n\t\treturn 0.0, errors.New(\"#NUM!\t-\tOccurred because the supplied number argument is negative\")\n\t}\n\n\tif math.IsNaN(number) {\n\t\treturn 0.0, errors.New(\"#VALUE!\t-\tOccurred because the supplied number argument is non-numeric\")\n\t}\n\n\treturn math.Sqrt(number), nil\n}", "func Sqrt(x float64) (float64, float64) {\n\tz := 1.0\n\tfor i := 0; i < 10; i++ {\n\t\tz -= (z*z - x) / (2 * z)\n\t}\n\treturn z, math.Sqrt(x)\n}", "func sqrt(x float64) string {\n\t// simple if statement\n\t// if value < 0\n\tif x < 0 {\n\t\t// re-run function on positive value\n\t\treturn sqrt(-x) + \"i\"\n\t}\n\n\t// if positive, simply get root of value\n\treturn fmt.Sprint(math.Sqrt(x))\n}", "func (c *Clac) Sqrt() error {\n\treturn c.applyFloat(1, func(vals []value.Value) (value.Value, error) {\n\t\treturn unary(\"sqrt\", vals[0])\n\t})\n}", "func Sqrt(a Tensor, opts ...FuncOpt) (retVal Tensor, err error) {\n\tswitch t := a.(type) {\n\tcase *Dense:\n\t\tif t.IsMaterializable() {\n\t\t\tvar f interface{}\n\t\t\tswitch t.t.Kind() {\n\t\t\tcase reflect.Float64:\n\t\t\t\tf = math.Sqrt\n\t\t\tcase reflect.Float32:\n\t\t\t\tf = math32.Sqrt\n\t\t\tdefault:\n\t\t\t\terr = errors.Errorf(\"Sqrt only works on floats\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\treturn t.Apply(f, opts...)\n\t\t}\n\t\tif !isFloat(t.t) {\n\t\t\terr = errors.Errorf(\"Sqrt only works on floats\")\n\t\t\treturn\n\t\t}\n\n\t\t// otherwise, we have optimizations for this\n\t\tvar reuse *Dense\n\t\tvar safe, toReuse, incr bool\n\t\tif reuse, safe, toReuse, incr, err = prepUnaryDense(t, opts...); err != nil {\n\t\t\terr = errors.Wrapf(err, opFail, \"PointwiseSquare\")\n\t\t\treturn\n\t\t}\n\n\t\tswitch {\n\t\tcase incr:\n\t\t\tcloned := t.Clone().(*Dense)\n\t\t\tswitch t.t.Kind() {\n\t\t\tcase reflect.Float64:\n\t\t\t\tvecf64.Sqrt(cloned.float64s())\n\t\t\tcase reflect.Float32:\n\t\t\t\tvecf32.Sqrt(cloned.float32s())\n\t\t\t}\n\t\t\t_, err = reuse.Add(cloned, UseUnsafe())\n\t\t\tretVal = reuse\n\t\tcase toReuse:\n\t\t\tcopyDense(reuse, t)\n\t\t\tswitch t.t.Kind() {\n\t\t\tcase reflect.Float64:\n\t\t\t\tvecf64.Sqrt(reuse.float64s())\n\t\t\tcase reflect.Float32:\n\t\t\t\tvecf32.Sqrt(reuse.float32s())\n\t\t\t}\n\t\t\tretVal = reuse\n\t\tcase safe:\n\t\t\tcloned := t.Clone().(*Dense)\n\t\t\tswitch t.t.Kind() {\n\t\t\tcase reflect.Float64:\n\t\t\t\tvecf64.Sqrt(cloned.float64s())\n\t\t\tcase reflect.Float32:\n\t\t\t\tvecf32.Sqrt(cloned.float32s())\n\t\t\t}\n\t\t\tretVal = cloned\n\t\tcase !safe:\n\t\t\tswitch t.t.Kind() {\n\t\t\tcase reflect.Float64:\n\t\t\t\tvecf64.Sqrt(t.float64s())\n\t\t\tcase reflect.Float32:\n\t\t\t\tvecf32.Sqrt(t.float32s())\n\t\t\t}\n\t\t\tretVal = t\n\t\t}\n\tdefault:\n\t\tpanic(\"NYI - not yet implemented\")\n\t}\n\treturn\n}", "func (g *Graph) Sqrt(x Node) Node {\n\treturn g.NewOperator(fn.NewSqrt(x), x)\n}", "func Sqrt(x float64) float64 {\n\tvar zN, zN1 float64 = 1.0, 0.0\n\n\tzN1 = zN - ((zN*zN)-x)/(2*zN)\n\n\tfor math.Abs(zN-zN1) > 0.000001 {\n\t\tzN = zN1\n\t\tzN1 = zN - ((zN*zN)-x)/(2*zN)\n\t}\n\treturn zN1\n}", "func (z *Decimal) Sqrt(x *Decimal) *Decimal {\n\tif debugDecimal {\n\t\tx.validate()\n\t}\n\n\tif z.prec == 0 {\n\t\tz.prec = x.prec\n\t}\n\n\tif x.Sign() == -1 {\n\t\t// following IEEE754-2008 (section 7.2)\n\t\tpanic(ErrNaN{\"square root of negative operand\"})\n\t}\n\n\t// handle ±0 and +∞\n\tif x.form != finite {\n\t\tz.acc = Exact\n\t\tz.form = x.form\n\t\tz.neg = x.neg // IEEE754-2008 requires √±0 = ±0\n\t\treturn z\n\t}\n\n\t// MantExp sets the argument's precision to the receiver's, and\n\t// when z.prec > x.prec this will lower z.prec. Restore it after\n\t// the MantExp call.\n\tprec := z.prec\n\tb := x.MantExp(z)\n\tz.prec = prec\n\n\t// Compute √(z·10**b) as\n\t// √( z)·10**(½b) if b is even\n\t// √(10z)·10**(⌊½b⌋) if b > 0 is odd\n\t// √(z/10)·10**(⌈½b⌉) if b < 0 is odd\n\tswitch b % 2 {\n\tcase 0:\n\t\t// nothing to do\n\tcase 1:\n\t\tz.exp++\n\tcase -1:\n\t\tz.exp--\n\t}\n\t// 0.01 <= z < 10.0\n\n\t// Unlike with big.Float, solving x² - z = 0 directly is faster only for\n\t// very small precisions (<_DW/2).\n\t//\n\t// Solve 1/x² - z = 0 instead.\n\tz.sqrtInverse(z)\n\n\t// restore precision and re-attach halved exponent\n\treturn z.SetMantExp(z, b/2)\n}", "func safeSqrt(x float64) (float64, error) {\n\tif x < 0 {\n\t\treturn 0, ErrNegativeSqrt(x)\n\t}\n\treturn math.Sqrt(x), nil\n}", "func Sqrt(value gcv.Value) gcv.Value {\n\tif value.Type() == gcv.Complex {\n\t\treturn gcv.MakeValue(cmplx.Sqrt(value.Complex()))\n\t}\n\treturn gcv.MakeValue(math.Sqrt(value.Real()))\n}", "func (self *State)Sqrt(a any)any{\n self.IncOperations(self.coeff[\"sqrt\"]+self.off[\"sqrt\"])\n return wrap1(a,math.Sqrt)\n}", "func sqrt(f float64) (float64, error) {\n\tif f < 0 {\n\t\treturn 0, errors.New(\"norgate math: square root of negative number\")\n\t\t// return 0, fmt.Errorf(\"math err: square root of negative number: %v\", f)\n\t}\n\treturn 26, nil\n}", "func Sqrt(x float64) float64 {\n\tz, d := 1.0, 1.0\n\tfor math.Abs(d) > 1e-15 {\n\t\tzPrevious := z\n\t\tz = z - ((z*z - x) / (2 * z))\n\t\td = zPrevious - z\n\t\tfmt.Printf(\"Current delta: %v, z: %v, zPrevious: %v\\n\", d, z, zPrevious)\n\t}\n\treturn z\n}", "func Sqrt(x float64) float64 {\n\tz := 1.0\n\ti := 1\n\tchanging := true\n\tfor changing {\n\t\tz1 := SqrtZ(x, z)\n\t\tfmt.Printf(\"loop: %v, value: %g\\n\", i, z1)\n\n\t\tchanging = math.Abs(z1-z) > 0.000000000000001\n\t\tz = z1\n\t\ti++\n\t}\n\treturn z\n}", "func funcSqrt(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector {\n\treturn simpleFunc(vals, enh, math.Sqrt)\n}", "func Sqrt(x float64) float64 {\n\tz:=45.0\n\tfor ; z*z-x>0.0000001;{\n\t\tz -= (z*z - x) / (2*z)\n\t\tfmt.Println(z)\n\t}\n\treturn z\n}", "func op_f64_sqrt(expr *CXExpression, fp int) {\n\tinp1, out1 := expr.Inputs[0], expr.Outputs[0]\n\toutB1 := FromF64(math.Sqrt(ReadF64(fp, inp1)))\n\tWriteMemory(GetFinalOffset(fp, out1), outB1)\n}", "func (v *Vector3) Sqrt() {\n\tv.X = math.Sqrt(v.X)\n\tv.Y = math.Sqrt(v.Y)\n\tv.Z = math.Sqrt(v.Z)\n}", "func Sqrt(x float64) float64 {\n z := 1.0;\n for i := 0; i < 10; i++ {\n fmt.Println(z)\n z -= (z*z - x) / (2*z)\n }\n return z\n}", "func sqrt(f float64) (float64, error) {\n\tif f < 0 {\n\t\tanError := fmt.Errorf(\"I'm an error, my value is %v\", f)\n\t\t// Need to return a float64 and a value of type \"Error\"\n\t\treturn 0, sqrtError{\"50.2289 N\", \"99.4656 W\", anError}\n\t}\n\treturn 42, nil\n}", "func mySqrt(x int) int {\n\tif x == 0 {\n\t\treturn 0\n\t}\n\tr := x\n\tfor {\n\t\td := (r - x/r) / 2\n\t\tif d == 0 {\n\t\t\tbreak\n\t\t}\n\t\tr -= d\n\t}\n\tif r*r > x {\n\t\treturn r - 1\n\t}\n\treturn r\n}", "func mySqrt(x int) int {\n\tvar i int\n\tfor i*i <= x {\n\t\ti++\n\t}\n\treturn i - 1\n}", "func InvSqrt(x float32) float32 {\n\txhalf := float32(0.5) * x\n\ti := *(*int32)(unsafe.Pointer(&x))\n\ti = int32(0x5f3759df) - int32(i>>1)\n\tx = *(*float32)(unsafe.Pointer(&i))\n\tx = x * (1.5 - (xhalf * x * x))\n\treturn x\n}", "func InvSqrt(x float32) float32 {\n\txhalf := float32(0.5) * x\n\ti := *(*int32)(unsafe.Pointer(&x))\n\ti = int32(0x5f3759df) - int32(i>>1)\n\tx = *(*float32)(unsafe.Pointer(&i))\n\tx = x * (1.5 - (xhalf * x * x))\n\treturn x\n}", "func SQRTSD(mx, x operand.Op) { ctx.SQRTSD(mx, x) }", "func findSqrt(x, y float64, z int) float64 {\n\t// track x before/after increment\n\tvar xNew float64 = x\n\n\t// repeat for z iterations\n\tfor i := 1; i <= z; i++ {\n\t\t// store current version of x\n\t\tvar xOld = xNew\n\n\t\t// calculate distance between square of x and actual y\n\t\t// scale down difference using derivative function (i.e. / 2x)\n\t\t// decrement x to get closer to actual square root\n\t\txNew -= ((xNew * xNew) - y) / (2 * xNew)\n\n\t\t// show progress\n\t\tfmt.Println(xNew, xNew * xNew, y)\n\n\t\t// return output if value has converged (i.e. found perfect square root)\n\t\tif xNew - xOld == 0 {\n\t\t\t// return final approximation of sqrt\n\t\t\treturn xNew\n\t\t}\n\t}\n\n\t// return final approximation of sqrt\n\treturn x\n}", "func sqrt(x float64) string {\n\tif x < 0 {\n\t\treturn sqrt(-x) + \"i\"\n\t}\n\treturn fmt.Sprint(math.Sqrt(x))\n}", "func FloatSqrt(z *big.Float, x *big.Float,) *big.Float", "func InvSqrt(a Tensor, opts ...FuncOpt) (retVal Tensor, err error) {\n\tswitch t := a.(type) {\n\tcase *Dense:\n\t\tif t.IsMaterializable() {\n\t\t\tvar f interface{}\n\t\t\tswitch t.t.Kind() {\n\t\t\tcase reflect.Float64:\n\t\t\t\tf = func(a float64) float64 { return float64(1) / math.Sqrt(a) }\n\t\t\tcase reflect.Float32:\n\t\t\t\tf = func(a float32) float32 { return float32(1) / math32.Sqrt(a) }\n\t\t\tdefault:\n\t\t\t\terr = errors.Errorf(\"InvSqrt only works on floats\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\treturn t.Apply(f, opts...)\n\t\t}\n\t\tif !isFloat(t.t) {\n\t\t\terr = errors.Errorf(\"InvSqrt only works on floats\")\n\t\t\treturn\n\t\t}\n\n\t\t// otherwise, we have optimizations for this\n\t\tvar reuse *Dense\n\t\tvar safe, toReuse, incr bool\n\t\tif reuse, safe, toReuse, incr, err = prepUnaryDense(t, opts...); err != nil {\n\t\t\terr = errors.Wrapf(err, opFail, \"PointwiseSquare\")\n\t\t\treturn\n\t\t}\n\n\t\tswitch {\n\t\tcase incr:\n\t\t\tcloned := t.Clone().(*Dense)\n\t\t\tswitch t.t.Kind() {\n\t\t\tcase reflect.Float64:\n\t\t\t\tvecf64.InvSqrt(cloned.float64s())\n\t\t\tcase reflect.Float32:\n\t\t\t\tvecf32.InvSqrt(cloned.float32s())\n\t\t\t}\n\t\t\t_, err = reuse.Add(cloned, UseUnsafe())\n\t\t\tretVal = reuse\n\t\tcase toReuse:\n\t\t\tcopyDense(reuse, t)\n\t\t\tswitch t.t.Kind() {\n\t\t\tcase reflect.Float64:\n\t\t\t\tvecf64.InvSqrt(reuse.float64s())\n\t\t\tcase reflect.Float32:\n\t\t\t\tvecf32.InvSqrt(reuse.float32s())\n\t\t\t}\n\t\t\tretVal = reuse\n\t\tcase safe:\n\t\t\tcloned := t.Clone().(*Dense)\n\t\t\tswitch t.t.Kind() {\n\t\t\tcase reflect.Float64:\n\t\t\t\tvecf64.InvSqrt(cloned.float64s())\n\t\t\tcase reflect.Float32:\n\t\t\t\tvecf32.InvSqrt(cloned.float32s())\n\t\t\t}\n\t\t\tretVal = cloned\n\t\tcase !safe:\n\t\t\tswitch t.t.Kind() {\n\t\t\tcase reflect.Float64:\n\t\t\t\tvecf64.InvSqrt(t.float64s())\n\t\t\tcase reflect.Float32:\n\t\t\t\tvecf32.InvSqrt(t.float32s())\n\t\t\t}\n\t\t\tretVal = t\n\t\t}\n\tdefault:\n\t\tpanic(\"NYI - not yet implemented\")\n\t}\n\treturn\n}", "func SqrtRootFloat64(number float64) float64 {\n\tvar i uint64\n\tvar x, y float64\n\tf := 1.5\n\tx = number * 0.5\n\ty = number\n\ti = math.Float64bits(y)\n\ti = 0x5fe6ec85e7de30da - (i >> 1)\n\ty = math.Float64frombits(i)\n\ty = y * (f - (x * y * y))\n\ty = y * (f - (x * y * y))\n\treturn number * y\n}", "func Sqrt(x float64, p float64) (float64, int) {\n\ti := 0\n\tz := float64(1)\n\td := float64(0)\n\tfor math.Abs(z-d) > p {\n\t\ti++\n\t\td = z\n\t\tz -= (z*z - x) / (2 * z)\n\t}\n\treturn z, i\n}", "func (v Posit8x4) Sqrt() Posit8x4 {\n\tout := Posit8x4{impl: make([]Posit8, 4)}\n\tfor i, posit := range v.impl {\n\t\tout.impl[i] = posit.Sqrt()\n\t}\n\treturn out\n}", "func SQRTSS(mx, x operand.Op) { ctx.SQRTSS(mx, x) }", "func Sqrt(x int64) int64 {\n\tif x < 0 {\n\t\treturn -1\n\t}\n\t// p starts at the highest power of four less or equal to x\n\t//Fast way to make p highest power of 4 <= x\n\tvar v, n uint\n\tif x > 1<<32 {\n\t\tv = uint(x >> 32)\n\t\tn = 32\n\t} else {\n\t\tv = uint(x)\n\t}\n\tif v >= 1<<16 {\n\t\tv >>= 16\n\t\tn += 16\n\t}\n\tif v >= 1<<8 {\n\t\tv >>= 8\n\t\tn += 8\n\t}\n\tif v >= 1<<4 {\n\t\tv >>= 4\n\t\tn += 4\n\t}\n\tif v >= 1<<2 {\n\t\tn += 2\n\t}\n\tvar r, b int64\n\tfor p := int64(1 << n); p != 0; p >>= 2 {\n\t\tb = r | p\n\t\tr >>= 1\n\t\tif x >= b {\n\t\t\tx -= b\n\t\t\tr |= p\n\t\t}\n\t}\n\treturn r\n}", "func ModSqrt(x, p *big.Int) *big.Int {\n\treturn new(big.Int).ModSqrt(x, p)\n}", "func (fn *formulaFuncs) SQRT(argsList *list.List) formulaArg {\n\tif argsList.Len() != 1 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"SQRT requires 1 numeric argument\")\n\t}\n\tvalue := argsList.Front().Value.(formulaArg).ToNumber()\n\tif value.Type == ArgError {\n\t\treturn value\n\t}\n\tif value.Number < 0 {\n\t\treturn newErrorFormulaArg(formulaErrorNUM, formulaErrorNUM)\n\t}\n\treturn newNumberFormulaArg(math.Sqrt(value.Number))\n}", "func RSQRTSS(mx, x operand.Op) { ctx.RSQRTSS(mx, x) }", "func (v Posit16x2) Sqrt() Posit16x2 {\n\tout := Posit16x2{impl: make([]Posit16, 2)}\n\tfor i, posit := range v.impl {\n\t\tout.impl[i] = posit.Sqrt()\n\t}\n\treturn out\n}", "func (z *Int) ModSqrt(x, p *Int) *Int {}", "func IntSqrt(z *big.Int, x *big.Int,) *big.Int", "func Sqrt32(x float32) float32 {\n\treturn float32(math.Sqrt(float64(x)))\n}", "func (curve *Curve) Sqrt(a *big.Int) *big.Int {\n\tZERO := big.NewInt(0)\n\tONE := big.NewInt(1)\n\tTWO := big.NewInt(2)\n\tTHREE := big.NewInt(3)\n\tFOUR := big.NewInt(4)\n\n\tp := curve.P\n\tc := new(big.Int)\n\n\t// Simple Cases\n\t//\n\n\tif a.Cmp(ZERO) == 0 {\n\t\treturn ZERO\n\t} else if p.Cmp(TWO) == 0 {\n\t\treturn a.Mod(a, p)\n\t} else if LegendreSymbol(a, p) != 1 {\n\t\treturn ZERO\n\t} else if c.Mod(p, FOUR).Cmp(THREE) == 0 {\n\t\tc.Add(p, ONE)\n\t\tc.Div(c, FOUR)\n\t\tc.Exp(a, c, p)\n\t\treturn c\n\t}\n\n\t// Partition p-1 to s * 2^e for an odd s (i.e.\n\t// reduce all the powers of 2 from p-1)\n\t//\n\ts := new(big.Int)\n\ts.Sub(p, ONE)\n\n\te := new(big.Int)\n\te.Set(ZERO)\n\tfor c.Mod(s, TWO).Cmp(ZERO) == 0 {\n\t\ts.Div(s, TWO)\n\t\te.Add(e, ONE)\n\t}\n\n\t// Find some 'n' with a legendre symbol n|p = -1.\n\t// Shouldn't take long.\n\t//\n\tn := new(big.Int)\n\tn.Set(TWO)\n\tfor LegendreSymbol(n, p) != -1 {\n\t\tn.Add(n, ONE)\n\t}\n\t/*\n\t Here be dragons!\n\n\t Read the paper \"Square roots from 1; 24, 51,\n\t 10 to Dan Shanks\" by Ezra Brown for more\n\t information\n\t*/\n\n\t// x is a guess of the square root that gets better\n\t// with each iteration.\n\tx := new(big.Int)\n\tx.Add(s, ONE)\n\tx.Div(x, TWO)\n\tx.Exp(a, x, p)\n\n\t// b is the \"fudge factor\" - by how much we're off\n\t// with the guess. The invariant x^2 = ab (mod p)\n\t// is maintained throughout the loop.\n\tb := new(big.Int)\n\tb.Exp(a, s, p)\n\n\t// g is used for successive powers of n to update both a and b\n\tg := new(big.Int)\n\tg.Exp(n, s, p)\n\n\t// r is the exponent - decreases with each update\n\tr := new(big.Int)\n\tr.Set(e)\n\n\tt := new(big.Int)\n\tm := new(big.Int)\n\tgs := new(big.Int)\n\n\tfor {\n\t\tt.Set(b)\n\t\tm.Set(ZERO)\n\n\t\tfor ; m.Cmp(r) < 0; m.Add(m, ONE) {\n\t\t\tif t.Cmp(ONE) == 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tt.Exp(t, TWO, p)\n\t\t}\n\n\t\tif m.Cmp(ZERO) == 0 {\n\t\t\treturn x\n\t\t}\n\n\t\tgs.Sub(r, m)\n\t\tgs.Sub(gs, ONE)\n\t\tgs.Exp(TWO, gs, nil)\n\t\tgs.Exp(g, gs, p)\n\n\t\tg.Mod(g.Mul(gs, gs), p)\n\t\tx.Mod(x.Mul(x, gs), p)\n\t\tb.Mod(b.Mul(b, g), p)\n\t\tr.Set(m)\n\t}\n}", "func (d LegacyDec) ApproxSqrt() (LegacyDec, error) {\n\treturn d.ApproxRoot(2)\n}", "func (f *Float) SqrtUint(x uint) *Float {\n\tf.doinit()\n\tC.mpf_sqrt_ui(&f.i[0], C.ulong(x))\n\treturn f\n}", "func fqSqrt(c, u, v *Fq, s int) {\n\tt0, t1, t, r := &Fp{}, &Fp{}, &Fp{}, &Fp{}\n\ta, b, g := &Fp{}, &Fp{}, &Fp{}\n\n\t// a = u0*v0 + u1*v1\n\tfpMul(a, &u[0], &v[0])\n\tfpMul(t0, &u[1], &v[1])\n\tfpAdd(a, a, t0)\n\n\t// b = v0^2 + v1^2\n\tfpSqr(b, &v[0])\n\tfpSqr(t0, &v[1])\n\tfpAdd(b, b, t0)\n\n\t// g = u1*v0 - u0*v1\n\tfpMul(g, &u[1], &v[0])\n\tfpMul(t0, &u[0], &v[1])\n\tfpSub(g, g, t0)\n\n\t// t = 2(a + sqrt(a^2+g^2)) = 2*(a + (a^2+g^2)^(2^125))\n\t// if t=0; then t = 2*(a - (a^2+g^2)^(2^125))\n\tfpSqr(t0, a)\n\tfpSqr(t1, g)\n\tfpAdd(t0, t0, t1)\n\tfor i := 0; i < 125; i++ {\n\t\tfpSqr(t0, t0)\n\t}\n\tfpAdd(t, a, t0)\n\tif t.isZero() {\n\t\tfpSub(t, a, t0)\n\t}\n\tfpAdd(t, t, t)\n\n\t// r = (t*b^3)^(2^125-1)\n\tfpSqr(r, b)\n\tfpMul(r, r, b)\n\tfpMul(r, r, t)\n\tfpTwo1251(r, r)\n\n\t// x0 = (r*b*t)/2\n\t// x1 = (r*b*g)\n\tfpMul(&c[1], r, b)\n\tfpMul(&c[0], &c[1], t)\n\tfpHlf(&c[0], &c[0])\n\tfpMul(&c[1], &c[1], g)\n\n\t// if b*(2*x0)^2 == t then (x0,x1) <- (x1,x0)\n\tfpAdd(t0, &c[0], &c[0])\n\tfpSqr(t0, t0)\n\tfpMul(t0, t0, b)\n\tfpSub(t0, t0, t)\n\tif !t0.isZero() {\n\t\t*t0 = c[0]\n\t\tc[0] = c[1]\n\t\tc[1] = *t0\n\t}\n\n\tif fqSgn(c) != s {\n\t\tfqNeg(c, c)\n\t}\n}", "func SqrtGrad(scope *Scope, y tf.Output, dy tf.Output) (z tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"SqrtGrad\",\n\t\tInput: []tf.Input{\n\t\t\ty, dy,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func Sqr(x float64) float64 {\n\treturn math.Pow(x, 2)\n}", "func (c *Context) SQRTSD(mx, x operand.Op) {\n\tc.addinstruction(x86.SQRTSD(mx, x))\n}", "func exercise01() {\n\tx := 38892.0\n\tres1, it1 := sqrt(x)\n\tres2, it2 := sqrt2(x)\n\tfmt.Println(res1, it1)\n\tfmt.Println(res2, it2)\n\tfmt.Println(math.Sqrt(x))\n}", "func Sqrt(out, in *NArray) *NArray {\n\tif out == nil {\n\t\tout = New(in.Shape...)\n\t} else {\n\t\tif !EqualShape(out, in) {\n\t\t\tpanic(\"narrays must have equal shape.\")\n\t\t}\n\t}\n\tsqrtSlice(out.Data, in.Data)\n\treturn out\n}", "func TestSqrt1(t *testing.T) {\n\tstubs := Stub(&MUL, float64(2))\n\tdefer stubs.Reset()\n\tactual := Sqrt(float64(4.5))\n\tassert.Equal(t, actual, float64(3), \"should equal\")\n\tt.Log(\"TestSqrt1 Finished\")\n}", "func (c *Context) SQRTSS(mx, x operand.Op) {\n\tc.addinstruction(x86.SQRTSS(mx, x))\n}", "func DefaultSqrt(c elliptic.Curve, s *big.Int) *big.Int {\n\tvar r big.Int\n\tif nil == r.ModSqrt(s, c.Params().P) {\n\t\treturn nil // s is not a square\n\t}\n\treturn &r\n}", "func (c *Context) RSQRTSS(mx, x operand.Op) {\n\tc.addinstruction(x86.RSQRTSS(mx, x))\n}", "func VRSQRTSS(mx, x, x1 operand.Op) { ctx.VRSQRTSS(mx, x, x1) }", "func sqrt2(x float64) string {\n\tif x < 0 {\n\t\treturn sqrt(-x) + \"i\"\n\t}\n\treturn fmt.Sprint(math.Sqrt(x))\n}", "func SqrtZ(x, z float64) float64 {\n\treturn z - (math.Pow(z, 2)-x)/(2*z)\n}", "func sqrt(n int) int {\n for i := 1; i <= n; i++ {\n if n % i == 0 && n / i == i {\n return i\n }\n if n / i < i {\n panic(strconv.Itoa(n) + \" is not a perfect square\")\n }\n }\n panic(\"Cannot find sqrt of n <= 0\")\n}", "func SquareRootReal(x float64) float64 {\n\tswitch {\n\tcase x < 0:\n\t\treturn math.NaN()\n\tcase x == 0 || math.IsNaN(x) || math.IsInf(x, 1):\n\t\treturn x\n\t}\n\n\tl, r := 1.0, x // For x >= 1.0, x <= x*x, so, we search in interval: <1.0, x>.\n\tif x < 1.0 { // For x < 1.0, x > x*x, so, we search in interval: <x, 1.0>.\n\t\tl, r = r, l\n\t}\n\n\tfor cmp(l, r) == -1 {\n\t\tm := l + (r-l)/2\n\t\tswitch cmp(m*m, x) {\n\t\tcase 0:\n\t\t\treturn m\n\t\tcase 1:\n\t\t\tr = m\n\t\tcase -1:\n\t\t\tl = m\n\t\t}\n\t}\n\n\treturn l\n}", "func root(arg float64) (float64, error) {\n\tif arg < 0 {\n\t\t// If argument is negative, then return an arbitrary integer\n\t\t// And an error value. Basic error construction:\n\t\treturn -1, errors.New(\"number can not be negative\")\n\t}\n\n\t// A nil value indicates no error happened\n\treturn math.Sqrt(arg), nil\n}", "func intsqrt(n uint64, maxIters int) (uint64, error) {\n\tx0 := uint64(0)\n\tx1 := n\n\tfor i := 0; i <= maxIters/2; i++ {\n\t\tx0 = (x1 + n/x1) / 2 // TODO: determine if overflow is possible here\n\t\tif absDiff(x0, x1) <= 2 {\n\t\t\t// Stops if the delta is less than 2, to prevent a possible loop\n\t\t\treturn x0, nil\n\t\t}\n\n\t\tx1 = (x0 + n/x0) / 2 // TODO: determine if overflow is possible here\n\t\tif absDiff(x0, x1) <= 2 {\n\t\t\treturn x1, nil\n\t\t}\n\t}\n\treturn x1, fmt.Errorf(\"Exceeded desired iterations (%v)\", maxIters)\n}", "func (s *BasejossListener) EnterFuncSqrt(ctx *FuncSqrtContext) {}", "func BenchmarkMySqrt(b *testing.B) {\n\tsampleCase := 100\n\n\tb.Run(\"Without Library\", func(b *testing.B) {\n\t\tfor n := 0; n < b.N; n++ {\n\t\t\tmySqrtWithoutLib(sampleCase)\n\t\t}\n\t})\n\n\tb.Run(\"With Math Library\", func(b *testing.B) {\n\t\tfor n := 0; n < b.N; n++ {\n\t\t\tmySqrtWithMathLib(sampleCase)\n\t\t}\n\t})\n}", "func Sqrt_Ten(x float64) float64 {\n\tz := 1.0\n\n\tfor i := 0; i < 10; i += 1 {\n\t\tz -= ((z * z) - x) / (2 * z)\n\t}\n\n\treturn z\n}", "func ModSqrt(a *big.Int, factors []*big.Int) (*big.Int, bool) {\n\tn := big.NewInt(1) // Should be new big int!\n\tres := new(big.Int)\n\n\t// Solve problem one factor at a time\n\tfor i, fac := range factors {\n\t\tvar locRes *big.Int\n\t\tif fac.Cmp(bigFOUR) == 0 {\n\t\t\t// Special case for 4\n\t\t\tif a.Bit(1) != 0 {\n\t\t\t\treturn nil, false\n\t\t\t}\n\t\t\tif a.Bit(0) == 0 {\n\t\t\t\tlocRes = big.NewInt(2) // For safety sake, keep new\n\t\t\t} else {\n\t\t\t\tlocRes = big.NewInt(1) // For safety sake, keep new\n\t\t\t}\n\t\t} else {\n\t\t\tvar ok bool\n\t\t\tlocRes, ok = PrimeSqrt(new(big.Int).Mod(a, fac), fac)\n\t\t\tif !ok {\n\t\t\t\treturn nil, false\n\t\t\t}\n\t\t}\n\t\tif i == 0 {\n\t\t\tres = locRes\n\t\t} else {\n\t\t\tres = Crt(res, n, locRes, fac)\n\t\t}\n\t\tn.Mul(n, fac)\n\t}\n\treturn res, true\n}", "func (s *BasejossListener) ExitFuncSqrt(ctx *FuncSqrtContext) {}", "func IntModSqrt(z *big.Int, x, p *big.Int,) *big.Int", "func (d *GF255e) Sqrt(a *GF255e) uint64 {\n\t// Since p = 5 mod 8, we use Atkin's algorithm:\n\t// b <- (2*a)^((p-5)/8)\n\t// c <- 2*a*b^2\n\t// return a*b*(c - 1)\n\tvar b, c, e, x, x2, x96, y [4]uint64\n\n\t// e <- 2*a\n\tgf_lsh(&e, (*[4]uint64)(a), 1, mq255e)\n\n\t// Raise e to the power (p-5)/8. We use an addition chain with\n\t// 251 squarings and 13 extra multiplications:\n\t// (p-5)/8 = (2^240-1)*2^12 + (2^2-1)*2^9 + (2^3-1)*2^5 + 2^2\n\n\t// x2 <- e^3\n\tgf_sqr(&x2, &e, mq255e)\n\tgf_mul(&x2, &x2, &e, mq255e)\n\n\t// x <- e^(2^4-1)\n\tgf_sqr_x(&x, &x2, 2, mq255e)\n\tgf_mul(&x, &x, &x2, mq255e)\n\n\t// x <- e^(2^8-1)\n\tgf_sqr_x(&y, &x, 4, mq255e)\n\tgf_mul(&x, &y, &x, mq255e)\n\n\t// x <- e^(2^16-1)\n\tgf_sqr_x(&y, &x, 8, mq255e)\n\tgf_mul(&x, &y, &x, mq255e)\n\n\t// x <- e^(2^48-1)\n\tgf_sqr_x(&y, &x, 16, mq255e)\n\tgf_mul(&y, &y, &x, mq255e)\n\tgf_sqr_x(&y, &y, 16, mq255e)\n\tgf_mul(&x, &y, &x, mq255e)\n\n\t// x96 <- e^(2^96-1)\n\tgf_sqr_x(&y, &x, 48, mq255e)\n\tgf_mul(&x96, &y, &x, mq255e)\n\n\t// x <- e^(2^240-1)\n\tgf_sqr_x(&y, &x96, 96, mq255e)\n\tgf_mul(&y, &y, &x96, mq255e)\n\tgf_sqr_x(&y, &y, 48, mq255e)\n\tgf_mul(&x, &y, &x, mq255e)\n\n\t// x <- e^((p-5)/8)\n\tgf_sqr_x(&x, &x, 3, mq255e)\n\tgf_mul(&x, &x, &x2, mq255e)\n\tgf_sqr_x(&x, &x, 2, mq255e)\n\tgf_mul(&x, &x, &e, mq255e)\n\tgf_sqr_x(&x, &x, 2, mq255e)\n\tgf_mul(&x, &x, &x2, mq255e)\n\tgf_sqr_x(&x, &x, 3, mq255e)\n\tgf_mul(&x, &x, &e, mq255e)\n\tgf_sqr_x(&b, &x, 2, mq255e)\n\n\t// We now have b = (2*a)^((p-5)/8).\n\n\t// c <- 2*a*b^2\n\tgf_sqr(&c, &b, mq255e)\n\tgf_mul(&c, &c, &e, mq255e)\n\n\t// x <- a*b*(c - 1)\n\tgf_sub(&x, &c, (*[4]uint64)(&GF255e_ONE), mq255e)\n\tgf_mul(&x, &x, (*[4]uint64)(a), mq255e)\n\tgf_mul(&x, &x, &b, mq255e)\n\n\t// Verify the result. If not square, then set the result to 0.\n\tgf_sqr(&y, &x, mq255e)\n\tqr := gf_eq(&y, (*[4]uint64)(a), mq255e)\n\tfor i := 0; i < 4; i ++ {\n\t\tx[i] &= -qr\n\t}\n\n\t// Normalize the result, and negate the value if the least\n\t// significant bit is 1.\n\tgf_norm(&x, &x, mq255e)\n\tgf_condneg(&x, &x, mq255e, x[0] & 1)\n\n\t// Return the result.\n\tcopy(d[:], x[:])\n\treturn qr\n}", "func main() {\n hypot := func(x, y float64) float64 {\n return math.Sqrt(x*x + y*y)\n }\n fmt.Println(hypot(3, 4))\n}", "func SqrtBigRat(s *big.Rat) *big.Rat {\n\tconst iterations = 10\n\n\tx := big.NewRat(10, 1) // temp\n\ttmp := new(big.Rat) // temp\n\ttwo := big.NewRat(2, 1) // const\n\tfor n := uint8(0); n < iterations; n++ {\n\t\ttmp.Quo(s, x) // S/x\n\t\ttmp.Add(x, tmp) // x + S/x\n\t\tx.Quo(tmp, two) // (x + S/x) / 2\n\t}\n\treturn x\n}", "func main() {\n\tfmt.Printf(\"Now you have %g problems. \\n\", math.Sqrt(7))\n}", "func mySqrtBS(x int) int {\n\tlow := 0\n\thigh := x\n\tfor {\n\t\tr := (low + high) / 2\n\t\tsqr := r * r\n\t\tif sqr == x {\n\t\t\treturn r\n\t\t}\n\t\tif sqr < x {\n\t\t\tlow = r + 1\n\t\t} else {\n\t\t\thigh = r - 1\n\t\t}\n\t\tif low > high {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn low - 1\n}", "func (c *Context) VRSQRTSS(mx, x, x1 operand.Op) {\n\tc.addinstruction(x86.VRSQRTSS(mx, x, x1))\n}", "func IsPrimeSqrt(p int64) bool {\n\tif p < 2 {\n\t\treturn false\n\t}\n\tif p == 2 {\n\t\treturn true\n\t}\n\tif p%2 == 0 {\n\t\treturn false\n\t}\n\tfor i := int64(3); i*i <= p; i += 2 {\n\t\tif p%i == 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func Sqr(z *Elt, x *Elt) {\n\tMul(z, x, x)\n}", "func (fn *formulaFuncs) IMSQRT(argsList *list.List) formulaArg {\n\tif argsList.Len() != 1 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"IMSQRT requires 1 argument\")\n\t}\n\tvalue := argsList.Front().Value.(formulaArg).Value()\n\tinumber, err := strconv.ParseComplex(str2cmplx(value), 128)\n\tif err != nil {\n\t\treturn newErrorFormulaArg(formulaErrorNUM, err.Error())\n\t}\n\treturn newStringFormulaArg(cmplx2str(cmplx.Sqrt(inumber), value[len(value)-1:]))\n}", "func VSQRTSD(ops ...operand.Op) { ctx.VSQRTSD(ops...) }", "func SquareRoot(numbers []int) (squareRoots []float64, err error) {\n\tsquareRoots = make([]float64, len(numbers))\n\tfor i, number := range numbers {\n\t\tif number < 0 {\n\t\t\treturn []float64{}, errors.New(\"number must be positive\")\n\t\t}\n\t\tsquareRoots[i] = math.Sqrt(float64(number))\n\t}\n\treturn\n}", "func main() {\n\t_, err := sqrt(-4)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n}", "func SQRT_APPROX(x int32) int32 {\n\tif x <= 0 {\n\t\treturn 0\n\t}\n\n\tlz, frac_Q7 := CLZ_FRAC(x)\n\n\tvar y int32\n\n\tif lz&1 != 0 {\n\t\ty = 32768\n\t} else {\n\t\ty = 46214 /* 46214 = sqrt(2) * 32768 */\n\t}\n\n\t/* get scaling right */\n\ty >>= lz >> 1\n\n\ty = SMLAWB(y, y, SMULBB(213, frac_Q7))\n\n\treturn y\n}", "func est_square_root(tls *libc.TLS, x int32) int32 { /* speedtest1.c:617:12: */\n\tvar y0 int32 = (x / 2)\n\tvar y1 int32\n\tvar n int32\n\tfor n = 0; (y0 > 0) && (n < 10); n++ {\n\t\ty1 = ((y0 + (x / y0)) / 2)\n\t\tif y1 == y0 {\n\t\t\tbreak\n\t\t}\n\t\ty0 = y1\n\t}\n\treturn y0\n}", "func intRoot(n int) int {\n return int(math.Sqrt(float64(n))) + 1\n}", "func Tsfn(phi, sinphi, e float64) float64 {\n\tsinphi *= e\n\n\t/* avoid zero division, fail gracefully */\n\tdenominator := 1.0 + sinphi\n\tif denominator == 0.0 {\n\t\treturn math.MaxFloat64\n\t}\n\n\treturn (math.Tan(.5*(PiOverTwo-phi)) /\n\t\tmath.Pow((1.-sinphi)/(denominator), .5*e))\n}", "func main() {\n\tfmt.Printf(\"hello, world Sqrt(2) = %v\\n\", newmath.Sqrt(2))\n\tfmt.Printf(\"hello again\\n\")\n\tfmt.Printf(\"good-bye\\n\")\n}", "func VSQRTSS(ops ...operand.Op) { ctx.VSQRTSS(ops...) }" ]
[ "0.8192842", "0.8122174", "0.8062811", "0.7846377", "0.780029", "0.7689977", "0.76817685", "0.7642759", "0.75944746", "0.75353956", "0.7508509", "0.75048697", "0.74791354", "0.7394101", "0.7389043", "0.73785484", "0.73684794", "0.73366386", "0.72748697", "0.716924", "0.7115298", "0.7101069", "0.70777637", "0.7075356", "0.70681274", "0.7014083", "0.6984281", "0.6981121", "0.6905592", "0.68895155", "0.6850215", "0.6828275", "0.6754217", "0.6753524", "0.6715183", "0.6618173", "0.6613145", "0.6577874", "0.6577874", "0.6514878", "0.6472618", "0.64184505", "0.6392769", "0.63292915", "0.62606347", "0.6260071", "0.62558895", "0.61927193", "0.61823803", "0.6173549", "0.61504596", "0.6134116", "0.61316615", "0.60823685", "0.6077671", "0.6047745", "0.59913844", "0.5948307", "0.59459853", "0.5941594", "0.58972603", "0.5890985", "0.58861035", "0.58317673", "0.5746658", "0.5717139", "0.57072455", "0.566827", "0.56663597", "0.5612491", "0.5565991", "0.5561767", "0.55171436", "0.548268", "0.54559", "0.54530483", "0.54355645", "0.5393432", "0.5369196", "0.5356525", "0.53523976", "0.5336075", "0.5313661", "0.52564174", "0.5174103", "0.51447666", "0.5127709", "0.5115779", "0.50933266", "0.5059245", "0.5055097", "0.50185776", "0.5015356", "0.4915403", "0.48965603", "0.48933122", "0.4875121", "0.48544148", "0.48496506", "0.4819255" ]
0.82109225
0
PowUint sets f = x^y and returns f
PowUint устанавливает f = x^y и возвращает f
func (f *Float) PowUint(x *Float, y uint) *Float { x.doinit() f.doinit() C.mpf_pow_ui(&f.i[0], &x.i[0], C.ulong(y)) return f }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func op_f64_pow(expr *CXExpression, fp int) {\n\tinp1, inp2, out1 := expr.Inputs[0], expr.Inputs[1], expr.Outputs[0]\n\toutB1 := FromF64(math.Pow(ReadF64(fp, inp1), ReadF64(fp, inp2)))\n\tWriteMemory(GetFinalOffset(fp, out1), outB1)\n}", "func myPow(x float64, n int) float64 {\n\t// 位运算\n\tif n < 0 {\n\t\treturn 1 / pow(x, -n)\n\t} else {\n\t\treturn pow(x, n)\n\t}\n}", "func pow(a, b int64) int64 {\n\tp := int64(1)\n\tfor b > 0 {\n\t\tif b&1 != 0 {\n\t\t\tp *= a\n\t\t}\n\t\tb >>= 1\n\t\ta *= a\n\t}\n\treturn p\n}", "func intPow(a, b int) uint64 {\n\tr := uint64(1)\n\tfor b > 0 {\n\t\tr *= uint64(a)\n\t\tb--\n\t}\n\treturn r\n}", "func (self *State)Pow(a,b any)any{\n self.IncOperations(self.coeff[\"pow\"]+self.off[\"pow\"])\n return wrap2(a,b,math.Pow)\n}", "func Pow(x, y float64) float64 {\n\t// TODO: x or y NaN, ±Inf, maybe ±0.\n\tswitch {\n\tcase y == 0:\n\t\treturn 1\n\tcase y == 1:\n\t\treturn x\n\tcase x == 0 && y > 0:\n\t\treturn 0\n\tcase x == 0 && y < 0:\n\t\treturn Inf(1)\n\tcase y == 0.5:\n\t\treturn Sqrt(x)\n\tcase y == -0.5:\n\t\treturn 1 / Sqrt(x)\n\t}\n\n\tabsy := y;\n\tflip := false;\n\tif absy < 0 {\n\t\tabsy = -absy;\n\t\tflip = true;\n\t}\n\tyi, yf := Modf(absy);\n\tif yf != 0 && x < 0 {\n\t\treturn NaN()\n\t}\n\tif yi >= 1<<63 {\n\t\treturn Exp(y * Log(x))\n\t}\n\n\t// ans = a1 * 2^ae (= 1 for now).\n\ta1 := float64(1);\n\tae := 0;\n\n\t// ans *= x^yf\n\tif yf != 0 {\n\t\tif yf > 0.5 {\n\t\t\tyf--;\n\t\t\tyi++;\n\t\t}\n\t\ta1 = Exp(yf * Log(x));\n\t}\n\n\t// ans *= x^yi\n\t// by multiplying in successive squarings\n\t// of x according to bits of yi.\n\t// accumulate powers of two into exp.\n\tx1, xe := Frexp(x);\n\tfor i := int64(yi); i != 0; i >>= 1 {\n\t\tif i&1 == 1 {\n\t\t\ta1 *= x1;\n\t\t\tae += xe;\n\t\t}\n\t\tx1 *= x1;\n\t\txe <<= 1;\n\t\tif x1 < .5 {\n\t\t\tx1 += x1;\n\t\t\txe--;\n\t\t}\n\t}\n\n\t// ans = a1*2^ae\n\t// if flip { ans = 1 / ans }\n\t// but in the opposite order\n\tif flip {\n\t\ta1 = 1 / a1;\n\t\tae = -ae;\n\t}\n\treturn Ldexp(a1, ae);\n}", "func pow(x, n int8) int8 {\n\tif n == 0 {\n\t\treturn 1\n\t} else {\n\t\treturn x * pow(x, n-1)\n\t}\n}", "func pow(a, b int) int {\n\tp := 1\n\tfor b > 0 {\n\t\tif b&1 != 0 {\n\t\t\tp *= a\n\t\t}\n\t\tb >>= 1\n\t\ta *= a\n\t}\n\treturn p\n}", "func Pow(x, y int) int {\n\tif y == 0 {\n\t\treturn 1\n\t}\n\n\tresult := x\n\tfor n := 1; n < y; n++ {\n\t\tresult = result * x\n\t}\n\treturn result\n}", "func Pow(arg, arg2 float64) float64 {\n\treturn math.Pow(arg, arg2)\n}", "func power_of_two(n int) uint64 {\n return uint64(math.Pow(2.0, float64(n)))\n}", "func Pow(a, b int) int {\n\treturn neogointernal.Opcode2(\"POW\", a, b).(int)\n}", "func pow(a, exp int) int {\n\tp := 1\n\tfor exp > 0 {\n\t\tif exp&1 != 0 {\n\t\t\tp *= a\n\t\t}\n\t\texp >>= 1\n\t\ta *= a\n\t}\n\treturn p\n}", "func TestMyPow(t *testing.T) {\n\tcases := []struct{\n\t\tx\t\tfloat64\n\t\tn\t\tint\n\t\twant\tfloat64\n\t}{\n\t\t{\t2.0,\n\t\t\t10,\n\t\t\t1024.0,\n\t\t},\n\t\t{\t2.1,\n\t\t\t3,\n\t\t\t9.26100,\n\t\t},\n\t\t{\t2.0,\n\t\t\t-2,\n\t\t\t0.25000,\n\t\t},\n\t}\n\tfor k, v := range cases {\n\t\tt.Run(fmt.Sprint(\"test\", k+1), func(t *testing.T){\n\t\t\tgot := myPow(v.x, v.n)\n\t\t\tif got != v.want {\n\t\t\t\tt.Errorf(\"got %v want %v\", got, v.want)\n\t\t\t}\n\t\t})\n\t}\n}", "func (*Math) Pow(x float64, y float64) float64 {\n\treturn math.Pow(x, y)\n}", "func pow(x, n int) int {\n\tif n == 0 {\n\t\treturn 1\n\t}\n\thalf := pow(x, n/2)\n\tres := half * half % bigNum\n\tif n%2 == 1 {\n\t\tres = res * x % bigNum\n\t}\n\treturn res\n}", "func floorPow2(v int) int {}", "func pow(n, i int) (res int) {\n\tres = 1\n\tfor i > 0 {\n\t\tif i&1 == 1 {\n\t\t\tres *= n\n\t\t}\n\t\ti >>= 1\n\t\tn *= n\n\t}\n\treturn res\n}", "func FastPow(base, pow int) int {\n\tif pow < 0 {\n\t\treturn 0\n\t}\n\tres := 1\n\tfor pow > 0 {\n\t\tif pow%2 == 1 {\n\t\t\tres *= base\n\t\t}\n\t\tbase *= base\n\t\tpow >>= 1\n\t}\n\treturn res\n}", "func (x f26dot6) mul(y f26dot6) f26dot6 {\n\treturn f26dot6(int64(x) * int64(y) >> 6)\n}", "func (cal *Calculate) pow(value float64) (result float64) {\n\tif len(cal.Arg) == 2 {\n\t\treturn math.Pow(cal.Arg[0], cal.Arg[1])\n\t} else if len(cal.Arg) == 1 {\n\t\treturn math.Pow(value, cal.Arg[0])\n\t}\n\n\tlog.Fatalln(\"Please check the data format of the calculation unit\")\n\treturn\n}", "func ModPow(x, y, m *big.Int) *big.Int {\n\tif y.Sign() == -1 {\n\t\tt := new(big.Int).ModInverse(x, m)\n\t\treturn t.Exp(t, new(big.Int).Neg(y), m)\n\t}\n\treturn new(big.Int).Exp(x, y, m)\n}", "func FastFloatPow(base float64, pow int) float64 {\n\tif pow < 0 {\n\t\treturn 1 / FastFloatPow(base, -pow)\n\t}\n\tres := 1.0\n\tfor pow > 0 {\n\t\tif pow%2 == 1 {\n\t\t\tres *= base\n\t\t}\n\t\tbase *= base\n\t\tpow >>= 1\n\t}\n\treturn res\n}", "func bigPow(a, b int64) *big.Int {\n\tr := big.NewInt(a)\n\treturn r.Exp(r, big.NewInt(b), nil)\n}", "func mul(x byte, y byte) byte {\n\tif x == 0 || y == 0 {\n\t\treturn 0\n\t}\n\treturn expOp[logOp[x]+logOp[y]]\n}", "func newPowGen(e float64) func() float64 {\n\tvar i float64\n\treturn func() (r float64) {\n\t\tr = math.Pow(i, e)\n\t\ti++\n\t\treturn\n\t}\n}", "func Pow2(x uint32) uint32 {\n\tx--\n\tx |= x >> 1\n\tx |= x >> 2\n\tx |= x >> 4\n\tx |= x >> 8\n\tx |= x >> 16\n\treturn x + 1\n}", "func Pow(a, b int) int {\n\tp := 1\n\tfor b > 0 {\n\t\tif b&1 != 0 {\n\t\t\tp *= a\n\t\t}\n\t\tb >>= 1\n\t\ta *= a\n\t}\n\treturn p\n}", "func Pow(a, b int) int {\n\tp := 1\n\tfor b > 0 {\n\t\tif b&1 != 0 {\n\t\t\tp *= a\n\t\t}\n\t\tb >>= 1\n\t\ta *= a\n\t}\n\treturn p\n}", "func Pow(a, b int) int {\n\tp := 1\n\tfor b > 0 {\n\t\tif b&1 != 0 {\n\t\t\tp *= a\n\t\t}\n\t\tb >>= 1\n\t\ta *= a\n\t}\n\treturn p\n}", "func FastModPow(base, pow, mod int) int {\n\tif pow < 0 {\n\t\treturn 0\n\t}\n\tres := 1\n\tfor pow > 0 {\n\t\tif pow%2 == 1 {\n\t\t\tres *= base\n\t\t\tres %= mod\n\t\t}\n\t\tbase *= base\n\t\tbase %= mod\n\t\tpow >>= 1\n\t}\n\treturn res\n}", "func IsPow2(x uint32) bool { return (x & (x - 1)) == 0 }", "func Pow(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Pow\",\n\t\tInput: []tf.Input{\n\t\t\tx, y,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func Pow(a *big.Float, e uint) *big.Float {\n\te = uint(e)\n\tresult := ZeroBigFloat().Copy(a)\n\tfor i := uint(0); i < e-1; i++ {\n\t\tresult = Mul(result, a)\n\t}\n\treturn result\n}", "func BinPow(base int, deg int, rem int) int {\n\tvar res = 1\n\tfor deg > 0 {\n\t\tif (deg & 1) > 0 {\n\t\t\tres = int(int64(res) * int64(base) % int64(rem))\n\t\t}\n\t\tbase = int((int64(base) * int64(base)) % int64(rem))\n\t\tdeg >>= 1\n\t}\n\treturn res\n}", "func Pow64(x int64, y int) int64 {\n\tif y == 0 {\n\t\treturn 1\n\t}\n\n\tresult := x\n\tfor n := 1; n < y; n++ {\n\t\tresult = result * x\n\t}\n\treturn result\n}", "func twoToPow(i int) int {\n\treturn int(1 << uint(i))\n}", "func ModPow(base, n, mod int) int {\n\tans := 1\n\tfor ; n > 0; n >>= 1 {\n\t\tif n&1 == 1 {\n\t\t\tans = ModMul(ans, base, mod)\n\t\t}\n\t\tbase = ModMul(base, base, mod)\n\t}\n\treturn ans\n}", "func hash_func(x, y, n HashValue) (HashValue) {\n return (x*1640531513 ^ y*2654435789) % n\n}", "func (c Currency) Pow(f float64) Currency {\n\treturn c.Setf(math.Pow(c.Getf(), f))\n}", "func Pow(z, x, y *inf.Dec, s inf.Scale) (*inf.Dec, error) {\n\ts = s + 2\n\tif z == nil {\n\t\tz = new(inf.Dec)\n\t\tz.SetUnscaled(1).SetScale(0)\n\t}\n\n\t// Check if y is of type int.\n\ttmp := new(inf.Dec).Abs(y)\n\tisInt := tmp.Cmp(new(inf.Dec).Round(tmp, 0, inf.RoundDown)) == 0\n\n\txs := x.Sign()\n\tif xs == 0 {\n\t\tswitch y.Sign() {\n\t\tcase 0:\n\t\t\treturn z.SetUnscaled(1).SetScale(0), nil\n\t\tcase 1:\n\t\t\treturn z.SetUnscaled(0).SetScale(0), nil\n\t\tdefault: // -1\n\t\t\t// undefined for y < 0\n\t\t\treturn nil, errPowZeroNegative\n\t\t}\n\t}\n\n\tneg := xs < 0\n\n\tif !isInt && neg {\n\t\treturn nil, errPowNegNonInteger\n\t}\n\n\t// Exponent Precision Explanation (RaduBerinde):\n\t// Say we compute the Log with a scale of k. That means that the result we get is:\n\t// ln x +/- 10^-k.\n\t// This leads to an error of y * 10^-k in the exponent, which leads to a\n\t// multiplicative error of e^(y*10^-k) in the result.\n\t// For small values of u, e^u can be approximated by 1 + u, so for large k\n\t// that error is around 1 + y*10^-k. So the additive error will be x^y * y * 10^-k,\n\t// and we want this to be less than 10^-s. This approximately means that k has to be\n\t// s + the number of digits before the decimal point in x^y. Which roughly is\n\t//\n\t// s + <the number of digits before decimal point in x> * y.\n\t//\n\t// exponent precision = s + <the number of digits before decimal point in x> * y.\n\tnumDigits := float64(x.UnscaledBig().BitLen()) / digitsToBitsRatio\n\tnumDigits -= float64(x.Scale())\n\n\t// Round up y which should provide us with a threshold in calculating the new scale.\n\tyu := float64(new(inf.Dec).Round(y, 0, inf.RoundUp).UnscaledBig().Int64())\n\n\t// exponent precision = s + <the number of digits before decimal point in x> * y\n\tes := s + inf.Scale(numDigits*yu)\n\tif es < 0 || es > maxPrecision {\n\t\treturn nil, errArgumentTooLarge\n\t}\n\n\ttmp = new(inf.Dec).Abs(x)\n\t_, err := Log(tmp, tmp, es)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ttmp.Mul(tmp, y)\n\tExp(tmp, tmp, es)\n\n\tif neg && y.Round(y, 0, inf.RoundDown).UnscaledBig().Bit(0) == 1 {\n\t\ttmp.Neg(tmp)\n\t}\n\n\t// Round to the desired scale.\n\treturn z.Round(tmp, s-2, inf.RoundHalfUp), nil\n}", "func pow(a, b int) int {\n\tswitch {\n\tcase b < 0:\n\t\tpanic(\"We're just handling positive exponents here\")\n\tcase b == 0:\n\t\treturn 1\n\tcase b == 1:\n\t\treturn a\n\tcase b%2 == 0:\n\t\treturn pow(a*a, b/2)\n\tdefault:\n\t\treturn a * pow(a*a, (b-1)/2)\n\t}\n}", "func main() {\n fmt.Printf( \"%f\\n\", Mypow(3, 2, 10) )\n fmt.Println( Add(3, -1) )\n}", "func powerf3(x float64, n int) float64 {\n\tans := 1.0\n\n\tfor n != 0 {\n\t\t\tans *= x\n\t\t\tn--\n\t}\n\treturn ans\n}", "func Pow6(in *big.Float) *big.Float {\n\treturn Pow(in, 6)\n}", "func Pow8(in *big.Float) *big.Float {\n\treturn Pow(in, 8)\n}", "func gfMultiply(a, b gfElement) gfElement {\n\tif a == gfZero || b == gfZero {\n\t\treturn gfZero\n\t}\n\n\treturn gfExpTable[(gfLogTable[a]+gfLogTable[b])%255]\n}", "func (x Int26_6) mul(y Int26_6) Int26_6 {\n\tconst M, N = 26, 6\n\tlo, hi := muli32(int32(x), int32(y))\n\tret := Int26_6(hi<<M | lo>>N)\n\tret += Int26_6((lo >> (N - 1)) & 1) // Round to nearest, instead of rounding down.\n\treturn ret\n}", "func TestPower(t *testing.T) {\n\t// base = 0, exp = n (>0)\n\ttest1 := pow(0, 23)\n\t// test1 should have output as 0 as 0^n = 0\n\t// if any other result if found then it has failed the test, we now throw an error\n\n\tif test1 != 0 {\n\t\tt.Errorf(\"pow(0, 23) = %f; expected: 0\", test1)\n\t}\n\n\t// base = 45, exp = 0 should return 1, as n^0 = 1\n\ttest2 := pow(45, 0)\n\n\tif test2 != 1 {\n\t\tt.Errorf(\"pow(45,0) = %f; expected: 1\", test2)\n\t}\n}", "func g(x float64) float64 {\n\treturn math.Pow(x, 2)\n}", "func Pow(a, b int64) *big.Int {\n\tjassert.Assert(!(a == 0 && b == 0), \"0 to the power of 0 is undefined\")\n\tjassert.Assert(a >= 0 && b >= 0, \"a and b cannot be negative\")\n\t//\n\tn := new(big.Int)\n\tn.Exp(big.NewInt(a), big.NewInt(b), nil)\n\treturn n\n}", "func powt(p int) int {\n\treturn int(math.Pow10(p))\n}", "func Pow(v Res, s anyvec.Numeric) Res {\n\tout := v.Output().Copy()\n\tanyvec.Pow(out, s)\n\treturn &powRes{\n\t\tIn: v,\n\t\tOutVec: out,\n\t\tPower: s,\n\t}\n}", "func Pow(i, j int) int {\n\tp := 1\n\tfor j > 0 {\n\t\tif j&1 != 0 {\n\t\t\tp *= i\n\t\t}\n\t\tj >>= 1\n\t\ti *= i\n\t}\n\n\treturn p\n}", "func pow(x, n, lim float64) float64 {\n if v := math.Pow(x, n); v < lim {\n return v\n }\n return lim\n}", "func Pow9(in *big.Float) *big.Float {\n\treturn Pow(in, 9)\n}", "func Pow(base []uint8, exp uint64) []uint8 {\n\tvar result []uint8 = base\n\n\tfor i := exp - 1; i != 0; i-- {\n\t\tresult = Product(result, base)\n\t}\n\treturn result\n}", "func PowInt(a, p int) int {\n\tswitch {\n\tcase a == 0:\n\t\tif p == 0 {\n\t\t\tpanic(\"indeterminant form\")\n\t\t}\n\t\treturn 0\n\tcase p < 0:\n\t\tpanic(\"p must be non-negative\")\n\t}\n\n\t// Yacca's method\n\ty := 1\n\tfor ; 0 < p; p >>= 1 {\n\t\tif p&1 == 1 {\n\t\t\ty *= a\n\t\t}\n\n\t\ta *= a\n\t}\n\n\treturn y\n}", "func polyMod(v []uint8) uint64 {\n\tvar c uint64 = 1\n\tfor _, d := range v {\n\t\tvar c0 uint64 = c >> 35\n\t\tc = ((c & 0x07ffffffff) << 5) ^ uint64(d)\n\n\t\tif c0&0x01 != 0 {\n\t\t\tc ^= 0x98f2bc8e61\n\t\t}\n\t\tif c0&0x02 != 0 {\n\t\t\tc ^= 0x79b76d99e2\n\t\t}\n\t\tif c0&0x04 != 0 {\n\t\t\tc ^= 0xf33e5fb3c4\n\t\t}\n\t\tif c0&0x08 != 0 {\n\t\t\tc ^= 0xae2eabe2a8\n\t\t}\n\t\tif c0&0x10 != 0 {\n\t\t\tc ^= 0x1e4f43e470\n\t\t}\n\t}\n\n\treturn c ^ 1\n}", "func xorshiftMult64(x uint64) uint64 {\n\tx ^= x >> 12 // a\n\tx ^= x << 25 // b\n\tx ^= x >> 27 // c\n\treturn x * 2685821657736338717\n}", "func PowOfInt(base, power uint) int {\n\tif base == 2 {\n\t\treturn 1 << power\n\t}\n\treturn int(math.RoundToEven(math.Pow(float64(base), float64(power))))\n}", "func Pow12(in *big.Float) *big.Float {\n\treturn Pow(in, 12)\n}", "func PowInts(x, n int) int {\n\tif n == 0 {\n\t\treturn 1\n\t}\n\n\tv := 1\n\tfor n != 0 {\n\t\tif n&1 == 1 {\n\t\t\tv *= x\n\t\t}\n\t\tx *= x\n\t\tn /= 2\n\t}\n\n\treturn v\n}", "func Pow4(in *big.Float) *big.Float {\n\treturn Pow(in, 4)\n}", "func PowerOf2(x, n, q, qInv uint64) (r uint64) {\n\tahi, alo := x>>(64-n), x<<n\n\tR := alo * qInv\n\tH, _ := bits.Mul64(R, q)\n\tr = ahi - H + q\n\tif r >= q {\n\t\tr -= q\n\t}\n\treturn\n}", "func pow13II(a int, b int) int {\n\tif b == 0 {\n\t\treturn 1\n\t}\n\n\tresult, remain := 1, b\n\tfor remain > 0 {\n\t\tpow, count := a, 1\n\t\tfor (count << 1) < remain {\n\t\t\tpow *= pow\n\t\t\tcount <<= 1\n\t\t}\n\t\tresult *= pow\n\t\tremain -= count\n\t}\n\treturn result\n}", "func ExpF(base, exponent *Int) *Int {\n\tz := &Int{1, 0, 0, 0}\n\t// b^0 == 1\n\tif exponent.IsZero() || base.IsOne() {\n\t\treturn z\n\t}\n\t// b^1 == b\n\tif exponent.IsOne() {\n\t\tz.Copy(base)\n\t\treturn z\n\t}\n\tvar (\n\t\tword uint64\n\t\tbits int\n\t)\n\texpBitlen := exponent.BitLen()\n\n\tword = exponent[0]\n\tbits = 0\n\tfor ; bits < expBitlen && bits < 64; bits++ {\n\t\tif word&1 == 1 {\n\t\t\tz.Mul(z, base)\n\t\t}\n\t\tbase.Squared()\n\t\tword >>= 1\n\t}\n\n\tword = exponent[1]\n\tfor ; bits < expBitlen && bits < 128; bits++ {\n\t\tif word&1 == 1 {\n\t\t\tz.Mul(z, base)\n\t\t}\n\t\tbase.Squared()\n\t\tword >>= 1\n\t}\n\n\tword = exponent[2]\n\tfor ; bits < expBitlen && bits < 192; bits++ {\n\t\tif word&1 == 1 {\n\t\t\tz.Mul(z, base)\n\t\t}\n\t\tbase.Squared()\n\t\tword >>= 1\n\t}\n\n\tword = exponent[3]\n\tfor ; bits < expBitlen && bits < 256; bits++ {\n\t\tif word&1 == 1 {\n\t\t\tz.Mul(z, base)\n\t\t}\n\t\tbase.Squared()\n\t\tword >>= 1\n\t}\n\treturn z\n}", "func fnv1(x uint32, list string) uint32 {\n\tfor _, b := range list {\n\t\tx = x*16777619 ^ uint32(b)\n\t}\n\treturn x\n}", "func pow13I(a int, b int) int {\n\tif b == 0 {\n\t\treturn 1\n\t}\n\n\ttmp := pow13I(a, b/2)\n\n\tif b%2 == 0 {\n\t\treturn tmp * tmp\n\t} else {\n\t\treturn tmp * tmp * b\n\t}\n}", "func JDK_java_lang_StrictMath_pow(base Double, exponent Double) Double {\n\treturn Double(math.Pow(float64(base), float64(exponent)))\n}", "func Power(n int, m int) int {\n\thelper := n\n\tif m == 0 {\n\t\tn = 1\n\t} else {\n\t\tfor i := 1; i < m; i++ {\n\t\t\tn *= helper\n\t\t}\n\t}\n\treturn n\n}", "func polymod(v []byte) uint64 {\n\tc := uint64(1)\n\tfor _, d := range v {\n\t\tc0 := byte(c >> 35)\n\t\tc = ((c & 0x07ffffffff) << 5) ^ uint64(d)\n\t\tif c0&0x01 != 0 {\n\t\t\tc ^= 0x98f2bc8e61\n\t\t}\n\t\tif c0&0x02 != 0 {\n\t\t\tc ^= 0x79b76d99e2\n\t\t}\n\t\tif c0&0x04 != 0 {\n\t\t\tc ^= 0xf33e5fb3c4\n\t\t}\n\t\tif c0&0x08 != 0 {\n\t\t\tc ^= 0xae2eabe2a8\n\t\t}\n\t\tif c0&0x10 != 0 {\n\t\t\tc ^= 0x1e4f43e470\n\t\t}\n\t}\n\treturn c ^ 1\n}", "func roundUpToNextPowerOfTwo(x uint64) uint64 {\n\tvar r uint64 = 1\n\tfor i := 0; i < 64; i++ {\n\t\tif x <= r {\n\t\t\treturn r\n\t\t}\n\t\tr = r << 1\n\t}\n\treturn 0 // won't fit in uint64 :-(\n}", "func Power(b, e int) int {\n\tif e == 0 {\n\t\treturn 1\n\t}\n\treturn b * Power(b, e-1)\n}", "func mul(x, y int) int {\n\treturn x * y\n}", "func opUI64Bitxor(prgrm *CXProgram) {\n\texpr := prgrm.GetExpr()\n\tfp := prgrm.GetFramePointer()\n\n\toutV0 := ReadUI64(fp, expr.Inputs[0]) ^ ReadUI64(fp, expr.Inputs[1])\n\tWriteUI64(GetFinalOffset(fp, expr.Outputs[0]), outV0)\n}", "func Ch(x uint32, y uint32, z uint32) uint32 {\n\treturn (x & y) ^ (^x & z)\n}", "func RoundUpPowerOfTwo(x int32) int32 {\n\tx--\n\tx |= (x >> 1)\n\tx |= (x >> 2)\n\tx |= (x >> 4)\n\tx |= (x >> 8)\n\tx |= (x >> 16)\n\treturn x + 1\n}", "func powmod(a, k int) int {\n\ta %= 1337\n\tresult := 1\n\tfor i := 0; i < k; i++ {\n\t\tresult = (result * a) % 1337\n\t}\n\treturn result\n}", "func pow(x, n, lim float64) float64 {\n\tif v := math.Pow(x, n); v < lim {\n\t\treturn v\n\t}\n\treturn lim\n}", "func pow(x, n, lim float64) float64 {\n\tif v := math.Pow(x, n); v < lim {\n\t\treturn v\n\t}\n\treturn lim\n}", "func pow(x, n, lim float64) float64 {\n\tif v := math.Pow(x, n); v < lim {\n\t\treturn v\n\t}\n\treturn lim\n}", "func UintBinomial(n, k uint64) uint64 {\n\tif k > n {\n\t\tchk.Panic(\"UintBinomial function requires that k <= n. Incorrect values: n=%v, k=%v\", n, k)\n\t}\n\tif k == 0 || k == n {\n\t\treturn 1\n\t}\n\tif k == 1 || k == n-1 {\n\t\treturn n\n\t}\n\tif k > n-k {\n\t\tk = n - k // take advantage of symmetry\n\t}\n\tvar c uint64 = 1\n\tvar i uint64\n\tfor i = 1; i <= k; i, n = i+1, n-1 {\n\t\tif c/i > math.MaxUint64/n {\n\t\t\tchk.Panic(\"Overflow in UintBinomial: %v > %v\", c/i, math.MaxUint64/n)\n\t\t}\n\t\tc = c/i*n + c%i*n/i // split c*n/i into (c/i*i + c%i)*n/i\n\t}\n\treturn c\n}", "func calcPow(rOpd, lOpd formulaArg, opdStack *Stack) error {\n\tlOpdVal := lOpd.ToNumber()\n\tif lOpdVal.Type != ArgNumber {\n\t\treturn errors.New(lOpdVal.Value())\n\t}\n\trOpdVal := rOpd.ToNumber()\n\tif rOpdVal.Type != ArgNumber {\n\t\treturn errors.New(rOpdVal.Value())\n\t}\n\topdStack.Push(newNumberFormulaArg(math.Pow(lOpdVal.Number, rOpdVal.Number)))\n\treturn nil\n}", "func nextPowerOf2(n uint) uint {\n\tif n > 0 && (n&(n-1)) == 0 {\n\t\treturn n\n\t}\n\n\tvar count uint\n\tfor k := n; k != 0; k >>= 1 {\n\t\tlogrus.WithFields(logrus.Fields{\"k\": k, \"count\": count}).Debug(\"iterating to next power of 2\")\n\t\tcount += 1\n\t}\n\tlogrus.WithField(\"nextPower2\", 1<<count).Debug(\"next power number calculated\")\n\treturn 1 << count\n}", "func (x *Int) Uint64() uint64 {}", "func eval(p []byte, x byte) (result byte) {\n\t// Horner's scheme\n\tfor i := 1; i <= len(p); i++ {\n\t\tresult = mul(result, x) ^ p[len(p)-i]\n\t}\n\treturn\n}", "func fiat_25519_carry_mul(out1 *[10]uint32, arg1 *[10]uint32, arg2 *[10]uint32) {\n var x1 uint64 = (uint64((arg1[9])) * uint64(((arg2[9]) * 0x26)))\n var x2 uint64 = (uint64((arg1[9])) * uint64(((arg2[8]) * 0x13)))\n var x3 uint64 = (uint64((arg1[9])) * uint64(((arg2[7]) * 0x26)))\n var x4 uint64 = (uint64((arg1[9])) * uint64(((arg2[6]) * 0x13)))\n var x5 uint64 = (uint64((arg1[9])) * uint64(((arg2[5]) * 0x26)))\n var x6 uint64 = (uint64((arg1[9])) * uint64(((arg2[4]) * 0x13)))\n var x7 uint64 = (uint64((arg1[9])) * uint64(((arg2[3]) * 0x26)))\n var x8 uint64 = (uint64((arg1[9])) * uint64(((arg2[2]) * 0x13)))\n var x9 uint64 = (uint64((arg1[9])) * uint64(((arg2[1]) * 0x26)))\n var x10 uint64 = (uint64((arg1[8])) * uint64(((arg2[9]) * 0x13)))\n var x11 uint64 = (uint64((arg1[8])) * uint64(((arg2[8]) * 0x13)))\n var x12 uint64 = (uint64((arg1[8])) * uint64(((arg2[7]) * 0x13)))\n var x13 uint64 = (uint64((arg1[8])) * uint64(((arg2[6]) * 0x13)))\n var x14 uint64 = (uint64((arg1[8])) * uint64(((arg2[5]) * 0x13)))\n var x15 uint64 = (uint64((arg1[8])) * uint64(((arg2[4]) * 0x13)))\n var x16 uint64 = (uint64((arg1[8])) * uint64(((arg2[3]) * 0x13)))\n var x17 uint64 = (uint64((arg1[8])) * uint64(((arg2[2]) * 0x13)))\n var x18 uint64 = (uint64((arg1[7])) * uint64(((arg2[9]) * 0x26)))\n var x19 uint64 = (uint64((arg1[7])) * uint64(((arg2[8]) * 0x13)))\n var x20 uint64 = (uint64((arg1[7])) * uint64(((arg2[7]) * 0x26)))\n var x21 uint64 = (uint64((arg1[7])) * uint64(((arg2[6]) * 0x13)))\n var x22 uint64 = (uint64((arg1[7])) * uint64(((arg2[5]) * 0x26)))\n var x23 uint64 = (uint64((arg1[7])) * uint64(((arg2[4]) * 0x13)))\n var x24 uint64 = (uint64((arg1[7])) * uint64(((arg2[3]) * 0x26)))\n var x25 uint64 = (uint64((arg1[6])) * uint64(((arg2[9]) * 0x13)))\n var x26 uint64 = (uint64((arg1[6])) * uint64(((arg2[8]) * 0x13)))\n var x27 uint64 = (uint64((arg1[6])) * uint64(((arg2[7]) * 0x13)))\n var x28 uint64 = (uint64((arg1[6])) * uint64(((arg2[6]) * 0x13)))\n var x29 uint64 = (uint64((arg1[6])) * uint64(((arg2[5]) * 0x13)))\n var x30 uint64 = (uint64((arg1[6])) * uint64(((arg2[4]) * 0x13)))\n var x31 uint64 = (uint64((arg1[5])) * uint64(((arg2[9]) * 0x26)))\n var x32 uint64 = (uint64((arg1[5])) * uint64(((arg2[8]) * 0x13)))\n var x33 uint64 = (uint64((arg1[5])) * uint64(((arg2[7]) * 0x26)))\n var x34 uint64 = (uint64((arg1[5])) * uint64(((arg2[6]) * 0x13)))\n var x35 uint64 = (uint64((arg1[5])) * uint64(((arg2[5]) * 0x26)))\n var x36 uint64 = (uint64((arg1[4])) * uint64(((arg2[9]) * 0x13)))\n var x37 uint64 = (uint64((arg1[4])) * uint64(((arg2[8]) * 0x13)))\n var x38 uint64 = (uint64((arg1[4])) * uint64(((arg2[7]) * 0x13)))\n var x39 uint64 = (uint64((arg1[4])) * uint64(((arg2[6]) * 0x13)))\n var x40 uint64 = (uint64((arg1[3])) * uint64(((arg2[9]) * 0x26)))\n var x41 uint64 = (uint64((arg1[3])) * uint64(((arg2[8]) * 0x13)))\n var x42 uint64 = (uint64((arg1[3])) * uint64(((arg2[7]) * 0x26)))\n var x43 uint64 = (uint64((arg1[2])) * uint64(((arg2[9]) * 0x13)))\n var x44 uint64 = (uint64((arg1[2])) * uint64(((arg2[8]) * 0x13)))\n var x45 uint64 = (uint64((arg1[1])) * uint64(((arg2[9]) * 0x26)))\n var x46 uint64 = (uint64((arg1[9])) * uint64((arg2[0])))\n var x47 uint64 = (uint64((arg1[8])) * uint64((arg2[1])))\n var x48 uint64 = (uint64((arg1[8])) * uint64((arg2[0])))\n var x49 uint64 = (uint64((arg1[7])) * uint64((arg2[2])))\n var x50 uint64 = (uint64((arg1[7])) * uint64(((arg2[1]) * 0x2)))\n var x51 uint64 = (uint64((arg1[7])) * uint64((arg2[0])))\n var x52 uint64 = (uint64((arg1[6])) * uint64((arg2[3])))\n var x53 uint64 = (uint64((arg1[6])) * uint64((arg2[2])))\n var x54 uint64 = (uint64((arg1[6])) * uint64((arg2[1])))\n var x55 uint64 = (uint64((arg1[6])) * uint64((arg2[0])))\n var x56 uint64 = (uint64((arg1[5])) * uint64((arg2[4])))\n var x57 uint64 = (uint64((arg1[5])) * uint64(((arg2[3]) * 0x2)))\n var x58 uint64 = (uint64((arg1[5])) * uint64((arg2[2])))\n var x59 uint64 = (uint64((arg1[5])) * uint64(((arg2[1]) * 0x2)))\n var x60 uint64 = (uint64((arg1[5])) * uint64((arg2[0])))\n var x61 uint64 = (uint64((arg1[4])) * uint64((arg2[5])))\n var x62 uint64 = (uint64((arg1[4])) * uint64((arg2[4])))\n var x63 uint64 = (uint64((arg1[4])) * uint64((arg2[3])))\n var x64 uint64 = (uint64((arg1[4])) * uint64((arg2[2])))\n var x65 uint64 = (uint64((arg1[4])) * uint64((arg2[1])))\n var x66 uint64 = (uint64((arg1[4])) * uint64((arg2[0])))\n var x67 uint64 = (uint64((arg1[3])) * uint64((arg2[6])))\n var x68 uint64 = (uint64((arg1[3])) * uint64(((arg2[5]) * 0x2)))\n var x69 uint64 = (uint64((arg1[3])) * uint64((arg2[4])))\n var x70 uint64 = (uint64((arg1[3])) * uint64(((arg2[3]) * 0x2)))\n var x71 uint64 = (uint64((arg1[3])) * uint64((arg2[2])))\n var x72 uint64 = (uint64((arg1[3])) * uint64(((arg2[1]) * 0x2)))\n var x73 uint64 = (uint64((arg1[3])) * uint64((arg2[0])))\n var x74 uint64 = (uint64((arg1[2])) * uint64((arg2[7])))\n var x75 uint64 = (uint64((arg1[2])) * uint64((arg2[6])))\n var x76 uint64 = (uint64((arg1[2])) * uint64((arg2[5])))\n var x77 uint64 = (uint64((arg1[2])) * uint64((arg2[4])))\n var x78 uint64 = (uint64((arg1[2])) * uint64((arg2[3])))\n var x79 uint64 = (uint64((arg1[2])) * uint64((arg2[2])))\n var x80 uint64 = (uint64((arg1[2])) * uint64((arg2[1])))\n var x81 uint64 = (uint64((arg1[2])) * uint64((arg2[0])))\n var x82 uint64 = (uint64((arg1[1])) * uint64((arg2[8])))\n var x83 uint64 = (uint64((arg1[1])) * uint64(((arg2[7]) * 0x2)))\n var x84 uint64 = (uint64((arg1[1])) * uint64((arg2[6])))\n var x85 uint64 = (uint64((arg1[1])) * uint64(((arg2[5]) * 0x2)))\n var x86 uint64 = (uint64((arg1[1])) * uint64((arg2[4])))\n var x87 uint64 = (uint64((arg1[1])) * uint64(((arg2[3]) * 0x2)))\n var x88 uint64 = (uint64((arg1[1])) * uint64((arg2[2])))\n var x89 uint64 = (uint64((arg1[1])) * uint64(((arg2[1]) * 0x2)))\n var x90 uint64 = (uint64((arg1[1])) * uint64((arg2[0])))\n var x91 uint64 = (uint64((arg1[0])) * uint64((arg2[9])))\n var x92 uint64 = (uint64((arg1[0])) * uint64((arg2[8])))\n var x93 uint64 = (uint64((arg1[0])) * uint64((arg2[7])))\n var x94 uint64 = (uint64((arg1[0])) * uint64((arg2[6])))\n var x95 uint64 = (uint64((arg1[0])) * uint64((arg2[5])))\n var x96 uint64 = (uint64((arg1[0])) * uint64((arg2[4])))\n var x97 uint64 = (uint64((arg1[0])) * uint64((arg2[3])))\n var x98 uint64 = (uint64((arg1[0])) * uint64((arg2[2])))\n var x99 uint64 = (uint64((arg1[0])) * uint64((arg2[1])))\n var x100 uint64 = (uint64((arg1[0])) * uint64((arg2[0])))\n var x101 uint64 = (x100 + (x45 + (x44 + (x42 + (x39 + (x35 + (x30 + (x24 + (x17 + x9)))))))))\n var x102 uint64 = (x101 >> 26)\n var x103 uint32 = (uint32(x101) & 0x3ffffff)\n var x104 uint64 = (x91 + (x82 + (x74 + (x67 + (x61 + (x56 + (x52 + (x49 + (x47 + x46)))))))))\n var x105 uint64 = (x92 + (x83 + (x75 + (x68 + (x62 + (x57 + (x53 + (x50 + (x48 + x1)))))))))\n var x106 uint64 = (x93 + (x84 + (x76 + (x69 + (x63 + (x58 + (x54 + (x51 + (x10 + x2)))))))))\n var x107 uint64 = (x94 + (x85 + (x77 + (x70 + (x64 + (x59 + (x55 + (x18 + (x11 + x3)))))))))\n var x108 uint64 = (x95 + (x86 + (x78 + (x71 + (x65 + (x60 + (x25 + (x19 + (x12 + x4)))))))))\n var x109 uint64 = (x96 + (x87 + (x79 + (x72 + (x66 + (x31 + (x26 + (x20 + (x13 + x5)))))))))\n var x110 uint64 = (x97 + (x88 + (x80 + (x73 + (x36 + (x32 + (x27 + (x21 + (x14 + x6)))))))))\n var x111 uint64 = (x98 + (x89 + (x81 + (x40 + (x37 + (x33 + (x28 + (x22 + (x15 + x7)))))))))\n var x112 uint64 = (x99 + (x90 + (x43 + (x41 + (x38 + (x34 + (x29 + (x23 + (x16 + x8)))))))))\n var x113 uint64 = (x102 + x112)\n var x114 uint64 = (x113 >> 25)\n var x115 uint32 = (uint32(x113) & 0x1ffffff)\n var x116 uint64 = (x114 + x111)\n var x117 uint64 = (x116 >> 26)\n var x118 uint32 = (uint32(x116) & 0x3ffffff)\n var x119 uint64 = (x117 + x110)\n var x120 uint64 = (x119 >> 25)\n var x121 uint32 = (uint32(x119) & 0x1ffffff)\n var x122 uint64 = (x120 + x109)\n var x123 uint64 = (x122 >> 26)\n var x124 uint32 = (uint32(x122) & 0x3ffffff)\n var x125 uint64 = (x123 + x108)\n var x126 uint64 = (x125 >> 25)\n var x127 uint32 = (uint32(x125) & 0x1ffffff)\n var x128 uint64 = (x126 + x107)\n var x129 uint64 = (x128 >> 26)\n var x130 uint32 = (uint32(x128) & 0x3ffffff)\n var x131 uint64 = (x129 + x106)\n var x132 uint64 = (x131 >> 25)\n var x133 uint32 = (uint32(x131) & 0x1ffffff)\n var x134 uint64 = (x132 + x105)\n var x135 uint64 = (x134 >> 26)\n var x136 uint32 = (uint32(x134) & 0x3ffffff)\n var x137 uint64 = (x135 + x104)\n var x138 uint64 = (x137 >> 25)\n var x139 uint32 = (uint32(x137) & 0x1ffffff)\n var x140 uint64 = (x138 * uint64(0x13))\n var x141 uint64 = (uint64(x103) + x140)\n var x142 uint32 = uint32((x141 >> 26))\n var x143 uint32 = (uint32(x141) & 0x3ffffff)\n var x144 uint32 = (x142 + x115)\n var x145 fiat_25519_uint1 = fiat_25519_uint1((x144 >> 25))\n var x146 uint32 = (x144 & 0x1ffffff)\n var x147 uint32 = (uint32(x145) + x118)\n out1[0] = x143\n out1[1] = x146\n out1[2] = x147\n out1[3] = x121\n out1[4] = x124\n out1[5] = x127\n out1[6] = x130\n out1[7] = x133\n out1[8] = x136\n out1[9] = x139\n}", "func Pow7(in *big.Float) *big.Float {\n\treturn Pow(in, 7)\n}", "func Pow(valueA gcv.Value, valueB gcv.Value) gcv.Value {\n\tif valueA.Type() == gcv.Complex || valueB.Type() == gcv.Complex {\n\t\treturn gcv.MakeValue(cmplx.Pow(valueA.Complex(), valueB.Complex()))\n\t}\n\treturn gcv.MakeValue(math.Pow(valueA.Real(), valueB.Real()))\n}", "func (e *Engine) exp(c, a *fe12) {\n\tc.set(a)\n\te.fp12.cyclotomicSquare(c) // (a ^ 2)\n\n\t// (a ^ (2 + 1)) ^ (2 ^ 2) = a ^ 12\n\te.fp12.mulAssign(c, a)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\n\t// (a ^ (12 + 1)) ^ (2 ^ 3) = a ^ 104\n\te.fp12.mulAssign(c, a)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\n\t// (a ^ (104 + 1)) ^ (2 ^ 9) = a ^ 53760\n\te.fp12.mulAssign(c, a)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\t// (a ^ (53760 + 1)) ^ (2 ^ 32) = a ^ 230901736800256\n\te.fp12.mulAssign(c, a)\n\tfor i := 0; i < 32; i++ {\n\t\te.fp12.cyclotomicSquare(c)\n\t}\n\n\t// (a ^ (230901736800256 + 1)) ^ (2 ^ 16) = a ^ 15132376222941642752\n\te.fp12.mulAssign(c, a)\n\tfor i := 0; i < 16; i++ {\n\t\te.fp12.cyclotomicSquare(c)\n\t}\n\t// invert chain result since x is negative\n\tfp12Conjugate(c, c)\n}", "func PSHUFD(i, mx, x operand.Op) { ctx.PSHUFD(i, mx, x) }", "func nextPowerOfTwo(n int) int {\n\tif n&(n-1) == 0 {\n\t\treturn n\n\t}\n\n\texponent := uint(math.Log2(float64(n))) + 1\n\treturn 1 << exponent // 2^exponent\n}", "func NextPowOfTwo(n int) int {\n\tswitch {\n\tcase n < 0:\n\t\treturn -NextPowOfTwo(-n)\n\tcase n == 0:\n\t\treturn 1\n\tcase n&(n-1) == 0:\n\t\t// n = 2^k, for some k >= 0\n\t\treturn n\n\tdefault:\n\t\t// 2^k > n where k bits represent n in base 2 (disregarding the leading sign bit)\n\t\treturn 1 << bits.Len(uint(n))\n\t}\n}", "func integerPower(z, x *inf.Dec, y int64, s inf.Scale) *inf.Dec {\n\tif z == nil {\n\t\tz = new(inf.Dec)\n\t}\n\n\tneg := y < 0\n\tif neg {\n\t\ty = -y\n\t}\n\n\tz.Set(decimalOne)\n\tfor y > 0 {\n\t\tif y%2 == 1 {\n\t\t\tz = z.Mul(z, x)\n\t\t}\n\t\ty >>= 1\n\t\tx.Mul(x, x)\n\n\t\t// integerPower is only ever called with `e` (decimalE), which is a constant\n\t\t// with very high precision. When it is squared above, the number of digits\n\t\t// needed to express it goes up quickly. If we are a large power of a small\n\t\t// number (like 0.5 ^ 5000), this loop becomes very slow because of the very\n\t\t// high number of digits it must compute. To prevent that, round x.\n\t\tx.Round(x, s*2, inf.RoundHalfUp)\n\t}\n\n\tif neg {\n\t\tz = z.QuoRound(decimalOne, z, s+2, inf.RoundHalfUp)\n\t}\n\treturn z.Round(z, s, inf.RoundHalfUp)\n}", "func opUI64Mod(prgrm *CXProgram) {\n\texpr := prgrm.GetExpr()\n\tfp := prgrm.GetFramePointer()\n\n\toutV0 := ReadUI64(fp, expr.Inputs[0]) % ReadUI64(fp, expr.Inputs[1])\n\tWriteUI64(GetFinalOffset(fp, expr.Outputs[0]), outV0)\n}", "func opUI64Mul(prgrm *CXProgram) {\n\texpr := prgrm.GetExpr()\n\tfp := prgrm.GetFramePointer()\n\n\toutV0 := ReadUI64(fp, expr.Inputs[0]) * ReadUI64(fp, expr.Inputs[1])\n\tWriteUI64(GetFinalOffset(fp, expr.Outputs[0]), outV0)\n}", "func NewPow(x Operand, power float64) *Pow {\n\treturn &Pow{x: x, power: power}\n}", "func IntXor(z *big.Int, x, y *big.Int,) *big.Int", "func (g *Graph) Pow(x Node, power float64) Node {\n\treturn g.NewOperator(fn.NewPow(x, power), x)\n}" ]
[ "0.6557375", "0.6482305", "0.63670856", "0.63278854", "0.6317327", "0.6217253", "0.62000436", "0.6197121", "0.61934346", "0.6190206", "0.6171746", "0.6134147", "0.60823005", "0.6079171", "0.607424", "0.6004703", "0.5967984", "0.59644586", "0.59597284", "0.5933642", "0.5871316", "0.58346915", "0.58131146", "0.5807569", "0.5793521", "0.5751053", "0.57202774", "0.5718856", "0.5718856", "0.5718856", "0.57027245", "0.569876", "0.56555", "0.5639252", "0.5631244", "0.5627343", "0.5624139", "0.55957514", "0.5592956", "0.5590583", "0.5575539", "0.5573745", "0.55679834", "0.5529336", "0.5505812", "0.5494671", "0.5488565", "0.54806215", "0.54351693", "0.54307175", "0.5422327", "0.5412965", "0.53725815", "0.5366418", "0.53495", "0.533931", "0.53076917", "0.5302694", "0.5301025", "0.53008956", "0.52911747", "0.5283049", "0.5263707", "0.5263614", "0.5246529", "0.524518", "0.524389", "0.52349544", "0.5218748", "0.52186304", "0.5202446", "0.5196789", "0.5195147", "0.519502", "0.5189213", "0.5180864", "0.51733214", "0.5166772", "0.5154282", "0.5145258", "0.5145258", "0.5145258", "0.5143407", "0.51396465", "0.5138032", "0.513676", "0.51343286", "0.5124384", "0.5119681", "0.5109489", "0.51094407", "0.5108867", "0.5107273", "0.5105021", "0.5090506", "0.5086017", "0.5081392", "0.5072154", "0.50678205", "0.5066832" ]
0.77589846
0
Mul2Exp sets z = x 2^s and returns z.
Mul2Exp устанавливает z = x * 2^s и возвращает z.
func (f *Float) Mul2Exp(x *Float, s uint) *Float { x.doinit() f.doinit() C.mpf_mul_2exp(&f.i[0], &x.i[0], C.mp_bitcnt_t(s)) return f }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (z *Int) Exp(x, y, m *Int) *Int {}", "func mathExp(ctx phpv.Context, args []*phpv.ZVal) (*phpv.ZVal, error) {\n\tvar x phpv.ZFloat\n\t_, err := core.Expand(ctx, args, &x)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn phpv.ZFloat(math.Exp(float64(x))).ZVal(), nil\n}", "func Exp(z, n *inf.Dec, s inf.Scale) *inf.Dec {\n\ts += 2\n\tnn := new(inf.Dec).Set(n)\n\tif z == nil {\n\t\tz = new(inf.Dec)\n\t\tz.SetUnscaled(1).SetScale(0)\n\t} else {\n\t\tz.SetUnscaled(1).SetScale(0)\n\t}\n\n\t// We are computing (e^n) by splitting n into an integer and a float\n\t// (e.g 3.1 ==> x = 3, y = 0.1), this allows us to write\n\t// e^n = e^(x+y) = e^x * e^y\n\n\t// Split out x (integer(n))\n\tx := new(inf.Dec).Round(nn, 0, inf.RoundDown)\n\n\t// Split out y (n - x) which is < 1\n\ty := new(inf.Dec).Sub(nn, x)\n\n\t// convert x to integer\n\tinteger, ok := x.Unscaled()\n\tif !ok {\n\t\tpanic(\"integer out of range\")\n\t}\n\n\tex := integerPower(z, new(inf.Dec).Set(decimalE), integer, s+2)\n\treturn smallExp(ex, y, s-2)\n}", "func Pow(z, x, y *inf.Dec, s inf.Scale) (*inf.Dec, error) {\n\ts = s + 2\n\tif z == nil {\n\t\tz = new(inf.Dec)\n\t\tz.SetUnscaled(1).SetScale(0)\n\t}\n\n\t// Check if y is of type int.\n\ttmp := new(inf.Dec).Abs(y)\n\tisInt := tmp.Cmp(new(inf.Dec).Round(tmp, 0, inf.RoundDown)) == 0\n\n\txs := x.Sign()\n\tif xs == 0 {\n\t\tswitch y.Sign() {\n\t\tcase 0:\n\t\t\treturn z.SetUnscaled(1).SetScale(0), nil\n\t\tcase 1:\n\t\t\treturn z.SetUnscaled(0).SetScale(0), nil\n\t\tdefault: // -1\n\t\t\t// undefined for y < 0\n\t\t\treturn nil, errPowZeroNegative\n\t\t}\n\t}\n\n\tneg := xs < 0\n\n\tif !isInt && neg {\n\t\treturn nil, errPowNegNonInteger\n\t}\n\n\t// Exponent Precision Explanation (RaduBerinde):\n\t// Say we compute the Log with a scale of k. That means that the result we get is:\n\t// ln x +/- 10^-k.\n\t// This leads to an error of y * 10^-k in the exponent, which leads to a\n\t// multiplicative error of e^(y*10^-k) in the result.\n\t// For small values of u, e^u can be approximated by 1 + u, so for large k\n\t// that error is around 1 + y*10^-k. So the additive error will be x^y * y * 10^-k,\n\t// and we want this to be less than 10^-s. This approximately means that k has to be\n\t// s + the number of digits before the decimal point in x^y. Which roughly is\n\t//\n\t// s + <the number of digits before decimal point in x> * y.\n\t//\n\t// exponent precision = s + <the number of digits before decimal point in x> * y.\n\tnumDigits := float64(x.UnscaledBig().BitLen()) / digitsToBitsRatio\n\tnumDigits -= float64(x.Scale())\n\n\t// Round up y which should provide us with a threshold in calculating the new scale.\n\tyu := float64(new(inf.Dec).Round(y, 0, inf.RoundUp).UnscaledBig().Int64())\n\n\t// exponent precision = s + <the number of digits before decimal point in x> * y\n\tes := s + inf.Scale(numDigits*yu)\n\tif es < 0 || es > maxPrecision {\n\t\treturn nil, errArgumentTooLarge\n\t}\n\n\ttmp = new(inf.Dec).Abs(x)\n\t_, err := Log(tmp, tmp, es)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ttmp.Mul(tmp, y)\n\tExp(tmp, tmp, es)\n\n\tif neg && y.Round(y, 0, inf.RoundDown).UnscaledBig().Bit(0) == 1 {\n\t\ttmp.Neg(tmp)\n\t}\n\n\t// Round to the desired scale.\n\treturn z.Round(tmp, s-2, inf.RoundHalfUp), nil\n}", "func (self *State)Exp2(a any)any{\n self.IncOperations(self.coeff[\"exp2\"]+self.off[\"exp2\"])\n return wrap1(a,math.Exp2)\n}", "func (z *E2) Mul(x, y *E2) *E2 {\n\tmulGenericE2(z, x, y)\n\treturn z\n}", "func (f *Float) Div2Exp(x *Float, s uint) *Float {\n\tx.doinit()\n\tf.doinit()\n\tC.mpf_div_2exp(&f.i[0], &x.i[0], C.mp_bitcnt_t(s))\n\treturn f\n}", "func (z *Element22) Exp(x Element22, e uint64) *Element22 {\n\tif e == 0 {\n\t\treturn z.SetOne()\n\t}\n\n\tz.Set(&x)\n\n\tl := bits.Len64(e) - 2\n\tfor i := l; i >= 0; i-- {\n\t\tz.Square(z)\n\t\tif e&(1<<uint(i)) != 0 {\n\t\t\tz.MulAssign(&x)\n\t\t}\n\t}\n\treturn z\n}", "func Mul(z, x, y *Elt)", "func (z *Int) Exp(base, exponent *Int) *Int {\n\treturn z.Copy(ExpF(base, exponent))\n}", "func (z *E6) MulByE2(x *E6, y *E2) *E6 {\n\tvar yCopy E2\n\tyCopy.Set(y)\n\tz.B0.Mul(&x.B0, &yCopy)\n\tz.B1.Mul(&x.B1, &yCopy)\n\tz.B2.Mul(&x.B2, &yCopy)\n\treturn z\n}", "func (c *Clac) Pow2() error {\n\treturn c.applyFloat(1, func(vals []value.Value) (value.Value, error) {\n\t\treturn binary(value.Int(2), \"**\", vals[0])\n\t})\n}", "func IntExp(z *big.Int, x, y, m *big.Int,) *big.Int", "func (z *Int) Mul(x, y *Int) *Int {}", "func FloatSetMantExp(z *big.Float, mant *big.Float, exp int) *big.Float", "func (z *E12) Exp(x *E12, e big.Int) *E12 {\n\tvar res E12\n\tres.SetOne()\n\tb := e.Bytes()\n\tfor i := range b {\n\t\tw := b[i]\n\t\tmask := byte(0x80)\n\t\tfor j := 7; j >= 0; j-- {\n\t\t\tres.Square(&res)\n\t\t\tif (w&mask)>>j != 0 {\n\t\t\t\tres.Mul(&res, x)\n\t\t\t}\n\t\t\tmask = mask >> 1\n\t\t}\n\t}\n\tz.Set(&res)\n\treturn z\n}", "func Pow2(x uint32) uint32 {\n\tx--\n\tx |= x >> 1\n\tx |= x >> 2\n\tx |= x >> 4\n\tx |= x >> 8\n\tx |= x >> 16\n\treturn x + 1\n}", "func Exp(x, y, m *big.Int) *big.Int {\n\treturn new(big.Int).Exp(x, y, m)\n}", "func Exp(x float64) float64 {\n\n\treturn math.Exp(x)\n}", "func IntMul(z *big.Int, x, y *big.Int,) *big.Int", "func (f *Float) Float2Exp() (d float64, exp int) {\n\tvar exp_ C.long\n\td = float64(C.mpf_get_d_2exp(&exp_, &f.i[0]))\n\texp = int(exp_)\n\treturn\n}", "func FloatMul(z *big.Float, x, y *big.Float,) *big.Float", "func RatMul(z *big.Rat, x, y *big.Rat,) *big.Rat", "func Pow(arg, arg2 float64) float64 {\n\treturn math.Pow(arg, arg2)\n}", "func (z *E12) MulByV2W(x *E12, y *E2) *E12 {\n\n\tvar result E12\n\tvar yNR E2\n\n\tyNR.MulByNonResidue(y)\n\tresult.C0.B0.Mul(&x.C1.B0, &yNR)\n\tresult.C0.B1.Mul(&x.C1.B1, &yNR)\n\tresult.C0.B2.Mul(&x.C1.B2, &yNR)\n\tresult.C1.B0.Mul(&x.C0.B1, &yNR)\n\tresult.C1.B1.Mul(&x.C0.B2, &yNR)\n\tresult.C1.B2.Mul(&x.C0.B0, y)\n\tz.Set(&result)\n\treturn z\n}", "func Exp(x float64) float64 {\n\tx = 1.0 + x/1024\n\tx *= x\n\tx *= x\n\tx *= x\n\tx *= x\n\tx *= x\n\tx *= x\n\tx *= x\n\tx *= x\n\tx *= x\n\tx *= x\n\n\treturn x\n}", "func ModExp(x, y, N int64) int64 {\n\tif y == 0 {\n\t\treturn 1\n\t}\n\tz := ModExp(x, y/2, N)\n\tt := (z * z) % N\n\tif y%2 == 0 {\n\t\treturn t\n\t}\n\treturn (x * t) % N\n}", "func (e *Engine) exp(c, a *fe12) {\n\tc.set(a)\n\te.fp12.cyclotomicSquare(c) // (a ^ 2)\n\n\t// (a ^ (2 + 1)) ^ (2 ^ 2) = a ^ 12\n\te.fp12.mulAssign(c, a)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\n\t// (a ^ (12 + 1)) ^ (2 ^ 3) = a ^ 104\n\te.fp12.mulAssign(c, a)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\n\t// (a ^ (104 + 1)) ^ (2 ^ 9) = a ^ 53760\n\te.fp12.mulAssign(c, a)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\t// (a ^ (53760 + 1)) ^ (2 ^ 32) = a ^ 230901736800256\n\te.fp12.mulAssign(c, a)\n\tfor i := 0; i < 32; i++ {\n\t\te.fp12.cyclotomicSquare(c)\n\t}\n\n\t// (a ^ (230901736800256 + 1)) ^ (2 ^ 16) = a ^ 15132376222941642752\n\te.fp12.mulAssign(c, a)\n\tfor i := 0; i < 16; i++ {\n\t\te.fp12.cyclotomicSquare(c)\n\t}\n\t// invert chain result since x is negative\n\tfp12Conjugate(c, c)\n}", "func (z *Big) Mul(x, y *Big) *Big { return z.Context.Mul(z, x, y) }", "func Exp(arg float64) float64 {\n\treturn math.Exp(arg)\n}", "func Exp(scope *Scope, x tf.Output) (y tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Exp\",\n\t\tInput: []tf.Input{\n\t\t\tx,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func (*Math) Pow(x float64, y float64) float64 {\n\treturn math.Pow(x, y)\n}", "func Exp(o, z *big.Float) *big.Float {\n\tif o.Prec() == 0 {\n\t\to.SetPrec(z.Prec())\n\t}\n\tif z.Sign() == 0 {\n\t\treturn o.SetFloat64(1)\n\t}\n\tif z.IsInf() {\n\t\tif z.Sign() < 0 {\n\t\t\treturn o.Set(&gzero)\n\t\t}\n\t\treturn o.Set(z)\n\t}\n\n\tp := o\n\tif p == z {\n\t\t// We need z for Newton's algorithm, so ensure we don't overwrite it.\n\t\tp = new(big.Float).SetPrec(z.Prec())\n\t}\n\t// try to get initial estimate using IEEE-754 math\n\t// TODO: save work (and an import of math) by checking the exponent of z\n\tzf, _ := z.Float64()\n\tzf = math.Exp(zf)\n\tif math.IsInf(zf, 1) || zf == 0 {\n\t\t// too big or too small for IEEE-754 math,\n\t\t// perform argument reduction using\n\t\t// e^{2z} = (e^z)²\n\t\thalfZ := quicksh(new(big.Float), z, -1).SetPrec(p.Prec() + 64)\n\t\t// TODO: avoid recursion\n\t\thalfExp := Exp(halfZ, halfZ)\n\t\treturn p.Mul(halfExp, halfExp)\n\t}\n\t// we got a nice IEEE-754 estimate\n\tguess := big.NewFloat(zf)\n\n\t// f(t)/f'(t) = t*(log(t) - z)\n\tf := func(t *big.Float) *big.Float {\n\t\tp.Sub(Log(new(big.Float), t), z)\n\t\treturn p.Mul(p, t)\n\t}\n\n\tx := newton(f, guess, z.Prec()) // TODO: make newton operate in place\n\n\treturn o.Set(x)\n}", "func mul(x byte, y byte) byte {\n\tif x == 0 || y == 0 {\n\t\treturn 0\n\t}\n\treturn expOp[logOp[x]+logOp[y]]\n}", "func Exp(in Res) Res {\n\texpd := in.Output().Copy()\n\tanyvec.Exp(expd)\n\treturn &expRes{OutVec: expd, In: in}\n}", "func integerPower(z, x *inf.Dec, y int64, s inf.Scale) *inf.Dec {\n\tif z == nil {\n\t\tz = new(inf.Dec)\n\t}\n\n\tneg := y < 0\n\tif neg {\n\t\ty = -y\n\t}\n\n\tz.Set(decimalOne)\n\tfor y > 0 {\n\t\tif y%2 == 1 {\n\t\t\tz = z.Mul(z, x)\n\t\t}\n\t\ty >>= 1\n\t\tx.Mul(x, x)\n\n\t\t// integerPower is only ever called with `e` (decimalE), which is a constant\n\t\t// with very high precision. When it is squared above, the number of digits\n\t\t// needed to express it goes up quickly. If we are a large power of a small\n\t\t// number (like 0.5 ^ 5000), this loop becomes very slow because of the very\n\t\t// high number of digits it must compute. To prevent that, round x.\n\t\tx.Round(x, s*2, inf.RoundHalfUp)\n\t}\n\n\tif neg {\n\t\tz = z.QuoRound(decimalOne, z, s+2, inf.RoundHalfUp)\n\t}\n\treturn z.Round(z, s, inf.RoundHalfUp)\n}", "func Mul128(x, y uint64) (z1, z0 uint64) {\n\t// Split x and y into 2 halfwords each, multiply\n\t// the halfwords separately while avoiding overflow,\n\t// and return the product as 2 words.\n\n\tconst (\n\t\tW\t= uint(unsafe.Sizeof(x)) * 8;\n\t\tW2\t= W / 2;\n\t\tB2\t= 1 << W2;\n\t\tM2\t= B2 - 1;\n\t)\n\n\tif x < y {\n\t\tx, y = y, x\n\t}\n\n\tif x < B2 {\n\t\t// y < B2 because y <= x\n\t\t// sub-digits of x and y are (0, x) and (0, y)\n\t\t// z = z[0] = x*y\n\t\tz0 = x * y;\n\t\treturn;\n\t}\n\n\tif y < B2 {\n\t\t// sub-digits of x and y are (x1, x0) and (0, y)\n\t\t// x = (x1*B2 + x0)\n\t\t// y = (y1*B2 + y0)\n\t\tx1, x0 := x>>W2, x&M2;\n\n\t\t// x*y = t2*B2*B2 + t1*B2 + t0\n\t\tt0 := x0 * y;\n\t\tt1 := x1 * y;\n\n\t\t// compute result digits but avoid overflow\n\t\t// z = z[1]*B + z[0] = x*y\n\t\tz0 = t1<<W2 + t0;\n\t\tz1 = (t1 + t0>>W2) >> W2;\n\t\treturn;\n\t}\n\n\t// general case\n\t// sub-digits of x and y are (x1, x0) and (y1, y0)\n\t// x = (x1*B2 + x0)\n\t// y = (y1*B2 + y0)\n\tx1, x0 := x>>W2, x&M2;\n\ty1, y0 := y>>W2, y&M2;\n\n\t// x*y = t2*B2*B2 + t1*B2 + t0\n\tt0 := x0 * y0;\n\tt1 := x1*y0 + x0*y1;\n\tt2 := x1 * y1;\n\n\t// compute result digits but avoid overflow\n\t// z = z[1]*B + z[0] = x*y\n\tz0 = t1<<W2 + t0;\n\tz1 = t2 + (t1+t0>>W2)>>W2;\n\treturn;\n}", "func (e *E6) MulByFp2(cs *frontend.ConstraintSystem, e1 *E6, e2 *E2, ext Extension) *E6 {\n\tres := E6{}\n\n\tres.B0.Mul(cs, &e1.B0, e2, ext)\n\tres.B1.Mul(cs, &e1.B1, e2, ext)\n\tres.B2.Mul(cs, &e1.B2, e2, ext)\n\n\te.B0 = res.B0\n\te.B1 = res.B1\n\te.B2 = res.B2\n\n\treturn e\n}", "func SimpleMultiply(exp string) string {\n var index int = strings.Index(exp, \"*\")\n var arg1 string = exp[:index]\n var arg2 string = exp[index + 1:]\n val1 := NotateToDouble(arg1)\n val2 := NotateToDouble(arg2)\n return NegativeNotate(fmt.Sprintf(\"%f\", val1 * val2))\n}", "func Exp(base, exponent, modulus *big.Int) *big.Int {\n\treturn I().Exp(base, exponent, modulus)\n}", "func Pow(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Pow\",\n\t\tInput: []tf.Input{\n\t\t\tx, y,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func ExpF(base, exponent *Int) *Int {\n\tz := &Int{1, 0, 0, 0}\n\t// b^0 == 1\n\tif exponent.IsZero() || base.IsOne() {\n\t\treturn z\n\t}\n\t// b^1 == b\n\tif exponent.IsOne() {\n\t\tz.Copy(base)\n\t\treturn z\n\t}\n\tvar (\n\t\tword uint64\n\t\tbits int\n\t)\n\texpBitlen := exponent.BitLen()\n\n\tword = exponent[0]\n\tbits = 0\n\tfor ; bits < expBitlen && bits < 64; bits++ {\n\t\tif word&1 == 1 {\n\t\t\tz.Mul(z, base)\n\t\t}\n\t\tbase.Squared()\n\t\tword >>= 1\n\t}\n\n\tword = exponent[1]\n\tfor ; bits < expBitlen && bits < 128; bits++ {\n\t\tif word&1 == 1 {\n\t\t\tz.Mul(z, base)\n\t\t}\n\t\tbase.Squared()\n\t\tword >>= 1\n\t}\n\n\tword = exponent[2]\n\tfor ; bits < expBitlen && bits < 192; bits++ {\n\t\tif word&1 == 1 {\n\t\t\tz.Mul(z, base)\n\t\t}\n\t\tbase.Squared()\n\t\tword >>= 1\n\t}\n\n\tword = exponent[3]\n\tfor ; bits < expBitlen && bits < 256; bits++ {\n\t\tif word&1 == 1 {\n\t\t\tz.Mul(z, base)\n\t\t}\n\t\tbase.Squared()\n\t\tword >>= 1\n\t}\n\treturn z\n}", "func MULSS(mx, x operand.Op) { ctx.MULSS(mx, x) }", "func Command_Mul(script *rex.Script, params []*rex.Value) {\n\tif len(params) != 2 {\n\t\trex.ErrorParamCount(\"float:mul\", \"2\")\n\t}\n\n\tscript.RetVal = rex.NewValueFloat64(params[0].Float64() * params[1].Float64())\n\treturn\n}", "func CalculateExponentTerm(z complex128, power1, power2 int, scale complex128, ignoreComplexConjugate bool) complex128 {\n\tzRaisedToN := cmplx.Pow(z, complex(float64(power1), 0))\n\tif ignoreComplexConjugate {\n\t\treturn zRaisedToN * scale\n\t}\n\n\tcomplexConjugate := complex(real(z), -1*imag(z))\n\tcomplexConjugateRaisedToM := cmplx.Pow(complexConjugate, complex(float64(power2), 0))\n\treturn zRaisedToN * complexConjugateRaisedToM * scale\n}", "func (z *polyGF2) MulX(a *polyGF2, n int) *polyGF2 {\n\tif n < 0 {\n\t\tpanic(\"power must be >= 0\")\n\t}\n\tz.coeff.Lsh(&a.coeff, uint(n))\n\treturn z\n}", "func Pow(x, y float64) float64 {\n\t// TODO: x or y NaN, ±Inf, maybe ±0.\n\tswitch {\n\tcase y == 0:\n\t\treturn 1\n\tcase y == 1:\n\t\treturn x\n\tcase x == 0 && y > 0:\n\t\treturn 0\n\tcase x == 0 && y < 0:\n\t\treturn Inf(1)\n\tcase y == 0.5:\n\t\treturn Sqrt(x)\n\tcase y == -0.5:\n\t\treturn 1 / Sqrt(x)\n\t}\n\n\tabsy := y;\n\tflip := false;\n\tif absy < 0 {\n\t\tabsy = -absy;\n\t\tflip = true;\n\t}\n\tyi, yf := Modf(absy);\n\tif yf != 0 && x < 0 {\n\t\treturn NaN()\n\t}\n\tif yi >= 1<<63 {\n\t\treturn Exp(y * Log(x))\n\t}\n\n\t// ans = a1 * 2^ae (= 1 for now).\n\ta1 := float64(1);\n\tae := 0;\n\n\t// ans *= x^yf\n\tif yf != 0 {\n\t\tif yf > 0.5 {\n\t\t\tyf--;\n\t\t\tyi++;\n\t\t}\n\t\ta1 = Exp(yf * Log(x));\n\t}\n\n\t// ans *= x^yi\n\t// by multiplying in successive squarings\n\t// of x according to bits of yi.\n\t// accumulate powers of two into exp.\n\tx1, xe := Frexp(x);\n\tfor i := int64(yi); i != 0; i >>= 1 {\n\t\tif i&1 == 1 {\n\t\t\ta1 *= x1;\n\t\t\tae += xe;\n\t\t}\n\t\tx1 *= x1;\n\t\txe <<= 1;\n\t\tif x1 < .5 {\n\t\t\tx1 += x1;\n\t\t\txe--;\n\t\t}\n\t}\n\n\t// ans = a1*2^ae\n\t// if flip { ans = 1 / ans }\n\t// but in the opposite order\n\tif flip {\n\t\ta1 = 1 / a1;\n\t\tae = -ae;\n\t}\n\treturn Ldexp(a1, ae);\n}", "func (p *EdwardsPoint) mulByPow2(t *EdwardsPoint, k uint) *EdwardsPoint {\n\tif k == 0 {\n\t\tpanic(\"curve/edwards: k out of bounds\")\n\t}\n\n\tvar (\n\t\tr completedPoint\n\t\ts projectivePoint\n\t)\n\ts.SetEdwards(t)\n\tfor i := uint(0); i < k-1; i++ {\n\t\ts.SetCompleted(r.Double(&s))\n\t}\n\t// Unroll last iteration so we can directly convert back to an EdwardsPoint.\n\treturn p.setCompleted(r.Double(&s))\n}", "func SimplePower(exp string) string {\n var index int = strings.Index(exp, \"^\")\n var arg1 string = exp[:index]\n var arg2 string = exp[index + 1:]\n val1 := NotateToDouble(arg1)\n val2 := NotateToDouble(arg2)\n return NegativeNotate(fmt.Sprintf(\"%f\", math.Pow(val1, val2)))\n}", "func smallExp(z, x *inf.Dec, s inf.Scale) *inf.Dec {\n\t// Allocate if needed and make sure args aren't mutated.\n\tif z == nil {\n\t\tz = new(inf.Dec)\n\t\tz.SetUnscaled(1).SetScale(0)\n\t}\n\tn := new(inf.Dec)\n\ttmp := new(inf.Dec).Set(z)\n\tfor loop := newLoop(\"exp\", z, s, 1); !loop.done(z); {\n\t\tn.Add(n, decimalOne)\n\t\ttmp.Mul(tmp, x)\n\t\ttmp.QuoRound(tmp, n, s+2, inf.RoundHalfUp)\n\t\tz.Add(z, tmp)\n\t}\n\t// Round to the desired scale.\n\treturn z.Round(z, s, inf.RoundHalfUp)\n}", "func (z *Float) Mul(x, y *Float) *Float {\n\t// possible: panic(ErrNaN{\"multiplication of zero with infinity\"})\n}", "func pow2(e int) []byte {\n\n\tres := []byte{byte(1 << uint(e%8))}\n\n\tres = append(res, make([]byte, e/8)...)\n\n\treturn res\n}", "func (g *Graph) Exp(x Node) Node {\n\treturn g.NewOperator(fn.NewExp(x), x)\n}", "func Mul(x, y Number) Number {\n\treturn Number{\n\t\tReal: x.Real * y.Real,\n\t\tE1mag: x.Real*y.E1mag + x.E1mag*y.Real,\n\t\tE2mag: x.Real*y.E2mag + x.E2mag*y.Real,\n\t\tE1E2mag: x.Real*y.E1E2mag + x.E1mag*y.E2mag + x.E2mag*y.E1mag + x.E1E2mag*y.Real,\n\t}\n}", "func ExpFloat64() float64 { return globalRand.ExpFloat64() }", "func ExpFloat64() float64 { return globalRand.ExpFloat64() }", "func Exp(a Int, e Int) Int {\n\treturn Int{big.NewInt(0).Exp(a.Int, e.Int, nil)}\n}", "func Pow(base []uint8, exp uint64) []uint8 {\n\tvar result []uint8 = base\n\n\tfor i := exp - 1; i != 0; i-- {\n\t\tresult = Product(result, base)\n\t}\n\treturn result\n}", "func (z nat) expNN(x, y, m nat) nat {\n\tif alias(z, x) || alias(z, y) {\n\t\t// We cannot allow in place modification of x or y.\n\t\tz = nil\n\t}\n\n\tif len(y) == 0 {\n\t\tz = z.make(1)\n\t\tz[0] = 1\n\t\treturn z\n\t}\n\n\tif m != nil {\n\t\t// We likely end up being as long as the modulus.\n\t\tz = z.make(len(m))\n\t}\n\tz = z.set(x)\n\tv := y[len(y)-1]\n\t// It's invalid for the most significant word to be zero, therefore we\n\t// will find a one bit.\n\tshift := leadingZeros(v) + 1\n\tv <<= shift\n\tvar q nat\n\n\tconst mask = 1 << (_W - 1)\n\n\t// We walk through the bits of the exponent one by one. Each time we\n\t// see a bit, we square, thus doubling the power. If the bit is a one,\n\t// we also multiply by x, thus adding one to the power.\n\n\tw := _W - int(shift)\n\tfor j := 0; j < w; j++ {\n\t\tz = z.mul(z, z)\n\n\t\tif v&mask != 0 {\n\t\t\tz = z.mul(z, x)\n\t\t}\n\n\t\tif m != nil {\n\t\t\tq, z = q.div(z, z, m)\n\t\t}\n\n\t\tv <<= 1\n\t}\n\n\tfor i := len(y) - 2; i >= 0; i-- {\n\t\tv = y[i]\n\n\t\tfor j := 0; j < _W; j++ {\n\t\t\tz = z.mul(z, z)\n\n\t\t\tif v&mask != 0 {\n\t\t\t\tz = z.mul(z, x)\n\t\t\t}\n\n\t\t\tif m != nil {\n\t\t\t\tq, z = q.div(z, z, m)\n\t\t\t}\n\n\t\t\tv <<= 1\n\t\t}\n\t}\n\n\treturn z\n}", "func (s VectOp) Exp() VectOp {\n\treturn fs.Exp(s)\n}", "func (v Posit16x2) Exp() []int16 {\n\tout := make([]int16, 2)\n\tfor i, posit := range v.impl {\n\t\tout[i] = posit.Exp()\n\t}\n\treturn out\n}", "func mathExpm1(ctx phpv.Context, args []*phpv.ZVal) (*phpv.ZVal, error) {\n\tvar x phpv.ZFloat\n\t_, err := core.Expand(ctx, args, &x)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn phpv.ZFloat(math.Expm1(float64(x))).ZVal(), nil\n}", "func (z *E12) Mul(x, y *E12) *E12 {\n\tvar a, b, c E6\n\ta.Add(&x.C0, &x.C1)\n\tb.Add(&y.C0, &y.C1)\n\ta.Mul(&a, &b)\n\tb.Mul(&x.C0, &y.C0)\n\tc.Mul(&x.C1, &y.C1)\n\tz.C1.Sub(&a, &b).Sub(&z.C1, &c)\n\tz.C0.MulByNonResidue(&c).Add(&z.C0, &b)\n\treturn z\n}", "func (c *Context) VEXTRACTI64X2_Z(i, yz, k, mx operand.Op) {\n\tc.addinstruction(x86.VEXTRACTI64X2_Z(i, yz, k, mx))\n}", "func MulA24(z, x *Elt)", "func feMul(out *fieldElement, a *fieldElement, b *fieldElement)", "func (d Decimal) Mul(d2 Decimal) Decimal {\n\td.ensureInitialized()\n\td2.ensureInitialized()\n\n\texpInt64 := int64(d.exp) + int64(d2.exp)\n\tif expInt64 > math.MaxInt32 || expInt64 < math.MinInt32 {\n\t\t// NOTE(vadim): better to panic than give incorrect results, as\n\t\t// Decimals are usually used for money\n\t\tpanic(fmt.Sprintf(\"exponent %v overflows an int32!\", expInt64))\n\t}\n\n\td3Value := new(big.Int).Mul(d.value, d2.value)\n\treturn Decimal{\n\t\tvalue: d3Value,\n\t\texp: int32(expInt64),\n\t}\n}", "func (d Decimal) Mul(d2 Decimal) Decimal {\n\td.ensureInitialized()\n\td2.ensureInitialized()\n\n\texpInt64 := int64(d.exp) + int64(d2.exp)\n\tif expInt64 > math.MaxInt32 || expInt64 < math.MinInt32 {\n\t\t// NOTE(vadim): better to panic than give incorrect results, as\n\t\t// Decimals are usually used for money\n\t\tpanic(fmt.Sprintf(\"exponent %v overflows an int32!\", expInt64))\n\t}\n\n\td3Value := new(big.Int).Mul(d.value, d2.value)\n\treturn Decimal{\n\t\tvalue: d3Value,\n\t\texp: int32(expInt64),\n\t}\n}", "func (d Decimal) Pow(d2 Decimal) Decimal {\n\tvar temp Decimal\n\tif d2.IntPart() == 0 {\n\t\treturn NewFromFloat(1)\n\t}\n\ttemp = d.Pow(d2.Div(NewFromFloat(2)))\n\tif d2.IntPart()%2 == 0 {\n\t\treturn temp.Mul(temp)\n\t}\n\tif d2.IntPart() > 0 {\n\t\treturn temp.Mul(temp).Mul(d)\n\t}\n\treturn temp.Mul(temp).Div(d)\n}", "func (d Decimal) Pow(d2 Decimal) Decimal {\n\tvar temp Decimal\n\tif d2.IntPart() == 0 {\n\t\treturn NewFromFloat(1)\n\t}\n\ttemp = d.Pow(d2.Div(NewFromFloat(2)))\n\tif d2.IntPart()%2 == 0 {\n\t\treturn temp.Mul(temp)\n\t}\n\tif d2.IntPart() > 0 {\n\t\treturn temp.Mul(temp).Mul(d)\n\t}\n\treturn temp.Mul(temp).Div(d)\n}", "func (x f26dot6) mul(y f26dot6) f26dot6 {\n\treturn f26dot6(int64(x) * int64(y) >> 6)\n}", "func (z *E6) Mul(x, y *E6) *E6 {\n\t// Algorithm 13 from https://eprint.iacr.org/2010/354.pdf\n\tvar t0, t1, t2, c0, c1, c2, tmp E2\n\tt0.Mul(&x.B0, &y.B0)\n\tt1.Mul(&x.B1, &y.B1)\n\tt2.Mul(&x.B2, &y.B2)\n\n\tc0.Add(&x.B1, &x.B2)\n\ttmp.Add(&y.B1, &y.B2)\n\tc0.Mul(&c0, &tmp).Sub(&c0, &t1).Sub(&c0, &t2).MulByNonResidue(&c0).Add(&c0, &t0)\n\n\tc1.Add(&x.B0, &x.B1)\n\ttmp.Add(&y.B0, &y.B1)\n\tc1.Mul(&c1, &tmp).Sub(&c1, &t0).Sub(&c1, &t1)\n\ttmp.MulByNonResidue(&t2)\n\tc1.Add(&c1, &tmp)\n\n\ttmp.Add(&x.B0, &x.B2)\n\tc2.Add(&y.B0, &y.B2).Mul(&c2, &tmp).Sub(&c2, &t0).Sub(&c2, &t2).Add(&c2, &t1)\n\n\tz.B0.Set(&c0)\n\tz.B1.Set(&c1)\n\tz.B2.Set(&c2)\n\n\treturn z\n}", "func (c *Context) VEXTRACTF64X2_Z(i, yz, k, mx operand.Op) {\n\tc.addinstruction(x86.VEXTRACTF64X2_Z(i, yz, k, mx))\n}", "func (self *State)Exp(a any)any{\n self.IncOperations(self.coeff[\"exp\"]+self.off[\"exp\"])\n return wrap1(a,math.Exp)\n}", "func (z *E2) Square(x *E2) *E2 {\n\tsquareGenericE2(z, x)\n\treturn z\n}", "func multi2(x int) int {\n\treturn x * 2\n}", "func (x *Secp256k1N) Mul(y, z *Secp256k1N) {\n\tC.secp256k1n_mul((*C.secp256k1n)(unsafe.Pointer(x)), (*C.secp256k1n)(unsafe.Pointer(y)), (*C.secp256k1n)(unsafe.Pointer(z)))\n}", "func (c *CurveOperations) Pow2k(xP *ProjectivePoint, params *CurveCoefficientsEquiv, k uint32) {\n\tvar t0, t1 Fp2Element\n\tvar op = c.Params.Op\n\n\tx, z := &xP.X, &xP.Z\n\tfor i := uint32(0); i < k; i++ {\n\t\top.Sub(&t0, x, z) // t0 = Xp - Zp\n\t\top.Add(&t1, x, z) // t1 = Xp + Zp\n\t\top.Square(&t0, &t0) // t0 = t0 ^ 2\n\t\top.Square(&t1, &t1) // t1 = t1 ^ 2\n\t\top.Mul(z, &params.C, &t0) // Z2p = C24 * t0\n\t\top.Mul(x, z, &t1) // X2p = Z2p * t1\n\t\top.Sub(&t1, &t1, &t0) // t1 = t1 - t0\n\t\top.Mul(&t0, &params.A, &t1) // t0 = A24+ * t1\n\t\top.Add(z, z, &t0) // Z2p = Z2p + t0\n\t\top.Mul(z, z, &t1) // Zp = Z2p * t1\n\t}\n}", "func (z *Int) Mul(x, y *Int) {\n\n\tvar (\n\t\talfa = &Int{} // Aggregate results\n\t\tbeta = &Int{} // Calculate intermediate\n\t)\n\t// The numbers are internally represented as [ a, b, c, d ]\n\t// We do the following operations\n\t//\n\t// d1 * d2\n\t// d1 * c2 (upshift 64)\n\t// d1 * b2 (upshift 128)\n\t// d1 * a2 (upshift 192)\n\t//\n\t// c1 * d2 (upshift 64)\n\t// c1 * c2 (upshift 128)\n\t// c1 * b2 (upshift 192)\n\t//\n\t// b1 * d2 (upshift 128)\n\t// b1 * c2 (upshift 192)\n\t//\n\t// a1 * d2 (upshift 192)\n\t//\n\t// And we aggregate results into 'alfa'\n\n\t// One optimization, however, is reordering.\n\t// For these ones, we don't care about if they overflow, thus we can use native multiplication\n\t// and set the result immediately into `a` of the result.\n\t// b1 * c2 (upshift 192)\n\t// a1 * d2 (upshift 192)\n\t// d1 * a2 (upshift 192)\n\t// c1 * b2 11(upshift 192)\n\n\t// Remaining ops:\n\t//\n\t// d1 * d2\n\t// d1 * c2 (upshift 64)\n\t// d1 * b2 (upshift 128)\n\t//\n\t// c1 * d2 (upshift 64)\n\t// c1 * c2 (upshift 128)\n\t//\n\t// b1 * d2 (upshift 128)\n\n\talfa.mulIntoLower128(x[0], y[0])\n\talfa.mulIntoUpper128(x[0], y[2])\n\talfa[3] += x[0]*y[3] + x[1]*y[2] + x[2]*y[1] + x[3]*y[0] // Top ones, ignore overflow\n\n\tbeta.mulIntoMiddle128(x[0], y[1])\n\talfa.Add(alfa, beta)\n\n\tbeta.Clear().mulIntoMiddle128(x[1], y[0])\n\talfa.Add(alfa, beta)\n\n\tbeta.Clear().mulIntoUpper128(x[1], y[1])\n\talfa.addHigh128(beta[3], beta[2])\n\n\tbeta.Clear().mulIntoUpper128(x[2], y[0])\n\talfa.addHigh128(beta[3], beta[2])\n\tz.Copy(alfa)\n\n}", "func (f Float) Exp() int {\n\t// 0b0111111111111111\n\treturn int(f.se & 0x7FFF)\n}", "func VEXTRACTI64X2_Z(i, yz, k, mx operand.Op) { ctx.VEXTRACTI64X2_Z(i, yz, k, mx) }", "func (z *Rat) Mul(x, y *Rat) *Rat {}", "func (expr Expression) Multiply() (float64, error) {\n\treturn (expr.FirstOperand.Value * expr.SecondOperand.Value), nil\n}", "func (c *Clac) Exp() error {\n\treturn c.applyFloat(1, func(vals []value.Value) (value.Value, error) {\n\t\treturn unary(\"**\", vals[0])\n\t})\n}", "func mul(x, y int) int {\n\treturn x * y\n}", "func (v Vector2D) Multiply(s float64) Vector {\n\treturn Vector2D{v.X * s, v.Y * s}\n}", "func MULPS(mx, x operand.Op) { ctx.MULPS(mx, x) }", "func (z *polyGF2) Mul(a, b *polyGF2) *polyGF2 {\n\tvar out *polyGF2\n\tif z != a && z != b {\n\t\tout = z\n\t} else {\n\t\tout = &polyGF2{}\n\t}\n\n\tdx := a.Degree()\n\tvar bs big.Int\n\tfor i := 0; i <= dx; i++ {\n\t\tif a.coeff.Bit(i) != 0 {\n\t\t\tbs.Lsh(&b.coeff, uint(i))\n\t\t\tout.coeff.Xor(&out.coeff, &bs)\n\t\t}\n\t}\n\n\tif z != out {\n\t\tz.coeff.Set(&out.coeff)\n\t}\n\treturn z\n}", "func VEXTRACTF64X2_Z(i, yz, k, mx operand.Op) { ctx.VEXTRACTF64X2_Z(i, yz, k, mx) }", "func Sqr(z, x *Elt)", "func exp2s(log int) int {\n\tvar value uint\n\n\tif log < 0 {\n\t\treturn -exp2s(-log)\n\t}\n\n\tvalue = uint(exp2_table[log&0xff] | 0x100)\n\n\tlog >>= 8\n\tif log <= 9 {\n\t\treturn int((value >> uint(9-log)))\n\t} else {\n\t\treturn int((value << uint(log-9)))\n\t}\n\n\treturn 0 // again, cannot actually reach this line, but keeps the compiler happy :)\n}", "func ExpReg(s []Coordinate) (regressions []Coordinate, err error) {\n\treturn ExponentialRegression(s)\n}", "func FloatMantExp(x *big.Float, mant *big.Float,) int", "func MULSD(mx, x operand.Op) { ctx.MULSD(mx, x) }", "func (z *Float64) Mul(x, y *Float64) *Float64 {\n\ta := (x.l * y.l) + (y.r * x.r)\n\tb := (x.r * y.l) + (y.r * x.l)\n\tz.SetPair(a, b)\n\treturn z\n}", "func (p *G2Jac) multiExp(curve *Curve, points []G2Jac, scalars []fr.Element) *G2Jac {\n\tconst s = 4 // s from Bootle, we choose s divisible by scalar bit length\n\tconst b = s // b from Bootle, we choose b equal to s\n\t// WARNING! This code breaks if you switch to b!=s\n\t// Because we chose b=s, each set S_i from Bootle is simply the set of points[i]^{2^j} for each j in [0:s]\n\t// This choice allows for simpler code\n\t// If you want to use b!=s then the S_i from Bootle are different\n\tconst TSize = (1 << b) - 1 // TSize is size of T_i sets from Bootle, equal to 2^b - 1\n\t// Store only one set T_i at a time---don't store them all!\n\tvar T [TSize]G2Jac // a set T_i from Bootle, the set of g^j for j in [1:2^b] for some choice of g\n\tcomputeT := func(T []G2Jac, t0 *G2Jac) {\n\t\tT[0].Set(t0)\n\t\tfor j := 1; j < (1<<b)-1; j = j + 2 {\n\t\t\tT[j].Set(&T[j/2]).Double()\n\t\t\tT[j+1].Set(&T[(j+1)/2]).Add(curve, &T[j/2])\n\t\t}\n\t}\n\treturn p.pippenger(curve, points, scalars, s, b, T[:], computeT)\n}", "func (self *State)Pow(a,b any)any{\n self.IncOperations(self.coeff[\"pow\"]+self.off[\"pow\"])\n return wrap2(a,b,math.Pow)\n}", "func ExpM1(arg float64) float64 {\n\treturn math.Exp(arg) - 1\n}", "func (ff FiniteField) Exp(elem1 float64, power int64) float64 {\n\tvar value float64 = 1\n\treducedExponent := mod(float64(power), float64(ff.order-1))\n\tfor i := int64(0); i < int64(reducedExponent); i++ {\n\t\tvalue = ff.Multiply(value, elem1)\n\t}\n\n\treturn ff.mod(value)\n}", "func Mul(x, y *Money) *Money {\n\tz := Money{}\n\treturn &z\n}" ]
[ "0.69238585", "0.65481603", "0.65338546", "0.6463379", "0.64598817", "0.6399806", "0.63596535", "0.628247", "0.6246554", "0.619069", "0.61777186", "0.6069037", "0.59977776", "0.5917513", "0.5910885", "0.59044635", "0.58424276", "0.5786833", "0.57340926", "0.57008433", "0.5681458", "0.5676606", "0.5669513", "0.56400985", "0.5638498", "0.5620237", "0.5610389", "0.5606376", "0.55928534", "0.5581458", "0.5580721", "0.55724204", "0.55247617", "0.54929006", "0.54779124", "0.5468266", "0.5458075", "0.54514635", "0.5441979", "0.54268557", "0.5426081", "0.54203963", "0.5410264", "0.53983086", "0.5379942", "0.53740394", "0.536798", "0.53634316", "0.5330521", "0.5325959", "0.5322725", "0.5308014", "0.53068924", "0.52938074", "0.5289651", "0.5289651", "0.52894133", "0.52879244", "0.5286874", "0.52859354", "0.52858883", "0.5255241", "0.5254049", "0.5224674", "0.5219185", "0.52122223", "0.5211823", "0.5211823", "0.5211546", "0.5211546", "0.51846063", "0.5180106", "0.5170135", "0.5167008", "0.51549083", "0.5152236", "0.51352686", "0.5126277", "0.5122508", "0.51120144", "0.51116073", "0.51057714", "0.50907016", "0.50842786", "0.5083633", "0.5068784", "0.5061002", "0.5054125", "0.50509846", "0.5049703", "0.50470215", "0.50305", "0.5022978", "0.5009237", "0.5004785", "0.49947318", "0.4990396", "0.49823126", "0.49821293", "0.49785063" ]
0.7422884
0
Div2Exp sets z = x / 2^s and returns z.
Div2Exp устанавливает z = x / 2^s и возвращает z.
func (f *Float) Div2Exp(x *Float, s uint) *Float { x.doinit() f.doinit() C.mpf_div_2exp(&f.i[0], &x.i[0], C.mp_bitcnt_t(s)) return f }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Exp(z, n *inf.Dec, s inf.Scale) *inf.Dec {\n\ts += 2\n\tnn := new(inf.Dec).Set(n)\n\tif z == nil {\n\t\tz = new(inf.Dec)\n\t\tz.SetUnscaled(1).SetScale(0)\n\t} else {\n\t\tz.SetUnscaled(1).SetScale(0)\n\t}\n\n\t// We are computing (e^n) by splitting n into an integer and a float\n\t// (e.g 3.1 ==> x = 3, y = 0.1), this allows us to write\n\t// e^n = e^(x+y) = e^x * e^y\n\n\t// Split out x (integer(n))\n\tx := new(inf.Dec).Round(nn, 0, inf.RoundDown)\n\n\t// Split out y (n - x) which is < 1\n\ty := new(inf.Dec).Sub(nn, x)\n\n\t// convert x to integer\n\tinteger, ok := x.Unscaled()\n\tif !ok {\n\t\tpanic(\"integer out of range\")\n\t}\n\n\tex := integerPower(z, new(inf.Dec).Set(decimalE), integer, s+2)\n\treturn smallExp(ex, y, s-2)\n}", "func mathExp(ctx phpv.Context, args []*phpv.ZVal) (*phpv.ZVal, error) {\n\tvar x phpv.ZFloat\n\t_, err := core.Expand(ctx, args, &x)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn phpv.ZFloat(math.Exp(float64(x))).ZVal(), nil\n}", "func ModExp(x, y, N int64) int64 {\n\tif y == 0 {\n\t\treturn 1\n\t}\n\tz := ModExp(x, y/2, N)\n\tt := (z * z) % N\n\tif y%2 == 0 {\n\t\treturn t\n\t}\n\treturn (x * t) % N\n}", "func Pow(z, x, y *inf.Dec, s inf.Scale) (*inf.Dec, error) {\n\ts = s + 2\n\tif z == nil {\n\t\tz = new(inf.Dec)\n\t\tz.SetUnscaled(1).SetScale(0)\n\t}\n\n\t// Check if y is of type int.\n\ttmp := new(inf.Dec).Abs(y)\n\tisInt := tmp.Cmp(new(inf.Dec).Round(tmp, 0, inf.RoundDown)) == 0\n\n\txs := x.Sign()\n\tif xs == 0 {\n\t\tswitch y.Sign() {\n\t\tcase 0:\n\t\t\treturn z.SetUnscaled(1).SetScale(0), nil\n\t\tcase 1:\n\t\t\treturn z.SetUnscaled(0).SetScale(0), nil\n\t\tdefault: // -1\n\t\t\t// undefined for y < 0\n\t\t\treturn nil, errPowZeroNegative\n\t\t}\n\t}\n\n\tneg := xs < 0\n\n\tif !isInt && neg {\n\t\treturn nil, errPowNegNonInteger\n\t}\n\n\t// Exponent Precision Explanation (RaduBerinde):\n\t// Say we compute the Log with a scale of k. That means that the result we get is:\n\t// ln x +/- 10^-k.\n\t// This leads to an error of y * 10^-k in the exponent, which leads to a\n\t// multiplicative error of e^(y*10^-k) in the result.\n\t// For small values of u, e^u can be approximated by 1 + u, so for large k\n\t// that error is around 1 + y*10^-k. So the additive error will be x^y * y * 10^-k,\n\t// and we want this to be less than 10^-s. This approximately means that k has to be\n\t// s + the number of digits before the decimal point in x^y. Which roughly is\n\t//\n\t// s + <the number of digits before decimal point in x> * y.\n\t//\n\t// exponent precision = s + <the number of digits before decimal point in x> * y.\n\tnumDigits := float64(x.UnscaledBig().BitLen()) / digitsToBitsRatio\n\tnumDigits -= float64(x.Scale())\n\n\t// Round up y which should provide us with a threshold in calculating the new scale.\n\tyu := float64(new(inf.Dec).Round(y, 0, inf.RoundUp).UnscaledBig().Int64())\n\n\t// exponent precision = s + <the number of digits before decimal point in x> * y\n\tes := s + inf.Scale(numDigits*yu)\n\tif es < 0 || es > maxPrecision {\n\t\treturn nil, errArgumentTooLarge\n\t}\n\n\ttmp = new(inf.Dec).Abs(x)\n\t_, err := Log(tmp, tmp, es)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ttmp.Mul(tmp, y)\n\tExp(tmp, tmp, es)\n\n\tif neg && y.Round(y, 0, inf.RoundDown).UnscaledBig().Bit(0) == 1 {\n\t\ttmp.Neg(tmp)\n\t}\n\n\t// Round to the desired scale.\n\treturn z.Round(tmp, s-2, inf.RoundHalfUp), nil\n}", "func (f *Float) Mul2Exp(x *Float, s uint) *Float {\n\tx.doinit()\n\tf.doinit()\n\tC.mpf_mul_2exp(&f.i[0], &x.i[0], C.mp_bitcnt_t(s))\n\treturn f\n}", "func (z *Int) Exp(x, y, m *Int) *Int {}", "func (z *Int) Div(x, y *Int) *Int {}", "func (z *Int) Exp(base, exponent *Int) *Int {\n\treturn z.Copy(ExpF(base, exponent))\n}", "func (z *Element22) Div(x, y *Element22) *Element22 {\n\tvar yInv Element22\n\tyInv.Inverse(y)\n\tz.Mul(x, &yInv)\n\treturn z\n}", "func (x f26dot6) div(y f26dot6) f26dot6 {\n\treturn f26dot6((int64(x) << 6) / int64(y))\n}", "func (z *Int) Div(x, y *Int) *Int {\n\tif y.IsZero() || y.Gt(x) {\n\t\treturn z.Clear()\n\t}\n\tif x.Eq(y) {\n\t\treturn z.SetOne()\n\t}\n\t// Shortcut some cases\n\tif x.IsUint64() {\n\t\treturn z.SetUint64(x.Uint64() / y.Uint64())\n\t}\n\n\t// At this point, we know\n\t// x/y ; x > y > 0\n\t// See Knuth, Volume 2, section 4.3.1, Algorithm D.\n\n\t// Normalize by shifting divisor left just enough so that its high-order\n\t// bit is on and u left the same amount.\n\t// function nlz do the caculating of the amount and shl do the left operation.\n\ts := nlz(y)\n\txn := shl(x, s, true)\n\tyn := shl(y, s, false)\n\n\t// divKnuth do the division of normalized dividend and divisor with Knuth Algorithm D.\n\tq := divKnuth(xn, yn)\n\n\tz.Clear()\n\tfor i := 0; i < len(q); i++ {\n\t\tz[i/2] = z[i/2] | uint64(q[i])<<(32*(uint64(i)%2))\n\t}\n\n\treturn z\n}", "func (self *State)Exp2(a any)any{\n self.IncOperations(self.coeff[\"exp2\"]+self.off[\"exp2\"])\n return wrap1(a,math.Exp2)\n}", "func Exp(o, z *big.Float) *big.Float {\n\tif o.Prec() == 0 {\n\t\to.SetPrec(z.Prec())\n\t}\n\tif z.Sign() == 0 {\n\t\treturn o.SetFloat64(1)\n\t}\n\tif z.IsInf() {\n\t\tif z.Sign() < 0 {\n\t\t\treturn o.Set(&gzero)\n\t\t}\n\t\treturn o.Set(z)\n\t}\n\n\tp := o\n\tif p == z {\n\t\t// We need z for Newton's algorithm, so ensure we don't overwrite it.\n\t\tp = new(big.Float).SetPrec(z.Prec())\n\t}\n\t// try to get initial estimate using IEEE-754 math\n\t// TODO: save work (and an import of math) by checking the exponent of z\n\tzf, _ := z.Float64()\n\tzf = math.Exp(zf)\n\tif math.IsInf(zf, 1) || zf == 0 {\n\t\t// too big or too small for IEEE-754 math,\n\t\t// perform argument reduction using\n\t\t// e^{2z} = (e^z)²\n\t\thalfZ := quicksh(new(big.Float), z, -1).SetPrec(p.Prec() + 64)\n\t\t// TODO: avoid recursion\n\t\thalfExp := Exp(halfZ, halfZ)\n\t\treturn p.Mul(halfExp, halfExp)\n\t}\n\t// we got a nice IEEE-754 estimate\n\tguess := big.NewFloat(zf)\n\n\t// f(t)/f'(t) = t*(log(t) - z)\n\tf := func(t *big.Float) *big.Float {\n\t\tp.Sub(Log(new(big.Float), t), z)\n\t\treturn p.Mul(p, t)\n\t}\n\n\tx := newton(f, guess, z.Prec()) // TODO: make newton operate in place\n\n\treturn o.Set(x)\n}", "func Exp(x float64) float64 {\n\n\treturn math.Exp(x)\n}", "func exp2s(log int) int {\n\tvar value uint\n\n\tif log < 0 {\n\t\treturn -exp2s(-log)\n\t}\n\n\tvalue = uint(exp2_table[log&0xff] | 0x100)\n\n\tlog >>= 8\n\tif log <= 9 {\n\t\treturn int((value >> uint(9-log)))\n\t} else {\n\t\treturn int((value << uint(log-9)))\n\t}\n\n\treturn 0 // again, cannot actually reach this line, but keeps the compiler happy :)\n}", "func div(x byte, y byte) byte {\n\tif x == 0 || y == 0 {\n\t\treturn 0\n\t}\n\treturn expOp[0xff+logOp[x]-logOp[y]]\n}", "func (d Decimal) Div(d2 Decimal) Decimal {\n\treturn d.DivRound(d2, int32(DivisionPrecision))\n}", "func (d Decimal) Div(d2 Decimal) Decimal {\n\treturn d.DivRound(d2, int32(DivisionPrecision))\n}", "func (z *Element22) Exp(x Element22, e uint64) *Element22 {\n\tif e == 0 {\n\t\treturn z.SetOne()\n\t}\n\n\tz.Set(&x)\n\n\tl := bits.Len64(e) - 2\n\tfor i := l; i >= 0; i-- {\n\t\tz.Square(z)\n\t\tif e&(1<<uint(i)) != 0 {\n\t\t\tz.MulAssign(&x)\n\t\t}\n\t}\n\treturn z\n}", "func Exp(x float64) float64 {\n\tx = 1.0 + x/1024\n\tx *= x\n\tx *= x\n\tx *= x\n\tx *= x\n\tx *= x\n\tx *= x\n\tx *= x\n\tx *= x\n\tx *= x\n\tx *= x\n\n\treturn x\n}", "func DIVSS(mx, x operand.Op) { ctx.DIVSS(mx, x) }", "func VDIVPD_RZ_SAE_Z(z, z1, k, z2 operand.Op) { ctx.VDIVPD_RZ_SAE_Z(z, z1, k, z2) }", "func IntDiv(z *big.Int, x, y *big.Int,) *big.Int", "func (z *E12) Exp(x *E12, e big.Int) *E12 {\n\tvar res E12\n\tres.SetOne()\n\tb := e.Bytes()\n\tfor i := range b {\n\t\tw := b[i]\n\t\tmask := byte(0x80)\n\t\tfor j := 7; j >= 0; j-- {\n\t\t\tres.Square(&res)\n\t\t\tif (w&mask)>>j != 0 {\n\t\t\t\tres.Mul(&res, x)\n\t\t\t}\n\t\t\tmask = mask >> 1\n\t\t}\n\t}\n\tz.Set(&res)\n\treturn z\n}", "func VDIVPS_RZ_SAE_Z(z, z1, k, z2 operand.Op) { ctx.VDIVPS_RZ_SAE_Z(z, z1, k, z2) }", "func (f *Float) Float2Exp() (d float64, exp int) {\n\tvar exp_ C.long\n\td = float64(C.mpf_get_d_2exp(&exp_, &f.i[0]))\n\texp = int(exp_)\n\treturn\n}", "func Exp(arg float64) float64 {\n\treturn math.Exp(arg)\n}", "func (z *Int) DivMod(x, y, m *Int) (*Int, *Int) {}", "func VDIVPS_Z(mxyz, xyz, k, xyz1 operand.Op) { ctx.VDIVPS_Z(mxyz, xyz, k, xyz1) }", "func VDIVSS_Z(mx, x, k, x1 operand.Op) { ctx.VDIVSS_Z(mx, x, k, x1) }", "func IntDivMod(z *big.Int, x, y, m *big.Int,) (*big.Int, *big.Int,)", "func IntExp(z *big.Int, x, y, m *big.Int,) *big.Int", "func SimpleDivide(exp string) string {\n var index int = strings.Index(exp, \"/\")\n var arg1 string = exp[:index]\n var arg2 string = exp[index + 1:]\n val1 := NotateToDouble(arg1)\n val2 := NotateToDouble(arg2)\n return NegativeNotate(fmt.Sprintf(\"%f\", val1 / val2))\n}", "func FloatSetMantExp(z *big.Float, mant *big.Float, exp int) *big.Float", "func Command_Div(script *rex.Script, params []*rex.Value) {\n\tif len(params) != 2 {\n\t\trex.ErrorParamCount(\"float:div\", \"2\")\n\t}\n\n\tscript.RetVal = rex.NewValueFloat64(params[0].Float64() / params[1].Float64())\n\treturn\n}", "func (v Posit16x2) Exp() []int16 {\n\tout := make([]int16, 2)\n\tfor i, posit := range v.impl {\n\t\tout[i] = posit.Exp()\n\t}\n\treturn out\n}", "func CalculateExponentTerm(z complex128, power1, power2 int, scale complex128, ignoreComplexConjugate bool) complex128 {\n\tzRaisedToN := cmplx.Pow(z, complex(float64(power1), 0))\n\tif ignoreComplexConjugate {\n\t\treturn zRaisedToN * scale\n\t}\n\n\tcomplexConjugate := complex(real(z), -1*imag(z))\n\tcomplexConjugateRaisedToM := cmplx.Pow(complexConjugate, complex(float64(power2), 0))\n\treturn zRaisedToN * complexConjugateRaisedToM * scale\n}", "func VDIVPD_RU_SAE_Z(z, z1, k, z2 operand.Op) { ctx.VDIVPD_RU_SAE_Z(z, z1, k, z2) }", "func (c *Context) VDIVSS_Z(mx, x, k, x1 operand.Op) {\n\tc.addinstruction(x86.VDIVSS_Z(mx, x, k, x1))\n}", "func Exp(base, exponent, modulus *big.Int) *big.Int {\n\treturn I().Exp(base, exponent, modulus)\n}", "func Xdivy(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Xdivy\",\n\t\tInput: []tf.Input{\n\t\t\tx, y,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func cdiv(a, b int) int { return (a + b - 1) / b }", "func DIVSD(mx, x operand.Op) { ctx.DIVSD(mx, x) }", "func (f Float) Exp() int {\n\t// 0b0111111111111111\n\treturn int(f.se & 0x7FFF)\n}", "func (c *Context) VDIVPS_Z(mxyz, xyz, k, xyz1 operand.Op) {\n\tc.addinstruction(x86.VDIVPS_Z(mxyz, xyz, k, xyz1))\n}", "func VDIVPS_RU_SAE_Z(z, z1, k, z2 operand.Op) { ctx.VDIVPS_RU_SAE_Z(z, z1, k, z2) }", "func VDIVPD_Z(mxyz, xyz, k, xyz1 operand.Op) { ctx.VDIVPD_Z(mxyz, xyz, k, xyz1) }", "func ExpF(base, exponent *Int) *Int {\n\tz := &Int{1, 0, 0, 0}\n\t// b^0 == 1\n\tif exponent.IsZero() || base.IsOne() {\n\t\treturn z\n\t}\n\t// b^1 == b\n\tif exponent.IsOne() {\n\t\tz.Copy(base)\n\t\treturn z\n\t}\n\tvar (\n\t\tword uint64\n\t\tbits int\n\t)\n\texpBitlen := exponent.BitLen()\n\n\tword = exponent[0]\n\tbits = 0\n\tfor ; bits < expBitlen && bits < 64; bits++ {\n\t\tif word&1 == 1 {\n\t\t\tz.Mul(z, base)\n\t\t}\n\t\tbase.Squared()\n\t\tword >>= 1\n\t}\n\n\tword = exponent[1]\n\tfor ; bits < expBitlen && bits < 128; bits++ {\n\t\tif word&1 == 1 {\n\t\t\tz.Mul(z, base)\n\t\t}\n\t\tbase.Squared()\n\t\tword >>= 1\n\t}\n\n\tword = exponent[2]\n\tfor ; bits < expBitlen && bits < 192; bits++ {\n\t\tif word&1 == 1 {\n\t\t\tz.Mul(z, base)\n\t\t}\n\t\tbase.Squared()\n\t\tword >>= 1\n\t}\n\n\tword = exponent[3]\n\tfor ; bits < expBitlen && bits < 256; bits++ {\n\t\tif word&1 == 1 {\n\t\t\tz.Mul(z, base)\n\t\t}\n\t\tbase.Squared()\n\t\tword >>= 1\n\t}\n\treturn z\n}", "func smallExp(z, x *inf.Dec, s inf.Scale) *inf.Dec {\n\t// Allocate if needed and make sure args aren't mutated.\n\tif z == nil {\n\t\tz = new(inf.Dec)\n\t\tz.SetUnscaled(1).SetScale(0)\n\t}\n\tn := new(inf.Dec)\n\ttmp := new(inf.Dec).Set(z)\n\tfor loop := newLoop(\"exp\", z, s, 1); !loop.done(z); {\n\t\tn.Add(n, decimalOne)\n\t\ttmp.Mul(tmp, x)\n\t\ttmp.QuoRound(tmp, n, s+2, inf.RoundHalfUp)\n\t\tz.Add(z, tmp)\n\t}\n\t// Round to the desired scale.\n\treturn z.Round(z, s, inf.RoundHalfUp)\n}", "func VDIVPS_RN_SAE_Z(z, z1, k, z2 operand.Op) { ctx.VDIVPS_RN_SAE_Z(z, z1, k, z2) }", "func VDIVPD_RN_SAE_Z(z, z1, k, z2 operand.Op) { ctx.VDIVPD_RN_SAE_Z(z, z1, k, z2) }", "func VDIVSS_RZ_SAE_Z(x, x1, k, x2 operand.Op) { ctx.VDIVSS_RZ_SAE_Z(x, x1, k, x2) }", "func (a Vec2) Div(b Vec2) Vec2 {\n\treturn Vec2{a.X / b.X, a.Y / b.Y}\n}", "func integerPower(z, x *inf.Dec, y int64, s inf.Scale) *inf.Dec {\n\tif z == nil {\n\t\tz = new(inf.Dec)\n\t}\n\n\tneg := y < 0\n\tif neg {\n\t\ty = -y\n\t}\n\n\tz.Set(decimalOne)\n\tfor y > 0 {\n\t\tif y%2 == 1 {\n\t\t\tz = z.Mul(z, x)\n\t\t}\n\t\ty >>= 1\n\t\tx.Mul(x, x)\n\n\t\t// integerPower is only ever called with `e` (decimalE), which is a constant\n\t\t// with very high precision. When it is squared above, the number of digits\n\t\t// needed to express it goes up quickly. If we are a large power of a small\n\t\t// number (like 0.5 ^ 5000), this loop becomes very slow because of the very\n\t\t// high number of digits it must compute. To prevent that, round x.\n\t\tx.Round(x, s*2, inf.RoundHalfUp)\n\t}\n\n\tif neg {\n\t\tz = z.QuoRound(decimalOne, z, s+2, inf.RoundHalfUp)\n\t}\n\treturn z.Round(z, s, inf.RoundHalfUp)\n}", "func DivZeroExp(exp string) bool {\n var index int = strings.Index(exp, \"/\")\n for index != -1 {\n var divisor string = exp[index+1:index+2]\n if divisor == \"(\" {\n divisor = exp[index+1:FindClosingParen(exp, index+1)+1]\n } else {\n var end int = index + 2\n for end < len(exp) && strings.Index(numbers, string(exp[end])) != -1 {\n end++\n }\n divisor = exp[index+1:end]\n }\n\n var result string = Pemdas(divisor)\n if result == \"Infinity\" || NotateToDouble(result) == 0 {\n return true\n }\n\n index = strings.Index(exp[index + 1:], \"/\")\n }\n\n return false\n}", "func (s VectOp) Exp() VectOp {\n\treturn fs.Exp(s)\n}", "func walkDivMod(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {\n\tn.X = walkExpr(n.X, init)\n\tn.Y = walkExpr(n.Y, init)\n\n\t// rewrite complex div into function call.\n\tet := n.X.Type().Kind()\n\n\tif types.IsComplex[et] && n.Op() == ir.ODIV {\n\t\tt := n.Type()\n\t\tcall := mkcall(\"complex128div\", types.Types[types.TCOMPLEX128], init, typecheck.Conv(n.X, types.Types[types.TCOMPLEX128]), typecheck.Conv(n.Y, types.Types[types.TCOMPLEX128]))\n\t\treturn typecheck.Conv(call, t)\n\t}\n\n\t// Nothing to do for float divisions.\n\tif types.IsFloat[et] {\n\t\treturn n\n\t}\n\n\t// rewrite 64-bit div and mod on 32-bit architectures.\n\t// TODO: Remove this code once we can introduce\n\t// runtime calls late in SSA processing.\n\tif types.RegSize < 8 && (et == types.TINT64 || et == types.TUINT64) {\n\t\tif n.Y.Op() == ir.OLITERAL {\n\t\t\t// Leave div/mod by constant powers of 2 or small 16-bit constants.\n\t\t\t// The SSA backend will handle those.\n\t\t\tswitch et {\n\t\t\tcase types.TINT64:\n\t\t\t\tc := ir.Int64Val(n.Y)\n\t\t\t\tif c < 0 {\n\t\t\t\t\tc = -c\n\t\t\t\t}\n\t\t\t\tif c != 0 && c&(c-1) == 0 {\n\t\t\t\t\treturn n\n\t\t\t\t}\n\t\t\tcase types.TUINT64:\n\t\t\t\tc := ir.Uint64Val(n.Y)\n\t\t\t\tif c < 1<<16 {\n\t\t\t\t\treturn n\n\t\t\t\t}\n\t\t\t\tif c != 0 && c&(c-1) == 0 {\n\t\t\t\t\treturn n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvar fn string\n\t\tif et == types.TINT64 {\n\t\t\tfn = \"int64\"\n\t\t} else {\n\t\t\tfn = \"uint64\"\n\t\t}\n\t\tif n.Op() == ir.ODIV {\n\t\t\tfn += \"div\"\n\t\t} else {\n\t\t\tfn += \"mod\"\n\t\t}\n\t\treturn mkcall(fn, n.Type(), init, typecheck.Conv(n.X, types.Types[et]), typecheck.Conv(n.Y, types.Types[et]))\n\t}\n\treturn n\n}", "func (o *IntrospectedOAuth2Token) SetExp(v int64) {\n\to.Exp = &v\n}", "func op_f64_div(expr *CXExpression, fp int) {\n\tinp1, inp2, out1 := expr.Inputs[0], expr.Inputs[1], expr.Outputs[0]\n\toutB1 := FromF64(ReadF64(fp, inp1) / ReadF64(fp, inp2))\n\tWriteMemory(GetFinalOffset(fp, out1), outB1)\n}", "func expneg(x *big.Int) *big.Int {\n\t// exp is approximated by rational function\n\t// polynomials of the rational function are evaluated using Horner's method\n\tnum := polyval(expNumCoef, x) // Q.256\n\tdeno := polyval(expDenoCoef, x) // Q.256\n\n\tnum = num.Lsh(num, precision) // Q.512\n\treturn num.Div(num, deno) // Q.512 / Q.256 => Q.256\n}", "func mathExpm1(ctx phpv.Context, args []*phpv.ZVal) (*phpv.ZVal, error) {\n\tvar x phpv.ZFloat\n\t_, err := core.Expand(ctx, args, &x)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn phpv.ZFloat(math.Expm1(float64(x))).ZVal(), nil\n}", "func (c *Context) VDIVPS_RZ_SAE_Z(z, z1, k, z2 operand.Op) {\n\tc.addinstruction(x86.VDIVPS_RZ_SAE_Z(z, z1, k, z2))\n}", "func VDIVSD_Z(mx, x, k, x1 operand.Op) { ctx.VDIVSD_Z(mx, x, k, x1) }", "func Div(x, y *Money) *Money {\n\tz := Money{}\n\treturn &z\n}", "func (v Posit8x4) Exp() []int8 {\n\tout := make([]int8, 4)\n\tfor i, posit := range v.impl {\n\t\tout[i] = posit.Exp()\n\t}\n\treturn out\n}", "func Pow(x, y float64) float64 {\n\t// TODO: x or y NaN, ±Inf, maybe ±0.\n\tswitch {\n\tcase y == 0:\n\t\treturn 1\n\tcase y == 1:\n\t\treturn x\n\tcase x == 0 && y > 0:\n\t\treturn 0\n\tcase x == 0 && y < 0:\n\t\treturn Inf(1)\n\tcase y == 0.5:\n\t\treturn Sqrt(x)\n\tcase y == -0.5:\n\t\treturn 1 / Sqrt(x)\n\t}\n\n\tabsy := y;\n\tflip := false;\n\tif absy < 0 {\n\t\tabsy = -absy;\n\t\tflip = true;\n\t}\n\tyi, yf := Modf(absy);\n\tif yf != 0 && x < 0 {\n\t\treturn NaN()\n\t}\n\tif yi >= 1<<63 {\n\t\treturn Exp(y * Log(x))\n\t}\n\n\t// ans = a1 * 2^ae (= 1 for now).\n\ta1 := float64(1);\n\tae := 0;\n\n\t// ans *= x^yf\n\tif yf != 0 {\n\t\tif yf > 0.5 {\n\t\t\tyf--;\n\t\t\tyi++;\n\t\t}\n\t\ta1 = Exp(yf * Log(x));\n\t}\n\n\t// ans *= x^yi\n\t// by multiplying in successive squarings\n\t// of x according to bits of yi.\n\t// accumulate powers of two into exp.\n\tx1, xe := Frexp(x);\n\tfor i := int64(yi); i != 0; i >>= 1 {\n\t\tif i&1 == 1 {\n\t\t\ta1 *= x1;\n\t\t\tae += xe;\n\t\t}\n\t\tx1 *= x1;\n\t\txe <<= 1;\n\t\tif x1 < .5 {\n\t\t\tx1 += x1;\n\t\t\txe--;\n\t\t}\n\t}\n\n\t// ans = a1*2^ae\n\t// if flip { ans = 1 / ans }\n\t// but in the opposite order\n\tif flip {\n\t\ta1 = 1 / a1;\n\t\tae = -ae;\n\t}\n\treturn Ldexp(a1, ae);\n}", "func (z *Float64) Divide(y *Float64, a float64) *Float64 {\n\tz.l = y.l / a\n\tz.r = y.r / a\n\treturn z\n}", "func Exp(a Int, e Int) Int {\n\treturn Int{big.NewInt(0).Exp(a.Int, e.Int, nil)}\n}", "func (c *Clac) Exp() error {\n\treturn c.applyFloat(1, func(vals []value.Value) (value.Value, error) {\n\t\treturn unary(\"**\", vals[0])\n\t})\n}", "func Exp(scope *Scope, x tf.Output) (y tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Exp\",\n\t\tInput: []tf.Input{\n\t\t\tx,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func (c *Context) VDIVPD_RZ_SAE_Z(z, z1, k, z2 operand.Op) {\n\tc.addinstruction(x86.VDIVPD_RZ_SAE_Z(z, z1, k, z2))\n}", "func floorPow2(v int) int {}", "func (ff FiniteField) Exp(elem1 float64, power int64) float64 {\n\tvar value float64 = 1\n\treducedExponent := mod(float64(power), float64(ff.order-1))\n\tfor i := int64(0); i < int64(reducedExponent); i++ {\n\t\tvalue = ff.Multiply(value, elem1)\n\t}\n\n\treturn ff.mod(value)\n}", "func (c Currency) Div(d Currency) Currency {\n\tf := (c.guardf * c.dpf * float64(c.m)) / float64(d.m) / c.guardf\n\ti := int64(f)\n\treturn c.Set(rnd(i, f-float64(i)))\n}", "func Div(x, y int) int {\n\treturn x / y\n}", "func (f Float) Exp() int {\n\t// 5 bit exponent: 0b0111110000000000\n\treturn int(f.bits & 0x7C00 >> 10)\n}", "func DIVPD(mx, x operand.Op) { ctx.DIVPD(mx, x) }", "func DIVPS(mx, x operand.Op) { ctx.DIVPS(mx, x) }", "func Div(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Div\",\n\t\tInput: []tf.Input{\n\t\t\tx, y,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func VDIVPD_RD_SAE_Z(z, z1, k, z2 operand.Op) { ctx.VDIVPD_RD_SAE_Z(z, z1, k, z2) }", "func ExpFloat64() float64 { return globalRand.ExpFloat64() }", "func ExpFloat64() float64 { return globalRand.ExpFloat64() }", "func lookup(z float64) (numStd float64) {\n\n\ta := math.Sqrt(1/z - 1)\n\tb := math.Sqrt(1/z + 1)\n\tres := math.Log(a*b+(1/z)) / 2.0\n\n\treturn res\n}", "func (c *Context) VDIVPD_Z(mxyz, xyz, k, xyz1 operand.Op) {\n\tc.addinstruction(x86.VDIVPD_Z(mxyz, xyz, k, xyz1))\n}", "func (group *QRRSA) Exp(base, exponent *big.Int) *big.Int {\n\texpAbs := new(big.Int).Abs(exponent)\n\tif expAbs.Cmp(exponent) == 0 {\n\t\treturn new(big.Int).Exp(base, exponent, group.N)\n\t} else {\n\t\tt := new(big.Int).Exp(base, expAbs, group.N)\n\t\treturn group.Inv(t)\n\t}\n}", "func Exp(x, y, m *big.Int) *big.Int {\n\treturn new(big.Int).Exp(x, y, m)\n}", "func SqrtZ(x, z float64) float64 {\n\treturn z - (math.Pow(z, 2)-x)/(2*z)\n}", "func (e *Engine) exp(c, a *fe12) {\n\tc.set(a)\n\te.fp12.cyclotomicSquare(c) // (a ^ 2)\n\n\t// (a ^ (2 + 1)) ^ (2 ^ 2) = a ^ 12\n\te.fp12.mulAssign(c, a)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\n\t// (a ^ (12 + 1)) ^ (2 ^ 3) = a ^ 104\n\te.fp12.mulAssign(c, a)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\n\t// (a ^ (104 + 1)) ^ (2 ^ 9) = a ^ 53760\n\te.fp12.mulAssign(c, a)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\te.fp12.cyclotomicSquare(c)\n\t// (a ^ (53760 + 1)) ^ (2 ^ 32) = a ^ 230901736800256\n\te.fp12.mulAssign(c, a)\n\tfor i := 0; i < 32; i++ {\n\t\te.fp12.cyclotomicSquare(c)\n\t}\n\n\t// (a ^ (230901736800256 + 1)) ^ (2 ^ 16) = a ^ 15132376222941642752\n\te.fp12.mulAssign(c, a)\n\tfor i := 0; i < 16; i++ {\n\t\te.fp12.cyclotomicSquare(c)\n\t}\n\t// invert chain result since x is negative\n\tfp12Conjugate(c, c)\n}", "func VDIVSS_RU_SAE_Z(x, x1, k, x2 operand.Op) { ctx.VDIVSS_RU_SAE_Z(x, x1, k, x2) }", "func VDIVPS_RD_SAE_Z(z, z1, k, z2 operand.Op) { ctx.VDIVPS_RD_SAE_Z(z, z1, k, z2) }", "func (p Poly64) Div(p2 Poly64) (q, r Poly64) {\n\tif p2 == 0 {\n\t\tpanic(\"division by zero\")\n\t}\n\n\tq = 0\n\tr = p\n\tlog2p2 := ilog2(uint64(p2))\n\tfor r != 0 {\n\t\tlog2r := ilog2(uint64(r))\n\t\tif log2r < log2p2 {\n\t\t\tbreak\n\t\t}\n\t\tdlog2 := log2r - log2p2\n\t\tq ^= (1 << dlog2)\n\t\tr ^= (p2 << dlog2)\n\t}\n\n\treturn q, r\n}", "func (c *Context) VEXTRACTF64X2_Z(i, yz, k, mx operand.Op) {\n\tc.addinstruction(x86.VEXTRACTF64X2_Z(i, yz, k, mx))\n}", "func div(x, y int) (answer int, err error) {\n\tif y == 0 {\n\t\terr = fmt.Errorf(\"Cannot Divid by zero\")\n\t} else {\n\t\tanswer = x / y\n\t}\n\treturn\n}", "func VDIVSD_RZ_SAE_Z(x, x1, k, x2 operand.Op) { ctx.VDIVSD_RZ_SAE_Z(x, x1, k, x2) }", "func (c *Context) VDIVSS_RZ_SAE_Z(x, x1, k, x2 operand.Op) {\n\tc.addinstruction(x86.VDIVSS_RZ_SAE_Z(x, x1, k, x2))\n}", "func DivUpPow2(dividend, divisor int, log2Divisor uint) int {\n\treturn (dividend + divisor - 1) >> log2Divisor\n}", "func (f1 Frac) Div(f2 Frac) Frac {\n\treturn f1.Mul(f2.Reciprocal())\n}", "func (z *Int) Sdiv(n, d *Int) *Int {\n\tif n.Sign() > 0 {\n\t\tif d.Sign() > 0 {\n\t\t\t// pos / pos\n\t\t\tz.Div(n, d)\n\t\t\treturn z\n\t\t} else {\n\t\t\t// pos / neg\n\t\t\tz.Div(n, d.Neg())\n\t\t\treturn z.Neg()\n\t\t}\n\t}\n\n\tif d.Sign() < 0 {\n\t\t// neg / neg\n\t\tz.Div(n.Neg(), d.Neg())\n\t\treturn z\n\t}\n\t// neg / pos\n\tz.Div(n.Neg(), d)\n\treturn z.Neg()\n}", "func (c *Context) VDIVPS_RU_SAE_Z(z, z1, k, z2 operand.Op) {\n\tc.addinstruction(x86.VDIVPS_RU_SAE_Z(z, z1, k, z2))\n}", "func (c *Clac) Pow2() error {\n\treturn c.applyFloat(1, func(vals []value.Value) (value.Value, error) {\n\t\treturn binary(value.Int(2), \"**\", vals[0])\n\t})\n}" ]
[ "0.6256803", "0.6164883", "0.60691875", "0.5726555", "0.56809974", "0.565142", "0.56230205", "0.5584276", "0.5552816", "0.5491405", "0.5465571", "0.54105353", "0.54019284", "0.53735286", "0.5363632", "0.53507364", "0.5349359", "0.5349359", "0.532853", "0.53251326", "0.52956903", "0.5292718", "0.5285282", "0.5240964", "0.52374", "0.52267677", "0.5210989", "0.5195186", "0.51849663", "0.51722455", "0.5165817", "0.51642543", "0.51362044", "0.5125648", "0.51208615", "0.51050556", "0.5104102", "0.5079112", "0.5059167", "0.5057933", "0.50494564", "0.5047318", "0.50458103", "0.50432163", "0.50355446", "0.50315017", "0.50128025", "0.500294", "0.49855658", "0.49722937", "0.49566826", "0.492816", "0.49243072", "0.49215895", "0.49207783", "0.49163893", "0.49140358", "0.49138156", "0.49016806", "0.48886156", "0.4880378", "0.4857867", "0.4855352", "0.48513648", "0.48480803", "0.48254678", "0.4822846", "0.48193312", "0.48176557", "0.48174977", "0.4811037", "0.48102382", "0.48101756", "0.4794985", "0.4784453", "0.4767256", "0.4753748", "0.4751895", "0.47387984", "0.47385147", "0.47384343", "0.47384343", "0.47369522", "0.47366533", "0.47322157", "0.47296518", "0.4722188", "0.4715957", "0.4713822", "0.47108176", "0.47034687", "0.4702267", "0.47009727", "0.4700121", "0.4696775", "0.46886745", "0.46796355", "0.46777448", "0.46776974", "0.4674885" ]
0.7626231
0
Sets f = Ceil(x) and returns f.
Устанавливает f = Ceil(x) и возвращает f.
func (f *Float) Ceil(x *Float) *Float { x.doinit() f.doinit() C.mpf_ceil(&f.i[0], &x.i[0]) return f }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Ceil(x float64) float64 {\n\n\treturn math.Ceil(x)\n}", "func Ceil(arg float64) float64 {\n\treturn math.Ceil(arg)\n}", "func Ceil(scope *Scope, x tf.Output) (y tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Ceil\",\n\t\tInput: []tf.Input{\n\t\t\tx,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func (c *Clac) Ceil() error {\n\treturn c.applyFloat(1, func(vals []value.Value) (value.Value, error) {\n\t\treturn unary(\"ceil\", vals[0])\n\t})\n}", "func Ceil(value gcv.Value) (gcv.Value, error) {\n\tif value.Type() == gcv.Complex {\n\t\treturn nil, errors.New(\"Ceil is not supported for Complex numbers\")\n\t}\n\treturn gcv.MakeValue(math.Ceil(value.Real())), nil\n}", "func Ceil(t1 TermT) TermT {\n\treturn TermT(C.yices_ceil(C.term_t(t1)))\n}", "func (i *Number) Ceil(precision Number) *Number {\n\tif precision.IsBelow(*NewNumber(1)) {\n\t\treturn NewNumber(math.Ceil(i.AsFloat64()))\n\t}\n\tbuf := bytes.NewBuffer([]byte{})\n\tbuf.WriteString(\"1\")\n\tfor i := 0; i < precision.AsInt(); i++ {\n\t\tbuf.WriteString(\"0\")\n\t}\n\tfactor := NewNumber(buf.String())\n\tconverted := i.Multiply(*factor)\n\tceiling := NewNumber(math.Ceil(converted.AsFloat64()))\n\treturn ceiling.Divide(*factor)\n}", "func Ceil(numerator, denominator int) int {\n\tif numerator%denominator == 0 {\n\t\treturn numerator / denominator\n\t}\n\treturn (numerator / denominator) + 1\n}", "func Ceil(r *Rectangle) *Rectangle {\n\tr.X = math.Ceil(r.X)\n\tr.Y = math.Ceil(r.Y)\n\n\treturn r\n}", "func (d Decimal) Ceil() Decimal {\n\td.ensureInitialized()\n\n\tif d.exp >= 0 {\n\t\treturn d\n\t}\n\n\texp := big.NewInt(10)\n\n\t// NOTE(vadim): must negate after casting to prevent int32 overflow\n\texp.Exp(exp, big.NewInt(-int64(d.exp)), nil)\n\n\tz, m := new(big.Int).DivMod(d.value, exp, new(big.Int))\n\tif m.Cmp(zeroInt) != 0 {\n\t\tz.Add(z, oneInt)\n\t}\n\treturn Decimal{value: z, exp: 0}\n}", "func (d Decimal) Ceil() Decimal {\n\td.ensureInitialized()\n\n\tif d.exp >= 0 {\n\t\treturn d\n\t}\n\n\texp := big.NewInt(10)\n\n\t// NOTE(vadim): must negate after casting to prevent int32 overflow\n\texp.Exp(exp, big.NewInt(-int64(d.exp)), nil)\n\n\tz, m := new(big.Int).DivMod(d.value, exp, new(big.Int))\n\tif m.Cmp(zeroInt) != 0 {\n\t\tz.Add(z, oneInt)\n\t}\n\treturn Decimal{value: z, exp: 0}\n}", "func (gdt *Vector3) Ceil() Vector3 {\n\targ0 := gdt.getBase()\n\n\tret := C.go_godot_vector3_ceil(GDNative.api, arg0)\n\n\treturn Vector3{base: &ret}\n\n}", "func (self *State)Ceil(a any)any{\n self.IncOperations(self.coeff[\"ceil\"]+self.off[\"ceil\"])\n return wrap1(a,math.Ceil)\n}", "func CeilP(x float64, p int) float64 {\n\tk := math.Pow10(p)\n\treturn math.Ceil(x*k) / k\n}", "func funcCeil(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector {\n\treturn simpleFunc(vals, enh, math.Ceil)\n}", "func (fn *formulaFuncs) CEILING(argsList *list.List) formulaArg {\n\tif argsList.Len() == 0 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"CEILING requires at least 1 argument\")\n\t}\n\tif argsList.Len() > 2 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"CEILING allows at most 2 arguments\")\n\t}\n\tnumber, significance, res := 0.0, 1.0, 0.0\n\tn := argsList.Front().Value.(formulaArg).ToNumber()\n\tif n.Type == ArgError {\n\t\treturn n\n\t}\n\tnumber = n.Number\n\tif number < 0 {\n\t\tsignificance = -1\n\t}\n\tif argsList.Len() > 1 {\n\t\ts := argsList.Back().Value.(formulaArg).ToNumber()\n\t\tif s.Type == ArgError {\n\t\t\treturn s\n\t\t}\n\t\tsignificance = s.Number\n\t}\n\tif significance < 0 && number > 0 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"negative sig to CEILING invalid\")\n\t}\n\tif argsList.Len() == 1 {\n\t\treturn newNumberFormulaArg(math.Ceil(number))\n\t}\n\tnumber, res = math.Modf(number / significance)\n\tif res > 0 {\n\t\tnumber++\n\t}\n\treturn newNumberFormulaArg(number * significance)\n}", "func (d LegacyDec) Ceil() LegacyDec {\n\ttmp := new(big.Int).Set(d.i)\n\n\tquo, rem := tmp, big.NewInt(0)\n\tquo, rem = quo.QuoRem(tmp, precisionReuse, rem)\n\n\t// no need to round with a zero remainder regardless of sign\n\tif rem.Cmp(zeroInt) == 0 {\n\t\treturn LegacyNewDecFromBigInt(quo)\n\t}\n\n\tif rem.Sign() == -1 {\n\t\treturn LegacyNewDecFromBigInt(quo)\n\t}\n\n\treturn LegacyNewDecFromBigInt(quo.Add(quo, oneInt))\n}", "func MustCeil(value gcv.Value) gcv.Value {\n\tval, err := Ceil(value)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val\n}", "func CeilDiv(n, divisor int) int {\n\treturn int(math.Ceil(float64(n) / float64(divisor)))\n}", "func (fn *formulaFuncs) ISOdotCEILING(argsList *list.List) formulaArg {\n\tif argsList.Len() == 0 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"ISO.CEILING requires at least 1 argument\")\n\t}\n\tif argsList.Len() > 2 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"ISO.CEILING allows at most 2 arguments\")\n\t}\n\tvar significance float64\n\tnumber := argsList.Front().Value.(formulaArg).ToNumber()\n\tif number.Type == ArgError {\n\t\treturn number\n\t}\n\tif number.Number < 0 {\n\t\tsignificance = -1\n\t}\n\tif argsList.Len() == 1 {\n\t\treturn newNumberFormulaArg(math.Ceil(number.Number))\n\t}\n\tif argsList.Len() > 1 {\n\t\ts := argsList.Back().Value.(formulaArg).ToNumber()\n\t\tif s.Type == ArgError {\n\t\t\treturn s\n\t\t}\n\t\tsignificance = s.Number\n\t\tsignificance = math.Abs(significance)\n\t\tif significance == 0 {\n\t\t\treturn newNumberFormulaArg(significance)\n\t\t}\n\t}\n\tval, res := math.Modf(number.Number / significance)\n\tif res != 0 {\n\t\tif number.Number > 0 {\n\t\t\tval++\n\t\t}\n\t}\n\treturn newNumberFormulaArg(val * significance)\n}", "func Ceil32(x float32) float32 {\n\treturn float32(math.Ceil(float64(x)))\n}", "func (d Decimal) RoundCeil(places int32) Decimal {\n\tif d.exp >= -places {\n\t\treturn d\n\t}\n\n\trescaled := d.rescale(-places)\n\tif d.Equal(rescaled) {\n\t\treturn d\n\t}\n\n\tif d.value.Sign() > 0 {\n\t\trescaled.value.Add(rescaled.value, oneInt)\n\t}\n\n\treturn rescaled\n}", "func CeilDiv(a, b int) int {\n\treturn (a + b - 1) / b\n}", "func (fn *formulaFuncs) CEILINGdotPRECISE(argsList *list.List) formulaArg {\n\tif argsList.Len() == 0 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"CEILING.PRECISE requires at least 1 argument\")\n\t}\n\tif argsList.Len() > 2 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"CEILING.PRECISE allows at most 2 arguments\")\n\t}\n\tnumber, significance := 0.0, 1.0\n\tn := argsList.Front().Value.(formulaArg).ToNumber()\n\tif n.Type == ArgError {\n\t\treturn n\n\t}\n\tnumber = n.Number\n\tif number < 0 {\n\t\tsignificance = -1\n\t}\n\tif argsList.Len() == 1 {\n\t\treturn newNumberFormulaArg(math.Ceil(number))\n\t}\n\tif argsList.Len() > 1 {\n\t\ts := argsList.Back().Value.(formulaArg).ToNumber()\n\t\tif s.Type == ArgError {\n\t\t\treturn s\n\t\t}\n\t\tsignificance = s.Number\n\t\tsignificance = math.Abs(significance)\n\t\tif significance == 0 {\n\t\t\treturn newNumberFormulaArg(significance)\n\t\t}\n\t}\n\tval, res := math.Modf(number / significance)\n\tif res != 0 {\n\t\tif number > 0 {\n\t\t\tval++\n\t\t}\n\t}\n\treturn newNumberFormulaArg(val * significance)\n}", "func Floor(x float64) float64 {\n\n\treturn math.Floor(x)\n}", "func (f *Float) Floor(x *Float) *Float {\n\tx.doinit()\n\tf.doinit()\n\tC.mpf_floor(&f.i[0], &x.i[0])\n\treturn f\n}", "func wrap(x, bound float64) float64 {\n\tif x >= 0 && x < bound {\n\t\treturn x\n\t}\n\tif x = math.Mod(x, bound); x < 0 {\n\t\treturn bound + x\n\t}\n\treturn x\n}", "func (fn *formulaFuncs) CEILINGdotMATH(argsList *list.List) formulaArg {\n\tif argsList.Len() == 0 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"CEILING.MATH requires at least 1 argument\")\n\t}\n\tif argsList.Len() > 3 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"CEILING.MATH allows at most 3 arguments\")\n\t}\n\tnumber, significance, mode := 0.0, 1.0, 1.0\n\tn := argsList.Front().Value.(formulaArg).ToNumber()\n\tif n.Type == ArgError {\n\t\treturn n\n\t}\n\tnumber = n.Number\n\tif number < 0 {\n\t\tsignificance = -1\n\t}\n\tif argsList.Len() > 1 {\n\t\ts := argsList.Front().Next().Value.(formulaArg).ToNumber()\n\t\tif s.Type == ArgError {\n\t\t\treturn s\n\t\t}\n\t\tsignificance = s.Number\n\t}\n\tif argsList.Len() == 1 {\n\t\treturn newNumberFormulaArg(math.Ceil(number))\n\t}\n\tif argsList.Len() > 2 {\n\t\tm := argsList.Back().Value.(formulaArg).ToNumber()\n\t\tif m.Type == ArgError {\n\t\t\treturn m\n\t\t}\n\t\tmode = m.Number\n\t}\n\tval, res := math.Modf(number / significance)\n\tif res != 0 {\n\t\tif number > 0 {\n\t\t\tval++\n\t\t} else if mode < 0 {\n\t\t\tval--\n\t\t}\n\t}\n\treturn newNumberFormulaArg(val * significance)\n}", "func (tree *Tree) Ceiling(key interface{}) (ceiling *Node, found bool) {\n\tfound = false\n\tnode := tree.Root\n\tfor node != nil {\n\t\tcompare := tree.Comparator(key, node.Key)\n\t\tswitch {\n\t\tcase compare == 0:\n\t\t\treturn node, true\n\t\tcase compare < 0:\n\t\t\tceiling, found = node, true\n\t\t\tnode = node.Left\n\t\tcase compare > 0:\n\t\t\tnode = node.Right\n\t\t}\n\t}\n\tif found {\n\t\treturn ceiling, true\n\t}\n\treturn nil, false\n}", "func Floor(arg float64) float64 {\n\treturn math.Floor(arg)\n}", "func Round(f float64) float64 {\n\tif f > 0 {\n\t\treturn math.Floor(f + 0.5)\n\t}\n\treturn math.Ceil(f - 0.5)\n}", "func Clamp(fValue, fMinValue, fMaxValue gl.Float) gl.Float {\n\tif fValue < fMinValue {\n\t\treturn fMinValue\n\t} else if fValue > fMaxValue {\n\t\treturn fMaxValue\n\t} else {\n\t\treturn fValue\n\t}\n}", "func (t *binarySearchST) Ceiling(key interface{}) interface{} {\n\tutils.AssertF(key != nil, \"Key is nil\")\n\ti := t.Rank(key)\n\tif i == t.n { // any key in table less than key\n\t\treturn nil\n\t}\n\treturn t.keys[i]\n}", "func (self *Rectangle) Ceil() {\n self.Object.Call(\"ceil\")\n}", "func Clamp(x, min, max float64) float64 {\n\tif x < min {\n\t\treturn min\n\t}\n\tif x > max {\n\t\treturn max\n\t}\n\treturn x\n}", "func Clamp(x, min, max float64) float64 {\n\tif x < min {\n\t\treturn min\n\t}\n\tif x > max {\n\t\treturn max\n\t}\n\treturn x\n}", "func Clamp(x, a, b float64) float64 {\n\tif x < a {\n\t\treturn a\n\t}\n\tif x > b {\n\t\treturn b\n\t}\n\treturn x\n}", "func Round(x float64) float64 {\n\n\treturn math.Floor(x + 0.5)\n}", "func (c *Clac) Floor() error {\n\treturn c.applyFloat(1, func(vals []value.Value) (value.Value, error) {\n\t\treturn unary(\"floor\", vals[0])\n\t})\n}", "func (self *Rectangle) CeilI(args ...interface{}) {\n self.Object.Call(\"ceil\", args)\n}", "func Round(x float64) float64 {\n\treturn math.Floor(x + 0.5)\n}", "func (dt DateTime) CeilMonth() DateTime {\n\ttempDateTime := dt.Copy()\n\ttempDateTime = tempDateTime.ShiftMonths(1)\n\ttempDateTime = tempDateTime.ReplaceDay(1)\n\ttempDateTime = tempDateTime.ShiftDays(-1)\n\treturn dt.Replace(dt.Year(), dt.Month(), tempDateTime.Day(), 23, 59, 59, 999999999)\n}", "func (dt DateTime) CeilDay() DateTime {\n\treturn dt.Replace(dt.Year(), dt.Month(), dt.Day(), 23, 59, 59, 999999999)\n}", "func Floor(x float64, unit float64) float64 {\n\tif IsZero(unit) {\n\t\treturn x\n\t}\n\n\tunits := int64((x + unit*e) / unit)\n\treturn float64(units) * unit\n}", "func (dt DateTime) CeilWeek() DateTime {\n\tcurrentWeekDay := int(dt.WeekDay())\n\tif currentWeekDay == 0 {\n\t\treturn dt.CeilDay()\n\t}\n\n\treturn dt.ShiftDays(WeekInDays - currentWeekDay).CeilDay()\n}", "func (t *RedBlackTree) Ceiling(key interface{}) (ceiling *Node) {\n\tfor node := t.root; node != nil; {\n\t\tswitch t.comparator(key, node.key) {\n\t\tcase 0:\n\t\t\tceiling = node\n\t\t\treturn\n\t\tcase -1:\n\t\t\tceiling = node\n\t\t\tnode = node.left\n\t\tcase 1:\n\t\t\tnode = node.right\n\t\t}\n\t}\n\n\treturn\n}", "func FloatIsInf(x *big.Float,) bool", "func pow(x, n, lim float64) float64 {\n if v := math.Pow(x, n); v < lim {\n return v\n }\n return lim\n}", "func clamp(x float64) float64 {\n\tif x > 1 {\n\t\treturn 1\n\t}\n\treturn x\n}", "func Sqrt(x float64) float64 {\n z := 1.0;\n for i := 0; i < 10; i++ {\n fmt.Println(z)\n z -= (z*z - x) / (2*z)\n }\n return z\n}", "func (self *Rectangle) CeilAll() {\n self.Object.Call(\"ceilAll\")\n}", "func round(f float64) int {\n\tif f < 0 {\n\t\treturn int(math.Ceil(f - 0.5))\n\t}\n\treturn int(math.Floor(f + 0.5))\n}", "func Clamp(v Vect, l f.Float) Vect {\n\tif Dot(v, v) > l*l {\n\t\treturn Mult(Normalize(v), l)\n\t}\n\treturn v\n}", "func Trunc(val value.Value) (value.Value, error) {\n\te := &eval{}\n\tif isTrue(e.binary(val, \">=\", zero)) {\n\t\tval = e.unary(\"floor\", val)\n\t} else {\n\t\tval = e.unary(\"ceil\", val)\n\t}\n\treturn val, e.err\n}", "func (dt DateTime) CeilSecond() DateTime {\n\treturn dt.Replace(dt.Year(), dt.Month(), dt.Day(), dt.Hour(), dt.Minute(), dt.Second(), 999999999)\n}", "func round(x float64) float64 {\n\tt := math.Trunc(x)\n\tif math.Abs(x-t) >= 0.5 {\n\t\treturn t + math.Copysign(1, x)\n\t}\n\treturn t\n}", "func (h *BSTHandler) CeilTraversal() {\n\n}", "func TruncateFloat(f float64, flen int, decimal int) (float64, error) {\n\tif math.IsNaN(f) {\n\t\t// nan returns 0\n\t\treturn 0, nil\n\t}\n\n\tmaxF := getMaxFloat(flen, decimal)\n\n\tif !math.IsInf(f, 0) {\n\t\tf = truncateFloat(f, decimal)\n\t}\n\n\tif f > maxF {\n\t\tf = maxF\n\t} else if f < -maxF {\n\t\tf = -maxF\n\t}\n\n\treturn f, nil\n}", "func (dt DateTime) CeilYear() DateTime {\n\treturn dt.Replace(dt.Year(), 12, 31, 23, 59, 59, 999999999)\n}", "func Float64(n, min, max float64) float64 {\n\tif n < min {\n\t\tn = min\n\t} else if n > max {\n\t\tn = max\n\t}\n\treturn n\n}", "func Round(input float64) float64 {\n\tif input < 0 {\n\t\treturn math.Ceil(input - 0.5)\n\t}\n\treturn math.Floor(input + 0.5)\n}", "func ClampFloat64(val float64, min float64, max float64) float64 {\n\tif val <= min {\n\t\treturn min\n\t}\n\tif val >= max {\n\t\treturn max\n\t}\n\treturn val\n}", "func Sqrt(x float64) float64 {\n\tz:=45.0\n\tfor ; z*z-x>0.0000001;{\n\t\tz -= (z*z - x) / (2*z)\n\t\tfmt.Println(z)\n\t}\n\treturn z\n}", "func Clamp(val, low, high float64) float64 {\n\tif val < low {\n\t\treturn low\n\t}\n\n\tif val > high {\n\t\treturn high\n\t}\n\n\treturn val\n}", "func (f *Float) Trunc(x *Float) *Float {\n\tx.doinit()\n\tf.doinit()\n\tC.mpf_trunc(&f.i[0], &x.i[0])\n\treturn f\n}", "func newton(f []int, f_length int, x, xtol, ftol float64, itermax int) float64{\n fx := feval(f, f_length, x)\n var df = deriv(f, f_length);\n var root float64\n var fdx float64;\n var d float64;\n if abs(fx) <= ftol {\n root = x\n } else{\n for i := 1; i < itermax; i++ {\n fdx = feval(df, f_length-1, x)\n d = float64(fx)/fdx;\n x = x - d\n fx = feval(f, f_length, x)\n if (abs(d) <= xtol) || (abs(fx) <= ftol) {\n root = x\n break\n }\n }\n }\n return root\n}", "func roundFloat(x float64, prec int) float64 {\n\tvar rounder float64\n\tpow := math.Pow(10, float64(prec))\n\tintermed := x * pow\n\t_, frac := math.Modf(intermed)\n\tx = .5\n\tif frac < 0.0 {\n\t\tx = -.5\n\t}\n\tif frac >= x {\n\t\trounder = math.Ceil(intermed)\n\t} else {\n\t\trounder = math.Floor(intermed)\n\t}\n\n\treturn rounder / pow\n}", "func ClampFloat64(e, lower, upper float64) (float64, error) {\n\tif lower > upper {\n\t\treturn 0, fmt.Errorf(\"lower must be less than or equal to upper, got lower = %v, upper = %v\", lower, upper)\n\t}\n\n\tif e > upper {\n\t\treturn upper, nil\n\t}\n\tif e < lower {\n\t\treturn lower, nil\n\t}\n\treturn e, nil\n}", "func surge(x float64) float64 {\n\treturn x/2.0 - math.Sin(math.Pi*x)/(2*math.Pi)\n}", "func (p *Vect) Clamp(l f.Float) {\n\tif Dot(*p, *p) > l*l {\n\t\tp.Normalize()\n\t\tp.Mult(l)\n\t}\n}", "func IsFinite(arg float64, ch int) bool {\n\treturn !math.IsInf(arg, ch)\n}", "func Floor(scope *Scope, x tf.Output) (y tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Floor\",\n\t\tInput: []tf.Input{\n\t\t\tx,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func Sqrt_Ten(x float64) float64 {\n\tz := 1.0\n\n\tfor i := 0; i < 10; i += 1 {\n\t\tz -= ((z * z) - x) / (2 * z)\n\t}\n\n\treturn z\n}", "func Sqrt(x float64) float64 {\n\tz, d := 1.0, 1.0\n\tfor math.Abs(d) > 1e-15 {\n\t\tzPrevious := z\n\t\tz = z - ((z*z - x) / (2 * z))\n\t\td = zPrevious - z\n\t\tfmt.Printf(\"Current delta: %v, z: %v, zPrevious: %v\\n\", d, z, zPrevious)\n\t}\n\treturn z\n}", "func factorial( x int64 ) int64 {\n\n\tif x == 0 {\n\t\treturn 1;\n\t}\n\tif x < 0 {\n\t\treturn -1;\n\t}\n\n\tvar product int64 = 1;\n\tvar i int64;\n\tfor i = 1; i <= x; i++ {\n\t\tproduct *= i;\n\t}\n\n\treturn product;\n}", "func (fn *formulaFuncs) FLOOR(argsList *list.List) formulaArg {\n\tif argsList.Len() != 2 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"FLOOR requires 2 numeric arguments\")\n\t}\n\tnumber := argsList.Front().Value.(formulaArg).ToNumber()\n\tif number.Type == ArgError {\n\t\treturn number\n\t}\n\tsignificance := argsList.Back().Value.(formulaArg).ToNumber()\n\tif significance.Type == ArgError {\n\t\treturn significance\n\t}\n\tif significance.Number < 0 && number.Number >= 0 {\n\t\treturn newErrorFormulaArg(formulaErrorNUM, \"invalid arguments to FLOOR\")\n\t}\n\tval := number.Number\n\tval, res := math.Modf(val / significance.Number)\n\tif res != 0 {\n\t\tif number.Number < 0 && res < 0 {\n\t\t\tval--\n\t\t}\n\t}\n\treturn newStringFormulaArg(strings.ToUpper(fmt.Sprintf(\"%g\", val*significance.Number)))\n}", "func funcFloor(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector {\n\treturn simpleFunc(vals, enh, math.Floor)\n}", "func FloatMinPrec(x *big.Float,) uint", "func FToC(f Fahrenheit) Celsius { return Celsius((f - 32.0) * 5.0 / 9.0) }", "func (g GumbelRight) CDF(x float64) float64 {\n\tz := g.z(x)\n\treturn math.Exp(-math.Exp(-z))\n}", "func FinitePrec(x *big.Rat) int {\n\tif !Finite(x) {\n\t\tpanic(fmt.Errorf(\"rounding.FinitePrec: called with non-finite value: %v\", x))\n\t}\n\t// calling x.Denom() can modify x (populates b) so be extra careful\n\txx := new(big.Rat).Set(x)\n\n\td := xx.Denom()\n\tn := xx.Num()\n\tm := new(big.Int)\n\n\tvar i int\n\tfor m.Mod(n, d).Sign() != 0 {\n\t\ti++\n\t\tn.Mul(n, big10)\n\t}\n\treturn i\n}", "func (g *Graph) CeLU(x Node, alpha Node) Node {\n\treturn g.NewOperator(fn.NewCeLU(x, alpha), x, alpha)\n}", "func TestDivCeil(t *testing.T) {\n\tif res, _ := divCeil(new(big.Int).SetInt64(15), new(big.Int).SetInt64(4)); res.Cmp(new(big.Int).SetInt64(4)) != 0 {\n\t\tt.Errorf(\"Error when doing divCeil(15,4), it gave: %s\", res.Text(10))\n\t}\n\tif res, _ := divCeil(new(big.Int).SetInt64(13), new(big.Int).SetInt64(4)); res.Cmp(new(big.Int).SetInt64(4)) != 0 {\n\t\tt.Errorf(\"Error when doing divCeil(13,4), it gave: %s\", res.Text(10))\n\t}\n\tif res, _ := divCeil(new(big.Int).SetInt64(-15), new(big.Int).SetInt64(4)); res.Cmp(new(big.Int).SetInt64(-3)) != 0 {\n\t\tt.Errorf(\"Error when doing divCeil(-15,4), it gave: %s\", res.Text(10))\n\t}\n\tif res, _ := divCeil(new(big.Int).SetInt64(15), new(big.Int).SetInt64(5)); res.Cmp(new(big.Int).SetInt64(3)) != 0 {\n\t\tt.Errorf(\"Error when doing divCeil(15,5), it gave: %s\", res.Text(10))\n\t}\n\tif res, _ := divCeil(new(big.Int).SetInt64(0), new(big.Int).SetInt64(5)); res.Cmp(new(big.Int).SetInt64(0)) != 0 {\n\t\tt.Errorf(\"Error when doing divCeil(0,5), it gave: %s\", res.Text(10))\n\t}\n\tif _, err := divCeil(new(big.Int).SetInt64(15), new(big.Int).SetInt64(0)); err.Error() != \"Division by zero\" {\n\t\tt.Errorf(\"Error when doing divCeil(15,0), it didn't gave the correct error: %v\", err)\n\t}\n}", "func FToC(f Fahrenheit) Celsius { return Celsius((f - 32) * 5 / 9) }", "func FToC(f Fahrenheit) Celsius { return Celsius((f - 32) * 5 / 9) }", "func FToC(f Fahrenheit) Celsius { return Celsius((f - 32) * 5 / 9) }", "func FToC(f Fahrenheit) Celsius { return Celsius((f - 32) * 5 / 9) }", "func FToC(f Fahrenheit) Celsius { return Celsius((f - 32) * 5 / 9) }", "func FToC(f Fahrenheit) Celsius { return Celsius((f - 32) * 5 / 9) }", "func FToC(f Fahrenheit) Celsius { return Celsius((f - 32) * 5 / 9) }", "func FToC(f Fahrenheit) Celsius { return Celsius((f - 32) * 5 / 9) }", "func round(value float64) float64 {\n\treturn math.Floor(value + .5)\n}", "func (f Float64) Filter(c func(float64) bool) Float64 {\n\tif c == nil || !f.IsPresent() || !c(f.value) {\n\t\treturn Float64{}\n\t}\n\treturn f\n}", "func FToC(f Farenheit) Celsius { return Celsius((f - 32) * 5 / 9) }", "func f(x int) {\n\tfmt.Printf(\"f(%d)\\n\", x+0/x) // panics if x == 0\n\tdefer fmt.Printf(\"defer %d\\n\", x)\n\tf(x - 1)\n}", "func pow2(x, n, lim float64) float64 {\n if v := math.Pow(x, n); v < lim {\n return v\n } else {\n fmt.Printf(\"%g >= %g\\n\", v, lim)\n }\n // can't use v here, though\n return lim\n}", "func fritsch(w, x float64) float64 {\n\tz := math.Log(x/w) - w\n\tw1 := w + 1\n\tq := 2 * w1 * (w1 + 2*z/3)\n\teps := z / w1 * (q - z) / (q - 2*z)\n\treturn w * (1 + eps)\n}", "func (adapter *LevelAdapter) CeilingEffect() (radiation bool, level int) {\n\tlevel = -1\n\tif properties := adapter.properties(); properties != nil {\n\t\tradiation = *properties.CeilingHasRadiation\n\t\tlevel = *properties.CeilingEffectLevel\n\t}\n\treturn\n}", "func (x *Float) IsInf() bool {}", "func clampval(x float32) float32 {\n\tif math.Abs(float64(x)) < 0.01 {\n\t\treturn 0.0\n\t}\n\n\tif x < -0.99 {\n\t\treturn -1.0\n\t} else if x > 0.99 {\n\t\treturn 1.0\n\t}\n\treturn x\n}" ]
[ "0.8501541", "0.8011263", "0.769773", "0.74975675", "0.71446115", "0.70501745", "0.69955975", "0.6909984", "0.6885982", "0.6835996", "0.6835996", "0.68304205", "0.673312", "0.6672578", "0.64298874", "0.6390639", "0.63456494", "0.61852944", "0.61362666", "0.61188453", "0.6066074", "0.6052603", "0.6008763", "0.57202566", "0.56705314", "0.55679524", "0.550608", "0.550001", "0.54139346", "0.53872365", "0.53806436", "0.53767437", "0.5375325", "0.5364676", "0.53183454", "0.53183454", "0.5316748", "0.5269909", "0.52318", "0.5216419", "0.52091414", "0.5201532", "0.52006644", "0.5185063", "0.5169426", "0.51280224", "0.5095373", "0.508976", "0.5076351", "0.506902", "0.5044815", "0.50435823", "0.5042135", "0.50238246", "0.5015014", "0.49985525", "0.49918488", "0.49822292", "0.4968273", "0.49641278", "0.49635297", "0.49615547", "0.4910092", "0.48966008", "0.4885814", "0.4880721", "0.48724803", "0.48477805", "0.4846949", "0.48398015", "0.483004", "0.47857478", "0.47820812", "0.47709793", "0.4763087", "0.4755545", "0.47545874", "0.47447708", "0.4739468", "0.4737701", "0.47342846", "0.47330615", "0.47313976", "0.47255218", "0.47255218", "0.47255218", "0.47255218", "0.47255218", "0.47255218", "0.47255218", "0.47255218", "0.47234428", "0.471746", "0.4713455", "0.4710453", "0.4682011", "0.46808293", "0.46720657", "0.4649071", "0.46447825" ]
0.84958863
1
Sets f = Floor(x) and returns f.
Определяет f = Floor(x) и возвращает f.
func (f *Float) Floor(x *Float) *Float { x.doinit() f.doinit() C.mpf_floor(&f.i[0], &x.i[0]) return f }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Floor(x float64) float64 {\n\n\treturn math.Floor(x)\n}", "func Floor(arg float64) float64 {\n\treturn math.Floor(arg)\n}", "func Floor(x float64, unit float64) float64 {\n\tif IsZero(unit) {\n\t\treturn x\n\t}\n\n\tunits := int64((x + unit*e) / unit)\n\treturn float64(units) * unit\n}", "func Floor(scope *Scope, x tf.Output) (y tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Floor\",\n\t\tInput: []tf.Input{\n\t\t\tx,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func (c *Clac) Floor() error {\n\treturn c.applyFloat(1, func(vals []value.Value) (value.Value, error) {\n\t\treturn unary(\"floor\", vals[0])\n\t})\n}", "func (i *Number) Floor(precision Number) *Number {\n\tif precision.IsBelow(*NewNumber(1)) {\n\t\treturn NewNumber(math.Floor(i.AsFloat64()))\n\t}\n\tbuf := bytes.NewBuffer([]byte{})\n\tbuf.WriteString(\"1\")\n\tfor i := 0; i < precision.AsInt(); i++ {\n\t\tbuf.WriteString(\"0\")\n\t}\n\tfactor := NewNumber(buf.String())\n\tconverted := i.Multiply(*factor)\n\tflooring := NewNumber(math.Floor(converted.AsFloat64()))\n\treturn flooring.Divide(*factor)\n}", "func wrap(x, bound float64) float64 {\n\tif x >= 0 && x < bound {\n\t\treturn x\n\t}\n\tif x = math.Mod(x, bound); x < 0 {\n\t\treturn bound + x\n\t}\n\treturn x\n}", "func Floor(t1 TermT) TermT {\n\treturn TermT(C.yices_floor(C.term_t(t1)))\n}", "func (d Decimal) Floor() Decimal {\n\td.ensureInitialized()\n\n\tif d.exp >= 0 {\n\t\treturn d\n\t}\n\n\texp := big.NewInt(10)\n\n\t// NOTE(vadim): must negate after casting to prevent int32 overflow\n\texp.Exp(exp, big.NewInt(-int64(d.exp)), nil)\n\n\tz := new(big.Int).Div(d.value, exp)\n\treturn Decimal{value: z, exp: 0}\n}", "func (d Decimal) Floor() Decimal {\n\td.ensureInitialized()\n\n\tif d.exp >= 0 {\n\t\treturn d\n\t}\n\n\texp := big.NewInt(10)\n\n\t// NOTE(vadim): must negate after casting to prevent int32 overflow\n\texp.Exp(exp, big.NewInt(-int64(d.exp)), nil)\n\n\tz := new(big.Int).Div(d.value, exp)\n\treturn Decimal{value: z, exp: 0}\n}", "func FloorP(x float64, p int) float64 {\n\tk := math.Pow10(p)\n\treturn math.Floor(x*k) / k\n}", "func Floor(value gcv.Value) (gcv.Value, error) {\n\tif value.Type() == gcv.Complex {\n\t\treturn nil, errors.New(\"Floor is not supported for Complex numbers\")\n\t}\n\treturn gcv.MakeValue(math.Floor(value.Real())), nil\n}", "func funcFloor(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector {\n\treturn simpleFunc(vals, enh, math.Floor)\n}", "func Round(x float64) float64 {\n\n\treturn math.Floor(x + 0.5)\n}", "func FloorMod(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"FloorMod\",\n\t\tInput: []tf.Input{\n\t\t\tx, y,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func (f *Float) Ceil(x *Float) *Float {\n\tx.doinit()\n\tf.doinit()\n\tC.mpf_ceil(&f.i[0], &x.i[0])\n\treturn f\n}", "func (self *State)Floor(a any)any{\n self.IncOperations(self.coeff[\"floor\"]+self.off[\"floor\"])\n return wrap1(a,math.Floor)\n}", "func Round(x float64) float64 {\n\treturn math.Floor(x + 0.5)\n}", "func (s Size) Floor() Size {\n\tfor _, unit := range allUnits {\n\t\tif s >= unit {\n\t\t\treturn (s / unit) * unit\n\t\t}\n\t}\n\treturn s\n}", "func FloorAtZero(x *float64) bool {\n\tif *x < 0 {\n\t\t*x = 0.0\n\t\treturn true\n\t}\n\treturn false\n}", "func Round(f float64) float64 {\n\tif f > 0 {\n\t\treturn math.Floor(f + 0.5)\n\t}\n\treturn math.Ceil(f - 0.5)\n}", "func FloorDiv(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"FloorDiv\",\n\t\tInput: []tf.Input{\n\t\t\tx, y,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func Floor32(x float32) float32 {\n\treturn float32(math.Floor(float64(x)))\n}", "func Ceil(x float64) float64 {\n\n\treturn math.Ceil(x)\n}", "func (f Float) floor_int() (int) {\n i := int(f)\n if f < Float(0.0) && f != Float(i) { \n return i - 1\n }\n return i \n}", "func roundFloat(x float64, prec int) float64 {\n\tvar rounder float64\n\tpow := math.Pow(10, float64(prec))\n\tintermed := x * pow\n\t_, frac := math.Modf(intermed)\n\tx = .5\n\tif frac < 0.0 {\n\t\tx = -.5\n\t}\n\tif frac >= x {\n\t\trounder = math.Ceil(intermed)\n\t} else {\n\t\trounder = math.Floor(intermed)\n\t}\n\n\treturn rounder / pow\n}", "func floorMod(x, y int64) int64 {\n\tm := x % y\n\tif m == 0 || ((x >= 0 && y > 0) || (x < 0 && y < 0)) {\n\t\treturn m\n\t}\n\treturn m + y\n}", "func clamp(x float64) float64 {\n\tif x > 1 {\n\t\treturn 1\n\t}\n\treturn x\n}", "func (u Vec) Floor() Vec {\n\treturn Vec{\n\t\tmath.Floor(u.X),\n\t\tmath.Floor(u.Y),\n\t}\n}", "func RoundFloat(f float64) float64 {\n\tif math.Remainder(f, 1.0) < 0 {\n\t\treturn math.Ceil(f)\n\t}\n\treturn math.Floor(f)\n}", "func (gdt *Vector3) Floor() Vector3 {\n\targ0 := gdt.getBase()\n\n\tret := C.go_godot_vector3_floor(GDNative.api, arg0)\n\n\treturn Vector3{base: &ret}\n\n}", "func (d Decimal) RoundFloor(places int32) Decimal {\n\tif d.exp >= -places {\n\t\treturn d\n\t}\n\n\trescaled := d.rescale(-places)\n\tif d.Equal(rescaled) {\n\t\treturn d\n\t}\n\n\tif d.value.Sign() < 0 {\n\t\trescaled.value.Sub(rescaled.value, oneInt)\n\t}\n\n\treturn rescaled\n}", "func MustFloor(value gcv.Value) gcv.Value {\n\tval, err := Floor(value)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn val\n}", "func round(x float64) float64 {\n\tt := math.Trunc(x)\n\tif math.Abs(x-t) >= 0.5 {\n\t\treturn t + math.Copysign(1, x)\n\t}\n\treturn t\n}", "func Round(input float64) float64 {\n\tif input < 0 {\n\t\treturn math.Ceil(input - 0.5)\n\t}\n\treturn math.Floor(input + 0.5)\n}", "func Clamp(x, a, b float64) float64 {\n\tif x < a {\n\t\treturn a\n\t}\n\tif x > b {\n\t\treturn b\n\t}\n\treturn x\n}", "func Clamp(x, min, max float64) float64 {\n\tif x < min {\n\t\treturn min\n\t}\n\tif x > max {\n\t\treturn max\n\t}\n\treturn x\n}", "func Clamp(x, min, max float64) float64 {\n\tif x < min {\n\t\treturn min\n\t}\n\tif x > max {\n\t\treturn max\n\t}\n\treturn x\n}", "func Clamp(fValue, fMinValue, fMaxValue gl.Float) gl.Float {\n\tif fValue < fMinValue {\n\t\treturn fMinValue\n\t} else if fValue > fMaxValue {\n\t\treturn fMaxValue\n\t} else {\n\t\treturn fValue\n\t}\n}", "func Round64(x float64, n int) float64 {\n\tif math.IsNaN(x) {\n\t\treturn x\n\t}\n\tshift := math.Pow(10, float64(n))\n\treturn math.Floor(x*shift+0.5) / shift\n}", "func round(value float64) float64 {\n\treturn math.Floor(value + .5)\n}", "func round(f float64) int {\n\tif f < 0 {\n\t\treturn int(math.Ceil(f - 0.5))\n\t}\n\treturn int(math.Floor(f + 0.5))\n}", "func floorPow2(v int) int {}", "func round(v float64) float64 {\n\treturn math.Floor(v + 0.5)\n}", "func Ceil(arg float64) float64 {\n\treturn math.Ceil(arg)\n}", "func (fn *formulaFuncs) FLOOR(argsList *list.List) formulaArg {\n\tif argsList.Len() != 2 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"FLOOR requires 2 numeric arguments\")\n\t}\n\tnumber := argsList.Front().Value.(formulaArg).ToNumber()\n\tif number.Type == ArgError {\n\t\treturn number\n\t}\n\tsignificance := argsList.Back().Value.(formulaArg).ToNumber()\n\tif significance.Type == ArgError {\n\t\treturn significance\n\t}\n\tif significance.Number < 0 && number.Number >= 0 {\n\t\treturn newErrorFormulaArg(formulaErrorNUM, \"invalid arguments to FLOOR\")\n\t}\n\tval := number.Number\n\tval, res := math.Modf(val / significance.Number)\n\tif res != 0 {\n\t\tif number.Number < 0 && res < 0 {\n\t\t\tval--\n\t\t}\n\t}\n\treturn newStringFormulaArg(strings.ToUpper(fmt.Sprintf(\"%g\", val*significance.Number)))\n}", "func Round(f float64, places int) float64 {\n\tshift := math.Pow(10, float64(places))\n\treturn math.Floor(f*shift+.5) / shift\n}", "func truncate(x, m int64) int64 {\n\tif m <= 0 {\n\t\treturn x\n\t}\n\treturn x - x%m\n}", "func (tree *Tree) Floor(key interface{}) (floor *Node, found bool) {\n\tfound = false\n\tnode := tree.Root\n\tfor node != nil {\n\t\tcompare := tree.Comparator(key, node.Key)\n\t\tswitch {\n\t\tcase compare == 0:\n\t\t\treturn node, true\n\t\tcase compare < 0:\n\t\t\tnode = node.Left\n\t\tcase compare > 0:\n\t\t\tfloor, found = node, true\n\t\t\tnode = node.Right\n\t\t}\n\t}\n\tif found {\n\t\treturn floor, true\n\t}\n\treturn nil, false\n}", "func Round(f float64) int {\n\tif math.Abs(f) < 0.5 {\n\t\treturn 0\n\t}\n\treturn int(f + math.Copysign(0.5, f))\n}", "func (flat) getFloorNumber() int {\n\treturn 32\n}", "func TruncateFloat(f float64, flen int, decimal int) (float64, error) {\n\tif math.IsNaN(f) {\n\t\t// nan returns 0\n\t\treturn 0, nil\n\t}\n\n\tmaxF := getMaxFloat(flen, decimal)\n\n\tif !math.IsInf(f, 0) {\n\t\tf = truncateFloat(f, decimal)\n\t}\n\n\tif f > maxF {\n\t\tf = maxF\n\t} else if f < -maxF {\n\t\tf = -maxF\n\t}\n\n\treturn f, nil\n}", "func roundValue(initialValue float64, floor float64) float64 {\n\tb := []byte(strings.Trim(fmt.Sprintf(\"%f\", initialValue), \"0\"))\n\tvalue := initialValue\n\tfor i := len(b)-1; i >= 0; i-- {\n\t\tif b[i] != '.' {\n\t\t\tb[i] = '0'\n\t\t\tround, e := strconv.ParseFloat(string(b), 64)\n\t\t\tif e != nil || round <= floor {\n\t\t\t\treturn value\n\t\t\t}\n\t\t\tvalue = round\n\t\t}\n\t}\n\treturn value\n}", "func (s *Series) floor(t time.Time) time.Time {\n\treturn t.Truncate(s.Resolution)\n}", "func FloatMode(x *big.Float,) big.RoundingMode", "func (t *binarySearchST) Floor(key interface{}) interface{} {\n\tutils.AssertF(key != nil, \"Key is nil\")\n\n\ti := t.Rank(key)\n\tif i < t.n && t.keys[i] == key { // key in table\n\t\treturn t.keys[i]\n\t}\n\tif i == 0 { // any key in table greater than key\n\t\treturn nil\n\t}\n\treturn t.keys[i-1]\n}", "func (f Fixed) Round(n int) Fixed {\n\tif f.IsNaN() {\n\t\treturn NaN\n\t}\n\n\tfraction := f.fp % scale\n\tf0 := fraction / int64(math.Pow10(nPlaces-n-1))\n\tdigit := abs(f0 % 10)\n\tf0 = (f0 / 10)\n\tif digit >= 5 {\n\t\tf0 += 1 * sign(f.fp)\n\t}\n\tf0 = f0 * int64(math.Pow10(nPlaces-n))\n\n\tintpart := f.fp - fraction\n\tfp := intpart + f0\n\n\treturn Fixed{fp: fp}\n}", "func ClampFloat64(val float64, min float64, max float64) float64 {\n\tif val <= min {\n\t\treturn min\n\t}\n\tif val >= max {\n\t\treturn max\n\t}\n\treturn val\n}", "func round(n float64) float64 {\n\treturn math.Trunc(n)\n}", "func Round(f float64) float64 {\n\treturn math.Round(f*1000000000) / 1000000000\n}", "func (l *limiter) floor(mark time.Time, now time.Time) time.Time {\n\tif t := now.Add(-l.quantum); !mark.After(t) {\n\t\treturn t\n\t}\n\treturn mark\n}", "func FloatRound(f float64, n int) float64 {\r\n\tpow10_n := math.Pow10(n)\r\n\toffset := 0.5\r\n\tif f < 0 {\r\n\t\toffset = -offset\r\n\t}\r\n\treturn math.Trunc((f+offset/pow10_n)*pow10_n) / pow10_n\r\n}", "func pow(x, n, lim float64) float64 {\n if v := math.Pow(x, n); v < lim {\n return v\n }\n return lim\n}", "func Trunc(val value.Value) (value.Value, error) {\n\te := &eval{}\n\tif isTrue(e.binary(val, \">=\", zero)) {\n\t\tval = e.unary(\"floor\", val)\n\t} else {\n\t\tval = e.unary(\"ceil\", val)\n\t}\n\treturn val, e.err\n}", "func FMod(arg float64, arg2 float64) float64 {\n\tflooRit := Floor(arg / arg2)\n\treturn arg - (flooRit * arg2)\n}", "func Clamp(val, low, high float64) float64 {\n\tif val < low {\n\t\treturn low\n\t}\n\n\tif val > high {\n\t\treturn high\n\t}\n\n\treturn val\n}", "func round(f float64) int {\n\tif math.Abs(f) < 0.5 {\n\t\treturn 0\n\t}\n\treturn int(f + math.Copysign(0.5, f))\n}", "func (f *Float) Trunc(x *Float) *Float {\n\tx.doinit()\n\tf.doinit()\n\tC.mpf_trunc(&f.i[0], &x.i[0])\n\treturn f\n}", "func RoundToInt(f float64) int {\n\tif math.Abs(f) < 0.5 {\n\t\treturn 0\n\t}\n\treturn int(f + math.Copysign(0.5, f))\n}", "func clampval(x float32) float32 {\n\tif math.Abs(float64(x)) < 0.01 {\n\t\treturn 0.0\n\t}\n\n\tif x < -0.99 {\n\t\treturn -1.0\n\t} else if x > 0.99 {\n\t\treturn 1.0\n\t}\n\treturn x\n}", "func f1(x int) int {\n\treturn x / 3 * 3\n}", "func f(x int) {\n\tfmt.Printf(\"f(%d)\\n\", x+0/x) // panics if x == 0\n\tdefer fmt.Printf(\"defer %d\\n\", x)\n\tf(x - 1)\n}", "func (dt DateTime) FloorMonth() DateTime {\n\treturn dt.Replace(dt.Year(), dt.Month(), 1, 0, 0, 0, 0)\n}", "func RoundFloat(x float32) float32 {\r\n\treturn float32(math.Round(float64(x)))\r\n}", "func roundRandom(f float64, rng *rand.Rand) int {\n\tr := f - math.Floor(f)\n\tp := rng.Float64()\n\tif p > r {\n\t\treturn int(f)\n\t}\n\treturn int(f) + 1\n}", "func (t *RedBlackTree) Floor(key interface{}) (floor *Node) {\n\tfor node := t.root; node != nil; {\n\t\tswitch t.comparator(key, node.key) {\n\t\tcase 0:\n\t\t\tfloor = node\n\t\t\treturn\n\t\tcase -1:\n\t\t\tnode = node.left\n\t\tcase 1:\n\t\t\tfloor = node\n\t\t\tnode = node.right\n\t\t}\n\t}\n\n\treturn\n}", "func Float64(n, min, max float64) float64 {\n\tif n < min {\n\t\tn = min\n\t} else if n > max {\n\t\tn = max\n\t}\n\treturn n\n}", "func (m *PrinterLocation) SetFloor(value *string)() {\n err := m.GetBackingStore().Set(\"floor\", value)\n if err != nil {\n panic(err)\n }\n}", "func (f Fixed) Round(n int) Fixed {\n\tif f.IsNaN() {\n\t\treturn NaN\n\t}\n\n\tround := .5\n\n\tf0 := f.Frac()\n\tf0 = f0*math.Pow10(n) + round\n\tf0 = float64(int(f0)) / math.Pow10(n)\n\n\treturn NewFromFloat(float64(f.UInt()) + f0)\n}", "func (fn *formulaFuncs) ISOdotCEILING(argsList *list.List) formulaArg {\n\tif argsList.Len() == 0 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"ISO.CEILING requires at least 1 argument\")\n\t}\n\tif argsList.Len() > 2 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"ISO.CEILING allows at most 2 arguments\")\n\t}\n\tvar significance float64\n\tnumber := argsList.Front().Value.(formulaArg).ToNumber()\n\tif number.Type == ArgError {\n\t\treturn number\n\t}\n\tif number.Number < 0 {\n\t\tsignificance = -1\n\t}\n\tif argsList.Len() == 1 {\n\t\treturn newNumberFormulaArg(math.Ceil(number.Number))\n\t}\n\tif argsList.Len() > 1 {\n\t\ts := argsList.Back().Value.(formulaArg).ToNumber()\n\t\tif s.Type == ArgError {\n\t\t\treturn s\n\t\t}\n\t\tsignificance = s.Number\n\t\tsignificance = math.Abs(significance)\n\t\tif significance == 0 {\n\t\t\treturn newNumberFormulaArg(significance)\n\t\t}\n\t}\n\tval, res := math.Modf(number.Number / significance)\n\tif res != 0 {\n\t\tif number.Number > 0 {\n\t\t\tval++\n\t\t}\n\t}\n\treturn newNumberFormulaArg(val * significance)\n}", "func CeilP(x float64, p int) float64 {\n\tk := math.Pow10(p)\n\treturn math.Ceil(x*k) / k\n}", "func RoundP(x float64, p int) float64 {\n\tk := math.Pow10(p)\n\treturn math.Floor(x*k+0.5) / k\n}", "func (i *Number) Ceil(precision Number) *Number {\n\tif precision.IsBelow(*NewNumber(1)) {\n\t\treturn NewNumber(math.Ceil(i.AsFloat64()))\n\t}\n\tbuf := bytes.NewBuffer([]byte{})\n\tbuf.WriteString(\"1\")\n\tfor i := 0; i < precision.AsInt(); i++ {\n\t\tbuf.WriteString(\"0\")\n\t}\n\tfactor := NewNumber(buf.String())\n\tconverted := i.Multiply(*factor)\n\tceiling := NewNumber(math.Ceil(converted.AsFloat64()))\n\treturn ceiling.Divide(*factor)\n}", "func (fn *formulaFuncs) FLOORdotPRECISE(argsList *list.List) formulaArg {\n\tif argsList.Len() == 0 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"FLOOR.PRECISE requires at least 1 argument\")\n\t}\n\tif argsList.Len() > 2 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"FLOOR.PRECISE allows at most 2 arguments\")\n\t}\n\tvar significance float64\n\tnumber := argsList.Front().Value.(formulaArg).ToNumber()\n\tif number.Type == ArgError {\n\t\treturn number\n\t}\n\tif number.Number < 0 {\n\t\tsignificance = -1\n\t}\n\tif argsList.Len() == 1 {\n\t\treturn newNumberFormulaArg(math.Floor(number.Number))\n\t}\n\tif argsList.Len() > 1 {\n\t\ts := argsList.Back().Value.(formulaArg).ToNumber()\n\t\tif s.Type == ArgError {\n\t\t\treturn s\n\t\t}\n\t\tsignificance = s.Number\n\t\tsignificance = math.Abs(significance)\n\t\tif significance == 0 {\n\t\t\treturn newNumberFormulaArg(significance)\n\t\t}\n\t}\n\tval, res := math.Modf(number.Number / significance)\n\tif res != 0 {\n\t\tif number.Number < 0 {\n\t\t\tval--\n\t\t}\n\t}\n\treturn newNumberFormulaArg(val * significance)\n}", "func maybeFloatToInt(val interface{}) interface{} {\n\tif f64, ok := val.(float64); ok {\n\t\tfloor := math.Floor(f64)\n\t\tif f64-floor == 0 {\n\t\t\treturn int64(floor)\n\t\t}\n\t}\n\n\treturn val\n}", "func (x Bits) round(prec uint, mode RoundingMode) *Float {\n\tx = x.norm()\n\n\t// determine range\n\tvar min, max int\n\tfor i, b := range x {\n\t\tif i == 0 || b < min {\n\t\t\tmin = b\n\t\t}\n\t\tif i == 0 || b > max {\n\t\t\tmax = b\n\t\t}\n\t}\n\tprec0 := uint(max + 1 - min)\n\tif prec >= prec0 {\n\t\treturn x.Float()\n\t}\n\t// prec < prec0\n\n\t// determine bit 0, rounding, and sticky bit, and result bits z\n\tvar bit0, rbit, sbit uint\n\tvar z Bits\n\tr := max - int(prec)\n\tfor _, b := range x {\n\t\tswitch {\n\t\tcase b == r:\n\t\t\trbit = 1\n\t\tcase b < r:\n\t\t\tsbit = 1\n\t\tdefault:\n\t\t\t// b > r\n\t\t\tif b == r+1 {\n\t\t\t\tbit0 = 1\n\t\t\t}\n\t\t\tz = append(z, b)\n\t\t}\n\t}\n\n\t// round\n\tf := z.Float() // rounded to zero\n\tif mode == ToNearestAway {\n\t\tpanic(\"not yet implemented\")\n\t}\n\tif mode == ToNearestEven && rbit == 1 && (sbit == 1 || sbit == 0 && bit0 != 0) || mode == AwayFromZero {\n\t\t// round away from zero\n\t\tf.SetMode(ToZero).SetPrec(prec)\n\t\tf.Add(f, Bits{int(r) + 1}.Float())\n\t}\n\treturn f\n}", "func (fn *formulaFuncs) FLOORdotMATH(argsList *list.List) formulaArg {\n\tif argsList.Len() == 0 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"FLOOR.MATH requires at least 1 argument\")\n\t}\n\tif argsList.Len() > 3 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"FLOOR.MATH allows at most 3 arguments\")\n\t}\n\tsignificance, mode := 1.0, 1.0\n\tnumber := argsList.Front().Value.(formulaArg).ToNumber()\n\tif number.Type == ArgError {\n\t\treturn number\n\t}\n\tif number.Number < 0 {\n\t\tsignificance = -1\n\t}\n\tif argsList.Len() > 1 {\n\t\ts := argsList.Front().Next().Value.(formulaArg).ToNumber()\n\t\tif s.Type == ArgError {\n\t\t\treturn s\n\t\t}\n\t\tsignificance = s.Number\n\t}\n\tif argsList.Len() == 1 {\n\t\treturn newNumberFormulaArg(math.Floor(number.Number))\n\t}\n\tif argsList.Len() > 2 {\n\t\tm := argsList.Back().Value.(formulaArg).ToNumber()\n\t\tif m.Type == ArgError {\n\t\t\treturn m\n\t\t}\n\t\tmode = m.Number\n\t}\n\tval, res := math.Modf(number.Number / significance)\n\tif res != 0 && number.Number < 0 && mode > 0 {\n\t\tval--\n\t}\n\treturn newNumberFormulaArg(val * significance)\n}", "func (bunker) getFloorNumber() int {\n\treturn 0\n}", "func Clamp(value, min, max float32) float32 {\n\tvar res float32\n\tif value < min {\n\t\tres = min\n\t} else {\n\t\tres = value\n\t}\n\n\tif res > max {\n\t\treturn max\n\t}\n\n\treturn res\n}", "func Ceil32(x float32) float32 {\n\treturn float32(math.Ceil(float64(x)))\n}", "func Round(arg float64) float64 {\n\treturn math.Round(arg)\n}", "func Round(x Decimal, unit Decimal, mode RoundingMode) Decimal {\n\tprec := unit.Exponent() * -1\n\n\tswitch mode {\n\tcase RoundDown:\n\t\trounded := x.RoundDown(prec)\n\t\treturn rounded.Sub(rounded.Mod(unit)).Truncate(prec)\n\tcase RoundUp:\n\t\trounded := x.RoundUp(prec)\n\t\treturn rounded.Add(rounded.Mod(unit)).Truncate(prec)\n\tcase RoundToNearest:\n\t\treturn x.RoundNearest(unit).Truncate(prec)\n\t}\n\treturn Decimal{}\n}", "func (x *Rat) Float64() (f float64, exact bool) {}", "func (x *Float) Mode() RoundingMode {}", "func (m *Money) Setf(f float64) *Money {\n\tfDPf := f * DPf\n\tr := int64(f * DPf)\n\treturn m.Set(Rnd(r, fDPf-float64(r)))\n}", "func clamp(val float64) float64 {\n\treturn math.Max(-1, math.Min(1, val))\n}", "func (w *QWriter) F(f float64) {\n\tn := int(f)\n\tif float64(n) == f {\n\t\t// Fast path - just int.\n\t\tw.D(n)\n\t\treturn\n\t}\n\n\t// Slow path.\n\tw.FPrec(f, -1)\n}", "func ClampFloat64(e, lower, upper float64) (float64, error) {\n\tif lower > upper {\n\t\treturn 0, fmt.Errorf(\"lower must be less than or equal to upper, got lower = %v, upper = %v\", lower, upper)\n\t}\n\n\tif e > upper {\n\t\treturn upper, nil\n\t}\n\tif e < lower {\n\t\treturn lower, nil\n\t}\n\treturn e, nil\n}", "func ROUNDPD(i, mx, x operand.Op) { ctx.ROUNDPD(i, mx, x) }", "func (h *hinter) round(x f26dot6) f26dot6 {\n\tif h.roundPeriod == 0 {\n\t\treturn x\n\t}\n\tneg := x < 0\n\tx -= h.roundPhase\n\tx += h.roundThreshold\n\tif x >= 0 {\n\t\tx = (x / h.roundPeriod) * h.roundPeriod\n\t} else {\n\t\tx -= h.roundPeriod\n\t\tx += 1\n\t\tx = (x / h.roundPeriod) * h.roundPeriod\n\t}\n\tx += h.roundPhase\n\tif neg {\n\t\tif x >= 0 {\n\t\t\tx = h.roundPhase - h.roundPeriod\n\t\t}\n\t} else if x < 0 {\n\t\tx = h.roundPhase\n\t}\n\treturn x\n}" ]
[ "0.8016191", "0.77603114", "0.73603815", "0.7285953", "0.70936745", "0.6759427", "0.66098326", "0.6581992", "0.65784335", "0.65784335", "0.6554434", "0.65519273", "0.65097517", "0.62348694", "0.62232935", "0.61974365", "0.6182518", "0.6132632", "0.60743606", "0.6069187", "0.60489005", "0.6015769", "0.60108227", "0.5954742", "0.5911254", "0.587775", "0.5871349", "0.5816993", "0.5703827", "0.5698761", "0.56682694", "0.5644104", "0.5636621", "0.5594592", "0.55830044", "0.5578031", "0.5577127", "0.5577127", "0.5515777", "0.5514368", "0.5501594", "0.54792225", "0.5474537", "0.54484534", "0.54267704", "0.54217565", "0.54073966", "0.5407046", "0.5388179", "0.53692645", "0.5358773", "0.52874136", "0.5270379", "0.5252403", "0.52386016", "0.5230623", "0.52265525", "0.5223921", "0.52128255", "0.520807", "0.5193166", "0.51865464", "0.5162272", "0.5162148", "0.51597786", "0.51571226", "0.515236", "0.5140767", "0.51378024", "0.5131845", "0.51168495", "0.511218", "0.5109469", "0.50928485", "0.50869304", "0.508283", "0.50715834", "0.50663775", "0.50633067", "0.5060793", "0.5057723", "0.50575507", "0.5056106", "0.504812", "0.5038645", "0.50382185", "0.50376767", "0.5005211", "0.50022554", "0.49886522", "0.49625662", "0.49481332", "0.49431336", "0.4936145", "0.48969394", "0.48964548", "0.48901492", "0.4885797", "0.48811498", "0.4879941" ]
0.80533195
0
Sets f = Trunc(x) (=round towards zero) and returns f.
Устанавливает f = Trunc(x) (=округление к нулю) и возвращает f.
func (f *Float) Trunc(x *Float) *Float { x.doinit() f.doinit() C.mpf_trunc(&f.i[0], &x.i[0]) return f }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Trunc(val value.Value) (value.Value, error) {\n\te := &eval{}\n\tif isTrue(e.binary(val, \">=\", zero)) {\n\t\tval = e.unary(\"floor\", val)\n\t} else {\n\t\tval = e.unary(\"ceil\", val)\n\t}\n\treturn val, e.err\n}", "func (c *Clac) Trunc() error {\n\treturn c.applyFloat(1, func(vals []value.Value) (value.Value, error) {\n\t\treturn Trunc(vals[0])\n\t})\n}", "func TruncateFloat(f float64, flen int, decimal int) (float64, error) {\n\tif math.IsNaN(f) {\n\t\t// nan returns 0\n\t\treturn 0, nil\n\t}\n\n\tmaxF := getMaxFloat(flen, decimal)\n\n\tif !math.IsInf(f, 0) {\n\t\tf = truncateFloat(f, decimal)\n\t}\n\n\tif f > maxF {\n\t\tf = maxF\n\t} else if f < -maxF {\n\t\tf = -maxF\n\t}\n\n\treturn f, nil\n}", "func round(x float64) float64 {\n\tt := math.Trunc(x)\n\tif math.Abs(x-t) >= 0.5 {\n\t\treturn t + math.Copysign(1, x)\n\t}\n\treturn t\n}", "func roundFloat(x float64, prec int) float64 {\n\tvar rounder float64\n\tpow := math.Pow(10, float64(prec))\n\tintermed := x * pow\n\t_, frac := math.Modf(intermed)\n\tx = .5\n\tif frac < 0.0 {\n\t\tx = -.5\n\t}\n\tif frac >= x {\n\t\trounder = math.Ceil(intermed)\n\t} else {\n\t\trounder = math.Floor(intermed)\n\t}\n\n\treturn rounder / pow\n}", "func (f F128d16) Trunc() F128d16 {\n\treturn F128d16{data: f.data.Div(multiplierF128d16).Mul(multiplierF128d16)}\n}", "func Round(f float64) float64 {\n\tif f > 0 {\n\t\treturn math.Floor(f + 0.5)\n\t}\n\treturn math.Ceil(f - 0.5)\n}", "func round(n float64) float64 {\n\treturn math.Trunc(n)\n}", "func truncate(num float64) float64 {\n\tvar truncated = math.Round(num*100) / 100\n\treturn truncated\n}", "func Truncate(val float64, prec int) float64 {\n\tfrep := strconv.FormatFloat(val, 'g', prec, 64)\n\tval, _ = strconv.ParseFloat(frep, 64)\n\treturn val\n}", "func round(f float64) int {\n\tif math.Abs(f) < 0.5 {\n\t\treturn 0\n\t}\n\treturn int(f + math.Copysign(0.5, f))\n}", "func roundValue(initialValue float64, floor float64) float64 {\n\tb := []byte(strings.Trim(fmt.Sprintf(\"%f\", initialValue), \"0\"))\n\tvalue := initialValue\n\tfor i := len(b)-1; i >= 0; i-- {\n\t\tif b[i] != '.' {\n\t\t\tb[i] = '0'\n\t\t\tround, e := strconv.ParseFloat(string(b), 64)\n\t\t\tif e != nil || round <= floor {\n\t\t\t\treturn value\n\t\t\t}\n\t\t\tvalue = round\n\t\t}\n\t}\n\treturn value\n}", "func truncate(x, m int64) int64 {\n\tif m <= 0 {\n\t\treturn x\n\t}\n\treturn x - x%m\n}", "func wrap(x, bound float64) float64 {\n\tif x >= 0 && x < bound {\n\t\treturn x\n\t}\n\tif x = math.Mod(x, bound); x < 0 {\n\t\treturn bound + x\n\t}\n\treturn x\n}", "func Round(x float64) float64 {\n\n\treturn math.Floor(x + 0.5)\n}", "func round(value float64) float64 {\n\treturn math.Floor(value + .5)\n}", "func RoundFloat(f float64) float64 {\n\tif math.Remainder(f, 1.0) < 0 {\n\t\treturn math.Ceil(f)\n\t}\n\treturn math.Floor(f)\n}", "func Floor(x float64) float64 {\n\n\treturn math.Floor(x)\n}", "func (h *hinter) round(x f26dot6) f26dot6 {\n\tif h.roundPeriod == 0 {\n\t\treturn x\n\t}\n\tneg := x < 0\n\tx -= h.roundPhase\n\tx += h.roundThreshold\n\tif x >= 0 {\n\t\tx = (x / h.roundPeriod) * h.roundPeriod\n\t} else {\n\t\tx -= h.roundPeriod\n\t\tx += 1\n\t\tx = (x / h.roundPeriod) * h.roundPeriod\n\t}\n\tx += h.roundPhase\n\tif neg {\n\t\tif x >= 0 {\n\t\t\tx = h.roundPhase - h.roundPeriod\n\t\t}\n\t} else if x < 0 {\n\t\tx = h.roundPhase\n\t}\n\treturn x\n}", "func Round(x float64) float64 {\n\treturn math.Floor(x + 0.5)\n}", "func Floor(x float64, unit float64) float64 {\n\tif IsZero(unit) {\n\t\treturn x\n\t}\n\n\tunits := int64((x + unit*e) / unit)\n\treturn float64(units) * unit\n}", "func round(v float64) float64 {\n\treturn math.Floor(v + 0.5)\n}", "func round(f float64) int {\n\tif f < 0 {\n\t\treturn int(math.Ceil(f - 0.5))\n\t}\n\treturn int(math.Floor(f + 0.5))\n}", "func (f Float64) Filter(c func(float64) bool) Float64 {\n\tif c == nil || !f.IsPresent() || !c(f.value) {\n\t\treturn Float64{}\n\t}\n\treturn f\n}", "func (f *Float) Floor(x *Float) *Float {\n\tx.doinit()\n\tf.doinit()\n\tC.mpf_floor(&f.i[0], &x.i[0])\n\treturn f\n}", "func Round(input float64) float64 {\n\tif input < 0 {\n\t\treturn math.Ceil(input - 0.5)\n\t}\n\treturn math.Floor(input + 0.5)\n}", "func Floor(arg float64) float64 {\n\treturn math.Floor(arg)\n}", "func Round(f float64) int {\n\tif math.Abs(f) < 0.5 {\n\t\treturn 0\n\t}\n\treturn int(f + math.Copysign(0.5, f))\n}", "func (x *Rat) Float64() (f float64, exact bool) {}", "func FloatSetInf(z *big.Float, signbit bool) *big.Float", "func (l *FSList) TruncFilter() {\n\tfl := len(l.Filter)\n\tif fl <= 0 {\n\t\treturn\n\t}\n\tl.Filter = l.Filter[:fl-1]\n}", "func trunc(num float64) int {\n\treturn int(num)\n}", "func (x Bits) round(prec uint, mode RoundingMode) *Float {\n\tx = x.norm()\n\n\t// determine range\n\tvar min, max int\n\tfor i, b := range x {\n\t\tif i == 0 || b < min {\n\t\t\tmin = b\n\t\t}\n\t\tif i == 0 || b > max {\n\t\t\tmax = b\n\t\t}\n\t}\n\tprec0 := uint(max + 1 - min)\n\tif prec >= prec0 {\n\t\treturn x.Float()\n\t}\n\t// prec < prec0\n\n\t// determine bit 0, rounding, and sticky bit, and result bits z\n\tvar bit0, rbit, sbit uint\n\tvar z Bits\n\tr := max - int(prec)\n\tfor _, b := range x {\n\t\tswitch {\n\t\tcase b == r:\n\t\t\trbit = 1\n\t\tcase b < r:\n\t\t\tsbit = 1\n\t\tdefault:\n\t\t\t// b > r\n\t\t\tif b == r+1 {\n\t\t\t\tbit0 = 1\n\t\t\t}\n\t\t\tz = append(z, b)\n\t\t}\n\t}\n\n\t// round\n\tf := z.Float() // rounded to zero\n\tif mode == ToNearestAway {\n\t\tpanic(\"not yet implemented\")\n\t}\n\tif mode == ToNearestEven && rbit == 1 && (sbit == 1 || sbit == 0 && bit0 != 0) || mode == AwayFromZero {\n\t\t// round away from zero\n\t\tf.SetMode(ToZero).SetPrec(prec)\n\t\tf.Add(f, Bits{int(r) + 1}.Float())\n\t}\n\treturn f\n}", "func f(t float64, w float64) float64 {\n\treturn (-1 - 0.02*w + (acc * t))\n}", "func FloorAtZero(x *float64) bool {\n\tif *x < 0 {\n\t\t*x = 0.0\n\t\treturn true\n\t}\n\treturn false\n}", "func Floor(scope *Scope, x tf.Output) (y tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Floor\",\n\t\tInput: []tf.Input{\n\t\t\tx,\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func (f Float) floor_int() (int) {\n i := int(f)\n if f < Float(0.0) && f != Float(i) { \n return i - 1\n }\n return i \n}", "func Ramp(x float64) float64 {\n\tif x < 0.0 {\n\t\treturn 0.0\n\t}\n\treturn x\n}", "func (f *Float) Ceil(x *Float) *Float {\n\tx.doinit()\n\tf.doinit()\n\tC.mpf_ceil(&f.i[0], &x.i[0])\n\treturn f\n}", "func zeroFunc(time.Duration) float64 { return 0 }", "func UnLexFloat(b uint64) float64 {\n\tif b>>63 == 1 {\n\t\tb = b ^ (1 << 63)\n\t} else {\n\t\tb = ^b\n\t}\n\treturn math.Float64frombits(b)\n}", "func ZeroFloat(v interface{}) float64 {\n\tf, err := Float64(v)\n\tif err != nil {\n\t\treturn 0\n\t}\n\treturn f\n}", "func Round(f float64, places int) float64 {\n\tshift := math.Pow(10, float64(places))\n\treturn math.Floor(f*shift+.5) / shift\n}", "func (f Fixed) Frac() float64 {\n\tif f.IsNaN() {\n\t\treturn math.NaN()\n\t}\n\treturn float64(f.fp%scale) / float64(scale)\n}", "func (f Fixed) Frac() float64 {\n\tif f.IsNaN() {\n\t\treturn math.NaN()\n\t}\n\treturn float64(f.fp%scale) / float64(scale)\n}", "func f(x int) {\n\tfmt.Printf(\"f(%d)\\n\", x+0/x) // panics if x == 0\n\tdefer fmt.Printf(\"defer %d\\n\", x)\n\tf(x - 1)\n}", "func (v Value) Float() float64 {\n\tswitch {\n\tcase v == 0:\n\t\treturn 0\n\tcase v == 64:\n\t\treturn 0.5\n\tcase v == 127:\n\t\treturn 1\n\tcase v < 64:\n\t\treturn float64(v) / 128\n\tdefault:\n\t\treturn float64(v-1) / 126\n\t}\n}", "func (t *Temp) F() int {\n\ttemp := math.Floor(float64(*t)*9/5) + 32\n\tif temp < 0 {\n\t\treturn int(temp - 1.0)\n\t}\n\treturn int(temp)\n}", "func fixToFloat(x int32) float32 {\n\treturn float32(x>>6) + float32(x&0x3f)/0x3f\n}", "func FloatMinPrec(x *big.Float,) uint", "func floatToFix(x float32) int32 {\n\treturn int32(x * 64.0)\n}", "func ( f MyFloat ) Abs() float64 {\n\tif f < 0 { return float64( -f ) }\n\treturn float64(f) \n}", "func FloatRound(f float64, n int) float64 {\r\n\tpow10_n := math.Pow10(n)\r\n\toffset := 0.5\r\n\tif f < 0 {\r\n\t\toffset = -offset\r\n\t}\r\n\treturn math.Trunc((f+offset/pow10_n)*pow10_n) / pow10_n\r\n}", "func TempFromF(f int) Temp {\n\tc := math.Floor(float64((f - 32)) / 1.8)\n\treturn Temp(c)\n\n}", "func Normalize(v Vect) Vect {\n\t// Neat trick I saw somewhere to avoid div/0.\n\treturn Mult(v, 1.0/(Length(v)+f.FloatMin))\n}", "func (c *Clac) Floor() error {\n\treturn c.applyFloat(1, func(vals []value.Value) (value.Value, error) {\n\t\treturn unary(\"floor\", vals[0])\n\t})\n}", "func (x *Float) MinPrec() uint {}", "func (z *Float) SetInf(signbit bool) *Float {}", "func round(val float64) int {\n\tif val < 0 {\n\t\treturn int(val - 0.5)\n\t}\n\treturn int(val + 0.5)\n}", "func RoundToInt(f float64) int {\n\tif math.Abs(f) < 0.5 {\n\t\treturn 0\n\t}\n\treturn int(f + math.Copysign(0.5, f))\n}", "func Abs(x float64) float64 {\n\tif x < 0 {\n\t\tx = -x\n\t}\n\treturn x\n}", "func ROUNDSD(i, mx, x operand.Op) { ctx.ROUNDSD(i, mx, x) }", "func ZeroSmall(x, y, epsilon float64) float64 {\n\tif Abs(x)/y < epsilon {\n\t\treturn 0\n\t}\n\treturn x\n}", "func maybeFloatToInt(val interface{}) interface{} {\n\tif f64, ok := val.(float64); ok {\n\t\tfloor := math.Floor(f64)\n\t\tif f64-floor == 0 {\n\t\t\treturn int64(floor)\n\t\t}\n\t}\n\n\treturn val\n}", "func (f Fixed) Round(n int) Fixed {\n\tif f.IsNaN() {\n\t\treturn NaN\n\t}\n\n\tfraction := f.fp % scale\n\tf0 := fraction / int64(math.Pow10(nPlaces-n-1))\n\tdigit := abs(f0 % 10)\n\tf0 = (f0 / 10)\n\tif digit >= 5 {\n\t\tf0 += 1 * sign(f.fp)\n\t}\n\tf0 = f0 * int64(math.Pow10(nPlaces-n))\n\n\tintpart := f.fp - fraction\n\tfp := intpart + f0\n\n\treturn Fixed{fp: fp}\n}", "func clamp(x float64) float64 {\n\tif x > 1 {\n\t\treturn 1\n\t}\n\treturn x\n}", "func Truncate(number string) (int64, error) {\n\tmatched := floatingNumberREGEX.FindStringSubmatch(number)\n\n\tif len(matched) == 0 { // check on the lenght of the parsed number\n\t\treturn 0, fmt.Errorf(\"Error parsing: %s is not a Float\", number)\n\t}\n\n\treturn strconv.ParseInt(matched[1], 10, 64)\n}", "func (m MyFloat) Abs() float64 {\n if m < 0 {\n return float64(-m)\n }\n return float64(m)\n}", "func (expr *ExprFPTrunc) Simplify() Constant {\n\tpanic(\"not yet implemented\")\n}", "func Round(arg float64) float64 {\n\treturn math.Round(arg)\n}", "func truncate(v, mod int64) uint64 {\n\treturn uint64(v - (v % mod))\n}", "func funcRound(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector {\n\tvec := vals[0].(Vector)\n\t// round returns a number rounded to toNearest.\n\t// Ties are solved by rounding up.\n\ttoNearest := float64(1)\n\tif len(args) >= 2 {\n\t\ttoNearest = vals[1].(Vector)[0].F\n\t}\n\t// Invert as it seems to cause fewer floating point accuracy issues.\n\ttoNearestInverse := 1.0 / toNearest\n\n\tfor _, el := range vec {\n\t\tf := math.Floor(el.F*toNearestInverse+0.5) / toNearestInverse\n\t\tenh.Out = append(enh.Out, Sample{\n\t\t\tMetric: enh.DropMetricName(el.Metric),\n\t\t\tF: f,\n\t\t})\n\t}\n\treturn enh.Out\n}", "func toFixed(num float64) float64 {\n\tbaseExpOutput := math.Pow10(floatFixedPrecision)\n\n\treturn math.Round(num*baseExpOutput) / baseExpOutput\n}", "func funcFloor(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector {\n\treturn simpleFunc(vals, enh, math.Floor)\n}", "func Sinf(a float64) float64 {\n\treturn float64(math.Sin(float64(a)))\n}", "func clampval(x float32) float32 {\n\tif math.Abs(float64(x)) < 0.01 {\n\t\treturn 0.0\n\t}\n\n\tif x < -0.99 {\n\t\treturn -1.0\n\t} else if x > 0.99 {\n\t\treturn 1.0\n\t}\n\treturn x\n}", "func FloatIsInf(x *big.Float,) bool", "func Round(f float64) float64 {\n\treturn math.Round(f*1000000000) / 1000000000\n}", "func (s *Streaming) UncorrectedValue() float64 {\n\treturn s.c * s.normx * s.normy / s.n\n}", "func (fn *formulaFuncs) TRUNC(argsList *list.List) formulaArg {\n\tif argsList.Len() == 0 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"TRUNC requires at least 1 argument\")\n\t}\n\tvar digits, adjust, rtrim float64\n\tvar err error\n\tnumber := argsList.Front().Value.(formulaArg).ToNumber()\n\tif number.Type == ArgError {\n\t\treturn number\n\t}\n\tif argsList.Len() > 1 {\n\t\td := argsList.Back().Value.(formulaArg).ToNumber()\n\t\tif d.Type == ArgError {\n\t\t\treturn d\n\t\t}\n\t\tdigits = d.Number\n\t\tdigits = math.Floor(digits)\n\t}\n\tadjust = math.Pow(10, digits)\n\tx := int((math.Abs(number.Number) - math.Abs(float64(int(number.Number)))) * adjust)\n\tif x != 0 {\n\t\tif rtrim, err = strconv.ParseFloat(strings.TrimRight(strconv.Itoa(x), \"0\"), 64); err != nil {\n\t\t\treturn newErrorFormulaArg(formulaErrorVALUE, err.Error())\n\t\t}\n\t}\n\tif (digits > 0) && (rtrim < adjust/10) {\n\t\treturn newNumberFormulaArg(number.Number)\n\t}\n\treturn newNumberFormulaArg(float64(int(number.Number*adjust)) / adjust)\n}", "func Round64(x float64, n int) float64 {\n\tif math.IsNaN(x) {\n\t\treturn x\n\t}\n\tshift := math.Pow(10, float64(n))\n\treturn math.Floor(x*shift+0.5) / shift\n}", "func (f MyFloat) Abs() float64 {\n\tif f < 0 {\n\t\treturn float64(-f)\n\t}\n\treturn float64(f)\n}", "func (sx ScaleX) Normalize(min, max, x float64) float64 {\n\ttXMin := sx(min)\n\treturn (sx(x) - tXMin) / (sx(max) - tXMin)\n}", "func FloatValue(f float64) Value { return StringValue(strconv.FormatFloat(f, 'f', -1, 64)) }", "func float64Round(v float64) float64 {\n\treturn math.Round(v*100) / 100\n}", "func F2fp(x float64) *float64 {\n\tif math.IsNaN(x) {\n\t\treturn nil\n\t} else {\n\t\treturn &x\n\t}\n}", "func round(val float64) float64 {\n\treturn math.Round(val*100) / 100\n}", "func round(num float64) int {\n\treturn int(num + math.Copysign(0.5, num))\n}", "func round(num float64) int {\n\treturn int(num + math.Copysign(0.5, num))\n}", "func round(num float64) int {\n\treturn int(num + math.Copysign(0.5, num))\n}", "func (f Fixed) Round(n int) Fixed {\n\tif f.IsNaN() {\n\t\treturn NaN\n\t}\n\n\tround := .5\n\n\tf0 := f.Frac()\n\tf0 = f0*math.Pow10(n) + round\n\tf0 = float64(int(f0)) / math.Pow10(n)\n\n\treturn NewFromFloat(float64(f.UInt()) + f0)\n}", "func (p *Vect) Normalize() {\n\t// Neat trick I saw somewhere to avoid div/0.\n\tp.Mult(1.0 / (p.Length() + f.FloatMin))\n}", "func fritsch(w, x float64) float64 {\n\tz := math.Log(x/w) - w\n\tw1 := w + 1\n\tq := 2 * w1 * (w1 + 2*z/3)\n\teps := z / w1 * (q - z) / (q - 2*z)\n\treturn w * (1 + eps)\n}", "func F(x int) {\n\t// fmt.Printf(\"f(%d)\\n\", x+0/x)\n\n\tdefer fmt.Printf(\"defer f(%d)\\n\", x)\n\n\tF(x - 1)\n}", "func (m mathUtil) Normalize(values ...float64) []float64 {\n\tvar total float64\n\tfor _, v := range values {\n\t\ttotal += v\n\t}\n\toutput := make([]float64, len(values))\n\tfor x, v := range values {\n\t\toutput[x] = m.RoundDown(v/total, 0.0001)\n\t}\n\treturn output\n}", "func (z *Float) Neg(x *Float) *Float {}", "func (me TPositiveFloatType) ToXsdtFloat() xsdt.Float { return xsdt.Float(me) }", "func Ceil(x float64) float64 {\n\n\treturn math.Ceil(x)\n}", "func FloatSign(x *big.Float,) int", "func (fn *formulaFuncs) FLOORdotPRECISE(argsList *list.List) formulaArg {\n\tif argsList.Len() == 0 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"FLOOR.PRECISE requires at least 1 argument\")\n\t}\n\tif argsList.Len() > 2 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"FLOOR.PRECISE allows at most 2 arguments\")\n\t}\n\tvar significance float64\n\tnumber := argsList.Front().Value.(formulaArg).ToNumber()\n\tif number.Type == ArgError {\n\t\treturn number\n\t}\n\tif number.Number < 0 {\n\t\tsignificance = -1\n\t}\n\tif argsList.Len() == 1 {\n\t\treturn newNumberFormulaArg(math.Floor(number.Number))\n\t}\n\tif argsList.Len() > 1 {\n\t\ts := argsList.Back().Value.(formulaArg).ToNumber()\n\t\tif s.Type == ArgError {\n\t\t\treturn s\n\t\t}\n\t\tsignificance = s.Number\n\t\tsignificance = math.Abs(significance)\n\t\tif significance == 0 {\n\t\t\treturn newNumberFormulaArg(significance)\n\t\t}\n\t}\n\tval, res := math.Modf(number.Number / significance)\n\tif res != 0 {\n\t\tif number.Number < 0 {\n\t\t\tval--\n\t\t}\n\t}\n\treturn newNumberFormulaArg(val * significance)\n}" ]
[ "0.6883881", "0.6752622", "0.6596779", "0.64890045", "0.6346826", "0.61972183", "0.60241574", "0.59341407", "0.5816053", "0.5804506", "0.5782765", "0.57764965", "0.57527107", "0.5731127", "0.56980056", "0.5691231", "0.56818634", "0.5680122", "0.5662104", "0.5647177", "0.5628769", "0.5615693", "0.5611032", "0.5601808", "0.5582259", "0.55698645", "0.556255", "0.5528165", "0.54181665", "0.5407833", "0.5392608", "0.53907245", "0.53483546", "0.5315031", "0.53036124", "0.5298832", "0.5293576", "0.5282163", "0.5265522", "0.5262463", "0.523855", "0.5220386", "0.521974", "0.51961035", "0.51961035", "0.51799077", "0.51674235", "0.51583207", "0.51453084", "0.5138219", "0.5133651", "0.512111", "0.51174855", "0.5115304", "0.5109287", "0.51055634", "0.5103259", "0.50845456", "0.50830495", "0.50822335", "0.5061201", "0.5054905", "0.5052695", "0.5051784", "0.5047795", "0.50411487", "0.50348884", "0.50309914", "0.5017037", "0.5013408", "0.50101477", "0.5000627", "0.49956152", "0.4993449", "0.49902734", "0.49901465", "0.49864557", "0.49842584", "0.49823782", "0.4979318", "0.49759856", "0.49754107", "0.49708417", "0.49696702", "0.49687198", "0.4957961", "0.49572894", "0.49557063", "0.49557063", "0.49557063", "0.49439928", "0.494165", "0.49389878", "0.49307206", "0.49288297", "0.49155474", "0.4914837", "0.49139372", "0.49126208", "0.49060246" ]
0.761743
0
The Listener should reset the temporary error retry delay after a successful Accept.
Слушатель должен сбросить временный задержку повторной попытки после успешного Accept.
func TestAcceptRetryTemporaryReset(t *testing.T) { // the accepted connection conn := &testutils.MockConn{} // the listener that fails with temporary errors, accepts one, // and fails again with temporary errors to check the reset // of the temporary errors delay listener := &testutils.MockListener{ AcceptFunc: func(i int) (net.Conn, error) { if i < 5 { return nil, testutils.ErrTemporaryTrue } if i == 5 { return conn, nil } if i < 10 { return nil, testutils.ErrTemporaryTrue } return nil, io.EOF }, } server := &RetryServer{ Listener: listener, Dispatch: nopDispatch, } ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() start := time.Now() if err := server.Serve(ctx); errors.Cause(err) != io.EOF { t.Errorf("want io.EOF, got %v", err) } // retried 5 times for temporary errors: firstDelay := (5 + 10 + 20 + 40 + 80) * time.Millisecond // then 4 more times after a delay reset: secondDelay := (5 + 10 + 20 + 40) * time.Millisecond want := firstDelay + secondDelay got := time.Since(start) if got < want || got > (want+(100*time.Millisecond)) { t.Errorf("want duration of %v, got %v", want, got) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestAcceptRetryTemporary(t *testing.T) {\n\tlistener := &testutils.MockListener{\n\t\tAcceptFunc: func(i int) (net.Conn, error) {\n\t\t\tif i < 10 {\n\t\t\t\treturn nil, testutils.ErrTemporaryTrue\n\t\t\t}\n\t\t\treturn nil, io.EOF\n\t\t},\n\t}\n\tserver := &RetryServer{\n\t\tListener: listener,\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\n\tdefer cancel()\n\n\tstart := time.Now()\n\tif err := server.Serve(ctx); errors.Cause(err) != io.EOF {\n\t\tt.Errorf(\"want io.EOF, got %v\", err)\n\t}\n\n\t// retried 10 times for temporary errors, so the delays should be:\n\twant := (5 + 10 + 20 + 40 + 80 + 160 + 320 + 640 + 1000 + 1000) * time.Millisecond\n\tgot := time.Since(start)\n\tif got < want || got > (want+(100*time.Millisecond)) {\n\t\tt.Errorf(\"want duration of %v, got %v\", want, got)\n\t}\n}", "func TestLimitListenerError(t *testing.T) {\n\tdonec := make(chan bool, 1)\n\tgo func() {\n\t\tconst n = 2\n\t\tll := LimitListener(errorListener{}, n)\n\t\tfor i := 0; i < n+1; i++ {\n\t\t\t_, err := ll.Accept()\n\t\t\tif err != errFake {\n\t\t\t\tt.Fatalf(\"Accept error = %v; want errFake\", err)\n\t\t\t}\n\t\t}\n\t\tdonec <- true\n\t}()\n\tselect {\n\tcase <-donec:\n\tcase <-time.After(5 * time.Second):\n\t\tt.Fatal(\"timeout. deadlock?\")\n\t}\n}", "func TestNoRetryTemporaryFalse(t *testing.T) {\n\tlistener := &testutils.MockListener{\n\t\tAcceptFunc: func(i int) (net.Conn, error) {\n\t\t\treturn nil, testutils.ErrTemporaryFalse\n\t\t},\n\t}\n\tserver := &RetryServer{\n\t\tListener: listener,\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\n\tdefer cancel()\n\n\tstart := time.Now()\n\tif err := server.Serve(ctx); errors.Cause(err) != testutils.ErrTemporaryFalse {\n\t\tt.Errorf(\"want %v, got %v\", testutils.ErrTemporaryFalse, err)\n\t}\n\n\t// error was a Temporary, but it returned false, so there should\n\t// be no delay\n\tgot := time.Since(start)\n\twant := time.Duration(0)\n\tif got < want || got > (want+(10*time.Millisecond)) {\n\t\tt.Errorf(\"want duration of %v, got %v\", want, got)\n\t}\n}", "func (b *MaxRetryBackOff) Reset() { b.tries = 0 }", "func (l *LimitListenerError) Temporary() bool { return true }", "func TestSignerRemoteRetryTCPOnly(t *testing.T) {\n\tvar (\n\t\tattemptCh = make(chan int)\n\t\tretries = 2\n\t)\n\n\tln, err := net.Listen(\"tcp\", \"127.0.0.1:0\")\n\trequire.NoError(t, err)\n\n\tgo func(ln net.Listener, attemptCh chan<- int) {\n\t\tattempts := 0\n\n\t\tfor {\n\t\t\tconn, err := ln.Accept()\n\t\t\trequire.NoError(t, err)\n\n\t\t\terr = conn.Close()\n\t\t\trequire.NoError(t, err)\n\n\t\t\tattempts++\n\n\t\t\tif attempts == retries {\n\t\t\t\tattemptCh <- attempts\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}(ln, attemptCh)\n\n\tserviceEndpoint := NewSignerServiceEndpoint(\n\t\tlog.TestingLogger(),\n\t\tcmn.RandStr(12),\n\t\ttypes.NewMockPV(),\n\t\tDialTCPFn(ln.Addr().String(), testTimeoutReadWrite, ed25519.GenPrivKey()),\n\t)\n\tdefer serviceEndpoint.Stop()\n\n\tSignerServiceEndpointTimeoutReadWrite(time.Millisecond)(serviceEndpoint)\n\tSignerServiceEndpointConnRetries(retries)(serviceEndpoint)\n\n\tassert.Equal(t, serviceEndpoint.Start(), ErrDialRetryMax)\n\n\tselect {\n\tcase attempts := <-attemptCh:\n\t\tassert.Equal(t, retries, attempts)\n\tcase <-time.After(100 * time.Millisecond):\n\t\tt.Error(\"expected remote to observe connection attempts\")\n\t}\n}", "func (c *Client) handleRefreshError() {\n\tif c.state != StateConnected {\n\t\treturn\n\t}\n\tc.refreshTimer = time.AfterFunc(10*time.Second, c.sendRefresh)\n}", "func (m *Message) Retry() {\n\tm.Trial++\n}", "func (l *LimitListenerError) Timeout() bool { return true }", "func (e *Opener) ErrTimeout(now time.Time, duration time.Duration) {\n\te.legitimateAttemptsCount.Inc(now)\n\te.errorsCount.Inc(now)\n}", "func TestUploadAcceptFailedClientConnectTimeout(t *testing.T) {\n\t// prepare share service parameter\n\tlocalNodeId := uuid.New()\n\tsenderChan := make(chan data.ShareCommand)\n\tsender := NewShareSender(senderChan)\n\n\t// prepare dirs\n\tdownloadDir, base := prepareDirs(t)\n\tdefer os.RemoveAll(downloadDir)\n\tdefer os.RemoveAll(base)\n\n\tmaxUploads := 1\n\tuploader := NewShareUploader(localNodeId, maxUploads, sender)\n\n\t// prepare shared file\n\tsf := createSharedFile(t, base)\n\tdefer os.Remove(sf.FilePath())\n\n\t// prepare download request of unknown chunk\n\tnodeId := uuid.New().String()\n\tchunkChecksum := sf.LocalChunksChecksums()[0]\n\n\t// start message reader for message\n\tdone := make(chan bool)\n\tgo failConnectClient(t, done, senderChan)\n\n\t// call receivedDownloadRequest method\n\tuploader.Upload(sf, chunkChecksum, nodeId, filepath.Join(downloadDir, sf.FileRelativePath()))\n\n\t// wait for message\n\t<-done\n\n\t// start message reader for message\n\tgo uploadAccept(t, done, senderChan)\n\n\t// check wether upload token was released and subsequent requests get handled\n\tuploader.Upload(sf, chunkChecksum, nodeId, filepath.Join(downloadDir, sf.FileRelativePath()))\n\n\t// wait for message\n\t<-done\n}", "func (sender *MessageSender) Retry(msgRetry *MessageRetry) {\n\tfor {\n\t\ttime.Sleep(RetryIntervalInSec * time.Second)\n\n\t\tif msgRetry.retryCount >= sender.retryTimes {\n\t\t\t// Retried enough times\n\t\t\treturn\n\t\t}\n\n\t\tmsgRetry.isActiveMutex.Lock()\n\t\tif !msgRetry.isActive {\n\t\t\tmsgRetry.isActiveMutex.Unlock()\n\t\t\t// Retry is stopped\n\t\t\treturn\n\t\t}\n\t\tmsgRetry.isActiveMutex.Unlock()\n\n\t\tif msgRetry.msgType != msg_pb.MessageType_COMMITTED {\n\t\t\tsender.blockNumMutex.Lock()\n\t\t\tif msgRetry.blockNum < sender.blockNum {\n\t\t\t\tsender.blockNumMutex.Unlock()\n\t\t\t\t// Block already moved ahead, no need to retry old block's messages\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsender.blockNumMutex.Unlock()\n\t\t}\n\n\t\tmsgRetry.retryCount++\n\t\tif err := sender.host.SendMessageToGroups(msgRetry.groups, msgRetry.p2pMsg); err != nil {\n\t\t\tutils.Logger().Warn().Str(\"groupID[0]\", msgRetry.groups[0].String()).Uint64(\"blockNum\", msgRetry.blockNum).Str(\"MsgType\", msgRetry.msgType.String()).Int(\"RetryCount\", msgRetry.retryCount).Msg(\"[Retry] Failed re-sending consensus message\")\n\t\t} else {\n\t\t\tutils.Logger().Info().Str(\"groupID[0]\", msgRetry.groups[0].String()).Uint64(\"blockNum\", msgRetry.blockNum).Str(\"MsgType\", msgRetry.msgType.String()).Int(\"RetryCount\", msgRetry.retryCount).Msg(\"[Retry] Successfully resent consensus message\")\n\t\t}\n\t}\n}", "func (r *RetryPolicy) Reset() {\n\tr.retryCount = atomic.NewUint32(0)\n}", "func retryTimeout(ctx context.Context, retryInterval time.Duration, check func(ctx context.Context) error) {\n\n\tfor {\n\t\tfmt.Println(\"perform user check call\")\n\t\tif err := check(ctx); err == nil {\n\t\t\tfmt.Println(\"work finished successfully\")\n\t\t\treturn\n\t\t}\n\n\t\tfmt.Println(\"check if timeout has expired\")\n\t\tif ctx.Err() != nil {\n\t\t\tfmt.Println(\"time expired 1 :\", ctx.Err())\n\t\t\treturn\n\t\t}\n\n\t\tfmt.Printf(\"wait %s before trying again\\n\", retryInterval)\n\t\tt := time.NewTimer(retryInterval)\n\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tfmt.Println(\"timed expired 2 :\", ctx.Err())\n\t\t\tt.Stop()\n\t\t\treturn\n\t\tcase <-t.C:\n\t\t\tfmt.Println(\"retry again\")\n\t\t}\n\t}\n}", "func (s *Server) Accept() error {\n\tvar tempDelay time.Duration // how long to sleep on accept failure\n\tfor {\n\t\tc, e := s.Listener.Accept()\n\t\tif e != nil {\n\t\t\tif ne, ok := e.(net.Error); ok && ne.Temporary() {\n\t\t\t\tif tempDelay == 0 {\n\t\t\t\t\ttempDelay = 5 * time.Millisecond\n\t\t\t\t} else {\n\t\t\t\t\ttempDelay *= 2\n\t\t\t\t}\n\t\t\t\tif max := 1 * time.Second; tempDelay > max {\n\t\t\t\t\ttempDelay = max\n\t\t\t\t}\n\t\t\t\ttime.Sleep(tempDelay)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn e\n\t\t}\n\t\tgo s.accept(c)\n\t}\n}", "func (ti *testItem) retry() {\n\t// release it to make it available for somebody else to try later:\n\t<-ti.take\n}", "func (m *Manager) listenAborted() chan struct{} {\n\treturn m.state.doneCh\n}", "func (r *FailBack) errorFrom(i int) {\n\tr.mu.Lock()\n\tdefer r.mu.Unlock()\n\tif i != r.active {\n\t\treturn\n\t}\n\tif r.failCh == nil { // lazy start the reset timer\n\t\tr.failCh = r.startResetTimer()\n\t}\n\tr.active = (r.active + 1) % len(r.resolvers)\n\tLog.WithFields(logrus.Fields{\n\t\t\"id\": r.id,\n\t\t\"resolver\": r.resolvers[r.active].String(),\n\t}).Debug(\"failing over to resolver\")\n\tr.metrics.failover.Add(1)\n\tr.metrics.available.Add(-1)\n\tr.failCh <- struct{}{} // signal the timer to wait some more before switching back\n}", "func (plm *PLM) retry(packet *Packet, retries int) (ack *Packet, err error) {\n\tplm.Lock()\n\tdefer plm.Unlock()\n\n\tfor err == ErrNak || retries > 0 {\n\t\tack, err = plm.tx(packet, time.Second)\n\t\tif err == nil {\n\t\t\tbreak\n\t\t}\n\t\tretries--\n\t}\n\n\tif err == ErrNak {\n\t\tinsteon.Log.Debugf(\"Retry count exceeded\")\n\t\terr = ErrRetryCountExceeded\n\t}\n\treturn ack, err\n}", "func (b *Backoff) Reset() {\n\tb.lastTry = time.Time{}\n\tb.n = 0\n}", "func (n *Sub) retry(uri *model.NotifyURL, msg string, source int) (err error) {\n\tlog.Info(\"Notify.retry do callback url(%v), msg(%s), source(%d)\", uri, msg, source)\n\tfor i := 0; i < _retry; i++ {\n\t\terr = n.clients.Post(context.TODO(), uri, msg)\n\t\tif err != nil {\n\t\t\ttime.Sleep(n.backoff.Backoff(i))\n\t\t\tcontinue\n\t\t} else {\n\t\t\tlog.Info(\"Notify.retry callback success group(%s), topic(%s), retry(%d), msg(%s), source(%d)\",\n\t\t\t\tn.w.Group, n.w.Topic, i, msg, source)\n\t\t\treturn\n\t\t}\n\t}\n\tif err != nil {\n\t\tlog.Error(\"Notify.retry callback error(%v), uri(%s), msg(%s), source(%d)\",\n\t\t\terr, uri, msg, source)\n\t}\n\treturn\n}", "func (e *errorMixin) resetError() {\n\te.once = &sync.Once{}\n\te.wg = &sync.WaitGroup{}\n\te.wg.Add(1)\n}", "func (c *Authorized) applyRetryWait(retryCount int) {\n\ttime.Sleep(time.Duration(c.retrySettings.MinMsBetweenRetries) * time.Millisecond)\n}", "func retryDNSHandler(t *testing.T, w dns.ResponseWriter, r *dns.Msg, s *dnsTestServer, invertAnswers bool) {\n\tif time.Now().Sub(startTime).Seconds() > 3 {\n\t\tdoDNSAnswer(t, w, r, s.DNSDatabaseRetry, invertAnswers)\n\t} else {\n\t\tdoDNSAnswer(t, w, r, s.DNSDatabase, invertAnswers)\n\t}\n}", "func Retry(attempts int, timeout time.Duration, callback func() error) (err error) {\n\tfor i := 0; i <= attempts-1; i++ {\n\t\terr = callback()\n\t\tif err == nil {\n\t\t\treturn nil\n\t\t}\n\n\t\t//time.Sleep(timeout)\n\t\t<-time.After(timeout)\n\t\tlog.Println(\"retrying...\")\n\t}\n\treturn fmt.Errorf(\"after %d attempts, last error: %s\", attempts, err)\n}", "func (cm *ConnectionManager) RetryConnect() {\n\tif cm.funds.Cmp(utils.BigInt0) <= 0 {\n\t\treturn\n\t}\n\tif cm.leaveState() {\n\t\treturn\n\t}\n\tcm.lock.Lock()\n\tdefer cm.lock.Unlock()\n\tif cm.fundsRemaining().Cmp(utils.BigInt0) <= 0 {\n\t\treturn\n\t}\n\tif len(cm.openChannels()) >= int(cm.initChannelTarget) {\n\t\treturn\n\t}\n\t//try to fullfill our connection goal\n\terr := cm.addNewPartners()\n\tif err != nil {\n\t\tlog.Error(fmt.Sprintf(\"addNewPartners err %s\", err))\n\t}\n}", "func (rw *RetryWatcher) receive() {\n\tdefer close(rw.doneChan)\n\tdefer close(rw.resultChan)\n\n\tklog.V(4).Info(\"Starting RetryWatcher.\")\n\tdefer klog.V(4).Info(\"Stopping RetryWatcher.\")\n\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\tgo func() {\n\t\tselect {\n\t\tcase <-rw.stopChan:\n\t\t\tcancel()\n\t\t\treturn\n\t\tcase <-ctx.Done():\n\t\t\treturn\n\t\t}\n\t}()\n\n\t// We use non sliding until so we don't introduce delays on happy path when WATCH call\n\t// timeouts or gets closed and we need to reestablish it while also avoiding hot loops.\n\twait.NonSlidingUntilWithContext(ctx, func(ctx context.Context) {\n\t\tdone, retryAfter := rw.doReceive()\n\t\tif done {\n\t\t\tcancel()\n\t\t\treturn\n\t\t}\n\n\t\ttimer := time.NewTimer(retryAfter)\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\ttimer.Stop()\n\t\t\treturn\n\t\tcase <-timer.C:\n\t\t}\n\n\t\tklog.V(4).Infof(\"Restarting RetryWatcher at RV=%q\", rw.lastResourceVersion)\n\t}, rw.minRestartDelay)\n}", "func (message *Message) Retry(err error) {\n\tif message == nil {\n\t\treturn\n\t}\n\n\tmessage.resolve(err)\n}", "func Retry(ctx context.Context, times int, delay time.Duration, callback func() error) error {\n\t// Retries n-1 times and ignores failures. Only return early on success.\n\tfor i := 1; (i < times || times < 0) && ctx.Err() == nil; i++ {\n\t\tif err := callback(); err == nil {\n\t\t\treturn nil\n\t\t}\n\n\t\ttime.Sleep(delay)\n\t}\n\n\t// The last error (if any) is the one to keep.\n\treturn callback()\n}", "func (peer *Peer) ResetRetryTimes() {\n\tpeer.RetryTimes = 0\n\tlogger.Debug(\"Reset retry times of %v\", peer.Addr)\n}", "func TestUploadAcceptFailedSendingResult(t *testing.T) {\n\t// prepare share service parameter\n\tlocalNodeId := uuid.New()\n\tsenderChan := make(chan data.ShareCommand)\n\tsender := NewShareSender(senderChan)\n\n\t// prepare dirs\n\tdownloadDir, base := prepareDirs(t)\n\tdefer os.RemoveAll(downloadDir)\n\tdefer os.RemoveAll(base)\n\n\tmaxUploads := 1\n\tuploader := NewShareUploader(localNodeId, maxUploads, sender)\n\n\t// prepare shared file\n\tsf := createSharedFile(t, base)\n\tdefer os.Remove(sf.FilePath())\n\n\t// prepare download request of unknown chunk\n\tnodeId := uuid.New().String()\n\tchunkChecksum := sf.LocalChunksChecksums()[0]\n\n\t// start message reader for message\n\tdone := make(chan bool)\n\tgo failSendingUploadAccept(t, done, senderChan)\n\n\t// call receivedDownloadRequest method\n\tuploader.Upload(sf, chunkChecksum, nodeId, filepath.Join(downloadDir, sf.FileRelativePath()))\n\n\t// wait for message\n\t<-done\n\n\t// start message reader for message\n\t// expect download request result message with valid port number\n\tgo uploadAccept(t, done, senderChan)\n\n\t// check wether upload token was released and subsequent requests get handled\n\tuploader.Upload(sf, chunkChecksum, nodeId, filepath.Join(downloadDir, sf.FileRelativePath()))\n\n\t// wait for message\n\t<-done\n}", "func (m *MetricsRetryListener) Retried(req *http.Request, attempt int) {\n\tm.retryMetrics.RetriesCounter().With(\"backend\", m.backendName).Add(1)\n}", "func (c *Conn) Tempfail() {\n\tswitch c.curcmd {\n\tcase HELO, EHLO:\n\t\tc.reply(ReplyServiceNotAvailable)\n\tcase AUTH:\n\t\tc.authDone(false)\n\t\tc.reply(ReplyAuthTmpFail)\n\tcase MAILFROM, RCPTTO, DATA:\n\t\tc.reply(ReplyMailboxNotAvailable)\n\t}\n\tc.replied = true\n}", "func (t *tkgctl) restoreAfterSettingTimeout(currentTimeout time.Duration) func() {\n\tt.tkgClient.ConfigureTimeout(currentTimeout)\n\treturn func() {\n\t\tt.tkgClient.ConfigureTimeout(constants.DefaultOperationTimeout)\n\t}\n}", "func (rw *RetryWatcher) doReceive() (bool, time.Duration) {\n\twatcher, err := rw.watcherClient.Watch(metav1.ListOptions{\n\t\tResourceVersion: rw.lastResourceVersion,\n\t\tAllowWatchBookmarks: true,\n\t})\n\t// We are very unlikely to hit EOF here since we are just establishing the call,\n\t// but it may happen that the apiserver is just shutting down (e.g. being restarted)\n\t// This is consistent with how it is handled for informers\n\tswitch err {\n\tcase nil:\n\t\tbreak\n\n\tcase io.EOF:\n\t\t// watch closed normally\n\t\treturn false, 0\n\n\tcase io.ErrUnexpectedEOF:\n\t\tklog.V(1).InfoS(\"Watch closed with unexpected EOF\", \"err\", err)\n\t\treturn false, 0\n\n\tdefault:\n\t\tmsg := \"Watch failed\"\n\t\tif net.IsProbableEOF(err) || net.IsTimeout(err) {\n\t\t\tklog.V(5).InfoS(msg, \"err\", err)\n\t\t\t// Retry\n\t\t\treturn false, 0\n\t\t}\n\n\t\tklog.ErrorS(err, msg)\n\t\t// Retry\n\t\treturn false, 0\n\t}\n\n\tif watcher == nil {\n\t\tklog.ErrorS(nil, \"Watch returned nil watcher\")\n\t\t// Retry\n\t\treturn false, 0\n\t}\n\n\tch := watcher.ResultChan()\n\tdefer watcher.Stop()\n\n\tfor {\n\t\tselect {\n\t\tcase <-rw.stopChan:\n\t\t\tklog.V(4).InfoS(\"Stopping RetryWatcher.\")\n\t\t\treturn true, 0\n\t\tcase event, ok := <-ch:\n\t\t\tif !ok {\n\t\t\t\tklog.V(4).InfoS(\"Failed to get event! Re-creating the watcher.\", \"resourceVersion\", rw.lastResourceVersion)\n\t\t\t\treturn false, 0\n\t\t\t}\n\n\t\t\t// We need to inspect the event and get ResourceVersion out of it\n\t\t\tswitch event.Type {\n\t\t\tcase watch.Added, watch.Modified, watch.Deleted, watch.Bookmark:\n\t\t\t\tmetaObject, ok := event.Object.(resourceVersionGetter)\n\t\t\t\tif !ok {\n\t\t\t\t\t_ = rw.send(watch.Event{\n\t\t\t\t\t\tType: watch.Error,\n\t\t\t\t\t\tObject: &apierrors.NewInternalError(errors.New(\"retryWatcher: doesn't support resourceVersion\")).ErrStatus,\n\t\t\t\t\t})\n\t\t\t\t\t// We have to abort here because this might cause lastResourceVersion inconsistency by skipping a potential RV with valid data!\n\t\t\t\t\treturn true, 0\n\t\t\t\t}\n\n\t\t\t\tresourceVersion := metaObject.GetResourceVersion()\n\t\t\t\tif resourceVersion == \"\" {\n\t\t\t\t\t_ = rw.send(watch.Event{\n\t\t\t\t\t\tType: watch.Error,\n\t\t\t\t\t\tObject: &apierrors.NewInternalError(fmt.Errorf(\"retryWatcher: object %#v doesn't support resourceVersion\", event.Object)).ErrStatus,\n\t\t\t\t\t})\n\t\t\t\t\t// We have to abort here because this might cause lastResourceVersion inconsistency by skipping a potential RV with valid data!\n\t\t\t\t\treturn true, 0\n\t\t\t\t}\n\n\t\t\t\t// All is fine; send the non-bookmark events and update resource version.\n\t\t\t\tif event.Type != watch.Bookmark {\n\t\t\t\t\tok = rw.send(event)\n\t\t\t\t\tif !ok {\n\t\t\t\t\t\treturn true, 0\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trw.lastResourceVersion = resourceVersion\n\n\t\t\t\tcontinue\n\n\t\t\tcase watch.Error:\n\t\t\t\t// This round trip allows us to handle unstructured status\n\t\t\t\terrObject := apierrors.FromObject(event.Object)\n\t\t\t\tstatusErr, ok := errObject.(*apierrors.StatusError)\n\t\t\t\tif !ok {\n\t\t\t\t\tklog.Error(fmt.Sprintf(\"Received an error which is not *metav1.Status but %s\", dump.Pretty(event.Object)))\n\t\t\t\t\t// Retry unknown errors\n\t\t\t\t\treturn false, 0\n\t\t\t\t}\n\n\t\t\t\tstatus := statusErr.ErrStatus\n\n\t\t\t\tstatusDelay := time.Duration(0)\n\t\t\t\tif status.Details != nil {\n\t\t\t\t\tstatusDelay = time.Duration(status.Details.RetryAfterSeconds) * time.Second\n\t\t\t\t}\n\n\t\t\t\tswitch status.Code {\n\t\t\t\tcase http.StatusGone:\n\t\t\t\t\t// Never retry RV too old errors\n\t\t\t\t\t_ = rw.send(event)\n\t\t\t\t\treturn true, 0\n\n\t\t\t\tcase http.StatusGatewayTimeout, http.StatusInternalServerError:\n\t\t\t\t\t// Retry\n\t\t\t\t\treturn false, statusDelay\n\n\t\t\t\tdefault:\n\t\t\t\t\t// We retry by default. RetryWatcher is meant to proceed unless it is certain\n\t\t\t\t\t// that it can't. If we are not certain, we proceed with retry and leave it\n\t\t\t\t\t// up to the user to timeout if needed.\n\n\t\t\t\t\t// Log here so we have a record of hitting the unexpected error\n\t\t\t\t\t// and we can whitelist some error codes if we missed any that are expected.\n\t\t\t\t\tklog.V(5).Info(fmt.Sprintf(\"Retrying after unexpected error: %s\", dump.Pretty(event.Object)))\n\n\t\t\t\t\t// Retry\n\t\t\t\t\treturn false, statusDelay\n\t\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tklog.Errorf(\"Failed to recognize Event type %q\", event.Type)\n\t\t\t\t_ = rw.send(watch.Event{\n\t\t\t\t\tType: watch.Error,\n\t\t\t\t\tObject: &apierrors.NewInternalError(fmt.Errorf(\"retryWatcher failed to recognize Event type %q\", event.Type)).ErrStatus,\n\t\t\t\t})\n\t\t\t\t// We are unable to restart the watch and have to stop the loop or this might cause lastResourceVersion inconsistency by skipping a potential RV with valid data!\n\t\t\t\treturn true, 0\n\t\t\t}\n\t\t}\n\t}\n}", "func onNoReconnect(attempt int) {\n\tfmt.Printf(\"Maximum no of reconnect attempt reached: %d\", attempt)\n}", "func delayedOk(http.ResponseWriter, *http.Request, int) (int, error) {\n\ttime.Sleep(time.Second)\n\treturn 0, nil\n}", "func TestRetryTimerSimple(t *testing.T) {\n\tdoneCh := make(chan struct{})\n\tattemptCh := newRetryTimerSimple(doneCh)\n\ti := <-attemptCh\n\tif i != 0 {\n\t\tclose(doneCh)\n\t\tt.Fatalf(\"Invalid attempt counter returned should be 0, found %d instead\", i)\n\t}\n\ti = <-attemptCh\n\tif i <= 0 {\n\t\tclose(doneCh)\n\t\tt.Fatalf(\"Invalid attempt counter returned should be greater than 0, found %d instead\", i)\n\t}\n\tclose(doneCh)\n\t_, ok := <-attemptCh\n\tif ok {\n\t\tt.Fatal(\"Attempt counter should be closed\")\n\t}\n}", "func tryToHandleDriveAPIError(err error, ntries int) error {\n\tdebug.Printf(\"tryToHandleDriveAPIError: ntries %d error %T %+v\",\n\t\tntries, err, err)\n\n\tmaxAPIRetries := 6\n\tif ntries == maxAPIRetries {\n\t\treturn err\n\t}\n\tswitch err := err.(type) {\n\tcase *googleapi.Error:\n\t\tif err.Code == 401 {\n\t\t\t// After an hour, the OAuth2 token expires and needs to\n\t\t\t// be refreshed.\n\t\t\tdebug.Printf(\"Trying OAuth2 token refresh.\")\n\t\t\tif err := oAuthTransport.Refresh(); err == nil {\n\t\t\t\t// Success\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\t// Otherwise fall through to sleep/backoff...\n\t\t}\n\t}\n\n\texponentialBackoff(ntries, nil, err)\n\treturn nil\n}", "func checkAndResend(s *server, ConnID int) {\n\t// check the waitingForAckMessage to see if there is pending data to resend\n\tfor k, v := range s.clientMap[ConnID].waitingForAckMessage {\n\t\tif v.epochToSent == 0 {\n\t\t\tresendDataToClient(s, *s.clientMap[ConnID].waitingForAckMessage[k].message)\n\t\t\ts.clientMap[ConnID].currentEpochAction = true\n\t\t\t// reset the interval\n\t\t\tif s.params.MaxBackOffInterval == 0 {\n\t\t\t\ts.clientMap[ConnID].waitingForAckMessage[k].epochToSent = 0\n\t\t\t} else {\n\t\t\t\tcur := s.clientMap[ConnID].waitingForAckMessage[k].curInterval\n\t\t\t\tif cur == 0 {\n\t\t\t\t\tcur++\n\t\t\t\t} else {\n\t\t\t\t\tcur = cur * 2\n\t\t\t\t}\n\t\t\t\tif cur > s.params.MaxBackOffInterval {\n\t\t\t\t\tcur = s.params.MaxBackOffInterval\n\t\t\t\t}\n\t\t\t\ts.clientMap[ConnID].waitingForAckMessage[k].curInterval = cur\n\t\t\t}\n\t\t} else {\n\t\t\ts.clientMap[ConnID].waitingForAckMessage[k].epochToSent = s.clientMap[ConnID].waitingForAckMessage[k].epochToSent - 1\n\t\t}\n\t}\n\t// if currentEpochAction is false, then send ack(0) as required\n\tif s.clientMap[ConnID].currentEpochAction == false {\n\t\tif verbose {\n\t\t\tfmt.Printf(\" ACK0 to client:%v\\n\", ConnID)\n\t\t}\n\t\tsendAckToClient(s, ConnID, 0, s.clientMap[ConnID].clientAddressMap)\n\t}\n}", "func (pl *Peerlist) ResetRetryTimes(addr string) {\n\tpl.lock.Lock()\n\tdefer pl.lock.Unlock()\n\n\tif _, ok := pl.peers[addr]; ok {\n\t\tpl.peers[addr].ResetRetryTimes()\n\t\tpl.peers[addr].Seen()\n\t}\n}", "func runErrorListener(errChan chan error, mainErrChan chan error, cancel context.CancelFunc) {\n\terr := <-errChan\n\tif err != nil {\n\t\tmainErrChan <- err\n\t\tcancel()\n\t}\n}", "func retryRequest(r *http.Request) {\n\tlog.Println(\"Going to retry request with exponential back off\")\n\twait := Config.InitialRetryWait\n\tc := &http.Client{}\n\tfor i := 0; i < Config.MaxRetries; i++ {\n\t\tresp, _ := c.Do(r)\n\t\tif resp != nil && resp.StatusCode >= 200 && resp.StatusCode <= 299 {\n\t\t\tlog.Printf(\"Retry succeeded after: %d retries\\n\", i)\n\t\t\treturn\n\t\t}\n\t\twait *= 2\n\t\tlog.Printf(\"Retry failed, waiting for: %d ms before retrying again\\n\", wait)\n\t\t// I guess this could be done much better (non blocking) manner - with timer channel maybe..\n\t\ttime.Sleep(time.Duration(wait) * time.Millisecond)\n\t}\n\tlog.Printf(\"Reached max retries (%d), stopping\\n\", Config.MaxRetries)\n}", "func (s stdlib) RetryInterval(time.Duration) {}", "func (b *Backoff) Reset() {\n\tb.attempts = 0\n}", "func (rf *Raft) resetElectionTimeout() {\n\trf.electionTimeoutStartTime = time.Now()\n\t// randomize election timeout, 300~400ms\n\trf.electionTimeoutInterval = time.Duration(time.Millisecond * time.Duration(500+rand.Intn(300)))\n}", "func Retry(logger *logrusx.Logger, maxWait time.Duration, failAfter time.Duration, f func() error) (err error) {\n\tvar lastStart time.Time\n\terr = errors.New(\"did not connect\")\n\tloopWait := time.Millisecond * 100\n\tretryStart := time.Now().UTC()\n\tfor retryStart.Add(failAfter).After(time.Now().UTC()) {\n\t\tlastStart = time.Now().UTC()\n\t\tif err = f(); err == nil {\n\t\t\treturn nil\n\t\t}\n\n\t\tif lastStart.Add(maxWait * 2).Before(time.Now().UTC()) {\n\t\t\tretryStart = time.Now().UTC()\n\t\t}\n\n\t\tlogger.WithError(err).Infof(\"Retrying in %f seconds...\", loopWait.Seconds())\n\t\ttime.Sleep(loopWait)\n\t\tloopWait = loopWait * time.Duration(int64(2))\n\t\tif loopWait > maxWait {\n\t\t\tloopWait = maxWait\n\t\t}\n\t}\n\treturn err\n}", "func (e *ExpBackoff) Reset() {\n\te.mu.Lock()\n\te.attempts = 0\n\te.delay = e.config.MinDelay\n\te.mu.Unlock()\n}", "func (e *EvtFailureDetector) timeout() {\n\t// TODO(student): Implement timeout procedure\n\t// Based on Algorithm 2.7: Increasing Timeout at page 55\n\t//if alive ∩ suspected != ∅ then:\n\tif len(e.intersection(e.alive, e.suspected)) > 0 {\n\t\t//delay := delay +Δ;\n\t\te.delay = e.delay + e.delta\n\t}\n\t// forall p ∈ Π do\n\tfor _, nodeID := range e.nodeIDs {\n\t\t// if (p !∈ alive) ∧ (p !∈ suspected) then\n\t\tif e.inAlive(nodeID) == false && e.inSuspected(nodeID) == false {\n\t\t\t//suspected := suspected ∪{p};\n\t\t\te.suspected[nodeID] = true\n\t\t\t//trigger P, Suspect | p;\n\t\t\te.sr.Suspect(nodeID)\n\t\t\t//else if (p ∈ alive) ∧ (p ∈ suspected) then\n\t\t} else if e.inAlive(nodeID) && e.inSuspected(nodeID) {\n\t\t\t//suspected := suspected \\{p};\n\t\t\tdelete(e.suspected, nodeID)\n\t\t\t//e.suspected[nodeID] = false\n\t\t\t//trigger P, Restore | p;\n\t\t\te.sr.Restore(nodeID)\n\t\t}\n\t\t//trigger pl, Send | p, [HEARTBEATREQUEST];\n\t\thbReq := Heartbeat{From: e.id, To: nodeID, Request: true}\n\t\te.hbSend <- hbReq\n\t}\n\t//alive := ∅;\n\temptyAlive := make(map[int]bool)\n\te.alive = emptyAlive\n\t//starttimer(delay);\n\te.timeoutSignal.Stop()\n\te.timeoutSignal = time.NewTicker(e.delay)\n}", "func (n *noBackoff) Reset() {}", "func (r *FailBack) startResetTimer() chan struct{} {\n\tfailCh := make(chan struct{}, 1)\n\tgo func() {\n\t\ttimer := time.NewTimer(r.opt.ResetAfter)\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-failCh:\n\t\t\t\tif !timer.Stop() {\n\t\t\t\t\t<-timer.C\n\t\t\t\t}\n\t\t\tcase <-timer.C:\n\t\t\t\tr.mu.Lock()\n\t\t\t\tr.active = 0\n\t\t\t\tLog.WithField(\"resolver\", r.resolvers[r.active].String()).Debug(\"failing back to resolver\")\n\t\t\t\tr.mu.Unlock()\n\t\t\t\tr.metrics.available.Add(1)\n\t\t\t\t// we just reset to the first resolver, let's wait for another failure before running again\n\t\t\t\t<-failCh\n\t\t\t}\n\t\t\ttimer.Reset(r.opt.ResetAfter)\n\t\t}\n\t}()\n\treturn failCh\n}", "func TestConcurrentAccept(t *testing.T) {\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\n\tp1 := tu.RandPeerNetParamsOrFatal(t)\n\n\tl1, err := Listen(ctx, p1.Addr, p1.ID, p1.PrivKey)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tn := 300\n\tdelay := time.Millisecond * 20\n\tif runtime.GOOS == \"darwin\" {\n\t\tn = 100\n\t}\n\n\tp1.Addr = l1.Multiaddr() // Addr has been determined by kernel.\n\n\tvar wg sync.WaitGroup\n\tfor i := 0; i < n; i++ {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tcon, err := net.Dial(\"tcp\", l1.Addr().String())\n\t\t\tif err != nil {\n\t\t\t\tlog.Error(err)\n\t\t\t\tt.Error(\"first dial failed: \", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// hang this connection\n\t\t\tdefer con.Close()\n\n\t\t\ttime.Sleep(delay)\n\t\t\terr = msmux.SelectProtoOrFail(SecioTag, con)\n\t\t\tif err != nil {\n\t\t\t\tt.Error(err)\n\t\t\t}\n\t\t}()\n\t}\n\n\tbefore := time.Now()\n\tfor i := 0; i < n; i++ {\n\t\tc, err := l1.Accept()\n\t\tif err != nil {\n\t\t\tt.Fatal(\"connections after a failed accept should still work: \", err)\n\t\t}\n\n\t\tc.Close()\n\t}\n\n\tlimit := delay * time.Duration(n)\n\ttook := time.Since(before)\n\tif took > limit {\n\t\tt.Fatal(\"took too long!\")\n\t}\n\tlog.Errorf(\"took: %s (less than %s)\", took, limit)\n\tl1.Close()\n\twg.Wait()\n\tcancel()\n\n\ttime.Sleep(time.Millisecond * 100)\n\n\terr = grc.CheckForLeaks(goroFilter)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n}", "func (r *CustomRetrier) Retry(\n\tctx context.Context,\n\tretry int,\n\treq *http.Request,\n\tresp *http.Response,\n\terr error) (time.Duration, bool, error) {\n\t// Fail hard on a specific error\n\tif err == syscall.ECONNREFUSED {\n\t\treturn 0, false, errors.New(\"elasticsearch or network down\")\n\t}\n\n\t// Stop after 5 retries\n\tif retry >= 5 {\n\t\treturn 0, false, nil\n\t}\n\n\t// Let the backoff strategy decide how long to wait and whether to stop\n\twait, stop := r.backoff.Next(retry)\n\n\treturn wait, stop, nil\n}", "func retryFunc(timeout time.Duration, f func() error) error {\n\tfinish := time.After(timeout)\n\tfor {\n\t\terr := f()\n\t\tif err == nil {\n\t\t\treturn nil\n\t\t}\n\t\tlog.Printf(\"Retryable error: %v\", err)\n\n\t\tselect {\n\t\tcase <-finish:\n\t\t\treturn err\n\t\tcase <-time.After(3 * time.Second):\n\t\t}\n\t}\n}", "func (r *CustomRetrier) Retry(\n\tctx context.Context,\n\tretry int,\n\treq *http.Request,\n\tresp *http.Response,\n\terr error) (time.Duration, bool, error) {\n\t// Fail hard on a specific error\n\tif err == syscall.ECONNREFUSED {\n\t\treturn 0, false, errors.New(\"Elasticsearch or network down\")\n\t}\n\n\t// Stop after 5 retries\n\tif retry >= 5 {\n\t\treturn 0, false, nil\n\t}\n\n\t// Let the backoff strategy decide how long to wait and whether to stop\n\twait, stop := r.backoff.Next(retry)\n\treturn wait, stop, nil\n}", "func (l *RstListener) Accept() (net.Conn, error) {\n\tconn, err := l.l.Accept()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttcpConn, ok := conn.(*net.TCPConn)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"Expected a TCP connection\")\n\t}\n\n\terr = tcpConn.SetLinger(0)\n\tif err != nil {\n\t\tfmt.Printf(\"get error before sending rst: %v\", err)\n\t}\n\treturn conn, err\n}", "func (c *Connect) setRTimeout() {\n\tif c.readTimeout != 0 {\n\t\tc.nc.SetReadDeadline(time.Now().Add(c.readTimeout))\n\t}\n}", "func (cc *Client) processRetryChan() {\n\tdefer cc.wg.Done()\n\tfor {\n\t\tselect {\n\t\tcase <-cc.ctx.Done(): // client is shutdown\n\t\t\treturn\n\t\tcase r := <-cc.retryChan:\n\t\t\tif r.ctx.Err() != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tselect {\n\t\t\tcase <-time.After(time.Until(r.sendAt)): // wait and resend the request\n\t\t\t\tatomic.AddInt64(&cc.TotalRetriedUpdates, int64(1))\n\t\t\t\tcc.makeRequest(r)\n\t\t\tcase <-r.ctx.Done(): // request is cancelled\n\t\t\t\tcontinue\n\t\t\tcase <-cc.ctx.Done(): // client is shutdown\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}", "func (collector *Collector) resetTimeout() {\n\t// We only need to do something if there actually is a ticker (ie: if an interval was specified)\n\tif collector.ticker != nil {\n\t\t// Stop the ticker so it can be garbage collected\n\t\tcollector.ticker.Stop()\n\n\t\t// From everything I've read the only real way to reset a ticker is to recreate it\n\t\tcollector.ticker = time.NewTicker(collector.config.Timeout.Interval)\n\t\tcollector.timeoutChannel = collector.ticker.C\n\t}\n}", "func (w *filePoller) sendErr(e error, chClose <-chan struct{}) error {\n\tselect {\n\tcase w.errors <- e:\n\tcase <-chClose:\n\t\treturn fmt.Errorf(\"closed\")\n\t}\n\treturn nil\n}", "func (r *Retrier) RunRetry() error {\n\t// Start signal handler.\n\tsigHandler := signals.NewSignalHandler(10)\n\tgo sigHandler.Register()\n\n\tfinish := make(chan bool, 1)\n\tgo func() {\n\t\tselect {\n\t\tcase <-finish:\n\t\t\treturn\n\t\tcase <-time.After(10 * time.Second):\n\t\t\treturn\n\t\tdefault:\n\t\t\tfor {\n\t\t\t\tif sigHandler.GetState() != 0 {\n\t\t\t\t\tlogger.Critical(\"detected signal. retry failed.\")\n\t\t\t\t\tos.Exit(1)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\tfor i := 0; i < r.retries; i++ {\n\t\terr := r.retryable.Try()\n\t\tif err != nil {\n\t\t\tlogger.Info(\"Retryable error: %v\", err)\n\t\t\ttime.Sleep(time.Duration(r.sleepSeconds) * time.Second)\n\t\t\tcontinue\n\t\t}\n\t\tfinish <- true\n\t\treturn nil\n\t}\n\n\tfinish <- true\n\treturn fmt.Errorf(\"unable to succeed at retry after %d attempts at %d seconds\", r.retries, r.sleepSeconds)\n}", "func TestServer_ServeCanRetryMessages(t *testing.T) {\n\tmessages := []*msg.Message{\n\t\t{\n\t\t\tAttributes: msg.Attributes{},\n\t\t\tBody: bytes.NewBufferString(\"message #1: hello world!\"),\n\t\t},\n\t}\n\n\tsrv := mem.NewServer(make(chan *msg.Message, len(messages)), 1)\n\n\tfor _, m := range messages {\n\t\tsrv.C <- m\n\t}\n\tdefer close(srv.C)\n\n\toutputChannel := make(chan struct{})\n\tgo func() {\n\t\tsrv.Serve(&RetryReceiver{\n\t\t\tt: t,\n\t\t\tC: outputChannel,\n\n\t\t\tcalls: 0,\n\t\t\tallowedRetries: 10,\n\t\t})\n\t}()\n\n\t// after 10th retry receiver will write to channel\n\tctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)\n\tdefer cancel()\n\n\tselect {\n\tcase <-ctx.Done():\n\t\tt.Fatalf(\"context timed out\")\n\tcase <-outputChannel:\n\t\tclose(outputChannel)\n\t}\n}", "func (l *Listener) Reset() {\n\tl.ready = false\n\tl.readyChan = make(chan struct{})\n}", "func (g *Goer) resumeAccept() {\n\tswitch g.Transport {\n\tcase \"tcp\", \"tcp4\", \"tcp6\", \"unix\", \"unixpacket\", \"ssl\":\n\t\tg.acceptTCPConnection()\n\tcase \"udp\", \"upd4\", \"udp6\", \"unixgram\":\n\t\tg.acceptUDPConnection()\n\t}\n}", "func TestBackoffRecovers(t *testing.T) {\n\tb := &Backoff{}\n\tb.init(decayIntervalSeconds, decayFraction, maxDelay)\n\n\tnow := time.Now()\n\n\t// Phase of all-errors\n\tfor i := 0; i < 100; i++ {\n\t\t_ = b.ComputeDelayForRequest(now)\n\t\tb.ReportError()\n\t\tnow = now.Add(time.Second)\n\t}\n\n\tfor i := 0; i < 10; i++ {\n\t\td := b.ComputeDelayForRequest(now)\n\t\tb.ReportError()\n\t\tif d.Seconds() < 5 {\n\t\t\tt.Fatalf(\"unexpected short-delay during all-error phase: %v\", d)\n\t\t}\n\t\tt.Logf(\"error phase delay @%d %v\", i, d)\n\t\tnow = now.Add(time.Second)\n\t}\n\n\t// Phase of no errors\n\tfor i := 0; i < 100; i++ {\n\t\t_ = b.ComputeDelayForRequest(now)\n\t\tnow = now.Add(3 * time.Second)\n\t}\n\n\tfor i := 0; i < 10; i++ {\n\t\td := b.ComputeDelayForRequest(now)\n\t\tif d.Seconds() != 0 {\n\t\t\tt.Fatalf(\"unexpected delay during error recovery phase: %v\", d)\n\t\t}\n\t\tt.Logf(\"no-error phase delay @%d %v\", i, d)\n\t\tnow = now.Add(time.Second)\n\t}\n}", "func reuseErrShouldRetry(err error) bool {\n\tif err == nil {\n\t\treturn false // hey, it worked! no need to retry.\n\t}\n\n\t// if it's a network timeout error, it's a legitimate failure.\n\tif nerr, ok := err.(net.Error); ok && nerr.Timeout() {\n\t\treturn false\n\t}\n\n\terrno, ok := err.(syscall.Errno)\n\tif !ok { // not an errno? who knows what this is. retry.\n\t\treturn true\n\t}\n\n\tswitch errno {\n\tcase syscall.EADDRINUSE, syscall.EADDRNOTAVAIL:\n\t\treturn true // failure to bind. retry.\n\tcase syscall.ECONNREFUSED:\n\t\treturn false // real dial error\n\tdefault:\n\t\treturn true // optimistically default to retry.\n\t}\n}", "func (t *ExponentialBackoff) Reset() {\n\tt.Lock()\n\tt.n = 0\n\tt.Unlock()\n}", "func (signaler *TestReconnectSignaler) WaitOnReconnect(ctx context.Context) {\n\tif ctx == nil {\n\t\tvar cancel context.CancelFunc\n\t\tctx, cancel = context.WithTimeout(context.Background(), 3*time.Second)\n\t\tdefer cancel()\n\t}\n\n\tfor signaler.original == signaler.manager.transport.underlyingTransport() {\n\t\tselect {\n\t\tcase <-signaler.reconnectSignal:\n\t\tcase <-ctx.Done():\n\t\t\tsignaler.tb.Fatalf(\n\t\t\t\t\"context cancelled before reconnection occurred: %v\", ctx.Err(),\n\t\t\t)\n\t\t}\n\t}\n}", "func runListener(cfg config, sigCh chan os.Signal) (resultError error) {\n\n\t// create listener\n\tln, err := net.Listen(\"tcp\", cfg.address)\n\tif err != nil {\n\t\tresultError = err\n\t\treturn\n\t}\n\n\t// for cancel connection handlers\n\tctx, cancelFunc := context.WithCancel(context.Background())\n\n\t// interruption/termination signal handler\n\tgo func() {\n\t\t<-sigCh // read interruption/termination signal\n\t\tcancelFunc() // for cancel connection handlers and accept loop\n\n\t\t// we must close listener here (not in defer), case Accept is blocking\n\t\terr := closeListener(ln)\n\t\tif err != nil {\n\t\t\tresultError = err\n\t\t}\n\t}()\n\n\t// on close lis we must wait for all\n\twg := &sync.WaitGroup{}\n\n\t// Accept connection loop\n\nLOOP:\n\tfor {\n\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tbreak LOOP\n\t\tdefault:\n\n\t\t\tconnection, err := ln.Accept()\n\n\t\t\t// accept error\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\tcancelFunc() // cancel connection handlers and accept loop\n\t\t\t\tcontinue LOOP // on next loop iteration we done\n\t\t\t}\n\n\t\t\t// accepted, inc wg for sync closing before return\n\t\t\tlog.Println(\"Connection accepted\")\n\t\t\twg.Add(1)\n\n\t\t\t// handle connection in goroutine\n\t\t\tgo func() {\n\n\t\t\t\terr := handleConn(ctx, cfg, connection)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Println(err)\n\t\t\t\t}\n\n\t\t\t\t// close connection after handler is done\n\t\t\t\terr = connection.Close()\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Println(\"Connection closed with error\", err)\n\t\t\t\t} else {\n\t\t\t\t\tlog.Println(\"Connection closed\")\n\t\t\t\t}\n\n\t\t\t\twg.Done()\n\t\t\t}()\n\t\t}\n\t}\n\n\twg.Wait()\n\n\treturn\n}", "func (cb *printcb) onRetry(context, err string) {\n\t// Reset data.\n\t*cb = []FileDetails{}\n}", "func (c *StreamerController) ReopenWithRetry(tctx *tcontext.Context, location binlog.Location) error {\n\tc.Lock()\n\tdefer c.Unlock()\n\n\tvar err error\n\tfor i := 0; i < maxRetryCount; i++ {\n\t\terr = c.resetReplicationSyncer(tctx, location)\n\t\tif err == nil {\n\t\t\treturn nil\n\t\t}\n\t\tif retry.IsConnectionError(err) {\n\t\t\ttctx.L().Info(\"fail to retry open binlog streamer\", log.ShortError(err))\n\t\t\ttime.Sleep(retryTimeout)\n\t\t\tcontinue\n\t\t}\n\t\tbreak\n\t}\n\treturn err\n}", "func (fd *failureDetector) timeout() {\n\tfd.logln(\"timeout\")\n\tfd.m.Lock()\n\tdefer fd.m.Unlock()\n\tif !fd.aliveSuspectedIntersectionEmpty() {\n\t\tfd.delay = fd.delay + fd.delta\n\t\tfd.logf(\"new delay %d\\n\", fd.delay)\n\t\tfd.timeoutSignal = time.NewTicker(fd.delay)\n\t}\n\tfor _, node := range fd.config.Nodes() {\n\t\tif !fd.alive[node] && !fd.suspected[node] {\n\t\t\tfd.suspected[node] = true\n\t\t\tfd.logf(\"suspect %v\\n\", node)\n\t\t\tfd.sr.Suspect(node)\n\t\t} else if fd.alive[node] && fd.suspected[node] {\n\t\t\tdelete(fd.suspected, node)\n\t\t\tfd.logf(\"restore %v\\n\", node)\n\t\t\tfd.sr.Restore(node)\n\t\t}\n\n\t\tfd.hbChan <- node\n\t}\n\tfd.logln(\"fd.alive\", fd.alive)\n\tfd.alive = make(map[*Node]bool)\n}", "func (c *backoffConfig) Reset() {\n\tc.attempt = 0\n}", "func (socketClientResponse *SocketClientResponse) sendBackoff(data []byte, i int) {\n\tif i > 1 {\n\t\tlog.Println(\"Retrying message send! Attempt:\", i)\n\t}\n\tif socketClientResponse.socketClient.Closed {\n\t\treturn\n\t}\n\n\tselect {\n\tcase socketClientResponse.socketClient.Data <- data:\n\t\treturn\n\tdefault:\n\t\ttime.Sleep(500 * time.Millisecond)\n\n\t\tif i > 5 {\n\t\t\treturn\n\t\t}\n\t\tsocketClientResponse.sendBackoff(data, i+1)\n\t}\n}", "func Test_Onu_DiscoverIndication_retry_on_discovery(t *testing.T) {\n\tonu := createTestOnu()\n\tstream := &mockStream{\n\t\tCallCount: 0,\n\t\tCalls: make(map[int]*openolt.Indication),\n\t\tfail: false,\n\t\tchannel: make(chan int, 10),\n\t}\n\tctx, cancel := context.WithCancel(context.TODO())\n\tgo onu.ProcessOnuMessages(ctx, stream, nil)\n\tonu.InternalState.SetState(OnuStateInitialized)\n\t_ = onu.InternalState.Event(OnuTxDiscover)\n\n\tselect {\n\tdefault:\n\tcase <-time.After(400 * time.Millisecond):\n\t\tassert.Equal(t, stream.CallCount, 4)\n\t}\n\tcancel()\n}", "func (b *Consecutive) Fail() {\n\tb.mutex.Lock()\n\tdefer b.mutex.Unlock()\n\n\tb.failures++\n\n\tif b.state == open {\n\t\treturn\n\t}\n\n\tif b.instantProvider == nil {\n\t\tb.instantProvider = systemTimer\n\t}\n\n\tif b.failures > b.FailureAllowance {\n\t\tb.nextClose = b.instantProvider.Now().Add(b.RetryTimeout)\n\t\tb.state = open\n\t}\n}", "func (c *Config) RetryEvent() <-chan struct{} {\n\tif c.RetryEventProvider != nil {\n\t\treturn c.RetryEventProvider()\n\t}\n\n\tch := make(chan struct{})\n\tgo func() {\n\t\ttime.Sleep(1)\n\t\tclose(ch)\n\t}()\n\treturn ch\n}", "func TestRetryAfterCount(t *testing.T) {\n\tconst attempts = 2\n\n\tvar (\n\t\treq, _ = http.NewRequest(\"GET\", \"http://example/test\", nil)\n\t\tnext = &testRoundTrip{err: fmt.Errorf(\"next\"), resp: nil}\n\t\ttrans = Transport{\n\t\t\tRetry: All(Errors(), Max(attempts)),\n\t\t\tNext: next,\n\t\t}\n\t)\n\n\tresp, err := trans.RoundTrip(req)\n\n\tif have, got := next.err.Error(), err.Error(); have == got {\n\t\tt.Fatalf(\"expected to override error from next\")\n\t}\n\n\tif want, got := attempts, next.count; want != got {\n\t\tt.Fatalf(\"expected to make %d attempts, got %d\", want, got)\n\t}\n\n\tif resp != nil {\n\t\tt.Fatalf(\"expected response to be nil since error is not nil\")\n\t}\n}", "func TestReAttachTCP(t *testing.T) {\n\ttestAttachNTimes(t, 3)\n}", "func (c *RetryController) triggerRetry() {\n\tif len(c.node.Actions) != 0 {\n\t\tc.node.Actions = []*workflow.Action{}\n\t\tclose(c.retryChannel)\n\t}\n\tc.node.BroadcastChanges(false /* updateChildren */)\n}", "func (g Gateway) OnAcceptError(err error) {\n\tlog.Warnf(\"OnAcceptError:%v\", err)\n}", "func (r ReliableTransport) poll(ready chan<- error) {\n\tlistener, err := r.relt.Consume()\n\tready <- err\n\tfor {\n\t\tselect {\n\t\tcase <-r.context.Done():\n\t\t\treturn\n\t\tcase recv, ok := <-listener:\n\t\t\tif !ok {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tr.consume(recv.Data, recv.Error)\n\t\t}\n\t}\n}", "func (s *streamMessageSender) multiAttempt(ctx context.Context, fn func() error) error {\n\t// Try to call the function repeatedly\n\tvar err error\n\tfor i := 0; i < s.opts.MaxRetries; i++ {\n\t\tif err = fn(); err == nil {\n\t\t\t// Attempt was successful\n\t\t\treturn nil\n\t\t}\n\n\t\t// Attempt failed\n\n\t\t// If the sender has been closed or the context cancelled, just bail out\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn ctx.Err()\n\t\tdefault:\n\t\t}\n\n\t\t// Protocol is not supported, so no need to try multiple times\n\t\tif errors.Is(err, multistream.ErrNotSupported) {\n\t\t\ts.bsnet.connectEvtMgr.MarkUnresponsive(s.to)\n\t\t\treturn err\n\t\t}\n\n\t\t// Failed to send so reset stream and try again\n\t\t_ = s.Reset()\n\n\t\t// Failed too many times so mark the peer as unresponsive and return an error\n\t\tif i == s.opts.MaxRetries-1 {\n\t\t\ts.bsnet.connectEvtMgr.MarkUnresponsive(s.to)\n\t\t\treturn err\n\t\t}\n\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn ctx.Err()\n\t\tcase <-time.After(s.opts.SendErrorBackoff):\n\t\t\t// wait a short time in case disconnect notifications are still propagating\n\t\t\tlog.Infof(\"send message to %s failed but context was not Done: %s\", s.to, err)\n\t\t}\n\t}\n\treturn err\n}", "func Retry(timeoutSeconds int, sleepSeconds int, try func() error) error {\n\tstart, err := time.Now(), try() // gurantees that it tries once regardless of timeout\n\ttime.Sleep(time.Duration(sleepSeconds) * time.Second) // all try calls are seperated by the sleep period\n\tfor err != nil && time.Since(start) < time.Duration(timeoutSeconds)*time.Second {\n\t\terr = try()\n\t\ttime.Sleep(time.Duration(sleepSeconds) * time.Second)\n\t}\n\treturn err\n}", "func clearErrno()", "func TestRetryTimerWithNoJitter(t *testing.T) {\n\tdoneCh := make(chan struct{})\n\t// No jitter\n\tattemptCh := newRetryTimerWithJitter(time.Millisecond, 5*time.Millisecond, NoJitter, doneCh)\n\ti := <-attemptCh\n\tif i != 0 {\n\t\tclose(doneCh)\n\t\tt.Fatalf(\"Invalid attempt counter returned should be 0, found %d instead\", i)\n\t}\n\t// Loop through the maximum possible attempt.\n\tfor i = range attemptCh {\n\t\tif i == 30 {\n\t\t\tclose(doneCh)\n\t\t}\n\t}\n\t_, ok := <-attemptCh\n\tif ok {\n\t\tt.Fatal(\"Attempt counter should be closed\")\n\t}\n}", "func (l *LexInner) Retry() {\n\tl.mark.pos = l.mark.start\n\tl.mark.width = 0\n}", "func Retry(callback func() error, retry int, sleep time.Duration) (err error) {\n\tfor i := 0; i < retry; i++ {\n\t\tif err = callback(); err == nil {\n\t\t\treturn\n\t\t}\n\t\ttime.Sleep(sleep)\n\t}\n\treturn\n}", "func (s *Socket) backoff() {\n\n\ts.lock.Unlock()\n\tdefer s.lock.Lock()\n\n\tduration := time.Duration(rand.Intn(MAX_RETRY_INTERVAL))\n\tlog.Debug(\"Backing off %d milliseconds.\", duration)\n\ttime.Sleep(duration * time.Millisecond)\n\n}", "func (suite *DetectorTestSuite) TestConfigureRetry() {\n\tok := registerMock(\"ok\", NodeRuntime)\n\tok.On(\"Detect\").Return(nil)\n\tnoRetry := registerMock(\"noretry\", NodeRuntime)\n\tnoRetry.On(\"Detect\").Return(errors.New(\"retry not implemented\"))\n\tfail := registerMock(\"fail\", NodeOrchestrator)\n\tfail.On(\"Detect\").Return(permaFailRetryError)\n\tretry := registerMock(\"retry\", NodeOrchestrator)\n\tretry.On(\"Detect\").Return(willRetryError).Once()\n\tretry.On(\"Detect\").Return(nil).Once()\n\n\td := NewDetector(\"\")\n\tassert.Len(suite.T(), d.candidates, 4)\n\tassert.Len(suite.T(), d.detected, 0)\n\n\t// First run detects ok and keeps retry as candidate\n\tc, n, err := d.GetPreferred()\n\tassert.NoError(suite.T(), err)\n\tassert.Equal(suite.T(), \"ok\", n)\n\tassert.Equal(suite.T(), ok, c)\n\tassert.Len(suite.T(), d.candidates, 1)\n\tassert.Len(suite.T(), d.detected, 1)\n\n\tok.AssertNumberOfCalls(suite.T(), \"Detect\", 1)\n\tnoRetry.AssertNumberOfCalls(suite.T(), \"Detect\", 1)\n\tfail.AssertNumberOfCalls(suite.T(), \"Detect\", 1)\n\tretry.AssertNumberOfCalls(suite.T(), \"Detect\", 1)\n\n\t// Second run detects retry and uses this one instead\n\tc, n, err = d.GetPreferred()\n\tassert.NoError(suite.T(), err)\n\tassert.Equal(suite.T(), \"retry\", n)\n\tassert.Equal(suite.T(), retry, c)\n\n\tok.AssertNumberOfCalls(suite.T(), \"Detect\", 1)\n\tnoRetry.AssertNumberOfCalls(suite.T(), \"Detect\", 1)\n\tfail.AssertNumberOfCalls(suite.T(), \"Detect\", 1)\n\tretry.AssertNumberOfCalls(suite.T(), \"Detect\", 2)\n\n\tassert.Nil(suite.T(), d.candidates)\n\tassert.Nil(suite.T(), d.detected)\n\n\t// Third run should be a noop\n\tc, n, err = d.GetPreferred()\n\tassert.NoError(suite.T(), err)\n\tassert.Equal(suite.T(), \"retry\", n)\n\tassert.Equal(suite.T(), retry, c)\n\n\tok.AssertNumberOfCalls(suite.T(), \"Detect\", 1)\n\tnoRetry.AssertNumberOfCalls(suite.T(), \"Detect\", 1)\n\tfail.AssertNumberOfCalls(suite.T(), \"Detect\", 1)\n\tretry.AssertNumberOfCalls(suite.T(), \"Detect\", 2)\n}", "func (a *ADMResponse) Retry() int {\n\treturn a.RetryAfter\n}", "func (tg *TradesGroup) listen() {\n\tgo func() {\n\t\tfor msg := range tg.bus.dch {\n\t\t\ttg.parseMessage(msg)\n\t\t}\n\t}()\n\tgo func() {\n\t\tfor err := range tg.bus.ech {\n\t\t\tlog.Printf(\"[BITFINEX] Error listen: %+v\", err)\n\t\t\ttg.restart()\n\t\t\treturn\n\t\t}\n\t}()\n}", "func (re *TCPLoop) Accepter(listen net.Listener) error {\n\n\tshuts := re.shutdown.Listen()\n\tgo func() {\n\t\tdefer func() {\n\t\t\tif listen != nil {\n\t\t\t\tlisten.Close()\n\t\t\t}\n\t\t}()\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-shuts.Ch:\n\t\t\t\tre.log.Warning(\"TCP Listener: Shutdown gotten .. stopping incoming connections\")\n\t\t\t\tlisten.Close()\n\t\t\t\tshuts.Close()\n\t\t\t\treturn\n\t\t\tdefault:\n\n\t\t\t}\n\n\t\t\tconn, err := listen.Accept()\n\t\t\tif err != nil {\n\t\t\t\tstats.StatsdClient.Incr(\"reader.tcp.incoming.failed.connections\", 1)\n\t\t\t\tre.log.Warning(\"Error Accecption Connection: %s\", err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tstats.StatsdClient.Incr(\"reader.tcp.incoming.connections\", 1)\n\t\t\t//server.log.Debug(\"Accepted connection from %s\", conn.RemoteAddr())\n\n\t\t\tre.AcceptChan <- conn\n\t\t}\n\t}()\n\treturn nil\n}", "func (client *BaseClient) Retry() int {\n\treturn client.retry\n}", "func (f *Sink) recoverFailed(endpoint *Endpoint) {\n\t// Ignore if we haven't failed\n\tif !endpoint.IsAlive() {\n\t\treturn\n\t}\n\n\tendpoint.mutex.Lock()\n\tendpoint.status = endpointStatusIdle\n\tendpoint.mutex.Unlock()\n\n\tf.failedList.Remove(&endpoint.failedElement)\n\tf.markReady(endpoint)\n}", "func RetryOnErr(\n\ti time.Duration,\n\tn int,\n\tfn func() (interface{}, error),\n) (r interface{}, err error) {\n\ttry := 1\n\tfor range time.Tick(i) {\n\t\tif try > n {\n\t\t\tbreak\n\t\t}\n\n\t\tif r, err = fn(); err == nil {\n\t\t\tbreak\n\t\t}\n\n\t\ttry++\n\t}\n\treturn r, err\n}", "func setuperror() chan error {\n\treturn make(chan error)\n}", "func retry(attempts int, sleep time.Duration, do func() error) error {\n\tvar err error\n\tfor i := 0; i < attempts; i++ {\n\t\tif err = do(); err == nil {\n\t\t\treturn nil\n\t\t}\n\t\ttime.Sleep(sleep)\n\t\tlog.Infof(\"retrying after error: %v\", err)\n\t}\n\treturn fmt.Errorf(\"failed after %d attempts; last error: %v\", attempts, err)\n}", "func (am *AccountManager) rescanListener() {\n\tfor msg := range am.rescanMsgs {\n\t\tAcctMgr.Grab()\n\t\tswitch e := msg.(type) {\n\t\tcase *RescanStartedMsg:\n\t\t\t// Log the newly-started rescan.\n\t\t\tn := 0\n\t\t\tfor _, addrs := range e.Addresses {\n\t\t\t\tn += len(addrs)\n\t\t\t}\n\t\t\tnoun := pickNoun(n, \"address\", \"addresses\")\n\t\t\tlog.Infof(\"Started rescan at height %d for %d %s\", e.StartHeight, n, noun)\n\n\t\tcase *RescanProgressMsg:\n\t\t\tfor acct, addrs := range e.Addresses {\n\t\t\t\tfor i := range addrs {\n\t\t\t\t\terr := acct.SetSyncStatus(addrs[i], wallet.PartialSync(e.Height))\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Errorf(\"Error marking address partially synced: %v\", err)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tam.ds.ScheduleWalletWrite(acct)\n\t\t\t\terr := am.ds.FlushAccount(acct)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Errorf(\"Could not write rescan progress: %v\", err)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlog.Infof(\"Rescanned through block height %d\", e.Height)\n\n\t\tcase *RescanFinishedMsg:\n\t\t\tif e.Error != nil {\n\t\t\t\tlog.Errorf(\"Rescan failed: %v\", e.Error.Message)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tn := 0\n\t\t\tfor acct, addrs := range e.Addresses {\n\t\t\t\tn += len(addrs)\n\t\t\t\tfor i := range addrs {\n\t\t\t\t\terr := acct.SetSyncStatus(addrs[i], wallet.FullSync{})\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Errorf(\"Error marking address synced: %v\", err)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tam.ds.ScheduleWalletWrite(acct)\n\t\t\t\terr := am.ds.FlushAccount(acct)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Errorf(\"Could not write rescan progress: %v\", err)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnoun := pickNoun(n, \"address\", \"addresses\")\n\t\t\tlog.Infof(\"Finished rescan for %d %s\", n, noun)\n\t\t}\n\t\tAcctMgr.Release()\n\t}\n}", "func onReconnect(attempt int, delay time.Duration) {\n\tfmt.Printf(\"Reconnect attempt %d in %fs\\n\", attempt, delay.Seconds())\n}" ]
[ "0.6866933", "0.63390505", "0.56829476", "0.5668464", "0.5609332", "0.5565546", "0.5492204", "0.54844296", "0.5472082", "0.54632837", "0.5270904", "0.52657753", "0.5260115", "0.52480096", "0.5239857", "0.52050614", "0.5151372", "0.512247", "0.511887", "0.5107964", "0.50983125", "0.5094848", "0.5062949", "0.5061921", "0.5038419", "0.50316525", "0.50180453", "0.5011045", "0.5007464", "0.49714455", "0.4970739", "0.49686232", "0.49557352", "0.49430868", "0.4938432", "0.49308613", "0.49114558", "0.49089807", "0.4902815", "0.48889276", "0.48882788", "0.48882297", "0.48787987", "0.48785818", "0.48722854", "0.48654896", "0.4864775", "0.486103", "0.48607087", "0.48585162", "0.4841309", "0.48407415", "0.48340908", "0.4832638", "0.48146498", "0.48108146", "0.48089638", "0.48077348", "0.48075065", "0.48022878", "0.47998133", "0.47949055", "0.47887212", "0.47840247", "0.47631955", "0.47569796", "0.4755978", "0.47380155", "0.47334546", "0.47229663", "0.47224036", "0.47196433", "0.4716441", "0.47136846", "0.47108266", "0.47089276", "0.47055316", "0.46997282", "0.4692175", "0.46912447", "0.46903187", "0.46899834", "0.46889618", "0.46798772", "0.46743128", "0.46709666", "0.4657735", "0.46561715", "0.46534443", "0.4648164", "0.46395954", "0.46296468", "0.46295086", "0.46237874", "0.4618286", "0.4616755", "0.4610442", "0.4609979", "0.46098152", "0.4605383" ]
0.73579
0
MergeTagSlices merges two tag slices, the second slice will always win for duplicates.
MergeTagSlices объединяет два среза тегов, второй срез всегда будет иметь приоритет при дублировании.
func MergeTagSlices(Original []TagInformation, ToAdd []TagInformation) []TagInformation { //Rules: //We do not care about meta-tags //Tags in ToAdd win //Exlusionary tags win after tags in ToAdd //First, remove duplicates from original that exist in ToAdd for Index := 0; Index < len(ToAdd); Index++ { if ToAdd[Index].IsMeta { continue //Skip Metatags } //Standard tag confirmed, scan for duplicates for ScanIndex := 0; ScanIndex < len(Original); ScanIndex++ { if Original[ScanIndex].IsMeta { continue //Skip comparing metas } if Original[ScanIndex].ID == ToAdd[Index].ID { //Remove and resize Original = append(Original[:ScanIndex], Original[ScanIndex+1:]...) //we just need to continue current scan from the same ScanIndex ScanIndex-- } } } //Now we can fall back to RemoveDuplicateTags to cleanup any other issues return RemoveDuplicateTags(append(Original, ToAdd...)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func mergeTags(t1, t2 []Tag) []Tag {\n\tn := len(t1) + len(t2)\n\tif n == 0 {\n\t\treturn nil\n\t}\n\n\tout := make([]Tag, 0, n)\n\tout = append(out, t1...)\n\tout = append(out, t2...)\n\n\treturn SortTags(out)\n}", "func MergeIndexedSlices(first *IndexedSlices, second *IndexedSlices) (*IndexedSlices, error) {\n\tif first == nil {\n\t\treturn second, nil\n\t}\n\tif second == nil {\n\t\treturn first, nil\n\t}\n\tif first.ConcatTensors.Dtype != second.ConcatTensors.Dtype {\n\t\treturn nil, fmt.Errorf(\"Could not merge two IndexedSlices with different types\")\n\t}\n\tif first.ConcatTensors.Dims[1] != second.ConcatTensors.Dims[1] {\n\t\treturn nil, fmt.Errorf(\"Could not merge two IndexedSlices with different widths\")\n\t}\n\theight := first.ConcatTensors.Dims[0] + second.ConcatTensors.Dims[0]\n\twidth := first.ConcatTensors.Dims[1]\n\tdtype := first.ConcatTensors.Dtype\n\ttensor := NewEmptyTensor([]int64{height, width}, dtype)\n\tvar ids []int64\n\tfor i, id := range first.Ids {\n\t\ttensor.SetRow(int64(i), first.ConcatTensors.GetRow(int64(i)))\n\t\tids = append(ids, id)\n\t}\n\tstart := len(ids)\n\tfor i, id := range second.Ids {\n\t\ttensor.SetRow(int64(start+i), second.ConcatTensors.GetRow(int64(i)))\n\t\tids = append(ids, id)\n\t}\n\treturn NewIndexedSlices(tensor, ids), nil\n}", "func mergeTagSets(s1, s2, scratch tagSet) tagSet {\n\ta := scratch\n\ti, j, k := 0, 0, 0\n\tfor ; i < len(s1) && j < len(s2) && k < len(a); k++ {\n\t\tif s1[i].key == s2[j].key {\n\t\t\ta[k] = s2[j]\n\t\t\ti++\n\t\t\tj++\n\t\t} else if s1[i].key < s2[j].key {\n\t\t\ta[k] = s1[i]\n\t\t\ti++\n\t\t} else {\n\t\t\ta[k] = s2[j]\n\t\t\tj++\n\t\t}\n\t}\n\tif i < len(s1) {\n\t\tk += copy(a[k:], s1[i:])\n\t}\n\tif j < len(s2) {\n\t\tk += copy(a[k:], s2[j:])\n\t}\n\treturn a[:k]\n}", "func BenchmarkMergeTagSets(b *testing.B) {\n\tif testing.Short() {\n\t\tb.Skip(\"short test\")\n\t}\n\tt1 := make(TagSet, 10)\n\tt2 := make(TagSet, 10)\n\tfor i := 0; i < len(t1); i++ {\n\t\tt1[i] = Tag{\n\t\t\tKey: fmt.Sprintf(\"k1%d\", i),\n\t\t\tValue: fmt.Sprintf(\"v1_%d\", i),\n\t\t}\n\t\tt2[i] = Tag{\n\t\t\tKey: fmt.Sprintf(\"k2%d\", i),\n\t\t\tValue: fmt.Sprintf(\"v2_%d\", i),\n\t\t}\n\t}\n\tt1.Sort()\n\tt2.Sort()\n\n\tscratch := make(TagSet, len(t1)+len(t2))\n\n\tb.ResetTimer()\n\tb.Run(\"KeysNotEqual\", func(b *testing.B) {\n\t\tfor size := 2; size <= 10; size += 2 {\n\t\t\tb.Run(fmt.Sprint(size), func(b *testing.B) {\n\t\t\t\ts1 := t1[:size]\n\t\t\t\ts2 := t2[:size]\n\t\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\t\tmergeTagSets(s1, s2, scratch)\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t})\n\n\tb.Run(\"KeysHalfEqual\", func(b *testing.B) {\n\t\tfor i := range t2 {\n\t\t\tif i&1 != 0 {\n\t\t\t\tt2[i].Key = t1[i].Key\n\t\t\t}\n\t\t}\n\t\tt2.Sort()\n\t\tfor size := 2; size <= 10; size += 2 {\n\t\t\tb.Run(fmt.Sprint(size), func(b *testing.B) {\n\t\t\t\ts1 := t1[:size]\n\t\t\t\ts2 := t2[:size]\n\t\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\t\tmergeTagSets(s1, s2, scratch)\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t})\n\n\tb.Run(\"KeysEqual\", func(b *testing.B) {\n\t\tfor i := range t2 {\n\t\t\tt2[i].Key = t1[i].Key\n\t\t}\n\t\tfor size := 2; size <= 10; size += 2 {\n\t\t\tb.Run(fmt.Sprint(size), func(b *testing.B) {\n\t\t\t\ts1 := t1[:size]\n\t\t\t\ts2 := t2[:size]\n\t\t\t\tfor i := 0; i < b.N; i++ {\n\t\t\t\t\tmergeTagSets(s1, s2, scratch)\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t})\n}", "func MergeTwoSorted(slice1 []int, slice2 []int, slice12 []int) {\n\tfmt.Println()\n\t// fmt.Println(\"MergeTwoSorted():\", len(slice1), len(slice2), len(slice12))\n\t// fmt.Println(\"MergeTwoSorted():\", slice1, slice2, slice12)\n\ti, j, k := 0, 0, 0\n\tfor {\n\t\t// fmt.Println(\"slice1[\", i, \"]=\", slice1[i])\n\t\t// fmt.Println(\"slice2[\", j, \"] =\", slice2[j])\n\t\tif slice1[i] < slice2[j] {\n\t\t\tslice12[k] = slice1[i]\n\t\t\tk++\n\t\t\ti++\n\t\t} else if slice1[i] == slice2[j] {\n\t\t\tslice12[k] = slice1[i]\n\t\t\tk++\n\t\t\ti++\n\n\t\t\tslice12[k] = slice2[j]\n\t\t\tk++\n\t\t\tj++\n\t\t} else if slice1[i] > slice2[j] {\n\t\t\tslice12[k] = slice2[j]\n\t\t\tk++\n\t\t\tj++\n\t\t}\n\n\t\tif i == len(slice1) {\n\t\t\tfor j < len(slice2) {\n\t\t\t\tslice12[k] = slice2[j]\n\t\t\t\tk++\n\t\t\t\tj++\n\t\t\t}\n\t\t}\n\n\t\tif j == len(slice2) {\n\t\t\tfor i < len(slice1) {\n\t\t\t\tslice12[k] = slice1[i]\n\t\t\t\tk++\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\n\t\tif k == len(slice12) {\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// fmt.Println(\"MergeTwoSorted():\", slice12)\n}", "func (p *plugin) concatTags(tags1 *structtag.Tags, tags2 *structtag.Tags) (*structtag.Tags, error) {\n\tif tags1.Len() == 0 {\n\t\treturn tags2, nil\n\t}\n\tif tags2.Len() == 0 {\n\t\treturn tags1, nil\n\t}\n\n\tfor _, t2 := range tags2.Tags() {\n\t\tvar found bool\n\t\tfor _, t1 := range tags1.Tags() {\n\t\t\tif t1.Key == t2.Key {\n\t\t\t\tif len(t1.Name) == 0 {\n\t\t\t\t\tt1.Name = t2.Name\n\t\t\t\t}\n\t\t\t\tif t1.Options == nil || len(t1.Options) == 0 {\n\t\t\t\t\tt1.Options = t2.Options\n\t\t\t\t}\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tvar err error\n\t\t\ts := tags1.String() + \" \" + t2.String()\n\t\t\ttags1, err = structtag.Parse(s)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to parse tags '%s': %s\", s, err.Error())\n\t\t\t}\n\t\t}\n\t}\n\n\treturn tags1, nil\n}", "func (t TagSet) Merge(more TagSet) TagSet {\n\tmerged := t[:]\n\treturn append(merged, more...)\n}", "func mergeTags(generalTags []*tag, infraTags []*tag) []*tag {\n\tvar dupMap = make(map[string]bool)\n\tfor _, tag := range generalTags {\n\t\tdupMap[tag.key] = true\n\t}\n\tfor _, tag := range infraTags {\n\t\tif _, exists := dupMap[tag.key]; !exists {\n\t\t\tgeneralTags = append(generalTags, tag)\n\t\t}\n\t}\n\treturn generalTags\n}", "func MergeTags(generalTags []*Tag, infraTags []*Tag) []*Tag {\n\tvar dupMap = make(map[string]bool)\n\tfor _, tag := range generalTags {\n\t\tdupMap[tag.Key] = true\n\t}\n\tfor _, tag := range infraTags {\n\t\tif _, exists := dupMap[tag.Key]; !exists {\n\t\t\tgeneralTags = append(generalTags, tag)\n\t\t}\n\t}\n\treturn generalTags\n}", "func merge(slice1, slice2 []int) []int {\n\tslice := make([]int, 0, len(slice1)+len(slice2))\n\n\tvar counter1, counter2 int\n\n\tfor counter1 != len(slice1) && counter2 != len(slice2) {\n\t\tif slice1[counter1] < slice2[counter2] {\n\t\t\tslice = append(slice, slice1[counter1])\n\t\t\tcounter1++\n\t\t} else {\n\t\t\tslice = append(slice, slice2[counter2])\n\t\t\tcounter2++\n\t\t}\n\t}\n\n\tif counter1 != len(slice1) {\n\t\tfor counter1 != len(slice1) {\n\t\t\tslice = append(slice, slice1[counter1])\n\t\t\tcounter1++\n\t\t}\n\t} else {\n\t\tfor counter2 != len(slice2) {\n\t\t\tslice = append(slice, slice2[counter2])\n\t\t\tcounter2++\n\t\t}\n\t}\n\n\treturn slice\n}", "func main() {\n\tnums1 := []int{1,4,7,0,0,0}\n\tnums2 := []int{2,3,6}\n\tmerge(nums1, len(nums1)-len(nums2), nums2, len(nums2))\n\tfmt.Println(nums1)\n}", "func (a *StringArray) Merge(b *StringArray) {\n\tif a.Len() == 0 {\n\t\t*a = *b\n\t\treturn\n\t}\n\n\tif b.Len() == 0 {\n\t\treturn\n\t}\n\n\t// Normally, both a and b should not contain duplicates. Due to a bug in older versions, it's\n\t// possible stored blocks might contain duplicate values. Remove them if they exists before\n\t// merging.\n\t// a = a.Deduplicate()\n\t// b = b.Deduplicate()\n\n\tif a.MaxTime() < b.MinTime() {\n\t\ta.Timestamps = append(a.Timestamps, b.Timestamps...)\n\t\ta.Values = append(a.Values, b.Values...)\n\t\treturn\n\t}\n\n\tif b.MaxTime() < a.MinTime() {\n\t\tvar tmp StringArray\n\t\ttmp.Timestamps = append(b.Timestamps, a.Timestamps...)\n\t\ttmp.Values = append(b.Values, a.Values...)\n\t\t*a = tmp\n\t\treturn\n\t}\n\n\tout := NewStringArrayLen(a.Len() + b.Len())\n\ti, j, k := 0, 0, 0\n\tfor i < len(a.Timestamps) && j < len(b.Timestamps) {\n\t\tif a.Timestamps[i] < b.Timestamps[j] {\n\t\t\tout.Timestamps[k] = a.Timestamps[i]\n\t\t\tout.Values[k] = a.Values[i]\n\t\t\ti++\n\t\t} else if a.Timestamps[i] == b.Timestamps[j] {\n\t\t\tout.Timestamps[k] = b.Timestamps[j]\n\t\t\tout.Values[k] = b.Values[j]\n\t\t\ti++\n\t\t\tj++\n\t\t} else {\n\t\t\tout.Timestamps[k] = b.Timestamps[j]\n\t\t\tout.Values[k] = b.Values[j]\n\t\t\tj++\n\t\t}\n\t\tk++\n\t}\n\n\tif i < len(a.Timestamps) {\n\t\tn := copy(out.Timestamps[k:], a.Timestamps[i:])\n\t\tcopy(out.Values[k:], a.Values[i:])\n\t\tk += n\n\t} else if j < len(b.Timestamps) {\n\t\tn := copy(out.Timestamps[k:], b.Timestamps[j:])\n\t\tcopy(out.Values[k:], b.Values[j:])\n\t\tk += n\n\t}\n\n\ta.Timestamps = out.Timestamps[:k]\n\ta.Values = out.Values[:k]\n}", "func mergeRightTags(tagsLeft, tagsRight map[string]string) map[string]string {\n\tif tagsLeft == nil && tagsRight == nil {\n\t\treturn nil\n\t}\n\tif len(tagsRight) == 0 {\n\t\treturn tagsLeft\n\t}\n\tif len(tagsLeft) == 0 {\n\t\treturn tagsRight\n\t}\n\n\tresult := make(map[string]string, len(tagsLeft)+len(tagsRight))\n\tfor k, v := range tagsLeft {\n\t\tresult[k] = v\n\t}\n\tfor k, v := range tagsRight {\n\t\tresult[k] = v\n\t}\n\treturn result\n}", "func (a *UnsignedArray) Merge(b *UnsignedArray) {\n\tif a.Len() == 0 {\n\t\t*a = *b\n\t\treturn\n\t}\n\n\tif b.Len() == 0 {\n\t\treturn\n\t}\n\n\t// Normally, both a and b should not contain duplicates. Due to a bug in older versions, it's\n\t// possible stored blocks might contain duplicate values. Remove them if they exists before\n\t// merging.\n\t// a = a.Deduplicate()\n\t// b = b.Deduplicate()\n\n\tif a.MaxTime() < b.MinTime() {\n\t\ta.Timestamps = append(a.Timestamps, b.Timestamps...)\n\t\ta.Values = append(a.Values, b.Values...)\n\t\treturn\n\t}\n\n\tif b.MaxTime() < a.MinTime() {\n\t\tvar tmp UnsignedArray\n\t\ttmp.Timestamps = append(b.Timestamps, a.Timestamps...)\n\t\ttmp.Values = append(b.Values, a.Values...)\n\t\t*a = tmp\n\t\treturn\n\t}\n\n\tout := NewUnsignedArrayLen(a.Len() + b.Len())\n\ti, j, k := 0, 0, 0\n\tfor i < len(a.Timestamps) && j < len(b.Timestamps) {\n\t\tif a.Timestamps[i] < b.Timestamps[j] {\n\t\t\tout.Timestamps[k] = a.Timestamps[i]\n\t\t\tout.Values[k] = a.Values[i]\n\t\t\ti++\n\t\t} else if a.Timestamps[i] == b.Timestamps[j] {\n\t\t\tout.Timestamps[k] = b.Timestamps[j]\n\t\t\tout.Values[k] = b.Values[j]\n\t\t\ti++\n\t\t\tj++\n\t\t} else {\n\t\t\tout.Timestamps[k] = b.Timestamps[j]\n\t\t\tout.Values[k] = b.Values[j]\n\t\t\tj++\n\t\t}\n\t\tk++\n\t}\n\n\tif i < len(a.Timestamps) {\n\t\tn := copy(out.Timestamps[k:], a.Timestamps[i:])\n\t\tcopy(out.Values[k:], a.Values[i:])\n\t\tk += n\n\t} else if j < len(b.Timestamps) {\n\t\tn := copy(out.Timestamps[k:], b.Timestamps[j:])\n\t\tcopy(out.Values[k:], b.Values[j:])\n\t\tk += n\n\t}\n\n\ta.Timestamps = out.Timestamps[:k]\n\ta.Values = out.Values[:k]\n}", "func (a *BooleanArray) Merge(b *BooleanArray) {\n\tif a.Len() == 0 {\n\t\t*a = *b\n\t\treturn\n\t}\n\n\tif b.Len() == 0 {\n\t\treturn\n\t}\n\n\t// Normally, both a and b should not contain duplicates. Due to a bug in older versions, it's\n\t// possible stored blocks might contain duplicate values. Remove them if they exists before\n\t// merging.\n\t// a = a.Deduplicate()\n\t// b = b.Deduplicate()\n\n\tif a.MaxTime() < b.MinTime() {\n\t\ta.Timestamps = append(a.Timestamps, b.Timestamps...)\n\t\ta.Values = append(a.Values, b.Values...)\n\t\treturn\n\t}\n\n\tif b.MaxTime() < a.MinTime() {\n\t\tvar tmp BooleanArray\n\t\ttmp.Timestamps = append(b.Timestamps, a.Timestamps...)\n\t\ttmp.Values = append(b.Values, a.Values...)\n\t\t*a = tmp\n\t\treturn\n\t}\n\n\tout := NewBooleanArrayLen(a.Len() + b.Len())\n\ti, j, k := 0, 0, 0\n\tfor i < len(a.Timestamps) && j < len(b.Timestamps) {\n\t\tif a.Timestamps[i] < b.Timestamps[j] {\n\t\t\tout.Timestamps[k] = a.Timestamps[i]\n\t\t\tout.Values[k] = a.Values[i]\n\t\t\ti++\n\t\t} else if a.Timestamps[i] == b.Timestamps[j] {\n\t\t\tout.Timestamps[k] = b.Timestamps[j]\n\t\t\tout.Values[k] = b.Values[j]\n\t\t\ti++\n\t\t\tj++\n\t\t} else {\n\t\t\tout.Timestamps[k] = b.Timestamps[j]\n\t\t\tout.Values[k] = b.Values[j]\n\t\t\tj++\n\t\t}\n\t\tk++\n\t}\n\n\tif i < len(a.Timestamps) {\n\t\tn := copy(out.Timestamps[k:], a.Timestamps[i:])\n\t\tcopy(out.Values[k:], a.Values[i:])\n\t\tk += n\n\t} else if j < len(b.Timestamps) {\n\t\tn := copy(out.Timestamps[k:], b.Timestamps[j:])\n\t\tcopy(out.Values[k:], b.Values[j:])\n\t\tk += n\n\t}\n\n\ta.Timestamps = out.Timestamps[:k]\n\ta.Values = out.Values[:k]\n}", "func mergeInjectionArrays(first, second []apimodel.Injection) []apimodel.Injection {\n\tnewslice := make([]apimodel.Injection, len(first)+len(second))\n\tcopy(newslice, first)\n\tcopy(newslice[len(first):], second)\n\treturn newslice\n}", "func BenchmarkScopeMergeTags(b *testing.B) {\n\tif testing.Short() {\n\t\tb.Skip(\"short test\")\n\t}\n\tfor baseSize := 1; baseSize <= 8; baseSize++ {\n\t\tfor tagSize := 1; tagSize <= 8; tagSize++ {\n\t\t\tb.Run(fmt.Sprintf(\"%d_%d\", baseSize, tagSize), func(b *testing.B) {\n\t\t\t\tbenchScopeMergeTags(b, baseSize, tagSize)\n\t\t\t})\n\t\t}\n\t}\n}", "func mergeExerciseArrays(first, second []apimodel.Exercise) []apimodel.Exercise {\n\tnewslice := make([]apimodel.Exercise, len(first)+len(second))\n\tcopy(newslice, first)\n\tcopy(newslice[len(first):], second)\n\treturn newslice\n}", "func (a *IntegerArray) Merge(b *IntegerArray) {\n\tif a.Len() == 0 {\n\t\t*a = *b\n\t\treturn\n\t}\n\n\tif b.Len() == 0 {\n\t\treturn\n\t}\n\n\t// Normally, both a and b should not contain duplicates. Due to a bug in older versions, it's\n\t// possible stored blocks might contain duplicate values. Remove them if they exists before\n\t// merging.\n\t// a = a.Deduplicate()\n\t// b = b.Deduplicate()\n\n\tif a.MaxTime() < b.MinTime() {\n\t\ta.Timestamps = append(a.Timestamps, b.Timestamps...)\n\t\ta.Values = append(a.Values, b.Values...)\n\t\treturn\n\t}\n\n\tif b.MaxTime() < a.MinTime() {\n\t\tvar tmp IntegerArray\n\t\ttmp.Timestamps = append(b.Timestamps, a.Timestamps...)\n\t\ttmp.Values = append(b.Values, a.Values...)\n\t\t*a = tmp\n\t\treturn\n\t}\n\n\tout := NewIntegerArrayLen(a.Len() + b.Len())\n\ti, j, k := 0, 0, 0\n\tfor i < len(a.Timestamps) && j < len(b.Timestamps) {\n\t\tif a.Timestamps[i] < b.Timestamps[j] {\n\t\t\tout.Timestamps[k] = a.Timestamps[i]\n\t\t\tout.Values[k] = a.Values[i]\n\t\t\ti++\n\t\t} else if a.Timestamps[i] == b.Timestamps[j] {\n\t\t\tout.Timestamps[k] = b.Timestamps[j]\n\t\t\tout.Values[k] = b.Values[j]\n\t\t\ti++\n\t\t\tj++\n\t\t} else {\n\t\t\tout.Timestamps[k] = b.Timestamps[j]\n\t\t\tout.Values[k] = b.Values[j]\n\t\t\tj++\n\t\t}\n\t\tk++\n\t}\n\n\tif i < len(a.Timestamps) {\n\t\tn := copy(out.Timestamps[k:], a.Timestamps[i:])\n\t\tcopy(out.Values[k:], a.Values[i:])\n\t\tk += n\n\t} else if j < len(b.Timestamps) {\n\t\tn := copy(out.Timestamps[k:], b.Timestamps[j:])\n\t\tcopy(out.Values[k:], b.Values[j:])\n\t\tk += n\n\t}\n\n\ta.Timestamps = out.Timestamps[:k]\n\ta.Values = out.Values[:k]\n}", "func mergeTags(existing string, tags []string) string {\n\tif existing == \"\" {\n\t\treturn strings.Join(tags, \",\")\n\t}\n\told := strings.Split(existing, \",\")\n\tvar merged []string\n\tfor _, o := range old {\n\t\tfound := false\n\t\tfor _, tag := range tags {\n\t\t\tif tag == o {\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tmerged = append(merged, o)\n\t\t}\n\t}\n\tfor _, tag := range tags {\n\t\tfound := false\n\t\tfor _, o := range merged {\n\t\t\tif tag == o {\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tmerged = append(merged, tag)\n\t\t}\n\t}\n\treturn strings.Join(merged, \",\")\n}", "func MergeStringSlices(slice1 []string, slice2 []string) []string {\n\tfor _, item := range slice2 {\n\t\tif !IsStringPresent(slice1, item) {\n\t\t\tslice1 = append(slice1, item)\n\t\t}\n\t}\n\treturn slice1\n}", "func MergeStringSlices(a []string, b []string) []string {\n\tset := sets.NewString(a...)\n\tset.Insert(b...)\n\treturn set.UnsortedList()\n}", "func SliceUnion(a, b []interface{}) []interface{} {\n\tm := make(map[interface{}]bool)\n\n\t// iterate through slice a, adding values as\n\t// keys in m\n\tfor _, v := range a {\n\t\tm[v] = true\n\t}\n\n\t// iterate through slice b, adding values not\n\t// in map m to slice a\n\tfor _, v := range b {\n\t\tif _, ok := m[v]; !ok {\n\t\t\ta = append(a, v)\n\t\t}\n\t}\n\n\t// return union of slices a and b\n\treturn a\n}", "func uniqueTagsWithSeen(seen map[string]struct{}, t1 gostatsd.Tags, t2 gostatsd.Tags) gostatsd.Tags {\n\tlast := len(t1)\n\tfor idx := 0; idx < last; {\n\t\ttag := t1[idx]\n\t\tif _, ok := seen[tag]; ok {\n\t\t\tlast--\n\t\t\tt1[idx] = t1[last]\n\t\t\tt1 = t1[:last]\n\t\t} else {\n\t\t\tseen[tag] = present\n\t\t\tidx++\n\t\t}\n\t}\n\n\tfor _, tag := range t2 {\n\t\tif _, ok := seen[tag]; !ok {\n\t\t\tt1 = append(t1, tag)\n\t\t}\n\t}\n\n\treturn t1\n}", "func MergeIntSlices(slice1 []int, slice2 []int) []int {\n\tfor _, item := range slice2 {\n\t\tif !IsIntPresent(slice1, item) {\n\t\t\tslice1 = append(slice1, item)\n\t\t}\n\t}\n\treturn slice1\n}", "func merge(left, right []Stake) []Stake {\n\n\tsize, leftIndex, rightIndex := len(left)+len(right), 0, 0\n\tsorted := make([]Stake, size, size)\n\n\tfor k := 0; k < size; k++ {\n\t\tswitch {\n\t\tcase leftIndex > len(left)-1 && rightIndex <= len(right)-1:\n\t\t\t// no more items in left\n\t\t\t// therefore take next index in right\n\t\t\tsorted[k] = right[rightIndex]\n\t\t\trightIndex++\n\t\tcase rightIndex > len(right)-1 && leftIndex <= len(left)-1:\n\t\t\t// no more items in right\n\t\t\t// therefore take next index in left\n\t\t\t// increment index of left\n\t\t\tsorted[k] = left[leftIndex]\n\t\t\tleftIndex++\n\t\tcase left[leftIndex].Odds < right[rightIndex].Odds:\n\t\t\t// lesser price goes first\n\t\t\tsorted[k] = left[leftIndex]\n\t\t\tleftIndex++\n\t\tcase left[leftIndex].Odds == right[rightIndex].Odds && left[leftIndex].CreatedAt.Before(right[rightIndex].CreatedAt):\n\t\t\t// if prices are equal do comparison with created on dates\n\t\t\tsorted[k] = left[leftIndex]\n\t\t\tleftIndex++\n\t\tdefault:\n\t\t\tsorted[k] = right[rightIndex]\n\t\t\trightIndex++\n\t\t}\n\t}\n\treturn sorted\n}", "func mergeSliceNode(n1, n2 *SliceNode) Node {\n\tvar node Node\n\tvar newVal []interface{}\n\tjsonName := n1.GetBaseNode().JsonName\n\tif n1.JsonName != n2.JsonName {\n\t\tfmt.Fprint(os.Stderr, \"mergeSliceNode n1, n2 node jsonname is not same <\" + n1.JsonName + \",\" + n2.JsonName + \">\")\n\t\tjsonName = \"\"\n\t}\n\t// 1: merge two slice to one slice\n\tnewVal = make([]interface{}, 0, len(n1.Val.([]interface{})) + len(n2.Val.([]interface{})))\n\tfor _, v := range n1.Val.([]interface{}) {\n\t\tnewVal = append(newVal, v)\n\t}\n\tfor _, v := range n2.Val.([]interface{}) {\n\t\tnewVal = append(newVal, v)\n\t}\n\tnode = NewNode(jsonName, newVal, n1.GenType, SliceType, n1.print)\n\t\n\t// 2: merge all slice element to a full element\n\tnode.fillSubNode()\n\treturn fullNode(node)\n}", "func (e *storageExecutor) mergeGroupByTagValueIDs(tagValueIDs []*roaring.Bitmap) {\n\tif tagValueIDs == nil {\n\t\treturn\n\t}\n\te.mutex.Lock()\n\tdefer e.mutex.Unlock()\n\n\tfor idx, tagVIDs := range e.tagValueIDs {\n\t\tif tagVIDs == nil {\n\t\t\te.tagValueIDs[idx] = tagValueIDs[idx]\n\t\t} else {\n\t\t\ttagVIDs.Or(tagValueIDs[idx])\n\t\t}\n\t}\n}", "func Merge(a, b map[string]interface{}) map[string]interface{} {\n\tresult := make(map[string]interface{})\n\tfor k, av := range a {\n\t\tar := reflect.ValueOf(av)\n\t\tif avm, ok := av.(map[string]interface{}); ok {\n\t\t\tif bv, ok := b[k]; ok {\n\t\t\t\tif bvm, ok := bv.(map[string]interface{}); ok {\n\t\t\t\t\tresult[k] = Merge(avm, bvm)\n\t\t\t\t} else {\n\t\t\t\t\tresult[k] = bv\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tresult[k] = av\n\t\t\t}\n\t\t} else if ar.Kind() == reflect.Slice {\n\t\t\tif bv, ok := b[k]; ok {\n\t\t\t\tbr := reflect.ValueOf(bv)\n\t\t\t\tif br.Kind() == reflect.Slice {\n\t\t\t\t\tcombined := reflect.MakeSlice(ar.Type(), 0, ar.Len())\n\t\t\t\t\tfor i := 0; i < ar.Len(); i++ {\n\t\t\t\t\t\tcombined = reflect.Append(combined, ar.Index(i))\n\t\t\t\t\t}\n\t\t\t\t\tfor i := 0; i < br.Len(); i++ {\n\t\t\t\t\t\tcombined = reflect.Append(combined, br.Index(i))\n\t\t\t\t\t}\n\t\t\t\t\tresult[k] = combined.Interface()\n\t\t\t\t} else {\n\t\t\t\t\tresult[k] = bv\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif bv, ok := b[k]; ok {\n\t\t\t\tresult[k] = bv\n\t\t\t} else {\n\t\t\t\tresult[k] = av\n\t\t\t}\n\t\t}\n\t}\n\tfor k, bv := range b {\n\t\tif _, ok := a[k]; !ok {\n\t\t\tresult[k] = bv\n\t\t}\n\t}\n\treturn result\n}", "func merge(a, b []model.Fingerprint) []model.Fingerprint {\n\tresult := make([]model.Fingerprint, 0, len(a)+len(b))\n\ti, j := 0, 0\n\tfor i < len(a) && j < len(b) {\n\t\tif a[i] < b[j] {\n\t\t\tresult = append(result, a[i])\n\t\t\ti++\n\t\t} else {\n\t\t\tresult = append(result, b[j])\n\t\t\tj++\n\t\t}\n\t}\n\tfor ; i < len(a); i++ {\n\t\tresult = append(result, a[i])\n\t}\n\tfor ; j < len(b); j++ {\n\t\tresult = append(result, b[j])\n\t}\n\treturn result\n}", "func Merge(arr []interface{}, comp goutils.TypeComparator, low, mid, high int)(){\n if low == high {\n return\n }\n n1 := mid - low + 1;\n n2 := high - mid;\n L := make([]interface{}, n1)\n R := make([]interface{}, n2)\n // Copy data to temp arrays Left[] and Right[]\n for i := 0; i < n1; i++{\n L[i] = arr[low + i]\n }\n for j := 0; j < n2; j++ {\n R[j] = arr[mid+1+j]\n }\n // Merge the temp arrays back into arr[low..high]\n i := 0 // Initial index of first subarray\n j := 0 // Initial index of second subarray\n k := low // Initial index of merged subarray\n for i < n1 && j < n2 {\n if comp(L[i], R[j]) == -1 || comp(L[i], R[j]) == 0 {\n arr[k] = L[i]\n i+=1\n } else{\n arr[k] = R[j]\n j+=1\n }\n k+=1\n }\n // Copy the remaining elements of L[], if there are any\n for i < n1 {\n arr[k] = L[i];\n i+=1\n k+=1\n }\n // Copy the remaining elements of R[], if there are any\n for j < n2 {\n arr[k] = R[j];\n j+=1\n k+=1\n }\n}", "func merge(dst, src *unstructured.Unstructured) bool {\n\tdstNS := dst.GetLabels()[resourceLabelNamespace]\n\tsrcNS := src.GetLabels()[resourceLabelNamespace]\n\tif dstNS != srcNS {\n\t\treturn false\n\t}\n\n\tif dstResults, ok, _ := unstructured.NestedSlice(dst.UnstructuredContent(), \"results\"); ok {\n\t\tif srcResults, ok, _ := unstructured.NestedSlice(src.UnstructuredContent(), \"results\"); ok {\n\t\t\tdstResults = append(dstResults, srcResults...)\n\n\t\t\tif err := unstructured.SetNestedSlice(dst.UnstructuredContent(), dstResults, \"results\"); err == nil {\n\t\t\t\taddSummary(dst, src)\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}", "func MergeAndDeduplicateSlice(src []string, target []string) []string {\n\tm := make(map[string]bool)\n\tfor i := range src {\n\t\tm[src[i]] = true\n\t}\n\n\tfor i := range target {\n\t\tif _, ok := m[target[i]]; !ok {\n\t\t\tsrc = append(src, target[i])\n\t\t}\n\t}\n\n\treturn src\n}", "func (s *SQLOperations) Merge(ops SQLOperations) {\n\tfor _, slice := range ops {\n\t\tif len(slice.Statement) > 0 {\n\t\t\ts.Add(slice)\n\t\t}\n\t}\n}", "func (ss *SectionSlice) Merge(sections ...*Section) error {\n\tfor _, s := range sections {\n\t\tif s != nil {\n\t\t\tif err := (*ss).merge(s); err != nil {\n\t\t\t\treturn errgo.Mask(err)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func Merge(left, right []string) []string {\n\treturn CollectVariety(left, right, GetAll, GetAll, GetAll)\n}", "func (t Tags) Merge(key string, value ...string) {\n\tfor _, v := range value {\n\t\tcurrent := t.GetAll(key)\n\t\tfound := false\n\t\tfor _, cv := range current {\n\t\t\tif v == cv {\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tt.Add(key, v)\n\t\t}\n\t}\n}", "func JoinTags(tags ...Tag) TagSet {\n\tvar result TagSet\n\tresult = append(result, tags...)\n\treturn result\n}", "func mergeGlucoseReadArrays(first, second []apimodel.GlucoseRead) []apimodel.GlucoseRead {\n\tnewslice := make([]apimodel.GlucoseRead, len(first)+len(second))\n\tcopy(newslice, first)\n\tcopy(newslice[len(first):], second)\n\treturn newslice\n}", "func mergeResourceTags(one map[string]string, two map[string]*string) (map[string]*string, bool) {\n\tmergedResourceTags := map[string]*string{}\n\t// \"Copy\" two into a new map.\n\tfor key, value := range two {\n\t\tmergedResourceTags[key] = to.Ptr(*value)\n\t}\n\tchanged := false\n\t// Merge \"one\" into the new map, setting changed if we had to make a modification,\n\t// this is for determining whether we needed to make an update to the existing tags.\n\tfor key, value := range one {\n\t\tval, ok := mergedResourceTags[key]\n\t\tif !ok || *val != value {\n\t\t\tmergedResourceTags[key] = to.Ptr(value)\n\t\t\tchanged = true\n\t\t}\n\t}\n\treturn mergedResourceTags, changed\n}", "func (a Vector) Merge(b Vector) Vector {\n\tvar ai, bi int\n\tfor bi < len(b) {\n\t\tif ai == len(a) {\n\t\t\t// We've reach the end of a, all that remains are appends\n\t\t\treturn append(a, b[bi:]...)\n\t\t}\n\n\t\tif a[ai].id > b[bi].id {\n\t\t\t// The index from b should be inserted here\n\t\t\tn := make(Vector, len(a)+1)\n\t\t\tcopy(n, a[:ai])\n\t\t\tn[ai] = b[bi]\n\t\t\tcopy(n[ai+1:], a[ai:])\n\t\t\ta = n\n\t\t}\n\n\t\tif a[ai].id == b[bi].id {\n\t\t\tif v := b[bi].value; v > a[ai].value {\n\t\t\t\ta[ai].value = v\n\t\t\t}\n\t\t}\n\n\t\tif bi < len(b) && a[ai].id == b[bi].id {\n\t\t\tbi++\n\t\t}\n\t\tai++\n\t}\n\n\treturn a\n}", "func merge(left []int, right []int) []int {\n\ti := 0\n\tj := 0\n\tsize := len(left) + len(right)\n\tslice := make([]int, size, size) // make built-in function allocates and initializes an object of type slice\n\tfor k := 0; k < size; k++ {\n\t\tif i > len(left)-1 && j < len(right) {\n\t\t\tslice[k] = right[j]\n\t\t\tj++\n\t\t} else if j > len(right)-1 && i < len(left) {\n\t\t\tslice[k] = left[i]\n\t\t\ti++\n\t\t} else if left[i] < right[j] {\n\t\t\tslice[k] = left[i]\n\t\t\ti++\n\t\t} else {\n\t\t\tslice[k] = right[j]\n\t\t\tj++\n\t\t}\n\t}\n\treturn slice\n}", "func (tm *merger) Merge(tagKeyID uint32, dataBlocks [][]byte) error {\n\tmaxSequenceID := uint32(0) // target sequence of tag value id\n\t// 1. prepare tagKeyMetas\n\tvar tagKeyMetas []TagKeyMeta\n\tfor _, dataBlock := range dataBlocks {\n\t\ttagKeyMeta, err := newTagKeyMeta(dataBlock)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif maxSequenceID < tagKeyMeta.TagValueIDSeq() {\n\t\t\tmaxSequenceID = tagKeyMeta.TagValueIDSeq()\n\t\t}\n\t\ttagKeyMetas = append(tagKeyMetas, tagKeyMeta)\n\t}\n\t// 2. iterator trie data, then merge the tag values\n\tfor _, tagKeyMeta := range tagKeyMetas {\n\t\titr, err := tagKeyMeta.PrefixIterator(nil)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor itr.Valid() {\n\t\t\ttm.metaFlusher.FlushTagValue(cloneSlice(itr.Key()), encoding.ByteSlice2Uint32(itr.Value()))\n\t\t\titr.Next()\n\t\t}\n\t}\n\tif err := tm.metaFlusher.FlushTagKeyID(tagKeyID, maxSequenceID); err != nil {\n\t\treturn err\n\t}\n\treturn tm.metaFlusher.commitTagKeyID()\n}", "func Merge(dits []Iterator, cb func([]*Meta) error) error {\n\treturn mergeByKey(dits, metaInputID, cb)\n}", "func Union(a, b RegInvImage) RegInvImage {\n\tfor imageName, digestTags := range b {\n\t\t// If a does not have this image at all, then it's a simple\n\t\t// injection.\n\t\tif a[imageName] == nil {\n\t\t\ta[imageName] = digestTags\n\t\t\tcontinue\n\t\t}\n\t\tfor digest, tags := range digestTags {\n\t\t\t// If a has the image but not this digest, inject just this digest\n\t\t\t// and all associated tags.\n\t\t\tif a[imageName][digest] == nil {\n\t\t\t\ta[imageName][digest] = tags\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// If c has the digest already, try to inject those tags in b that\n\t\t\t// are not already in a.\n\t\t\ttagSlice := TagSlice{}\n\t\t\tfor tag := range tags.Union(a[imageName][digest]) {\n\t\t\t\tif tag == \"latest\" {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\ttagSlice = append(tagSlice, tag)\n\t\t\t}\n\t\t\ta[imageName][digest] = tagSlice\n\t\t}\n\t}\n\n\treturn a\n}", "func mergeArrays(one []uint8, two[]uint8) []uint8 {\n var result []uint8\n for _, value := range one {\n result = append(result, value)\n }\n for _, value := range two {\n result = append(result, value)\n }\n return result\n }", "func MergeSamples(a, b []model.SamplePair) []model.SamplePair {\n\tresult := make([]model.SamplePair, 0, len(a)+len(b))\n\ti, j := 0, 0\n\tfor i < len(a) && j < len(b) {\n\t\tif a[i].Timestamp < b[j].Timestamp {\n\t\t\tresult = append(result, a[i])\n\t\t\ti++\n\t\t} else if a[i].Timestamp > b[j].Timestamp {\n\t\t\tresult = append(result, b[j])\n\t\t\tj++\n\t\t} else {\n\t\t\tresult = append(result, a[i])\n\t\t\ti++\n\t\t\tj++\n\t\t}\n\t}\n\tfor ; i < len(a); i++ {\n\t\tresult = append(result, a[i])\n\t}\n\tfor ; j < len(b); j++ {\n\t\tresult = append(result, b[j])\n\t}\n\treturn result\n}", "func (ss *SectionSlice) merge(s *Section) error {\n\tif s == nil {\n\t\treturn nil\n\t}\n\tcs, err := (*ss).FindByID(s.ID) // cs current section\n\tif cs == nil || err != nil {\n\t\tcs = &Section{ID: s.ID}\n\t\t(*ss).Append(cs)\n\t}\n\n\tif s.Label != \"\" {\n\t\tcs.Label = s.Label\n\t}\n\tif s.Scope > 0 {\n\t\tcs.Scope = s.Scope\n\t}\n\tif s.SortOrder != 0 {\n\t\tcs.SortOrder = s.SortOrder\n\t}\n\tif s.Permission > 0 {\n\t\tcs.Permission = s.Permission\n\t}\n\treturn cs.Groups.Merge(s.Groups...)\n}", "func TestMergeWithPreviousBuilds(t *testing.T) {\n\tbuilds := MergeWithPreviousBuilds([]graph.Artifact{artifact(\"img1\", \"tag1_1\"), artifact(\"img2\", \"tag2_1\")}, nil)\n\ttestutil.CheckDeepEqual(t, \"img1:tag1_1,img2:tag2_1\", tags(builds))\n\n\tbuilds = MergeWithPreviousBuilds([]graph.Artifact{artifact(\"img1\", \"tag1_2\")}, builds)\n\ttestutil.CheckDeepEqual(t, \"img1:tag1_2,img2:tag2_1\", tags(builds))\n\n\tbuilds = MergeWithPreviousBuilds([]graph.Artifact{artifact(\"img2\", \"tag2_2\")}, builds)\n\ttestutil.CheckDeepEqual(t, \"img1:tag1_2,img2:tag2_2\", tags(builds))\n\n\tbuilds = MergeWithPreviousBuilds([]graph.Artifact{artifact(\"img1\", \"tag1_3\"), artifact(\"img2\", \"tag2_3\")}, builds)\n\ttestutil.CheckDeepEqual(t, \"img1:tag1_3,img2:tag2_3\", tags(builds))\n}", "func (ss *SectionSlice) MergeMultiple(sSlices ...SectionSlice) error {\n\tfor _, sl := range sSlices {\n\t\tif err := (*ss).Merge(sl...); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func merge2(nums1 []int, m int, nums2 []int, n int) {\n\t// 1. copy a [:m] slice\n\tnums1Copy := make([]int, m)\n\t// copy\n\tcopy(nums1Copy, nums1)\n\tvar p1, p2, index int\n\tfor p1 < m && p2 < n {\n\t\tif nums1Copy[p1] < nums2[p2] {\n\t\t\tnums1[index] = nums1Copy[p1]\n\t\t\tp1++\n\t\t} else {\n\t\t\tnums1[index] = nums2[p2]\n\t\t\tp2++\n\t\t}\n\t\tindex++\n\t}\n\tif p1 < m {\n\t\tcopy(nums1[index:], nums1Copy[p1:])\n\t}\n\n\tif p2 < n {\n\t\tcopy(nums1[index:], nums2[p2:])\n\t}\n}", "func (e *Element) MergeTags(tags ...string) {\n\te.Tags = mergeTags(e.Tags, tags)\n}", "func (bm tsidbitmap) Merge(other tsidbitmap) (tsidbitmap, bool) {\n\tfor len(bm) < len(other) {\n\t\tbm = append(bm, 0)\n\t}\n\tdirty := false\n\tfor i, v := range other {\n\t\tdirty = dirty || (bm[i]|v != bm[i])\n\t\tbm[i] |= v\n\t}\n\treturn bm, dirty\n}", "func (p LabelPairs) Merge(other LabelPairs) LabelPairs {\n\tresult := make(LabelPairs, len(p)+len(other))\n\tfor k, v := range p {\n\t\tresult[k] = v\n\t}\n\tfor k, v := range other {\n\t\tresult[k] = v\n\t}\n\treturn result\n}", "func benchScopeMergeTags(b *testing.B, baseSize, tagsSize int) {\n\tset := make(TagSet, baseSize)\n\tfor i := range set {\n\t\tset[i] = Tag{\n\t\t\tKey: fmt.Sprintf(\"key1_%d\", i),\n\t\t\tValue: fmt.Sprintf(\"val1_%d\", i),\n\t\t}\n\t}\n\ttags := make(map[string]string, tagsSize)\n\tfor i := 0; i < tagsSize; i++ {\n\t\tkey := fmt.Sprintf(\"key2_%d\", i)\n\t\tval := fmt.Sprintf(\"val2_%d\", i)\n\t\ttags[key] = val\n\t}\n\tb.ResetTimer()\n\n\tfor i := 0; i < b.N; i++ {\n\t\tset.MergeTags(tags)\n\t}\n}", "func Merge(datas interfaces.Sortable) interfaces.Sortable {\n\tmergeSort(datas, 0, datas.Len()-1)\n\treturn datas\n}", "func (s BlobSet) Merge(other BlobSet) {\n\tfor h := range other {\n\t\ts.Insert(h)\n\t}\n}", "func merge(in1, in2 []int) []int {\n\tsize1, size2 := len(in1), len(in2)\n\tout := make([]int, size1+size2)\n\n\tvar idx1, idx2, index int\n\tfor idx1 < size1 && idx2 < size2 {\n\t\tif in1[idx1] < in2[idx2] {\n\t\t\tout[index] = in1[idx1]\n\t\t\tidx1++\n\t\t} else {\n\t\t\tout[index] = in2[idx2]\n\t\t\tidx2++\n\t\t}\n\t\tindex++\n\t}\n\tfor idx1 < size1 {\n\t\tout[index] = in1[idx1]\n\t\tidx1++\n\t\tindex++\n\t}\n\tfor idx2 < size2 {\n\t\tout[index] = in2[idx2]\n\t\tidx2++\n\t\tindex++\n\t}\n\treturn out\n}", "func mergeSeries(dst, src *influxdb.Series) {\n\tdst.Points = append(dst.Points, src.Points...)\n}", "func Merge (a []int, b []int) []int{\n\tvar Result = make([]int,0)\n\tvar t = len(a) + len(b)\n\tfor i := 0; i < t; i++{\n\t\tif len(a) == 0{\n\t\t\tResult = append(Result,b[0])\n\t\t\tb = Utils.Delete(b,0)\n\t\t} else if len(b) == 0{\n\t\t\tResult = append(Result,a[0])\n\t\t\ta = Utils.Delete(a,0)\n\t\t} else if a[0] < b[0]{\n\t\t\tResult = append(Result,a[0])\n\t\t\ta = Utils.Delete(a,0)\n\t\t} else {\n\t\t\tResult = append(Result,b[0])\n\t\t\tb = Utils.Delete(b,0)\n\t\t}\n\t}\n\treturn Result\n}", "func mergeLabel(ss []string, i, prefixLen int, prefixes prefixMap) {\n\ts := ss[i]\n\tsuffix := s[len(s)-prefixLen:]\n\tfor _, j := range prefixes[suffix] {\n\t\t// Empty strings mean \"already used.\" Also avoid merging with self.\n\t\tif ss[j] == \"\" || i == j {\n\t\t\tcontinue\n\t\t}\n\t\tif *v {\n\t\t\tfmt.Fprintf(os.Stderr, \"%d-length overlap at (%4d,%4d): %q and %q share %q\\n\",\n\t\t\t\tprefixLen, i, j, ss[i], ss[j], suffix)\n\t\t}\n\t\tss[i] += ss[j][prefixLen:]\n\t\tss[j] = \"\"\n\t\t// ss[i] has a new suffix, so merge again if possible.\n\t\t// Note: we only have to merge again at the same prefix length. Shorter\n\t\t// prefix lengths will be handled in the next iteration of crush's for loop.\n\t\t// Can there be matches for longer prefix lengths, introduced by the merge?\n\t\t// I believe that any such matches would by necessity have been eliminated\n\t\t// during substring removal or merged at a higher prefix length. For\n\t\t// instance, in crush(\"abc\", \"cde\", \"bcdef\"), combining \"abc\" and \"cde\"\n\t\t// would yield \"abcde\", which could be merged with \"bcdef.\" However, in\n\t\t// practice \"cde\" would already have been elimintated by removeSubstrings.\n\t\tmergeLabel(ss, i, prefixLen, prefixes)\n\t\treturn\n\t}\n}", "func (bml BitmapLayers) Merge() (BitmapLayer, error) {\n\tout := BitmapLayer{}\n\tif len(bml) != 2 {\n\t\treturn out, fmt.Errorf(\"merge requires exactly two input segments\")\n\t}\n\n\tleft, right := bml[0], bml[1]\n\n\tadditions := left.Additions.Clone()\n\tadditions.Or(right.Additions)\n\tadditions.AndNot(right.Deletions)\n\n\tdeletions := left.Deletions.Clone()\n\tdeletions.AndNot(right.Additions)\n\tdeletions.Or(right.Deletions)\n\n\tout.Additions = Condense(additions)\n\tout.Deletions = Condense(deletions)\n\treturn out, nil\n}", "func merge(a, b []int) []int {\n\tvar r []int = make([]int, 0)\n\tvar i, j int = 0, 0\n\tfor {\n\t\t// if a has a lower or equal value, put it on the result\n\t\tif a[i] < b[j] || a[i] == b[j] {\n\t\t\tr = append(r, a[i])\n\t\t\ti++\n\t\t} else if b[j] < a[i] { // same but for b\n\t\t\tr = append(r, b[j])\n\t\t\tj++\n\t\t}\n\t\tif i == len(a) { // a exhausted\n\t\t\tfor ; j < len(b); j++ {\n\t\t\t\tr = append(r, b[j])\n\t\t\t}\n\t\t} else if j == len(b) { // b exhausted\n\t\t\tfor ; i < len(a); i++ {\n\t\t\t\tr = append(r, a[i])\n\t\t\t}\n\t\t}\n\t\tif j == len(b) && i == len(a) { // global termination condition\n\t\t\treturn r\n\t\t}\n\t}\n}", "func MergeUnique(left, right []string) []string {\n\treturn CollectVariety(left, right, GetUnique, GetUnique, GetUnique)\n}", "func merge(p, pPrime uint, sizeEst uint64, it1, it2 u64It) *sparse {\n\n\tleftIt := makeMergeElemIter(p, pPrime, it1)\n\trightIt := makeMergeElemIter(p, pPrime, it2)\n\n\tleft, haveLeft := leftIt()\n\tright, haveRight := rightIt()\n\n\toutput := newSparse(sizeEst)\n\n\tfor haveLeft && haveRight {\n\t\tvar toAppend uint64\n\t\tif left.index < right.index {\n\t\t\ttoAppend = left.encoded\n\t\t\tleft, haveLeft = leftIt()\n\t\t} else if right.index < left.index {\n\t\t\ttoAppend = right.encoded\n\t\t\tright, haveRight = rightIt()\n\t\t} else { // The indexes are equal. Keep the one with the highest rho value.\n\t\t\tif left.rho > right.rho {\n\t\t\t\ttoAppend = left.encoded\n\t\t\t} else {\n\t\t\t\ttoAppend = right.encoded\n\t\t\t}\n\t\t\tleft, haveLeft = leftIt()\n\t\t\tright, haveRight = rightIt()\n\t\t}\n\t\toutput.Add(toAppend)\n\t}\n\n\tfor haveRight {\n\t\toutput.Add(right.encoded)\n\t\tright, haveRight = rightIt()\n\t}\n\n\tfor haveLeft {\n\t\toutput.Add(left.encoded)\n\t\tleft, haveLeft = leftIt()\n\t}\n\n\treturn output\n}", "func combine(original, override map[string]string) map[string]string {\n\t// We know the size must be at least the length of the existing tag map, but\n\t// since values can be overridden we cannot assume the length is the sum of\n\t// both inputs.\n\tcombined := make(map[string]string, len(original))\n\n\tfor k, v := range original {\n\t\tcombined[k] = v\n\t}\n\tfor k, v := range override {\n\t\tcombined[k] = v\n\t}\n\n\treturn combined\n}", "func Intersection(a, b AnySlice) AnySlice {\n\tmustBeSlice(a)\n\tmustBeSlice(b)\n\n\taVal := reflect.ValueOf(a)\n\tbVal := reflect.ValueOf(b)\n\taCount := aVal.Len()\n\tbCount := bVal.Len()\n\toutput := makeFilterSlice(a, 0, aCount+bCount)\n\tkeys := make(map[interface{}]bool)\n\n\tfor i := 0; i < aCount; i++ {\n\t\tkeys[aVal.Index(i).Interface()] = true\n\t}\n\tfor i := 0; i < bCount; i++ {\n\t\tkey := bVal.Index(i)\n\t\tif _, present := keys[key.Interface()]; present {\n\t\t\toutput = reflect.Append(output, key)\n\t\t}\n\t}\n\treturn output.Interface()\n}", "func UniqueMergeSlices(s [][]int64) (result []int64) {\n\tvar m = make(map[int64]bool)\n\n\tfor _, el := range s {\n\t\tfor _, i := range el {\n\t\t\tm[i] = true\n\t\t}\n\t}\n\n\tfor k := range m {\n\t\tresult = append(result, k)\n\t}\n\n\treturn result\n}", "func merge(source ...[]string) []string {\n\tm := make(map[string]struct{}, len(source)*10)\n\tfor _, list := range source {\n\t\tfor _, item := range list {\n\t\t\tm[item] = struct{}{}\n\t\t}\n\t}\n\tdst := make([]string, len(m))\n\tcnt := 0\n\tfor k := range m {\n\t\tdst[cnt] = k\n\t\tcnt += 1\n\t}\n\tsort.Strings(dst)\n\treturn dst\n}", "func mergeCalibrationReadArrays(first, second []apimodel.CalibrationRead) []apimodel.CalibrationRead {\n\tnewslice := make([]apimodel.CalibrationRead, len(first)+len(second))\n\tcopy(newslice, first)\n\tcopy(newslice[len(first):], second)\n\treturn newslice\n}", "func Merge(left, right []int) []int {\n\tsize := len(left) + len(right)\n\ti, j := 0, 0\n\n\tslice := make([]int, size, size)\n\n\tfor k := 0; k < size; k++ {\n\t\tif i > len(left) - 1 && j <= len(right) - 1 {\n\t\t\tslice[k] = right[j]\n\t\t\tj++\n\t\t} else if j > len(right) - 1 && i <= len(left) - 1 {\n\t\t\tslice[k] = left[i]\n\t\t\ti++\n\t\t} else if left[i] < right[j] {\n\t\t\tslice[k] = left[i]\n\t\t\ti++\n\t\t} else {\n\t\t\tslice[k] = right[j]\n\t\t\tj++\n\t\t}\n\t}\n\n\treturn slice\n}", "func TagsDiff(sqsTags map[string]string, newTags map[string]string) (removed, added map[string]string) {\n\tremoved = map[string]string{}\n\tfor k, v := range sqsTags {\n\t\tif _, ok := newTags[k]; !ok {\n\t\t\tremoved[k] = v\n\t\t}\n\t}\n\n\tadded = map[string]string{}\n\tfor k, newV := range newTags {\n\t\tif oldV, ok := sqsTags[k]; !ok || oldV != newV {\n\t\t\tadded[k] = newV\n\t\t}\n\t}\n\treturn\n}", "func mergeAlternately(word1 string, word2 string) string {\n\tvar buf bytes.Buffer\n\tfor i := range word1 {\n\t\tbuf.WriteByte(word1[i])\n\t\tif i < len(word2) {\n\t\t\tbuf.WriteByte(word2[i])\n\t\t}\n\t}\n\n\tif len(word1) < len(word2) {\n\t\tbuf.WriteString(word2[len(word1):])\n\t}\n\treturn buf.String()\n}", "func (*ZapPlugin) Merge(segments []seg.Segment, drops []*roaring.Bitmap, path string,\n\tcloseCh chan struct{}, s seg.StatsReporter) (\n\t[][]uint64, uint64, error) {\n\tsegmentBases := make([]*SegmentBase, len(segments))\n\tfor segmenti, segment := range segments {\n\t\tswitch segmentx := segment.(type) {\n\t\tcase *Segment:\n\t\t\tsegmentBases[segmenti] = &segmentx.SegmentBase\n\t\tcase *SegmentBase:\n\t\t\tsegmentBases[segmenti] = segmentx\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"oops, unexpected segment type: %T\", segment))\n\t\t}\n\t}\n\treturn mergeSegmentBases(segmentBases, drops, path, DefaultChunkMode, closeCh, s)\n}", "func (c StringArrayCollection) Merge(i interface{}) Collection {\n\tm := i.([]string)\n\tvar d = make([]string, len(c.value))\n\tcopy(d, c.value)\n\n\tfor i := 0; i < len(m); i++ {\n\t\texist := false\n\t\tfor j := 0; j < len(d); j++ {\n\t\t\tif d[j] == m[i] {\n\t\t\t\texist = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !exist {\n\t\t\td = append(d, m[i])\n\t\t}\n\t}\n\n\treturn StringArrayCollection{\n\t\tvalue: d,\n\t}\n}", "func mergeSpans(latches []Span) ([]Span, bool) {\n\tif len(latches) == 0 {\n\t\treturn latches, true\n\t}\n\n\tsort.Sort(sortedSpans(latches))\n\n\t// We build up the resulting slice of merged spans in place. This is safe\n\t// because \"r\" grows by at most 1 element on each iteration, staying abreast\n\t// or behind the iteration over \"latches\".\n\tr := latches[:1]\n\tdistinct := true\n\n\tfor _, cur := range latches[1:] {\n\t\tprev := &r[len(r)-1]\n\t\tif len(cur.EndKey) == 0 && len(prev.EndKey) == 0 {\n\t\t\tif cur.Key.Compare(prev.Key) != 0 {\n\t\t\t\t// [a, nil] merge [b, nil]\n\t\t\t\tr = append(r, cur)\n\t\t\t} else {\n\t\t\t\t// [a, nil] merge [a, nil]\n\t\t\t\tif cur.Timestamp != prev.Timestamp {\n\t\t\t\t\tr = append(r, cur)\n\t\t\t\t}\n\t\t\t\tdistinct = false\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif len(prev.EndKey) == 0 {\n\t\t\tif cur.Key.Compare(prev.Key) == 0 {\n\t\t\t\t// [a, nil] merge [a, b]\n\t\t\t\tif cur.Timestamp != prev.Timestamp {\n\t\t\t\t\tr = append(r, cur)\n\t\t\t\t} else {\n\t\t\t\t\tprev.EndKey = cur.EndKey\n\t\t\t\t}\n\t\t\t\tdistinct = false\n\t\t\t} else {\n\t\t\t\t// [a, nil] merge [b, c]\n\t\t\t\tr = append(r, cur)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif c := prev.EndKey.Compare(cur.Key); c >= 0 {\n\t\t\tif cur.EndKey != nil {\n\t\t\t\tif prev.EndKey.Compare(cur.EndKey) < 0 {\n\t\t\t\t\t// [a, c] merge [b, d]\n\t\t\t\t\tif cur.Timestamp != prev.Timestamp {\n\t\t\t\t\t\tr = append(r, cur)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tprev.EndKey = cur.EndKey\n\t\t\t\t\t}\n\t\t\t\t\tif c > 0 {\n\t\t\t\t\t\tdistinct = false\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// [a, c] merge [b, c]\n\t\t\t\t\tif cur.Timestamp != prev.Timestamp {\n\t\t\t\t\t\tr = append(r, cur)\n\t\t\t\t\t}\n\t\t\t\t\tdistinct = false\n\t\t\t\t}\n\t\t\t} else if c == 0 {\n\t\t\t\t// [a, b] merge [b, nil]\n\t\t\t\tif cur.Timestamp != prev.Timestamp {\n\t\t\t\t\tr = append(r, cur)\n\t\t\t\t}\n\t\t\t\tprev.EndKey = cur.Key.Next()\n\t\t\t} else {\n\t\t\t\t// [a, c] merge [b, nil]\n\t\t\t\tif cur.Timestamp != prev.Timestamp {\n\t\t\t\t\tr = append(r, cur)\n\t\t\t\t}\n\t\t\t\tdistinct = false\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tr = append(r, cur)\n\t}\n\treturn r, distinct\n}", "func (gs *GroupSlice) Merge(groups ...*Group) error {\n\tfor _, g := range groups {\n\t\tif err := (*gs).merge(g); err != nil {\n\t\t\treturn errgo.Mask(err)\n\t\t}\n\t}\n\treturn nil\n}", "func (gs *GroupSlice) Merge(groups ...*Group) error {\n\tfor _, g := range groups {\n\t\tif err := (*gs).merge(g); err != nil {\n\t\t\treturn errgo.Mask(err)\n\t\t}\n\t}\n\treturn nil\n}", "func MergeRegions(regions []*metapb.Region) []*metapb.Region {\n\tresults := make([]*metapb.Region, 0, len(regions)/2)\n\tfor i := 0; i < len(regions); i += 2 {\n\t\tleft := regions[i]\n\t\tright := regions[i]\n\t\tif i+1 < len(regions) {\n\t\t\tright = regions[i+1]\n\t\t}\n\t\tregion := &metapb.Region{\n\t\t\tId: left.Id + uint64(len(regions)),\n\t\t\tStartKey: left.StartKey,\n\t\t\tEndKey: right.EndKey,\n\t\t}\n\t\tif left.RegionEpoch.Version > right.RegionEpoch.Version {\n\t\t\tregion.RegionEpoch = left.RegionEpoch\n\t\t} else {\n\t\t\tregion.RegionEpoch = right.RegionEpoch\n\t\t}\n\t\tregion.RegionEpoch.Version++\n\t\tresults = append(results, region)\n\t}\n\treturn results\n}", "func MergeSlices(slice1 []float32, slice2 []int32) []int {\n\tslice := make([]int, len(slice1)+len(slice2))\n\tfor key, value := range slice1 {\n\t\tslice[key] = int(value)\n\t}\n\tfor key, value := range slice2 {\n\t\tslice[key+len(slice1)] = int(value)\n\t}\n\treturn slice\n}", "func Merge(scope *Scope, inputs []tf.Output) (output tf.Output, value_index tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Merge\",\n\t\tInput: []tf.Input{\n\t\t\ttf.OutputList(inputs),\n\t\t},\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0), op.Output(1)\n}", "func merge(arr1 []int, arr2 []int) []int {\n\t// Merged array\n\tvar arr []int\n\t// Use two indices to track progress through each array\n\ti1, i2 := 0, 0\n\tfor i1 < len(arr1) || i2 < len(arr2) {\n\t\tif i1 == len(arr1) {\n\t\t\tarr = append(arr, arr2[i2])\n\t\t\ti2++\n\t\t} else if i2 == len(arr2) {\n\t\t\tarr = append(arr, arr1[i1])\n\t\t\ti1++\n\t\t} else if arr1[i1] < arr2[i2] {\n\t\t\tarr = append(arr, arr1[i1])\n\t\t\ti1++\n\t\t} else {\n\t\t\tarr = append(arr, arr2[i2])\n\t\t\ti2++\n\t\t}\n\t}\n\treturn arr\n}", "func TestMergeTagValueIterators(t *testing.T) {\n\titr := tsi1.MergeTagValueIterators(\n\t\t&TagValueIterator{Elems: []TagValueElem{\n\t\t\t{value: []byte(\"aaa\")},\n\t\t\t{value: []byte(\"bbb\"), deleted: true},\n\t\t\t{value: []byte(\"ccc\")},\n\t\t}},\n\t\t&TagValueIterator{},\n\t\t&TagValueIterator{Elems: []TagValueElem{\n\t\t\t{value: []byte(\"bbb\")},\n\t\t\t{value: []byte(\"ccc\"), deleted: true},\n\t\t\t{value: []byte(\"ddd\")},\n\t\t}},\n\t)\n\n\tif e := itr.Next(); !bytes.Equal(e.Value(), []byte(\"aaa\")) || e.Deleted() {\n\t\tt.Fatalf(\"unexpected elem(0): %s/%v\", e.Value(), e.Deleted())\n\t} else if e := itr.Next(); !bytes.Equal(e.Value(), []byte(\"bbb\")) || !e.Deleted() {\n\t\tt.Fatalf(\"unexpected elem(1): %s/%v\", e.Value(), e.Deleted())\n\t} else if e := itr.Next(); !bytes.Equal(e.Value(), []byte(\"ccc\")) || e.Deleted() {\n\t\tt.Fatalf(\"unexpected elem(2): %s/%v\", e.Value(), e.Deleted())\n\t} else if e := itr.Next(); !bytes.Equal(e.Value(), []byte(\"ddd\")) || e.Deleted() {\n\t\tt.Fatalf(\"unexpected elem(3): %s/%v\", e.Value(), e.Deleted())\n\t} else if e := itr.Next(); e != nil {\n\t\tt.Fatalf(\"expected nil elem: %#v\", e)\n\t}\n}", "func mergeTwoSorted(arr MergeSorter, low1, high1, low2, high2 int) {\n\ti, j := low1, low2\n\tfor i<=high1 && j<=high2 {\n\t\tif arr.Less(i, j) {\n\t\t\ti++\n\t\t} else {\n\t\t\tfor k:=j; k>i; k-- {\n\t\t\t\tarr.Swap(k, k-1)\n\t\t\t}\n\t\t\ti++\n\t\t\tj++\n\t\t\thigh1++\n\t\t}\n\t}\n}", "func Merge(target sgmt.MutableSegment, srcs ...sgmt.MutableSegment) error {\n\tsafeClosers := []io.Closer{}\n\tdefer func() {\n\t\tfor _, c := range safeClosers {\n\t\t\tc.Close()\n\t\t}\n\t}()\n\n\t// for each src\n\tfor _, src := range srcs {\n\t\t// get reader for `src`\n\t\treader, err := src.Reader()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// ensure readers are all closed.\n\t\treaderCloser := x.NewSafeCloser(reader)\n\t\tsafeClosers = append(safeClosers, readerCloser)\n\n\t\t// retrieve all docs known to the reader\n\t\tdIter, err := reader.AllDocs()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// iterate over all known docs\n\t\tfor dIter.Next() {\n\t\t\td := dIter.Current()\n\t\t\t_, err := target.Insert(d)\n\t\t\tif err == nil || err == index.ErrDuplicateID {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\n\t\t// ensure no errors while iterating\n\t\tif err := dIter.Err(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// ensure no errors while closing reader\n\t\tif err := readerCloser.Close(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// all good\n\treturn nil\n}", "func (b *builder) collapsedTags(ts []*Tag, count int, flatTags bool) []*Tag {\n\tts = SortTags(ts, flatTags)\n\tif len(ts) <= count {\n\t\treturn ts\n\t}\n\n\ttagGroups := make([][]*Tag, count)\n\tfor i, t := range (ts)[:count] {\n\t\ttagGroups[i] = []*Tag{t}\n\t}\n\tfor _, t := range (ts)[count:] {\n\t\tg, d := 0, tagDistance(t, tagGroups[0][0])\n\t\tfor i := 1; i < count; i++ {\n\t\t\tif nd := tagDistance(t, tagGroups[i][0]); nd < d {\n\t\t\t\tg, d = i, nd\n\t\t\t}\n\t\t}\n\t\ttagGroups[g] = append(tagGroups[g], t)\n\t}\n\n\tvar nts []*Tag\n\tfor _, g := range tagGroups {\n\t\tl, w, c := b.tagGroupLabel(g)\n\t\tnts = append(nts, &Tag{\n\t\t\tName: l,\n\t\t\tFlat: w,\n\t\t\tCum: c,\n\t\t})\n\t}\n\treturn SortTags(nts, flatTags)\n}", "func Merge(metrics map[string]metricSource.MetricData, other map[string]metricSource.MetricData) map[string]metricSource.MetricData {\n\tresult := make(map[string]metricSource.MetricData, len(metrics)+len(other))\n\tfor k, v := range metrics {\n\t\tresult[k] = v\n\t}\n\tfor k, v := range other {\n\t\tresult[k] = v\n\t}\n\treturn result\n}", "func (res *ruleMatchResults) merge(other ruleMatchResults) *ruleMatchResults {\n\tif res.cutoverNanos < other.cutoverNanos {\n\t\tres.cutoverNanos = other.cutoverNanos\n\t}\n\tres.pipelines = append(res.pipelines, other.pipelines...)\n\treturn res\n}", "func mergeTwoArrayIntoRet(nums1 []int, m int, nums2 []int, n int) {\n\tvar i, j int\n\tvar ret []int\n\tfor {\n\t\tif i == m || j == n {\n\t\t\tbreak\n\t\t}\n\t\tif nums1[i] < nums2[j] {\n\t\t\tret = append(ret, nums1[i])\n\t\t\ti++\n\t\t} else if nums1[i] > nums2[j] {\n\t\t\tret = append(ret, nums2[j])\n\t\t\tj++\n\t\t} else {\n\t\t\tret = append(ret, nums1[i], nums2[j])\n\t\t\ti++\n\t\t\tj++\n\t\t}\n\t}\n\tif i == m && j < n {\n\t\tret = append(ret, nums2[j:]...)\n\t} else if j == n && i < m {\n\t\tret = append(ret, nums1[i:]...)\n\t}\n\tnums1 = ret\n}", "func Merge(a, b IntSet, reuse []int) IntSet {\n\tswitch {\n\tcase a.Empty():\n\t\treturn b\n\tcase b.Empty():\n\t\treturn a\n\tcase a.Inverse:\n\t\tif b.Inverse {\n\t\t\treturn IntSet{Inverse: true, Set: intersect(a.Set, b.Set, reuse)}\n\t\t}\n\t\treturn IntSet{Inverse: true, Set: subtract(a.Set, b.Set, reuse)}\n\tcase b.Inverse:\n\t\treturn IntSet{Inverse: true, Set: subtract(b.Set, a.Set, reuse)}\n\t}\n\treturn IntSet{Set: combine(a.Set, b.Set, reuse)}\n}", "func (r *AggregateMetadata) Merge(other AggregateMetadata) {\n\tfor k, v := range other {\n\t\t(*r)[k] += v\n\t}\n}", "func MergeByteSliceCodecOptions(opts ...*ByteSliceCodecOptions) *ByteSliceCodecOptions {\n\tbs := ByteSliceCodec()\n\tfor _, opt := range opts {\n\t\tif opt == nil {\n\t\t\tcontinue\n\t\t}\n\t\tif opt.EncodeNilAsEmpty != nil {\n\t\t\tbs.EncodeNilAsEmpty = opt.EncodeNilAsEmpty\n\t\t}\n\t}\n\n\treturn bs\n}", "func SeriesMerge(name string, series []*Series, colMapping []map[string]string) *Series {\n\tallCols := []string{\"time\"}\n\tmerged := Series{\n\t\tName: name,\n\t}\n\tpts := map[float64][]interface{}{}\n\tfor i, s := range series {\n\t\tindexes := []int{}\n\t\tfor k, v := range colMapping[i] {\n\t\t\tindex := s.ColIndex(k)\n\t\t\tif index != -1 {\n\t\t\t\tallCols = append(allCols, v)\n\t\t\t\tindexes = append(indexes, index)\n\t\t\t}\n\t\t}\n\t\tvar t float64 = 0.12345\n\t\tfor _, point := range s.Points {\n\t\t\t// temp bug workaround for https://github.com/influxdb/influxdb/issues/321#issuecomment-37207763\n\t\t\tv := point[0].(float64)\n\t\t\tif t == v {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tt = v\n\t\t\t// end bug\n\t\t\tpt := []interface{}{}\n\t\t\tfor _, index := range indexes {\n\t\t\t\tpt = append(pt, point[index])\n\t\t\t}\n\t\t\ttime := point[0].(float64)\n\t\t\tfor len(pts[time]) < i { // padding missing values with 0\n\t\t\t\tpts[time] = append(pts[time], 0.0)\n\t\t\t}\n\t\t\t// \"Merge\" columns of points with same timestamp together\n\t\t\tpts[time] = append(pts[time], pt...)\n\t\t}\n\t}\n\tmerged.Columns = allCols\n\tfor time, vals := range pts {\n\t\tpt := []interface{}{time}\n\t\tpt = append(pt, vals...)\n\t\tfor len(pt) < len(allCols) { // padding missing values with 0\n\t\t\tpt = append(pt, 0.0)\n\t\t}\n\t\tmerged.Points = append(merged.Points, pt)\n\t}\n\treturn &merged\n}", "func AddTagsToPodSelector(runnerBuilds []graph.Artifact, deployerArtifacts []graph.Artifact, podSelector *kubernetes.ImageList) {\n\t// This implementation is mostly picked from v1 for fixing log duplication issue when multiple deployers are used.\n\t// According to the original author \"Each Deployer will be directly responsible for adding its deployed artifacts to the PodSelector\n\t// by cross-referencing them against the list of images parsed out of the set of manifests they each deploy\". Each deploy should only\n\t// add its own deployed artifacts to the PodSelector to avoid duplicate logging when multi-deployers are used.\n\t// This implementation only streams logs for the intersection of runnerBuilds and deployerArtifacts images, not all images from a deployer\n\t// probably because at that time the team didn't want to stream logs from images not built by Skaffold, e.g. images from docker hub, but this\n\t// may change. The initial implementation was using imageName as map key for getting shared elements, this was ok as deployerArtifacts were\n\t// parsed out from skaffold config files in v1 and tag was not available if not specified. Now deployers don't own render responsibilities\n\t// anymore, instead callers pass rendered manifests to deployers, we can only parse artifacts from these rendered manifests. The imageName\n\t// from deployerArtifacts here has the default-repo value as prefix while the one from runnerBuilds doesn't. This discrepancy causes artifact.Tag\n\t// fail to add into podSelector, which leads to podWatchers fail to get events from pods. As tags are available in deployerArtifacts now, so using\n\t// tag as map key to get the shared elements.\n\tm := map[string]bool{}\n\tfor _, a := range deployerArtifacts {\n\t\tm[a.Tag] = true\n\t}\n\tfor _, artifact := range runnerBuilds {\n\t\tif _, ok := m[artifact.Tag]; ok {\n\t\t\tpodSelector.Add(artifact.Tag)\n\t\t}\n\t}\n}", "func merge(new, dst *Range) bool {\n\tif new.End() < dst.Pos {\n\t\treturn false\n\t}\n\tif new.End() > dst.End() {\n\t\tdst.Size = new.Size\n\t} else {\n\t\tdst.Size += dst.Pos - new.Pos\n\t}\n\tdst.Pos = new.Pos\n\treturn true\n}", "func ExampleIntSet_Merge() {\n\ts1 := gset.NewIntSet()\n\ts1.Add([]int{1, 2, 3, 4}...)\n\n\ts2 := gset.NewIntSet()\n\tfmt.Println(s1.Merge(s2).Slice())\n\n\t// May Output:\n\t// [1 2 3 4]\n}", "func UnionTags(tagSets [][]Tag) []Tag {\n\th := TagSetsHeap(tagSets)\n\theap.Init(&h)\n\tset := []Tag{}\n\tfor h.Len() > 0 {\n\t\tcur := h[0]\n\t\ttag := cur[0]\n\t\tif len(set) == 0 || set[len(set)-1] != tag {\n\t\t\tset = append(set, tag)\n\t\t}\n\t\tif len(cur) == 1 {\n\t\t\theap.Pop(&h)\n\t\t} else {\n\t\t\th[0] = cur[1:]\n\t\t\theap.Fix(&h, 0)\n\t\t}\n\t}\n\treturn set\n}", "func (a *FloatArray) Merge(b *FloatArray) {\n\tif a.Len() == 0 {\n\t\t*a = *b\n\t\treturn\n\t}\n\n\tif b.Len() == 0 {\n\t\treturn\n\t}\n\n\t// Normally, both a and b should not contain duplicates. Due to a bug in older versions, it's\n\t// possible stored blocks might contain duplicate values. Remove them if they exists before\n\t// merging.\n\t// a = a.Deduplicate()\n\t// b = b.Deduplicate()\n\n\tif a.MaxTime() < b.MinTime() {\n\t\ta.Timestamps = append(a.Timestamps, b.Timestamps...)\n\t\ta.Values = append(a.Values, b.Values...)\n\t\treturn\n\t}\n\n\tif b.MaxTime() < a.MinTime() {\n\t\tvar tmp FloatArray\n\t\ttmp.Timestamps = append(b.Timestamps, a.Timestamps...)\n\t\ttmp.Values = append(b.Values, a.Values...)\n\t\t*a = tmp\n\t\treturn\n\t}\n\n\tout := NewFloatArrayLen(a.Len() + b.Len())\n\ti, j, k := 0, 0, 0\n\tfor i < len(a.Timestamps) && j < len(b.Timestamps) {\n\t\tif a.Timestamps[i] < b.Timestamps[j] {\n\t\t\tout.Timestamps[k] = a.Timestamps[i]\n\t\t\tout.Values[k] = a.Values[i]\n\t\t\ti++\n\t\t} else if a.Timestamps[i] == b.Timestamps[j] {\n\t\t\tout.Timestamps[k] = b.Timestamps[j]\n\t\t\tout.Values[k] = b.Values[j]\n\t\t\ti++\n\t\t\tj++\n\t\t} else {\n\t\t\tout.Timestamps[k] = b.Timestamps[j]\n\t\t\tout.Values[k] = b.Values[j]\n\t\t\tj++\n\t\t}\n\t\tk++\n\t}\n\n\tif i < len(a.Timestamps) {\n\t\tn := copy(out.Timestamps[k:], a.Timestamps[i:])\n\t\tcopy(out.Values[k:], a.Values[i:])\n\t\tk += n\n\t} else if j < len(b.Timestamps) {\n\t\tn := copy(out.Timestamps[k:], b.Timestamps[j:])\n\t\tcopy(out.Values[k:], b.Values[j:])\n\t\tk += n\n\t}\n\n\ta.Timestamps = out.Timestamps[:k]\n\ta.Values = out.Values[:k]\n}", "func (kvs KeyValues) Merge(other KeyValues) KeyValues {\n\tif len(other) == 0 {\n\t\treturn kvs.Clone()\n\t}\n\tm := kvs.Map()\n\tfor _, item := range other {\n\t\tm[item.Key] = item.Value\n\t}\n\tmerged := make(KeyValues, len(m))\n\tidx := 0\n\tfor key, value := range m {\n\t\tmerged[idx] = &protoMetricsV1.KeyValue{\n\t\t\tKey: key,\n\t\t\tValue: value,\n\t\t}\n\t\tidx++\n\t}\n\tsort.Sort(merged)\n\treturn merged\n}", "func mergeSlice(nums []uint64) uint64 {\n\tvar s string\n\tfor i := range nums {\n\t\ts += strconv.Itoa(int(nums[i]))\n\n\t}\n\tn, _ := strconv.Atoi(s)\n\treturn uint64(n)\n}" ]
[ "0.6697766", "0.63986164", "0.6325036", "0.61794055", "0.58035576", "0.57719207", "0.5753241", "0.5650223", "0.5627464", "0.55612606", "0.55480397", "0.55223817", "0.54399157", "0.5435634", "0.54297525", "0.54236025", "0.5373789", "0.5337852", "0.5319766", "0.52526253", "0.5242719", "0.5217532", "0.52160615", "0.5213101", "0.5180664", "0.517454", "0.51579565", "0.5119701", "0.51150113", "0.5094918", "0.5088626", "0.504886", "0.50424826", "0.5033724", "0.5030624", "0.5004878", "0.5001474", "0.4985188", "0.49803603", "0.4974703", "0.49526176", "0.4949056", "0.49481592", "0.49162942", "0.4915413", "0.49082738", "0.4906283", "0.48927498", "0.4888909", "0.48694718", "0.4868763", "0.48682076", "0.48616764", "0.4860704", "0.48383826", "0.48143795", "0.48124808", "0.4802025", "0.47915018", "0.47840995", "0.4771813", "0.4764065", "0.47592026", "0.47571135", "0.47341782", "0.47135976", "0.47121444", "0.47070897", "0.47027802", "0.47025442", "0.46974748", "0.46867397", "0.46791005", "0.46774122", "0.46731305", "0.46718204", "0.4659374", "0.4659374", "0.46587026", "0.46585265", "0.4656548", "0.46483225", "0.46424448", "0.46414736", "0.46404517", "0.46348488", "0.46343294", "0.46276394", "0.46260783", "0.4624959", "0.46113947", "0.4610589", "0.46094093", "0.46063334", "0.4603207", "0.4598548", "0.45984885", "0.4595174", "0.45941687", "0.45834967" ]
0.7504278
0
Test keyword search query
Тестовый поисковой запрос по ключевым словам
func TestKeywordSearch(t *testing.T) { testURL1 := TestBaseURL + "/v1/query?keyword=node01" testURL2 := TestBaseURL + "/v1/query?keyword=node02" tests := []TestStruct{ {"TestKeywordSearchNode01", testURL1, "", 200, "", 0}, {"TestKeywordSearchNode02", testURL2, "", 200, "", 0}, } for i, testCase := range tests { t.Run(testCase.testCaseName, func(t *testing.T) { resCode, resBody, _ := KeywordSearch(t, testCase.testURL) tests[i].observedStatusCode = resCode tests[i].responseBody = string(resBody) }) } DisplayTestCaseResults("TestKeywordSearch", tests, t, "uid") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func KeywordSearch(t *testing.T, url string) (statusCode int, respBody []byte, err error) {\n\n\trespStatusCode, respBody, _ := GetResponseByGet(t, url)\n\treturn respStatusCode, respBody, nil\n}", "func main() {\n // perform the search for the specified term\n search.Run(\"president\")\n}", "func verify(t *testing.T, searchQuery string, searchResults []workitem.WorkItem, expectedCount int) {\n\t// Since this test adds test data, whether or not other workitems exist\n\t// there must be at least 1 search result returned.\n\tif len(searchResults) == expectedCount && expectedCount == 0 {\n\t\t// no point checking further, we got what we wanted.\n\t\treturn\n\t}\n\trequire.Equal(t, expectedCount, len(searchResults), \"invalid number of results in the search\")\n\n\t// These keywords need a match in the textual part.\n\tallKeywords := strings.Fields(searchQuery)\n\t// These keywords need a match optionally either as URL string or ID\t\t +\t\t\t\tkeyWord = strings.ToLower(keyWord)\n\t// optionalKeywords := []string{workItemURLInSearchString, strconv.Itoa(fxt.WorkItems[idx].Number)}\n\t// We will now check the legitimacy of the search results.\n\t// Iterate through all search results and see whether they meet the criteria\n\tfor _, searchResult := range searchResults {\n\t\tt.Logf(\"Examining workitem id=`%v` number=`%d` using keywords %v\", searchResult.ID, searchResult.Number, allKeywords)\n\t\tfor _, keyWord := range allKeywords {\n\t\t\tkeyWord = strings.ToLower(keyWord)\n\t\t\tt.Logf(\"Verifying workitem id=`%v` number=`%d` for keyword `%s`...\", searchResult.ID, searchResult.Number, keyWord)\n\t\t\tworkItemTitle := \"\"\n\t\t\tif searchResult.Fields[workitem.SystemTitle] != nil {\n\t\t\t\tworkItemTitle = strings.ToLower(searchResult.Fields[workitem.SystemTitle].(string))\n\t\t\t}\n\t\t\tworkItemDescription := \"\"\n\t\t\tif searchResult.Fields[workitem.SystemDescription] != nil {\n\t\t\t\tdescriptionField := searchResult.Fields[workitem.SystemDescription].(rendering.MarkupContent)\n\t\t\t\tworkItemDescription = strings.ToLower(descriptionField.Content)\n\t\t\t}\n\t\t\tassert.True(t,\n\t\t\t\tstrings.Contains(workItemTitle, keyWord) || strings.Contains(workItemDescription, keyWord),\n\t\t\t\t\"`%s` neither found in title `%s` nor in the description `%s` for workitem #%d\", keyWord, workItemTitle, workItemDescription, searchResult.Number)\n\t\t}\n\t}\n}", "func (s *searcher) Keyword(resp http.ResponseWriter, req *http.Request) {\n\tsearchTerms := mux.Vars(req)\n\n\tkey := searchTerms[\"keyword\"]\n\tif len(key) == 0 {\n\t\tresp.WriteHeader(http.StatusBadRequest)\n\t\tresp.Write([]byte(\"keyword is empty\"))\n\t\treturn\n\t}\n\n\tsearchPaths, err := s.searchIndex.GetTransactionPathsByKeyword(key)\n\tif err != nil {\n\t\tresp.WriteHeader(http.StatusInternalServerError)\n\t\tresp.Write([]byte(fmt.Sprintf(\"error finding transactions: %s\", err.Error())))\n\t\treturn\n\t}\n\n\ttransactions, err := s.searchIndex.GetTransactionsFromFiles(searchPaths)\n\tif err != nil {\n\t\tresp.WriteHeader(http.StatusInternalServerError)\n\t\tresp.Write([]byte(fmt.Sprintf(\"error finding transactions: %s\", err.Error())))\n\t\treturn\n\t}\n\n\tresultBytes, err := json.Marshal(transactions)\n\tif err != nil {\n\t\tresp.WriteHeader(http.StatusInternalServerError)\n\t\tresp.Write([]byte(fmt.Sprintf(\"error marshallig transactions to json: %s\", err.Error())))\n\t\treturn\n\t}\n\n\tresp.WriteHeader(http.StatusOK)\n\tresp.Write(resultBytes)\n}", "func (this *WordDictionary) Search(word string) bool {\n \n}", "func TestSearch(t *testing.T) {\n\tvar result *SearchResult\n\tvar err error\n\n\tresult, err = Search(\n\t\tSimpleQuery{\n\t\t\tSearch: \"electron\",\n\t\t\tMaxResults: 5,\n\t\t},\n\t)\n\n\tif err != nil {\n\t\tlog.Printf(\"error occurred during Search(): %v\", err)\n\t\tt.FailNow()\n\t}\n\n\tif result == nil {\n\t\tlog.Printf(\"empty SearchResult: %v\", result)\n\t\tt.FailNow()\n\t}\n\n\tif len(result.Entries) != 5 {\n\t\tlog.Printf(\"invalid length for SearchResult.entries: %v\", result.Entries)\n\t\tt.FailNow()\n\t}\n\n}", "func TestSingleQuerySearch(t *testing.T) {\n\tfor _, tItem := range testData {\n\t\tsq := NewSingleQuery(tItem.query, tItem.links)\n\t\trealFind, err := sq.QuerySearch()\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Can't make test, too much errors, %v\", err)\n\t\t}\n\t\tif len(realFind) != len(tItem.results) {\n\t\t\tt.Errorf(\"got %v slice of resources, need to %v (query=%s)\", realFind, tItem.results, tItem.query)\n\t\t} else {\n\t\t\t// detail comparison\n\t\t\tfor _, realItem := range realFind {\n\t\t\t\texists := false\n\t\t\t\tfor _, expected := range tItem.results {\n\t\t\t\t\tif expected == realItem {\n\t\t\t\t\t\texists = true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !exists {\n\t\t\t\t\tt.Errorf(\"wrong content, got %v slice of resources, need to %v (query=%s)\", realFind, tItem.results, tItem.query)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func (tmdb *TMDb) SearchKeyword(name string, options map[string]string) (*KeywordSearchResults, error) {\n\tvar availableOptions = map[string]struct{}{\n\t\t\"page\": {}}\n\tvar keywords KeywordSearchResults\n\tsafeName := url.QueryEscape(name)\n\toptionsString := getOptionsString(options, availableOptions)\n\turi := fmt.Sprintf(\"%s/search/keyword?query=%s&api_key=%s%s\", baseURL, safeName, tmdb.apiKey, optionsString)\n\tresult, err := getTmdb(uri, &keywords)\n\treturn result.(*KeywordSearchResults), err\n}", "func main() {\n\tt := Constructor()\n\tt.AddWord(\"bad\")\n\tt.AddWord(\"dad\")\n\tt.AddWord(\"mad\")\n\ts := \"pad\"\n\tfmt.Printf(\"find %q, get %t\\n\", s, t.Search(s))\n\ts = \"dad\"\n\tfmt.Printf(\"find %q, get %t\\n\", s, t.Search(s))\n\ts = \".ad\"\n\tfmt.Printf(\"find %q, get %t\\n\", s, t.Search(s))\n\ts = \"b..\"\n\tfmt.Printf(\"find %q, get %t\\n\", s, t.Search(s))\n\ts = \".adx\"\n\tfmt.Printf(\"find %q, get %t\\n\", s, t.Search(s))\n\ts = \".ax\"\n\tfmt.Printf(\"find %q, get %t\\n\", s, t.Search(s))\n\ts = \".\"\n\tfmt.Printf(\"find %q, get %t\\n\", s, t.Search(s))\n\ts = \"d.\"\n\tfmt.Printf(\"find %q, get %t\\n\", s, t.Search(s))\n}", "func searchSongs(ctx context.Context, w http.ResponseWriter, r *http.Request) {\n criteria := pat.Param(ctx, \"searchCriteria\")\n result := searchSongsDA(criteria)\n fmt.Fprintf(w, result)\n}", "func (sq *SQ3Driver) realSearch(pattern string, ignoreCase, searchContent bool, ch SearchFeed) {\n\tcolumn := \"key\"\n\tif ignoreCase {\n\t\tcolumn = \"lc_key\"\n\t\tpattern = strings.ToLower(pattern)\n\t}\n\tpattern = \"%\" + pattern + \"%\"\n\n\tsql := fmt.Sprintf(\"SELECT key FROM %v WHERE %v LIKE ?\", dbTable, column)\n\tfmt.Printf(\"DEBUG: Search sql: %v\\n\", sql)\n\trows, err := sq.DB.Query(sql, pattern)\n\tif err != nil {\n\t\tfmt.Printf(\"Error starting query: %v\\n\", err)\n\t\treturn\n\t}\n\tdefer rows.Close()\n\n\terrorStrings := \"\"\n\n\tfor rows.Next() {\n\t\tvar key string\n\t\terr = rows.Scan(&key)\n\t\tif err != nil {\n\t\t\terrorStrings = errorStrings + fmt.Sprintf(\"Error: %v\\n\", err)\n\t\t} else {\n\t\t\t// emit this result\n\t\t\tch <- &DBObj{Key: key}\n\t\t}\n\t}\n\n\tif len(errorStrings) > 0 {\n\t\terr = fmt.Errorf(\"Errors found:\\n%v\", errorStrings)\n\t}\n\t// Return that error as a key for now\n\tch <- &DBObj{Key: errorStrings}\n\n\t// Finally close our channel to notify any consumers we're done.\n\tclose(ch)\n}", "func Test_Search(t *testing.T) {\n\tfor _, testCase := range searchTestCases {\n\t\tresult := org.Search(org.CEO, testCase.name)\n\n\t\tif testCase.expected && result == nil {\n\t\t\tt.Errorf(\"Expected to find '%s', but did not find\", testCase.name)\n\t\t\tt.Fail()\n\t\t} else if !testCase.expected && result != nil {\n\t\t\tt.Errorf(\"Expected to not find '%s', but found\", testCase.name)\n\t\t}\n\t}\n}", "func (this *Trie) Search(word string) bool {\n\n}", "func TestEmptyInputString(t *testing.T) {\n\temptyString := \"\"\n\tfa := NewFrequencyAnalyzer(emptyString)\n\n\tactualWords := fa.Search()\n\tassert.Nil(t, actualWords)\n}", "func FakeSearch(kind, title, url string) SearchFunc {\n\treturn func(query string) Result {\n\t\ttime.Sleep(time.Duration(100 * time.Millisecond)) // artificial delay for instructional reasons\n\t\treturn Result{\n\t\t\tTitle: fmt.Sprintf(\"Query: %q | Source: %s -> Result: %s\", query, kind, title),\n\t\t\tURL: url,\n\t\t}\n\t}\n}", "func TestSearchWord(t *testing.T) {\n\ts, dir := createTestServer(5, 8, 8, 0.000001, uint64(100000))\n\tdefer os.RemoveAll(dir)\n\n\tc, cliDir := createTestClient(s, 0)\n\tdefer os.RemoveAll(cliDir)\n\n\tcontents := []string{\n\t\t\"This is a simple test file\",\n\t\t\"This is another test file\",\n\t\t\"This is a different test file\",\n\t\t\"This is yet another test file\",\n\t\t\"This is the last test file\"}\n\n\tfilenames := make([]string, 5)\n\n\tfor i := 0; i < len(contents); i++ {\n\t\tfile := createTestFile(contents[i])\n\t\tdefer os.Remove(file)\n\t\t_, filenames[i] = path.Split(file)\n\t\tc.AddFile(file)\n\t}\n\n\tc2, cliDir2 := createTestClient(s, 1)\n\tdefer os.RemoveAll(cliDir2)\n\n\texpected := []string{filenames[1], filenames[3]}\n\tsort.Strings(expected)\n\tactual, _, err := c2.SearchWord(\"another\")\n\tif err != nil {\n\t\tt.Fatalf(\"error when searching word: %s\", err)\n\t}\n\tsort.Strings(actual)\n\tif !reflect.DeepEqual(expected, actual) {\n\t\tt.Fatalf(\"incorrect search result\")\n\t}\n\n\tempty, _, err := c2.SearchWord(\"non-existing\")\n\tif err != nil {\n\t\tt.Fatalf(\"error when searching word: %s\", err)\n\t}\n\tif len(empty) > 0 {\n\t\tt.Fatalf(\"filenames found for non-existing word\")\n\t}\n\n\texpected = filenames\n\tsort.Strings(expected)\n\tactual, _, err = c2.SearchWord(\"file\")\n\tif err != nil {\n\t\tt.Fatalf(\"error when searching word: %s\", err)\n\t}\n\tsort.Strings(actual)\n\tif !reflect.DeepEqual(expected, actual) {\n\t\tt.Fatalf(\"incorrect search result\")\n\t}\n}", "func (m defaultMatcher) Search(feed *Feed, searchTerm string) ([]*Result, error) {\n\treturn nil, nil\n}", "func TestSearch(t *testing.T) {\n\n\t\tclient := http.Client{}\n\t\treq, _ := http.NewRequest(\"GET\",\"http://127.0.0.1:8080/api/coupons/fetch?brand=BurgerKong\", nil)\n\n\t\tresp, err := client.Do(req)\n\n\t\tif(err != nil) {\n\n\t\t\tt.Fail()\n\t\t\tt.Logf(\"Error making post request for token modification\")\n\t\t\treturn\n\t\t}\n\n\t\tbody, err := ioutil.ReadAll(resp.Body)\n\n\t\tif(err != nil) {\n\n\t\t\tt.Fail()\n\t\t\tt.Log(\"Error reading response body from token modification\")\n\t\t\treturn\n\t\t}\n\n\t\t// Unpack our coupon(s) - hopefully just one\n\t\tmyCoupons := make([]Structures.Coupon, 0)\n\t\tjson.Unmarshal(body, &myCoupons)\n\n\t\t// OK so the first result should match our second coupon\n\t\tif(myCoupons[0].Brand != coupons[1].Brand) {\n\n\t\t\tt.Fail()\n\t\t\tt.Log(\"Search did not give the expected result\")\n\t\t}\n\t}", "func isKeyword(in string) bool {\n\tswitch strings.ToUpper(in) {\n\tcase \"SELECT\", \"INSERT\", \"UPDATE\", \"DELETE\":\n\t\treturn true\n\tcase \"FROM\", \"WHERE\", \"AND\", \"OR\", \"IS\", \"NOT\", \"IN\":\n\t\treturn true\n\tcase \"INNER\", \"JOIN\":\n\t\treturn true\n\t}\n\n\treturn false\n}", "func FakeSearch(kind, title, URL string) SearchFunc {\n\treturn func(query string) Result {\n\t\ttime.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)\n\t\treturn Result{\n\t\t\tfmt.Sprintf(\"%s(%q): %s\", kind, query, title),\n\t\t\tURL}\n\t}\n}", "func (m *FeedDAO) Search(keyword string, limit int) ([]searchResult, error)", "func (rec *Record) Search(text string) bool {\n\n\tif strings.Contains(strings.ToLower(rec.Title), text) {\n\t\treturn true\n\t}\n\tif strings.Contains(strings.ToLower(rec.Account), text) {\n\t\treturn true\n\t}\n\tif strings.Contains(strings.ToLower(rec.Password), text) {\n\t\treturn true\n\t}\n\tif strings.Contains(strings.ToLower(strings.Join(rec.Tags, \", \")), text) {\n\t\treturn true\n\t}\n\tif strings.Contains(strings.ToLower(rec.Url), text) {\n\t\treturn true\n\t}\n\tif strings.Contains(strings.ToLower(rec.Notes), text) {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func testFrontMatterKeywords(mdBytes []byte) error {\n\tfm, _, err := frontparser.ParseFrontmatterAndContent(mdBytes)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tkeywords, exists := fm[\"keywords\"]\n\n\t// it's ok to have a page without keywords\n\tif exists == false {\n\t\treturn nil\n\t}\n\n\tif _, ok := keywords.(string); !ok {\n\t\treturn errors.New(\"keywords should be a comma separated string\")\n\t}\n\n\treturn nil\n}", "func TestWordsWithLowerAndUpperCases(t *testing.T) {\n\tinputString := \"Do you know what this word means? dO You kNow whaT thIs Word meanS?\"\n\tfa := NewFrequencyAnalyzer(inputString)\n\n\tactualWords := fa.Search()\n\texpectedWords := []string{\"do\", \"you\", \"know\", \"what\", \"this\", \"word\", \"means\"}\n\tassert.Equal(t, expectedWords, actualWords)\n}", "func setupSearch() {\n\n}", "func TestSearchCorrectPayload(t *testing.T) {\n\tdb := DBSession()\n\tdefer db.Close() // clean up when we’re done\n\n\tSetupData(db)\n\ta := assert.New(t)\n\trouter := mux.NewRouter()\n\trouter.HandleFunc(\"/cb_service/contact_book/search/{query}\", http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {\n\t\t// save it in the request context\n\t\tctx := context.WithValue(req.Context(), dbSessionKey, db)\n\t\treq.Header.Set(\"Content-Type\", contentType)\n\t\treq.Header.Set(\"Authorization\", encodedAuthToken)\n\t\treq = req.WithContext(ctx)\n\t\tsearchH(res, req)\n\t}))\n\n\tserver := httptest.NewServer(router)\n\tdefer server.Close()\n\treqURL := server.URL + \"/cb_service/contact_book/search/Yog\"\n\tres, err := http.Get(reqURL)\n\tif err != nil {\n\t\tl.Printf(\"Cannot Make Request :%v \", err)\n\t\ta.Error(err)\n\t}\n\n\ta.Equal(res.StatusCode, http.StatusOK)\n\tClearData(db)\n}", "func Search(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tl := logger.New(\"default\")\n\n\tquery := r.URL.Query().Get(\"q\")\n\tresults, err := catalog.SearchMulti(url.QueryEscape(query))\n\tif err != nil {\n\t\tl.Errorf(err.Error())\n\t\thttp.Error(w, \"HTTP 500 : Internal Server Error\", 500)\n\t\treturn\n\t}\n\tcontext := struct {\n\t\tTitle string\n\t\tQuery string\n\t\tResults tmdb.SearchMultiResult\n\t}{\n\t\t\"tvt.io\",\n\t\tquery,\n\t\tresults,\n\t}\n\tt := template.Must(template.ParseFiles(\n\t\t\"templates/search.html\",\n\t\t\"templates/partials/facebook.html\",\n\t\t\"templates/partials/footer.html\",\n\t\t\"templates/partials/javascript.html\",\n\t\t\"templates/partials/css.html\",\n\t))\n\tt.Execute(w, context)\n}", "func (t *Trie) Query(text string) (sanitize string, keywords []string, exist bool) {\n\tchars := []rune(text)\n\ttxtLen := len(chars)\n\n\tif txtLen == 0 {\n\t\treturn\n\t}\n\n\tnode := t.root\n\tt.mu.RLock()\n\tfor i := 0; i < txtLen; i++ {\n\t\tif _, ok := node.children[chars[i]]; !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tnode = node.children[chars[i]]\n\t\tfor j := i + 1; j < txtLen; j++ {\n\t\t\tif _, ok := node.children[chars[j]]; !ok {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tnode = node.children[chars[j]]\n\t\t\tif node.end {\n\t\t\t\tkeywords = append(keywords, string(chars[i:j+1]))\n\t\t\t\tt.replaceWithMask(chars, i, j+1)\n\t\t\t}\n\t\t}\n\t\tnode = t.root\n\t}\n\n\tif len(keywords) > 0 {\n\t\texist = true\n\t}\n\tsanitize = string(chars)\n\tt.mu.RUnlock()\n\n\treturn\n}", "func (m Model) Search(query string) []Result {\n\tvar results []Result\n\n\twords := Tokenize(query)\n\tif len(words) == 0 {\n\t\treturn results\n\t}\n\n\t// main search query\n\tif err := m.PG.Model(&Occurence{}).\n\t\tColumnExpr(\"(SELECT name FROM files WHERE id = occurence.file_id) as file_name\").\n\t\tColumnExpr(\"SUM(occurence.count) as sum\").\n\t\tColumnExpr(\"array_agg(occurence.word_id) as words\").\n\t\tJoin(\"JOIN words on occurence.word_id = words.id\").\n\t\tWhere(\"words.word in (?)\", pg.In(words)).\n\t\tGroup(\"occurence.file_id\").\n\t\tOrder(\"sum DESC\").\n\t\tSelect(&results); err != nil {\n\t\tlog.Println(err.Error())\n\t}\n\n\treturn results\n}", "func (c *Client) Search(keyword string) ([]Movie, error) {\n\treturn []Movie{}, fmt.Errorf(\"not implemented\")\n}", "func SearchTerm(query url.Values, m martini.Context) {\n\tp := SearchParameter{}\n\tp.Search = query.Get(\"search\")\n\tp.Success = p.Search != \"\"\n\n\tm.Map(p)\n}", "func TestIndex(t *testing.T) {\n\tdefer os.RemoveAll(\"testidx\")\n\n\tindex, err := New(\"testidx\", mapping)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer index.Close()\n\n\t// index all the people\n\tfor _, person := range people {\n\t\terr = index.Index(person.Identifier, person)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}\n\n\ttermQuery := NewTermQuery(\"marti\").SetField(\"name\")\n\tsearchRequest := NewSearchRequest(termQuery)\n\tsearchResult, err := index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for term query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"a\" {\n\t\t\tt.Errorf(\"expected top hit id 'a', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\ttermQuery = NewTermQuery(\"noone\").SetField(\"name\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(0) {\n\t\tt.Errorf(\"expected 0 total hits\")\n\t}\n\n\tmatchPhraseQuery := NewMatchPhraseQuery(\"long name\")\n\tsearchRequest = NewSearchRequest(matchPhraseQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for phrase query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"b\" {\n\t\t\tt.Errorf(\"expected top hit id 'b', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\ttermQuery = NewTermQuery(\"walking\").SetField(\"name\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(0) {\n\t\tt.Errorf(\"expected 0 total hits\")\n\t}\n\n\tmatchQuery := NewMatchQuery(\"walking\").SetField(\"name\")\n\tsearchRequest = NewSearchRequest(matchQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for match query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"c\" {\n\t\t\tt.Errorf(\"expected top hit id 'c', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\tprefixQuery := NewPrefixQuery(\"bobble\").SetField(\"name\")\n\tsearchRequest = NewSearchRequest(prefixQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for prefix query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"d\" {\n\t\t\tt.Errorf(\"expected top hit id 'd', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\tsyntaxQuery := NewSyntaxQuery(\"+name:phone\")\n\tsearchRequest = NewSearchRequest(syntaxQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for syntax query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"d\" {\n\t\t\tt.Errorf(\"expected top hit id 'd', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\tmaxAge := 30.0\n\tnumericRangeQuery := NewNumericRangeQuery(nil, &maxAge).SetField(\"age\")\n\tsearchRequest = NewSearchRequest(numericRangeQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(2) {\n\t\tt.Errorf(\"expected 2 total hits for numeric range query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"b\" {\n\t\t\tt.Errorf(\"expected top hit id 'b', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t\tif searchResult.Hits[1].ID != \"a\" {\n\t\t\tt.Errorf(\"expected next hit id 'a', got '%s'\", searchResult.Hits[1].ID)\n\t\t}\n\t}\n\n\tstartDate = \"2010-01-01\"\n\tdateRangeQuery := NewDateRangeQuery(&startDate, nil).SetField(\"birthday\")\n\tsearchRequest = NewSearchRequest(dateRangeQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(2) {\n\t\tt.Errorf(\"expected 2 total hits for numeric range query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"d\" {\n\t\t\tt.Errorf(\"expected top hit id 'd', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t\tif searchResult.Hits[1].ID != \"c\" {\n\t\t\tt.Errorf(\"expected next hit id 'c', got '%s'\", searchResult.Hits[1].ID)\n\t\t}\n\t}\n\n\t// test that 0 time doesn't get indexed\n\tendDate = \"2010-01-01\"\n\tdateRangeQuery = NewDateRangeQuery(nil, &endDate).SetField(\"birthday\")\n\tsearchRequest = NewSearchRequest(dateRangeQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for numeric range query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"b\" {\n\t\t\tt.Errorf(\"expected top hit id 'b', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\t// test behavior of arrays\n\t// make sure we can successfully find by all elements in array\n\ttermQuery = NewTermQuery(\"gopher\").SetField(\"tags\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t} else {\n\t\tif searchResult.Total != uint64(1) {\n\t\t\tt.Errorf(\"expected 1 total hit for term query, got %d\", searchResult.Total)\n\t\t} else {\n\t\t\tif searchResult.Hits[0].ID != \"a\" {\n\t\t\t\tt.Errorf(\"expected top hit id 'a', got '%s'\", searchResult.Hits[0].ID)\n\t\t\t}\n\t\t}\n\t}\n\n\ttermQuery = NewTermQuery(\"belieber\").SetField(\"tags\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t} else {\n\t\tif searchResult.Total != uint64(1) {\n\t\t\tt.Errorf(\"expected 1 total hit for term query, got %d\", searchResult.Total)\n\t\t} else {\n\t\t\tif searchResult.Hits[0].ID != \"a\" {\n\t\t\t\tt.Errorf(\"expected top hit id 'a', got '%s'\", searchResult.Hits[0].ID)\n\t\t\t}\n\t\t}\n\t}\n\n\ttermQuery = NewTermQuery(\"notintagsarray\").SetField(\"tags\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(0) {\n\t\tt.Errorf(\"expected 0 total hits\")\n\t}\n\n\t// lookup document a\n\t// expect to find 2 values for field \"tags\"\n\ttagsCount := 0\n\tdoc, err := index.Document(\"a\")\n\tif err != nil {\n\t\tt.Error(err)\n\t} else {\n\t\tfor _, f := range doc.Fields {\n\t\t\tif f.Name() == \"tags\" {\n\t\t\t\ttagsCount++\n\t\t\t}\n\t\t}\n\t}\n\tif tagsCount != 2 {\n\t\tt.Errorf(\"expected to find 2 values for tags\")\n\t}\n}", "func Test_searchWord_FindMatchingDir_MatchingDirFound(t *testing.T) {\n\tterm := \"findme\"\n\tsubDir := \"findme\"\n\ttestingDir := \"TestDir\"\n\tdirPath, err := filepath.Abs(testingDir)\n\tif err != nil {\n\t\tt.Error(\"Couldn't get absolute path\")\n\t}\n\t//remove test Dir if exists\n\tif _, err := os.Stat(dirPath); err == nil {\n\t\tos.RemoveAll(dirPath)\n\t}\n\terr = os.Mkdir(dirPath, os.ModePerm)\n\tif err != nil {\n\t\tt.Error(\"Couldn't create test directory\")\n\t}\n\terr = os.Mkdir(filepath.Join(dirPath, subDir), os.ModePerm)\n\tif err != nil {\n\t\tt.Error(\"Dir could not be created\")\n\t}\n\tvar buf []byte\n\tresult, err := searchWord(term, dirPath, &buf)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tfmt.Println(\"Results found in test: \" + result)\n\tif !strings.Contains(result, term) {\n\t\tt.Fatal(\"Test failed! Expected \" + subDir + \" but found nothing\")\n\t}\n}", "func Search(w http.ResponseWriter, r *http.Request) {\n\tq := r.URL.Query()\n\n\tif keywords, ok := q[\"keyword\"]; ok {\n\t\tsearch := keywords[0]\n\n\t\tproducts, err := lib.Search(search)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\n\t\tbytes, err := helpers.JSONMarshal(products, true)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\n\t\tfmt.Fprintf(w, \"%s\", bytes)\n\t}\n}", "func main() {\n\t//perform the search for the specific term\n\tsearch.Run(\"president\")\n}", "func searchExact(w http.ResponseWriter, r *http.Request, db *mgo.Database, argPos int) {\n\tkey := r.FormValue(\"key\")\n\tval := r.FormValue(\"val\")\n\n\tcontext := make([]appResult, 0, 10)\n\tvar res *appResult\n\n\tc := db.C(\"machines\")\n\tvar usePath bool\n\tif key == \"apps.path\" {\n\t\tusePath = true\n\t}\n\n\terr := c.Find(bson.M{key: val}).\n\t\tSelect(bson.M{\n\t\t\"hostname\": 1,\n\t\t\"apps\": 1,\n\t\t\"_id\": 1}).\n\t\tSort(\"hostname\").\n\t\tFor(&res, func() error {\n\t\tres.Apps = filter_apps(val, res.Apps, usePath)\n\t\tcontext = append(context, *res)\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\tset.ExecuteTemplate(w, \"searchresults\", context)\n}", "func runSearch(ctx context.Context, teamsDB teams.TeamsDB, fixturesDB fixtures.DB, query string) (*SearchResults, error) {\n\tteams, err := searchTeams(ctx, teamsDB, query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfixtures, err := fixturesDB.Search(ctx, query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &SearchResults{\n\t\tQuery: query,\n\t\tFixtures: fixtures,\n\t\tTeams: teams,\n\t}, nil\n}", "func (p *plaintext) Search(key interface{}, resChan chan result.Result, wg *sync.WaitGroup) {\n\tstr := key.(string)\n\tfmt.Println(\"Search plain text, key=\", str)\n\t//开始搜索\n\tcmp := []byte(str)\n\tf, err := os.Open(p.filePath)\n\tif err != nil {\n\t\twg.Done()\n\t\treturn\n\t}\n\tsourceName := f.Name()\n\tdefer f.Close()\n\tinput := bufio.NewScanner(f)\n\tfor input.Scan() {\n\t\tinfo := input.Bytes()\n\t\tif bytes.Contains(info, cmp) {\n\t\t\tresult := result.Result{\n\t\t\t\tSource: sourceName,\n\t\t\t\tScore: 1,\n\t\t\t\tHit: str,\n\t\t\t\tText: string(info),\n\t\t\t}\n\t\t\tresChan <- result\n\t\t}\n\t}\n\twg.Done()\n}", "func (i *Index) Search(q query.Query) ([]index.Document, int, error) {\n Flag_highlight := false\n\teq := elastic.NewMatchQuery(\"body\", q.Term).Analyzer(\"whitespace\").Operator(\"and\") //Simple AND query\n if (q.Term[0] == '\"') {\n q.Term = q.Term[1:len(q.Term)-1]\n eq = elastic.NewMatchPhraseQuery(\"body\", q.Term).Analyzer(\"whitespace\").Slop(0) //Phrase Query\n }\n\t//eq := elastic.NewQueryStringQuery(q.Term)\n\t//eq := elastic.NewMatchQuery(\"body\", q.Term).Analyzer(\"whitespace\").Operator(\"and\") //Simple AND query\n //eq := elastic.NewMatchPhraseQuery(\"body\", q.Term).Analyzer(\"whitespace\").Slop(0) //Phrase Query\n\t//eq := elastic.NewMatchPhraseQuery(\"body\", q.Term).Analyzer(\"whitespace\").Slop(100000) //Proximity Query\n\n // Specify highlighter\n hl := elastic.NewHighlight()\n hl = hl.Fields(elastic.NewHighlighterField(\"body\"))\n hl = hl.HighlighterType(\"unified\")\n hl = hl.PreTags(\"<em>\").PostTags(\"</em>\")\n //src, err := hl.Source()\n //j_src, _ := json.MarshalIndent(&src, \"\", \" \")\n //fmt.Println(string(j_src))\n //fmt.Println(\"offset: \", q.Paging.Offset, \"max size: \", q.Paging.Num)\n var res *elastic.SearchResult\n var err error\n // to get latency distribution of each query\n //st_latency := time.Now()\n\n\n if Flag_highlight == true {\n res, err = i.conn.Search(i.name).Type(\"doc\").\n Query(eq).\n\t\tHighlight(hl).\n\t\tFrom(q.Paging.Offset).\n\t\tSize(q.Paging.Num).\n\t\tDo()\n } else {\n res, err = i.conn.Search(i.name).Type(\"doc\").\n Query(eq).\n\t\t//Highlight(hl).\n\t\tFrom(q.Paging.Offset).\n\t\tSize(q.Paging.Num).\n FetchSource(false).\n\t\tDo()\n }\n\n //j, _ := json.MarshalIndent(&res, \"\", \" \")\n //fmt.Println(string(j))\n //fmt.Println(\"=======\", res.Hits.TotalHits)\n //fmt.Println(\"======= took \", res.TookInMillis, \" ms\\n\\n\")\n\tif err != nil {\n\t\treturn nil, 0, err\n\t}\n\n\tret := make([]index.Document, 0, q.Paging.Num)\n\tfor _, h := range res.Hits.Hits {\n\t\tif h != nil {\n\t\t\td := index.NewDocument(h.Id, float32(*h.Score))\n\t\t\t//json.Unmarshal(*h.Source, &d.Properties);\n\t\t\tret = append(ret, d)\n\t\t\t//if err := json.Unmarshal(*h.Source, &d.Properties); err == nil {\n\t\t\t//\tret = append(ret, d)\n\t\t\t//}\n\t\t}\n\n\t}\n\n\t//return ret, int(res.TotalHits()), err\n\treturn ret, int(res.TookInMillis*10), err\n}", "func Test_searchWord_FindCaseSensitiveFile_FileFound(t *testing.T) {\n\t//can add OS detection here\n\tterm := \"findMe\"\n\tfileName := \"findMe\"\n\ttestingDir := \"TestDir\"\n\tdirPath, err := filepath.Abs(testingDir)\n\tif err != nil {\n\t\tt.Error(\"Couldn't get absolute path\")\n\t}\n\t//remove test Dir if exists\n\tif _, err := os.Stat(dirPath); err == nil {\n\t\tos.RemoveAll(dirPath)\n\t}\n\terr = os.Mkdir(dirPath, os.ModePerm)\n\tif err != nil {\n\t\tt.Error(\"Couldn't create test directory\")\n\t}\n\t_, err = os.Create(filepath.Join(dirPath, fileName))\n\tif err != nil {\n\t\tt.Error(\"File could not be created\")\n\t}\n\tvar buf []byte\n\tresult, err := searchWord(term, dirPath, &buf)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tfmt.Println(\"Results found in test: \" + result)\n\tif !strings.Contains(result, term) {\n\t\tt.Fatal(\"Test failed! Expected \" + fileName + \" but found nothing\")\n\t}\n}", "func Search(w http.ResponseWriter, r *http.Request) {\n\tviewData := BaseViewData(w, r)\n\n\ttermMap := utils.GetSearchTermsForString(r.FormValue(\"q\"), true)\n\tterms := make([]string, len(termMap))\n\ti := 0\n\tfor term := range termMap {\n\t\tterms[i] = term\n\t\ti++\n\t}\n\n\tpageNumStr := \"1\"\n\tif len(r.FormValue(\"page\")) > 0 {\n\t\tpageNumStr = r.FormValue(\"page\")\n\t}\n\n\tpage, err := strconv.Atoi(pageNumStr)\n\tif err != nil {\n\t\tviewData.NotFound(w)\n\t\treturn\n\t}\n\t// Correct for the human readable format for page numbers used\n\t// by the client here\n\tpage = page - 1\n\n\tplaceID := -1\n\tif viewData.Session != nil {\n\t\tplaceID = viewData.Session.User.PlaceID\n\t}\n\n\tlistings := []models.Listing{}\n\tif len(terms) > 0 {\n\t\tlistings, err = models.DoSearchForTerms(Base.Db, terms, page, placeID)\n\t\tif err != nil {\n\t\t\tviewData.InternalError(w)\n\t\t\treturn\n\t\t}\n\t}\n\n\tnumPages := models.GetPageCountForTerms(Base.Db, terms, placeID)\n\n\tviewData.Data = searchViewData{\n\t\tListings: listings,\n\t\tQuery: r.FormValue(\"q\"),\n\t\tPage: page + 1,\n\t\tStartOffset: page*50 + 1,\n\t\tEndOffset: page*50 + len(listings),\n\t\tMaxTotal: numPages * 50,\n\t\tOutOf: numPages,\n\t}\n\tRenderView(w, \"search#search\", viewData)\n}", "func TestSetSearchParams(t *testing.T) {\n\tstartDate, _ := time.Parse(\"2006-01-02\", \"2019-01-02\")\n\tendDate, _ := time.Parse(\"2006-01-02\", \"2019-02-02\")\n\n\ttestList := []SearchParamTest{\n\t\t{\"/anime.php\", searchModel.Query{\n\t\t\tQuery: \"naruto\",\n\t\t\tPage: 2}, \"/anime.php?c%5B%5D=a&c%5B%5D=b&c%5B%5D=c&c%5B%5D=d&c%5B%5D=e&c%5B%5D=f&c%5B%5D=g&gx=0&mid=0&p=0&q=naruto&score=0&show=50&status=0&type=0\",\n\t\t},\n\t\t{\"/manga.php\", searchModel.Query{\n\t\t\tQuery: \"naruto\",\n\t\t\tPage: 2,\n\t\t\tScore: 7}, \"/manga.php?c%5B%5D=a&c%5B%5D=b&c%5B%5D=c&c%5B%5D=d&c%5B%5D=e&c%5B%5D=f&c%5B%5D=g&gx=0&mid=0&p=0&q=naruto&score=7&show=50&status=0&type=0\",\n\t\t},\n\t\t{\"/anime.php\", searchModel.Query{\n\t\t\tQuery: \"naruto\",\n\t\t\tPage: 2,\n\t\t\tStartDate: startDate,\n\t\t\tEndDate: endDate}, \"/anime.php?c%5B%5D=a&c%5B%5D=b&c%5B%5D=c&c%5B%5D=d&c%5B%5D=e&c%5B%5D=f&c%5B%5D=g&ed=2019&em=2&ey=2&gx=0&mid=0&p=0&q=naruto&score=0&sd=2019&show=50&sm=1&status=0&sy=2&type=0\",\n\t\t},\n\t\t{\"/anime.php\", searchModel.Query{\n\t\t\tQuery: \"naruto\",\n\t\t\tGenre: []int{\n\t\t\t\t1,\n\t\t\t\t4,\n\t\t\t\t5,\n\t\t\t}}, \"/anime.php?c%5B%5D=a&c%5B%5D=b&c%5B%5D=c&c%5B%5D=d&c%5B%5D=e&c%5B%5D=f&c%5B%5D=g&genre%5B%5D=1&genre%5B%5D=4&genre%5B%5D=5&gx=0&mid=0&p=0&q=naruto&score=0&status=0&type=0\",\n\t\t},\n\t}\n\n\tfor _, param := range testList {\n\t\tu, _ := url.Parse(param.URL)\n\t\tq := SetSearchParams(u, param.Query)\n\t\tu.RawQuery = q.Encode()\n\t\tif u.String() != param.Result {\n\t\t\tt.Errorf(\"SetSearchParams() failed: expected %v got %v\", param.Result, u.String())\n\t\t}\n\t}\n}", "func (*query) _TSearch(ctx context.Context, args _TSearchArgs) _TResult {\n\treturn _TResult{}\n}", "func Test_searchWord_FindSubStringInName_MatchingFileReturned(t *testing.T) {\n\tterm := \"findme\"\n\tfileName := \"IAmAfindmeSubString.txt\"\n\ttestingDir := \"TestDir\"\n\tdirPath, err := filepath.Abs(testingDir)\n\tif err != nil {\n\t\tt.Error(\"Couldn't get absolute path\")\n\t}\n\t//remove test Dir if exists\n\tif _, err := os.Stat(dirPath); err == nil {\n\t\tos.RemoveAll(dirPath)\n\t}\n\terr = os.Mkdir(dirPath, os.ModePerm)\n\tif err != nil {\n\t\tt.Error(\"Couldn't create test directory\")\n\t}\n\t_, err = os.Create(filepath.Join(dirPath, fileName))\n\tif err != nil {\n\t\tt.Error(\"File could not be created\")\n\t}\n\tvar buf []byte\n\tresult, err := searchWord(term, dirPath, &buf)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tfmt.Println(\"Results found in test: \" + result)\n\tif !strings.Contains(result, term) {\n\t\tt.Fatal(\"Test failed! Expected \" + fileName + \" but found nothing\")\n\t}\n\n}", "func Test_searchWord_NoMatchingFiles_EmptyResultReturned(t *testing.T) {\n\ttestingDir := \"TestDir\"\n\tdirPath, err := filepath.Abs(testingDir)\n\tif err != nil {\n\t\tt.Error(\"Couldn't get absolute path\")\n\t}\n\t//remove test Dir if exists\n\tif _, err := os.Stat(dirPath); err == nil {\n\t\tos.RemoveAll(dirPath)\n\t}\n\terr = os.Mkdir(dirPath, os.ModePerm)\n\tif err != nil {\n\t\tt.Error(\"Couldn't create test directory\")\n\t}\n\tvar buf []byte\n\tresult, err := searchWord(\"nothing\", dirPath, &buf)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif len(result) > 0 {\n\t\tt.Fatal(\"No result expected but found a match\")\n\t}\n}", "func contains(keywords []string, keyword string) bool {\n\tfor _, value := range keywords {\n\t\tif keyword == value {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func processQuery(userQuery string) (keywords string) {\n\tcandidates := rake.RunRake(userQuery)\n\tkeywords = \"\"\n\tfor _, candidate := range candidates {\n\t\tkeywords += candidate.Key + \";\"\n\t}\n\treturn keywords\n\n}", "func makeSearchCondition(term string) *sqlf.Query {\n\tsearchableColumns := []string{\n\t\t\"u.commit\",\n\t\t\"u.root\",\n\t\t\"(u.state)::text\",\n\t\t\"u.failure_message\",\n\t\t\"repo.name\",\n\t\t\"u.indexer\",\n\t\t\"u.indexer_version\",\n\t}\n\n\tvar termConds []*sqlf.Query\n\tfor _, column := range searchableColumns {\n\t\ttermConds = append(termConds, sqlf.Sprintf(column+\" ILIKE %s\", \"%\"+term+\"%\"))\n\t}\n\n\treturn sqlf.Sprintf(\"(%s)\", sqlf.Join(termConds, \" OR \"))\n}", "func search(query string, ch chan<-string){\n\tgo duckDuckGoSearch(query, ch)\n\tgo googleSearch(query, ch)\n\tgo bingSearch(query, ch)\n}", "func (r Repository) index(q Quote) {\n\tconst limitSize = 3\n\n\twords := strings.FieldsFunc(q.Quote, func(r rune) bool {\n\t\tswitch r {\n\t\tcase '\\'', '!', ',', '.', '-', '…', ' ':\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t})\n\tfor _, w := range words {\n\t\twLower := strings.ToLower(w)\n\t\tif len(wLower) > limitSize {\n\t\t\tr.storeIndex(wLower, q.id)\n\t\t\tlog.Println(\"Store :\", wLower, q.id)\n\t\t}\n\t}\n}", "func search(line *base.Line) {\n\tkeys := fc.GetKeysMatching(line.Args[1])\n\tif keys == nil || len(keys) == 0 {\n\t\tbot.ReplyN(line, \"I couldn't think of anything matching '%s'.\",\n\t\t\tline.Args[1])\n\t\treturn\n\t}\n\t// RESULTS.\n\tcount := len(keys)\n\tif count > 10 {\n\t\tres := strings.Join(keys[:10], \"', '\")\n\t\tbot.ReplyN(line,\n\t\t\t\"I found %d keys matching '%s', here's the first 10: '%s'.\",\n\t\t\tcount, line.Args[1], res)\n\t} else {\n\t\tres := strings.Join(keys, \"', '\")\n\t\tbot.ReplyN(line,\n\t\t\t\"%s: I found %d keys matching '%s', here they are: '%s'.\",\n\t\t\tcount, line.Args[1], res)\n\t}\n}", "func FakeSearch(w http.ResponseWriter, r *http.Request) {\n\tLogRequest(r, \"attack\")\n\tresponse := fmt.Sprintf(`\n\t{\n \"took\" : 6,\n \"timed_out\" : false,\n \"_shards\" : {\n \"total\" : 6,\n \"successful\" : 6,\n \"failed\" : 0\n },\n \"hits\" : {\n \"total\" : 1,\n \"max_score\" : 1.0,\n \"hits\" : [ {\n \"_index\" : \".kibana\",\n \"_type\" : \"index-pattern\",\n \"_id\" : \"logstash-*\",\n \"_score\" : 1.0,\n \"_source\":{\"title\":\"logstash-*\",\"timeFieldName\":\"@timestamp\",\"customFormats\":\"{}\",\"fields\":\"[{\\\"type\\\":\\\"string\\\",\\\"indexed\\\":true,\\\"analyzed\\\":true,\\\"doc_values\\\":false,\\\"name\\\":\\\"host\\\",\\\"count\\\":0},{\\\"type\\\":\\\"string\\\",\\\"indexed\\\":false,\\\"analyzed\\\":false,\\\"name\\\":\\\"_source\\\",\\\"count\\\":0},{\\\"type\\\":\\\"string\\\",\\\"indexed\\\":true,\\\"analyzed\\\":false,\\\"doc_values\\\":false,\\\"name\\\":\\\"message.raw\\\",\\\"count\\\":0},{\\\"type\\\":\\\"string\\\",\\\"indexed\\\":false,\\\"analyzed\\\":false,\\\"name\\\":\\\"_index\\\",\\\"count\\\":0},{\\\"type\\\":\\\"string\\\",\\\"indexed\\\":true,\\\"analyzed\\\":false,\\\"doc_values\\\":false,\\\"name\\\":\\\"@version\\\",\\\"count\\\":0},{\\\"type\\\":\\\"string\\\",\\\"indexed\\\":true,\\\"analyzed\\\":true,\\\"doc_values\\\":false,\\\"name\\\":\\\"message\\\",\\\"count\\\":0},{\\\"type\\\":\\\"date\\\",\\\"indexed\\\":true,\\\"analyzed\\\":false,\\\"doc_values\\\":false,\\\"name\\\":\\\"@timestamp\\\",\\\"count\\\":0},{\\\"type\\\":\\\"string\\\",\\\"indexed\\\":true,\\\"analyzed\\\":false,\\\"name\\\":\\\"_type\\\",\\\"count\\\":0},{\\\"type\\\":\\\"string\\\",\\\"indexed\\\":true,\\\"analyzed\\\":false,\\\"name\\\":\\\"_id\\\",\\\"count\\\":0},{\\\"type\\\":\\\"string\\\",\\\"indexed\\\":true,\\\"analyzed\\\":false,\\\"doc_values\\\":false,\\\"name\\\":\\\"host.raw\\\",\\\"count\\\":0},{\\\"type\\\":\\\"geo_point\\\",\\\"indexed\\\":true,\\\"analyzed\\\":false,\\\"doc_values\\\":false,\\\"name\\\":\\\"geoip.location\\\",\\\"count\\\":0}]\"}\n }]\n }\n }`)\n\tWriteResponse(w, response)\n\treturn\n}", "func (pr *SearchRepository) Search(userID uint64, query string) (SearchVM, error) {\n\tvm := SearchVM{}\n\n\tif len(strings.TrimSpace(query)) == 0 {\n\t\treturn SearchVM{}, fmt.Errorf(\"Query string is empty\")\n\t}\n\terr := db.Where(\"user_id = ?\", userID).\n\t\tWhere(\"to_tsvector(name) @@ to_tsquery(?)\", fmt.Sprintf(\"%s:*\", query)).\n\t\tOrder(\"id asc\").Find(&vm.Categories).Error\n\tif err != nil {\n\t\treturn SearchVM{}, err\n\t}\n\n\terr = db.Preload(\"Tasks\").Preload(\"Category\").Where(\"user_id = ?\", userID).\n\t\tWhere(\"to_tsvector(name || ' ' || description) @@ to_tsquery(?)\", fmt.Sprintf(\"%s:*\", query)).\n\t\tOrder(\"archived asc, created_at asc\").Find(&vm.Projects).Error\n\tif err != nil {\n\t\treturn SearchVM{}, err\n\t}\n\n\tq := db.Where(\"user_id = ?\", userID).\n\t\tWhere(\"to_tsvector(name || ' ' || description) @@ to_tsquery(?)\", fmt.Sprintf(\"%s:*\", query)).\n\t\tPreload(\"Project\").Preload(\"Comments\").Preload(\"Category\")\n\tq = q.Preload(\"TaskLogs\", func(db *gorm.DB) *gorm.DB {\n\t\treturn db.Where(\"session_id = 0 and minutes > 0\")\n\t})\n\terr = q.Order(\"tasks.completed asc, tasks.created_at asc\").Find(&vm.Tasks).Error\n\tif err != nil {\n\t\treturn SearchVM{}, err\n\t}\n\n\terr = db.Where(\"user_id = ?\", userID).\n\t\tWhere(\"to_tsvector(contents) @@ to_tsquery(?)\", fmt.Sprintf(\"%s:*\", query)).\n\t\tOrder(\"id\").Find(&vm.Comments).Error\n\n\treturn vm, err\n}", "func TestQueryParser(t *testing.T) {\n\ttests := []struct {\n\t\tname string\n\t\tinputQuery string\n\t\texpectedProblemSelector string\n\t\texpectedEntitySelector string\n\t}{\n\t\t{\n\t\t\tname: \"valid\",\n\t\t\tinputQuery: \"PV2;problemSelector=status(open)&entitySelector=mzId(7030365576649815430)\",\n\t\t\texpectedProblemSelector: \"status(open)\",\n\t\t\texpectedEntitySelector: \"mzId(7030365576649815430)\",\n\t\t},\n\t\t{\n\t\t\tname: \"valid - empty\",\n\t\t\tinputQuery: \"PV2;\",\n\t\t},\n\t\t{\n\t\t\tname: \"valid\",\n\t\t\tinputQuery: \"PV2;entitySelector=mzId(7030365576649815430)\",\n\t\t\texpectedEntitySelector: \"mzId(7030365576649815430)\",\n\t\t},\n\t\t{\n\t\t\tname: \"valid\",\n\t\t\tinputQuery: \"PV2;problemSelector=status(open)\",\n\t\t\texpectedProblemSelector: \"status(open)\",\n\t\t},\n\t}\n\tfor _, tc := range tests {\n\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\tquery, err := NewQueryParser(tc.inputQuery).Parse()\n\n\t\t\tassert.NoError(t, err)\n\t\t\tif assert.NotNil(t, query) {\n\t\t\t\tassert.EqualValues(t, tc.expectedProblemSelector, query.GetProblemSelector())\n\t\t\t\tassert.EqualValues(t, tc.expectedEntitySelector, query.GetEntitySelector())\n\t\t\t}\n\t\t})\n\t}\n}", "func Find(name string) (string, bool) { q, ok := queries[name]; return q, ok }", "func testQuery(t *testing.T, q *Query, models []*indexedTestModel) {\n\texpected := expectedResultsForQuery(q.query, models)\n\ttestQueryRun(t, q, expected)\n\ttestQueryIDs(t, q, expected)\n\ttestQueryCount(t, q, expected)\n\ttestQueryStoreIDs(t, q, expected)\n\tcheckForLeakedTmpKeys(t, q.query)\n}", "func TestReadWithSearchQueryTaskAPI(t *testing.T) {\n\tquery := \"search\"\n\treq, err := http.NewRequest(http.MethodDelete, url+\"?query=\"+query, strings.NewReader(\"\"))\n\tif err != nil {\n\t\tt.Errorf(\"unexpected error (%v)\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\n\t// Create a response recorder.\n\trr := httptest.NewRecorder()\n\thandler := http.HandlerFunc(SearchTaskAPI)\n\n\t// Serve the request.\n\thandler.ServeHTTP(rr, req)\n\n\t// Test status code.\n\tif rr.Code != http.StatusOK {\n\t\tt.Errorf(\"Code : %v, Error : %v\", rr.Code, rr.Body.String())\n\t}\n\n\t// Test the result data.\n\tdata, err := jsonapi.UnmarshalManyPayload(rr.Body, reflect.TypeOf(&Task{}))\n\tif err != nil {\n\t\tt.Errorf(\"unexpected error (%v)\", err)\n\t}\n\n\tif len(data) == 0 {\n\t\tt.Errorf(\"expected data len, got %v\", len(data))\n\t}\n\n\t// Iter on data and check the query exist in title\n\tre := regexp.MustCompile(query)\n\tfor _, row := range data {\n\t\ttask := row.(*Task)\n\t\tif \"\" == re.FindString(task.Title) {\n\t\t\tt.Errorf(\"expected task with match title with '%v', got '%v'\", query, task.Title)\n\t\t\treturn\n\t\t}\n\t}\n\n}", "func (tp *TestParams) Keywords() []string {\n\treturn tp.Kwords\n}", "func (s *WindowsDesktopServiceV3) MatchSearch(values []string) bool {\n\tfieldVals := append(utils.MapToStrings(s.GetAllLabels()), s.GetName(), s.GetHostname())\n\treturn MatchSearch(fieldVals, values, nil)\n}", "func TestQueryParser(t *testing.T) {\n\ttests := []struct {\n\t\tname string\n\t\tinputMV2Query string\n\t\texpectedMetricSelector string\n\t\texpectedEntitySelector string\n\t\texpectedUnit string\n\t\texpectError bool\n\t}{\n\t\t// these should fail\n\t\t{\n\t\t\tname: \"percent unit does not work\",\n\t\t\tinputMV2Query: \"MV2;Percent;metricSelector=builtin:host.cpu.usage:merge(\\\"dt.entity.host\\\"):avg:names&entitySelector=type(HOST)\",\n\t\t\texpectError: true,\n\t\t},\n\t\t{\n\t\t\tname: \"missing microsecond metric unit\",\n\t\t\tinputMV2Query: \"MV2;metricSelector=builtin:service.response.server:filter(and(in(\\\"dt.entity.service\\\",entitySelector(\\\"type(service),tag(~\\\"KeptnQualityGate~\\\")\\\")))):splitBy():percentile(90)\",\n\t\t\texpectError: true,\n\t\t},\n\t\t{\n\t\t\tname: \"missing mv2 prefix\",\n\t\t\tinputMV2Query: \"MicroSecond;metricSelector=builtin:service.response.server:filter(and(in(\\\"dt.entity.service\\\",entitySelector(\\\"type(service),tag(~\\\"KeptnQualityGate~\\\")\\\")))):splitBy():percentile(90)\",\n\t\t\texpectError: true,\n\t\t},\n\t\t{\n\t\t\tname: \"missing mv2 prefix\",\n\t\t\tinputMV2Query: \"MV2;MicroSeconds;metricSelector=builtin:service.response.server:filter(and(in(\\\"dt.entity.service\\\",entitySelector(\\\"type(service),tag(~\\\"KeptnQualityGate~\\\")\\\")))):splitBy():percentile(90)\",\n\t\t\texpectError: true,\n\t\t},\n\t\t// these should not fail\n\t\t{\n\t\t\tname: \"microsecond metric works\",\n\t\t\tinputMV2Query: \"MV2;MicroSecond;metricSelector=builtin:service.response.server:filter(and(in(\\\"dt.entity.service\\\",entitySelector(\\\"type(service),tag(~\\\"KeptnQualityGate~\\\")\\\")))):splitBy():percentile(90)\",\n\t\t\texpectedMetricSelector: \"builtin:service.response.server:filter(and(in(\\\"dt.entity.service\\\",entitySelector(\\\"type(service),tag(~\\\"KeptnQualityGate~\\\")\\\")))):splitBy():percentile(90)\",\n\t\t\texpectedUnit: \"MicroSecond\",\n\t\t},\n\t\t{\n\t\t\tname: \"microsecond metric works 2\",\n\t\t\tinputMV2Query: \"MV2;MicroSecond;metricSelector=builtin:service.keyRequest.response.server:filter(and(in(\\\"dt.entity.service_method\\\",entitySelector(\\\"type(service_method),entityName(~\\\"/api/ui/v2/bootstrap~\\\")\\\")))):splitBy(\\\"dt.entity.service_method\\\"):percentile(90)\",\n\t\t\texpectedMetricSelector: \"builtin:service.keyRequest.response.server:filter(and(in(\\\"dt.entity.service_method\\\",entitySelector(\\\"type(service_method),entityName(~\\\"/api/ui/v2/bootstrap~\\\")\\\")))):splitBy(\\\"dt.entity.service_method\\\"):percentile(90)\",\n\t\t\texpectedUnit: \"MicroSecond\",\n\t\t},\n\t\t{\n\t\t\tname: \"microsecond metric works - metric selector first\",\n\t\t\tinputMV2Query: \"MV2;MicroSecond;metricSelector=builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)&entitySelector=type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)\",\n\t\t\texpectedMetricSelector: \"builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedEntitySelector: \"type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)\",\n\t\t\texpectedUnit: \"MicroSecond\",\n\t\t},\n\t\t{\n\t\t\tname: \"microsecond metric works - entity selector first - MicroSecond unit\",\n\t\t\tinputMV2Query: \"MV2;MicroSecond;entitySelector=type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)&metricSelector=builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedMetricSelector: \"builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedEntitySelector: \"type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)\",\n\t\t\texpectedUnit: \"MicroSecond\",\n\t\t},\n\t\t{\n\t\t\tname: \"microsecond metric works - entity selector first - Microsecond unit\",\n\t\t\tinputMV2Query: \"MV2;Microsecond;entitySelector=type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)&metricSelector=builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedMetricSelector: \"builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedEntitySelector: \"type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)\",\n\t\t\texpectedUnit: \"Microsecond\",\n\t\t},\n\t\t{\n\t\t\tname: \"microsecond metric works - entity selector first - microsecond unit\",\n\t\t\tinputMV2Query: \"MV2;microsecond;entitySelector=type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)&metricSelector=builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedMetricSelector: \"builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedEntitySelector: \"type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)\",\n\t\t\texpectedUnit: \"microsecond\",\n\t\t},\n\t\t{\n\t\t\tname: \"microsecond metric works - entity selector first - microSecond unit\",\n\t\t\tinputMV2Query: \"MV2;microSecond;entitySelector=type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)&metricSelector=builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedMetricSelector: \"builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedEntitySelector: \"type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)\",\n\t\t\texpectedUnit: \"microSecond\",\n\t\t},\n\t\t{\n\t\t\tname: \"byte metric works - Byte unit\",\n\t\t\tinputMV2Query: \"MV2;Byte;metricSelector=builtin:host.disk.avail:merge(\\\"dt.entity.host\\\"):merge(\\\"dt.entity.disk\\\")\",\n\t\t\texpectedMetricSelector: \"builtin:host.disk.avail:merge(\\\"dt.entity.host\\\"):merge(\\\"dt.entity.disk\\\")\",\n\t\t\texpectedUnit: \"Byte\",\n\t\t},\n\t\t{\n\t\t\tname: \"byte metric works - byte unit\",\n\t\t\tinputMV2Query: \"MV2;byte;metricSelector=builtin:host.disk.avail:merge(\\\"dt.entity.host\\\"):merge(\\\"dt.entity.disk\\\")\",\n\t\t\texpectedMetricSelector: \"builtin:host.disk.avail:merge(\\\"dt.entity.host\\\"):merge(\\\"dt.entity.disk\\\")\",\n\t\t\texpectedUnit: \"byte\",\n\t\t},\n\t}\n\tfor _, tc := range tests {\n\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\tquery, err := NewQueryParser(tc.inputMV2Query).Parse()\n\t\t\tif tc.expectError {\n\t\t\t\tassert.Error(t, err)\n\t\t\t\tassert.Nil(t, query)\n\t\t\t} else {\n\t\t\t\tassert.NoError(t, err)\n\t\t\t\tif assert.NotNil(t, query) {\n\t\t\t\t\tassert.EqualValues(t, tc.expectedUnit, query.GetUnit())\n\t\t\t\t\tassert.EqualValues(t, tc.expectedMetricSelector, query.GetQuery().GetMetricSelector())\n\t\t\t\t\tassert.EqualValues(t, tc.expectedEntitySelector, query.GetQuery().GetEntitySelector())\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n}", "func QslSearch(t *testing.T, url string) (statusCode int, respBody []byte, err error) {\n\n\trespStatusCode, respBody, _ := GetResponseByGet(t, url)\n\treturn respStatusCode, respBody, nil\n}", "func (this *Trie) Search(word string) bool {\n for _,v :=range word{\n if this.name[v-'a'] == nil{\n return false\n }\n \n this = this.name[v-'a']\n }\n \n if this.isWord == false{\n return false\n }\n \n return true\n}", "func TestGenerateQuery(t *testing.T) {\n\tfor _, test := range []struct {\n\t\tname, q, want string\n\t}{\n\t\t{\"querySearchSymbol\", SymbolQuery(SearchTypeSymbol), querySearchSymbol},\n\t\t{\"querySearchPackageDotSymbol\", SymbolQuery(SearchTypePackageDotSymbol), querySearchPackageDotSymbol},\n\t\t{\"querySearchMultiWordExact\", SymbolQuery(SearchTypeMultiWordExact), querySearchMultiWordExact},\n\t} {\n\t\tt.Run(test.name, func(t *testing.T) {\n\t\t\tif diff := cmp.Diff(test.want, test.q); diff != \"\" {\n\t\t\t\tt.Errorf(\"mismatch (-want, +got):\\n%s\", diff)\n\t\t\t}\n\t\t})\n\t}\n}", "func main() {\n\tdictionary := mydict.Dictionary{\"first\": \"first word\"}\n\tvalue, err := dictionary.Search(\"second\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t} else {\n\t\tfmt.Println(value)\n\t}\n}", "func init() {\n\tpkg.AddScript(\"Searching\",\n\t\tThe(\"actors\",\n\t\t\tCan(\"search it\").And(\"searching it\").RequiresOnly(\"prop\"),\n\t\t\tTo(\"search it\", g.ReflectToTarget(\"report search\"))),\n\t\tThe(\"props\",\n\t\t\tCan(\"report search\").And(\"reporting search\").RequiresOnly(\"actor\"),\n\t\t\tTo(\"report search\",\n\t\t\t\tg.Say(\"You find nothing unexpected.\"))),\n\n\t\t// WARNING/FIX: multi-word statements must appear before their single word variants\n\t\t// ( or the parser will attempt to match the setcond word as a noun )\n\t\tUnderstand(\"search {{something}}\").\n\t\t\tAnd(\"look inside|in|into|through {{something}}\").\n\t\t\tAs(\"search it\"))\n}", "func (estor *ElasticStore) Search(ctx context.Context, searchTerms []string, searchName bool, mustMap map[string][]string, scrollID string) ([]string, error) {\n\tquery := elastic.NewBoolQuery()\n\n\tfor _, term := range searchTerms {\n\t\tif searchName {\n\t\t\tquery = query.Should(elastic.NewFuzzyQuery(\"FirstName\", term).Fuzziness(\"AUTO\"))\n\t\t\tquery = query.Should(elastic.NewFuzzyQuery(\"LastName\", term).Fuzziness(\"AUTO\"))\n\t\t}\n\t}\n\n\tresults := []string{}\n\n\tscroll := estor.client.Scroll().\n\t\tIndex(estor.eIndex).\n\t\tQuery(query).\n\t\tSize(10).\n\t\tSort(\"_score\", false)\n\n\tif scrollID != \"\" {\n\t\tscroll = scroll.ScrollId(scrollID)\n\t}\n\n\tres, err := scroll.Do(ctx)\n\tif (err != nil && err != io.EOF) || res == nil {\n\t\treturn results, err\n\t}\n\n\tfor _, element := range res.Hits.Hits {\n\t\tresults = append(results, element.Id)\n\t}\n\treturn results, nil\n}", "func (m *MockRepository) Search(word string, begin, end int) (models.Films, bool) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Search\", word, begin, end)\n\tret0, _ := ret[0].(models.Films)\n\tret1, _ := ret[1].(bool)\n\treturn ret0, ret1\n}", "func (as *API) Search(ctx context.Context, req *pbreq.Search) (*pbresp.Results, error) {\n\tobjects, err := as.lens.KeywordSearch(req.Keywords)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar objs = make([]*pbresp.Object, len(objects))\n\tfor _, v := range objects {\n\t\tobjs = append(objs, &pbresp.Object{\n\t\t\tName: v.Name,\n\t\t\tMimeType: v.MetaData.MimeType,\n\t\t\tCategory: v.MetaData.Category,\n\t\t})\n\t}\n\n\treturn &pbresp.Results{\n\t\tObjects: objs,\n\t}, nil\n}", "func (client *Client) Query(text string) ([]string, error) {\n\tif ContainsCh(text) { // 汉字\n\t\treturn client.CliCh.Query(text, AND)\n\t}\n\treturn client.CliEn.Query(text, AND)\n\n}", "func Test_searchWord_FindMatchingFile_MatchingFileReturned(t *testing.T) {\n\tterm := \"findme\"\n\tfileName := \"findme\"\n\ttestingDir := \"TestDir\"\n\tdirPath, err := filepath.Abs(testingDir)\n\tif err != nil {\n\t\tt.Error(\"Couldn't get absolute path\")\n\t}\n\t//remove test Dir if exists\n\tif _, err := os.Stat(dirPath); err == nil {\n\t\tos.RemoveAll(dirPath)\n\t}\n\t//create test Dir\n\terr = os.Mkdir(dirPath, os.ModePerm)\n\tif err != nil {\n\t\tt.Error(\"Couldn't create test directory\")\n\t}\n\t//create test File\n\t_, err = os.Create(filepath.Join(dirPath, fileName))\n\tif err != nil {\n\t\tt.Error(\"File could not be created\")\n\t}\n\tvar buf []byte\n\tresult, err := searchWord(term, dirPath, &buf)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tfmt.Println(\"Results found in test: \" + result)\n\tif !strings.Contains(result, term) {\n\t\tt.Fatal(\"Test failed! Expected \" + fileName + \" but found nothing\")\n\t}\n}", "func (this *WordDictionary) Search(word string) bool {\n\tif len(word) == 0 {\n\t\treturn false\n\t}\n\n\treturn this.SearchWord(word)\n}", "func DoSearch(wf *aw.Workflow, arg string) (string, error) {\n\tif arg == \"\" {\n\t\treturn \"\", fmt.Errorf(\"please provide team or token input 😂\")\n\t}\n\n\tctx := context.Background()\n\tdocBaseService, err := docbase.NewClient(ctx, wf)\n\titems, err := docBaseService.List(arg)\n\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"fail to get docbase posts 😂\")\n\t}\n\n\tfor _, item := range items {\n\t\twf.\n\t\t\tNewItem(item.Title).\n\t\t\tUID(strconv.Itoa(item.ID)).\n\t\t\tSubtitle(item.User.Name).\n\t\t\tArg(item.URL).\n\t\t\tValid(true).\n\t\t\tIcon(&aw.Icon{Value: \"./icon/icon01.png\"})\n\t}\n\n\twf.WarnEmpty(\"No Posts were found.\", \"Try different query.\")\n\twf.SendFeedback()\n\n\treturn \"\", nil\n}", "func (op *ListSharedAccessOp) SearchText(val string) *ListSharedAccessOp {\n\tif op != nil {\n\t\top.QueryOpts.Set(\"search_text\", val)\n\t}\n\treturn op\n}", "func (sem SEManager) Get(keyword string) (SearchEngine, error) {\n if len(keyword) < 1 {\n return SearchEngine{}, errors.New(\"Keyword too short\")\n }\n for _, se := range sem.Engines {\n if keyword == se.Keyword {\n return se, nil\n }\n }\n return SearchEngine{}, errors.New(fmt.Sprintf(\"No search engine with keyword %s found\", keyword))\n}", "func TestSearchWordNaive(t *testing.T) {\n\ts, dir := createTestServer(5, 8, 8, 0.000001, uint64(100000))\n\tdefer os.RemoveAll(dir)\n\n\tc, cliDir := createTestClient(s, 0)\n\tdefer os.RemoveAll(cliDir)\n\n\tcontents := []string{\n\t\t\"This is a simple test file\",\n\t\t\"This is another test file\",\n\t\t\"This is a different test file\",\n\t\t\"This is yet another test file\",\n\t\t\"This is the last test file\"}\n\n\tfilenames := make([]string, 5)\n\n\tfor i := 0; i < len(contents); i++ {\n\t\tfile := createTestFile(contents[i])\n\t\tdefer os.Remove(file)\n\t\t_, filenames[i] = path.Split(file)\n\t\tc.AddFile(file)\n\t}\n\n\tc2, cliDir2 := createTestClient(s, 1)\n\tdefer os.RemoveAll(cliDir2)\n\n\texpected := []string{filenames[1], filenames[3]}\n\tsort.Strings(expected)\n\tactual, _, err := c2.SearchWordNaive(\"another\")\n\tif err != nil {\n\t\tt.Fatalf(\"error when searching word: %s\", err)\n\t}\n\tsort.Strings(actual)\n\tif !reflect.DeepEqual(expected, actual) {\n\t\tt.Fatalf(\"incorrect search result\")\n\t}\n\n\tempty, _, err := c2.SearchWordNaive(\"non-existing\")\n\tif err != nil {\n\t\tt.Fatalf(\"error when searching word: %s\", err)\n\t}\n\tif len(empty) > 0 {\n\t\tt.Fatalf(\"filenames found for non-existing word\")\n\t}\n\n\texpected = filenames\n\tsort.Strings(expected)\n\tactual, _, err = c2.SearchWordNaive(\"file\")\n\tif err != nil {\n\t\tt.Fatalf(\"error when searching word: %s\", err)\n\t}\n\tsort.Strings(actual)\n\tif !reflect.DeepEqual(expected, actual) {\n\t\tt.Fatalf(\"incorrect search result\")\n\t}\n\n}", "func (tsr *TextSearchRequest) Query(qrfj *QueryResult) (string, error) {\n\n\t// Get data\n\tres, err := http.Get(tsr.Url) // post\n\n\tif err != nil {\n\t\treturn \"ERROR: \", err\n\t}\n\n\t// Check resposne code\n\tif res.StatusCode != 200 {\n\t\treturn \"ERROR: \", errors.New(res.Status)\n\t}\n\n\t//DEBUG\n\t// // Output response headers\n\t// for key, ele := range res.Header {\n\t// \tfmt.Print(key + \": \\n\")\n\t// \tfor key1, ele1 := range ele {\n\t// \t\tfmt.Print(\" \" + string(key1) + \":\" + ele1 + \"\\n\")\n\t// \t}\n\t// }\n\t//DEBUG^^^\n\n\t// Store data in it's type\n\tbody, err := ioutil.ReadAll(res.Body)\n\n\tif tsr.ResponseType == \"json\" {\n\t\tjson.Unmarshal(body, qrfj)\n\t} else if tsr.ResponseType == \"xml\" {\n\t\txml.Unmarshal(body, qrfj)\n\t}\n\tres.Body.Close()\n\tif err != nil {\n\t\treturn string(body), err\n\t}\n\n\t// store placaes in memory\t\n\n\t// return json\n\treturn string(body), nil\n\n}", "func (s *Service) Search(c context.Context, mid, zoneid int64, mobiApp, device, platform, buvid, keyword, duration, order, filtered, lang, fromSource, recommend, parent string, plat int8, rid, highlight, build, pn, ps, isQuery int, old bool, now time.Time) (res *search.Result, err error) {\n\tconst (\n\t\t_newIPhonePGC = 6500\n\t\t_newAndroidPGC = 519010\n\t\t_newIPhoneSearch = 6500\n\t\t_newAndroidSearch = 5215000\n\t\t_newAndroidBSearch = 591200\n\t)\n\tvar (\n\t\tnewPGC, flow, isNewTwitter bool\n\t\tavids []int64\n\t\tavm map[int64]*api.Arc\n\t\towners []int64\n\t\tfollows map[int64]bool\n\t\troomIDs []int64\n\t\tlm map[int64]*live.RoomInfo\n\t\tseasonIDs []int64\n\t\tbangumis map[string]*bangumi.Card\n\t\t//tagSeasonIDs []int32\n\t\ttagBangumis map[int32]*seasongrpc.CardInfoProto\n\t\ttags []int64\n\t\ttagMyInfos []*tagmdl.Tag\n\t\tdynamicIDs []int64\n\t\tdynamicDetails map[int64]*bplus.Detail\n\t\taccInfos map[int64]*account.Info\n\t\tcooperation bool\n\t)\n\t// android 概念版 591205\n\tif (plat == model.PlatAndroid && build >= _newAndroidPGC && build != 591205) || (plat == model.PlatIPhone && build >= _newIPhonePGC && build != 7140) || (plat == model.PlatAndroidB && build >= _newAndroidBSearch) || (plat == model.PlatIPad && build >= search.SearchNewIPad) || (plat == model.PlatIpadHD && build >= search.SearchNewIPadHD) || model.IsIPhoneB(plat) {\n\t\tnewPGC = true\n\t}\n\t// 处理一个ios概念版是 7140,是否需要过滤\n\tif (plat == model.PlatAndroid && build >= _newAndroidSearch) || (plat == model.PlatIPhone && build >= _newIPhoneSearch && build != 7140) || (plat == model.PlatAndroidB && build >= _newAndroidBSearch) || model.IsIPhoneB(plat) {\n\t\tflow = true\n\t}\n\tvar (\n\t\tseasonNum int\n\t\tmovieNum int\n\t)\n\tif (plat == model.PlatIPad && build >= search.SearchNewIPad) || (plat == model.PlatIpadHD && build >= search.SearchNewIPadHD) {\n\t\tseasonNum = s.iPadSearchBangumi\n\t\tmovieNum = s.iPadSearchFt\n\t} else {\n\t\tseasonNum = s.seasonNum\n\t\tmovieNum = s.movieNum\n\t}\n\tall, code, err := s.srchDao.Search(c, mid, zoneid, mobiApp, device, platform, buvid, keyword, duration, order, filtered, fromSource, recommend, parent, plat, seasonNum, movieNum, s.upUserNum, s.uvLimit, s.userNum, s.userVideoLimit, s.biliUserNum, s.biliUserVideoLimit, rid, highlight, build, pn, ps, isQuery, old, now, newPGC, flow)\n\tif err != nil {\n\t\tlog.Error(\"%+v\", err)\n\t\treturn\n\t}\n\tif (model.IsAndroid(plat) && build > s.c.SearchBuildLimit.NewTwitterAndroid) || (model.IsIPhone(plat) && build > s.c.SearchBuildLimit.NewTwitterIOS) {\n\t\tisNewTwitter = true\n\t}\n\tif code == model.ForbidCode || code == model.NoResultCode {\n\t\tres = _emptyResult\n\t\terr = nil\n\t\treturn\n\t}\n\tres = &search.Result{}\n\tres.Trackid = all.Trackid\n\tres.Page = all.Page\n\tres.Array = all.FlowPlaceholder\n\tres.Attribute = all.Attribute\n\tres.NavInfo = s.convertNav(all, plat, build, lang, old, newPGC)\n\tif len(all.FlowResult) != 0 {\n\t\tvar item []*search.Item\n\t\tfor _, v := range all.FlowResult {\n\t\t\tswitch v.Type {\n\t\t\tcase search.TypeUser, search.TypeBiliUser:\n\t\t\t\towners = append(owners, v.User.Mid)\n\t\t\t\tfor _, vr := range v.User.Res {\n\t\t\t\t\tavids = append(avids, vr.Aid)\n\t\t\t\t}\n\t\t\t\troomIDs = append(roomIDs, v.User.RoomID)\n\t\t\tcase search.TypeVideo:\n\t\t\t\tavids = append(avids, v.Video.ID)\n\t\t\tcase search.TypeLive:\n\t\t\t\troomIDs = append(roomIDs, v.Live.RoomID)\n\t\t\tcase search.TypeMediaBangumi, search.TypeMediaFt:\n\t\t\t\tseasonIDs = append(seasonIDs, v.Media.SeasonID)\n\t\t\tcase search.TypeStar:\n\t\t\t\tif v.Star.MID != 0 {\n\t\t\t\t\towners = append(owners, v.Star.MID)\n\t\t\t\t}\n\t\t\t\tif v.Star.TagID != 0 {\n\t\t\t\t\ttags = append(tags, v.Star.TagID)\n\t\t\t\t}\n\t\t\tcase search.TypeArticle:\n\t\t\t\towners = append(owners, v.Article.Mid)\n\t\t\tcase search.TypeChannel:\n\t\t\t\ttags = append(tags, v.Channel.TagID)\n\t\t\t\tif len(v.Channel.Values) > 0 {\n\t\t\t\t\tfor _, vc := range v.Channel.Values {\n\t\t\t\t\t\tswitch vc.Type {\n\t\t\t\t\t\tcase search.TypeVideo:\n\t\t\t\t\t\t\tif vc.Video != nil {\n\t\t\t\t\t\t\t\tavids = append(avids, vc.Video.ID)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//case search.TypeLive:\n\t\t\t\t\t\t\t//\tif vc.Live != nil {\n\t\t\t\t\t\t\t//\t\troomIDs = append(roomIDs, vc.Live.RoomID)\n\t\t\t\t\t\t\t//\t}\n\t\t\t\t\t\t\t//case search.TypeMediaBangumi, search.TypeMediaFt:\n\t\t\t\t\t\t\t//\tif vc.Media != nil {\n\t\t\t\t\t\t\t//\t\ttagSeasonIDs = append(tagSeasonIDs, int32(vc.Media.SeasonID))\n\t\t\t\t\t\t\t//\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase search.TypeTwitter:\n\t\t\t\tdynamicIDs = append(dynamicIDs, v.Twitter.ID)\n\t\t\t}\n\t\t}\n\t\tg, ctx := errgroup.WithContext(c)\n\t\tif len(owners) != 0 {\n\t\t\tif mid > 0 {\n\t\t\t\tg.Go(func() error {\n\t\t\t\t\tfollows = s.accDao.Relations3(ctx, owners, mid)\n\t\t\t\t\treturn nil\n\t\t\t\t})\n\t\t\t}\n\t\t\tg.Go(func() (err error) {\n\t\t\t\tif accInfos, err = s.accDao.Infos3(ctx, owners); err != nil {\n\t\t\t\t\tlog.Error(\"%v\", err)\n\t\t\t\t\terr = nil\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t})\n\t\t}\n\t\tif len(avids) != 0 {\n\t\t\tg.Go(func() (err error) {\n\t\t\t\tif avm, err = s.arcDao.Archives2(ctx, avids); err != nil {\n\t\t\t\t\tlog.Error(\"%+v\", err)\n\t\t\t\t\terr = nil\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t})\n\t\t}\n\t\tif len(roomIDs) != 0 {\n\t\t\tg.Go(func() (err error) {\n\t\t\t\tif lm, err = s.liveDao.LiveByRIDs(ctx, roomIDs); err != nil {\n\t\t\t\t\tlog.Error(\"%+v\", err)\n\t\t\t\t\terr = nil\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t})\n\t\t}\n\t\tif len(seasonIDs) != 0 {\n\t\t\tg.Go(func() (err error) {\n\t\t\t\tif bangumis, err = s.bangumiDao.Card(ctx, mid, seasonIDs); err != nil {\n\t\t\t\t\tlog.Error(\"%+v\", err)\n\t\t\t\t\terr = nil\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t})\n\t\t}\n\t\t//if len(tagSeasonIDs) != 0 {\n\t\t//\tg.Go(func() (err error) {\n\t\t//\t\tif tagBangumis, err = s.bangumiDao.Cards(ctx, tagSeasonIDs); err != nil {\n\t\t//\t\t\tlog.Error(\"%+v\", err)\n\t\t//\t\t\terr = nil\n\t\t//\t\t}\n\t\t//\t\treturn\n\t\t//\t})\n\t\t//}\n\t\tif len(tags) != 0 {\n\t\t\tg.Go(func() (err error) {\n\t\t\t\tif tagMyInfos, err = s.tagDao.TagInfos(ctx, tags, mid); err != nil {\n\t\t\t\t\tlog.Error(\"%v \\n\", err)\n\t\t\t\t\terr = nil\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t})\n\t\t}\n\t\tif len(dynamicIDs) != 0 {\n\t\t\tg.Go(func() (err error) {\n\t\t\t\tif dynamicDetails, err = s.bplusDao.DynamicDetails(ctx, dynamicIDs, \"search\"); err != nil {\n\t\t\t\t\tlog.Error(\"%v \\n\", err)\n\t\t\t\t\terr = nil\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t})\n\t\t}\n\t\tif err = g.Wait(); err != nil {\n\t\t\tlog.Error(\"%+v\", err)\n\t\t\treturn\n\t\t}\n\t\tif all.SuggestKeyword != \"\" && pn == 1 {\n\t\t\ti := &search.Item{Title: all.SuggestKeyword, Goto: model.GotoSuggestKeyWord, SugKeyWordType: 1}\n\t\t\titem = append(item, i)\n\t\t} else if all.CrrQuery != \"\" && pn == 1 {\n\t\t\tif (model.IsAndroid(plat) && build > s.c.SearchBuildLimit.QueryCorAndroid) || (model.IsIPhone(plat) && build > s.c.SearchBuildLimit.QueryCorIOS) {\n\t\t\t\ti := &search.Item{Title: fmt.Sprintf(\"已匹配%q的搜索结果\", all.CrrQuery), Goto: model.GotoSuggestKeyWord, SugKeyWordType: 2}\n\t\t\t\titem = append(item, i)\n\t\t\t}\n\t\t}\n\t\tfor _, v := range all.FlowResult {\n\t\t\ti := &search.Item{TrackID: v.TrackID, LinkType: v.LinkType, Position: v.Position}\n\t\t\tswitch v.Type {\n\t\t\tcase search.TypeVideo:\n\t\t\t\tif (model.IsAndroid(plat) && build > s.c.SearchBuildLimit.CooperationAndroid) || (model.IsIPhone(plat) && build > s.c.SearchBuildLimit.CooperationIOS) {\n\t\t\t\t\tcooperation = true\n\t\t\t\t}\n\t\t\t\ti.FromVideo(v.Video, avm[v.Video.ID], cooperation)\n\t\t\tcase search.TypeLive:\n\t\t\t\ti.FromLive(v.Live, lm[v.Live.RoomID])\n\t\t\tcase search.TypeMediaBangumi:\n\t\t\t\ti.FromMedia(v.Media, \"\", model.GotoBangumi, bangumis)\n\t\t\tcase search.TypeMediaFt:\n\t\t\t\ti.FromMedia(v.Media, \"\", model.GotoMovie, bangumis)\n\t\t\tcase search.TypeArticle:\n\t\t\t\ti.FromArticle(v.Article, accInfos[v.Article.Mid])\n\t\t\tcase search.TypeSpecial:\n\t\t\t\ti.FromOperate(v.Operate, model.GotoSpecial)\n\t\t\tcase search.TypeBanner:\n\t\t\t\ti.FromOperate(v.Operate, model.GotoBanner)\n\t\t\tcase search.TypeUser:\n\t\t\t\tif follows[v.User.Mid] {\n\t\t\t\t\ti.Attentions = 1\n\t\t\t\t}\n\t\t\t\ti.FromUser(v.User, avm, lm[v.User.RoomID])\n\t\t\tcase search.TypeBiliUser:\n\t\t\t\tif follows[v.User.Mid] {\n\t\t\t\t\ti.Attentions = 1\n\t\t\t\t}\n\t\t\t\ti.FromUpUser(v.User, avm, lm[v.User.RoomID])\n\t\t\tcase search.TypeSpecialS:\n\t\t\t\ti.FromOperate(v.Operate, model.GotoSpecialS)\n\t\t\tcase search.TypeGame:\n\t\t\t\ti.FromGame(v.Game)\n\t\t\tcase search.TypeQuery:\n\t\t\t\ti.Title = v.TypeName\n\t\t\t\ti.FromQuery(v.Query)\n\t\t\tcase search.TypeComic:\n\t\t\t\ti.FromComic(v.Comic)\n\t\t\tcase search.TypeConverge:\n\t\t\t\tvar (\n\t\t\t\t\taids, rids, artids []int64\n\t\t\t\t\tam map[int64]*api.Arc\n\t\t\t\t\trm map[int64]*live.Room\n\t\t\t\t\tartm map[int64]*article.Meta\n\t\t\t\t)\n\t\t\t\tfor _, c := range v.Operate.ContentList {\n\t\t\t\t\tswitch c.Type {\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\taids = append(aids, c.ID)\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\trids = append(rids, c.ID)\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\tartids = append(artids, c.ID)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tg, ctx := errgroup.WithContext(c)\n\t\t\t\tif len(aids) != 0 {\n\t\t\t\t\tg.Go(func() (err error) {\n\t\t\t\t\t\tif am, err = s.arcDao.Archives2(ctx, aids); err != nil {\n\t\t\t\t\t\t\tlog.Error(\"%+v\", err)\n\t\t\t\t\t\t\terr = nil\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tif len(rids) != 0 {\n\t\t\t\t\tg.Go(func() (err error) {\n\t\t\t\t\t\tif rm, err = s.liveDao.AppMRoom(ctx, rids); err != nil {\n\t\t\t\t\t\t\tlog.Error(\"%+v\", err)\n\t\t\t\t\t\t\terr = nil\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tif len(artids) != 0 {\n\t\t\t\t\tg.Go(func() (err error) {\n\t\t\t\t\t\tif artm, err = s.artDao.Articles(ctx, artids); err != nil {\n\t\t\t\t\t\t\tlog.Error(\"%+v\", err)\n\t\t\t\t\t\t\terr = nil\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tif err = g.Wait(); err != nil {\n\t\t\t\t\tlog.Error(\"%+v\", err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\ti.FromConverge(v.Operate, am, rm, artm)\n\t\t\tcase search.TypeTwitter:\n\t\t\t\ti.FromTwitter(v.Twitter, dynamicDetails, s.c.SearchDynamicSwitch.IsUP, s.c.SearchDynamicSwitch.IsCount, isNewTwitter)\n\t\t\tcase search.TypeStar:\n\t\t\t\tif v.Star.TagID != 0 {\n\t\t\t\t\ti.URIType = search.StarChannel\n\t\t\t\t\tfor _, myInfo := range tagMyInfos {\n\t\t\t\t\t\tif myInfo != nil && myInfo.TagID == v.Star.TagID {\n\t\t\t\t\t\t\ti.IsAttention = myInfo.IsAtten\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if v.Star.MID != 0 {\n\t\t\t\t\ti.URIType = search.StarSpace\n\t\t\t\t\tif follows[v.Star.MID] {\n\t\t\t\t\t\ti.IsAttention = 1\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ti.FromStar(v.Star)\n\t\t\tcase search.TypeTicket:\n\t\t\t\ti.FromTicket(v.Ticket)\n\t\t\tcase search.TypeProduct:\n\t\t\t\ti.FromProduct(v.Product)\n\t\t\tcase search.TypeSpecialerGuide:\n\t\t\t\ti.FromSpecialerGuide(v.SpecialerGuide)\n\t\t\tcase search.TypeChannel:\n\t\t\t\ti.FromChannel(v.Channel, avm, tagBangumis, lm, tagMyInfos)\n\t\t\t}\n\t\t\tif i.Goto != \"\" {\n\t\t\t\titem = append(item, i)\n\t\t\t}\n\t\t}\n\t\tres.Item = item\n\t\tif plat == model.PlatAndroid && build < search.SearchEggInfoAndroid {\n\t\t\treturn\n\t\t}\n\t\tif all.EggInfo != nil {\n\t\t\tres.EasterEgg = &search.EasterEgg{ID: all.EggInfo.Source, ShowCount: all.EggInfo.ShowCount}\n\t\t}\n\t\treturn\n\t}\n\tvar items []*search.Item\n\tif all.SuggestKeyword != \"\" && pn == 1 {\n\t\tres.Items.SuggestKeyWord = &search.Item{Title: all.SuggestKeyword, Goto: model.GotoSuggestKeyWord}\n\t}\n\t// archive\n\tfor _, v := range all.Result.Video {\n\t\tavids = append(avids, v.ID)\n\t}\n\tif duration == \"0\" && order == \"totalrank\" && rid == 0 {\n\t\tfor _, v := range all.Result.Movie {\n\t\t\tif v.Type == \"movie\" {\n\t\t\t\tavids = append(avids, v.Aid)\n\t\t\t}\n\t\t}\n\t}\n\tif pn == 1 {\n\t\tfor _, v := range all.Result.User {\n\t\t\tfor _, vr := range v.Res {\n\t\t\t\tavids = append(avids, vr.Aid)\n\t\t\t}\n\t\t}\n\t\tif old {\n\t\t\tfor _, v := range all.Result.UpUser {\n\t\t\t\tfor _, vr := range v.Res {\n\t\t\t\t\tavids = append(avids, vr.Aid)\n\t\t\t\t}\n\t\t\t\towners = append(owners, v.Mid)\n\t\t\t\troomIDs = append(roomIDs, v.RoomID)\n\t\t\t}\n\t\t} else {\n\t\t\tfor _, v := range all.Result.BiliUser {\n\t\t\t\tfor _, vr := range v.Res {\n\t\t\t\t\tavids = append(avids, vr.Aid)\n\t\t\t\t}\n\t\t\t\towners = append(owners, v.Mid)\n\t\t\t\troomIDs = append(roomIDs, v.RoomID)\n\t\t\t}\n\t\t}\n\t}\n\tif model.IsOverseas(plat) {\n\t\tfor _, v := range all.Result.LiveRoom {\n\t\t\troomIDs = append(roomIDs, v.RoomID)\n\t\t}\n\t\tfor _, v := range all.Result.LiveUser {\n\t\t\troomIDs = append(roomIDs, v.RoomID)\n\t\t}\n\t}\n\tg, ctx := errgroup.WithContext(c)\n\tif len(owners) != 0 {\n\t\tif mid > 0 {\n\t\t\tg.Go(func() error {\n\t\t\t\tfollows = s.accDao.Relations3(ctx, owners, mid)\n\t\t\t\treturn nil\n\t\t\t})\n\t\t}\n\t}\n\tif len(avids) != 0 {\n\t\tg.Go(func() (err error) {\n\t\t\tif avm, err = s.arcDao.Archives2(ctx, avids); err != nil {\n\t\t\t\tlog.Error(\"%+v\", err)\n\t\t\t\terr = nil\n\t\t\t}\n\t\t\treturn\n\t\t})\n\t}\n\tif len(roomIDs) != 0 {\n\t\tg.Go(func() (err error) {\n\t\t\tif lm, err = s.liveDao.LiveByRIDs(ctx, roomIDs); err != nil {\n\t\t\t\tlog.Error(\"%+v\", err)\n\t\t\t\terr = nil\n\t\t\t}\n\t\t\treturn\n\t\t})\n\t}\n\tif err = g.Wait(); err != nil {\n\t\tlog.Error(\"%+v\", err)\n\t\treturn\n\t}\n\tif duration == \"0\" && order == \"totalrank\" && rid == 0 {\n\t\tvar promptBangumi, promptFt string\n\t\t// season\n\t\tbangumi := all.Result.Bangumi\n\t\titems = make([]*search.Item, 0, len(bangumi))\n\t\tfor _, v := range bangumi {\n\t\t\tsi := &search.Item{}\n\t\t\tif (model.IsAndroid(plat) && build <= _oldAndroid) || (model.IsIPhone(plat) && build <= _oldIOS) {\n\t\t\t\tsi.FromSeason(v, model.GotoBangumi)\n\t\t\t} else {\n\t\t\t\tsi.FromSeason(v, model.GotoBangumiWeb)\n\t\t\t}\n\t\t\titems = append(items, si)\n\t\t}\n\t\tres.Items.Season = items\n\t\t// movie\n\t\tmovie := all.Result.Movie\n\t\titems = make([]*search.Item, 0, len(movie))\n\t\tfor _, v := range movie {\n\t\t\tsi := &search.Item{}\n\t\t\tsi.FromMovie(v, avm)\n\t\t\titems = append(items, si)\n\t\t}\n\t\tres.Items.Movie = items\n\t\t// season2\n\t\tmb := all.Result.MediaBangumi\n\t\titems = make([]*search.Item, 0, len(mb))\n\t\tfor k, v := range mb {\n\t\t\tsi := &search.Item{}\n\t\t\tif ((plat == model.PlatIPad && build >= search.SearchNewIPad) || (plat == model.PlatIpadHD && build >= search.SearchNewIPadHD)) && (k == len(mb)-1) && all.PageInfo.MediaBangumi.NumResults > s.iPadSearchBangumi {\n\t\t\t\tpromptBangumi = fmt.Sprintf(\"查看全部番剧 ( %d ) >\", all.PageInfo.MediaBangumi.NumResults)\n\t\t\t}\n\t\t\tsi.FromMedia(v, promptBangumi, model.GotoBangumi, nil)\n\t\t\titems = append(items, si)\n\t\t}\n\t\tres.Items.Season2 = items\n\t\t// movie2\n\t\tmf := all.Result.MediaFt\n\t\titems = make([]*search.Item, 0, len(mf))\n\t\tfor k, v := range mf {\n\t\t\tsi := &search.Item{}\n\t\t\tif ((plat == model.PlatIPad && build >= search.SearchNewIPad) || (plat == model.PlatIpadHD && build >= search.SearchNewIPadHD)) && (k == len(mf)-1) && all.PageInfo.MediaFt.NumResults > s.iPadSearchFt {\n\t\t\t\tpromptFt = fmt.Sprintf(\"查看全部影视 ( %d ) >\", all.PageInfo.MediaFt.NumResults)\n\t\t\t}\n\t\t\tsi.FromMedia(v, promptFt, model.GotoMovie, nil)\n\t\t\tsi.Goto = model.GotoAv\n\t\t\titems = append(items, si)\n\t\t}\n\t\tres.Items.Movie2 = items\n\t}\n\tif pn == 1 {\n\t\t// upper + user\n\t\tvar tmp []*search.User\n\t\tif old {\n\t\t\ttmp = all.Result.UpUser\n\t\t} else {\n\t\t\ttmp = all.Result.BiliUser\n\t\t}\n\t\titems = make([]*search.Item, 0, len(tmp)+len(all.Result.User))\n\t\tfor _, v := range all.Result.User {\n\t\t\tsi := &search.Item{}\n\t\t\tsi.FromUser(v, avm, lm[v.RoomID])\n\t\t\tif follows[v.Mid] {\n\t\t\t\tsi.Attentions = 1\n\t\t\t}\n\t\t\titems = append(items, si)\n\t\t}\n\t\tif len(items) == 0 {\n\t\t\tfor _, v := range tmp {\n\t\t\t\tsi := &search.Item{}\n\t\t\t\tsi.FromUpUser(v, avm, lm[v.RoomID])\n\t\t\t\tif follows[v.Mid] {\n\t\t\t\t\tsi.Attentions = 1\n\t\t\t\t}\n\t\t\t\tif old {\n\t\t\t\t\tsi.IsUp = true\n\t\t\t\t}\n\t\t\t\titems = append(items, si)\n\t\t\t}\n\t\t}\n\t\tres.Items.Upper = items\n\t}\n\titems = make([]*search.Item, 0, len(all.Result.Video))\n\tfor _, v := range all.Result.Video {\n\t\tsi := &search.Item{}\n\t\tsi.FromVideo(v, avm[v.ID], cooperation)\n\t\titems = append(items, si)\n\t}\n\tres.Items.Archive = items\n\t// live room\n\tif model.IsOverseas(plat) {\n\t\titems = make([]*search.Item, 0, len(all.Result.LiveRoom))\n\t\tfor _, v := range all.Result.LiveRoom {\n\t\t\tsi := &search.Item{}\n\t\t\tsi.FromLive(v, lm[v.RoomID])\n\t\t\titems = append(items, si)\n\t\t}\n\t\tres.Items.LiveRoom = items\n\t\t// live user\n\t\titems = make([]*search.Item, 0, len(all.Result.LiveUser))\n\t\tfor _, v := range all.Result.LiveUser {\n\t\t\tsi := &search.Item{}\n\t\t\tsi.FromLive(v, lm[v.RoomID])\n\t\t\titems = append(items, si)\n\t\t}\n\t\tres.Items.LiveUser = items\n\t}\n\treturn\n}", "func Test_searchWord_MatchingFileWithinMatchingDir_BothResultsReturned(t *testing.T) {\n\tterm := \"findme\"\n\tsubDir := \"findme\"\n\tfileName := \"findme\"\n\ttestingDir := \"TestDir\"\n\tdirPath, err := filepath.Abs(testingDir)\n\tif err != nil {\n\t\tt.Error(\"Couldn't get absolute path\")\n\t}\n\t//remove test Dir if exists\n\tif _, err := os.Stat(dirPath); err == nil {\n\t\tos.RemoveAll(dirPath)\n\t}\n\t//create test Dir\n\terr = os.Mkdir(dirPath, os.ModePerm)\n\tif err != nil {\n\t\tt.Error(\"Couldn't create test directory\")\n\t}\n\t//crete sub Dir\n\tsubDirPath, err := filepath.Abs(filepath.Join(dirPath,subDir))\n\terr = os.Mkdir(subDirPath, os.ModePerm)\n\tif err != nil {\n\t\tt.Error(\"Sub dir could not be created\")\n\t}\n\t//create file in nested dir\n\t_, err = os.Create(filepath.Join(subDirPath, fileName))\n\tif err != nil {\n\t\tt.Error(\"File could not be created\")\n\t}\n\tvar buf []byte\n\tresult, err := searchWord(term, dirPath, &buf)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tfmt.Println(\"Results found in test: \" + result)\n\tif strings.Count(result,\"\\n\") != 2 {\n\t\tt.Fatal(\"Test failed! Didn't find 2 results\")\n\t}\n}", "func TestKeyWords(t *testing.T) {\n\tcfg := internal.TestingPostgresConfig(t)\n\n\tctx := context.Background()\n\n\tconn, err := pgxpool.ConnectConfig(ctx, cfg)\n\trequire.NoError(t, err)\n\tdefer conn.Close()\n\n\t// Get Version gets postgres version.\n\tversion, err := GetVersion(ctx, conn)\n\trequire.NoError(t, err)\n\n\trequire.NotEqual(t, 0, version)\n\n\t_, err = GetKeyWords(ctx, conn, version)\n\trequire.NoError(t, err)\n}", "func TestSearch(t *testing.T) {\n\t// Create a mocked peers cache connected to a mock directory\n\tcache, mgds, err := makePeersCache()\n\trequire.NoError(t, err, \"could not create mocked peers cache\")\n\tdefer mgds.Shutdown()\n\n\t// Handle the case where GDS returns an error\n\tmgds.UseError(gdsmock.SearchRPC, codes.NotFound, \"the search terms you provided were not found\")\n\t_, err = cache.Search(\"missing\")\n\trequire.EqualError(t, err, \"rpc error: code = NotFound desc = the search terms you provided were not found\")\n\n\t// Handle the case where the GDS returns an error in the lookup reply\n\tmgds.OnSearch = func(context.Context, *gds.SearchRequest) (*gds.SearchReply, error) {\n\t\treturn &gds.SearchReply{\n\t\t\tError: &gds.Error{\n\t\t\t\tCode: 99,\n\t\t\t\tMessage: \"the GDS really shouldn't be returning these errors\",\n\t\t\t},\n\t\t}, nil\n\t}\n\n\t_, err = cache.Search(\"missing\")\n\trequire.EqualError(t, err, \"[99] the GDS really shouldn't be returning these errors\")\n\n\t// Handle the case where GDS returns no results in the search reply\n\tmgds.OnSearch = func(context.Context, *gds.SearchRequest) (*gds.SearchReply, error) {\n\t\treturn &gds.SearchReply{\n\t\t\tResults: make([]*gds.SearchReply_Result, 0),\n\t\t}, nil\n\t}\n\n\t_, err = cache.Search(\"Da Vinci Digital Exchange\")\n\trequire.EqualError(t, err, \"could not find peer named \\\"Da Vinci Digital Exchange\\\"\")\n\n\terr = mgds.UseFixture(gdsmock.SearchRPC, \"testdata/gds_search_reply.pb.json\")\n\trequire.NoError(t, err, \"could not load multiple results fixture\")\n\n\t_, err = cache.Search(\"Da Vinci Digital Exchange\")\n\trequire.EqualError(t, err, \"too many results returned for \\\"Da Vinci Digital Exchange\\\"\")\n\n\t// Have the mock GDS respond correctly based on the input\n\tmgds.Reset()\n\tmgds.OnSearch = func(_ context.Context, in *gds.SearchRequest) (out *gds.SearchReply, err error) {\n\t\tout = &gds.SearchReply{}\n\t\tif err = loadGRPCFixture(\"testdata/gds_search_reply.pb.json\", out); err != nil {\n\t\t\treturn nil, status.Error(codes.FailedPrecondition, err.Error())\n\t\t}\n\n\t\tlookupID := map[string]string{\n\t\t\t\"Da Vinci Digital Exchange\": \"19d84515-007a-48cc-9efd-b153a263e77c\",\n\t\t\t\"Brooklyn BitMining Ltd\": \"b19c9ebd-82f5-4bda-91ef-226e3ecee4b8\",\n\t\t}[in.Name[0]]\n\n\t\tresults := make([]*gds.SearchReply_Result, 0, 1)\n\t\tfor _, result := range out.Results {\n\t\t\tif result.Id == lookupID {\n\t\t\t\tresults = append(results, result)\n\t\t\t}\n\t\t}\n\n\t\treturn &gds.SearchReply{\n\t\t\tResults: results,\n\t\t}, nil\n\t}\n\n\t// Test concurrent Search calls populating the cache\n\tt.Run(\"search\", func(t *testing.T) {\n\t\ttests := []struct {\n\t\t\tname string\n\t\t\tpeer string\n\t\t}{\n\t\t\t{\"search-leonardo\", \"Da Vinci Digital Exchange\"},\n\t\t\t{\"search-donatello\", \"Brooklyn BitMining Ltd\"},\n\t\t}\n\t\tfor _, tt := range tests {\n\t\t\ttc := tt\n\t\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\t\tt.Parallel()\n\t\t\t\tp, err := cache.Search(tc.peer)\n\t\t\t\trequire.NoError(t, err)\n\t\t\t\trequire.NotNil(t, p)\n\t\t\t})\n\t\t}\n\t})\n\n\trequire.Equal(t, 2, mgds.Calls[gdsmock.SearchRPC])\n\trequire.Equal(t, 0, mgds.Calls[gdsmock.LookupRPC])\n\trequire.Equal(t, 0, mgds.Calls[gdsmock.StatusRPC])\n\n\t// Cache should contain the two peers\n\tleonardo, err := cache.Get(\"leonardo.trisa.dev\")\n\trequire.NoError(t, err)\n\trequire.Equal(t, \"19d84515-007a-48cc-9efd-b153a263e77c\", leonardo.Info().ID)\n\trequire.Equal(t, \"testdirectory.org\", leonardo.Info().RegisteredDirectory)\n\trequire.Equal(t, \"leonardo.trisa.dev\", leonardo.Info().CommonName)\n\trequire.Equal(t, \"leonardo.trisa.dev:8000\", leonardo.Info().Endpoint)\n\n\tdonatello, err := cache.Get(\"donatello.example.com\")\n\trequire.NoError(t, err)\n\trequire.Equal(t, \"b19c9ebd-82f5-4bda-91ef-226e3ecee4b8\", donatello.Info().ID)\n\trequire.Equal(t, \"testdirectory.org\", donatello.Info().RegisteredDirectory)\n\trequire.Equal(t, \"donatello.example.com\", donatello.Info().CommonName)\n\trequire.Equal(t, \"donatello.example.com:443\", donatello.Info().Endpoint)\n}", "func TestBigSearch(t *testing.T) {\n\ttree := avl.TreeInit()\n\tfor i := 0; i < 100000; i++ {\n\t\ttree.Insert(myString{s: strconv.Itoa(i)})\n\t}\n\n\tfor i := 0; i < 100000; i++ {\n\t\tf := tree.Search(myString{s: strconv.Itoa(i)})\n\t\tif f == false {\n\t\t\tt.Errorf(\"Search error\\n\")\n\t\t\tt.Errorf(\"Could not find value: %v\\n\", myString{s: strconv.Itoa(i)})\n\t\t}\n\t}\n}", "func (n *NGramIndex) Search(query string) []string {\n\tterms := SplitIntoNGrams(n.nGram, query)\n\tresult := []string{}\n\tset := map[DocumentID]struct{}{}\n\n\tfor _, term := range terms {\n\t\tposting := n.index[term]\n\n\t\tif posting == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, docID := range posting {\n\t\t\tset[docID] = struct{}{}\n\t\t}\n\t}\n\n\tfor docID, _ := range set {\n\t\tresult = append(result, n.dictionary[int(docID)])\n\t}\n\n\treturn result\n}", "func GetRelKw(keyword string) (sliceKw []string, err error) {\n\tkeyword = strings.ReplaceAll(keyword, \" \", \"+\")\n\tmapKeywords := make(map[string]bool)\n\tchkeywords := make(chan []string)\n\tchFinished := make(chan bool)\n\t// ----------------------------- google ----------------------------\n\tfor x := 0; x <= 25; x++ {\n\t\tgo func(x int, chkeywords chan []string, chFinshed chan bool) {\n\t\t\tresSlice, err := getGoogleJSON(\"http://suggestqueries.google.com/complete/search?client=chrome&hl=kr&q=\" + keyword + \"+\" + string(rune('a'+x)))\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"error: %v\\n\", err)\n\t\t\t\tchkeywords <- nil\n\t\t\t\tchFinshed <- true\n\t\t\t}\n\t\t\tchkeywords <- resSlice\n\t\t\tchFinshed <- true\n\t\t}(x, chkeywords, chFinished)\n\t}\n\tfor x := 0; x <= 25; {\n\t\tselect {\n\t\tcase keywords := <-chkeywords:\n\t\t\tfor _, keyword := range keywords {\n\t\t\t\tif !strings.Contains(keyword, \"xaml\") {\n\t\t\t\t\tmapKeywords[keyword] = true\n\t\t\t\t}\n\t\t\t}\n\t\tcase <-chFinished:\n\t\t\tx++\n\t\t}\n\t}\n\t// ----------------------------- bing ----------------------------\n\tfor x := 0; x <= 25; x++ {\n\t\tgo func(x int, chkeywords chan []string, chFinshed chan bool) {\n\t\t\tresSlice, err := getBingJSON(\"https://www.bing.com/AS/Suggestions?pt=page.home&cp=1&cvid=\" +\n\t\t\t\trandomStrFromCharset(22, \"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\") +\n\t\t\t\t\"&qry=\" + keyword + \"+\" + string(rune('a'+x)))\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"error: %v\\n\", err)\n\t\t\t\tchkeywords <- nil\n\t\t\t\tchFinshed <- true\n\t\t\t}\n\t\t\tchkeywords <- resSlice\n\t\t\tchFinshed <- true\n\t\t}(x, chkeywords, chFinished)\n\t}\n\tfor x := 0; x <= 25; {\n\t\tselect {\n\t\tcase keywords := <-chkeywords:\n\t\t\tfor _, keyword := range keywords {\n\t\t\t\tmapKeywords[keyword] = true\n\t\t\t}\n\t\tcase <-chFinished:\n\t\t\tx++\n\t\t}\n\t}\n\tfor keyword := range mapKeywords {\n\t\tsliceKw = append(sliceKw, keyword)\n\t}\n\treturn sliceKw, nil\n}", "func Search(w http.ResponseWriter, r *http.Request) {\n\n\tuser := utils.GetAuthenticatedUser(r)\n\n\tkeys, ok := r.URL.Query()[\"q\"]\n\n\tif !ok || len(keys[0]) < 1 {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\n\t// Query()[\"key\"] will return an array of items,\n\t// we only want the single item.\n\tkey := keys[0]\n\n\t// redirect to glsa if isNumeric\n\tif _, err := strconv.Atoi(key); err == nil {\n\t\thttp.Redirect(w, r, \"/glsa/\"+key, 301)\n\t}\n\n\tif key == \"#home\" {\n\t\thttp.Redirect(w, r, \"/\", 301)\n\t\treturn\n\t} else if key == \"#dashboard\" {\n\t\thttp.Redirect(w, r, \"/dashboard\", 301)\n\t\treturn\n\t} else if key == \"#new\" {\n\t\thttp.Redirect(w, r, \"/new\", 301)\n\t\treturn\n\t} else if key == \"#cvetool\" {\n\t\thttp.Redirect(w, r, \"/cve/tool\", 301)\n\t\treturn\n\t} else if key == \"#requests\" {\n\t\thttp.Redirect(w, r, \"/requests\", 301)\n\t\treturn\n\t} else if key == \"#drafts\" {\n\t\thttp.Redirect(w, r, \"/drafts\", 301)\n\t\treturn\n\t} else if key == \"#all\" {\n\t\thttp.Redirect(w, r, \"/all\", 301)\n\t\treturn\n\t} else if key == \"#archive\" {\n\t\thttp.Redirect(w, r, \"/archive\", 301)\n\t\treturn\n\t} else if key == \"#about\" {\n\t\thttp.Redirect(w, r, \"/about\", 301)\n\t\treturn\n\t} else if key == \"#bugzilla\" {\n\t\thttp.Redirect(w, r, \"https://bugs.gentoo.org/\", 301)\n\t\treturn\n\t} else if key == \"#admin\" {\n\t\thttp.Redirect(w, r, \"/admin\", 301)\n\t\treturn\n\t} else if key == \"#password\" {\n\t\thttp.Redirect(w, r, \"/account/password\", 301)\n\t\treturn\n\t} else if key == \"#2fa\" {\n\t\thttp.Redirect(w, r, \"/account/2fa\", 301)\n\t\treturn\n\t} else if key == \"#statistics\" {\n\t\thttp.Redirect(w, r, \"/statistics\", 301)\n\t\treturn\n\t}\n\n\tif key == \"#logout\" {\n\t\thttp.Redirect(w, r, \"/logout\", 301)\n\t\treturn\n\t}\n\n\tif !user.Permissions.Glsa.View {\n\t\tauthentication.AccessDenied(w, r)\n\t\treturn\n\t}\n\n\tvar glsas []*models.Glsa\n\terr := user.CanAccess(connection.DB.Model(&glsas).\n\t\tRelation(\"Bugs\").\n\t\tRelation(\"Comments\").\n\t\tRelation(\"Creator\").\n\t\tWhereGroup(func(q *orm.Query) (*orm.Query, error) {\n\t\t\tq = q.WhereOr(\"title LIKE \" + \"'%\" + key + \"%'\").\n\t\t\t\tWhereOr(\"type LIKE \" + \"'%\" + key + \"%'\").\n\t\t\t\tWhereOr(\"synopsis LIKE \" + \"'%\" + key + \"%'\").\n\t\t\t\tWhereOr(\"description LIKE \" + \"'%\" + key + \"%'\").\n\t\t\t\tWhereOr(\"workaround LIKE \" + \"'%\" + key + \"%'\").\n\t\t\t\tWhereOr(\"resolution LIKE \" + \"'%\" + key + \"%'\").\n\t\t\t\tWhereOr(\"keyword LIKE \" + \"'%\" + key + \"%'\").\n\t\t\t\tWhereOr(\"background LIKE \" + \"'%\" + key + \"%'\")\n\t\t\t\t//WhereOr(\"creator LIKE \" + \"'%\" + key + \"%'\")\n\t\t\treturn q, nil\n\t\t})).\n\t\tSelect()\n\n\t// TODO search in comments\n\t// TODO search in bugs\n\n\tif err != nil {\n\t\tlogger.Info.Println(\"Error during searching\")\n\t\tlogger.Info.Println(err)\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\n\tfor _, glsa := range glsas {\n\t\tglsa.ComputeStatus(user)\n\t}\n\n\trenderSearchTemplate(w, user, key, glsas)\n\n}", "func (s *Db) Search(phrase string) SearchTitles {\n\tvar superset map[string]bool\n\tinit := false\n\tfor _, word := range strings.FieldsFunc(strings.ToLower(phrase), onlyLettersPredicate) {\n\t\tsearchSet := make(map[string]bool)\n\t\tfor _, id := range s.lookup[word] {\n\t\t\tsearchSet[id] = true\n\t\t}\n\t\t//fmt.Println(\"SearchSet: \", searchSet)\n\t\tif !init {\n\t\t\tsuperset = searchSet\n\t\t\tinit = true\n\t\t} else {\n\t\t\tresult := make(map[string]bool)\n\t\t\tfor k := range superset {\n\t\t\t\tif _, ok := searchSet[k]; ok {\n\t\t\t\t\tresult[k] = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tsuperset = result\n\t\t}\n\t\t//fmt.Println(\"superset: \", superset)\n\t}\n\toutput := make([]SearchInfo, 0, len(superset))\n\tfor id := range superset {\n\t\ttitle := s.titles[id]\n\t\toutput = append(output,\n\t\t\tSearchInfo{\n\t\t\t\tID: id,\n\t\t\t\tPrimaryTitle: title.PrimaryTitle,\n\t\t\t\tStartYear: title.StartYear,\n\t\t\t\tAverageRating: title.AverageRating,\n\t\t\t})\n\t}\n\n\tsort.Sort(sort.Reverse(SearchTitles(output)))\n\n\treturn output\n}", "func TestRE2Search(t *testing.T) {\n\ttestRE2(t, \"testdata/re2-search.txt\")\n}", "func TestParseQuery(t *testing.T) {\n\tunittest.SmallTest(t)\n\n\tq := &Search{}\n\terr := clearParseQuery(q, \"fdiffmax=-1&fref=false&frgbamax=-1&head=true&include=false&issue=2370153003&limit=50&match=gamma_correct&match=name&metric=combined&neg=false&pos=false&query=source_type%3Dgm&sort=desc&unt=true\")\n\trequire.NoError(t, err)\n\n\trequire.Equal(t, &Search{\n\t\tMetric: \"combined\",\n\t\tSort: \"desc\",\n\t\tMatch: []string{\"gamma_correct\", \"name\"},\n\t\tBlameGroupID: \"\",\n\t\tPos: false,\n\t\tNeg: false,\n\t\tHead: true,\n\t\tUnt: true,\n\t\tIncludeIgnores: false,\n\t\tQueryStr: \"\",\n\t\tTraceValues: url.Values{\n\t\t\t\"source_type\": []string{\"gm\"},\n\t\t},\n\t\tRQueryStr: \"\",\n\t\tRTraceValues: paramtools.ParamSet{},\n\t\tChangeListID: \"2370153003\",\n\t\tPatchSetsStr: \"\",\n\t\tPatchSets: []int64(nil),\n\t\tIncludeMaster: false,\n\t\tFCommitBegin: \"\",\n\t\tFCommitEnd: \"\",\n\t\tFRGBAMin: 0,\n\t\tFRGBAMax: -1,\n\t\tFDiffMax: -1,\n\t\tFGroupTest: \"\",\n\t\tFRef: false,\n\t\tOffset: 0,\n\t\tLimit: 50,\n\t\tNoDiff: false,\n\t\tNewCLStore: false,\n\t}, q)\n}", "func TestSuccessfulMultiQuery(t *testing.T) {\n\tlocations, err := metaweather.QueryLocations(\"san\")\n\tif err != nil {\n\t\tt.Fatalf(\"query returned error: %v\", err)\n\t}\n\tif !(len(locations) > 1) {\n\t\tt.Fatalf(\"number of query results is %d\", len(locations))\n\t}\n\tfor i, loc := range locations {\n\t\tif !strings.Contains(strings.ToLower(loc.Title), \"san\") {\n\t\t\tt.Fatalf(\"query result %d contains no 'san': %v\", i, loc)\n\t\t}\n\t}\n}", "func (s *Server) handleSearch(w http.ResponseWriter, r *http.Request) {\n\ttitle := r.URL.Query().Get(\"title\")\n\tyear := r.URL.Query().Get(\"year\")\n\toffsetStr := r.URL.Query().Get(\"offset\")\n\n\tvar offset int\n\tvar err error\n\tif offsetStr != \"\" {\n\t\toffset, err = strconv.Atoi(offsetStr)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\tswitch {\n\tcase title != \"\" && year != \"\":\n\t\ts.SearchTitleYear(w, r, title, year, offset)\n\tcase title != \"\":\n\t\ts.SearchTitle(w, r, title, offset)\n\tcase year != \"\":\n\t\t// s.SearchYear(w, r, year)\n\t\t// Don't allow year only searches.\n\t\tfallthrough\n\tdefault:\n\t\thttp.Error(w, \"You must enter a query.\", 404)\n\t\treturn\n\t}\n}", "func (v *verifier) Contains(inner string) *verifier {\n\treturn v.addVerification(\"Contains\", strings.Contains(v.Query, inner))\n}", "func (qc *querycheck) test(t *testing.T, db weave.ReadOnlyKVStore, qr weave.QueryRouter) {\n\tt.Helper()\n\n\tresult, err := qr.Handler(qc.path).Query(db, \"\", qc.data)\n\tif err != nil {\n\t\tt.Fatalf(\"query %q: %s\", qc.path, err)\n\t}\n\tif w, g := len(qc.wantRes), len(result); w != g {\n\t\tt.Fatalf(\"want %d entries returned, got %d\", w, g)\n\t}\n\tfor i, wres := range qc.wantRes {\n\t\tif want, got := qc.bucket.DBKey(wres.Key()), result[i].Key; !bytes.Equal(want, got) {\n\t\t\tt.Errorf(\"want %d key to be %q, got %q\", i, want, got)\n\t\t}\n\n\t\tif got, err := qc.bucket.Parse(nil, result[i].Value); err != nil {\n\t\t\tt.Errorf(\"parse %d: %s\", i, err)\n\t\t} else if w, g := wres.Value(), got.Value(); !reflect.DeepEqual(w, g) {\n\t\t\tt.Logf(\" got value: %+v\", g)\n\t\t\tt.Logf(\"want value: %+v\", w)\n\t\t\tt.Errorf(\"value %d missmatch\", i)\n\t\t}\n\t}\n}", "func TestQuery(t *testing.T) {\n\tdefer gock.Off()\n\tclient := testClient()\n\n\tgock.New(testURL).Get(\"/url\").MatchParam(\"foo\", \"bar\").Reply(200)\n\t_, err := client.Get(\"/url\", Query(\"foo\", \"bar\"))\n\tassert.NoError(t, err)\n\n\t// Test case for comma-separated parameters\n\tgock.New(testURL).Get(\"/url\").MatchParam(\"foo\", \"bar,baz\").Reply(200)\n\t_, err = client.Get(\"/url\", Query(\"foo\", \"bar,baz\"))\n\tassert.NoError(t, err)\n}", "func (s *gRPCsrv) Search(q *pb.Query, stream pb.Crawler_SearchServer) error {\n\tif q.Key == \"\" {\n\t\treturn badRequest(\"Key must not be empty\")\n\t}\n\n\t// create query\n\td := make(chan bool)\n\topt := mart.Query{\n\t\tKey: q.Key,\n\t\tOrder: mart.ByPrice,\n\t\tDone: func() { d <- true },\n\t}\n\tif q.Order == pb.Query_POPULAR {\n\t\topt.Order = mart.ByPopular\n\t}\n\n\t// find if mart available\n\tvar ms []*mart.Mart\n\tif q.Mart != \"\" {\n\t\tm, err := mart.Open(q.Mart)\n\t\tif err != nil {\n\t\t\treturn noFound(\"Mart \" + q.Mart + \" not available\")\n\t\t}\n\n\t\tms = append(ms, m)\n\t} else {\n\t\tms = mart.All()\n\t\tif len(ms) == 0 {\n\t\t\treturn noFound(\"No mart available\")\n\t\t}\n\t}\n\n\t// create context and channel; make search request\n\tctx, quit := context.WithCancel(stream.Context())\n\tdefer quit()\n\n\tput := make(chan []mart.Product)\n\tche := make(chan error)\n\tfor i := range ms {\n\t\tms[i].Search(ctx, opt, put, che)\n\t}\n\n\t// listen for search response\n\tvar sent, done int64\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tlog.Println(\"Search keyword\", q.Key, \"cancelled\")\n\t\t\treturn nil\n\t\tcase ps := <-put:\n\t\t\tfor i := range ps {\n\t\t\t\tsent++\n\t\t\t\tif q.Num > 0 && sent > q.Num { // reach max number, return\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\n\t\t\t\tif err := stream.Send(&pb.Product{\n\t\t\t\t\tName: ps[i].Name,\n\t\t\t\t\tImage: ps[i].Image,\n\t\t\t\t\tPage: ps[i].Page,\n\t\t\t\t\tPrice: int64(ps[i].Price),\n\t\t\t\t\tMart: ps[i].Mart,\n\t\t\t\t}); err != nil {\n\t\t\t\t\tlog.Println(err)\n\t\t\t\t\treturn nil // connection lost?\n\t\t\t\t}\n\t\t\t}\n\t\tcase err := <-che:\n\t\t\tlog.Println(err)\n\t\tcase <-d:\n\t\t\tdone++\n\t\t\tif done == int64(len(ms)) { // all jobs are done\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}\n}", "func search(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error) {\n\t// Upgrades the connection to a websocket and checks for fb.Errors.\n\tconn, err := upgrader.Upgrade(w, r, nil)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tdefer conn.Close()\n\n\tvar (\n\t\tvalue string\n\t\tsearch *searchOptions\n\t\tmessage []byte\n\t)\n\n\t// Starts an infinite loop until a valid command is captured.\n\tfor {\n\t\t_, message, err = conn.ReadMessage()\n\t\tif err != nil {\n\t\t\treturn http.StatusInternalServerError, err\n\t\t}\n\n\t\tif len(message) != 0 {\n\t\t\tvalue = string(message)\n\t\t\tbreak\n\t\t}\n\t}\n\n\tsearch = parseSearch(value)\n\tscope := strings.TrimPrefix(r.URL.Path, \"/\")\n\tscope = \"/\" + scope\n\tscope = c.User.Scope + scope\n\tscope = strings.Replace(scope, \"\\\\\", \"/\", -1)\n\tscope = filepath.Clean(scope)\n\n\terr = filepath.Walk(scope, func(path string, f os.FileInfo, err error) error {\n\t\tif search.CaseInsensitive {\n\t\t\tpath = strings.ToLower(path)\n\t\t}\n\n\t\tpath = strings.TrimPrefix(path, scope)\n\t\tpath = strings.TrimPrefix(path, \"/\")\n\t\tpath = strings.Replace(path, \"\\\\\", \"/\", -1)\n\n\t\t// Only execute if there are conditions to meet.\n\t\tif len(search.Conditions) > 0 {\n\t\t\tmatch := false\n\n\t\t\tfor _, t := range search.Conditions {\n\t\t\t\tif t(path) {\n\t\t\t\t\tmatch = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If doesn't meet the condition, go to the next.\n\t\t\tif !match {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\n\t\tif len(search.Terms) > 0 {\n\t\t\tis := false\n\n\t\t\t// Checks if matches the terms and if it is allowed.\n\t\t\tfor _, term := range search.Terms {\n\t\t\t\tif is {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tif strings.Contains(path, term) {\n\t\t\t\t\tif !c.User.Allowed(path) {\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\n\t\t\t\t\tis = true\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif !is {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\n\t\tresponse, _ := json.Marshal(map[string]interface{}{\n\t\t\t\"dir\": f.IsDir(),\n\t\t\t\"path\": path,\n\t\t})\n\n\t\treturn conn.WriteMessage(websocket.TextMessage, response)\n\t})\n\n\tif err != nil {\n\t\treturn http.StatusInternalServerError, err\n\t}\n\n\treturn 0, nil\n}", "func searchAppSubstring(w http.ResponseWriter, r *http.Request, db *mgo.Database, argPos int) {\n\tapp_str := r.FormValue(\"search\")\n\t// app_str2 := r.FormValue(\"test2\")\n\tfmt.Println(\"searching for substring in apps: \", app_str)\n\n\tc := db.C(\"machines\")\n\n\tcontext := make([]appResult, 0, 10)\n\tvar res *appResult\n\n\tp := \"^.*\" + app_str + \".*\"\n\n\tfmt.Println(\"query: \", p)\n\t// m := bson.M{} \n\tif len(app_str) == 0 {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\terr := c.Find(bson.M{\"apps._name\": &bson.RegEx{Pattern: p, Options: \"i\"}}).\n\t\tSelect(bson.M{\n\t\t\"hostname\": 1,\n\t\t\"apps\": 1,\n\t\t\"_id\": 1}).\n\t\tSort(\"hostname\").\n\t\tFor(&res, func() error {\n\t\tres.Apps = fuzzyFilter_apps(app_str, res.Apps)\n\t\tcontext = append(context, *res)\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\tset.ExecuteTemplate(w, \"searchresults\", context)\n}", "func (m *MongoSearchSuite) TestPatientNameStringQueryObject(c *C) {\n\tq := Query{\"Patient\", \"name=Peters\"}\n\n\to := m.MongoSearcher.createQueryObject(q)\n\tc.Assert(o, DeepEquals, bson.M{\n\t\t\"$or\": []bson.M{\n\t\t\tbson.M{\"name.text\": bson.RegEx{Pattern: \"^Peters\", Options: \"i\"}},\n\t\t\tbson.M{\"name.family\": bson.RegEx{Pattern: \"^Peters\", Options: \"i\"}},\n\t\t\tbson.M{\"name.given\": bson.RegEx{Pattern: \"^Peters\", Options: \"i\"}},\n\t\t},\n\t})\n}", "func main() {\n\tword := \"apple\"\n\tprefix := \"app\"\n\tobj := Constructor()\n\tobj.Insert(word)\n\tparam_2 := obj.Search(word)\n\tparam_3 := obj.StartsWith(prefix)\n\tfmt.Println(param_2, param_3)\n}", "func TitleMatch(word []string, pageID int64) (ok bool, queryScore float64) {\n\tok = false\n\tqueryScore = 0.0\n\n\tfor _, w := range word {\n\t\twordScore := 0.0\n\t\ttitle := database.GetTitle(pageID)\n\t\t// splitTitle := strings.Split(title, \" \")\n\t\t// titleSlice := make([]string, 0)\n\t\t// for _, q := range splitTitle {\n\t\t// \ttitleSlice = append(titleSlice, q)\n\t\t// }\n\t\t// titleStem := stopstem.StemString(titleSlice)\n\t\tfor _, t := range title {\n\t\t\tif w == t {\n\t\t\t\tok = true\n\t\t\t\twordScore++\n\t\t\t\t// fmt.Println(w, \"match in \", pageID)\n\t\t\t}\n\t\t}\n\t\tqueryScore += wordScore\n\t}\n\treturn ok, queryScore\n}", "func (h *Hostman) Search(query string) Entries {\n\tvar matches Entries\n\n\tentries := h.Entries()\n\n\tfor _, entry := range entries {\n\t\tif strings.Contains(entry.Raw, query) {\n\t\t\tmatches = append(matches, entry)\n\t\t}\n\t}\n\n\treturn matches\n}", "func TestQslSearch(t *testing.T) {\n\tif testing.Short() {\n\t\tt.Skip(\"skipping TestQSLSearch in short mode\")\n\t}\n\ttestURL1 := TestBaseURL + \"/v1/qsl/node[@name=\\\"node01\\\"]{*}\"\n\ttestURL2 := TestBaseURL + \"/v1/qsl/node[@name=\\\"node01\\\"]{@labels}\"\n\n\ttests := []TestStruct{\n\t\t{\"TestSearchNode01All\", testURL1, \"\", 200, \"\", 0},\n\t\t{\"TestSearchNode01@labels\", testURL2, \"\", 200, \"\", 0},\n\t}\n\n\tfor i, testCase := range tests {\n\t\tt.Run(testCase.testCaseName, func(t *testing.T) {\n\t\t\tresCode, resBody, _ := QslSearch(t, testCase.testURL)\n\t\t\ttests[i].observedStatusCode = resCode\n\t\t\ttests[i].responseBody = string(resBody)\n\t\t})\n\t}\n\tDisplayTestCaseResults(\"TestQslSearch\", tests, t, \"uid\")\n}" ]
[ "0.66071653", "0.6170704", "0.6104493", "0.6101992", "0.6071285", "0.6054238", "0.5773076", "0.5768604", "0.576822", "0.5691482", "0.566482", "0.56577206", "0.5652532", "0.5647406", "0.56422365", "0.56411195", "0.56259054", "0.56133455", "0.55830723", "0.5568", "0.5545437", "0.5537441", "0.5497379", "0.5492344", "0.54886425", "0.5481234", "0.5470698", "0.5466094", "0.54580784", "0.5453668", "0.54282117", "0.5414651", "0.53990924", "0.5392189", "0.53876275", "0.5381496", "0.5367881", "0.53657806", "0.5361772", "0.5349121", "0.53357905", "0.5333128", "0.5313407", "0.52939767", "0.5293526", "0.5290563", "0.5288806", "0.5271554", "0.52702874", "0.5266161", "0.5262121", "0.5256509", "0.5253942", "0.5249774", "0.5245778", "0.52434087", "0.5238305", "0.5229474", "0.5219771", "0.52196807", "0.5205627", "0.5203278", "0.5200516", "0.5192333", "0.5188779", "0.517402", "0.51739097", "0.51665807", "0.5164258", "0.5161571", "0.51543736", "0.51531255", "0.51464343", "0.5142224", "0.5139301", "0.5137701", "0.51356274", "0.5129461", "0.51288956", "0.5124413", "0.5121945", "0.5116537", "0.5114839", "0.51137835", "0.51081455", "0.5098212", "0.50966394", "0.5092504", "0.5091362", "0.5082654", "0.50790244", "0.50775206", "0.50769335", "0.5073991", "0.50724703", "0.50723636", "0.50671047", "0.50594753", "0.50493777", "0.50461847" ]
0.70359737
0
Test Qsl search query
Тестовый запрос Qsl поиска
func TestQslSearch(t *testing.T) { if testing.Short() { t.Skip("skipping TestQSLSearch in short mode") } testURL1 := TestBaseURL + "/v1/qsl/node[@name=\"node01\"]{*}" testURL2 := TestBaseURL + "/v1/qsl/node[@name=\"node01\"]{@labels}" tests := []TestStruct{ {"TestSearchNode01All", testURL1, "", 200, "", 0}, {"TestSearchNode01@labels", testURL2, "", 200, "", 0}, } for i, testCase := range tests { t.Run(testCase.testCaseName, func(t *testing.T) { resCode, resBody, _ := QslSearch(t, testCase.testURL) tests[i].observedStatusCode = resCode tests[i].responseBody = string(resBody) }) } DisplayTestCaseResults("TestQslSearch", tests, t, "uid") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestSingleQuerySearch(t *testing.T) {\n\tfor _, tItem := range testData {\n\t\tsq := NewSingleQuery(tItem.query, tItem.links)\n\t\trealFind, err := sq.QuerySearch()\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Can't make test, too much errors, %v\", err)\n\t\t}\n\t\tif len(realFind) != len(tItem.results) {\n\t\t\tt.Errorf(\"got %v slice of resources, need to %v (query=%s)\", realFind, tItem.results, tItem.query)\n\t\t} else {\n\t\t\t// detail comparison\n\t\t\tfor _, realItem := range realFind {\n\t\t\t\texists := false\n\t\t\t\tfor _, expected := range tItem.results {\n\t\t\t\t\tif expected == realItem {\n\t\t\t\t\t\texists = true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !exists {\n\t\t\t\t\tt.Errorf(\"wrong content, got %v slice of resources, need to %v (query=%s)\", realFind, tItem.results, tItem.query)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func QslSearch(t *testing.T, url string) (statusCode int, respBody []byte, err error) {\n\n\trespStatusCode, respBody, _ := GetResponseByGet(t, url)\n\treturn respStatusCode, respBody, nil\n}", "func TestQuery(t *testing.T) {\n\n\tresults, err := FindAll(Published())\n\tif err != nil {\n\t\tt.Fatalf(\"pages: error getting pages :%s\", err)\n\t}\n\tif len(results) == 0 {\n\t\tt.Fatalf(\"pages: published pages not found :%s\", err)\n\t}\n\n\tresults, err = FindAll(Query().Where(\"id>=? AND id <=?\", 0, 100))\n\tif err != nil || len(results) == 0 {\n\t\tt.Fatalf(\"pages: no page found :%s\", err)\n\t}\n\tif len(results) > 1 {\n\t\tt.Fatalf(\"pages: more than one page found for where :%s\", err)\n\t}\n\n}", "func testQuery(t *testing.T, q *Query, models []*indexedTestModel) {\n\texpected := expectedResultsForQuery(q.query, models)\n\ttestQueryRun(t, q, expected)\n\ttestQueryIDs(t, q, expected)\n\ttestQueryCount(t, q, expected)\n\ttestQueryStoreIDs(t, q, expected)\n\tcheckForLeakedTmpKeys(t, q.query)\n}", "func TESTQ(ir, mr operand.Op) { ctx.TESTQ(ir, mr) }", "func (qc *querycheck) test(t *testing.T, db weave.ReadOnlyKVStore, qr weave.QueryRouter) {\n\tt.Helper()\n\n\tresult, err := qr.Handler(qc.path).Query(db, \"\", qc.data)\n\tif err != nil {\n\t\tt.Fatalf(\"query %q: %s\", qc.path, err)\n\t}\n\tif w, g := len(qc.wantRes), len(result); w != g {\n\t\tt.Fatalf(\"want %d entries returned, got %d\", w, g)\n\t}\n\tfor i, wres := range qc.wantRes {\n\t\tif want, got := qc.bucket.DBKey(wres.Key()), result[i].Key; !bytes.Equal(want, got) {\n\t\t\tt.Errorf(\"want %d key to be %q, got %q\", i, want, got)\n\t\t}\n\n\t\tif got, err := qc.bucket.Parse(nil, result[i].Value); err != nil {\n\t\t\tt.Errorf(\"parse %d: %s\", i, err)\n\t\t} else if w, g := wres.Value(), got.Value(); !reflect.DeepEqual(w, g) {\n\t\t\tt.Logf(\" got value: %+v\", g)\n\t\t\tt.Logf(\"want value: %+v\", w)\n\t\t\tt.Errorf(\"value %d missmatch\", i)\n\t\t}\n\t}\n}", "func TestQuery(t *testing.T) {\n\t_, smc := getConnectionToShardMasterRaftLeader(t)\n\n\tfireQueryRequest(t, smc, &pb.QueryArgs{Num: -1})\n\n}", "func TestSearch(t *testing.T) {\n\tvar result *SearchResult\n\tvar err error\n\n\tresult, err = Search(\n\t\tSimpleQuery{\n\t\t\tSearch: \"electron\",\n\t\t\tMaxResults: 5,\n\t\t},\n\t)\n\n\tif err != nil {\n\t\tlog.Printf(\"error occurred during Search(): %v\", err)\n\t\tt.FailNow()\n\t}\n\n\tif result == nil {\n\t\tlog.Printf(\"empty SearchResult: %v\", result)\n\t\tt.FailNow()\n\t}\n\n\tif len(result.Entries) != 5 {\n\t\tlog.Printf(\"invalid length for SearchResult.entries: %v\", result.Entries)\n\t\tt.FailNow()\n\t}\n\n}", "func TestQuery(t *testing.T) {\n\tdefer gock.Off()\n\tclient := testClient()\n\n\tgock.New(testURL).Get(\"/url\").MatchParam(\"foo\", \"bar\").Reply(200)\n\t_, err := client.Get(\"/url\", Query(\"foo\", \"bar\"))\n\tassert.NoError(t, err)\n\n\t// Test case for comma-separated parameters\n\tgock.New(testURL).Get(\"/url\").MatchParam(\"foo\", \"bar,baz\").Reply(200)\n\t_, err = client.Get(\"/url\", Query(\"foo\", \"bar,baz\"))\n\tassert.NoError(t, err)\n}", "func TestPaymentsSearch(t *testing.T) {\n\tfmt.Println(\"mp_test : PaymentsSearch\")\n\n\tfilter := &url.Values{}\n\tfilter.Add(\"range\", \"date_created\")\n\tfilter.Add(\"begin_date\", \"NOW-1MONTH\")\n\tfilter.Add(\"end_date\", \"NOW\")\n\tfilter.Add(\"status\", \"approved\")\n\n\tpmtSearch, err := mp.PaymentsSearch(filter)\n\tif err != nil {\n\t\tt.Fatalf(\"Error getting the payment: %v\", err)\n\t}\n\tfmt.Println(\"Payments: \", pmtSearch)\n}", "func TestSearchCorrectPayload(t *testing.T) {\n\tdb := DBSession()\n\tdefer db.Close() // clean up when we’re done\n\n\tSetupData(db)\n\ta := assert.New(t)\n\trouter := mux.NewRouter()\n\trouter.HandleFunc(\"/cb_service/contact_book/search/{query}\", http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {\n\t\t// save it in the request context\n\t\tctx := context.WithValue(req.Context(), dbSessionKey, db)\n\t\treq.Header.Set(\"Content-Type\", contentType)\n\t\treq.Header.Set(\"Authorization\", encodedAuthToken)\n\t\treq = req.WithContext(ctx)\n\t\tsearchH(res, req)\n\t}))\n\n\tserver := httptest.NewServer(router)\n\tdefer server.Close()\n\treqURL := server.URL + \"/cb_service/contact_book/search/Yog\"\n\tres, err := http.Get(reqURL)\n\tif err != nil {\n\t\tl.Printf(\"Cannot Make Request :%v \", err)\n\t\ta.Error(err)\n\t}\n\n\ta.Equal(res.StatusCode, http.StatusOK)\n\tClearData(db)\n}", "func TestQueryFunc(t *testing.T) {\n\tts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tif r.Header == nil {\n\t\t\tt.Errorf(\"Expected non-nil request Header\")\n\t\t}\n\t\tv := r.URL.Query()\n\t\tcheckQuery(t, v, \"query1\", \"test1\")\n\t\tcheckQuery(t, v, \"query2\", \"test2\")\n\t}))\n\tdefer ts.Close()\n\n\tNew().Post(ts.URL).\n\t\tQuery(\"query1=test1\").\n\t\tQuery(\"query2=test2\").\n\t\tEnd()\n\n\tqq := struct {\n\t\tQuery1 string `json:\"query1\"`\n\t\tQuery2 string `json:\"query2\"`\n\t}{\n\t\tQuery1: \"test1\",\n\t\tQuery2: \"test2\",\n\t}\n\tNew().Post(ts.URL).\n\t\tQuery(qq).\n\t\tEnd()\n}", "func (tsr *TextSearchRequest) Query(qrfj *QueryResult) (string, error) {\n\n\t// Get data\n\tres, err := http.Get(tsr.Url) // post\n\n\tif err != nil {\n\t\treturn \"ERROR: \", err\n\t}\n\n\t// Check resposne code\n\tif res.StatusCode != 200 {\n\t\treturn \"ERROR: \", errors.New(res.Status)\n\t}\n\n\t//DEBUG\n\t// // Output response headers\n\t// for key, ele := range res.Header {\n\t// \tfmt.Print(key + \": \\n\")\n\t// \tfor key1, ele1 := range ele {\n\t// \t\tfmt.Print(\" \" + string(key1) + \":\" + ele1 + \"\\n\")\n\t// \t}\n\t// }\n\t//DEBUG^^^\n\n\t// Store data in it's type\n\tbody, err := ioutil.ReadAll(res.Body)\n\n\tif tsr.ResponseType == \"json\" {\n\t\tjson.Unmarshal(body, qrfj)\n\t} else if tsr.ResponseType == \"xml\" {\n\t\txml.Unmarshal(body, qrfj)\n\t}\n\tres.Body.Close()\n\tif err != nil {\n\t\treturn string(body), err\n\t}\n\n\t// store placaes in memory\t\n\n\t// return json\n\treturn string(body), nil\n\n}", "func TestSetSearchParams(t *testing.T) {\n\tstartDate, _ := time.Parse(\"2006-01-02\", \"2019-01-02\")\n\tendDate, _ := time.Parse(\"2006-01-02\", \"2019-02-02\")\n\n\ttestList := []SearchParamTest{\n\t\t{\"/anime.php\", searchModel.Query{\n\t\t\tQuery: \"naruto\",\n\t\t\tPage: 2}, \"/anime.php?c%5B%5D=a&c%5B%5D=b&c%5B%5D=c&c%5B%5D=d&c%5B%5D=e&c%5B%5D=f&c%5B%5D=g&gx=0&mid=0&p=0&q=naruto&score=0&show=50&status=0&type=0\",\n\t\t},\n\t\t{\"/manga.php\", searchModel.Query{\n\t\t\tQuery: \"naruto\",\n\t\t\tPage: 2,\n\t\t\tScore: 7}, \"/manga.php?c%5B%5D=a&c%5B%5D=b&c%5B%5D=c&c%5B%5D=d&c%5B%5D=e&c%5B%5D=f&c%5B%5D=g&gx=0&mid=0&p=0&q=naruto&score=7&show=50&status=0&type=0\",\n\t\t},\n\t\t{\"/anime.php\", searchModel.Query{\n\t\t\tQuery: \"naruto\",\n\t\t\tPage: 2,\n\t\t\tStartDate: startDate,\n\t\t\tEndDate: endDate}, \"/anime.php?c%5B%5D=a&c%5B%5D=b&c%5B%5D=c&c%5B%5D=d&c%5B%5D=e&c%5B%5D=f&c%5B%5D=g&ed=2019&em=2&ey=2&gx=0&mid=0&p=0&q=naruto&score=0&sd=2019&show=50&sm=1&status=0&sy=2&type=0\",\n\t\t},\n\t\t{\"/anime.php\", searchModel.Query{\n\t\t\tQuery: \"naruto\",\n\t\t\tGenre: []int{\n\t\t\t\t1,\n\t\t\t\t4,\n\t\t\t\t5,\n\t\t\t}}, \"/anime.php?c%5B%5D=a&c%5B%5D=b&c%5B%5D=c&c%5B%5D=d&c%5B%5D=e&c%5B%5D=f&c%5B%5D=g&genre%5B%5D=1&genre%5B%5D=4&genre%5B%5D=5&gx=0&mid=0&p=0&q=naruto&score=0&status=0&type=0\",\n\t\t},\n\t}\n\n\tfor _, param := range testList {\n\t\tu, _ := url.Parse(param.URL)\n\t\tq := SetSearchParams(u, param.Query)\n\t\tu.RawQuery = q.Encode()\n\t\tif u.String() != param.Result {\n\t\t\tt.Errorf(\"SetSearchParams() failed: expected %v got %v\", param.Result, u.String())\n\t\t}\n\t}\n}", "func (t *evidence_management) Query(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\n\tqueryString := args[1]\n\n\tqueryResults, err := getQueryResultForQueryString(stub, queryString)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\treturn shim.Success(queryResults)\n}", "func FakeSearch(kind, title, url string) SearchFunc {\n\treturn func(query string) Result {\n\t\ttime.Sleep(time.Duration(100 * time.Millisecond)) // artificial delay for instructional reasons\n\t\treturn Result{\n\t\t\tTitle: fmt.Sprintf(\"Query: %q | Source: %s -> Result: %s\", query, kind, title),\n\t\t\tURL: url,\n\t\t}\n\t}\n}", "func verify(t *testing.T, searchQuery string, searchResults []workitem.WorkItem, expectedCount int) {\n\t// Since this test adds test data, whether or not other workitems exist\n\t// there must be at least 1 search result returned.\n\tif len(searchResults) == expectedCount && expectedCount == 0 {\n\t\t// no point checking further, we got what we wanted.\n\t\treturn\n\t}\n\trequire.Equal(t, expectedCount, len(searchResults), \"invalid number of results in the search\")\n\n\t// These keywords need a match in the textual part.\n\tallKeywords := strings.Fields(searchQuery)\n\t// These keywords need a match optionally either as URL string or ID\t\t +\t\t\t\tkeyWord = strings.ToLower(keyWord)\n\t// optionalKeywords := []string{workItemURLInSearchString, strconv.Itoa(fxt.WorkItems[idx].Number)}\n\t// We will now check the legitimacy of the search results.\n\t// Iterate through all search results and see whether they meet the criteria\n\tfor _, searchResult := range searchResults {\n\t\tt.Logf(\"Examining workitem id=`%v` number=`%d` using keywords %v\", searchResult.ID, searchResult.Number, allKeywords)\n\t\tfor _, keyWord := range allKeywords {\n\t\t\tkeyWord = strings.ToLower(keyWord)\n\t\t\tt.Logf(\"Verifying workitem id=`%v` number=`%d` for keyword `%s`...\", searchResult.ID, searchResult.Number, keyWord)\n\t\t\tworkItemTitle := \"\"\n\t\t\tif searchResult.Fields[workitem.SystemTitle] != nil {\n\t\t\t\tworkItemTitle = strings.ToLower(searchResult.Fields[workitem.SystemTitle].(string))\n\t\t\t}\n\t\t\tworkItemDescription := \"\"\n\t\t\tif searchResult.Fields[workitem.SystemDescription] != nil {\n\t\t\t\tdescriptionField := searchResult.Fields[workitem.SystemDescription].(rendering.MarkupContent)\n\t\t\t\tworkItemDescription = strings.ToLower(descriptionField.Content)\n\t\t\t}\n\t\t\tassert.True(t,\n\t\t\t\tstrings.Contains(workItemTitle, keyWord) || strings.Contains(workItemDescription, keyWord),\n\t\t\t\t\"`%s` neither found in title `%s` nor in the description `%s` for workitem #%d\", keyWord, workItemTitle, workItemDescription, searchResult.Number)\n\t\t}\n\t}\n}", "func TestQueryParser(t *testing.T) {\n\ttests := []struct {\n\t\tname string\n\t\tinputQuery string\n\t\texpectedProblemSelector string\n\t\texpectedEntitySelector string\n\t}{\n\t\t{\n\t\t\tname: \"valid\",\n\t\t\tinputQuery: \"PV2;problemSelector=status(open)&entitySelector=mzId(7030365576649815430)\",\n\t\t\texpectedProblemSelector: \"status(open)\",\n\t\t\texpectedEntitySelector: \"mzId(7030365576649815430)\",\n\t\t},\n\t\t{\n\t\t\tname: \"valid - empty\",\n\t\t\tinputQuery: \"PV2;\",\n\t\t},\n\t\t{\n\t\t\tname: \"valid\",\n\t\t\tinputQuery: \"PV2;entitySelector=mzId(7030365576649815430)\",\n\t\t\texpectedEntitySelector: \"mzId(7030365576649815430)\",\n\t\t},\n\t\t{\n\t\t\tname: \"valid\",\n\t\t\tinputQuery: \"PV2;problemSelector=status(open)\",\n\t\t\texpectedProblemSelector: \"status(open)\",\n\t\t},\n\t}\n\tfor _, tc := range tests {\n\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\tquery, err := NewQueryParser(tc.inputQuery).Parse()\n\n\t\t\tassert.NoError(t, err)\n\t\t\tif assert.NotNil(t, query) {\n\t\t\t\tassert.EqualValues(t, tc.expectedProblemSelector, query.GetProblemSelector())\n\t\t\t\tassert.EqualValues(t, tc.expectedEntitySelector, query.GetEntitySelector())\n\t\t\t}\n\t\t})\n\t}\n}", "func TestGenerateQuery(t *testing.T) {\n\tfor _, test := range []struct {\n\t\tname, q, want string\n\t}{\n\t\t{\"querySearchSymbol\", SymbolQuery(SearchTypeSymbol), querySearchSymbol},\n\t\t{\"querySearchPackageDotSymbol\", SymbolQuery(SearchTypePackageDotSymbol), querySearchPackageDotSymbol},\n\t\t{\"querySearchMultiWordExact\", SymbolQuery(SearchTypeMultiWordExact), querySearchMultiWordExact},\n\t} {\n\t\tt.Run(test.name, func(t *testing.T) {\n\t\t\tif diff := cmp.Diff(test.want, test.q); diff != \"\" {\n\t\t\t\tt.Errorf(\"mismatch (-want, +got):\\n%s\", diff)\n\t\t\t}\n\t\t})\n\t}\n}", "func (r *Search) Q(q string) *Search {\n\tr.values.Set(\"q\", q)\n\n\treturn r\n}", "func Test_Search(t *testing.T) {\n\tfor _, testCase := range searchTestCases {\n\t\tresult := org.Search(org.CEO, testCase.name)\n\n\t\tif testCase.expected && result == nil {\n\t\t\tt.Errorf(\"Expected to find '%s', but did not find\", testCase.name)\n\t\t\tt.Fail()\n\t\t} else if !testCase.expected && result != nil {\n\t\t\tt.Errorf(\"Expected to not find '%s', but found\", testCase.name)\n\t\t}\n\t}\n}", "func (o *Option) Query(question string) {\n\tlctx := logrus.WithFields(logrus.Fields{\n\t\t\"option\": o.Text,\n\t})\n\n\tlctx.Debug(\"Checking Option\")\n\n\tclient := newClient()\n\treq, _ := http.NewRequest(\"GET\", SEARCHBASE, nil)\n\n\tq := req.URL.Query()\n\tq.Add(\"q\", o.QueryString(question))\n\tq.Add(\"num\", \"5\") //Limit to 5 results\n\treq.Header.Set(\"User-Agent\", \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36\")\n\treq.URL.RawQuery = q.Encode()\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tlctx.WithError(err).Error(\"Unable to get results\")\n\t\treturn\n\t}\n\n\tlctx.WithFields(logrus.Fields{\n\t\t\"status_code\": resp.Status,\n\t\t\"url\": req.URL.String(),\n\t}).Debug(\"Response Code\")\n\n\tdefer resp.Body.Close()\n\tresults, err := parseResp(resp)\n\tif err != nil {\n\t\tlogrus.WithError(err).Error(\"Unable to parse search results\")\n\t}\n\n\t//Assign the results\n\to.ResultCount = results.ResultCount\n\to.Results = results.Results\n\tlctx.WithFields(logrus.Fields{\n\t\t\"count\": o.ResultCount,\n\t}).Debug(\"Option Result\")\n\n\tfor _, r := range results.Results {\n\t\tlogrus.WithField(\"title\", r.ResultTitle).Debug(\"Result Title\")\n\t}\n\n}", "func main() {\n // perform the search for the specified term\n search.Run(\"president\")\n}", "func (m *ItemItemsDriveItemItemRequestBuilder) SearchWithQ(q *string)(*ItemItemsItemSearchWithQRequestBuilder) {\n return NewItemItemsItemSearchWithQRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter, q)\n}", "func FakeSearch(kind, title, URL string) SearchFunc {\n\treturn func(query string) Result {\n\t\ttime.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)\n\t\treturn Result{\n\t\t\tfmt.Sprintf(\"%s(%q): %s\", kind, query, title),\n\t\t\tURL}\n\t}\n}", "func TestParseQuery(t *testing.T) {\n\tunittest.SmallTest(t)\n\n\tq := &Search{}\n\terr := clearParseQuery(q, \"fdiffmax=-1&fref=false&frgbamax=-1&head=true&include=false&issue=2370153003&limit=50&match=gamma_correct&match=name&metric=combined&neg=false&pos=false&query=source_type%3Dgm&sort=desc&unt=true\")\n\trequire.NoError(t, err)\n\n\trequire.Equal(t, &Search{\n\t\tMetric: \"combined\",\n\t\tSort: \"desc\",\n\t\tMatch: []string{\"gamma_correct\", \"name\"},\n\t\tBlameGroupID: \"\",\n\t\tPos: false,\n\t\tNeg: false,\n\t\tHead: true,\n\t\tUnt: true,\n\t\tIncludeIgnores: false,\n\t\tQueryStr: \"\",\n\t\tTraceValues: url.Values{\n\t\t\t\"source_type\": []string{\"gm\"},\n\t\t},\n\t\tRQueryStr: \"\",\n\t\tRTraceValues: paramtools.ParamSet{},\n\t\tChangeListID: \"2370153003\",\n\t\tPatchSetsStr: \"\",\n\t\tPatchSets: []int64(nil),\n\t\tIncludeMaster: false,\n\t\tFCommitBegin: \"\",\n\t\tFCommitEnd: \"\",\n\t\tFRGBAMin: 0,\n\t\tFRGBAMax: -1,\n\t\tFDiffMax: -1,\n\t\tFGroupTest: \"\",\n\t\tFRef: false,\n\t\tOffset: 0,\n\t\tLimit: 50,\n\t\tNoDiff: false,\n\t\tNewCLStore: false,\n\t}, q)\n}", "func queryHandler(s *search.SearchServer, w http.ResponseWriter, r *http.Request) {\n\tparams := r.URL.Query()\n\tcollection := params.Get(\"collection\")\n\n\tif collection == \"\" {\n\t\trespondWithError(w, r, \"Collection query parameter is required\")\n\t\treturn\n\t}\n\n\tif !s.Exists(collection) {\n\t\trespondWithError(w, r, \"Specified collection does not exist\")\n\t\treturn\n\t}\n\n\t// TODO support more complex queries, eg: AND, OR\n\n\tquery := params.Get(\"query\")\n\tpartialMatch := params.Get(\"partial\") == \"1\"\n\n\tvar err error\n\tvar count int\n\tvar page int\n\n\tcountStr := params.Get(\"count\")\n\tif countStr == \"\" {\n\t\tcount = search.DefaultPageSize\n\t} else if count, err = strconv.Atoi(countStr); err != nil {\n\t\tcount = search.DefaultPageSize\n\t}\n\n\tpageStr := params.Get(\"page\")\n\tif pageStr == \"\" {\n\t\tpage = 1\n\t} else if page, err = strconv.Atoi(pageStr); err != nil {\n\t\tpage = 1\n\t}\n\n\tfields := params.Get(\"fields\")\n\n\tres := s.Query(collection, search.Query{Terms: query, Page: page, PageSize: count, ReturnFields: fields, PartialMatch: partialMatch})\n\tresp := map[string]interface{}{}\n\tresp[\"success\"] = true\n\tbytes, _ := json.Marshal(res)\n\trespondWithBody(w, r, string(bytes))\n}", "func searchSongs(ctx context.Context, w http.ResponseWriter, r *http.Request) {\n criteria := pat.Param(ctx, \"searchCriteria\")\n result := searchSongsDA(criteria)\n fmt.Fprintf(w, result)\n}", "func TestReadWithSearchQueryTaskAPI(t *testing.T) {\n\tquery := \"search\"\n\treq, err := http.NewRequest(http.MethodDelete, url+\"?query=\"+query, strings.NewReader(\"\"))\n\tif err != nil {\n\t\tt.Errorf(\"unexpected error (%v)\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\n\t// Create a response recorder.\n\trr := httptest.NewRecorder()\n\thandler := http.HandlerFunc(SearchTaskAPI)\n\n\t// Serve the request.\n\thandler.ServeHTTP(rr, req)\n\n\t// Test status code.\n\tif rr.Code != http.StatusOK {\n\t\tt.Errorf(\"Code : %v, Error : %v\", rr.Code, rr.Body.String())\n\t}\n\n\t// Test the result data.\n\tdata, err := jsonapi.UnmarshalManyPayload(rr.Body, reflect.TypeOf(&Task{}))\n\tif err != nil {\n\t\tt.Errorf(\"unexpected error (%v)\", err)\n\t}\n\n\tif len(data) == 0 {\n\t\tt.Errorf(\"expected data len, got %v\", len(data))\n\t}\n\n\t// Iter on data and check the query exist in title\n\tre := regexp.MustCompile(query)\n\tfor _, row := range data {\n\t\ttask := row.(*Task)\n\t\tif \"\" == re.FindString(task.Title) {\n\t\t\tt.Errorf(\"expected task with match title with '%v', got '%v'\", query, task.Title)\n\t\t\treturn\n\t\t}\n\t}\n\n}", "func TestBuildSimpleQuery(t *testing.T) {\n\tq := []QueryElement{\n\t\tQueryElement{Key: \"key0\", Op: \"op0\", Val: \"val0\"},\n\t\tQueryElement{Key: \"key1\", Op: \"op1\", Val: \"val1\"},\n\t}\n\ts := BuildQuery(\"http://localhost/v1/test\", q)\n\tu, err := url.Parse(s)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif u.Query().Get(\"k0\") != \"key0\" {\n\t\tt.Errorf(\"Issue with k0: %v\\n\", u.Query().Get(\"k0\"))\n\t}\n\tif u.Query().Get(\"o0\") != \"op0\" {\n\t\tt.Errorf(\"Issue with o0: %v\\n\", u.Query().Get(\"o0\"))\n\t}\n\tif u.Query().Get(\"v0\") != \"val0\" {\n\t\tt.Errorf(\"Issue with v0: %v\\n\", u.Query().Get(\"v0\"))\n\t}\n\tif u.Query().Get(\"k1\") != \"key1\" {\n\t\tt.Errorf(\"Issue with k1: %v\\n\", u.Query().Get(\"k1\"))\n\t}\n\tif u.Query().Get(\"o1\") != \"op1\" {\n\t\tt.Errorf(\"Issue with o1: %v\\n\", u.Query().Get(\"o1\"))\n\t}\n\tif u.Query().Get(\"v1\") != \"val1\" {\n\t\tt.Errorf(\"Issue with v1: %v\\n\", u.Query().Get(\"v1\"))\n\t}\n}", "func TestRawQuery(t *testing.T) {\n\tassert := assert.New(t)\n\tquery, params := Build(NewRawQuery(\"SELECT * FROM Users WHERE ID >= ?\", 10))\n\tassertEqual(assert, \"SELECT * FROM Users WHERE ID >= ?\", query)\n\tassertParams(assert, []interface{}{10}, params)\n}", "func (b *GroupsSearchBuilder) Q(v string) *GroupsSearchBuilder {\n\tb.Params[\"q\"] = v\n\treturn b\n}", "func runSearch(ctx context.Context, teamsDB teams.TeamsDB, fixturesDB fixtures.DB, query string) (*SearchResults, error) {\n\tteams, err := searchTeams(ctx, teamsDB, query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfixtures, err := fixturesDB.Search(ctx, query)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &SearchResults{\n\t\tQuery: query,\n\t\tFixtures: fixtures,\n\t\tTeams: teams,\n\t}, nil\n}", "func Query(ctx context.Context, search *Search) ([]Result, error) {\n\t// Get fake user agent\n\tfakeUserAgent := browser.Chrome()\n\n\tif search.Num == 0 {\n\t\tsearch.Num = 10\n\t}\n\n\t// Build request\n\turlString := fmt.Sprintf(baseURL, url.QueryEscape(search.Q), search.Num, search.Start)\n\treq, err := http.NewRequestWithContext(ctx, \"GET\", urlString, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Set(\"User-Agent\", fakeUserAgent)\n\tvar resp *http.Response\n\n\t// Do request\n\tif search.TryHard {\n\t\t// Use a proxy if default method fails\n\t\tif p == nil {\n\t\t\tp = proxier.New()\n\t\t\tp.TryNoProxyFirst = true\n\t\t}\n\t\tresp, err = p.DoRequest(ctx, req)\n\t} else {\n\t\tresp, err = http.DefaultClient.Do(req)\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"invalid response code: %d\", resp.StatusCode)\n\t}\n\n\treturn parse(resp.Body)\n}", "func setupSearch() {\n\n}", "func (c *Context) TESTQ(ir, mr operand.Op) {\n\tc.addinstruction(x86.TESTQ(ir, mr))\n}", "func (b *MessagesSearchBuilder) Q(v string) *MessagesSearchBuilder {\n\tb.Params[\"q\"] = v\n\treturn b\n}", "func (i *Index) Search(q query.Query) ([]index.Document, int, error) {\n Flag_highlight := false\n\teq := elastic.NewMatchQuery(\"body\", q.Term).Analyzer(\"whitespace\").Operator(\"and\") //Simple AND query\n if (q.Term[0] == '\"') {\n q.Term = q.Term[1:len(q.Term)-1]\n eq = elastic.NewMatchPhraseQuery(\"body\", q.Term).Analyzer(\"whitespace\").Slop(0) //Phrase Query\n }\n\t//eq := elastic.NewQueryStringQuery(q.Term)\n\t//eq := elastic.NewMatchQuery(\"body\", q.Term).Analyzer(\"whitespace\").Operator(\"and\") //Simple AND query\n //eq := elastic.NewMatchPhraseQuery(\"body\", q.Term).Analyzer(\"whitespace\").Slop(0) //Phrase Query\n\t//eq := elastic.NewMatchPhraseQuery(\"body\", q.Term).Analyzer(\"whitespace\").Slop(100000) //Proximity Query\n\n // Specify highlighter\n hl := elastic.NewHighlight()\n hl = hl.Fields(elastic.NewHighlighterField(\"body\"))\n hl = hl.HighlighterType(\"unified\")\n hl = hl.PreTags(\"<em>\").PostTags(\"</em>\")\n //src, err := hl.Source()\n //j_src, _ := json.MarshalIndent(&src, \"\", \" \")\n //fmt.Println(string(j_src))\n //fmt.Println(\"offset: \", q.Paging.Offset, \"max size: \", q.Paging.Num)\n var res *elastic.SearchResult\n var err error\n // to get latency distribution of each query\n //st_latency := time.Now()\n\n\n if Flag_highlight == true {\n res, err = i.conn.Search(i.name).Type(\"doc\").\n Query(eq).\n\t\tHighlight(hl).\n\t\tFrom(q.Paging.Offset).\n\t\tSize(q.Paging.Num).\n\t\tDo()\n } else {\n res, err = i.conn.Search(i.name).Type(\"doc\").\n Query(eq).\n\t\t//Highlight(hl).\n\t\tFrom(q.Paging.Offset).\n\t\tSize(q.Paging.Num).\n FetchSource(false).\n\t\tDo()\n }\n\n //j, _ := json.MarshalIndent(&res, \"\", \" \")\n //fmt.Println(string(j))\n //fmt.Println(\"=======\", res.Hits.TotalHits)\n //fmt.Println(\"======= took \", res.TookInMillis, \" ms\\n\\n\")\n\tif err != nil {\n\t\treturn nil, 0, err\n\t}\n\n\tret := make([]index.Document, 0, q.Paging.Num)\n\tfor _, h := range res.Hits.Hits {\n\t\tif h != nil {\n\t\t\td := index.NewDocument(h.Id, float32(*h.Score))\n\t\t\t//json.Unmarshal(*h.Source, &d.Properties);\n\t\t\tret = append(ret, d)\n\t\t\t//if err := json.Unmarshal(*h.Source, &d.Properties); err == nil {\n\t\t\t//\tret = append(ret, d)\n\t\t\t//}\n\t\t}\n\n\t}\n\n\t//return ret, int(res.TotalHits()), err\n\treturn ret, int(res.TookInMillis*10), err\n}", "func Query(q string) func(r *Zego) {\n\treturn func(r *Zego) {\n\t\tr.query = q\n\t}\n}", "func (s *gRPCsrv) Search(q *pb.Query, stream pb.Crawler_SearchServer) error {\n\tif q.Key == \"\" {\n\t\treturn badRequest(\"Key must not be empty\")\n\t}\n\n\t// create query\n\td := make(chan bool)\n\topt := mart.Query{\n\t\tKey: q.Key,\n\t\tOrder: mart.ByPrice,\n\t\tDone: func() { d <- true },\n\t}\n\tif q.Order == pb.Query_POPULAR {\n\t\topt.Order = mart.ByPopular\n\t}\n\n\t// find if mart available\n\tvar ms []*mart.Mart\n\tif q.Mart != \"\" {\n\t\tm, err := mart.Open(q.Mart)\n\t\tif err != nil {\n\t\t\treturn noFound(\"Mart \" + q.Mart + \" not available\")\n\t\t}\n\n\t\tms = append(ms, m)\n\t} else {\n\t\tms = mart.All()\n\t\tif len(ms) == 0 {\n\t\t\treturn noFound(\"No mart available\")\n\t\t}\n\t}\n\n\t// create context and channel; make search request\n\tctx, quit := context.WithCancel(stream.Context())\n\tdefer quit()\n\n\tput := make(chan []mart.Product)\n\tche := make(chan error)\n\tfor i := range ms {\n\t\tms[i].Search(ctx, opt, put, che)\n\t}\n\n\t// listen for search response\n\tvar sent, done int64\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tlog.Println(\"Search keyword\", q.Key, \"cancelled\")\n\t\t\treturn nil\n\t\tcase ps := <-put:\n\t\t\tfor i := range ps {\n\t\t\t\tsent++\n\t\t\t\tif q.Num > 0 && sent > q.Num { // reach max number, return\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\n\t\t\t\tif err := stream.Send(&pb.Product{\n\t\t\t\t\tName: ps[i].Name,\n\t\t\t\t\tImage: ps[i].Image,\n\t\t\t\t\tPage: ps[i].Page,\n\t\t\t\t\tPrice: int64(ps[i].Price),\n\t\t\t\t\tMart: ps[i].Mart,\n\t\t\t\t}); err != nil {\n\t\t\t\t\tlog.Println(err)\n\t\t\t\t\treturn nil // connection lost?\n\t\t\t\t}\n\t\t\t}\n\t\tcase err := <-che:\n\t\t\tlog.Println(err)\n\t\tcase <-d:\n\t\t\tdone++\n\t\t\tif done == int64(len(ms)) { // all jobs are done\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}\n}", "func (b *PhotosSearchBuilder) Q(v string) *PhotosSearchBuilder {\n\tb.Params[\"q\"] = v\n\treturn b\n}", "func (r *Elasticsearch) Query(collections []string, term string, bbox []float64, timeVal []time.Time, from int, size int, sr *search.Results) error {\n\tvar mr metadata.Record\n\t//\tvar query elastic.Query\n\tctx := context.Background()\n\n\tquery := elastic.NewBoolQuery()\n\n\tif term == \"\" {\n\t\tquery = query.Must(elastic.NewMatchAllQuery())\n\t} else {\n\t\tquery = query.Must(elastic.NewQueryStringQuery(term))\n\t}\n\tif len(timeVal) > 0 {\n\t\tif len(timeVal) == 1 { // exact match\n\t\t\tquery = query.Must(elastic.NewTermQuery(\"properties.product_info.acquisition_date\", timeVal[0]))\n\t\t} else if len(timeVal) == 2 { // range\n\t\t\trangeQuery := elastic.NewRangeQuery(\"properties.product_info.acquisition_date\").\n\t\t\t\tFrom(timeVal[0]).\n\t\t\t\tTo(timeVal[1])\n\t\t\tquery = query.Must(rangeQuery)\n\t\t}\n\t}\n\tif len(bbox) == 4 {\n\t\t// workaround for issuing a RawStringQuery until\n\t\t// GeoShape queries are supported (https://github.com/olivere/elastic/pull/276)\n\t\tvar tpl bytes.Buffer\n\t\tvars := map[string]interface{}{\n\t\t\t\"bbox\": bbox,\n\t\t\t\"field\": \"geometry\",\n\t\t}\n\t\trawStringQueryTemplate, _ := template.New(\"geo_shape_query\").Parse(`{ \n \"geo_shape\": {\n \"{{ .field }}\": {\n \"shape\": {\n \"type\": \"envelope\",\n \"coordinates\": [\n [ \n {{ index .bbox 0 }}, \n {{ index .bbox 1 }}\n ], \n [ \n {{ index .bbox 2 }}, \n {{ index .bbox 3 }}\n ] \n ]\n },\n \"relation\": \"within\"\n } \n } \n }`)\n\t\trawStringQueryTemplate.Execute(&tpl, vars)\n\n\t\tquery = query.Must(elastic.NewRawStringQuery(tpl.String()))\n\t}\n\tif len(collections) > 0 {\n\t\tc := make([]interface{}, len(collections))\n\t\tfor i, s := range collections {\n\t\t\tc[i] = s\n\t\t}\n\t\tquery = query.Must(elastic.NewTermsQuery(\"properties.product_info.collection\", c...))\n\t}\n\n\t//src, err := query.Source()\n\t//data, err := json.Marshal(src)\n\t//fmt.Println(string(data))\n\n\tsearchResult, err := r.Index.Search().\n\t\tIndex(r.IndexName).\n\t\tType(r.TypeName).\n\t\tFrom(from).\n\t\tSize(size).\n\t\tQuery(query).Do(ctx)\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tfmt.Println(\"JJJJ\")\n\t\treturn err\n\t}\n\n\tsr.ElapsedTime = int(searchResult.TookInMillis)\n\tsr.Matches = int(searchResult.TotalHits())\n\tsr.Returned = size\n\tsr.NextRecord = size + 1\n\n\tif sr.Matches < size {\n\t\tsr.Returned = sr.Matches\n\t\tsr.NextRecord = 0\n\t}\n\n\tfor _, item := range searchResult.Each(reflect.TypeOf(mr)) {\n\t\tif t, ok := item.(metadata.Record); ok {\n\t\t\tsr.Records = append(sr.Records, t)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (client *esClient) Query(index, typeName string, queryStrings ...string) (*elastic.SearchResult, error) {\n\tvar queryString string\n\tif len(queryStrings) > 0 {\n\t\tqueryString = queryStrings[0]\n\t}\n\t// 根据名字查询\n\tquery := elastic.NewQueryStringQuery(queryString)\n\tresult, err := client.Search().Index(index).Type(typeName).Query(query).Do(client.ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif result.Hits.TotalHits > 0 {\n\t\treturn result, nil\n\t}\n\treturn nil, errors.New(\"query the result is null\")\n}", "func home(w http.ResponseWriter, req *http.Request) {\n\tval := req.FormValue(\"q\")\n\tio.WriteString(w, \"Do my search: \"+val)\n}", "func TestSearch(t *testing.T) {\n\n\t\tclient := http.Client{}\n\t\treq, _ := http.NewRequest(\"GET\",\"http://127.0.0.1:8080/api/coupons/fetch?brand=BurgerKong\", nil)\n\n\t\tresp, err := client.Do(req)\n\n\t\tif(err != nil) {\n\n\t\t\tt.Fail()\n\t\t\tt.Logf(\"Error making post request for token modification\")\n\t\t\treturn\n\t\t}\n\n\t\tbody, err := ioutil.ReadAll(resp.Body)\n\n\t\tif(err != nil) {\n\n\t\t\tt.Fail()\n\t\t\tt.Log(\"Error reading response body from token modification\")\n\t\t\treturn\n\t\t}\n\n\t\t// Unpack our coupon(s) - hopefully just one\n\t\tmyCoupons := make([]Structures.Coupon, 0)\n\t\tjson.Unmarshal(body, &myCoupons)\n\n\t\t// OK so the first result should match our second coupon\n\t\tif(myCoupons[0].Brand != coupons[1].Brand) {\n\n\t\t\tt.Fail()\n\t\t\tt.Log(\"Search did not give the expected result\")\n\t\t}\n\t}", "func (m *MongoSearchSuite) TestPatientNameStringQueryObject(c *C) {\n\tq := Query{\"Patient\", \"name=Peters\"}\n\n\to := m.MongoSearcher.createQueryObject(q)\n\tc.Assert(o, DeepEquals, bson.M{\n\t\t\"$or\": []bson.M{\n\t\t\tbson.M{\"name.text\": bson.RegEx{Pattern: \"^Peters\", Options: \"i\"}},\n\t\t\tbson.M{\"name.family\": bson.RegEx{Pattern: \"^Peters\", Options: \"i\"}},\n\t\t\tbson.M{\"name.given\": bson.RegEx{Pattern: \"^Peters\", Options: \"i\"}},\n\t\t},\n\t})\n}", "func TestParseSearchValidList(t *testing.T) {\n\tunittest.SmallTest(t)\n\n\t// Load the list of of live queries.\n\tcontents, err := testutils.ReadFile(\"valid_queries.txt\")\n\trequire.NoError(t, err)\n\n\tqueries := strings.Split(contents, \"\\n\")\n\n\tfor _, qStr := range queries {\n\t\tassertQueryValidity(t, true, qStr)\n\t}\n}", "func (*query) _TSearch(ctx context.Context, args _TSearchArgs) _TResult {\n\treturn _TResult{}\n}", "func Search() {\n\t// Add nodes\n\tclient := Client()\n\taddNodes(client)\n\t// Give the nodes time to end up in all of the data bases. An immediate search will show no nodes\n\ttime.Sleep(10 * time.Second)\n\n\t// List Indexes\n\tindexes, err := client.Search.Indexes()\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Issue listing indexes \", err)\n\t}\n\tfmt.Printf(\"List indexes %+v EndIndex\\n\", indexes)\n\n\t// build an invalid seach query\n\tquery, err := client.Search.NewQuery(\"node\", \"name\")\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Issue building invalid query\", err)\n\t}\n\n\t// build a seach query\n\tquery, err = client.Search.NewQuery(\"node\", \"name:node*\")\n\tquery.Rows = 2\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Issue building query \", err)\n\t}\n\tfmt.Printf(\"List new query %+v\\n\", query)\n\n\t// Run the query\n\tres, err := query.Do(client)\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Issue running query \", err)\n\t}\n\tfmt.Printf(\"List nodes from query %+v\\n\", res)\n\n\t// Run the query, JSON output\n\tjres, err := query.DoJSON(client)\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Issue running query \", err)\n\t}\n\tfmt.Printf(\"List nodes from query JSON format %+v\\n\", jres)\n\n\t// Get the next page of results\n\tfmt.Printf(\"Query after the call %+v\\n\", query)\n\tquery.Start = query.Start + query.Rows\n\tres, err = query.Do(client)\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Issue running 2nd query \", err)\n\t}\n\tfmt.Printf(\"List 2nd set of nodes from query %+v\\n\", res)\n\n\t// Get the next page of results again, in JSON format\n\tquery.Start = query.Start - query.Rows\n\tjres, err = query.DoJSON(client)\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Issue running 2nd query \", err)\n\t}\n\tfmt.Printf(\"List 2nd set of nodes from query JSON format %+v\\n\", jres)\n\n\t// You can also use the service to run a query\n\tres, err = client.Search.Exec(\"node\", \"name:node1\")\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Issue running Search.Exec() \", err)\n\t}\n\tfmt.Printf(\"List nodes from Exec query %+v\\n\", res)\n\t// dump out results back in json as an example\n\tfmt.Println(\"JSON output example\")\n\tjsonData, err := json.MarshalIndent(res, \"\", \"\\t\")\n\tos.Stdout.Write(jsonData)\n\tos.Stdout.WriteString(\"\\n\")\n\n\tres, err = client.Search.Exec(\"node\", \"name:*\")\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Issue running Search.Exec() \", err)\n\t}\n\tfmt.Printf(\"List nodes from all nodes Exec query %+v\\n\", res)\n\n\t// You can also use the service to run a query JSON Format\n\tjres, err = client.Search.ExecJSON(\"node\", \"name:node1\")\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Issue running Search.Exec() \", err)\n\t}\n\tfmt.Printf(\"List nodes from Exec query JSON format %+v\\n\", jres)\n\t// dump out results back in json as an example\n\tfmt.Println(\"JSON output example\")\n\tos.Stdout.WriteString(\"\\n\")\n\n\tjres, err = client.Search.ExecJSON(\"node\", \"name:*\")\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Issue running Search.Exec() \", err)\n\t}\n\tfmt.Printf(\"List nodes from all nodes Exec query JSON format %+v\\n\", jres)\n\n\t// Partial search\n\tpart := make(map[string]interface{})\n\tpart[\"name\"] = []string{\"name\"}\n\tjpres, err := client.Search.PartialExecJSON(\"node\", \"*:*\", part)\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Issue running Search.PartialExec()\", err)\n\t}\n\tfmt.Printf(\"List nodes from partial search %+v\\n\", jpres)\n\n\t// Partial search JSON format\n\tpart = make(map[string]interface{})\n\tpart[\"name\"] = []string{\"name\"}\n\tjpres, err = client.Search.PartialExecJSON(\"node\", \"*:*\", part)\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"Issue running Search.PartialExec()\", err)\n\t}\n\tfmt.Printf(\"List nodes from partial search JSON format %+v\\n\", jpres)\n\tfor i, row := range jpres.Rows {\n\t\tfmt.Fprintf(os.Stdout, \"Partial search JSON format row: %v rawjson: %v\\n\", i, string(row.Data))\n\t}\n\n\t// Clean up nodes\n\tdeleteNodes(client)\n}", "func searchExact(w http.ResponseWriter, r *http.Request, db *mgo.Database, argPos int) {\n\tkey := r.FormValue(\"key\")\n\tval := r.FormValue(\"val\")\n\n\tcontext := make([]appResult, 0, 10)\n\tvar res *appResult\n\n\tc := db.C(\"machines\")\n\tvar usePath bool\n\tif key == \"apps.path\" {\n\t\tusePath = true\n\t}\n\n\terr := c.Find(bson.M{key: val}).\n\t\tSelect(bson.M{\n\t\t\"hostname\": 1,\n\t\t\"apps\": 1,\n\t\t\"_id\": 1}).\n\t\tSort(\"hostname\").\n\t\tFor(&res, func() error {\n\t\tres.Apps = filter_apps(val, res.Apps, usePath)\n\t\tcontext = append(context, *res)\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\tset.ExecuteTemplate(w, \"searchresults\", context)\n}", "func Test_search_a_resource_based_on_a_field(t *testing.T) {\n\n\t//delete the content from disk if it exists from previous tests\n\tdeleteJsonFromDisk(\"users\", \"2\")\n\tdeleteJsonFromDisk(\"users\", \"3\")\n\n\t//define a json content\n\tcontent1 := \"{\\\"country\\\":\\\"Argentina\\\",\\\"id\\\":2,\\\"name\\\":\\\"Natalia\\\"}\"\n\tcontent2 := \"{\\\"country\\\":\\\"Argentina\\\",\\\"id\\\":3,\\\"name\\\":\\\"Agustina\\\"}\"\n\n\t//create the resource\n\tpost(\"/users\", content1)\n\tpost(\"/users\", content2)\n\n\t//search for a resource with equal name\n\tresponse := get(\"/users/search?field=name&equal=Natalia\")\n\n\t//Check the array with only one resource\n\tcheckContent(t, response, \"[\"+content1+\"]\")\n\n\t//search for a resource that not exists\n\tresponse2 := get(\"/users/search?field=name&equal=Adriana\")\n\n\t//Check the array with any resource\n\tcheckContent(t, response2, \"[]\")\n\n\t//search for a resource with equal name\n\tresponse3 := get(\"/users/search?field=country&equal=Argentina\")\n\n\t//Check the array with two resources\n\tbody, _ := ioutil.ReadAll(response3.Body)\n\tif string(body) != \"[\"+content1+\",\"+content2+\"]\" {\n\t\t//Check the array with two resources in the oder order (travis fails without it)\n\t\tif string(body) != \"[\"+content2+\",\"+content1+\"]\" {\n\t\t\tt.Fatalf(\"Non-expected content %s, expected %s or %s\", string(body), \"[\"+content1+\",\"+content2+\"]\", \"[\"+content2+\",\"+content1+\"]\")\n\t\t}\n\t}\n\n\t//delete the content from disk if it exists from previous tests\n\tdeleteJsonFromDisk(\"users\", \"2\")\n\tdeleteJsonFromDisk(\"users\", \"3\")\n}", "func Test_QueryEngine(t *testing.T) {\n\terr := filepath.Walk(\"testdata\", func(path string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !info.IsDir() && strings.HasSuffix(path, \"query.bql\") {\n\t\t\t// path includes the leading testdata directory, so strip that off for the test name\n\t\t\tt.Run(strings.TrimSuffix(strings.TrimPrefix(path, \"testdata/\"), \"/query.bql\"), func(t *testing.T) {\n\t\t\t\trunQueryTest(t, filepath.Dir(path))\n\t\t\t})\n\t\t}\n\t\treturn nil\n\t})\n\tassert.NoError(t, err)\n}", "func (t *VersityChaincode) queryRecords(stub shim.ChaincodeStubInterface, args []string) peer.Response {\n\n\t// 0\n\t// \"queryString\"\n\tif len(args) < 1 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 1\")\n\t}\n\n\tqueryString := args[0]\n\n\tqueryResults, err := getQueryResultForQueryString(stub, queryString)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\treturn shim.Success(queryResults)\n}", "func (tq TestQuery) Test(name string, client *QueryClient) error {\n\t_, err := exec(client, string(tq), nil)\n\tif err != nil {\n\t\tif name == \"\" {\n\t\t\treturn err\n\t\t}\n\t\treturn vterrors.Wrapf(err, \"%s: Execute failed\", name)\n\t}\n\treturn nil\n}", "func Test_Ctx_Query(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\tctx.Fasthttp.Request.URI().SetQueryString(\"search=john&age=20\")\n\tutils.AssertEqual(t, \"john\", ctx.Query(\"search\"))\n\tutils.AssertEqual(t, \"20\", ctx.Query(\"age\"))\n\tutils.AssertEqual(t, \"default\", ctx.Query(\"unknown\", \"default\"))\n}", "func TestGetQuery(t *testing.T) {\n\t// set up test server and mocked LogStore\n\tmockLogStore := new(MockedLogStore)\n\tserver := newTestServer(mockLogStore)\n\ttestServer := httptest.NewServer(server.server.Handler)\n\tdefer testServer.Close()\n\tclient := testServer.Client()\n\n\t// query to ask\n\tstartTime := MustParse(\"2018-01-01T12:00:00.000Z\")\n\tendTime := MustParse(\"2018-01-01T13:00:00.000Z\")\n\tquery := logstore.Query{\n\t\tNamespace: \"default\",\n\t\tPodName: \"nginx-deployment-abcde\",\n\t\tContainerName: \"nginx\",\n\t\tStartTime: startTime,\n\t\tEndTime: endTime,\n\t}\n\n\t//\n\t// set up mock expectations\n\t//\n\n\t// will respond with this query result\n\tlogStoreResult := logstore.QueryResult{\n\t\tLogRows: []logstore.LogRow{\n\t\t\t{\n\t\t\t\tTime: startTime,\n\t\t\t\tLog: \"event 1\",\n\t\t\t},\n\t\t},\n\t}\n\n\tmockLogStore.On(\"Ready\").Return(true, nil)\n\tmockLogStore.On(\"Query\", &query).Return(&logStoreResult, nil)\n\n\t//\n\t// make call\n\t//\n\tqueryURL, _ := url.Parse(testServer.URL + \"/query\")\n\tqueryParams := queryURL.Query()\n\tqueryParams.Set(\"namespace\", query.Namespace)\n\tqueryParams.Set(\"pod_name\", query.PodName)\n\tqueryParams.Set(\"container_name\", query.ContainerName)\n\tqueryParams.Set(\"start_time\", \"2018-01-01T12:00:00.000Z\")\n\tqueryParams.Set(\"end_time\", \"2018-01-01T13:00:00.000Z\")\n\tqueryURL.RawQuery = queryParams.Encode()\n\n\tresp, _ := client.Get(queryURL.String())\n\t// should return 200\n\tassert.Equalf(t, http.StatusOK, resp.StatusCode, \"unexpected response code\")\n\tassert.Equalf(t, []string{\"application/json\"}, resp.Header[\"Content-Type\"], \"unexpected Content-Type\")\n\tvar clientResult logstore.QueryResult\n\tjson.Unmarshal([]byte(readBody(t, resp)), &clientResult)\n\tassert.Equalf(t, logStoreResult, clientResult, \"unexpected query response\")\n\n\t// verify that expected calls were made\n\tmockLogStore.AssertExpectations(t)\n}", "func TestSuccessfulSingleQuery(t *testing.T) {\n\tlocations, err := metaweather.QueryLocations(\"london\")\n\tif err != nil {\n\t\tt.Fatalf(\"query returned error: %v\", err)\n\t}\n\tif len(locations) != 1 {\n\t\tt.Fatalf(\"number of query results is %d\", len(locations))\n\t}\n\tif locations[0].Title != \"London\" {\n\t\tt.Fatalf(\"query results returned wrong location: %v\", locations[0])\n\t}\n}", "func testQueryParserListener() {\n\tfmt.Printf(\"\\ntestQueryParserListener: %s\\n\", t)\n\tinput := antlr.NewInputStream(t)\n\t// input, _ := antlr.NewFileStream(fn)\n\tlexer := query_parser.NewQueryLexer(input)\n\tstream := antlr.NewCommonTokenStream(lexer, 0)\n\tp := query_parser.NewQueryParser(stream)\n\tp.AddErrorListener(antlr.NewDiagnosticErrorListener(true))\n\tp.BuildParseTrees = true\n\ttree := p.Query()\n\tantlr.ParseTreeWalkerDefault.Walk(NewSearchQueryListener(), tree)\n}", "func Search(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tl := logger.New(\"default\")\n\n\tquery := r.URL.Query().Get(\"q\")\n\tresults, err := catalog.SearchMulti(url.QueryEscape(query))\n\tif err != nil {\n\t\tl.Errorf(err.Error())\n\t\thttp.Error(w, \"HTTP 500 : Internal Server Error\", 500)\n\t\treturn\n\t}\n\tcontext := struct {\n\t\tTitle string\n\t\tQuery string\n\t\tResults tmdb.SearchMultiResult\n\t}{\n\t\t\"tvt.io\",\n\t\tquery,\n\t\tresults,\n\t}\n\tt := template.Must(template.ParseFiles(\n\t\t\"templates/search.html\",\n\t\t\"templates/partials/facebook.html\",\n\t\t\"templates/partials/footer.html\",\n\t\t\"templates/partials/javascript.html\",\n\t\t\"templates/partials/css.html\",\n\t))\n\tt.Execute(w, context)\n}", "func TestIndex(t *testing.T) {\n\tdefer os.RemoveAll(\"testidx\")\n\n\tindex, err := New(\"testidx\", mapping)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer index.Close()\n\n\t// index all the people\n\tfor _, person := range people {\n\t\terr = index.Index(person.Identifier, person)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}\n\n\ttermQuery := NewTermQuery(\"marti\").SetField(\"name\")\n\tsearchRequest := NewSearchRequest(termQuery)\n\tsearchResult, err := index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for term query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"a\" {\n\t\t\tt.Errorf(\"expected top hit id 'a', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\ttermQuery = NewTermQuery(\"noone\").SetField(\"name\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(0) {\n\t\tt.Errorf(\"expected 0 total hits\")\n\t}\n\n\tmatchPhraseQuery := NewMatchPhraseQuery(\"long name\")\n\tsearchRequest = NewSearchRequest(matchPhraseQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for phrase query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"b\" {\n\t\t\tt.Errorf(\"expected top hit id 'b', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\ttermQuery = NewTermQuery(\"walking\").SetField(\"name\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(0) {\n\t\tt.Errorf(\"expected 0 total hits\")\n\t}\n\n\tmatchQuery := NewMatchQuery(\"walking\").SetField(\"name\")\n\tsearchRequest = NewSearchRequest(matchQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for match query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"c\" {\n\t\t\tt.Errorf(\"expected top hit id 'c', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\tprefixQuery := NewPrefixQuery(\"bobble\").SetField(\"name\")\n\tsearchRequest = NewSearchRequest(prefixQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for prefix query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"d\" {\n\t\t\tt.Errorf(\"expected top hit id 'd', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\tsyntaxQuery := NewSyntaxQuery(\"+name:phone\")\n\tsearchRequest = NewSearchRequest(syntaxQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for syntax query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"d\" {\n\t\t\tt.Errorf(\"expected top hit id 'd', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\tmaxAge := 30.0\n\tnumericRangeQuery := NewNumericRangeQuery(nil, &maxAge).SetField(\"age\")\n\tsearchRequest = NewSearchRequest(numericRangeQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(2) {\n\t\tt.Errorf(\"expected 2 total hits for numeric range query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"b\" {\n\t\t\tt.Errorf(\"expected top hit id 'b', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t\tif searchResult.Hits[1].ID != \"a\" {\n\t\t\tt.Errorf(\"expected next hit id 'a', got '%s'\", searchResult.Hits[1].ID)\n\t\t}\n\t}\n\n\tstartDate = \"2010-01-01\"\n\tdateRangeQuery := NewDateRangeQuery(&startDate, nil).SetField(\"birthday\")\n\tsearchRequest = NewSearchRequest(dateRangeQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(2) {\n\t\tt.Errorf(\"expected 2 total hits for numeric range query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"d\" {\n\t\t\tt.Errorf(\"expected top hit id 'd', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t\tif searchResult.Hits[1].ID != \"c\" {\n\t\t\tt.Errorf(\"expected next hit id 'c', got '%s'\", searchResult.Hits[1].ID)\n\t\t}\n\t}\n\n\t// test that 0 time doesn't get indexed\n\tendDate = \"2010-01-01\"\n\tdateRangeQuery = NewDateRangeQuery(nil, &endDate).SetField(\"birthday\")\n\tsearchRequest = NewSearchRequest(dateRangeQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for numeric range query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"b\" {\n\t\t\tt.Errorf(\"expected top hit id 'b', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\t// test behavior of arrays\n\t// make sure we can successfully find by all elements in array\n\ttermQuery = NewTermQuery(\"gopher\").SetField(\"tags\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t} else {\n\t\tif searchResult.Total != uint64(1) {\n\t\t\tt.Errorf(\"expected 1 total hit for term query, got %d\", searchResult.Total)\n\t\t} else {\n\t\t\tif searchResult.Hits[0].ID != \"a\" {\n\t\t\t\tt.Errorf(\"expected top hit id 'a', got '%s'\", searchResult.Hits[0].ID)\n\t\t\t}\n\t\t}\n\t}\n\n\ttermQuery = NewTermQuery(\"belieber\").SetField(\"tags\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t} else {\n\t\tif searchResult.Total != uint64(1) {\n\t\t\tt.Errorf(\"expected 1 total hit for term query, got %d\", searchResult.Total)\n\t\t} else {\n\t\t\tif searchResult.Hits[0].ID != \"a\" {\n\t\t\t\tt.Errorf(\"expected top hit id 'a', got '%s'\", searchResult.Hits[0].ID)\n\t\t\t}\n\t\t}\n\t}\n\n\ttermQuery = NewTermQuery(\"notintagsarray\").SetField(\"tags\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(0) {\n\t\tt.Errorf(\"expected 0 total hits\")\n\t}\n\n\t// lookup document a\n\t// expect to find 2 values for field \"tags\"\n\ttagsCount := 0\n\tdoc, err := index.Document(\"a\")\n\tif err != nil {\n\t\tt.Error(err)\n\t} else {\n\t\tfor _, f := range doc.Fields {\n\t\t\tif f.Name() == \"tags\" {\n\t\t\t\ttagsCount++\n\t\t\t}\n\t\t}\n\t}\n\tif tagsCount != 2 {\n\t\tt.Errorf(\"expected to find 2 values for tags\")\n\t}\n}", "func (m *MongoSearchSuite) TestValueQuantityQueryObjectByValueAndUnit(c *C) {\n\tq := Query{\"Observation\", \"value-quantity=185||lbs\"}\n\to := m.MongoSearcher.createQueryObject(q)\n\tc.Assert(o, DeepEquals, bson.M{\n\t\t\"valueQuantity.value\": bson.M{\n\t\t\t\"$gte\": float64(184.5),\n\t\t\t\"$lt\": float64(185.5),\n\t\t},\n\t\t\"$or\": []bson.M{\n\t\t\tbson.M{\"valueQuantity.code\": bson.RegEx{Pattern: \"^lbs$\", Options: \"i\"}},\n\t\t\tbson.M{\"valueQuantity.unit\": bson.RegEx{Pattern: \"^lbs$\", Options: \"i\"}},\n\t\t},\n\t})\n}", "func (t *SimpleChaincode) Query(stub shim.ChaincodeStubInterface, function string, args []string) ([]byte, error) {\n\tfmt.Println(\"query is running \" + function)\n\n\t// Handle different functions\n\tif function == \"read\" { //read a variable\n\t\treturn t.read(stub, args)\n\t} /*else if function == \"searchLogBog\" {\n\t\treturn t.searchSKATEmployee(stub,args)\n\t}*/\n\tfmt.Println(\"query did not find func: \" + function)\n\n\treturn nil, errors.New(\"Received unknown function query: \" + function)\n}", "func (t *IPDCChaincode) query_using_rich_query(stub shim.ChaincodeStubInterface, args []string) pb.Response {\r\n\r\n\tfmt.Println(\"***********Entering query_using_rich_query***********\")\r\n\tif len(args) < 3 {\r\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 3\")\r\n\t}\r\n\r\n\tdocType := args[0]\r\n\tkey := args[1]\r\n\tvalue := args[2]\r\n\r\n\tqueryString := fmt.Sprintf(\"{\\\"selector\\\":{\\\"docType\\\":%s,%s:%s}}\", docType, key, value)\r\n\r\n\tqueryResults, err := getQueryResultForQueryString(stub, queryString)\r\n\tif err != nil {\r\n\t\treturn shim.Error(err.Error())\r\n\t}\r\n\treturn shim.Success(queryResults)\r\n}", "func (m *MongoSearchSuite) TestDeviceStringQueryObject(c *C) {\n\tq := Query{\"Device\", \"manufacturer=Acme\"}\n\n\to := m.MongoSearcher.createQueryObject(q)\n\tc.Assert(o, DeepEquals, bson.M{\"manufacturer\": bson.RegEx{Pattern: \"^Acme\", Options: \"i\"}})\n}", "func TestQueryParser(t *testing.T) {\n\ttests := []struct {\n\t\tname string\n\t\tinputMV2Query string\n\t\texpectedMetricSelector string\n\t\texpectedEntitySelector string\n\t\texpectedUnit string\n\t\texpectError bool\n\t}{\n\t\t// these should fail\n\t\t{\n\t\t\tname: \"percent unit does not work\",\n\t\t\tinputMV2Query: \"MV2;Percent;metricSelector=builtin:host.cpu.usage:merge(\\\"dt.entity.host\\\"):avg:names&entitySelector=type(HOST)\",\n\t\t\texpectError: true,\n\t\t},\n\t\t{\n\t\t\tname: \"missing microsecond metric unit\",\n\t\t\tinputMV2Query: \"MV2;metricSelector=builtin:service.response.server:filter(and(in(\\\"dt.entity.service\\\",entitySelector(\\\"type(service),tag(~\\\"KeptnQualityGate~\\\")\\\")))):splitBy():percentile(90)\",\n\t\t\texpectError: true,\n\t\t},\n\t\t{\n\t\t\tname: \"missing mv2 prefix\",\n\t\t\tinputMV2Query: \"MicroSecond;metricSelector=builtin:service.response.server:filter(and(in(\\\"dt.entity.service\\\",entitySelector(\\\"type(service),tag(~\\\"KeptnQualityGate~\\\")\\\")))):splitBy():percentile(90)\",\n\t\t\texpectError: true,\n\t\t},\n\t\t{\n\t\t\tname: \"missing mv2 prefix\",\n\t\t\tinputMV2Query: \"MV2;MicroSeconds;metricSelector=builtin:service.response.server:filter(and(in(\\\"dt.entity.service\\\",entitySelector(\\\"type(service),tag(~\\\"KeptnQualityGate~\\\")\\\")))):splitBy():percentile(90)\",\n\t\t\texpectError: true,\n\t\t},\n\t\t// these should not fail\n\t\t{\n\t\t\tname: \"microsecond metric works\",\n\t\t\tinputMV2Query: \"MV2;MicroSecond;metricSelector=builtin:service.response.server:filter(and(in(\\\"dt.entity.service\\\",entitySelector(\\\"type(service),tag(~\\\"KeptnQualityGate~\\\")\\\")))):splitBy():percentile(90)\",\n\t\t\texpectedMetricSelector: \"builtin:service.response.server:filter(and(in(\\\"dt.entity.service\\\",entitySelector(\\\"type(service),tag(~\\\"KeptnQualityGate~\\\")\\\")))):splitBy():percentile(90)\",\n\t\t\texpectedUnit: \"MicroSecond\",\n\t\t},\n\t\t{\n\t\t\tname: \"microsecond metric works 2\",\n\t\t\tinputMV2Query: \"MV2;MicroSecond;metricSelector=builtin:service.keyRequest.response.server:filter(and(in(\\\"dt.entity.service_method\\\",entitySelector(\\\"type(service_method),entityName(~\\\"/api/ui/v2/bootstrap~\\\")\\\")))):splitBy(\\\"dt.entity.service_method\\\"):percentile(90)\",\n\t\t\texpectedMetricSelector: \"builtin:service.keyRequest.response.server:filter(and(in(\\\"dt.entity.service_method\\\",entitySelector(\\\"type(service_method),entityName(~\\\"/api/ui/v2/bootstrap~\\\")\\\")))):splitBy(\\\"dt.entity.service_method\\\"):percentile(90)\",\n\t\t\texpectedUnit: \"MicroSecond\",\n\t\t},\n\t\t{\n\t\t\tname: \"microsecond metric works - metric selector first\",\n\t\t\tinputMV2Query: \"MV2;MicroSecond;metricSelector=builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)&entitySelector=type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)\",\n\t\t\texpectedMetricSelector: \"builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedEntitySelector: \"type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)\",\n\t\t\texpectedUnit: \"MicroSecond\",\n\t\t},\n\t\t{\n\t\t\tname: \"microsecond metric works - entity selector first - MicroSecond unit\",\n\t\t\tinputMV2Query: \"MV2;MicroSecond;entitySelector=type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)&metricSelector=builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedMetricSelector: \"builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedEntitySelector: \"type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)\",\n\t\t\texpectedUnit: \"MicroSecond\",\n\t\t},\n\t\t{\n\t\t\tname: \"microsecond metric works - entity selector first - Microsecond unit\",\n\t\t\tinputMV2Query: \"MV2;Microsecond;entitySelector=type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)&metricSelector=builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedMetricSelector: \"builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedEntitySelector: \"type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)\",\n\t\t\texpectedUnit: \"Microsecond\",\n\t\t},\n\t\t{\n\t\t\tname: \"microsecond metric works - entity selector first - microsecond unit\",\n\t\t\tinputMV2Query: \"MV2;microsecond;entitySelector=type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)&metricSelector=builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedMetricSelector: \"builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedEntitySelector: \"type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)\",\n\t\t\texpectedUnit: \"microsecond\",\n\t\t},\n\t\t{\n\t\t\tname: \"microsecond metric works - entity selector first - microSecond unit\",\n\t\t\tinputMV2Query: \"MV2;microSecond;entitySelector=type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)&metricSelector=builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedMetricSelector: \"builtin:service.response.time:merge(\\\"dt.entity.service\\\"):percentile(50)\",\n\t\t\texpectedEntitySelector: \"type(SERVICE),tag(keptn_project:project1),tag(keptn_stage:staging),tag(keptn_service:carts),tag(keptn_deployment:direct)\",\n\t\t\texpectedUnit: \"microSecond\",\n\t\t},\n\t\t{\n\t\t\tname: \"byte metric works - Byte unit\",\n\t\t\tinputMV2Query: \"MV2;Byte;metricSelector=builtin:host.disk.avail:merge(\\\"dt.entity.host\\\"):merge(\\\"dt.entity.disk\\\")\",\n\t\t\texpectedMetricSelector: \"builtin:host.disk.avail:merge(\\\"dt.entity.host\\\"):merge(\\\"dt.entity.disk\\\")\",\n\t\t\texpectedUnit: \"Byte\",\n\t\t},\n\t\t{\n\t\t\tname: \"byte metric works - byte unit\",\n\t\t\tinputMV2Query: \"MV2;byte;metricSelector=builtin:host.disk.avail:merge(\\\"dt.entity.host\\\"):merge(\\\"dt.entity.disk\\\")\",\n\t\t\texpectedMetricSelector: \"builtin:host.disk.avail:merge(\\\"dt.entity.host\\\"):merge(\\\"dt.entity.disk\\\")\",\n\t\t\texpectedUnit: \"byte\",\n\t\t},\n\t}\n\tfor _, tc := range tests {\n\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\tquery, err := NewQueryParser(tc.inputMV2Query).Parse()\n\t\t\tif tc.expectError {\n\t\t\t\tassert.Error(t, err)\n\t\t\t\tassert.Nil(t, query)\n\t\t\t} else {\n\t\t\t\tassert.NoError(t, err)\n\t\t\t\tif assert.NotNil(t, query) {\n\t\t\t\t\tassert.EqualValues(t, tc.expectedUnit, query.GetUnit())\n\t\t\t\t\tassert.EqualValues(t, tc.expectedMetricSelector, query.GetQuery().GetMetricSelector())\n\t\t\t\t\tassert.EqualValues(t, tc.expectedEntitySelector, query.GetQuery().GetEntitySelector())\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n}", "func TestQueryIntegration(t *testing.T) {\n\tqueryData := []byte{\n\t\t111, 222, // [0-1] query ID\n\t\t1, 0, // [2-3] flags, RD=1\n\t\t0, 1, // [4-5] QDCOUNT (number of queries) = 1\n\t\t0, 0, // [6-7] ANCOUNT (number of answers) = 0\n\t\t0, 0, // [8-9] NSCOUNT (number of authoritative answers) = 0\n\t\t0, 0, // [10-11] ARCOUNT (number of additional records) = 0\n\t\t// Start of first query\n\t\t7, 'y', 'o', 'u', 't', 'u', 'b', 'e',\n\t\t3, 'c', 'o', 'm',\n\t\t0, // null terminator of FQDN (DNS root)\n\t\t0, 1, // QTYPE = A\n\t\t0, 1, // QCLASS = IN (Internet)\n\t}\n\n\ttestQuery := func(queryData []byte) {\n\n\t\tdoh, err := NewTransport(testURL, ips, nil, nil, nil)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tresp, err2 := doh.Query(queryData)\n\t\tif err2 != nil {\n\t\t\tt.Fatal(err2)\n\t\t}\n\t\tif resp[0] != queryData[0] || resp[1] != queryData[1] {\n\t\t\tt.Error(\"Query ID mismatch\")\n\t\t}\n\t\tif len(resp) <= len(queryData) {\n\t\t\tt.Error(\"Response is short\")\n\t\t}\n\t}\n\n\ttestQuery(queryData)\n\n\tpaddedQueryBytes, err := AddEdnsPadding(simpleQueryBytes)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\ttestQuery(paddedQueryBytes)\n}", "func TestNonMetricQuery(t *testing.T) {\n\toverrides, err := validation.NewOverrides(validation.Limits{}, nil)\n\trequire.Nil(t, err)\n\n\tengine := logql.NewEngine(logql.EngineOpts{}, &FakeQuerier{}, overrides, log.Logger)\n\tqueryFunc := engineQueryFunc(engine, overrides, fakeChecker{}, \"fake\")\n\n\t_, err = queryFunc(context.TODO(), `{job=\"nginx\"}`, time.Now())\n\trequire.Error(t, err, \"rule result is not a vector or scalar\")\n}", "func (i *Index) Search(q query.Query) (docs []index.Document, total int, err error) {\n\tconn := i.getConn()\n\tdefer conn.Close()\n\n\targs := redis.Args{i.name, q.Term, \"LIMIT\", q.Paging.Offset, q.Paging.Num, \"WITHSCORES\"}\n\t//if q.Flags&query.QueryVerbatim != 0 {\n\targs = append(args, \"VERBATIM\")\n\t//}\n\tif q.Flags&query.QueryNoContent != 0 {\n\t\targs = append(args, \"NOCONTENT\")\n\t}\n\n\tif q.HighlightOpts != nil {\n\t\targs = args.Add(\"HIGHLIGHT\")\n\t\tif q.HighlightOpts.Fields != nil && len(q.HighlightOpts.Fields) > 0 {\n\t\t\targs = args.Add(\"FIELDS\", len(q.HighlightOpts.Fields))\n\t\t\targs = args.AddFlat(q.HighlightOpts.Fields)\n\t\t}\n\t\targs = args.Add(\"TAGS\", q.HighlightOpts.Tags[0], q.HighlightOpts.Tags[1])\n\t}\n\n\tif q.SummarizeOpts != nil {\n\t\targs = args.Add(\"SUMMARIZE\")\n\t\tif q.SummarizeOpts.Fields != nil && len(q.SummarizeOpts.Fields) > 0 {\n\t\t\targs = args.Add(\"FIELDS\", len(q.SummarizeOpts.Fields))\n\t\t\targs = args.AddFlat(q.SummarizeOpts.Fields)\n\t\t}\n\t\tif q.SummarizeOpts.FragmentLen > 0 {\n\t\t\targs = args.Add(\"LEN\", q.SummarizeOpts.FragmentLen)\n\t\t}\n\t\tif q.SummarizeOpts.NumFragments > 0 {\n\t\t\targs = args.Add(\"FRAGS\", q.SummarizeOpts.NumFragments)\n\t\t}\n\t\tif q.SummarizeOpts.Separator != \"\" {\n\t\t\targs = args.Add(\"SEPARATOR\", q.SummarizeOpts.Separator)\n\t\t}\n\t}\n\n\tif err := conn.Send(i.commandPrefix+\".SEARCH\", args...); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif err := conn.Flush(); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif _, err := conn.Receive(); err != nil {\n\t\tpanic(err)\n\t}\n\n\tres, err := redis.Values(conn.Do(i.commandPrefix+\".SEARCH\", args...))\n\tif err != nil {\n\t\treturn nil, 0, err\n\t}\n\n\tif total, err = redis.Int(res[0], nil); err != nil {\n\t\treturn nil, 0, err\n\t}\n\n\tdocs = make([]index.Document, 0, len(res)-1)\n\n\tif len(res) > 2 {\n\t\tfor i := 1; i < len(res); i += 2 {\n\n\t\t\tvar fields interface{} = []interface{}{}\n\t\t\tif q.Flags&query.QueryNoContent == 0 {\n\t\t\t\tfields = res[i+2]\n\n\t\t\t}\n\t\t\tif d, e := loadDocument(res[i], res[i+1], fields); e == nil {\n\t\t\t\tdocs = append(docs, d)\n\t\t\t}\n\t\t\tif q.Flags&query.QueryNoContent == 0 {\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\t}\n\treturn docs, len(docs), nil\n}", "func TestDifferentQueriesTriggersGetAndAccessRequests(t *testing.T) {\n\trunTest(t, func(s *Session) {\n\t\tc := s.Connect()\n\t\tsubscribeToTestQueryModel(t, s, c, \"q=foo&f=bar\", \"q=foo&f=bar\")\n\t\tsubscribeToTestQueryModel(t, s, c, \"q=foo&f=baz\", \"q=foo&f=baz\")\n\t})\n}", "func (s *ValidateService) Q(q string) *ValidateService {\n\ts.q = q\n\treturn s\n}", "func (p *Plugin) searchStackOverflow(userQuery string) map[string]string {\n\n\t// prepare response if search is unsuccessful\n\tfailedResponse := map[string]string{\n\t\t\"Found\": \"false\",\n\t\t\"Question Title\": \"NOT FOUND\",\n\t\t\"Question Body\": \"NOT FOUND\",\n\t\t\"Solution\": \"NOT FOUND\",\n\t}\n\n\t// Preprocess query first\n\tuserQuery = preprocessQuery(userQuery)\n\n\t// Get keywords from query\n\tkeywords := processQuery(userQuery)\n\n\tarrayOfKeywords := strings.Split(keywords, \";\")\n\twordsOfUserQuery := strings.Split(userQuery, \" \")\n\n\t// Prepare tags from words of userQuer\n\ttags := \"\"\n\tfor _, word := range wordsOfUserQuery {\n\t\ttags += word + \";\"\n\t}\n\n\t// Use stackongo to call stackoverflow API\n\tsession := stackongo.NewSession(\"stackoverflow\")\n\n\t// Call stackoverflow search API with appropriate parameters\n\tquestions, err := session.Search(userQuery, map[string]string{\"tagged\": tags, \"intitle\": arrayOfKeywords[0], \"filter\": \"withbody\", \"page\": \"1\", \"pagesize\": \"10\", \"sort\": \"votes\"})\n\tif err != nil {\n\t\tp.API.LogError(\"Failed to search on stackoverflow using stackoverflow API. Returned error.\", \"err\", err.Error())\n\t\treturn failedResponse\n\t}\n\n\t// Consider only those questions that have an accepted answer\n\tquestionsWithAnswers := []stackongo.Question{}\n\tatleastOne := false\n\n\tfor _, question := range questions.Items {\n\n\t\tif question.Is_answered && question.Accepted_answer_id != 0 {\n\t\t\tquestionsWithAnswers = append(questionsWithAnswers, question)\n\t\t\tatleastOne = true\n\t\t}\n\t}\n\n\tif !atleastOne {\n\t\tp.API.LogInfo(\"No question found with an accepted answer\", map[string]string{\"Info\": \"No question found with an accepted answer\"})\n\t\treturn failedResponse\n\t}\n\n\t// Among all questions that have an answer, choose a question whose title best matches with user's question/issue\n\tmaxScore := 0\n\tquestionIndexHighestScore := 0\n\tindex := 0\n\tfor _, question := range questionsWithAnswers {\n\t\tscore := fuzmatch.TokenSetRatio(strings.ToLower(userQuery), strings.ToLower(question.Title))\n\t\tif score > maxScore {\n\t\t\tmaxScore = score\n\t\t\tquestionIndexHighestScore = index\n\t\t}\n\t\tindex = index + 1\n\t}\n\n\t// Get accepted answer to the question selected\n\tid := []int{questionsWithAnswers[questionIndexHighestScore].Accepted_answer_id}\n\tanswers, err := session.GetAnswers(id, map[string]string{\"filter\": \"withbody\"})\n\tif err != nil {\n\t\tp.API.LogError(\"Failed to get answer from stackoverflow\", \"err\", err.Error())\n\t\treturn failedResponse\n\t}\n\tanswerBody := answers.Items[0].Body\n\n\t// Rules for formatting html <code> tag and </code> tag\n\thtml2md.AddRule(\"\", &html2md.Rule{\n\t\tPatterns: []string{\"<code>\"},\n\t\tTp: html2md.Void,\n\t\tReplacement: func(innerHTML string, attrs []string) string {\n\t\t\treturn \"```\"\n\t\t},\n\t})\n\thtml2md.AddRule(\"\", &html2md.Rule{\n\t\tPatterns: []string{\"</code>\"},\n\t\tTp: html2md.Void,\n\t\tReplacement: func(innerHTML string, attrs []string) string {\n\t\t\treturn \"```\"\n\t\t},\n\t})\n\n\tp.API.LogInfo(\"Search on stackoverflow successful\", map[string]string{\"Info\": \"Search on stackoverflow successful\"})\n\treturn map[string]string{\n\t\t\"Found\": \"true\",\n\t\t\"Question Title\": questionsWithAnswers[questionIndexHighestScore].Title,\n\t\t\"Question Body\": html2md.Convert(questionsWithAnswers[questionIndexHighestScore].Body),\n\t\t\"Solution\": html2md.Convert(answerBody),\n\t}\n}", "func TestSuccessfulMultiQuery(t *testing.T) {\n\tlocations, err := metaweather.QueryLocations(\"san\")\n\tif err != nil {\n\t\tt.Fatalf(\"query returned error: %v\", err)\n\t}\n\tif !(len(locations) > 1) {\n\t\tt.Fatalf(\"number of query results is %d\", len(locations))\n\t}\n\tfor i, loc := range locations {\n\t\tif !strings.Contains(strings.ToLower(loc.Title), \"san\") {\n\t\t\tt.Fatalf(\"query result %d contains no 'san': %v\", i, loc)\n\t\t}\n\t}\n}", "func TestSearch(t *testing.T) {\n\t// Create a mocked peers cache connected to a mock directory\n\tcache, mgds, err := makePeersCache()\n\trequire.NoError(t, err, \"could not create mocked peers cache\")\n\tdefer mgds.Shutdown()\n\n\t// Handle the case where GDS returns an error\n\tmgds.UseError(gdsmock.SearchRPC, codes.NotFound, \"the search terms you provided were not found\")\n\t_, err = cache.Search(\"missing\")\n\trequire.EqualError(t, err, \"rpc error: code = NotFound desc = the search terms you provided were not found\")\n\n\t// Handle the case where the GDS returns an error in the lookup reply\n\tmgds.OnSearch = func(context.Context, *gds.SearchRequest) (*gds.SearchReply, error) {\n\t\treturn &gds.SearchReply{\n\t\t\tError: &gds.Error{\n\t\t\t\tCode: 99,\n\t\t\t\tMessage: \"the GDS really shouldn't be returning these errors\",\n\t\t\t},\n\t\t}, nil\n\t}\n\n\t_, err = cache.Search(\"missing\")\n\trequire.EqualError(t, err, \"[99] the GDS really shouldn't be returning these errors\")\n\n\t// Handle the case where GDS returns no results in the search reply\n\tmgds.OnSearch = func(context.Context, *gds.SearchRequest) (*gds.SearchReply, error) {\n\t\treturn &gds.SearchReply{\n\t\t\tResults: make([]*gds.SearchReply_Result, 0),\n\t\t}, nil\n\t}\n\n\t_, err = cache.Search(\"Da Vinci Digital Exchange\")\n\trequire.EqualError(t, err, \"could not find peer named \\\"Da Vinci Digital Exchange\\\"\")\n\n\terr = mgds.UseFixture(gdsmock.SearchRPC, \"testdata/gds_search_reply.pb.json\")\n\trequire.NoError(t, err, \"could not load multiple results fixture\")\n\n\t_, err = cache.Search(\"Da Vinci Digital Exchange\")\n\trequire.EqualError(t, err, \"too many results returned for \\\"Da Vinci Digital Exchange\\\"\")\n\n\t// Have the mock GDS respond correctly based on the input\n\tmgds.Reset()\n\tmgds.OnSearch = func(_ context.Context, in *gds.SearchRequest) (out *gds.SearchReply, err error) {\n\t\tout = &gds.SearchReply{}\n\t\tif err = loadGRPCFixture(\"testdata/gds_search_reply.pb.json\", out); err != nil {\n\t\t\treturn nil, status.Error(codes.FailedPrecondition, err.Error())\n\t\t}\n\n\t\tlookupID := map[string]string{\n\t\t\t\"Da Vinci Digital Exchange\": \"19d84515-007a-48cc-9efd-b153a263e77c\",\n\t\t\t\"Brooklyn BitMining Ltd\": \"b19c9ebd-82f5-4bda-91ef-226e3ecee4b8\",\n\t\t}[in.Name[0]]\n\n\t\tresults := make([]*gds.SearchReply_Result, 0, 1)\n\t\tfor _, result := range out.Results {\n\t\t\tif result.Id == lookupID {\n\t\t\t\tresults = append(results, result)\n\t\t\t}\n\t\t}\n\n\t\treturn &gds.SearchReply{\n\t\t\tResults: results,\n\t\t}, nil\n\t}\n\n\t// Test concurrent Search calls populating the cache\n\tt.Run(\"search\", func(t *testing.T) {\n\t\ttests := []struct {\n\t\t\tname string\n\t\t\tpeer string\n\t\t}{\n\t\t\t{\"search-leonardo\", \"Da Vinci Digital Exchange\"},\n\t\t\t{\"search-donatello\", \"Brooklyn BitMining Ltd\"},\n\t\t}\n\t\tfor _, tt := range tests {\n\t\t\ttc := tt\n\t\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\t\tt.Parallel()\n\t\t\t\tp, err := cache.Search(tc.peer)\n\t\t\t\trequire.NoError(t, err)\n\t\t\t\trequire.NotNil(t, p)\n\t\t\t})\n\t\t}\n\t})\n\n\trequire.Equal(t, 2, mgds.Calls[gdsmock.SearchRPC])\n\trequire.Equal(t, 0, mgds.Calls[gdsmock.LookupRPC])\n\trequire.Equal(t, 0, mgds.Calls[gdsmock.StatusRPC])\n\n\t// Cache should contain the two peers\n\tleonardo, err := cache.Get(\"leonardo.trisa.dev\")\n\trequire.NoError(t, err)\n\trequire.Equal(t, \"19d84515-007a-48cc-9efd-b153a263e77c\", leonardo.Info().ID)\n\trequire.Equal(t, \"testdirectory.org\", leonardo.Info().RegisteredDirectory)\n\trequire.Equal(t, \"leonardo.trisa.dev\", leonardo.Info().CommonName)\n\trequire.Equal(t, \"leonardo.trisa.dev:8000\", leonardo.Info().Endpoint)\n\n\tdonatello, err := cache.Get(\"donatello.example.com\")\n\trequire.NoError(t, err)\n\trequire.Equal(t, \"b19c9ebd-82f5-4bda-91ef-226e3ecee4b8\", donatello.Info().ID)\n\trequire.Equal(t, \"testdirectory.org\", donatello.Info().RegisteredDirectory)\n\trequire.Equal(t, \"donatello.example.com\", donatello.Info().CommonName)\n\trequire.Equal(t, \"donatello.example.com:443\", donatello.Info().Endpoint)\n}", "func (m *MongoSearchSuite) TestImagingStudyBodySiteQueryObjectBySystemAndCode(c *C) {\n\tq := Query{\"ImagingStudy\", \"bodysite=http://snomed.info/sct|67734004\"}\n\to := m.MongoSearcher.createQueryObject(q)\n\tc.Assert(o, DeepEquals, bson.M{\n\t\t\"series\": bson.M{\n\t\t\t\"$elemMatch\": bson.M{\n\t\t\t\t\"bodySite.system\": bson.RegEx{Pattern: \"^http://snomed\\\\.info/sct$\", Options: \"i\"},\n\t\t\t\t\"bodySite.code\": bson.RegEx{Pattern: \"^67734004$\", Options: \"i\"},\n\t\t\t},\n\t\t},\n\t})\n}", "func (t *IPDCChaincode) query_all_rich_query(stub shim.ChaincodeStubInterface, args []string) pb.Response {\r\n\r\n\tfmt.Println(\"***********Entering query_all_rich_query***********\")\r\n\tif len(args) < 1 {\r\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 1\")\r\n\t}\r\n\r\n\tdocType := args[0]\r\n\r\n\tqueryString := fmt.Sprintf(\"{\\\"selector\\\":{\\\"docType\\\":%s}}\", docType)\r\n\r\n\tqueryResults, err := getQueryResultForQueryString(stub, queryString)\r\n\tif err != nil {\r\n\t\treturn shim.Error(err.Error())\r\n\t}\r\n\treturn shim.Success(queryResults)\r\n}", "func TestKeywordSearch(t *testing.T) {\n\ttestURL1 := TestBaseURL + \"/v1/query?keyword=node01\"\n\ttestURL2 := TestBaseURL + \"/v1/query?keyword=node02\"\n\n\ttests := []TestStruct{\n\t\t{\"TestKeywordSearchNode01\", testURL1, \"\", 200, \"\", 0},\n\t\t{\"TestKeywordSearchNode02\", testURL2, \"\", 200, \"\", 0},\n\t}\n\n\tfor i, testCase := range tests {\n\t\tt.Run(testCase.testCaseName, func(t *testing.T) {\n\t\t\tresCode, resBody, _ := KeywordSearch(t, testCase.testURL)\n\t\t\ttests[i].observedStatusCode = resCode\n\t\t\ttests[i].responseBody = string(resBody)\n\t\t})\n\t}\n\tDisplayTestCaseResults(\"TestKeywordSearch\", tests, t, \"uid\")\n}", "func (m *MongoSearchSuite) TestConditionPatientAndCodeAndOnsetQueryObject(c *C) {\n\tq := Query{\"Condition\", \"patient=4954037118555241963&code=http://hl7.org/fhir/sid/icd-9|428.0&onset=2012-03-01T07:00-05:00\"}\n\n\to := m.MongoSearcher.createQueryObject(q)\n\t// Make sure only the expected elements are there\n\tc.Assert(o, HasLen, 4)\n\n\t// Check the patient part of the query\n\tc.Assert(o[\"patient.referenceid\"], DeepEquals, bson.RegEx{Pattern: \"^4954037118555241963$\", Options: \"i\"})\n\tc.Assert(o[\"patient.type\"], Equals, \"Patient\")\n\n\t// Check the code part of the query\n\tc.Assert(o[\"code.coding\"], DeepEquals, bson.M{\n\t\t\"$elemMatch\": bson.M{\n\t\t\t\"system\": bson.RegEx{Pattern: \"^http://hl7\\\\.org/fhir/sid/icd-9$\", Options: \"i\"},\n\t\t\t\"code\": bson.RegEx{Pattern: \"^428\\\\.0$\", Options: \"i\"},\n\t\t},\n\t})\n\n\t// Check the onset part of the query\n\t// 2012-03-01T07:00-05:00 <= onsetDateTime < 2012-03-01T07:01-05:00\n\tonsetDt := o[\"$or\"].([]bson.M)[0][\"onsetDateTime.time\"].(bson.M)\n\tc.Assert(onsetDt, HasLen, 2)\n\tgte := onsetDt[\"$gte\"].(time.Time)\n\tlt := onsetDt[\"$lt\"].(time.Time)\n\tc.Assert(gte.UnixNano(), Equals, time.Date(2012, time.March, 1, 7, 0, 0, 0, m.EST).UnixNano())\n\tc.Assert(lt.UnixNano(), Equals, time.Date(2012, time.March, 1, 7, 1, 0, 0, m.EST).UnixNano())\n\n\t// 2012-03-01T07:00:00-05:00 <= onsetPeriod.start <= onsetPeriod.end < 2012-03-01T07:01:00-05:00\n\tstart := o[\"$or\"].([]bson.M)[1][\"onsetPeriod.start.time\"].(bson.M)[\"$gte\"].(time.Time)\n\tc.Assert(start.UnixNano(), Equals, time.Date(2012, time.March, 1, 7, 0, 0, 0, m.EST).UnixNano())\n\tend := o[\"$or\"].([]bson.M)[1][\"onsetPeriod.end.time\"].(bson.M)[\"$lt\"].(time.Time)\n\tc.Assert(end.UnixNano(), Equals, time.Date(2012, time.March, 1, 7, 1, 0, 0, m.EST).UnixNano())\n}", "func TestESMockSearch(t *testing.T) {\n\tmc := newMockClient()\n\tdefer mc.Close()\n\tAssert(t, mc.CreateIndex(ctx, indexName, \"\") == nil, \"failed to create index\")\n\n\trequests := make([]*elastic.BulkRequest, 10)\n\tfor i := 0; i < 10; i++ {\n\t\trequests[i] = &elastic.BulkRequest{\n\t\t\tRequestType: elastic.Index,\n\t\t\tIndex: indexName,\n\t\t\tID: uuid.NewV4().String(),\n\t\t\tObj: mockObj{name: \"dummy1\"},\n\t\t}\n\t}\n\n\t// test bulk operation\n\tresp, err := mc.Bulk(ctx, requests)\n\tAssert(t, err == nil, \"failed to perform bulk operation\")\n\tAssert(t, len(resp.Indexed()) == 10, fmt.Sprintf(\"expected %v, got %v\", 10, len(resp.Indexed())))\n\n\t// search documents\n\tresult, err := mc.Search(ctx, indexName, mockQuery{name: \"dummy1\"}, mockAggregation{}, from, maxResults, sortByField, sortAsc)\n\tAssert(t, err == nil, \"failed to search\")\n\tAssert(t, result.TotalHits() == 10, fmt.Sprintf(\"expected search result %v, got %v\", 10, result.TotalHits()))\n\n\t// search using invalid query\n\tresult, err = mc.Search(ctx, indexName, nil, mockAggregation{}, from, maxResults, sortByField, sortAsc)\n\tAssert(t, elastic.IsInvalidSearchQuery(err), fmt.Sprintf(\"expected failure, got %v\", err))\n\tAssert(t, result == nil, fmt.Sprintf(\"expected nil search result, got %v\", result))\n}", "func Test_Ctx_QueryParser(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\ttype Query struct {\n\t\tID int\n\t\tName string\n\t\tHobby []string\n\t}\n\tctx.Fasthttp.Request.SetBody([]byte(``))\n\tctx.Fasthttp.Request.Header.SetContentType(\"\")\n\tctx.Fasthttp.Request.URI().SetQueryString(\"id=1&name=tom&hobby=basketball&hobby=football\")\n\tq := new(Query)\n\tutils.AssertEqual(t, nil, ctx.QueryParser(q))\n\tutils.AssertEqual(t, 2, len(q.Hobby))\n\n\tempty := new(Query)\n\tctx.Fasthttp.Request.URI().SetQueryString(\"\")\n\tutils.AssertEqual(t, nil, ctx.QueryParser(empty))\n\tutils.AssertEqual(t, 0, len(empty.Hobby))\n}", "func TestAdvancedFilter(t *testing.T) {\n queries, err := readQuery([]byte(`\n{\n \"filters\": [\n {\"f\": \"generated_time\", \"sql\": \"> subtractMonths(now(), 1)\"}\n ],\n \"order\": \"generated_time\"\n}\n`))\n if err != nil {\n t.Error(err)\n }\n\n //noinspection GoImportUsedAsName\n assert := assert.New(t)\n assert.NotEmpty(queries)\n\n sql, _, err := buildSql(queries[0], \"test\")\n if err != nil {\n t.Error(err)\n }\n assert.Equal(\"select from test where generated_time > subtractMonths(now(), 1) order by generated_time\", sql)\n}", "func (client *Client) Query(text string) ([]string, error) {\n\tif ContainsCh(text) { // 汉字\n\t\treturn client.CliCh.Query(text, AND)\n\t}\n\treturn client.CliEn.Query(text, AND)\n\n}", "func search(cl *lib.Client, r string, c, m, d int) ([]byte, []extAQLFileInfo, error) {\n\t// construct AQL query request\n\tvar request lib.Request\n\trequest.Verb = \"POST\"\n\trequest.Path = \"/api/search/aql\"\n\taqlString := fmt.Sprintf(`items.find(\n\t\t{\n\t\t\t\"$and\": [\n\t\t\t\t{\"repo\":\"%s\"},\n\t\t\t\t{\"created\": {\"$before\": \"%dmo\"}},\n\t\t\t\t{\"modified\": {\"$before\": \"%dmo\"}},\n\t\t\t\t{\"stat.downloaded\":{\"$before\": \"%dmo\"}}\n\t\t\t\t]\n\t\t\t}\n\t\t\t).include(\"updated\",\"created_by\",\"repo\",\"type\",\"size\",\"name\",\"modified_by\",\"path\",\"modified\",\"id\",\"actual_sha1\",\"created\",\"stat.downloaded\")`, r, c, m, d)\n\trequest.Body = bytes.NewReader([]byte(aqlString))\n\trequest.ContentType = \"text/plain\"\n\n\t// make request\n\tresp, err := cl.HTTPRequest(request)\n\tif err != nil {\n\t\texitErrorf(\"could not query Artifactory API: \", err)\n\t}\n\n\t// decode response bytes into json\n\tvar res extAQLResults\n\terr = json.Unmarshal(resp, &res)\n\tif err != nil {\n\t\texitErrorf(\"could not decode Artifactory response: \", err)\n\t}\n\tlist := res.ExtResults\n\n\treturn resp, list, nil\n}", "func (h *HaproxyInstace) q(query string) (string, error) {\n\tc, err := net.Dial(h.Network, h.Address)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer c.Close()\n\n\tc.Write([]byte(query + \"\\n\"))\n\n\tvar buf bytes.Buffer\n\tio.Copy(&buf, c)\n\n\treturn strings.TrimSpace(buf.String()), nil\n}", "func searchByURL(t *testing.T, customHost, queryString string) *app.SearchWorkItemList {\n\tservice := getServiceAsUser()\n\tvar resp interface{}\n\tvar respSetter goatest.ResponseSetterFunc = func(r interface{}) { resp = r }\n\tnewEncoder := func(io.Writer) goa.Encoder { return respSetter }\n\tservice.Encoder = goa.NewHTTPEncoder()\n\tservice.Encoder.Register(newEncoder, \"*/*\")\n\trw := httptest.NewRecorder()\n\tquery := url.Values{}\n\tu := &url.URL{\n\t\tPath: fmt.Sprintf(\"/api/search\"),\n\t\tRawQuery: query.Encode(),\n\t\tHost: customHost,\n\t}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\tpanic(\"invalid test \" + err.Error()) // bug\n\t}\n\tprms := url.Values{}\n\tprms[\"q\"] = []string{queryString} // any value will do\n\tctx := service.Context\n\tgoaCtx := goa.NewContext(goa.WithAction(ctx, \"SearchTest\"), rw, req, prms)\n\tshowCtx, err := app.NewShowSearchContext(goaCtx, service)\n\tif err != nil {\n\t\tpanic(\"invalid test data \" + err.Error()) // bug\n\t}\n\tctrl := NewSearchController(service, gormapplication.NewGormDB(DB))\n\t// Perform action\n\terr = ctrl.Show(showCtx)\n\n\t// Validate response\n\tif err != nil {\n\t\tt.Fatalf(\"controller returned %s\", err)\n\t}\n\tif rw.Code != 200 {\n\t\tt.Fatalf(\"invalid response status code: got %+v, expected 200\", rw.Code)\n\t}\n\tmt, ok := resp.(*app.SearchWorkItemList)\n\tif !ok {\n\t\tt.Fatalf(\"invalid response media: got %+v, expected instance of app.SearchWorkItemList\", resp)\n\t}\n\treturn mt\n}", "func (s *service) searchCore(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tvar err error\n\n\tq := r.FormValue(\"q\")\n\tif len(q) == 0 {\n\t\tq = \"*\"\n\t}\n\n\tsort := r.FormValue(\"sort\")\n\tif len(sort) == 0 {\n\t\tsort = \"dumped_at\"\n\t}\n\tswitch sort {\n\tcase \"dumped_at\", \"hostname\":\n\t\tbreak\n\tdefault:\n\t\twriteError(w, http.StatusBadRequest, fmt.Errorf(\"invalid sort field '%s'\", sort))\n\t\treturn\n\t}\n\n\torder := r.FormValue(\"order\")\n\tif len(order) == 0 {\n\t\torder = \"desc\"\n\t}\n\tswitch order {\n\tcase \"asc\", \"desc\":\n\t\tbreak\n\tdefault:\n\t\twriteError(w, http.StatusBadRequest, fmt.Errorf(\"invalid sort order '%s'\", order))\n\t\treturn\n\t}\n\n\trawSize := r.FormValue(\"size\")\n\tif len(rawSize) == 0 {\n\t\trawSize = \"50\"\n\t}\n\tsize, err := strconv.Atoi(rawSize)\n\tif err != nil {\n\t\twriteError(w, http.StatusBadRequest, wrap(err, \"invalid size parameter\"))\n\t\treturn\n\t}\n\n\trawFrom := r.FormValue(\"from\")\n\tif len(rawFrom) == 0 {\n\t\trawFrom = \"0\"\n\t}\n\tfrom, err := strconv.Atoi(rawFrom)\n\tif err != nil {\n\t\twriteError(w, http.StatusBadRequest, wrap(err, \"invalid from parameter\"))\n\t\treturn\n\t}\n\n\tres, total, err := s.index.Search(q, sort, order, size, from)\n\tif err != nil {\n\t\twriteError(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\twrite(w, http.StatusOK, SearchResult{Results: res, Total: total})\n}", "func (t *MockPgxW) Query(sql string, args ...interface{}) (*pgx.Rows, error) {\n\tif t.ExpQ == nil {\n\t\tt.ExpQ = make([]string, len(t.QueryRes))\n\t\tt.ExpQArgs = make([][]interface{}, len(t.QueryRes))\n\t}\n\ttmp := t.CurrentQ\n\tt.ExpQ[tmp] = sql\n\tt.ExpQArgs[tmp] = args\n\tt.CurrentQ++\n\treturn t.QueryRes[tmp], t.QueryErrs[tmp]\n}", "func (c *HTTPClient) Query(q *Query, timeout time.Duration) (\n res *QueryResponse, err error) {\n\n if q == nil {\n err = fmt.Errorf(\"kairosdb: nil query passed\")\n return\n }\n payload, err := json.Marshal(q)\n if err != nil {\n return\n }\n\n res = &QueryResponse{}\n glog.V(3).Infof(\"querying metric: %s\", string(payload))\n reader := ioutil.NopCloser(bytes.NewReader(payload))\n err = c.backend.Call(\"POST\", c.url+\"/api/v1/datapoints/query\", reader,\n timeout, http.StatusOK, res)\n if err != nil {\n return\n }\n\n glog.V(3).Infof(\"response from query: %+v\", res)\n return\n}", "func TestShortQuery(t *testing.T) {\n\tvar qerr *queryError\n\tdoh, _ := NewTransport(testURL, ips, nil, nil, nil)\n\t_, err := doh.Query([]byte{})\n\tif err == nil {\n\t\tt.Error(\"Empty query should fail\")\n\t} else if !errors.As(err, &qerr) {\n\t\tt.Errorf(\"Wrong error type: %v\", err)\n\t} else if qerr.status != BadQuery {\n\t\tt.Errorf(\"Wrong error status: %d\", qerr.status)\n\t}\n\n\t_, err = doh.Query([]byte{1})\n\tif err == nil {\n\t\tt.Error(\"One byte query should fail\")\n\t} else if !errors.As(err, &qerr) {\n\t\tt.Errorf(\"Wrong error type: %v\", err)\n\t} else if qerr.status != BadQuery {\n\t\tt.Errorf(\"Wrong error status: %d\", qerr.status)\n\t}\n}", "func ADOXQ(mr, r operand.Op) { ctx.ADOXQ(mr, r) }", "func (m *MongoSearchSuite) TestPatientAddressStringQueryObject(c *C) {\n\tq := Query{\"Patient\", \"address=AK\"}\n\n\to := m.MongoSearcher.createQueryObject(q)\n\tc.Assert(o, DeepEquals, bson.M{\n\t\t\"$or\": []bson.M{\n\t\t\tbson.M{\"address.text\": bson.RegEx{Pattern: \"^AK\", Options: \"i\"}},\n\t\t\tbson.M{\"address.line\": bson.RegEx{Pattern: \"^AK\", Options: \"i\"}},\n\t\t\tbson.M{\"address.city\": bson.RegEx{Pattern: \"^AK\", Options: \"i\"}},\n\t\t\tbson.M{\"address.state\": bson.RegEx{Pattern: \"^AK\", Options: \"i\"}},\n\t\t\tbson.M{\"address.postalCode\": bson.RegEx{Pattern: \"^AK\", Options: \"i\"}},\n\t\t\tbson.M{\"address.country\": bson.RegEx{Pattern: \"^AK\", Options: \"i\"}},\n\t\t},\n\t})\n}", "func expectedResultsForQuery(q *query, models []*indexedTestModel) []*indexedTestModel {\n\texpected := make([]*indexedTestModel, len(models))\n\tcopy(expected, models)\n\n\t// apply filters\n\tfor _, filter := range q.filters {\n\t\texpected = orderedIntersectModels(applyFilter(expected, filter), expected)\n\t}\n\n\t// apply order (if applicable)\n\tif q.hasOrder() {\n\t\texpected = applyOrder(expected, q.order)\n\t}\n\n\t// apply limit/offset\n\texpected = applyLimitAndOffset(expected, q.limit, q.offset)\n\n\t// apply includes/excludes\n\tif q.hasIncludes() {\n\t\texpected = applyIncludes(expected, q.includes)\n\t} else if q.hasExcludes() {\n\t\texpected = applyExcludes(expected, q.excludes)\n\t}\n\n\treturn expected\n}", "func (suite *KeeperTestSuite) TestNewQuerier() {\n\tquery := abci.RequestQuery{\n\t\tPath: \"\",\n\t\tData: []byte{},\n\t}\n\n\tcases := []struct {\n\t\tname string\n\t\tpath []string\n\t\texpectsDefaultErr bool\n\t\terrMsg string\n\t}{\n\t\t{\"client - QuerierClients\",\n\t\t\t[]string{clienttypes.SubModuleName, clienttypes.QueryAllClients},\n\t\t\tfalse,\n\t\t\t\"\",\n\t\t},\n\t\t{\n\t\t\t\"client - invalid query\",\n\t\t\t[]string{clienttypes.SubModuleName, \"foo\"},\n\t\t\ttrue,\n\t\t\tfmt.Sprintf(\"unknown IBC %s query endpoint\", clienttypes.SubModuleName),\n\t\t},\n\t\t{\n\t\t\t\"connection - invalid query\",\n\t\t\t[]string{connectiontypes.SubModuleName, \"foo\"},\n\t\t\ttrue,\n\t\t\tfmt.Sprintf(\"unknown IBC %s query endpoint\", connectiontypes.SubModuleName),\n\t\t},\n\t\t{\n\t\t\t\"channel - QuerierChannelClientState\",\n\t\t\t[]string{channeltypes.SubModuleName, channeltypes.QueryChannelClientState},\n\t\t\tfalse,\n\t\t\t\"\",\n\t\t},\n\t\t{\n\t\t\t\"channel - invalid query\",\n\t\t\t[]string{channeltypes.SubModuleName, \"foo\"},\n\t\t\ttrue,\n\t\t\tfmt.Sprintf(\"unknown IBC %s query endpoint\", channeltypes.SubModuleName),\n\t\t},\n\t\t{\n\t\t\t\"invalid query\",\n\t\t\t[]string{\"foo\"},\n\t\t\ttrue,\n\t\t\t\"unknown IBC query endpoint\",\n\t\t},\n\t}\n\n\tfor i, tc := range cases {\n\t\ti, tc := i, tc\n\t\tsuite.Run(tc.name, func() {\n\t\t\t_, err := suite.querier(suite.ctx, tc.path, query)\n\t\t\tif tc.expectsDefaultErr {\n\t\t\t\trequire.Contains(suite.T(), err.Error(), tc.errMsg, \"test case #%d\", i)\n\t\t\t} else {\n\t\t\t\tsuite.Error(err, \"test case #%d\", i)\n\t\t\t}\n\t\t})\n\t}\n}", "func TestMSApp_Queries(t *testing.T) {\n\tt.Parallel()\n\n\tapp, appStop := NewTestDnAppMockVM()\n\tdefer appStop()\n\n\tgenValidators, _, _, _ := CreateGenAccounts(7, GenDefCoins(t))\n\tCheckSetGenesisMockVM(t, app, genValidators)\n\n\t// check call by non-existing uniqueID query\n\t{\n\t\trequest := multisig.CallByUniqueIdReq{UniqueID: \"non-existing-unique-id\"}\n\t\tCheckRunQuerySpecificError(t, app, request, queryMsGetUniqueCall, multisig.ErrWrongCallUniqueId)\n\t}\n}", "func (m *Command) Queryf(t *testing.T, index, rawQuery, query string, params ...interface{}) (string, error) {\n\tquery = fmt.Sprintf(query, params...)\n\tresp := Do(t, \"POST\", fmt.Sprintf(\"%s/index/%s/query?%s\", m.URL(), index, rawQuery), query)\n\tif resp.StatusCode != gohttp.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"invalid status: %d, body=%s\", resp.StatusCode, resp.Body)\n\t}\n\treturn resp.Body, nil\n}", "func (cfg *CfgYaXML) Query(query string) (yr YandexResult, err error) {\n\tvar ye YandexError\n\turlParts := []string{\n\t\tYaURIprefix, cfg.domain, \"/xmlsearch?user=\", cfg.user,\n\t\t\"&key=\", cfg.key, \"&query=\", query,\n\t}\n\turl := strings.Join(urlParts, \"\")\n\t//\tfmt.Println(url)\n\tyr = YandexResult{YandexSearch{}, query, \"\", 0}\n\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\t//ye.err = err\n\t\treturn\n\t}\n\n\trespData, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\t//ye.err = err\n\t\treturn\n\t}\n\n\tyr.httpCode = resp.Status\n\tyr.httpSize = len(respData)\n\tif resp.Status != \"200 OK\" {\n\t\terr = fmt.Errorf(\"response status is %s\", resp.Status)\n\t\treturn\n\t}\n\n\t// Check Yandex error response\n\terr = xml.Unmarshal(respData, &ye)\n\tif err != nil {\n\t\treturn\n\t}\n\tif len(ye.YaErr.Code) > 0 {\n\t\terr = fmt.Errorf(\"Yandex.XML returned code: %s, text: %s\",\n\t\t\tye.YaErr.Code, ye.YaErr.Text)\n\t\treturn\n\t}\n\n\tvar ys YandexSearch\n\tys, err = Parse(respData)\n\tif err != nil {\n\t\treturn\n\t}\n\tyr.data = ys\n\n\treturn\n}", "func TestQuipFactFinding(t *testing.T) {\n\ts := InitScripts()\n\tDescribe_Facts(s)\n\tDescribe_Quips(s)\n\n\ts.The(\"facts\",\n\t\tTable(\"name\", \"summary\").\n\t\t\tHas(\"red\", \"as rage\").\n\t\t\tAnd(\"blue\", \"as the sea\").\n\t\t\tAnd(\"yellow\", \"as the sun\").\n\t\t\tAnd(\"green\", \"as fresh spirulina\"))\n\n\ts.The(\"quips\",\n\t\tTable(\"name\", \"reply\").\n\t\t\tHas(\"retort\", \"arg!\").\n\t\t\tAnd(\"smoothie request\", \"yes, please!\").\n\t\t\tAnd(\"orbital wonder\", \"what were the skies like when you were young?\"))\n\n\ts.The(\"quip requirements\",\n\t\tTable(\"fact\", \"permitted\", \"quip\").\n\t\t\tHas(\"red\", \"permitted\", \"retort\").\n\t\t\tAnd(\"red\", \"prohibited\", \"smoothie request\").\n\t\t\tAnd(\"green\", \"permitted\", \"retort\").\n\t\t\tAnd(\"yellow\", \"prohibited\", \"retort\"))\n\n\tif test, err := NewTestGame(t, s); assert.NoError(t, err) {\n\t\tg := test.Game.NewAdapter()\n\t\tqm := quips.PlayerMemory(g)\n\n\t\tassert.True(t, qm.IsQuipAllowed(g.The(\"orbital wonder\")))\n\t\tassert.True(t, qm.IsQuipAllowed(g.The(\"smoothie request\")))\n\t\tassert.False(t, qm.IsQuipAllowed(g.The(\"retort\")), \"the retort should not be allowed\")\n\n\t\tred := g.The(\"red\")\n\t\trequire.True(t, red.Exists())\n\t\trequire.False(t, qm.Recollects(red), \"before learning, doesnt contain red\")\n\t\tqm.Learns(red)\n\t\trequire.True(t, qm.Recollects(red), \"after learning contains red\")\n\n\t\tassert.True(t, qm.IsQuipAllowed(g.The(\"orbital wonder\")))\n\t\tassert.False(t, qm.IsQuipAllowed(g.The(\"smoothie request\")))\n\t\tassert.False(t, qm.IsQuipAllowed(g.The(\"retort\")))\n\t\tgreen := g.The(\"green\")\n\t\tqm.Learns(green)\n\t\tassert.True(t, qm.IsQuipAllowed(g.The(\"orbital wonder\")))\n\t\tassert.False(t, qm.IsQuipAllowed(g.The(\"smoothie request\")))\n\t\tassert.True(t, qm.IsQuipAllowed(g.The(\"retort\")))\n\t\tyellow := g.The(\"yellow\")\n\t\tqm.Learns(yellow)\n\t\tassert.True(t, qm.IsQuipAllowed(g.The(\"orbital wonder\")))\n\t\tassert.False(t, qm.IsQuipAllowed(g.The(\"smoothie request\")))\n\t\tassert.False(t, qm.IsQuipAllowed(g.The(\"retort\")))\n\t}\n}", "func (m *MongoSearchSuite) TestConditionPatientAndMultipleCodesQueryObject(c *C) {\n\tq := Query{\"Condition\", \"patient=4954037118555241963&code=http://hl7.org/fhir/sid/icd-9|428.0,http://snomed.info/sct|981000124106\"}\n\n\to := m.MongoSearcher.createQueryObject(q)\n\t// Make sure only the expected elements are there\n\tc.Assert(o, HasLen, 3)\n\n\t// Check the patient part of the query\n\tc.Assert(o[\"patient.referenceid\"], DeepEquals, bson.RegEx{Pattern: \"^4954037118555241963$\", Options: \"i\"})\n\tc.Assert(o[\"patient.type\"], Equals, \"Patient\")\n\n\t// Check the code part of the query\n\tc.Assert(o[\"$or\"], DeepEquals, []bson.M{\n\t\tbson.M{\n\t\t\t\"code.coding\": bson.M{\n\t\t\t\t\"$elemMatch\": bson.M{\n\t\t\t\t\t\"system\": bson.RegEx{Pattern: \"^http://hl7\\\\.org/fhir/sid/icd-9$\", Options: \"i\"},\n\t\t\t\t\t\"code\": bson.RegEx{Pattern: \"^428\\\\.0$\", Options: \"i\"},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tbson.M{\n\t\t\t\"code.coding\": bson.M{\n\t\t\t\t\"$elemMatch\": bson.M{\n\t\t\t\t\t\"system\": bson.RegEx{Pattern: \"^http://snomed\\\\.info/sct$\", Options: \"i\"},\n\t\t\t\t\t\"code\": bson.RegEx{Pattern: \"^981000124106$\", Options: \"i\"},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t})\n}", "func (sq *SQ3Driver) realSearch(pattern string, ignoreCase, searchContent bool, ch SearchFeed) {\n\tcolumn := \"key\"\n\tif ignoreCase {\n\t\tcolumn = \"lc_key\"\n\t\tpattern = strings.ToLower(pattern)\n\t}\n\tpattern = \"%\" + pattern + \"%\"\n\n\tsql := fmt.Sprintf(\"SELECT key FROM %v WHERE %v LIKE ?\", dbTable, column)\n\tfmt.Printf(\"DEBUG: Search sql: %v\\n\", sql)\n\trows, err := sq.DB.Query(sql, pattern)\n\tif err != nil {\n\t\tfmt.Printf(\"Error starting query: %v\\n\", err)\n\t\treturn\n\t}\n\tdefer rows.Close()\n\n\terrorStrings := \"\"\n\n\tfor rows.Next() {\n\t\tvar key string\n\t\terr = rows.Scan(&key)\n\t\tif err != nil {\n\t\t\terrorStrings = errorStrings + fmt.Sprintf(\"Error: %v\\n\", err)\n\t\t} else {\n\t\t\t// emit this result\n\t\t\tch <- &DBObj{Key: key}\n\t\t}\n\t}\n\n\tif len(errorStrings) > 0 {\n\t\terr = fmt.Errorf(\"Errors found:\\n%v\", errorStrings)\n\t}\n\t// Return that error as a key for now\n\tch <- &DBObj{Key: errorStrings}\n\n\t// Finally close our channel to notify any consumers we're done.\n\tclose(ch)\n}", "func Search(w http.ResponseWriter, r *http.Request) {\n\tviewData := BaseViewData(w, r)\n\n\ttermMap := utils.GetSearchTermsForString(r.FormValue(\"q\"), true)\n\tterms := make([]string, len(termMap))\n\ti := 0\n\tfor term := range termMap {\n\t\tterms[i] = term\n\t\ti++\n\t}\n\n\tpageNumStr := \"1\"\n\tif len(r.FormValue(\"page\")) > 0 {\n\t\tpageNumStr = r.FormValue(\"page\")\n\t}\n\n\tpage, err := strconv.Atoi(pageNumStr)\n\tif err != nil {\n\t\tviewData.NotFound(w)\n\t\treturn\n\t}\n\t// Correct for the human readable format for page numbers used\n\t// by the client here\n\tpage = page - 1\n\n\tplaceID := -1\n\tif viewData.Session != nil {\n\t\tplaceID = viewData.Session.User.PlaceID\n\t}\n\n\tlistings := []models.Listing{}\n\tif len(terms) > 0 {\n\t\tlistings, err = models.DoSearchForTerms(Base.Db, terms, page, placeID)\n\t\tif err != nil {\n\t\t\tviewData.InternalError(w)\n\t\t\treturn\n\t\t}\n\t}\n\n\tnumPages := models.GetPageCountForTerms(Base.Db, terms, placeID)\n\n\tviewData.Data = searchViewData{\n\t\tListings: listings,\n\t\tQuery: r.FormValue(\"q\"),\n\t\tPage: page + 1,\n\t\tStartOffset: page*50 + 1,\n\t\tEndOffset: page*50 + len(listings),\n\t\tMaxTotal: numPages * 50,\n\t\tOutOf: numPages,\n\t}\n\tRenderView(w, \"search#search\", viewData)\n}", "func (m *MongoSearchSuite) TestConditionCodeQueryObjectBySystemAndCode(c *C) {\n\tq := Query{\"Condition\", \"code=http://snomed.info/sct|123641001\"}\n\to := m.MongoSearcher.createQueryObject(q)\n\tc.Assert(o, DeepEquals, bson.M{\n\t\t\"code.coding\": bson.M{\n\t\t\t\"$elemMatch\": bson.M{\n\t\t\t\t\"system\": bson.RegEx{Pattern: \"^http://snomed\\\\.info/sct$\", Options: \"i\"},\n\t\t\t\t\"code\": bson.RegEx{Pattern: \"^123641001$\", Options: \"i\"},\n\t\t\t},\n\t\t},\n\t})\n}" ]
[ "0.69777787", "0.6884206", "0.6431281", "0.6417766", "0.63961565", "0.63852024", "0.63790214", "0.6338699", "0.6240596", "0.6002227", "0.5930339", "0.5895522", "0.5894307", "0.5869451", "0.5833881", "0.5830371", "0.58204687", "0.58136594", "0.5799873", "0.5759508", "0.57385695", "0.5730464", "0.5714448", "0.57100695", "0.57026774", "0.5690373", "0.5632474", "0.56282395", "0.5607626", "0.56000495", "0.5600026", "0.55757344", "0.55731416", "0.55040157", "0.54996544", "0.5482291", "0.547974", "0.5471526", "0.5465674", "0.5444813", "0.5437083", "0.5425047", "0.54079115", "0.5405133", "0.5387086", "0.53772736", "0.53704125", "0.53699726", "0.53487957", "0.5333881", "0.5333306", "0.53311974", "0.5328759", "0.53278446", "0.53272516", "0.5324131", "0.53221613", "0.5321107", "0.5316062", "0.5315043", "0.530776", "0.53043824", "0.53028923", "0.5299947", "0.52967507", "0.52959216", "0.5292913", "0.5290905", "0.52897894", "0.5286983", "0.52811706", "0.52795094", "0.52792263", "0.52790713", "0.5278533", "0.5276781", "0.5273815", "0.5272803", "0.52575564", "0.5255897", "0.5254258", "0.52415234", "0.523929", "0.52320075", "0.52315193", "0.5220964", "0.522062", "0.52188885", "0.5216091", "0.5212738", "0.5208805", "0.5203519", "0.5191222", "0.51861095", "0.51734304", "0.516278", "0.5156876", "0.51556426", "0.51518756", "0.5150318" ]
0.71631724
0
GenerateTimestampArray allows to generate a Timestamp array
GenerateTimestampArray позволяет создать массив Timestamp
func GenerateTimestampArray(startTS, endTS int64) (tsArray []int64) { daysNbr := (endTS - startTS) / (24 * 3600) var i int64 for i = 0; i <= daysNbr; i++ { tsArray = append(tsArray, startTS+(i*24*3600)) } return tsArray }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func funcTimestamp(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector {\n\tvec := vals[0].(Vector)\n\tfor _, el := range vec {\n\t\tenh.Out = append(enh.Out, Sample{\n\t\t\tMetric: enh.DropMetricName(el.Metric),\n\t\t\tF: float64(el.T) / 1000,\n\t\t})\n\t}\n\treturn enh.Out\n}", "func newTimeSeriesPB(values []float64, timestamps []int64, labels []prompbmarshal.Label) prompbmarshal.TimeSeries {\n\tts := prompbmarshal.TimeSeries{\n\t\tSamples: make([]prompbmarshal.Sample, len(values)),\n\t}\n\tfor i := range values {\n\t\tts.Samples[i] = prompbmarshal.Sample{\n\t\t\tValue: values[i],\n\t\t\tTimestamp: time.Unix(timestamps[i], 0).UnixNano() / 1e6,\n\t\t}\n\t}\n\tts.Labels = labels\n\treturn ts\n}", "func GenerateData[N Number](len int, dtype DataType) []Element[N] {\n\tres := make([]Element[N], len)\n\tt := int64(0)\n\tfor i := 0; i < len; i++ {\n\t\tswitch dtype {\n\t\tcase Int32:\n\t\t\tres[i] = Element[N]{\n\t\t\t\tTimestamp: t,\n\t\t\t\tValue: N(int32(i)),\n\t\t\t}\n\t\tcase Float32:\n\t\t\tres[i] = Element[N]{\n\t\t\t\tTimestamp: t,\n\t\t\t\tValue: N(float32(i)),\n\t\t\t}\n\t\tcase Float64:\n\t\t\tres[i] = Element[N]{\n\t\t\t\tTimestamp: t,\n\t\t\t\tValue: N(float64(i)),\n\t\t\t}\n\t\t}\n\t\tt += 3\n\t}\n\treturn res\n}", "func (_TellorMesosphere *TellorMesosphereCaller) Timestamps(opts *bind.CallOpts, arg0 *big.Int, arg1 *big.Int) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _TellorMesosphere.contract.Call(opts, &out, \"timestamps\", arg0, arg1)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (_ECC *ECCCaller) Timestamps(opts *bind.CallOpts, arg0 [32]byte) (struct {\n\tUnixTime int64\n\tHash [32]byte\n\tDevice common.Address\n}, error) {\n\tret := new(struct {\n\t\tUnixTime int64\n\t\tHash [32]byte\n\t\tDevice common.Address\n\t})\n\tout := ret\n\terr := _ECC.contract.Call(opts, out, \"timestamps\", arg0)\n\treturn *ret, err\n}", "func Timestamp(t, i uint32) Val {\n\tv := Val{t: bsontype.Timestamp}\n\tv.bootstrap[0] = byte(i)\n\tv.bootstrap[1] = byte(i >> 8)\n\tv.bootstrap[2] = byte(i >> 16)\n\tv.bootstrap[3] = byte(i >> 24)\n\tv.bootstrap[4] = byte(t)\n\tv.bootstrap[5] = byte(t >> 8)\n\tv.bootstrap[6] = byte(t >> 16)\n\tv.bootstrap[7] = byte(t >> 24)\n\treturn v\n}", "func (_ECC *ECCSession) Timestamps(arg0 [32]byte) (struct {\n\tUnixTime int64\n\tHash [32]byte\n\tDevice common.Address\n}, error) {\n\treturn _ECC.Contract.Timestamps(&_ECC.CallOpts, arg0)\n}", "func TimeToTimeStampPPB(times ...time.Time) ([]*timestamp.Timestamp, error) {\n\tvar returnStamps []*timestamp.Timestamp\n\tfor _, currentTime := range times {\n\t\tnewStamp, err := ptypes.TimestampProto(currentTime)\n\t\tif err != nil {\n\t\t\tlog.Printf(glErr.DtTimeStampToProtoTimeStamp(currentTime, err))\n\t\t\t// log.Printf(\"Unable to convert timestamp %v to proto timestamp when trying to update promotion. Error: %v \\n\", currentTime, err)\n\t\t\treturn nil, err\n\t\t}\n\t\treturnStamps = append(returnStamps, newStamp)\n\t}\n\treturn returnStamps, nil\n}", "func (_ECC *ECCCallerSession) Timestamps(arg0 [32]byte) (struct {\n\tUnixTime int64\n\tHash [32]byte\n\tDevice common.Address\n}, error) {\n\treturn _ECC.Contract.Timestamps(&_ECC.CallOpts, arg0)\n}", "func (o ApplicationOutput) CreateTimestamp() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Application) pulumi.StringOutput { return v.CreateTimestamp }).(pulumi.StringOutput)\n}", "func (el Elements) Timestamp(i int) int64 {\n\tswitch el.Type {\n\tcase part3.Int32:\n\t\treturn el.I32[i].Ts\n\tcase part3.Float32:\n\t\treturn el.F32[i].Ts\n\tcase part3.Float64:\n\t\treturn el.F64[i].Ts\n\tdefault:\n\t\treturn int64(-1)\n\t}\n}", "func (t *Timestamp) MarshalJSON() ([]byte, error) {\n\tts := time.Time(*t).Unix()\n\tstamp := fmt.Sprint(ts)\n\n\treturn []byte(stamp), nil\n}", "func (t *Timestamp) MarshalJSON() ([]byte, error) {\n\tts := time.Time(*t).Unix()\n\tstamp := fmt.Sprint(ts)\n\n\treturn []byte(stamp), nil\n}", "func NewTweetArray(n int) []Tweet {\n\tres := make([]Tweet, n)\n\tfor i := 0; i < n; i++ {\n\t\tres[i] = NewTweet()\n\t}\n\treturn res\n}", "func (t *Timestamp) MarshalJSON() ([]byte, error) {\n\tif t != nil {\n\t\tts := time.Time(*t)\n\t\treturn []byte(fmt.Sprintf(`\"%d\"`, ts.UnixNano()/int64(time.Millisecond))), nil\n\t}\n\treturn nil, nil\n}", "func TimeStampPPBToTime(timeStamps ...*timestamp.Timestamp) ([]time.Time, error) {\n\tvar returnTimes []time.Time\n\tfor _, timeStamp := range timeStamps {\n\t\tnewTime, err := ptypes.Timestamp(timeStamp)\n\t\tif err != nil {\n\t\t\tlog.Printf(glErr.DtProtoTimeStampToTimeStamp(timeStamp, err))\n\t\t\t// log.Printf(\"Unable to convert proto timestamp %v to timestamp when trying to update promotion. Error: %v \\n\", timeStamp, err)\n\t\t\treturn nil, err\n\t\t}\n\t\treturnTimes = append(returnTimes, newTime)\n\t}\n\treturn returnTimes, nil\n\n}", "func ExampleTime_Timestamp() {\n\tt := gtime.Timestamp()\n\n\tfmt.Println(t)\n\n\t// May output:\n\t// 1533686888\n}", "func getTimeStamp(A []int) time {\n\ttimeStamp := time{}\n\ttimeStamp.hour = A[0]*10 + A[1]\n\ttimeStamp.minute = A[2]*10 + A[3]\n\treturn timeStamp\n}", "func Timestamp(scope *Scope) (ts tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Timestamp\",\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func (t Timestamp) MarshalJSON() ([]byte, error) {\n\t// write seconds.\n\ttt := time.Time(t)\n\tb := make([]byte, 0, 20)\n\tb = strconv.AppendInt(b, tt.Unix(), 10)\n\tb = append(b, '.')\n\n\t// write microsecond\n\tm := (time.Duration(tt.Nanosecond()) + 500*time.Nanosecond) / time.Microsecond\n\tswitch {\n\tcase m < 10:\n\t\tb = append(b, '0', '0', '0', '0', '0')\n\tcase m < 100:\n\t\tb = append(b, '0', '0', '0', '0')\n\tcase m < 1000:\n\t\tb = append(b, '0', '0', '0')\n\tcase m < 10000:\n\t\tb = append(b, '0', '0')\n\tcase m < 100000:\n\t\tb = append(b, '0')\n\t}\n\tb = strconv.AppendInt(b, int64(m), 10)\n\treturn b, nil\n}", "func (ms HistogramDataPoint) Timestamp() TimestampUnixNano {\n\treturn TimestampUnixNano((*ms.orig).TimeUnixNano)\n}", "func (_L1Block *L1BlockCaller) Timestamp(opts *bind.CallOpts) (uint64, error) {\n\tvar out []interface{}\n\terr := _L1Block.contract.Call(opts, &out, \"timestamp\")\n\n\tif err != nil {\n\t\treturn *new(uint64), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(uint64)).(*uint64)\n\n\treturn out0, err\n\n}", "func TimestampProto(t time.Time) (*tspb.Timestamp, error) {\n\tseconds := t.Unix()\n\tnanos := int32(t.Sub(time.Unix(seconds, 0)))\n\tts := &tspb.Timestamp{\n\t\tSeconds: seconds,\n\t\tNanos: nanos,\n\t}\n\tif err := validateTimestamp(ts); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ts, nil\n}", "func WriteTimestamp(buffer []byte, offset int, value Timestamp) {\n nanoseconds := uint64(value.UnixNano())\n WriteUInt64(buffer, offset, nanoseconds)\n}", "func (t Timestamp) MarshalJSON() ([]byte, error) {\n\tts := t.Time().Unix()\n\tstamp := fmt.Sprint(ts)\n\n\treturn []byte(stamp), nil\n}", "func (_TellorMesosphere *TellorMesosphereSession) Timestamps(arg0 *big.Int, arg1 *big.Int) (*big.Int, error) {\n\treturn _TellorMesosphere.Contract.Timestamps(&_TellorMesosphere.CallOpts, arg0, arg1)\n}", "func MarshalTimestamp(x interface{}) (Timestamp, error) {\n\tv := Timestamp{}\n\terr := v.Scan(x)\n\treturn v, err\n}", "func (ms DoubleDataPoint) Timestamp() TimestampUnixNano {\n\treturn TimestampUnixNano((*ms.orig).TimeUnixNano)\n}", "func (self *Tween) GenerateData() []interface{}{\n\tarray00 := self.Object.Call(\"generateData\")\n\tlength00 := array00.Length()\n\tout00 := make([]interface{}, length00, length00)\n\tfor i00 := 0; i00 < length00; i00++ {\n\t\tout00[i00] = array00.Index(i00)\n\t}\n\treturn out00\n}", "func (ms Int64DataPoint) Timestamp() TimestampUnixNano {\n\treturn TimestampUnixNano((*ms.orig).TimeUnixNano)\n}", "func (_TellorMesosphere *TellorMesosphereCallerSession) Timestamps(arg0 *big.Int, arg1 *big.Int) (*big.Int, error) {\n\treturn _TellorMesosphere.Contract.Timestamps(&_TellorMesosphere.CallOpts, arg0, arg1)\n}", "func (t *TsBulk) GetTimestamp() (time.Time, error) {\n\tvar content C.qdb_timespec_t\n\terr := C.qdb_ts_row_get_timestamp(t.table, C.qdb_size_t(t.index), &content)\n\tt.index++\n\treturn content.toStructG(), makeErrorOrNil(err)\n}", "func ManyTimesToProto(times ...interface{}) ([]*timestamp.Timestamp, error) {\n\tvar list []*timestamp.Timestamp\n\tfor _, t := range times {\n\t\tswitch tt := t.(type) {\n\t\tcase time.Time:\n\t\t\tts, err := TimeToProto(tt)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tlist = append(list, ts)\n\t\tcase *time.Time:\n\t\t\tts, err := TimePtrToProto(tt)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tlist = append(list, ts)\n\t\t}\n\t}\n\treturn list, nil\n}", "func (b *Blueprint) Timestamps(precision int) {\n\tb.Timestamp(\"created_at\", precision).Nullable()\n\tb.Timestamp(\"updated_at\", precision).Nullable()\n}", "func makeTimestamp() int64 {\n\treturn time.Now().UnixNano()/int64(time.Microsecond)\n}", "func As2DArray(rawdata interface{}, params *TimeSeriesParam) ([][]interface{}, *api.Error) {\n\trawArray := reflect.ValueOf(rawdata)\n\trawArray.Len()\n\n\tkey := params.AsArray\n\tswitch key {\n\tcase \"time\", \"height\", \"timems\": // Valid\n\tdefault: // Invalid\n\t\te := api.NewInvalidParametersError()\n\t\te.Data = fmt.Errorf(\"'asarray' must be 'time' or 'height'\")\n\t\treturn nil, e\n\t}\n\n\tvar result [][]interface{}\n\tfor i := 0; i < rawArray.Len(); i++ {\n\t\titem := rawArray.Index(i).Interface().(database.ITimeSeriesData)\n\t\tv := []interface{}{dataKey(item, key)}\n\n\t\tfor _, value := range params.Values {\n\t\t\tv = append(v, database.FieldValue(item, value))\n\t\t}\n\t\tresult = append(result, v)\n\t}\n\treturn result, nil\n}", "func timeToByteArr(timeVal int64) []byte {\n\tbuff := make([]byte, 8)\n\tbinary.BigEndian.PutUint64(buff, uint64(timeVal))\n\n\treturn buff\n\n}", "func (t *timestamp) MarshalJSON() ([]byte, error) {\n\tts := time.Time(*t).Unix()\n\tstamp := fmt.Sprint(ts)\n\treturn []byte(stamp), nil\n}", "func (t Timestamp) MarshalJSON() ([]byte, error) {\n\tbuf := make([]byte, 0, 20)\n\tbuf = strconv.AppendInt(buf, int64(t), 10)\n\treturn buf, nil\n}", "func (t Timestamp) MarshalJSON() ([]byte, error) {\n\t// Per Node.js epochs, we need milliseconds\n\treturn []byte(strconv.FormatInt(t.JSEpoch(), 10)), nil\n}", "func TestTimestamp(t *testing.T) {\n\tassert := assert.New(t)\n\n\ttestCases := []*TestCaseRoundTrip{\n\t\t{\n\t\t\tName: \"NotNil\",\n\t\t\tValue: protosql.Timestamp(timestamppb.New(time.Now().UTC())),\n\t\t\tDecoded: &protosql.TimestampMarshaller{},\n\t\t\tSQLFieldType: \"datetime\",\n\t\t\tSubTest: func(t *testing.T, testCase *TestCaseRoundTrip) {\n\t\t\t\tencoded := testCase.Value.(protosql.TimestampMarshaller)\n\t\t\t\tdecoded := testCase.Decoded.(*protosql.TimestampMarshaller)\n\n\t\t\t\tassert.True(\n\t\t\t\t\tdecoded.AsTime().Equal(encoded.AsTime()),\n\t\t\t\t\t\"%v equals %v\",\n\t\t\t\t\tdecoded.AsTime(),\n\t\t\t\t\tencoded.AsTime(),\n\t\t\t\t)\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"Nil\",\n\t\t\tValue: protosql.Timestamp(nil),\n\t\t\tDecoded: &protosql.TimestampMarshaller{},\n\t\t\tSQLFieldType: \"datetime\",\n\t\t\tSubTest: func(t *testing.T, testCase *TestCaseRoundTrip) {\n\t\t\t\tdecoded := testCase.Decoded.(*protosql.TimestampMarshaller)\n\t\t\t\tassert.Nil(decoded.Timestamp)\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tName: \"ScanErr\",\n\t\t\tValue: \"not a timestamp\",\n\t\t\tDecoded: &protosql.TimestampMarshaller{},\n\t\t\tSQLFieldType: \"string\",\n\t\t\tExpectedDecodeErr: errors.New(\n\t\t\t\t\"sql: Scan error on column index 0, name \\\"value\\\": \" +\n\t\t\t\t\t\"unsupported Scan, storing driver.Value type string into type\" +\n\t\t\t\t\t\" *time.Time\",\n\t\t\t),\n\t\t},\n\t}\n\n\tfor _, testCase := range testCases {\n\t\tRunTestRoundTrip(t, testCase)\n\t}\n}", "func makeTimestamp() int64 {\n\treturn time.Now().UnixNano() / int64(time.Millisecond)\n}", "func collectTimestamp(ch chan<- prometheus.Metric, desc *prometheus.Desc, time time.Time, labelValues ...string) {\n\tif time.IsZero() {\n\t\treturn\n\t}\n\n\tch <- prometheus.MustNewConstMetric(\n\t\tdesc,\n\t\tprometheus.GaugeValue,\n\t\tfloat64(time.Unix()),\n\t\tlabelValues...,\n\t)\n}", "func (v Timestamp) MarshalJSON() ([]byte, error) {\n\tif !v.Valid() {\n\t\treturn nullBytes, nil\n\t}\n\treturn []byte(strconv.FormatInt(v.time.Unix(), 10)), nil\n}", "func TimestampProto(t time.Time) *tspb.Timestamp {\n\tts, err := ptypes.TimestampProto(t)\n\tif err != nil {\n\t\treturn &tspb.Timestamp{}\n\t}\n\treturn ts\n}", "func (o TestMatrixOutput) Timestamp() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *TestMatrix) pulumi.StringOutput { return v.Timestamp }).(pulumi.StringOutput)\n}", "func (cr CertResponse) ToArray() []string {\n\tdays := int(cr.NotAfter.Time.Sub(time.Now()).Hours() / 24)\n\tvar daysleft string\n\tif days == 0 {\n\t\tdaysleft = \"today\"\n\t} else if days == 1 {\n\t\tdaysleft = fmt.Sprintf(\"%d day\", days)\n\t} else {\n\t\tdaysleft = fmt.Sprintf(\"%v days\", days)\n\t}\n\n\treturn []string{cr.CommonName, cr.NameValue, ISO8601LocalTime.String(cr.EntryTimestamp), cr.IssuerName, ISO8601LocalTime.String(cr.NotBefore), ISO8601LocalTime.String(cr.NotAfter), daysleft}\n}", "func makeTimestamp() int64 {\n return time.Now().UnixNano() / int64(time.Millisecond)\n}", "func MarshalTimestamp(t time.Time) graphql.Marshaler {\n\treturn graphql.WriterFunc(func(w io.Writer) {\n\t\tio.WriteString(w, strconv.FormatInt(t.Unix(), 10))\n\t})\n}", "func MarshalTimestamp(t time.Time) graphql.Marshaler {\n\treturn graphql.WriterFunc(func(w io.Writer) {\n\t\tio.WriteString(w, strconv.FormatInt(t.Unix(), 10))\n\t})\n}", "func makeTimestamp() int64 {\n\treturn time.Now().UnixNano() / (int64(time.Millisecond) / int64(time.Nanosecond))\n}", "func makeTimestamp() int64 {\n\treturn time.Now().UnixNano() / (int64(time.Millisecond) / int64(time.Nanosecond))\n}", "func GenerateArray(n int) ([]int, error) {\n\tif n < 1 {\n\t\treturn nil, ErrArrayNoLength\n\t}\n\n\tvar arr []int\n\trand.Seed(time.Now().UTC().UnixNano())\n\tfor i := 0; i < n; i++ {\n\t\tarr = append(arr, rand.Intn(LENGTH))\n\t}\n\n\treturn arr, nil\n}", "func (l *Lista) GetArray() []Tiendas{\n\ta := make([]Tiendas, l.len)\n\ti := 0\n\tAux := l.Inicio\n\tfor Aux != nil{\n\t\ta[i] = Aux.Dato\n\t\ti++\n\t\tAux = Aux.Siguiente\n\t}\n\treturn a\n}", "func (l *ListaXTienda) GetArray() []XTiendas{\n\ta := make([]XTiendas, l.len)\n\ti := 0\n\tAux := l.Inicio\n\tfor Aux != nil{\n\t\ta[i] = Aux.Dato\n\t\ti++\n\t\tAux = Aux.Siguiente\n\t}\n\treturn a\n}", "func (_Aggregator *AggregatorCaller) GetTimestamp(opts *bind.CallOpts, roundId *big.Int) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _Aggregator.contract.Call(opts, &out, \"getTimestamp\", roundId)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (_AggregatorV2V3Interface *AggregatorV2V3InterfaceCaller) GetTimestamp(opts *bind.CallOpts, roundId *big.Int) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _AggregatorV2V3Interface.contract.Call(opts, &out, \"getTimestamp\", roundId)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func EncodeTimestamp(b []byte, t time.Time) {\n\tbinary.LittleEndian.PutUint64(b, uint64(t.UTC().UnixNano()/100+116444736000000000))\n}", "func (_Token *TokenCaller) LaunchTimestamp(opts *bind.CallOpts) (*big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t)\n\tout := ret0\n\terr := _Token.contract.Call(opts, out, \"launchTimestamp\")\n\treturn *ret0, err\n}", "func NewArrayGenerator(array []interface{}) Generator {\n\treturn &arrayGenerator{array, 0}\n}", "func initTSFile(filepath string) {\n\tif _, err := os.Stat(filepath); os.IsNotExist(err) {\n\t\ttimestamps := []int{}\n\t\twriteTSToFile(filepath, timestamps)\n\t}\n}", "func (ms HistogramBucketExemplar) Timestamp() TimestampUnixNano {\n\treturn TimestampUnixNano((*ms.orig).TimeUnixNano)\n}", "func generateInput(n int) []time.Duration {\n\tar := []time.Duration{}\n\tfor i := 0; i < n; i++ {\n\t\td := time.Duration(rand.Int63n(6000))\n\t\tar = append(ar, d)\n\t}\n\treturn ar\n}", "func (p *parser) parseTimestamp(annotations []Symbol) Timestamp {\n\treturn Timestamp{annotations: annotations, text: p.next().Val}\n}", "func (t *Timestamp) MarshalJSON() ([]byte, error) {\n\treturn []byte(t.String()), nil\n}", "func (UserID) mapToArray(params []interface{}) *[]UserID {\n\tmembers := ArrayToStringType(params)\n\tUserList := make([]UserID, len(members))\n\tfor i := range members {\n\t\tUserList[i] = UserID{}.mapToStruct(members[i])\n\t}\n\treturn &UserList\n}", "func ExampleMarshal_toarray() {\n\ttype Record struct {\n\t\t_ struct{} `cbor:\",toarray\"`\n\t\tName string\n\t\tUnit string\n\t\tMeasurement int\n\t}\n\trec := Record{Name: \"current\", Unit: \"V\", Measurement: 1}\n\tb, err := cbor.Marshal(rec)\n\tif err != nil {\n\t\tfmt.Println(\"error:\", err)\n\t}\n\tfmt.Printf(\"%x\\n\", b)\n\t// Output:\n\t// 836763757272656e74615601\n}", "func typeToArray(args ...DataType) (DataType, error) {\n\tif len(args) != 1 {\n\t\treturn nil, fmt.Errorf(\"Type.toArray expects exactly 1 argument\")\n\t}\n\n\tswitch object := args[0].(type) {\n\tcase *StringType:\n\t\tresult := []DataType{}\n\t\tfor _, k := range object.Value {\n\t\t\tresult = append(result, &StringType{Value: string(k)})\n\t\t}\n\n\t\treturn &ArrayType{Elements: result}, nil\n\tcase *IntegerType, *FloatType:\n\t\treturn &ArrayType{Elements: []DataType{object}}, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Type.toArray can't convert '%s' to Array\", object.Type())\n\t}\n}", "func (s *Schema) GenerateSchemaFields(FormattedRecords []map[string]interface{}, timestampFormat string) []string {\n\tlog.Printf(\"GOT TIMESTAMP FORMAT: %v\", timestampFormat)\n\ttimestampFields := make([]string, len(FormattedRecords))\n\tfor _, record := range FormattedRecords {\n\t\tfor recordKey, recordValue := range record {\n\t\t\tswitch reflect.ValueOf(recordValue).Kind() {\n\t\t\tcase reflect.Int64:\n\t\t\t\ts.AddField(recordKey, \"long\")\n\t\t\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32:\n\t\t\t\ts.AddField(recordKey, \"int\")\n\t\t\tcase reflect.Bool:\n\t\t\t\ts.AddField(recordKey, \"boolean\")\n\t\t\tcase reflect.Float32:\n\t\t\t\ts.AddField(recordKey, \"float\")\n\t\t\tcase reflect.Float64:\n\t\t\t\t// CHECK IF FLOAT IS ACTUALLY AN INT BECAUSE JSON UNMARSHALLS ALL NUMBERS AS FLOAT64\n\t\t\t\t// IF IT IS, EDIT THE VALUE SO IT IS AN INT AND THEN USE INT SCHEMA\n\t\t\t\tisInt := isFloatInt(recordValue.(float64))\n\t\t\t\tif !isInt {\n\t\t\t\t\ts.AddField(recordKey, \"double\")\n\t\t\t\t} else {\n\t\t\t\t\tnewValue := int(recordValue.(float64))\n\t\t\t\t\trecord[recordKey] = newValue\n\t\t\t\t\ts.AddField(recordKey, \"int\")\n\t\t\t\t}\n\t\t\tcase reflect.String:\n\t\t\t\t// ATTEMPT TO CONVERT STRINGS TO time.Time objects, IF IT FAILS THEN ITS JUST STRING, ELSE MAKE IT A TIMESTAMP\n\t\t\t\tnewValue, _ := recordValue.(string)\n\t\t\t\ttimeValue, err := time.Parse(timestampFormat, newValue)\n\t\t\t\tif err == nil {\n\t\t\t\t\t// BIGQUERY TAKES UNIX MICROS SO WE GET NANO AND DIVIDE BY 1000\n\t\t\t\t\trecord[recordKey] = timeValue.UnixNano() / 1000\n\t\t\t\t\ttimestampFields = append(timestampFields, recordKey)\n\t\t\t\t\ts.AddField(recordKey, \"long\")\n\t\t\t\t} else {\n\t\t\t\t\ts.AddField(recordKey, \"string\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn timestampFields\n}", "func NewTimestamp(unixTime int64) *Timestamp {\n\tstamp := Timestamp(time.Unix(unixTime, 0))\n\treturn &stamp\n}", "func (id UUID) Timestamp() (sec uint32, millisec uint16) {\n\tsec = uint32(id[0])<<24 | uint32(id[1])<<16 | uint32(id[2])<<8 | uint32(id[3])\n\tmillisec = uint16(id[4])<<8 | uint16(id[5])\n\treturn\n}", "func (t Timestamp) MarshalJSON() ([]byte, error) {\n\t// Always send back in UTC with nanoseconds\n\ts := t.Time().UTC().Format(time.RFC3339Nano)\n\treturn []byte(`\"` + s + `\"`), nil\n}", "func (ts *Timestamp) MarshalJSON() ([]byte, error) {\n\n\tif ts == nil || *ts == 0 {\n\t\treturn ekaenc.NULL_JSON_BYTES_SLICE, nil\n\t}\n\n\t// Date: 10 chars (YYYY-MM-DD)\n\t// Clock: 8 chars (hh:mm:ss)\n\t// Quotes: 2 chars (\"\")\n\t// Date clock separator: 1 char (T)\n\t// Summary: 21 char.\n\tb := make([]byte, 21)\n\n\t_ = ts.Date().AppendTo(b[1:1:20], '-')\n\t_ = ts.Time().AppendTo(b[12:12:20], ':')\n\n\tb[0] = '\"'\n\tb[11] = 'T'\n\tb[20] = '\"'\n\n\treturn b, nil\n}", "func InitTimestampsTable(db *sql.DB) {\n\tstmt, _ := db.Prepare(`CREATE TABLE IF NOT EXISTS timestamps (\n\t\tday text,\n\t\thour text,\n\t\tchannel text,\n\t\tmessages integer DEFAULT 0,\n\t\treactions integer DEFAULT 0,\n\t\tembeds integer DEFAULT 0\n\t)`)\n\tstmt.Exec()\n}", "func getTSFromFile(filename string) []int {\n\tcontent, err := ioutil.ReadFile(filename)\n\thandleError(err)\n\n\tvar timestamps []int\n\terrJSON := json.Unmarshal(content, &timestamps)\n\thandleError(errJSON)\n\n\treturn timestamps\n}", "func ToADXTimeSeries(in *data.Frame) (*data.Frame, error) {\n\tif in.Rows() == 0 {\n\t\treturn in, nil\n\t}\n\n\ttimeColIdx := -1\n\tlabelColIdxs := []int{}\n\tvalueColIdxs := []int{}\n\n\t// TODO check to avoid panics\n\tgetKustoColType := func(fIdx int) string {\n\t\treturn in.Meta.Custom.(AzureFrameMD).ColumnTypes[fIdx]\n\t}\n\n\tfoundTime := false\n\tfor fieldIdx, field := range in.Fields {\n\t\tswitch getKustoColType(fieldIdx) {\n\t\tcase \"string\":\n\t\t\tlabelColIdxs = append(labelColIdxs, fieldIdx)\n\t\tcase \"dynamic\":\n\t\t\tif field.Name == \"Timestamp\" {\n\t\t\t\tif foundTime {\n\t\t\t\t\treturn nil, fmt.Errorf(\"must be exactly one column named 'Timestamp', but response has more than one\")\n\t\t\t\t}\n\t\t\t\tfoundTime = true\n\t\t\t\ttimeColIdx = fieldIdx\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tvalueColIdxs = append(valueColIdxs, fieldIdx)\n\n\t\t}\n\t}\n\n\tif timeColIdx == -1 {\n\t\treturn nil, fmt.Errorf(\"response must have a column named 'Timestamp'\")\n\t}\n\tif len(valueColIdxs) < 1 {\n\t\treturn nil, fmt.Errorf(\"did not find a numeric value column, expected at least one column of type 'dynamic', got %v\", len(valueColIdxs))\n\t}\n\n\tout := data.NewFrame(in.Name).SetMeta(&data.FrameMeta{ExecutedQueryString: in.Meta.ExecutedQueryString})\n\n\t// Each row is a series\n\texpectedRowLen := 0\n\tfor rowIdx := 0; rowIdx < in.Rows(); rowIdx++ {\n\t\t// Set up the shared time index\n\t\tif rowIdx == 0 {\n\t\t\trawTimeArrayString := in.At(timeColIdx, 0).(string)\n\t\t\ttimes := []time.Time{}\n\t\t\terr := jsoniter.Unmarshal([]byte(rawTimeArrayString), &times)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\texpectedRowLen = len(times)\n\t\t\tout.Fields = append(out.Fields, data.NewField(\"Timestamp\", nil, times))\n\t\t}\n\n\t\t// Build the labels for the series from the row\n\t\tvar l data.Labels\n\t\tfor i, labelIdx := range labelColIdxs {\n\t\t\tif i == 0 {\n\t\t\t\tl = make(data.Labels)\n\t\t\t}\n\t\t\tlabelVal, _ := in.ConcreteAt(labelIdx, rowIdx)\n\t\t\tl[in.Fields[labelIdx].Name] = labelVal.(string)\n\t\t}\n\n\t\tfor _, valueIdx := range valueColIdxs {\n\t\t\t// Will treat all numberic values as nullable floats here\n\t\t\tvals := []*float64{}\n\t\t\trawValues := in.At(valueIdx, rowIdx).(string)\n\t\t\terr := jsoniter.Unmarshal([]byte(rawValues), &vals)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif len(vals) == 0 {\n\t\t\t\t// When all the values are null, the object is null in the response.\n\t\t\t\t// Must set to length of frame for a consistent length frame\n\t\t\t\tvals = make([]*float64, expectedRowLen)\n\t\t\t}\n\t\t\tout.Fields = append(out.Fields, data.NewField(in.Fields[valueIdx].Name, l, vals))\n\t\t}\n\n\t}\n\n\treturn out, nil\n}", "func Array(args ...interface{}) []interface{} {\n\treturn []interface{}{args}\n}", "func (ms SummaryDataPoint) Timestamp() TimestampUnixNano {\n\treturn TimestampUnixNano((*ms.orig).TimeUnixNano)\n}", "func MarshalTimestamp(s *jsonplugin.MarshalState, v *timestamppb.Timestamp) {\n\tif v == nil {\n\t\ts.WriteNil()\n\t\treturn\n\t}\n\ts.WriteTime(v.AsTime())\n}", "func TimestampFromStdTime(t time.Time) Timestamp {\n\tif t.IsZero() {\n\t\treturn Timestamp(0)\n\t}\n\treturn Timestamp(t.UTC().Unix())\n}", "func UseFrozenTimeStamps() {\n\ttimestamper = func() time.Time {\n\t\treturn time.Unix(190701725, 0)\n\t}\n}", "func (_BaseAccessWallet *BaseAccessWalletCaller) ValidateTimestamp(opts *bind.CallOpts, _ts *big.Int) (bool, error) {\n\tvar out []interface{}\n\terr := _BaseAccessWallet.contract.Call(opts, &out, \"validateTimestamp\", _ts)\n\n\tif err != nil {\n\t\treturn *new(bool), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(bool)).(*bool)\n\n\treturn out0, err\n\n}", "func (mr *MetricsRecorder) GetTimeSeriesData() []ts.TimeSeriesData {\n\tmr.mu.Lock()\n\tdefer mr.mu.Unlock()\n\n\tif mr.mu.desc.NodeID == 0 {\n\t\t// We haven't yet processed initialization information; do nothing.\n\t\tif log.V(1) {\n\t\t\tlog.Warning(\"MetricsRecorder.GetTimeSeriesData() called before NodeID allocation\")\n\t\t}\n\t\treturn nil\n\t}\n\n\tdata := make([]ts.TimeSeriesData, 0, mr.mu.lastDataCount)\n\n\t// Record time series from node-level registries.\n\tnow := mr.mu.clock.PhysicalNow()\n\trecorder := registryRecorder{\n\t\tregistry: mr.nodeRegistry,\n\t\tformat: nodeTimeSeriesPrefix,\n\t\tsource: strconv.FormatInt(int64(mr.mu.nodeID), 10),\n\t\ttimestampNanos: now,\n\t}\n\trecorder.record(&data)\n\n\t// Record time series from store-level registries.\n\tfor storeID, r := range mr.mu.storeRegistries {\n\t\tstoreRecorder := registryRecorder{\n\t\t\tregistry: r,\n\t\t\tformat: storeTimeSeriesPrefix,\n\t\t\tsource: strconv.FormatInt(int64(storeID), 10),\n\t\t\ttimestampNanos: now,\n\t\t}\n\t\tstoreRecorder.record(&data)\n\t}\n\tmr.mu.lastDataCount = len(data)\n\treturn data\n}", "func getTimestamp() uint64 {\n\treturn uint64(time.Since(Epoch).Nanoseconds() / 1e6)\n}", "func (t TsTimestampPoint) Timestamp() time.Time {\n\treturn t.timestamp\n}", "func NewTimestamp(v time.Time) *Timestamp {\n\treturn ((*Timestamp)(nil)).Load(v)\n}", "func (r *Response) Timestamp() time.Time {\n\t// if r.TimestempNumber != 0 {\n\treturn time.Unix(r.TimestempNumber/1000, 0)\n\t// }\n\n}", "func (b *Blueprint) Timestamp(column string, precision int) *ColumnDefinition {\n\treturn b.addColumn(\"timestamp\", column, &ColumnOptions{\n\t\tPrecision: precision,\n\t})\n}", "func templateFunctionSnippetArray(entry *registry.Entry) func(name string, parameters []interface{}) ([]interface{}, error) {\n\treturn func(name string, parameters []interface{}) ([]interface{}, error) {\n\t\tglog.V(log.LevelDebug).Infof(\"snippetArray: values '%v'\", parameters)\n\n\t\ttemplate, err := getTemplate(name)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tresult := make([]interface{}, len(parameters))\n\n\t\tfor i, parameter := range parameters {\n\t\t\trendered, err := renderTemplate(template, entry, parameter)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tvar value interface{}\n\n\t\t\tif err := json.Unmarshal(rendered.Template.Raw, &value); err != nil {\n\t\t\t\treturn nil, errors.NewConfigurationError(\"template not JSON formatted: %v\", err)\n\t\t\t}\n\n\t\t\tglog.V(log.LevelDebug).Infof(\"snippetArray: element '%v'\", value)\n\n\t\t\tresult[i] = value\n\t\t}\n\n\t\tglog.V(log.LevelDebug).Infof(\"snippetArray: result '%v'\", result)\n\n\t\treturn result, nil\n\t}\n}", "func CreateArray(m map[string]struct{}) []string {\n\tarray := []string{}\n\tfor k := range m {\n\t\tarray = append(array, k)\n\t}\n\treturn array\n}", "func GetTimestamp(rxInfo []*gw.UplinkRXInfo) time.Time {\n\tfor i := range rxInfo {\n\t\tif rxInfo[i].Time != nil {\n\t\t\tt, err := ptypes.Timestamp(rxInfo[i].Time)\n\t\t\tif err == nil {\n\t\t\t\treturn t\n\t\t\t}\n\t\t}\n\t}\n\n\treturn time.Now()\n}", "func NewArray(x int64) *Array {\n\treturn &Array{big.NewInt(x)}\n}", "func (n *NodeDataArrayTimestamp) OnMetadata() (datalayer.Result, *datalayer.Variant) {\n\tm := datalayer.NewMetaDataBuilder(datalayer.AllowedOperationRead, \"array-of-timestamp variable\", \"array-of-timestamp_variable_url\")\n\tm.Unit(\"ns\").DisplayName(\"array-of-timestamp\").NodeClass(fbs.NodeClassVariable)\n\tm.AddReference(datalayer.ReferenceTypeRead, typeaddressarraytimestamp)\n\tv := m.Build()\n\treturn datalayer.ResultOk, v\n}", "func (_BaseLibrary *BaseLibraryCaller) VersionTimestamp(opts *bind.CallOpts, arg0 *big.Int) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _BaseLibrary.contract.Call(opts, &out, \"versionTimestamp\", arg0)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (ms DoubleDataPoint) SetTimestamp(v TimestampUnixNano) {\n\t(*ms.orig).TimeUnixNano = uint64(v)\n}", "func (t UnixTimestamp) MarshalJSON() ([]byte, error) {\n\treturn []byte(fmt.Sprintf(\"\\\"%d\\\"\", time.Time(t).Unix())), nil\n}", "func generaTimeStampDateDateTime() string {\n\tnow := time.Now()\n\treturn now.String()[0:17]\n}", "func (t StTimestamp) MarshalJSON() ([]byte, error) {\n\treturn []byte(fmt.Sprintf(`\"%s\"`, t.Format(\"2006-01-02 15:04:05\"))), nil\n}", "func NewTimestampRange(cfg baker.FilterParams) (baker.Filter, error) {\n\tdcfg := cfg.DecodedConfig.(*TimestampRangeConfig)\n\n\tfidx, ok := cfg.FieldByName(dcfg.Field)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unknown field %q\", dcfg.Field)\n\t}\n\n\tf := &TimestampRange{\n\t\tfidx: fidx,\n\t}\n\tif err := f.setTimes(dcfg.StartDatetime, dcfg.EndDatetime); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn f, nil\n}", "func Timestamp(ts time.Time) func(Call) error {\n\treturn func(o Call) error {\n\t\tm, ok := o.(*Mutate)\n\t\tif !ok {\n\t\t\treturn errors.New(\"'Timestamp' option can only be used with mutation queries\")\n\t\t}\n\t\tm.timestamp = uint64(ts.UnixNano() / 1e6)\n\t\treturn nil\n\t}\n}" ]
[ "0.57288086", "0.56269246", "0.54959416", "0.54605746", "0.53964067", "0.5373701", "0.51312923", "0.51274085", "0.5120402", "0.5048022", "0.5006886", "0.4996967", "0.4996967", "0.49909705", "0.4914925", "0.48994032", "0.4887998", "0.48787725", "0.4842352", "0.48110104", "0.48072147", "0.4806696", "0.48026985", "0.47856778", "0.47825894", "0.47719327", "0.47596437", "0.47541282", "0.4752301", "0.475093", "0.47466663", "0.47454768", "0.47288966", "0.47280633", "0.4719873", "0.4719203", "0.47115177", "0.47011152", "0.46974427", "0.4687448", "0.46829003", "0.46707034", "0.46685457", "0.46663865", "0.46594477", "0.46568674", "0.465449", "0.465194", "0.46386158", "0.46386158", "0.46255255", "0.46255255", "0.4625173", "0.46184278", "0.46044838", "0.4602869", "0.45989093", "0.4559175", "0.45532897", "0.45508236", "0.45453155", "0.45309752", "0.4528635", "0.45227873", "0.45122668", "0.45119107", "0.4503314", "0.45011944", "0.44975215", "0.44880754", "0.44880632", "0.4486552", "0.44820502", "0.44811052", "0.4474101", "0.447241", "0.44714686", "0.44646746", "0.44462636", "0.4442707", "0.44320896", "0.4431162", "0.4430208", "0.44261962", "0.44251359", "0.441908", "0.44061762", "0.44058323", "0.4386838", "0.43784782", "0.4371742", "0.4362376", "0.4361777", "0.43608156", "0.43559322", "0.43531534", "0.43470272", "0.43436417", "0.43408707", "0.4339809" ]
0.80039763
0
whenAll wrapps multiple dependencies in a single dependency the result is completed once any dependency completes with an error or once all dependencies ran to completion without error
когда все wrapps несколько зависимостей в одну зависимость, результат завершается, как только любая зависимость завершается с ошибкой или как только все зависимости завершаются без ошибок
func whenAll(dependencies []dependency) dependency { completionSource := &completionSource{ done: make(chan struct{}), } go func() { defer close(completionSource.done) cases := make([]reflect.SelectCase, len(dependencies)) for ix, dependency := range dependencies { cases[ix] = reflect.SelectCase{ Chan: reflect.ValueOf(dependency.Done()), Dir: reflect.SelectRecv, } } for len(dependencies) > 0 { ix, _, _ := reflect.Select(cases) if err := dependencies[ix].Err(); err != nil { completionSource.err = err return } cases = append(cases[:ix], cases[ix+1:]...) dependencies = append(dependencies[:ix], dependencies[ix+1:]...) } }() return completionSource }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *manager) BuildAll(options BuildOptions) error {\n\tif m.config == nil || m.config.Dependencies == nil || len(m.config.Dependencies) == 0 {\n\t\treturn nil\n\t}\n\n\t// Resolve all dependencies\n\tdependencies, err := m.resolver.Resolve(options.UpdateDependencies)\n\tif err != nil {\n\t\tif _, ok := err.(*cyclicError); ok {\n\t\t\treturn errors.Errorf(\"%v.\\n To allow cyclic dependencies run with the '%s' flag\", err, ansi.Color(\"--allow-cyclic\", \"white+b\"))\n\t\t}\n\n\t\treturn err\n\t}\n\n\tdefer m.log.StopWait()\n\n\tif options.Verbose == false {\n\t\tm.log.Infof(\"To display the complete dependency build run with the '--verbose-dependencies' flag\")\n\t}\n\n\t// Deploy all dependencies\n\tfor i := 0; i < len(dependencies); i++ {\n\t\tvar (\n\t\t\tdependency = dependencies[i]\n\t\t\tbuff = &bytes.Buffer{}\n\t\t\tdependencyLogger = m.log\n\t\t)\n\n\t\t// If not verbose log to a stream\n\t\tif options.Verbose == false {\n\t\t\tm.log.StartWait(fmt.Sprintf(\"Building dependency %d of %d: %s\", i+1, len(dependencies), dependency.ID))\n\t\t\tdependencyLogger = log.NewStreamLogger(buff, logrus.InfoLevel)\n\t\t} else {\n\t\t\tm.log.Infof(fmt.Sprintf(\"Building dependency %d of %d: %s\", i+1, len(dependencies), dependency.ID))\n\t\t}\n\n\t\terr := dependency.Build(options.SkipPush, options.ForceDeployDependencies, options.ForceBuild, dependencyLogger)\n\t\tif err != nil {\n\t\t\treturn errors.Errorf(\"Error building dependency %s: %s %v\", dependency.ID, buff.String(), err)\n\t\t}\n\n\t\tm.log.Donef(\"Built dependency %s\", dependency.ID)\n\t}\n\n\tm.log.StopWait()\n\tm.log.Donef(\"Successfully built %d dependencies\", len(dependencies))\n\n\treturn nil\n}", "func BuildAll(config *latest.Config, cache *generated.Config, allowCyclic, updateDependencies, skipPush, forceDeployDependencies, forceBuild bool, logger log.Logger) error {\n\tif config == nil || config.Dependencies == nil || len(*config.Dependencies) == 0 {\n\t\treturn nil\n\t}\n\n\t// Create a new dependency resolver\n\tresolver, err := NewResolver(config, cache, allowCyclic, logger)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"new resolver\")\n\t}\n\n\t// Resolve all dependencies\n\tdependencies, err := resolver.Resolve(*config.Dependencies, updateDependencies)\n\tif err != nil {\n\t\tif _, ok := err.(*CyclicError); ok {\n\t\t\treturn fmt.Errorf(\"%v.\\n To allow cyclic dependencies run with the '%s' flag\", err, ansi.Color(\"--allow-cyclic\", \"white+b\"))\n\t\t}\n\n\t\treturn err\n\t}\n\n\tdefer logger.StopWait()\n\n\t// Deploy all dependencies\n\tfor i := 0; i < len(dependencies); i++ {\n\t\tdependency := dependencies[i]\n\n\t\tlogger.StartWait(fmt.Sprintf(\"Building dependency %d of %d: %s\", i+1, len(dependencies), dependency.ID))\n\t\tbuff := &bytes.Buffer{}\n\t\tstreamLog := log.NewStreamLogger(buff, logrus.InfoLevel)\n\n\t\terr := dependency.Build(skipPush, forceDeployDependencies, forceBuild, streamLog)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error building dependency %s: %s %v\", dependency.ID, buff.String(), err)\n\t\t}\n\n\t\t// Prettify path if its a path deployment\n\t\tif dependency.DependencyConfig.Source.Path != nil {\n\t\t\tlogger.Donef(\"Built dependency %s\", dependency.ID[len(filepath.Dir(dependency.ID))+1:])\n\t\t} else {\n\t\t\tlogger.Donef(\"Built dependency %s\", dependency.ID)\n\t\t}\n\t}\n\n\tlogger.StopWait()\n\tlogger.Donef(\"Successfully built %d dependencies\", len(dependencies))\n\n\treturn nil\n}", "func WhenAll(tasks ...Task) Task {\n\treturn Run(func() (interface{}, error) {\n\t\tif len(tasks) == 0 {\n\t\t\treturn nil, nil\n\t\t}\n\n\t\tvar waitGroup sync.WaitGroup\n\t\twaitGroup.Add(len(tasks))\n\t\tfor _, task := range tasks {\n\t\t\tgo func(task Task) {\n\t\t\t\tdefer waitGroup.Done()\n\t\t\t\t_, _ = task.Result()\n\t\t\t}(task)\n\t\t}\n\t\twaitGroup.Wait()\n\n\t\treturn nil, nil\n\t})\n}", "func (m *manager) DeployAll(options DeployOptions) error {\n\tif m.config == nil || m.config.Dependencies == nil || len(m.config.Dependencies) == 0 {\n\t\treturn nil\n\t}\n\n\t// Resolve all dependencies\n\tdependencies, err := m.resolver.Resolve(options.UpdateDependencies)\n\tif err != nil {\n\t\tif _, ok := err.(*cyclicError); ok {\n\t\t\treturn errors.Errorf(\"%v.\\n To allow cyclic dependencies run with the '%s' flag\", err, ansi.Color(\"--allow-cyclic\", \"white+b\"))\n\t\t}\n\n\t\treturn err\n\t}\n\n\tdefer m.log.StopWait()\n\n\tif options.Verbose == false {\n\t\tm.log.Infof(\"To display the complete dependency deployment run with the '--verbose-dependencies' flag\")\n\t}\n\n\t// Deploy all dependencies\n\tfor i := 0; i < len(dependencies); i++ {\n\t\tvar (\n\t\t\tdependency = dependencies[i]\n\t\t\tbuff = &bytes.Buffer{}\n\t\t\tdependencyLogger = m.log\n\t\t)\n\n\t\t// If not verbose log to a stream\n\t\tif options.Verbose == false {\n\t\t\tm.log.StartWait(fmt.Sprintf(\"Deploying dependency %d of %d: %s\", i+1, len(dependencies), dependency.ID))\n\t\t\tdependencyLogger = log.NewStreamLogger(buff, logrus.InfoLevel)\n\t\t} else {\n\t\t\tm.log.Infof(fmt.Sprintf(\"Deploying dependency %d of %d: %s\", i+1, len(dependencies), dependency.ID))\n\t\t}\n\n\t\terr := dependency.Deploy(m.client, options.SkipPush, options.ForceDeployDependencies, options.SkipBuild, options.ForceBuild, options.ForceDeploy, dependencyLogger)\n\t\tif err != nil {\n\t\t\treturn errors.Errorf(\"Error deploying dependency %s: %s %v\", dependency.ID, buff.String(), err)\n\t\t}\n\n\t\t// Prettify path if its a path deployment\n\t\tm.log.Donef(\"Deployed dependency %s\", dependency.ID)\n\t}\n\n\tm.log.StopWait()\n\tm.log.Donef(\"Successfully deployed %d dependencies\", len(dependencies))\n\n\treturn nil\n}", "func (p *promise) all(promises []Promise) Promise {\n\t// how many promises must complete?\n\tcount := int64(len(promises))\n\n\t// none? return success\n\tif count == 0 {\n\t\treturn resolved\n\t}\n\n\t// create a promise to bridge this promise and the 'all' promises\n\tresult := NewPromise()\n\n\tfor _, promise := range promises {\n\t\t// attach an always handler and based on the result do the right thing\n\t\tpromise.Always(func(p2 Controller) {\n\t\t\t// if the promise failed, then result is failed\n\t\t\tif p2.IsFailed() {\n\t\t\t\tresult.DeliverWithPromise(p2)\n\t\t\t} else {\n\t\t\t\t// once all promises complete successfully, result is successful\n\t\t\t\tif atomic.AddInt64(&count, -1) == 0 {\n\t\t\t\t\tresult.DeliverWithPromise(p2)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\t// early-out in case the promise got delivered synchronously\n\t\tif result.IsDelivered() {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn result\n}", "func WhenAny(tasks ...Task) Task {\n\treturn Run(func() (interface{}, error) {\n\t\tif len(tasks) == 0 {\n\t\t\treturn nil, nil\n\t\t}\n\n\t\tfinished := make(chan Task)\n\n\t\tvar waitGroup sync.WaitGroup\n\t\twaitGroup.Add(1)\n\n\t\t// perhaps add cancelation here to avoid blocking these unfinished go routines?\n\t\tfor _, task := range tasks {\n\t\t\tgo func(task Task, finished chan Task) {\n\t\t\t\tdefer waitGroup.Done()\n\t\t\t\t_, _ = task.Result()\n\t\t\t\tfinished <- task\n\t\t\t}(task, finished)\n\t\t}\n\t\twaitGroup.Wait()\n\t\treturn <-finished, nil\n\t})\n}", "func DeployAll(config *latest.Config, cache *generated.Config, allowCyclic, updateDependencies, skipPush, forceDeployDependencies, forceBuild, forceDeploy bool, logger log.Logger) error {\n\tif config == nil || config.Dependencies == nil || len(*config.Dependencies) == 0 {\n\t\treturn nil\n\t}\n\n\t// Create a new dependency resolver\n\tresolver, err := NewResolver(config, cache, allowCyclic, logger)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"new resolver\")\n\t}\n\n\t// Resolve all dependencies\n\tdependencies, err := resolver.Resolve(*config.Dependencies, updateDependencies)\n\tif err != nil {\n\t\tif _, ok := err.(*CyclicError); ok {\n\t\t\treturn fmt.Errorf(\"%v.\\n To allow cyclic dependencies run with the '%s' flag\", err, ansi.Color(\"--allow-cyclic\", \"white+b\"))\n\t\t}\n\n\t\treturn err\n\t}\n\n\tdefer logger.StopWait()\n\n\t// Deploy all dependencies\n\tfor i := 0; i < len(dependencies); i++ {\n\t\tdependency := dependencies[i]\n\n\t\tlogger.StartWait(fmt.Sprintf(\"Deploying dependency %d of %d: %s\", i+1, len(dependencies), dependency.ID))\n\t\tbuff := &bytes.Buffer{}\n\t\tstreamLog := log.NewStreamLogger(buff, logrus.InfoLevel)\n\n\t\terr := dependency.Deploy(skipPush, forceDeployDependencies, forceBuild, forceDeploy, streamLog)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error deploying dependency %s: %s %v\", dependency.ID, buff.String(), err)\n\t\t}\n\n\t\t// Prettify path if its a path deployment\n\t\tif dependency.DependencyConfig.Source.Path != nil {\n\t\t\tlogger.Donef(\"Deployed dependency %s\", dependency.ID[len(filepath.Dir(dependency.ID))+1:])\n\t\t} else {\n\t\t\tlogger.Donef(\"Deployed dependency %s\", dependency.ID)\n\t\t}\n\t}\n\n\tlogger.StopWait()\n\tlogger.Donef(\"Successfully deployed %d dependencies\", len(dependencies))\n\n\treturn nil\n}", "func WaitAll(tasks ...Task) {\n\tt := WhenAll(tasks...)\n\tt.Wait()\n}", "func (config *Config) FetchAllDependencies(force bool) error {\n\turls := []string{}\n\tfor url := range config.Dependencies {\n\t\turls = append(urls, url)\n\t}\n\tsort.Strings(urls)\n\n\ttitle := \"Checking dependencies\"\n\tif force {\n\t\ttitle = \"Updating dependencies\"\n\t}\n\n\treturn config.UI.InMeasuredFrame(title, func(ctx *gluey.Ctx, frame *gluey.Frame) error {\n\t\tgroup := ctx.NewSpinGroup()\n\t\tfor _, url := range urls {\n\t\t\tdepurl := url\n\t\t\tgroup.Go(depurl, func() error {\n\t\t\t\treturn config.addDep(depurl, force)\n\t\t\t})\n\t\t}\n\t\treturn config.UI.Debreif(group.Wait())\n\t})\n}", "func (Build) All() error {\n\tmg.Deps(Build.Nethealth, Build.Satellite, Build.Healthz)\n\n\treturn nil\n}", "func (p *promise) ThenAllf(factory func() []Promise) Promise {\n\treturn p.Then(p.all(factory()))\n}", "func (p *promise) ThenAll(promises ...Promise) Promise {\n\treturn p.Then(p.all(promises))\n}", "func WaitAll(futures []*Future) {\r\n\tfor _,future:= range futures {\r\n\t\tfuture.Join()\r\n\t}\r\n\tfor _,future:= range futures {\r\n\t\tif !future.Success() && !future.Cancelled() {\r\n\t\t\terr:= future.Error()\r\n\t\t\tif err != nil {\r\n\t\t\t\tpanic(err)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}", "func (t Target) all() []string {\n\tall := t.initial\n\tfor _, name := range t.dependencies {\n\t\tall = append(all, name)\n\t}\n\tsort.Strings(all)\n\treturn all\n}", "func (m *manager) PurgeAll(verbose bool) error {\n\tif m.config == nil || m.config.Dependencies == nil || len(m.config.Dependencies) == 0 {\n\t\treturn nil\n\t}\n\n\t// Resolve all dependencies\n\tdependencies, err := m.resolver.Resolve(false)\n\tif err != nil {\n\t\tif _, ok := err.(*cyclicError); ok {\n\t\t\treturn errors.Errorf(\"%v.\\n To allow cyclic dependencies run with the '%s' flag\", err, ansi.Color(\"--allow-cyclic\", \"white+b\"))\n\t\t}\n\n\t\treturn errors.Wrap(err, \"resolve dependencies\")\n\t}\n\n\tdefer m.log.StopWait()\n\n\tif verbose == false {\n\t\tm.log.Infof(\"To display the complete dependency deletion run with the '--verbose-dependencies' flag\")\n\t}\n\n\t// Purge all dependencies\n\tfor i := len(dependencies) - 1; i >= 0; i-- {\n\t\tvar (\n\t\t\tdependency = dependencies[i]\n\t\t\tbuff = &bytes.Buffer{}\n\t\t\tdependencyLogger = m.log\n\t\t)\n\n\t\t// If not verbose log to a stream\n\t\tif verbose == false {\n\t\t\tm.log.StartWait(fmt.Sprintf(\"Purging %d dependencies\", i+1))\n\t\t\tdependencyLogger = log.NewStreamLogger(buff, logrus.InfoLevel)\n\t\t}\n\n\t\terr := dependency.Purge(m.client, dependencyLogger)\n\t\tif err != nil {\n\t\t\treturn errors.Errorf(\"Error deploying dependency %s: %s %v\", dependency.ID, buff.String(), err)\n\t\t}\n\n\t\tm.log.Donef(\"Purged dependency %s\", dependency.ID)\n\t}\n\n\tm.log.StopWait()\n\tm.log.Donef(\"Successfully purged %d dependencies\", len(dependencies))\n\n\treturn nil\n}", "func (m *manager) UpdateAll() error {\n\tif m.config == nil || m.config.Dependencies == nil || len(m.config.Dependencies) == 0 {\n\t\treturn nil\n\t}\n\n\tm.log.StartWait(\"Update dependencies\")\n\tdefer m.log.StopWait()\n\n\t// Resolve all dependencies\n\t_, err := m.resolver.Resolve(true)\n\tif err != nil {\n\t\tif _, ok := err.(*cyclicError); ok {\n\t\t\treturn errors.Errorf(\"%v.\\n To allow cyclic dependencies run with the '%s' flag\", err, ansi.Color(\"--allow-cyclic\", \"white+b\"))\n\t\t}\n\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func DockerBuildAll(repository string) {\n\tvar fns []interface{}\n\tfor _, module := range []ModuleName{SCALER, OPERATOR, INTERCEPTOR} {\n\t\tfns = append(fns, mg.F(DockerBuild, repository, (string)(module)))\n\t}\n\tmg.Deps(fns...)\n}", "func All(promises ...*Promise) *Promise {\n\tif len(promises) == 0 {\n\t\treturn New(empty)\n\t}\n\tp := &Promise{\n\t\tcond: sync.Cond{L: &sync.Mutex{}},\n\t\tt: allCall,\n\t}\n\n\t// Extract the type\n\tp.resultType = []reflect.Type{}\n\tfor _, prior := range promises {\n\t\tp.resultType = append(p.resultType, prior.resultType...)\n\t}\n\n\tp.counter = int64(len(promises))\n\n\tfor i := range promises {\n\t\tgo p.run(reflect.Value{}, nil, promises, i, nil)\n\t}\n\treturn p\n}", "func (s YieldingWaitStrategy) NotifyAll() {\n}", "func installAllDependencies(mypackage Package, wg *sync.WaitGroup) {\n\n // TODO: need to check if the dependency is already downloaded\n // TODO: what if one of the dependency is removed from the gopackage.json\n\n // read the gopackage.json's dependencies section\n for k,_ := range mypackage.Dependencies {\n wg.Add(1)\n fmt.Printf(\"Dependency = %s\\n\", k)\n go func(packageName string) {\n fetch(packageName)\n wg.Done()\n }(k)\n }\n}", "func ApplyAll(manifests name.ManifestMap, version pkgversion.Version, opts *kubectlcmd.Options) (CompositeOutput, error) {\n\tlog.Infof(\"Preparing manifests for these components:\")\n\tfor c := range manifests {\n\t\tlog.Infof(\"- %s\", c)\n\t}\n\tlog.Infof(\"Component dependencies tree: \\n%s\", installTreeString())\n\tif err := InitK8SRestClient(opts.Kubeconfig, opts.Context); err != nil {\n\t\treturn nil, err\n\t}\n\treturn applyRecursive(manifests, version, opts)\n}", "func onePackageCheckerRuner(command string, args []string, deps []string, errCh chan<- checkerErr, done func()) {\n\tvar wg sync.WaitGroup\n\twg.Add(len(deps))\n\tfor _, dep := range deps {\n\t\trate <- struct{}{}\n\t\tgo func(dep string) {\n\t\t\tdefer func() {\n\t\t\t\t<-rate\n\t\t\t\twg.Done()\n\t\t\t}()\n\t\t\tmultiCheckerRuner(command, append(args, dep), errCh)\n\t\t}(dep)\n\t}\n\twg.Wait()\n\tdone()\n}", "func JoinAll(futures []*Future) {\r\n\tfor _,future:= range futures {\r\n\t\tfuture.Join()\r\n\t}\r\n}", "func (aio *AsyncIO) waitAll() {\n\taio.trigger <- struct{}{}\n\t<-aio.trigger\n}", "func (p *promise) any(promises []Promise) Promise {\n\t// if there are no any promises, then success\n\tif len(promises) == 0 {\n\t\treturn resolved\n\t}\n\n\t// create a bridge promise between this promise and the any promises\n\tresult := NewPromise()\n\n\tfor _, promise := range promises {\n\t\t// add an always handler for each promise\n\t\tpromise.Always(func(p2 Controller) {\n\t\t\t// deliver result based on result of promise. For Any, we only need\n\t\t\t// one promise to deliver, not all of them (see all([]Promise))\n\t\t\tresult.DeliverWithPromise(p2)\n\t\t})\n\n\t\t// early-out in case the promise got delivered synchronously\n\t\tif result.IsDelivered() {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn result\n}", "func PurgeAll(config *latest.Config, cache *generated.Config, allowCyclic bool, logger log.Logger) error {\n\tif config == nil || config.Dependencies == nil || len(*config.Dependencies) == 0 {\n\t\treturn nil\n\t}\n\n\t// Create a new dependency resolver\n\tresolver, err := NewResolver(config, cache, allowCyclic, logger)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Resolve all dependencies\n\tdependencies, err := resolver.Resolve(*config.Dependencies, false)\n\tif err != nil {\n\t\tif _, ok := err.(*CyclicError); ok {\n\t\t\treturn fmt.Errorf(\"%v.\\n To allow cyclic dependencies run with the '%s' flag\", err, ansi.Color(\"--allow-cyclic\", \"white+b\"))\n\t\t}\n\n\t\treturn errors.Wrap(err, \"resolve dependencies\")\n\t}\n\n\tdefer logger.StopWait()\n\n\t// Purge all dependencies\n\tfor i := len(dependencies) - 1; i >= 0; i-- {\n\t\tlogger.StartWait(fmt.Sprintf(\"Purging %d dependencies\", i+1))\n\t\tdependency := dependencies[i]\n\n\t\tbuff := &bytes.Buffer{}\n\t\tstreamLog := log.NewStreamLogger(buff, logrus.InfoLevel)\n\n\t\terr := dependency.Purge(streamLog)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error deploying dependency %s: %s %v\", dependency.ID, buff.String(), err)\n\t\t}\n\n\t\t// Prettify path if its a path deployment\n\t\tif dependency.DependencyConfig.Source.Path != nil {\n\t\t\tlogger.Donef(\"Purged dependency %s\", dependency.ID[len(filepath.Dir(dependency.ID)):])\n\t\t} else {\n\t\t\tlogger.Donef(\"Purged dependency %s\", dependency.ID)\n\t\t}\n\t}\n\n\tlogger.StopWait()\n\tlogger.Donef(\"Successfully purged %d dependencies\", len(dependencies))\n\n\treturn nil\n}", "func (p *promise) ThenAny(promises ...Promise) Promise {\n\treturn p.Then(p.any(promises))\n}", "func execActions(actions []*action) {\n\tvar wg sync.WaitGroup\n\tfor _, act := range actions {\n\t\tact := act\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tact.once.Do(func() {\n\t\t\t\texecActions(act.hdeps) // analyze \"horizontal\" dependencies\n\t\t\t\tact.result, act.summary, act.err = act.exec()\n\t\t\t\tif act.err != nil {\n\t\t\t\t\tact.summary = &actionSummary{Err: act.err.Error()}\n\t\t\t\t\t// TODO(adonovan): suppress logging. But\n\t\t\t\t\t// shouldn't the root error's causal chain\n\t\t\t\t\t// include this information?\n\t\t\t\t\tif false { // debugging\n\t\t\t\t\t\tlog.Printf(\"act.exec(%v) failed: %v\", act, act.err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t\tif act.summary == nil {\n\t\t\t\tpanic(\"nil action.summary (#60551)\")\n\t\t\t}\n\t\t}()\n\t}\n\twg.Wait()\n}", "func UpdateAll(config *latest.Config, cache *generated.Config, allowCyclic bool, log log.Logger) error {\n\tif config == nil || config.Dependencies == nil || len(*config.Dependencies) == 0 {\n\t\treturn nil\n\t}\n\n\tlog.StartWait(\"Update dependencies\")\n\tdefer log.StopWait()\n\n\t// Create a new dependency resolver\n\tresolver, err := NewResolver(config, cache, allowCyclic, log)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"new resolver\")\n\t}\n\n\t// Resolve all dependencies\n\t_, err = resolver.Resolve(*config.Dependencies, true)\n\tif err != nil {\n\t\tif _, ok := err.(*CyclicError); ok {\n\t\t\treturn fmt.Errorf(\"%v.\\n To allow cyclic dependencies run with the '%s' flag\", err, ansi.Color(\"--allow-cyclic\", \"white+b\"))\n\t\t}\n\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (syncObj *Sync)JoinAllRoutines() {\n syncObj.appWaitGroups.Wait()\n\n}", "func TestDoAll(t *testing.T) {\n\tassert := audit.NewTestingAssertion(t, true)\n\tmsgs := []string{}\n\tf := func(err error) {\n\t\tmsgs = append(msgs, err.Error())\n\t}\n\n\t// Test it on annotated errors.\n\tmessages := errors.Messages{\n\t\t1: \"foo\",\n\t\t2: \"bar\",\n\t\t3: \"baz\",\n\t\t4: \"yadda\",\n\t}\n\terrX := testError(\"xxx\")\n\terrA := errors.Annotate(errX, 1, messages)\n\terrB := errors.Annotate(errA, 2, messages)\n\terrC := errors.Annotate(errB, 3, messages)\n\terrD := errors.Annotate(errC, 4, messages)\n\n\terrors.DoAll(errD, f)\n\n\tassert.Length(msgs, 5)\n\n\t// Test it on collected errors.\n\tmsgs = []string{}\n\terrA = testError(\"foo\")\n\terrB = testError(\"bar\")\n\terrC = testError(\"baz\")\n\terrD = testError(\"yadda\")\n\tcerr := errors.Collect(errA, errB, errC, errD)\n\n\terrors.DoAll(cerr, f)\n\n\tassert.Equal(msgs, []string{\"foo\", \"bar\", \"baz\", \"yadda\"})\n\n\t// Test it on a single error.\n\tmsgs = []string{}\n\terrA = testError(\"foo\")\n\n\terrors.DoAll(errA, f)\n\n\tassert.Equal(msgs, []string{\"foo\"})\n}", "func (p *promise) ThenAllWithResult(factory ...FactoryWithResult) Promise {\n\tresult := NewPromise()\n\n\tp.Always(func(p2 Controller) {\n\t\tif p2.IsSuccess() {\n\t\t\t// cache the result of the promise\n\t\t\tpresult := p2.Result()\n\n\t\t\t// invoke each factory with the result and get its promise\n\t\t\tvar promises []Promise\n\t\t\tfor _, f := range factory {\n\t\t\t\tpromises = append(promises, f(presult))\n\t\t\t}\n\n\t\t\t// wait for all the promises to be delivered\n\t\t\tresult.DeliverWithPromise(p.all(promises).(Controller))\n\t\t} else {\n\t\t\tresult.DeliverWithPromise(p2)\n\t\t}\n\t})\n\n\treturn result\n}", "func buildAllReferencedResources(un unstructured.Unstructured, refResource *validation.ReferencedResources) error {\n\n\tvalueBytes, err := un.MarshalJSON()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tgvk := un.GroupVersionKind()\n\tswitch {\n\tcase gvk.Group == v1.GroupName && gvk.Kind == \"Service\":\n\t\tvar svc v1.Service\n\t\terr := unmarshal(valueBytes, &svc)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\trefResource.ServiceWithType = append(refResource.ServiceWithType, validation.ServiceWithType{\n\t\t\tService: &svc,\n\t\t})\n\n\tcase gvk.Group == \"networking.istio.io\" && gvk.Kind == \"VirtualService\":\n\t\trefResource.VirtualServices = append(refResource.VirtualServices, un)\n\n\tcase (gvk.Group == networkingv1.GroupName || gvk.Group == extensionsv1beta1.GroupName) && gvk.Kind == \"Ingress\":\n\t\tvar ing networkingv1.Ingress\n\t\tvar ingv1beta1 extensionsv1beta1.Ingress\n\t\tif gvk.Version == \"v1\" {\n\t\t\terr := unmarshal(valueBytes, &ing)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\trefResource.Ingresses = append(refResource.Ingresses, *ingressutil.NewIngress(&ing))\n\t\t} else if gvk.Version == \"v1beta1\" {\n\t\t\terr := unmarshal(valueBytes, &ingv1beta1)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\trefResource.Ingresses = append(refResource.Ingresses, *ingressutil.NewLegacyIngress(&ingv1beta1))\n\t\t}\n\n\t}\n\treturn nil\n}", "func All(promises ...*Promise) *Promise {\n\tpsLen := len(promises)\n\tif psLen == 0 {\n\t\treturn Resolve(make([]interface{}, 0))\n\t}\n\n\treturn New(func(resolve func(interface{}), reject func(error)) {\n\t\tresolutionsChan := make(chan []interface{}, psLen)\n\t\terrorChan := make(chan error, psLen)\n\n\t\tfor index, promise := range promises {\n\t\t\tfunc(i int) {\n\t\t\t\tpromise.Then(func(data interface{}) interface{} {\n\t\t\t\t\tresolutionsChan <- []interface{}{i, data}\n\t\t\t\t\treturn data\n\t\t\t\t}).Catch(func(err error) error {\n\t\t\t\t\terrorChan <- err\n\t\t\t\t\treturn err\n\t\t\t\t})\n\t\t\t}(index)\n\t\t}\n\n\t\tresolutions := make([]interface{}, psLen)\n\t\tfor x := 0; x < psLen; x++ {\n\t\t\tselect {\n\t\t\tcase resolution := <-resolutionsChan:\n\t\t\t\tresolutions[resolution[0].(int)] = resolution[1]\n\n\t\t\tcase err := <-errorChan:\n\t\t\t\treject(err)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tresolve(resolutions)\n\t})\n}", "func updateDeps(bld *build.File, errorOnUnresolvedImports bool, reports []*arpb.DependencyReport) error {\n\t// First, check *all* reports on whether they were successful, so that users\n\t// get the complete set of errors at once.\n\tvar errors []AnalysisFailureCause\n\tfor _, report := range reports {\n\t\tif !report.GetSuccessful() {\n\t\t\tfor _, fb := range report.GetFeedback() {\n\t\t\t\tmsg := fmt.Sprintf(\"dependency analysis failed for %s:\\n%s\",\n\t\t\t\t\treport.GetRule(), fb)\n\n\t\t\t\tm := bazelErrorRE.FindStringSubmatch(fb)\n\t\t\t\tif m == nil {\n\t\t\t\t\t// error message didn't contain file and line number, so just use the\n\t\t\t\t\t// path of the BUILD file that was analyzed\n\t\t\t\t\terrors = append(errors, AnalysisFailureCause{Message: msg, Path: bld.Path})\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tfile := m[1]\n\t\t\t\tline, err := strconv.Atoi(m[2])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\terrors = append(errors, AnalysisFailureCause{msg, file, line})\n\t\t\t}\n\t\t}\n\t}\n\tif len(errors) > 0 {\n\t\treturn &AnalysisFailedError{errors}\n\t}\n\n\tpkg := filepath.Dir(bld.Path)\n\tfor _, report := range reports {\n\t\tplatform.Infof(\"Applying report: %s\", report.String())\n\t\tfullTarget := report.GetRule()\n\t\ttargetName := fullTarget[strings.LastIndex(fullTarget, \":\")+1:]\n\t\tr := edit.FindRuleByName(bld, targetName)\n\t\tif r == nil {\n\t\t\treturn fmt.Errorf(\"could not find rule from report %v\", targetName)\n\t\t}\n\t\tfor _, md := range report.MissingDependencyGroup {\n\t\t\tfor _, d := range md.Dependency {\n\t\t\t\td = AbsoluteBazelTarget(bld, d)\n\t\t\t\tif d == fullTarget {\n\t\t\t\t\treturn &AnalysisFailedError{\n\t\t\t\t\t\t[]AnalysisFailureCause{\n\t\t\t\t\t\t\tAnalysisFailureCause{\n\t\t\t\t\t\t\t\tMessage: fmt.Sprintf(\"target %s depends on itself. \"+\n\t\t\t\t\t\t\t\t\t\"Maybe you have an incorrect `// from %s` comment, or need to split application \"+\n\t\t\t\t\t\t\t\t\t\"entry point (main.ts) and ng_module() rule?\", d, d),\n\t\t\t\t\t\t\t\tPath: bld.Path,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tplatform.Infof(\"Adding dependency on %s to %s\\n\", d, fullTarget)\n\t\t\t\taddDep(bld, r, d)\n\t\t\t}\n\t\t}\n\t\thadUnresolved := len(report.UnresolvedImport) > 0\n\t\tif hadUnresolved {\n\t\t\terrMsg := fmt.Sprintf(\"ERROR in %s: unresolved imports %s.\\nMaybe you are missing a \"+\n\t\t\t\t\"'// from ...'' comment, or the target BUILD files are incorrect?\\n%s\\n\",\n\t\t\t\tfullTarget, report.UnresolvedImport, strings.Join(report.GetFeedback(), \"\\n\"))\n\t\t\tif errorOnUnresolvedImports {\n\t\t\t\treturn fmt.Errorf(errMsg)\n\t\t\t}\n\t\t\tfmt.Fprintf(os.Stderr, errMsg)\n\t\t\tfmt.Fprintf(os.Stderr, \"Continuing.\\n\")\n\t\t}\n\t\tfor _, d := range report.UnnecessaryDependency {\n\t\t\tif hadUnresolved {\n\t\t\t\tfmt.Fprintf(os.Stderr, \"Keeping unnecessary dependency %s due to unresolved imports\\n\", d)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tplatform.Infof(\"Removing dependency on %s from %s\\n\", d, fullTarget)\n\t\t\tedit.ListAttributeDelete(r, \"deps\", d, pkg)\n\t\t}\n\t\tfor _, s := range report.MissingSourceFile {\n\t\t\tplatform.Infof(\"Removing missing source %s from %s\\n\", s, fullTarget)\n\t\t\tedit.ListAttributeDelete(r, \"srcs\", s, pkg)\n\t\t}\n\t}\n\treturn nil\n}", "func TestMultipleDefer(t *testing.T) {\n\tdefer t.Log(1)\n\tdefer t.Log(2)\n\tt.Log(3)\n}", "func buildDependencies(fdSet *dpb.FileDescriptorSet) {\n\t// Dependency to google/api/annotations.proto for gRPC-HTTP transcoding. Here a couple of problems arise:\n\t// 1. Problem: \tWe cannot call descriptor.ForMessage(&annotations.E_Http), which would be our\n\t//\t\t\t\trequired dependency. However, we can call descriptor.ForMessage(&http) and\n\t//\t\t\t\tthen construct the extension manually.\n\t// 2. Problem: \tThe name is set wrong.\n\t// 3. Problem: \tgoogle/api/annotations.proto has a dependency to google/protobuf/descriptor.proto.\n\thttp := annotations.Http{}\n\tfd, _ := descriptor.MessageDescriptorProto(&http)\n\n\textensionName := \"http\"\n\tn := \"google/api/annotations.proto\"\n\tl := dpb.FieldDescriptorProto_LABEL_OPTIONAL\n\tt := dpb.FieldDescriptorProto_TYPE_MESSAGE\n\ttName := \"google.api.HttpRule\"\n\textendee := \".google.protobuf.MethodOptions\"\n\n\thttpExtension := &dpb.FieldDescriptorProto{\n\t\tName: &extensionName,\n\t\tNumber: &annotations.E_Http.Field,\n\t\tLabel: &l,\n\t\tType: &t,\n\t\tTypeName: &tName,\n\t\tExtendee: &extendee,\n\t}\n\n\tfd.Extension = append(fd.Extension, httpExtension) // 1. Problem\n\tfd.Name = &n // 2. Problem\n\tfd.Dependency = append(fd.Dependency, \"google/protobuf/descriptor.proto\") //3.rd Problem\n\n\t// Build other required dependencies\n\te := empty.Empty{}\n\tfdp := dpb.DescriptorProto{}\n\tfd2, _ := descriptor.MessageDescriptorProto(&e)\n\tfd3, _ := descriptor.MessageDescriptorProto(&fdp)\n\tdependencies := []*dpb.FileDescriptorProto{fd, fd2, fd3}\n\n\t// According to the documentation of protoReflect.CreateFileDescriptorFromSet the file I want to print\n\t// needs to be at the end of the array. All other FileDescriptorProto are dependencies.\n\tfdSet.File = append(dependencies, fdSet.File...)\n}", "func (o *RecipeAdditive) doAfterSelectHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range recipeAdditiveAfterSelectHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func ExamplePromiseStruct_All() {\n\tstuff := Promise(func() int {\n\t\treturn 3\n\t}).\n\t\tAll(\n\t\t\tfunc(x int) (int, error) {\n\t\t\t\tfmt.Println(x)\n\t\t\t\ttime.Sleep(50 * time.Millisecond) //Guarantee Order\n\t\t\t\treturn x + 3, nil\n\t\t\t},\n\t\t\tfunc(x int) (int, error) {\n\t\t\t\tfmt.Println(x)\n\t\t\t\treturn x * x, nil\n\t\t\t})\n\tfmt.Println(stuff.Result[0])\n\tfmt.Println(stuff.Result[1])\n\t// Output:\n\t// 3\n\t// 3\n\t// 6\n\t// 9\n}", "func AwaitAll(\n\tctx context.Context,\n\ttimeout time.Duration,\n\tall ...Awaiter) []Response {\n\tctx, cancel := context.WithTimeout(ctx, timeout)\n\tdefer cancel()\n\tresults := make([]Response, 0)\n\tfor _, next := range all {\n\t\tres, err := next.Await(ctx, timeout)\n\t\tresults = append(results, Response{Result: res, Err: err})\n\t}\n\treturn results\n}", "func (s *Scheduler) resolveDependencies(j *gaia.Job, mw *managedWorkloads, executeScheduler chan *gaia.Job, done chan bool) {\n\tfor _, depJob := range j.DependsOn {\n\t\t// Check if this workload is already resolved\n\t\tvar resolved bool\n\t\tfor workload := range mw.Iter() {\n\t\t\tif workload.done && workload.job.ID == depJob.ID {\n\t\t\t\tresolved = true\n\t\t\t}\n\t\t}\n\n\t\t// Job has been resolved\n\t\tif resolved {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Resolve job\n\t\ts.resolveDependencies(depJob, mw, executeScheduler, done)\n\t}\n\n\t// Queue used to signal that the work should be finished soon.\n\t// We do not block here because this is just a pre-validation step.\n\tselect {\n\tcase _, ok := <-done:\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\tdefault:\n\t}\n\n\t// If we are here, then the job is resolved.\n\t// We have to check if the job still needs to be run\n\t// or if another goroutine has already started the execution.\n\trelatedWL := mw.GetByID(j.ID)\n\tif !relatedWL.started {\n\t\t// Job has not been executed yet.\n\t\t// Send workload to execute scheduler.\n\t\texecuteScheduler <- j\n\n\t\t// Wait until finished\n\t\t<-relatedWL.finishedSig\n\t} else if !relatedWL.done {\n\t\t// Job has been started but not finished.\n\t\t// Let us wait till finished.\n\t\t<-relatedWL.finishedSig\n\t}\n}", "func makeDeps(t BuildVariantTaskUnit, thisTask *task.Task, taskIds TaskIdTable) []task.Dependency {\n\tdependencySet := make(map[task.Dependency]bool)\n\tfor _, dep := range t.DependsOn {\n\t\tstatus := evergreen.TaskSucceeded\n\t\tif dep.Status != \"\" {\n\t\t\tstatus = dep.Status\n\t\t}\n\n\t\t// set unspecified fields to match thisTask\n\t\tif dep.Name == \"\" {\n\t\t\tdep.Name = thisTask.DisplayName\n\t\t}\n\t\tif dep.Variant == \"\" {\n\t\t\tdep.Variant = thisTask.BuildVariant\n\t\t}\n\n\t\tvar depIDs []string\n\t\tif dep.Variant == AllVariants && dep.Name == AllDependencies {\n\t\t\tdepIDs = taskIds.GetIdsForAllTasks()\n\t\t} else if dep.Variant == AllVariants {\n\t\t\tdepIDs = taskIds.GetIdsForTaskInAllVariants(dep.Name)\n\t\t} else if dep.Name == AllDependencies {\n\t\t\tdepIDs = taskIds.GetIdsForAllTasksInVariant(dep.Variant)\n\t\t} else {\n\t\t\t// don't add missing dependencies\n\t\t\t// patch_optional tasks aren't in the patch and will be missing from the table\n\t\t\tif id := taskIds.GetId(dep.Variant, dep.Name); id != \"\" {\n\t\t\t\tdepIDs = []string{id}\n\t\t\t}\n\t\t}\n\n\t\tfor _, id := range depIDs {\n\t\t\t// tasks don't depend on themselves\n\t\t\tif id == thisTask.Id {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdependencySet[task.Dependency{TaskId: id, Status: status}] = true\n\t\t}\n\t}\n\n\tdependencies := make([]task.Dependency, 0, len(dependencySet))\n\tfor dep := range dependencySet {\n\t\tdependencies = append(dependencies, dep)\n\t}\n\n\treturn dependencies\n}", "func All(functions ...TaskFunc) {\n\tFor(0, len(functions), func(i int) {\n\t\tfunctions[i]()\n\t})\n}", "func resolveDependencies(c *king.Config, bpp []*king.Package, fT bool) (epp, dpp []*king.Package,\n\ttpp []*king.Tarball, err error) {\n\tmpp := make(map[string]bool, len(bpp))\n\tepp = make([]*king.Package, 0, len(bpp))\n\n\tlog.Running(\"resolving dependencies\")\n\n\tfor _, p := range bpp {\n\t\tdd, err := p.RecursiveDependencies()\n\n\t\tif err != nil && !errors.Is(err, os.ErrNotExist) {\n\t\t\treturn nil, nil, nil, err\n\t\t}\n\n\t\tfor _, d := range dd {\n\t\t\tif mpp[d.Name] {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t_, err := king.NewPackage(c, &king.PackageOptions{\n\t\t\t\tName: d.Name,\n\t\t\t\tFrom: king.Database,\n\t\t\t})\n\n\t\t\tif errors.Is(err, king.ErrPackageNameNotFound) {\n\t\t\t\t//\n\t\t\t} else if err != nil {\n\t\t\t\treturn nil, nil, nil, err\n\t\t\t} else {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tp, err := king.NewPackage(c, &king.PackageOptions{\n\t\t\t\tName: d.Name,\n\t\t\t\tFrom: king.Repository,\n\t\t\t})\n\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, nil, err\n\t\t\t}\n\n\t\t\tt, err := p.Tarball()\n\n\t\t\tif fT || errors.Is(err, king.ErrTarballNotFound) {\n\t\t\t\tdpp = append(dpp, p)\n\t\t\t} else if err != nil {\n\t\t\t\treturn nil, nil, nil, err\n\t\t\t} else {\n\t\t\t\ttpp = append(tpp, t)\n\t\t\t}\n\n\t\t\tmpp[p.Name] = true\n\t\t}\n\n\t\tif !mpp[p.Name] {\n\t\t\tmpp[p.Name] = true\n\t\t\tepp = append(epp, p)\n\t\t}\n\t}\n\n\treturn epp, dpp, tpp, nil\n}", "func (bs *Builders) RunAll() {\n\tfor _, b := range *bs {\n\t\tb.Build()\n\t}\n}", "func (p BaseConfigLogLevel) Dependencies() []string {\n\treturn []string{\n\t\t\"Base/Config/Validate\", //This identifies this task as dependent on \"Base/Config/Validate\" and so the results from that task will be passed to this task. See the execute method to see how to interact with the results.\n\t}\n}", "func TestRunTargetDependency(t *testing.T) {\n\ttodo := context.TODO()\n\terrTest := errors.New(`test`)\n\tt.Run(`NoContextNoErr`, func(t *testing.T) {\n\t\td, _ := makeDependency(t1)\n\t\tt1runs = 0\n\t\terr := d.RunDependency(todo)\n\t\tif t1runs != 1 {\n\t\t\tt.Error(`expected function to be run`)\n\t\t\treturn\n\t\t}\n\t\tif err != nil {\n\t\t\tt.Errorf(`unexpected error: %v`, err)\n\t\t}\n\t\terr = d.RunDependency(todo)\n\t\tif t1runs != 1 {\n\t\t\tt.Error(`expected function to not run again`)\n\t\t\treturn\n\t\t}\n\t\tif err != nil {\n\t\t\tt.Errorf(`unexpected error on repeat: %v`, err)\n\t\t}\n\t})\n\tt.Run(`ContextNoErr`, func(t *testing.T) {\n\t\td, _ := makeDependency(t2)\n\t\tt2runs = 0\n\t\terr := d.RunDependency(todo)\n\t\tif t2runs != 1 {\n\t\t\tt.Error(`expected function to be run`)\n\t\t\treturn\n\t\t}\n\t\tif t2ctx != todo {\n\t\t\tt.Error(`expected function to be given context`)\n\t\t}\n\t\tif err != nil {\n\t\t\tt.Errorf(`unexpected error: %v`, err)\n\t\t}\n\t\terr = d.RunDependency(todo)\n\t\tif t2runs != 1 {\n\t\t\tt.Error(`expected function to not run again`)\n\t\t\treturn\n\t\t}\n\t\tif err != nil {\n\t\t\tt.Errorf(`unexpected error on repeat: %v`, err)\n\t\t}\n\t})\n\tt.Run(`NoContextErr`, func(t *testing.T) {\n\t\td, _ := makeDependency(t3)\n\t\tt3runs, t3err = 0, errTest\n\t\terr := d.RunDependency(todo)\n\t\tif t3runs != 1 {\n\t\t\tt.Error(`expected function to be run`)\n\t\t\treturn\n\t\t}\n\t\tswitch err {\n\t\tcase nil:\n\t\t\tt.Error(`internal error not relayed`)\n\t\tcase errTest:\n\t\tdefault:\n\t\t\tt.Errorf(`unexpected error: %v`, err)\n\t\t}\n\t\terr = d.RunDependency(todo)\n\t\tif t3runs != 1 {\n\t\t\tt.Error(`expected function to not run again`)\n\t\t\treturn\n\t\t}\n\t\tif err != errTest {\n\t\t\tt.Errorf(`expected error on repeat`)\n\t\t}\n\t})\n\tt.Run(`ContextErr`, func(t *testing.T) {\n\t\td, _ := makeDependency(t4)\n\t\tt4runs, t4err = 0, errTest\n\t\terr := d.RunDependency(todo)\n\t\tif t4runs != 1 {\n\t\t\tt.Error(`expected function to be run`)\n\t\t\treturn\n\t\t}\n\t\tif t4ctx != todo {\n\t\t\tt.Error(`expected function to be given context`)\n\t\t}\n\t\tswitch err {\n\t\tcase nil:\n\t\t\tt.Error(`internal error not relayed`)\n\t\tcase errTest:\n\t\tdefault:\n\t\t\tt.Errorf(`unexpected error: %v`, err)\n\t\t}\n\t\terr = d.RunDependency(todo)\n\t\tif t4runs != 1 {\n\t\t\tt.Error(`expected function to not run again`)\n\t\t\treturn\n\t\t}\n\t\tif err != errTest {\n\t\t\tt.Errorf(`expected error on repeat`)\n\t\t}\n\t})\n}", "func (s SleepWaitStrategy) NotifyAll() {\n}", "func (g *GardenerAPI) RunAll(ctx context.Context, rSrc RunnableSource, jt *tracker.JobWithTarget) (*errgroup.Group, error) {\n\teg := &errgroup.Group{}\n\tcount := 0\n\tjob := jt.Job\n\tfor {\n\t\trun, err := rSrc.Next(ctx)\n\t\tif err != nil {\n\t\t\tif err == iterator.Done {\n\t\t\t\tdebug.Printf(\"Dispatched total of %d archives for %s\\n\", count, job.String())\n\t\t\t\treturn eg, nil\n\t\t\t} else {\n\t\t\t\tmetrics.BackendFailureCount.WithLabelValues(\n\t\t\t\t\tjob.Datatype, \"rSrc.Next\").Inc()\n\t\t\t\tlog.Println(err, \"processing\", job.String())\n\t\t\t\treturn eg, err\n\t\t\t}\n\t\t}\n\n\t\tif err := g.jobs.Heartbeat(ctx, jt.ID); err != nil {\n\t\t\tlog.Println(err, \"on heartbeat for\", job.Path())\n\t\t}\n\n\t\tdebug.Println(\"Starting func\")\n\n\t\tf := func() (err error) {\n\t\t\tmetrics.ActiveTasks.WithLabelValues(rSrc.Label()).Inc()\n\t\t\tdefer metrics.ActiveTasks.WithLabelValues(rSrc.Label()).Dec()\n\n\t\t\t// Capture any panic and convert it to an error.\n\t\t\tdefer func(tag string) {\n\t\t\t\tif err2 := metrics.PanicToErr(err, recover(), \"Runall.f: \"+tag); err2 != nil {\n\t\t\t\t\terr = err2\n\t\t\t\t}\n\t\t\t}(run.Info())\n\n\t\t\terr = run.Run(ctx)\n\t\t\tif err == nil {\n\t\t\t\tif err := g.jobs.Update(ctx, jt.ID, tracker.Parsing, run.Info()); err != nil {\n\t\t\t\t\tlog.Println(err, \"on update for\", job.Path())\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tcount++\n\t\teg.Go(f)\n\t}\n}", "func (builder *Builder) BuildAll() error {\n\tif err := builder.BuildLinux(); err != nil {\n\t\treturn fmt.Errorf(\"could not build linux: %v\", err)\n\t}\n\n\tif err := builder.BuildVulnKo(); err != nil {\n\t\treturn fmt.Errorf(\"could not build vuln-ko: %v\", err)\n\t}\n\n\tif err := builder.BuildGlibc(); err != nil {\n\t\treturn fmt.Errorf(\"could not build glibc: %v\", err)\n\t}\n\n\tif err := builder.BuildBusyBox(); err != nil {\n\t\treturn fmt.Errorf(\"could not build busybox: %v\", err)\n\t}\n\n\treturn nil\n}", "func WhenAll(rules ...Rule) Rule {\n\tif len(rules) == 0 {\n\t\treturn None\n\t}\n\n\tif len(rules) == 1 {\n\t\treturn rules[0]\n\t}\n\n\treturn RuleFunc(func(src net.Addr) bool {\n\t\tfor _, rule := range rules {\n\t\t\tif !rule.Match(src) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\t})\n}", "func (eh *ElevatorHub) checkForAndResolveMultipleMaster(finishAllOrders bool) {\n\tif finishAllOrders {\n\t\tfmt.Println(\"\\n\\t\\x1b[31;1m::: Finish All Orders In Progress :::\\x1b[0m\\n\")\n\n\t\teh.currNetwork.Statuses[eh.currNetwork.Id] = *eh.currElevstat\n\t\tfor order, completed := range eh.currNetwork.Orders {\n\t\t\tif completed {\n\t\t\t\tdelete(eh.currNetwork.Orders, order)\n\t\t\t}\n\t\t}\n\t\tfor order, completed := range eh.newOrders {\n\t\t\tif completed {\n\t\t\t\tdelete(eh.currNetwork.Orders, order)\n\t\t\t}\n\t\t}\n\t\tsetActiveLights(eh.currNetwork)\n\t\tif len(eh.currNetwork.Orders) == 0 {\n\t\t\tfmt.Println(\"\\t\\x1b[31;1m::: DONE FINISH ALL ORDERS :::\\x1b[0m\")\n\t\t\tfmt.Println(\"\\t\\x1b[31;1m::: RESTARTING :::\\x1b[0m\\n\\n\")\n\t\t\tos.Exit(0)\n\t\t}\n\t\tfmt.Println()\n\t\teh.newNetwork <- *eh.currNetwork\n\t\ttime.Sleep(200 * time.Millisecond)\n\t}\n}", "func All(project, label string, fullTime bool) (ok bool) {\n\tif ok = TODO(project, label, fullTime); !ok {\n\t\treturn\n\t}\n\tfmt.Printf(\"\\n\\033[100m BACKLOG \\033[49m\\n\\n\")\n\tif ok = Backlog(project, label, fullTime); !ok {\n\t\treturn\n\t}\n\tfmt.Printf(\"\\n\\033[100m COMPLETED \\033[49m\\n\\n\")\n\tok = Completed(project, label, fullTime)\n\treturn\n}", "func DockerPushAll(repository string) {\n\tvar fns []interface{}\n\tfor _, module := range []ModuleName{SCALER, OPERATOR, INTERCEPTOR} {\n\t\tfns = append(fns, mg.F(DockerPush, repository, (string)(module)))\n\t}\n\tmg.Deps(fns...)\n}", "func allDepsProcessed(task task.Task, unprocessedTasks map[string]task.Task) bool {\n\tfor _, dep := range task.DependsOn {\n\t\tif _, unprocessed := unprocessedTasks[dep.TaskId]; unprocessed {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func resolveAll(ctx context.Context, resolvers []Resolver, classNames []ClassName, depsOfRuleToFix map[bazel.Label]map[bazel.Label]bool) (map[ClassName][]*bazel.Rule, []ClassName, map[Resolver]error) {\n\tresultResolved := make(map[ClassName][]*bazel.Rule)\n\tresultUnresolved := make(map[ClassName]bool)\n\tresultErrors := make(map[Resolver]error)\n\tfor _, c := range classNames {\n\t\tresultUnresolved[c] = true\n\t}\n\tfor _, res := range resolvers {\n\t\tif len(resultUnresolved) == 0 {\n\t\t\tbreak\n\t\t}\n\t\tvar classNames []ClassName\n\t\tfor cls := range resultUnresolved {\n\t\t\tclassNames = append(classNames, cls)\n\t\t}\n\n\t\ttctx, endSpan := compat.NewLocalSpan(ctx, \"Jade: Resolve (\"+res.Name())\n\t\tstopwatch := time.Now()\n\t\tresolved, err := res.Resolve(tctx, classNames, depsOfRuleToFix)\n\t\tlog.Printf(\"Resolved %4d/%-4d classes using %20s (%dms)\", len(resolved), len(classNames), res.Name(), int64(time.Now().Sub(stopwatch)/time.Millisecond))\n\t\tendSpan()\n\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error when resolving using %s: %v\", res.Name(), err)\n\t\t\tresultErrors[res] = err\n\t\t}\n\t\tfor cls, rules := range resolved {\n\t\t\tfor _, r := range rules {\n\t\t\t\tresultResolved[cls] = append(resultResolved[cls], r)\n\t\t\t}\n\t\t\tdelete(resultUnresolved, cls)\n\t\t}\n\t}\n\n\tvar unresolvedSlice []ClassName\n\tfor cls := range resultUnresolved {\n\t\tunresolvedSlice = append(unresolvedSlice, cls)\n\t}\n\tsort.Slice(unresolvedSlice, func(i, j int) bool { return string(unresolvedSlice[i]) < string(unresolvedSlice[j]) })\n\treturn resultResolved, unresolvedSlice, resultErrors\n}", "func AllSettled(promises ...*Promise) *Promise {\n\tpsLen := len(promises)\n\tif psLen == 0 {\n\t\treturn Resolve(make([]interface{}, 0))\n\t}\n\n\treturn New(func(resolve func(interface{}), reject func(error)) {\n\t\tresolutionsChan := make(chan []interface{}, psLen)\n\n\t\tfor index, promise := range promises {\n\t\t\tfunc(i int) {\n\t\t\t\tpromise.Then(func(data interface{}) interface{} {\n\t\t\t\t\tresolutionsChan <- []interface{}{i, data}\n\t\t\t\t\treturn data\n\t\t\t\t}).Catch(func(err error) error {\n\t\t\t\t\tresolutionsChan <- []interface{}{i, err}\n\t\t\t\t\treturn err\n\t\t\t\t})\n\t\t\t}(index)\n\t\t}\n\n\t\tresolutions := make([]interface{}, psLen)\n\t\tfor x := 0; x < psLen; x++ {\n\t\t\tresolution := <-resolutionsChan\n\t\t\tresolutions[resolution[0].(int)] = resolution[1]\n\t\t}\n\t\tresolve(resolutions)\n\t})\n}", "func do(steps ...string) { // steps: variadic parameters\n\tdefer fmt.Println(\"All done!\")\n\n\tfor _, s := range steps {\n\t\t// last deferred statement is executed first (start car...)\n\t\tdefer fmt.Println(s) // defer each element\n\t}\n\n\tfmt.Println(\"Starting\")\n}", "func (m *JetReleaserMock) MinimockCloseAllUntilDone() bool {\n\tfor _, e := range m.CloseAllUntilMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.CloseAllUntilMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterCloseAllUntilCounter) < 1 {\n\t\treturn false\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcCloseAllUntil != nil && mm_atomic.LoadUint64(&m.afterCloseAllUntilCounter) < 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "func (a *Assertions) All(target interface{}, predicate Predicate, userMessageComponents ...interface{}) bool {\n\ta.assertion()\n\tif didFail, message := shouldAll(target, predicate); didFail {\n\t\treturn a.fail(message, userMessageComponents...)\n\t}\n\treturn true\n}", "func (Test) All() error {\n\tmg.Deps(Test.Unit, Test.Lint, Test.Style)\n\treturn nil\n}", "func AllTask() {\n\tRun(\"clean\")\n\tRun(\"deps\")\n\tRun(\"browser\")\n\tRun(\"chrome\")\n\tRun(\"bindata\")\n\tRun(\"test\")\n\tRun(\"dist-build\")\n}", "func All(validators ...Validator) []error {\n\tvar output []error\n\tvar err error\n\tfor _, validator := range validators {\n\t\tif err = validator(); err != nil {\n\t\t\toutput = append(output, err)\n\t\t}\n\t}\n\treturn output\n}", "func orderDeps(directStaticDeps []android.Path, directSharedDeps []android.Path, allTransitiveDeps map[android.Path][]android.Path) (orderedAllDeps []android.Path, orderedDeclaredDeps []android.Path) {\n\t// If A depends on B, then\n\t// Every list containing A will also contain B later in the list\n\t// So, after concatenating all lists, the final instance of B will have come from the same\n\t// original list as the final instance of A\n\t// So, the final instance of B will be later in the concatenation than the final A\n\t// So, keeping only the final instance of A and of B ensures that A is earlier in the output\n\t// list than B\n\tfor _, dep := range directStaticDeps {\n\t\torderedAllDeps = append(orderedAllDeps, dep)\n\t\torderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...)\n\t}\n\tfor _, dep := range directSharedDeps {\n\t\torderedAllDeps = append(orderedAllDeps, dep)\n\t\torderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...)\n\t}\n\n\torderedAllDeps = android.LastUniquePaths(orderedAllDeps)\n\n\t// We don't want to add any new dependencies into directStaticDeps (to allow the caller to\n\t// intentionally exclude or replace any unwanted transitive dependencies), so we limit the\n\t// resultant list to only what the caller has chosen to include in directStaticDeps\n\t_, orderedDeclaredDeps = android.FilterPathList(orderedAllDeps, directStaticDeps)\n\n\treturn orderedAllDeps, orderedDeclaredDeps\n}", "func (e *Exit) AfterAll(fn func(*Report)) {\n\te.afterAllFn = fn\n}", "func TestOnlyCallOnceOnMultipleDepChanges(t *testing.T) {\n\tr := New()\n\ti := r.CreateInput(1)\n\tc1 := r.CreateCompute1(i, func(v int) int { return v + 1 })\n\tc2 := r.CreateCompute1(i, func(v int) int { return v - 1 })\n\tc3 := r.CreateCompute1(c2, func(v int) int { return v - 1 })\n\tc4 := r.CreateCompute2(c1, c3, func(v1, v3 int) int { return v1 * v3 })\n\tchanged4 := 0\n\tc4.AddCallback(func(int) { changed4++ })\n\ti.SetValue(3)\n\tif changed4 < 1 {\n\t\tt.Fatalf(\"callback function was not called\")\n\t} else if changed4 > 1 {\n\t\tt.Fatalf(\"callback function was called too often\")\n\t}\n}", "func (r *ReconcileRunner) run(ctx context.Context) (ctrl.Result, error) {\n\n\t// Verify that all dependencies are present in the cluster, and they are\n\towner := r.Owner\n\tvar allDeps []*Dependency\n\tif owner != nil {\n\t\tallDeps = append([]*Dependency{owner}, r.Dependencies...)\n\t} else {\n\t\tallDeps = r.Dependencies\n\t}\n\tstatus := r.status\n\tr.dependencies = map[types.NamespacedName]runtime.Object{}\n\n\t// jump out and requeue if any of the dependencies are missing\n\tfor i, dep := range allDeps {\n\t\tinstance := dep.InitialInstance\n\t\terr := r.KubeClient.Get(ctx, dep.NamespacedName, instance)\n\t\tlog := r.log.WithValues(\"Dependency\", dep.NamespacedName)\n\n\t\t// if any of the dependencies are not found, we jump out.\n\t\tif err != nil { // note that dependencies should be an empty array\n\t\t\tif apierrors.IsNotFound(err) {\n\t\t\t\tlog.Info(\"Dependency not found for \" + dep.NamespacedName.Name + \". Requeuing request.\")\n\t\t\t} else {\n\t\t\t\tlog.Info(fmt.Sprintf(\"Unable to retrieve dependency for %s: %v\", dep.NamespacedName.Name, err.Error()))\n\t\t\t}\n\t\t\treturn r.applyTransition(ctx, \"Dependency\", Pending, client.IgnoreNotFound(err))\n\t\t}\n\n\t\t// set the owner reference if owner is present and references have not been set\n\t\t// currently we only have single object ownership, but it is poosible to have multiple owners\n\t\tif owner != nil && i == 0 {\n\t\t\tif len(r.objectMeta.GetOwnerReferences()) == 0 {\n\t\t\t\treturn r.setOwner(ctx, instance)\n\t\t\t}\n\t\t\tr.owner = instance\n\t\t}\n\t\tr.dependencies[dep.NamespacedName] = instance\n\n\t\tsucceeded, err := dep.SucceededAccessor(instance)\n\t\tif err != nil {\n\t\t\tlog.Info(fmt.Sprintf(\"Cannot get success state for %s. terminal failure.\", dep.NamespacedName.Name))\n\t\t\t// Fail if cannot get Status accessor for dependency\n\t\t\treturn r.applyTransition(ctx, \"Dependency\", Failed, err)\n\t\t}\n\n\t\tif !succeeded {\n\t\t\tlog.Info(\"One of the dependencies is not in 'Succeeded' state, requeuing\")\n\t\t\treturn r.applyTransition(ctx, \"Dependency\", Pending, nil)\n\t\t}\n\t}\n\t// status = &Status{State: Checking}\n\tr.log.Info(fmt.Sprintf(\"ReconcileState: %s\", status))\n\t// **** checking for termination of dockerfile\n\tif status.IsChecking() {\n\t\treturn r.check(ctx)\n\t}\n\n\t// **** podPreviousPod for termination of dockerfile\n\tif status.IsPodDeleting() {\n\t\treturn r.podDelete(ctx)\n\t}\n\n\tif status.IsCompleted(){\n\t\treturn r.applyTransition(ctx, \"from completed\", Pending, nil)\n\t}\n\n\tif status.IsFailed(){\n\t\treturn r.applyTransition(ctx, \"from failed\", Pending, nil)\n\t}\n\n\t// Verify the resource state\n\tif status.IsVerifying() || status.IsPending() || status.IsSucceeded() || status.IsRecreating() {\n\t\tpodSpec, _ := r.ResourceManager.Verify(ctx)\n\t\tpodValue, err := r.spawnPod(\"verify\", podSpec)\n\t\tfmt.Printf(\"%+v\\n\", err)\n\t\tr.instanceUpdater.setPodConfig(podValue)\n\t\treturn r.applyTransition(ctx, \"Check\", Checking, nil)\n\t}\n\n\t// dependencies are now satisfied, can now reconcile the manifest and create or update the resource\n\tif status.IsCreating() {\n\t\tpodSpec, _ := r.ResourceManager.Create(ctx)\n\t\tpodValue, err := r.spawnPod(\"create\", podSpec)\n\t\tfmt.Printf(\"%+v\\n\", err)\n\t\tr.instanceUpdater.setPodConfig(podValue)\n\t\treturn r.applyTransition(ctx, \"Check\", Checking, nil)\n\t}\n\n\t// **** Updating\n\tif status.IsUpdating() {\n\t\tpodSpec, _ := r.ResourceManager.Update(ctx)\n\t\tpodValue, err := r.spawnPod(\"update\", podSpec)\n\t\tfmt.Printf(\"%+v\\n\", err)\n\t\tr.instanceUpdater.setPodConfig(podValue)\n\t\treturn r.applyTransition(ctx, \"Check\", Checking, nil)\n\t}\n\n\t// **** Completing\n\t// has created or updated, running completion step\n\tif status.IsCompleting() {\n\t\treturn r.runCompletion(ctx)\n\t}\n\n\t// **** Terminating\n\tif status.IsTerminating() {\n\t\tr.log.Info(\"unexpected condition. Terminating state should be handled in finalizer\")\n\t\treturn ctrl.Result{}, nil\n\t}\n\n\t// if has no Status, set to pending\n\treturn r.applyTransition(ctx, \"run\", Pending, nil)\n}", "func (q recipeAdditiveQuery) All(ctx context.Context, exec boil.ContextExecutor) (RecipeAdditiveSlice, error) {\n\tvar o []*RecipeAdditive\n\n\terr := q.Bind(ctx, exec, &o)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"models: failed to assign all query results to RecipeAdditive slice\")\n\t}\n\n\tif len(recipeAdditiveAfterSelectHooks) != 0 {\n\t\tfor _, obj := range o {\n\t\t\tif err := obj.doAfterSelectHooks(ctx, exec); err != nil {\n\t\t\t\treturn o, err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn o, nil\n}", "func (r *Runner) SetupAll() {\n\tvar wg sync.WaitGroup\n\n\tfor _, application := range r.applications {\n\t\twg.Add(1)\n\t\tr.setup(application, &wg)\n\t}\n\n\twg.Wait()\n\n\tif hasSetup {\n\t\tr.view.Write(\"\\n✅ Setup complete!\\n\\n\")\n\t}\n}", "func All(fs ...Allow) Allow {\n\treturn func(conn net.Conn) (error, Cleanup) {\n\t\tcleanup := func() {}\n\t\tfor _, f := range fs {\n\t\t\terr, cleanupF := f(conn)\n\t\t\tif cleanupF != nil {\n\t\t\t\tcleanupCopy := cleanup\n\t\t\t\tcleanup = func() {\n\t\t\t\t\tcleanupF()\n\t\t\t\t\tcleanupCopy()\n\t\t\t\t}\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\treturn err, cleanup\n\t\t\t}\n\t\t}\n\t\treturn nil, cleanup\n\t}\n}", "func (k *Bot) OnAll(cb AllCallback) {\n\tk.mutex.Lock()\n\tk.allCallback = append(k.allCallback, cb)\n\tk.mutex.Unlock()\n}", "func closeAll(closers ...xclose.Closer) error {\n\tmultiErr := xerrors.NewMultiError()\n\tfor _, closer := range closers {\n\t\tif err := closer.Close(); err != nil {\n\t\t\tmultiErr = multiErr.Add(err)\n\t\t}\n\t}\n\treturn multiErr.FinalError()\n}", "func All(helper *SQLHelper, awaitables []Awaitable) Awaitable {\n\tif _, ok := awaitables[0].(sqlRowContainer); !ok {\n\t\treturn awaitables[0]\n\t}\n\n\tret := &sqlAllAwaiter{\n\t\thelper: helper,\n\t\tdata: make(map[interface{}]sqlRowContainer, len(awaitables)),\n\t\tretrievedValues: make([]map[string]interface{}, 0),\n\t\ttable: awaitables[0].(sqlRowContainer).getTable(),\n\t}\n\n\tfor _, row := range awaitables {\n\t\trowContainer, ok := row.(sqlRowContainer)\n\t\tif !ok {\n\t\t\treturn row\n\t\t}\n\t\tkey := rowContainer.getData()[rowContainer.getTable().uniqueIndex[0]]\n\t\tret.data[normalizeKeys(key)] = rowContainer\n\t}\n\n\treturn &basicAwaitable{\n\t\tpollableAndCheckable: ret,\n\t\ttimeout: 120 * time.Second,\n\t}\n}", "func all(fns ...setUpEnvFn) setUpEnvFn {\n\treturn func(t *testing.T) func() {\n\t\tt.Helper()\n\t\tvar cleanUps []func()\n\t\tfor _, fn := range fns {\n\t\t\tcleanUps = append(cleanUps, fn(t))\n\t\t}\n\n\t\treturn func() {\n\t\t\tfor i := len(cleanUps) - 1; i >= 0; i-- {\n\t\t\t\tcleanUps[i]()\n\t\t\t}\n\t\t}\n\t}\n}", "func (q failureQuery) All() (FailureSlice, error) {\n\tvar o []*Failure\n\n\terr := q.Bind(&o)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"models: failed to assign all query results to Failure slice\")\n\t}\n\n\tif len(failureAfterSelectHooks) != 0 {\n\t\tfor _, obj := range o {\n\t\t\tif err := obj.doAfterSelectHooks(queries.GetExecutor(q.Query)); err != nil {\n\t\t\t\treturn o, err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn o, nil\n}", "func (m *MockEventLogger) AppendCheckMulti(assumedVersion uint64, events ...eventlog.EventData) (uint64, uint64, time.Time, error) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{assumedVersion}\n\tfor _, a := range events {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"AppendCheckMulti\", varargs...)\n\tret0, _ := ret[0].(uint64)\n\tret1, _ := ret[1].(uint64)\n\tret2, _ := ret[2].(time.Time)\n\tret3, _ := ret[3].(error)\n\treturn ret0, ret1, ret2, ret3\n}", "func waitFor(fns ...func()) {\n\tvar wg sync.WaitGroup\n\n\tfor _, fn1 := range fns {\n\t\twg.Add(1)\n\t\tgo func(fn2 func()) {\n\t\t\tfn2()\n\t\t\twg.Done()\n\t\t}(fn1)\n\t}\n\n\twg.Wait()\n}", "func CallAll(dst []string, rpcname string, args interface{}) error {\n\tch := make(chan error)\n\tfor _, d := range dst {\n\t\tgo func(addr string) {\n\t\t\tch <- Call(addr, rpcname, args, nil)\n\t\t}(d)\n\t}\n\terrList := \"\"\n\tok := true\n\tfor _ = range dst {\n\t\tif err := <-ch; err != nil {\n\t\t\tok = false\n\t\t\terrList += err.Error() + \";\"\n\t\t}\n\t}\n\n\tif ok {\n\t\treturn nil\n\t} else {\n\t\treturn fmt.Errorf(errList)\n\t}\n}", "func (d DependencyList) InstallAllRequiredCommand() string {\n\n\tresult := \"\"\n\tfor _, dependency := range d {\n\t\tif !dependency.Installed && !dependency.Optional {\n\t\t\tresult += \" - \" + dependency.Name + \": \" + dependency.InstallCommand + \"\\n\"\n\t\t}\n\t}\n\n\treturn result\n}", "func All(config, sysprobeYamlCfg ddconfig.ConfigReaderWriter, syscfg *sysconfig.Config) []Check {\n\treturn []Check{\n\t\tNewProcessCheck(config),\n\t\tNewContainerCheck(config),\n\t\tNewRTContainerCheck(config),\n\t\tNewConnectionsCheck(config, sysprobeYamlCfg, syscfg),\n\t\tNewPodCheck(),\n\t\tNewProcessDiscoveryCheck(config),\n\t\tNewProcessEventsCheck(config),\n\t}\n}", "func Test_Framework_ResourceCallOrder(t *testing.T) {\n\ttestCases := []struct {\n\t\tProcessMethod func(ctx context.Context, obj interface{}, rs []Resource) error\n\t\tCtx context.Context\n\t\tResources []Resource\n\t\tExpectedOrders [][]string\n\t\tErrorMatcher func(err error) bool\n\t}{\n\t\t// Test 1 ensures ProcessCreate returns an error in case no resources are\n\t\t// provided.\n\t\t{\n\t\t\tProcessMethod: ProcessCreate,\n\t\t\tCtx: context.TODO(),\n\t\t\tResources: nil,\n\t\t\tExpectedOrders: nil,\n\t\t\tErrorMatcher: IsExecutionFailed,\n\t\t},\n\n\t\t// Test 2 ensures ProcessCreate executes the steps of a single resource in\n\t\t// the expected order.\n\t\t{\n\t\t\tProcessMethod: ProcessCreate,\n\t\t\tCtx: context.TODO(),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 3 ensures ProcessCreate executes the steps of multile resources in\n\t\t// the expected order.\n\t\t{\n\t\t\tProcessMethod: ProcessCreate,\n\t\t\tCtx: context.TODO(),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{},\n\t\t\t\t&testResource{},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 4 ensures ProcessCreate executes the steps of a single resource in\n\t\t// the expected order until it gets canceled.\n\t\t{\n\t\t\tProcessMethod: ProcessCreate,\n\t\t\tCtx: canceledcontext.NewContext(context.Background(), make(chan struct{})),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{\n\t\t\t\t\tCancelingStep: \"GetCurrentState\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 5 ensures ProcessCreate executes the steps of a single resource in\n\t\t// the expected order even if the resource is canceled while the given\n\t\t// context does not contain a canceler.\n\t\t{\n\t\t\tProcessMethod: ProcessCreate,\n\t\t\tCtx: context.TODO(),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{\n\t\t\t\t\tCancelingStep: \"GetCurrentState\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 6 ensures ProcessCreate executes the steps of the first resource in\n\t\t// the expected order in case multile resources are given, until the first\n\t\t// resource gets canceled.\n\t\t{\n\t\t\tProcessMethod: ProcessCreate,\n\t\t\tCtx: canceledcontext.NewContext(context.Background(), make(chan struct{})),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{\n\t\t\t\t\tCancelingStep: \"NewUpdatePatch\",\n\t\t\t\t},\n\t\t\t\t&testResource{},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t},\n\t\t\t\tnil,\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 7 ensures ProcessCreate executes the steps of the first and second resource in\n\t\t// the expected order in case multile resources are given, until the second\n\t\t// resource gets canceled.\n\t\t{\n\t\t\tProcessMethod: ProcessCreate,\n\t\t\tCtx: canceledcontext.NewContext(context.Background(), make(chan struct{})),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{},\n\t\t\t\t&testResource{\n\t\t\t\t\tCancelingStep: \"NewUpdatePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 8 ensures ProcessDelete returns an error in case no resources are\n\t\t// provided.\n\t\t{\n\t\t\tProcessMethod: ProcessDelete,\n\t\t\tCtx: context.TODO(),\n\t\t\tResources: nil,\n\t\t\tExpectedOrders: nil,\n\t\t\tErrorMatcher: IsExecutionFailed,\n\t\t},\n\n\t\t// Test 9 ensures ProcessDelete executes the steps of a single resource in\n\t\t// the expected order.\n\t\t{\n\t\t\tProcessMethod: ProcessDelete,\n\t\t\tCtx: context.TODO(),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewDeletePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 10 ensures ProcessDelete executes the steps of multile resources in\n\t\t// the expected order.\n\t\t{\n\t\t\tProcessMethod: ProcessDelete,\n\t\t\tCtx: context.TODO(),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{},\n\t\t\t\t&testResource{},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewDeletePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewDeletePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 11 ensures ProcessDelete executes the steps of a single resource in\n\t\t// the expected order until it gets canceled.\n\t\t{\n\t\t\tProcessMethod: ProcessDelete,\n\t\t\tCtx: canceledcontext.NewContext(context.Background(), make(chan struct{})),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{\n\t\t\t\t\tCancelingStep: \"GetCurrentState\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 12 ensures ProcessDelete executes the steps of a single resource in\n\t\t// the expected order even if the resource is canceled while the given\n\t\t// context does not contain a canceler.\n\t\t{\n\t\t\tProcessMethod: ProcessDelete,\n\t\t\tCtx: context.TODO(),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{\n\t\t\t\t\tCancelingStep: \"GetCurrentState\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewDeletePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 13 ensures ProcessDelete executes the steps of the first resource in\n\t\t// the expected order in case multile resources are given, until the first\n\t\t// resource gets canceled.\n\t\t{\n\t\t\tProcessMethod: ProcessDelete,\n\t\t\tCtx: canceledcontext.NewContext(context.Background(), make(chan struct{})),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{\n\t\t\t\t\tCancelingStep: \"NewDeletePatch\",\n\t\t\t\t},\n\t\t\t\t&testResource{},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewDeletePatch\",\n\t\t\t\t},\n\t\t\t\tnil,\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 14 ensures ProcessDelete executes the steps of the first and second resource in\n\t\t// the expected order in case multile resources are given, until the second\n\t\t// resource gets canceled.\n\t\t{\n\t\t\tProcessMethod: ProcessDelete,\n\t\t\tCtx: canceledcontext.NewContext(context.Background(), make(chan struct{})),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{},\n\t\t\t\t&testResource{\n\t\t\t\t\tCancelingStep: \"NewDeletePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewDeletePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewDeletePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 15 ensures ProcessUpdate returns an error in case no resources are\n\t\t// provided.\n\t\t{\n\t\t\tProcessMethod: ProcessUpdate,\n\t\t\tCtx: context.TODO(),\n\t\t\tResources: nil,\n\t\t\tExpectedOrders: nil,\n\t\t\tErrorMatcher: IsExecutionFailed,\n\t\t},\n\n\t\t// Test 16 ensures ProcessUpdate executes the steps of a single resource in\n\t\t// the expected order.\n\t\t{\n\t\t\tProcessMethod: ProcessUpdate,\n\t\t\tCtx: context.TODO(),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 17 ensures ProcessUpdate executes the steps of multile resources in\n\t\t// the expected order.\n\t\t{\n\t\t\tProcessMethod: ProcessUpdate,\n\t\t\tCtx: context.TODO(),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{},\n\t\t\t\t&testResource{},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 18 ensures ProcessUpdate executes the steps of a single resource in\n\t\t// the expected order until it gets canceled.\n\t\t{\n\t\t\tProcessMethod: ProcessUpdate,\n\t\t\tCtx: canceledcontext.NewContext(context.Background(), make(chan struct{})),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{\n\t\t\t\t\tCancelingStep: \"GetCurrentState\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 19 ensures ProcessUpdate executes the steps of a single resource in\n\t\t// the expected order even if the resource is canceled while the given\n\t\t// context does not contain a canceler.\n\t\t{\n\t\t\tProcessMethod: ProcessUpdate,\n\t\t\tCtx: context.TODO(),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{\n\t\t\t\t\tCancelingStep: \"GetCurrentState\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 20 ensures ProcessUpdate executes the steps of the first resource in\n\t\t// the expected order in case multile resources are given, until the first\n\t\t// resource gets canceled.\n\t\t{\n\t\t\tProcessMethod: ProcessUpdate,\n\t\t\tCtx: canceledcontext.NewContext(context.Background(), make(chan struct{})),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{\n\t\t\t\t\tCancelingStep: \"NewUpdatePatch\",\n\t\t\t\t},\n\t\t\t\t&testResource{},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t},\n\t\t\t\tnil,\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 21 ensures ProcessUpdate executes the steps of the first and second resource in\n\t\t// the expected order in case multile resources are given, until the second\n\t\t// resource gets canceled.\n\t\t{\n\t\t\tProcessMethod: ProcessUpdate,\n\t\t\tCtx: canceledcontext.NewContext(context.Background(), make(chan struct{})),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{},\n\t\t\t\t&testResource{\n\t\t\t\t\tCancelingStep: \"NewUpdatePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 22 ensures ProcessCreate calls Resource.Apply*Patch\n\t\t// only when Patch has corresponding part set.\n\t\t{\n\t\t\tProcessMethod: ProcessCreate,\n\t\t\tCtx: canceledcontext.NewContext(context.Background(), make(chan struct{})),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t\tp.SetCreateChange(\"test create data\")\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t\tp.SetDeleteChange(\"test delete data\")\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t\tp.SetUpdateChange(\"test update data\")\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t\tp.SetCreateChange(\"test create data\")\n\t\t\t\t\t\tp.SetDeleteChange(\"test delete data\")\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 23 ensures ProcessDelete calls Resource.Apply*Patch\n\t\t// only when Patch has corresponding part set.\n\t\t{\n\t\t\tProcessMethod: ProcessDelete,\n\t\t\tCtx: canceledcontext.NewContext(context.Background(), make(chan struct{})),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t\tp.SetCreateChange(\"test create data\")\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t\tp.SetDeleteChange(\"test delete data\")\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t\tp.SetUpdateChange(\"test update data\")\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t\tp.SetCreateChange(\"test create data\")\n\t\t\t\t\t\tp.SetDeleteChange(\"test delete data\")\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewDeletePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewDeletePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewDeletePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewDeletePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewDeletePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\n\t\t// Test 24 ensures ProcessUpdate calls Resource.Apply*Patch\n\t\t// only when Patch has corresponding part set.\n\t\t{\n\t\t\tProcessMethod: ProcessUpdate,\n\t\t\tCtx: canceledcontext.NewContext(context.Background(), make(chan struct{})),\n\t\t\tResources: []Resource{\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t\tp.SetCreateChange(\"test create data\")\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t\tp.SetDeleteChange(\"test delete data\")\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t\tp.SetUpdateChange(\"test update data\")\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t&testResource{\n\t\t\t\t\tSetupPatchFunc: func(p *Patch) {\n\t\t\t\t\t\tp.SetCreateChange(\"test create data\")\n\t\t\t\t\t\tp.SetDeleteChange(\"test delete data\")\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tExpectedOrders: [][]string{\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyUpdatePatch\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"GetCurrentState\",\n\t\t\t\t\t\"GetDesiredState\",\n\t\t\t\t\t\"NewUpdatePatch\",\n\t\t\t\t\t\"ApplyCreatePatch\",\n\t\t\t\t\t\"ApplyDeletePatch\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tErrorMatcher: nil,\n\t\t},\n\t}\n\n\tfor i, tc := range testCases {\n\t\terr := tc.ProcessMethod(tc.Ctx, nil, tc.Resources)\n\t\tif err != nil {\n\t\t\tif tc.ErrorMatcher == nil {\n\t\t\t\tt.Fatal(\"test\", i+1, \"expected\", nil, \"got\", \"error matcher\")\n\t\t\t} else if !tc.ErrorMatcher(err) {\n\t\t\t\tt.Fatal(\"test\", i+1, \"expected\", true, \"got\", false)\n\t\t\t}\n\t\t} else {\n\t\t\tif len(tc.Resources) != len(tc.ExpectedOrders) {\n\t\t\t\tt.Fatal(\"test\", i+1, \"expected\", len(tc.ExpectedOrders), \"got\", len(tc.ExpectedOrders))\n\t\t\t}\n\n\t\t\tfor j, r := range tc.Resources {\n\t\t\t\tif !reflect.DeepEqual(tc.ExpectedOrders[j], r.(*testResource).Order) {\n\t\t\t\t\tt.Fatal(\"test\", i+1, \"expected\", tc.ExpectedOrders[j], \"got\", r.(*testResource).Order)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func StartAll(services ...Service) <-chan bool {\n\tstarted := make(chan bool, 1)\n\tgo func() {\n\t\tallStarted := true\n\t\tif services != nil {\n\t\t\tvar wg sync.WaitGroup\n\t\t\twg.Add(len(services))\n\t\t\tfor _, svc := range services {\n\t\t\t\tgo func(svc Service) {\n\t\t\t\t\tif svc != nil && !<-svc.Start() {\n\t\t\t\t\t\tallStarted = false\n\t\t\t\t\t}\n\t\t\t\t\twg.Done()\n\t\t\t\t}(svc)\n\t\t\t}\n\t\t\twg.Wait()\n\t\t}\n\t\tstarted <- allStarted\n\t\tclose(started)\n\t}()\n\treturn started\n}", "func (b *taskBuilder) dep(tasks ...string) {\n\tfor _, task := range tasks {\n\t\tif !In(task, b.Spec.Dependencies) {\n\t\t\tb.Spec.Dependencies = append(b.Spec.Dependencies, task)\n\t\t}\n\t}\n}", "func (d DependencyList) InstallAllOptionalCommand() string {\n\n\tresult := \"\"\n\tfor _, dependency := range d {\n\t\tif !dependency.Installed && dependency.Optional {\n\t\t\tresult += \" - \" + dependency.Name + \": \" + dependency.InstallCommand + \"\\n\"\n\t\t}\n\t}\n\n\treturn result\n}", "func (p BaseLogCopy) Dependencies() []string {\n\treturn []string{\n\t\t\"Base/Env/CollectEnvVars\",\n\t\t\"Base/Env/CollectSysProps\",\n\t\t\"Base/Config/Validate\",\n\t}\n}", "func (c *Cluster) SomeWorkloads(ctx context.Context, ids []resource.ID) (res []cluster.Workload, err error) {\n\tvar workloads []cluster.Workload\n\tfor _, id := range ids {\n\t\tif !c.IsAllowedResource(id) {\n\t\t\tcontinue\n\t\t}\n\t\tns, kind, name := id.Components()\n\n\t\tresourceKind, ok := resourceKinds[kind]\n\t\tif !ok {\n\t\t\tc.logger.Log(\"warning\", \"automation of this resource kind is not supported\", \"resource\", id)\n\t\t\tcontinue\n\t\t}\n\n\t\tworkload, err := resourceKind.getWorkload(ctx, c, ns, name)\n\t\tif err != nil {\n\t\t\tif apierrors.IsForbidden(err) || apierrors.IsNotFound(err) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif !isAddon(workload) {\n\t\t\tc.muSyncErrors.RLock()\n\t\t\tworkload.syncError = c.syncErrors[id]\n\t\t\tc.muSyncErrors.RUnlock()\n\t\t\tworkloads = append(workloads, workload.toClusterWorkload(id))\n\t\t}\n\t}\n\treturn workloads, nil\n}", "func (m *HeavySyncMock) AllMocksCalled() bool {\n\n\tif !m.ResetFinished() {\n\t\treturn false\n\t}\n\n\tif !m.StartFinished() {\n\t\treturn false\n\t}\n\n\tif !m.StopFinished() {\n\t\treturn false\n\t}\n\n\tif !m.StoreBlobsFinished() {\n\t\treturn false\n\t}\n\n\tif !m.StoreDropFinished() {\n\t\treturn false\n\t}\n\n\tif !m.StoreIndicesFinished() {\n\t\treturn false\n\t}\n\n\tif !m.StoreRecordsFinished() {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func AffectedTargets(state *core.BuildState, files []string, tests, transitive bool) {\n\taffectedTargets := make(chan *core.BuildTarget, 100)\n\tdone := make(chan bool)\n\n\tfilePaths := map[string]bool{}\n\tfor _, file := range files {\n\t\tfilePaths[file] = true\n\t}\n\n\t// Check all the targets to see if any own one of these files\n\tgo func() {\n\t\tfor _, target := range state.Graph.AllTargets() {\n\t\t\t// TODO(peterebden): this assumption is very crude, revisit.\n\t\t\tif target.Subrepo == nil {\n\t\t\t\tfor _, source := range target.AllSourcePaths(state.Graph) {\n\t\t\t\t\tif _, present := filePaths[source]; present {\n\t\t\t\t\t\taffectedTargets <- target\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdone <- true\n\t}()\n\n\t// Check all the packages to see if any are defined by these files.\n\t// This is pretty pessimistic, we have to just assume the whole package is invalidated.\n\t// A better approach involves using plz query graph and plz_diff_graphs - see that tool\n\t// for more explanation.\n\tgo func() {\n\t\tinvalidatePackage := func(pkg *core.Package) {\n\t\t\tfor _, target := range pkg.AllTargets() {\n\t\t\t\taffectedTargets <- target\n\t\t\t}\n\t\t}\n\t\tfor _, pkg := range state.Graph.PackageMap() {\n\t\t\tif _, present := filePaths[pkg.Filename]; present {\n\t\t\t\tinvalidatePackage(pkg)\n\t\t\t} else {\n\t\t\t\tfor _, subinclude := range pkg.Subincludes {\n\t\t\t\t\tfor _, source := range state.Graph.TargetOrDie(subinclude).AllSourcePaths(state.Graph) {\n\t\t\t\t\t\tif _, present := filePaths[source]; present {\n\t\t\t\t\t\t\tinvalidatePackage(pkg)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdone <- true\n\t}()\n\n\tgo handleAffectedTargets(state, affectedTargets, done, tests, transitive)\n\n\t<-done\n\t<-done\n\tclose(affectedTargets)\n\t<-done\n}", "func (d Depseeker) Run(ctx context.Context, url string) ([]Dependency, error) {\n\tif url[len(url)-1:] != \"/\" {\n\t\turl += \"/\"\n\t}\n\n\thm := hashmap.HashMap{}\n\treturnDependencies := []Dependency{}\n\t// mutex\n\tmutex := sync.Mutex{}\n\n\t// check for package.json\n\thttp.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}\n\tresp, err := http.Get(url + \"package.json\")\n\tif err == nil {\n\t\tif resp.StatusCode == http.StatusOK {\n\t\t\tbody, err := ioutil.ReadAll(resp.Body)\n\t\t\tif err == nil {\n\t\t\t\tfoundPackages := findPackages(string(body))\n\t\t\t\tfor _, foundPackage := range foundPackages {\n\t\t\t\t\t_, loaded := hm.GetOrInsert(foundPackage.Name, \"\")\n\t\t\t\t\tif !loaded {\n\t\t\t\t\t\tgologger.Debug().Msgf(\"[package.json] Found package %s (%s)\", foundPackage.Name, foundPackage.Version)\n\t\t\t\t\t\tnewDependency := Dependency{\n\t\t\t\t\t\t\tName: foundPackage.Name,\n\t\t\t\t\t\t\tVersion: foundPackage.Version,\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// add to result\n\t\t\t\t\t\tmutex.Lock()\n\t\t\t\t\t\treturnDependencies = append(returnDependencies, newDependency)\n\t\t\t\t\t\tmutex.Unlock()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// check for package-lock.json\n\thttp.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}\n\tresp, err = http.Get(url + \"package-lock.json\")\n\tif err == nil {\n\t\tif resp.StatusCode == http.StatusOK {\n\t\t\tbody, err := ioutil.ReadAll(resp.Body)\n\t\t\tif err == nil {\n\t\t\t\tfoundPackages := findPackages(string(body))\n\t\t\t\tfor _, foundPackage := range foundPackages {\n\t\t\t\t\t_, loaded := hm.GetOrInsert(foundPackage.Name, \"\")\n\t\t\t\t\tif !loaded {\n\t\t\t\t\t\tgologger.Debug().Msgf(\"[package-lock.json] Found package %s (%s)\", foundPackage.Name, foundPackage.Version)\n\t\t\t\t\t\tnewDependency := Dependency{\n\t\t\t\t\t\t\tName: foundPackage.Name,\n\t\t\t\t\t\t\tVersion: foundPackage.Version,\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// add to result\n\t\t\t\t\t\tmutex.Lock()\n\t\t\t\t\t\treturnDependencies = append(returnDependencies, newDependency)\n\t\t\t\t\t\tmutex.Unlock()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// create chrome instance\n\toptions := []chromedp.ExecAllocatorOption{}\n\toptions = append(options, chromedp.DefaultExecAllocatorOptions[:]...)\n\toptions = append(options, chromedp.UserAgent(d.options.UserAgent))\n\toptions = append(options, chromedp.DisableGPU)\n\toptions = append(options, chromedp.Flag(\"ignore-certificate-errors\", true)) // RIP shittyproxy.go\n\toptions = append(options, chromedp.WindowSize(1920, 1080))\n\tif d.options.HTTPProxy != \"\" {\n\t\toptions = append(options, chromedp.ProxyServer(d.options.HTTPProxy))\n\t}\n\n\t// create context\n\tchromeCtx, xcancel := chromedp.NewExecAllocator(ctx, options...)\n\tdefer xcancel()\n\n\t// start chrome\n\t// remove the 2nd param if you don't need debug information logged\n\tctxt, cancel := chromedp.NewContext(chromeCtx)\n\tdefer cancel()\n\n\tchromedp.ListenTarget(\n\t\tctxt,\n\t\tfunc(ev interface{}) {\n\t\t\tif ev, ok := ev.(*network.EventResponseReceived); ok {\n\t\t\t\tif ev.Type != \"Script\" {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tgo func() {\n\t\t\t\t\t// get response body\n\t\t\t\t\tc := chromedp.FromContext(ctxt)\n\t\t\t\t\trbp := network.GetResponseBody(ev.RequestID)\n\t\t\t\t\tbody, err := rbp.Do(cdp.WithExecutor(ctxt, c.Target))\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tgologger.Error().Msgf(\"Encountered error: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t\tfoundPackages := findPackages(string(body))\n\t\t\t\t\tfor _, foundPackage := range foundPackages {\n\t\t\t\t\t\t_, loaded := hm.GetOrInsert(foundPackage.Name, \"\")\n\t\t\t\t\t\tif !loaded {\n\t\t\t\t\t\t\tgologger.Debug().Msgf(\"[JS assets] Found package %s (%s)\", foundPackage.Name, foundPackage.Version)\n\t\t\t\t\t\t\tnewDependency := Dependency{\n\t\t\t\t\t\t\t\tName: foundPackage.Name,\n\t\t\t\t\t\t\t\tVersion: foundPackage.Version,\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// add to result\n\t\t\t\t\t\t\tmutex.Lock()\n\t\t\t\t\t\t\treturnDependencies = append(returnDependencies, newDependency)\n\t\t\t\t\t\t\tmutex.Unlock()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}()\n\n\t\t\t}\n\t\t},\n\t)\n\n\terr = chromedp.Run(ctxt, chromedp.Tasks{\n\t\tnavigateAndWaitFor(url, \"networkIdle\"),\n\t\tchromedp.Sleep(time.Duration(15 * time.Second)),\n\t})\n\tif err != nil {\n\t\tgologger.Error().Msgf(\"Error: %v\", err)\n\t}\n\n\tfor _, returnDependency := range returnDependencies {\n\t\t// check if package is existed in npm\n\t\tresp, err = http.Get(\"http://registry.npmjs.com/\" + returnDependency.Name)\n\t\tif err == nil {\n\t\t\tbody, err := ioutil.ReadAll(resp.Body)\n\t\t\tif err == nil {\n\t\t\t\tif strings.TrimSpace(string(body)) == \"{\\\"error\\\":\\\"Not found\\\"}\" {\n\t\t\t\t\treturnDependency.IsPrivate = true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tgologger.Error().Msgf(\"Error: %v\", err)\n\t\t\t}\n\t\t} else {\n\t\t\tgologger.Error().Msgf(\"Error: %v\", err)\n\t\t}\n\t}\n\n\treturn returnDependencies, nil\n}", "func (o *RecipeAdditive) doAfterUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) {\n\tif boil.HooksAreSkipped(ctx) {\n\t\treturn nil\n\t}\n\n\tfor _, hook := range recipeAdditiveAfterUpsertHooks {\n\t\tif err := hook(ctx, exec, o); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (pool *Pool) WaitAll() {\n\tpool.waitGroup.Wait()\n}", "func getDependencies() error {\n\t// go get -u dependencies from the dependencies array\n\tfor _, dependency := range dependencies {\n\t\t// Exec go get command inside Name folder using exec.Command\n\t\tcmd := exec.Command(\"go\", \"get\", \"-u\", dependency)\n\t\tcmd.Dir = Name\n\n\t\tif err := cmd.Run(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func generateBuildtimeDependencies(artifactID strfmt.UUID, includeBuilders bool, lookup map[strfmt.UUID]interface{}, result map[strfmt.UUID]struct{}) (map[strfmt.UUID]struct{}, error) {\n\tartifact, ok := lookup[artifactID].(*model.Artifact)\n\tif !ok {\n\t\t_, sourceOK := lookup[artifactID].(*model.Source)\n\t\tif sourceOK {\n\t\t\t// Dependency is a source, skipping\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, errs.New(\"Incorrect target type for id %s, expected Artifact or Source\", artifactID)\n\t}\n\n\tif !includeBuilders && artifact.MimeType == model.XActiveStateBuilderMimeType {\n\t\treturn nil, nil\n\t}\n\n\t// We iterate through the direct dependencies of the artifact\n\t// and recursively add all of the dependencies of those artifacts map.\n\tfor _, depID := range artifact.RuntimeDependencies {\n\t\tresult[depID] = struct{}{}\n\t\t_, err := generateBuildtimeDependencies(depID, includeBuilders, lookup, result)\n\t\tif err != nil {\n\t\t\treturn nil, errs.Wrap(err, \"Could not build map for runtime dependencies of artifact %s\", artifact.NodeID)\n\t\t}\n\t}\n\n\tstep, ok := lookup[artifact.GeneratedBy].(*model.Step)\n\tif !ok {\n\t\t_, ok := lookup[artifact.GeneratedBy].(*model.Source)\n\t\tif !ok {\n\t\t\treturn nil, errs.New(\"Incorrect target type for id %s, expected Step or Source\", artifact.GeneratedBy)\n\t\t}\n\n\t\t// Artifact was not generated by a step, skipping\n\t\treturn nil, nil\n\t}\n\n\t// We iterate through the inputs of the step that generated the\n\t// artifact and recursively add all of the dependencies of those\n\t// artifacts, skipping over the builder artifacts as those resolve\n\t// directly to sources. This is because they are not built and therefore\n\t// not generated by a step.\n\tfor _, input := range step.Inputs {\n\t\tif input.Tag == model.TagBuilder {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, id := range input.NodeIDs {\n\t\t\t_, err := generateBuildtimeDependencies(id, includeBuilders, lookup, result)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errs.Wrap(err, \"Could not build map for step dependencies of artifact %s\", artifact.NodeID)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result, nil\n}", "func Dependencies(logger logr.Logger, manager feature.ResourceManagers, dda *v2alpha1.DatadogAgent) (errs []error) {\n\toverrides := dda.Spec.Override\n\tnamespace := dda.Namespace\n\n\tfor component, override := range overrides {\n\t\terr := overrideRBAC(logger, manager, override, component, namespace)\n\t\tif err != nil {\n\t\t\terrs = append(errs, err)\n\t\t}\n\n\t\t// Handle custom agent configurations (datadog.yaml, cluster-agent.yaml, etc.)\n\t\terrs = append(errs, overrideCustomConfigs(logger, manager, override.CustomConfigurations, dda.Name, namespace)...)\n\n\t\t// Handle custom check configurations\n\t\tconfdCMName := fmt.Sprintf(v2alpha1.ExtraConfdConfigMapName, strings.ToLower((string(component))))\n\t\terrs = append(errs, overrideExtraConfigs(logger, manager, override.ExtraConfd, namespace, confdCMName, true)...)\n\n\t\t// Handle custom check files\n\t\tchecksdCMName := fmt.Sprintf(v2alpha1.ExtraChecksdConfigMapName, strings.ToLower((string(component))))\n\t\terrs = append(errs, overrideExtraConfigs(logger, manager, override.ExtraChecksd, namespace, checksdCMName, false)...)\n\n\t\t// Handle scc\n\t\terrs = append(errs, overrideSCC(manager, dda)...)\n\t}\n\n\treturn errs\n}", "func (b *Builder) addTransitiveLinkDeps(a, a1 *Action, shlib string) {\n\t// Expand Deps to include all built packages, for the linker.\n\t// Use breadth-first search to find rebuilt-for-test packages\n\t// before the standard ones.\n\t// TODO(rsc): Eliminate the standard ones from the action graph,\n\t// which will require doing a little bit more rebuilding.\n\tworkq := []*Action{a1}\n\thaveDep := map[string]bool{}\n\tif a1.Package != nil {\n\t\thaveDep[a1.Package.ImportPath] = true\n\t}\n\tfor i := 0; i < len(workq); i++ {\n\t\ta1 := workq[i]\n\t\tfor _, a2 := range a1.Deps {\n\t\t\t// TODO(rsc): Find a better discriminator than the Mode strings, once the dust settles.\n\t\t\tif a2.Package == nil || (a2.Mode != \"build-install\" && a2.Mode != \"build\") || haveDep[a2.Package.ImportPath] {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\thaveDep[a2.Package.ImportPath] = true\n\t\t\ta.Deps = append(a.Deps, a2)\n\t\t\tif a2.Mode == \"build-install\" {\n\t\t\t\ta2 = a2.Deps[0] // walk children of \"build\" action\n\t\t\t}\n\t\t\tworkq = append(workq, a2)\n\t\t}\n\t}\n\n\t// If this is go build -linkshared, then the link depends on the shared libraries\n\t// in addition to the packages themselves. (The compile steps do not.)\n\tif cfg.BuildLinkshared {\n\t\thaveShlib := map[string]bool{shlib: true}\n\t\tfor _, a1 := range a.Deps {\n\t\t\tp1 := a1.Package\n\t\t\tif p1 == nil || p1.Shlib == \"\" || haveShlib[filepath.Base(p1.Shlib)] {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\thaveShlib[filepath.Base(p1.Shlib)] = true\n\t\t\t// TODO(rsc): The use of ModeInstall here is suspect, but if we only do ModeBuild,\n\t\t\t// we'll end up building an overall library or executable that depends at runtime\n\t\t\t// on other libraries that are out-of-date, which is clearly not good either.\n\t\t\t// We call it ModeBuggyInstall to make clear that this is not right.\n\t\t\ta.Deps = append(a.Deps, b.linkSharedAction(ModeBuggyInstall, ModeBuggyInstall, p1.Shlib, nil))\n\t\t}\n\t}\n}", "func Any(promises ...*Promise) *Promise {\n\tif len(promises) == 0 {\n\t\treturn New(empty)\n\t}\n\n\tif len(promises) == 1 {\n\t\treturn promises[0]\n\t}\n\n\t// Check that all the promises have the same return type\n\tfirstResultType := promises[0].resultType\n\tfor promiseIdx, promise := range promises[1:] {\n\t\tnewResultType := promise.resultType\n\t\tif len(firstResultType) != len(newResultType) {\n\t\t\tpanic(errors.Errorf(anyErrorFormat, promiseIdx))\n\t\t}\n\t\tfor index := range firstResultType {\n\t\t\tif firstResultType[index] != newResultType[index] {\n\t\t\t\tpanic(errors.Errorf(anyErrorFormat, promiseIdx))\n\t\t\t}\n\t\t}\n\t}\n\n\tp := &Promise{\n\t\tcond: sync.Cond{L: &sync.Mutex{}},\n\t\tt: anyCall,\n\t\tanyErrs: make([]error, len(promises)),\n\t}\n\n\t// Extract the type\n\tp.resultType = firstResultType[:]\n\n\tp.counter = int64(1)\n\tp.errCounter = int64(len(promises))\n\n\tfor i := range promises {\n\t\tgo p.run(reflect.Value{}, nil, promises, i, nil)\n\t}\n\treturn p\n}", "func AnyJoin(out chan<- Any, inp ...Any) (done <-chan struct{}) {\n\tsig := make(chan struct{})\n\tgo joinAny(sig, out, inp...)\n\treturn sig\n}", "func (p *Wheel) Dependencies() []Dependency {\n\tvar dependencies []Dependency\n\n\tfor _, row := range p.RequiresDist {\n\t\tdep, err := version.ParseDependency(row)\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"❗️ %s: %s(%v)\\n\", p.name, row, err)\n\t\t\tcontinue\n\t\t}\n\t\tinstall, err := dep.Evaluate(env)\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"❗️ %s: %s(%v)\\n\", p.name, row, err)\n\t\t\tcontinue\n\t\t}\n\t\tif !install {\n\t\t\tcontinue\n\t\t}\n\n\t\t// fmt.Fprintf(os.Stderr, \"🍀 %s: %s(minimal = %s)\\n\", name, row, version.Minimal(dep.Versions))\n\t\tdependencies = append(dependencies, Dependency{\n\t\t\tName: NormalizePackageName(dep.Name),\n\t\t\tVersion: version.Minimal(dep.Versions),\n\t\t})\n\t}\n\n\treturn dependencies\n}", "func TestMakeDependency(t *testing.T) {\n\tt.Run(`NoContextNoErr`, func(t *testing.T) {\n\t\td, err := makeDependency(t1)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfd, ok := d.(targetDep)\n\t\tif !ok {\n\t\t\tt.Errorf(`expected makeDependency to produce a targetDep`)\n\t\t}\n\t\tif string(fd) != name(t1) {\n\t\t\tt.Errorf(`expected name to match target`)\n\t\t}\n\t\tif fd.getRun().fn == nil {\n\t\t\tt.Errorf(`expected makeDependency to specify fn`)\n\t\t}\n\t})\n\tt.Run(`ContextNoErr`, func(t *testing.T) {\n\t\td, err := makeDependency(t2)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfd, ok := d.(targetDep)\n\t\tif !ok {\n\t\t\tt.Errorf(`expected makeDependency to produce a targetDep`)\n\t\t}\n\t\tif string(fd) != name(t2) {\n\t\t\tt.Errorf(`expected name to match target`)\n\t\t}\n\t\tif fd.getRun().fn == nil {\n\t\t\tt.Errorf(`expected makeDependency to specify fn`)\n\t\t}\n\t})\n\tt.Run(`NoContextErr`, func(t *testing.T) {\n\t\td, err := makeDependency(t3)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfd, ok := d.(targetDep)\n\t\tif !ok {\n\t\t\tt.Errorf(`expected makeDependency to produce a targetDep`)\n\t\t}\n\t\tif string(fd) != name(t3) {\n\t\t\tt.Errorf(`expected name to match target`)\n\t\t}\n\t\tif fd.getRun().fn == nil {\n\t\t\tt.Errorf(`expected makeDependency to specify fn`)\n\t\t}\n\t})\n\tt.Run(`ContextErr`, func(t *testing.T) {\n\t\td, err := makeDependency(t4)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfd, ok := d.(targetDep)\n\t\tif !ok {\n\t\t\tt.Errorf(`expected makeDependency to produce a targetDep`)\n\t\t}\n\t\tif string(fd) != name(t4) {\n\t\t\tt.Errorf(`expected name to match target`)\n\t\t}\n\t\tif name(fd.getRun().fn) != name(t4) {\n\t\t\tt.Errorf(`expected makeDependency to use the target as fn`)\n\t\t}\n\t})\n}", "func WaitAny(tasks ...Task) Task {\n\tt := WhenAny()\n\tvalue, err := t.Result()\n\tif err != nil {\n\t\treturn FromError(err)\n\t}\n\n\t// create unwrap function?\n\tinnerTask, ok := value.(Task)\n\tif !ok {\n\t\treturn FromError(fmt.Errorf(\"unable to cast value to task\"))\n\t}\n\treturn innerTask\n}" ]
[ "0.66200477", "0.6336258", "0.63357496", "0.6108432", "0.6054186", "0.59423923", "0.5868885", "0.5806676", "0.58031505", "0.5698449", "0.5670537", "0.56573665", "0.5622649", "0.5605129", "0.56030434", "0.5568432", "0.55593777", "0.55325687", "0.55232847", "0.5516108", "0.5502269", "0.5476786", "0.54650307", "0.54485244", "0.54154944", "0.53841805", "0.5344574", "0.52758", "0.5237052", "0.5233704", "0.5182982", "0.5179896", "0.5173847", "0.51613206", "0.5138995", "0.512723", "0.51249546", "0.5118205", "0.51024145", "0.5079434", "0.50666964", "0.50647485", "0.5051743", "0.504904", "0.50437796", "0.5017297", "0.5008366", "0.49995664", "0.49964258", "0.4992495", "0.4991134", "0.49838588", "0.49725366", "0.4958973", "0.4958372", "0.49573323", "0.49542424", "0.49512285", "0.4926104", "0.49203226", "0.48978344", "0.48788622", "0.4848694", "0.4847955", "0.48424423", "0.48401722", "0.48343238", "0.48293674", "0.4828959", "0.48251566", "0.48149976", "0.4813047", "0.47937784", "0.4792186", "0.47890776", "0.4787531", "0.47851667", "0.47828925", "0.47798085", "0.47775087", "0.47749126", "0.4769853", "0.47684956", "0.4768219", "0.47599992", "0.47577602", "0.47575647", "0.47540525", "0.47445214", "0.47420308", "0.47403437", "0.47173765", "0.47165036", "0.47129256", "0.47110698", "0.47084165", "0.4703112", "0.47027314", "0.46957213", "0.4692574" ]
0.7441156
0
newPromise creates a promise out of a dependency
newPromise создает промис на основе зависимости
func newPromise(scheduler scheduler, dependency dependency) promise { return promise{scheduler: scheduler, dependency: dependency} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewPromise() Promise {\n\treturn &promise{sync.Mutex{}, make(chan error), nil, nil, false}\n}", "func NewPromise() Controller {\n\treturn &promise{}\n}", "func New(executor func(resolve func(interface{}), reject func(error))) *Promise {\n\tvar wg = &sync.WaitGroup{}\n\twg.Add(1)\n\n\tvar promise = &Promise{\n\t\tstate: pending,\n\t\texecutor: executor,\n\t\tthen: make([]func(interface{}) interface{}, 0),\n\t\tcatch: make([]func(error) error, 0),\n\t\tresult: nil,\n\t\terr: nil,\n\t\tmutex: &sync.Mutex{},\n\t\twg: wg,\n\t}\n\n\tgo func() {\n\t\tdefer promise.handlePanic()\n\t\tpromise.executor(promise.resolve, promise.reject)\n\t}()\n\n\treturn promise\n}", "func newFuture() *future {\n\treturn &future{\n\t\twaitCh: make(chan struct{}),\n\t\tid: uuid.Generate(),\n\t}\n}", "func populatePromise(p *Promise, r interface{}, e error) *Promise {\n\n\t// If promise is undefined\n\tif p == nil {\n\n\t\t// Create a new promise\n\t\tp = getPromiseOrEmptyPromise(nil)\n\n\t\t// If result provided, set status and result values\n\t\tif r != nil {\n\t\t\tp.status = RESOLVED\n\t\t\tp.res = r\n\t\t\tp.err = nil\n\t\t}\n\n\t\t// If error provided, set status and error values\n\t\tif e != nil {\n\t\t\tp.status = REJECTED\n\t\t\tp.err = e\n\t\t\tp.res = nil\n\t\t}\n\n\t\t// If result and error both not provided, set status as RESOLVED (Case where no more then or catch are required)\n\t\tif r == nil && e == nil {\n\t\t\tp.status = RESOLVED\n\t\t}\n\t}\n\treturn p\n}", "func New(f interface{}, args ...interface{}) *Promise {\n\t// Extract the type\n\tp := &Promise{\n\t\tcond: sync.Cond{L: new(sync.Mutex)},\n\t\tt: simpleCall,\n\t}\n\n\tfunctionRv := reflect.ValueOf(f)\n\n\tif functionRv.Kind() != reflect.Func {\n\t\tpanic(errors.Errorf(\"expected Function, got %s\", functionRv.Kind()))\n\t}\n\n\treflectType := functionRv.Type()\n\n\tinputs := []reflect.Type{}\n\tfor i := 0; i < reflectType.NumIn(); i++ {\n\t\tinputs = append(inputs, reflectType.In(i))\n\t}\n\n\tif len(args) != len(inputs) {\n\t\tpanic(errors.Errorf(\"expected %d args, got %d args\", len(inputs), len(args)))\n\t}\n\n\tp.resultType, p.returnsError = getResultType(reflectType)\n\n\targValues := []reflect.Value{}\n\n\tfor i := 0; i < len(args); i++ {\n\t\tprovidedArgRv := reflect.ValueOf(args[i])\n\t\tprovidedArgType := providedArgRv.Type()\n\t\tif providedArgType != inputs[i] {\n\t\t\tpanic(errors.Errorf(\"for argument %d: expected type %s got type %s\", i, inputs[i], providedArgType))\n\t\t}\n\t\targValues = append(argValues, providedArgRv)\n\t}\n\tgo p.run(functionRv, nil, nil, 0, argValues)\n\treturn p\n}", "func WrapInPromise(f func() (interface{}, error)) js.Value {\n\tvar executor js.Func\n\texecutor = js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\tresolve := args[0]\n\t\treject := args[1]\n\t\tgo func() {\n\t\t\tdefer executor.Release()\n\t\t\tif result, err := f(); err != nil {\n\t\t\t\treject.Invoke(ErrorToJS(err))\n\t\t\t} else {\n\t\t\t\tresolve.Invoke(result)\n\t\t\t}\n\t\t}()\n\t\treturn nil\n\t})\n\treturn js.Global().Get(\"Promise\").New(executor)\n}", "func getPromiseOrEmptyPromise(p *Promise) *Promise {\n\tif p != nil {\n\t\treturn p\n\t}\n\tp1 := &Promise{}\n\tp1.channel = make(chan int)\n\tp1.res = nil\n\tp1.err = nil\n\tp1.status = PENDING\n\treturn p1\n}", "func newTask() task {\n\treturn task{}\n}", "func newAsync() *async {\n\treturn &async{state: pending, completions: []func(){}, done: make(chan struct{})}\n}", "func newProcess(cmd *exec.Cmd, done func()) *process {\n\treturn &process{\n\t\tcmd: cmd,\n\t\tdone: done,\n\t\twaitC: make(chan error, 1),\n\t}\n}", "func (d *Deferred) Promise() *js.Object {\n\treturn d.Get(\"promise\")\n}", "func NewNodePromise(ctx context.Context) *NodePromise {\n\treturn &NodePromise{\n\t\tdone: make(chan struct{}),\n\t\tctx: ctx,\n\t}\n}", "func newDependencyResolver(\n\tbasePath string,\n\texclusions []*regexp.Regexp) (dr dag.DependencyResolver) {\n\tdr = &dependencyResolver{\n\t\tbasePath: basePath,\n\t\texclusions: exclusions,\n\t}\n\n\treturn\n}", "func (f *FirstErrPromise) Promise() func(*Record, error) {\n\tf.wg.Add(1)\n\treturn f.promise\n}", "func NewPromiseValidator(address common.Address, backend bind.ContractBackend) (*PromiseValidator, error) {\n\tcontract, err := bindPromiseValidator(address, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &PromiseValidator{PromiseValidatorCaller: PromiseValidatorCaller{contract: contract}, PromiseValidatorTransactor: PromiseValidatorTransactor{contract: contract}}, nil\n}", "func newProtonInstance(proton core.Protoner) reflect.Value {\n\tbaseValue := reflect.ValueOf(proton)\n\n\t// try to create new value of proton\n\tmethod := baseValue.MethodByName(\"New\")\n\tif method.IsValid() {\n\t\treturns := method.Call(emptyParameters)\n\t\tif len(returns) <= 0 {\n\t\t\tpanic(fmt.Sprintf(\"Method New must has at least 1 returns. now %d\", len(returns)))\n\t\t}\n\t\treturn returns[0]\n\t} else {\n\t\t// return reflect.New(reflect.TypeOf(proton).Elem())\n\t\treturn newInstance(reflect.TypeOf(proton))\n\t}\n}", "func newTask(jobID *peloton.JobID, id uint32, jobFactory *jobFactory, jobType pbjob.JobType) *task {\n\ttask := &task{\n\t\tjobID: jobID,\n\t\tid: id,\n\t\tjobType: jobType,\n\t\tjobFactory: jobFactory,\n\t}\n\n\treturn task\n}", "func NewPool(concurrency int, fns <-chan func() Promise, opts ...PoolOptions) *Pool {\n\tif concurrency <= 0 {\n\t\tpanic(\"promise.NewPool: concurrency must be greater than 0\")\n\t}\n\n\tvar options PoolOptions\n\tif len(opts) > 0 {\n\t\toptions = opts[0]\n\t}\n\n\treturn &Pool{\n\t\tfns: fns,\n\t\tsem: make(chan struct{}, concurrency),\n\t\tdone: make(chan struct{}),\n\t\tresult: make(chan Result),\n\t\toptions: options,\n\t}\n}", "func ExamplePromise() {\n\tstuff := Promise(func() int {\n\t\treturn 3\n\t}).\n\t\tThen(func(x int) int {\n\t\t\tfmt.Println(x)\n\t\t\treturn x * x\n\t\t}).\n\t\tThen(func(x int) {\n\t\t\tfmt.Println(x)\n\t\t})\n\tfmt.Println(stuff.Result)\n\t// Output:\n\t// 3\n\t// 9\n\t// []\n}", "func newQuotaPool(q int) *quotaPool {\n\tqp := &quotaPool{\n\t\tacquireChannel: make(chan int, 1),\n\t}\n\tif q > 0 {\n\t\tqp.acquireChannel <- q\n\t} else {\n\t\tqp.quota = q\n\t}\n\treturn qp\n}", "func (h *HTTPClient) newReq(method, token, projID, path string, body io.Reader) (*http.Request, error) {\n\turlStr := fmt.Sprintf(\"%s://%s:%d/3/projects/%s/%s\", h.scheme, h.host, h.port, projID, path)\n\treq, err := http.NewRequest(method, urlStr, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"Authorization\", \"OAuth \"+token)\n\treturn req, nil\n}", "func scheduleAndUnwrap(scheduler scheduler, do func(ctx context.Context) (dependency, error)) promise {\n\tcompletionSource := &completionSource{\n\t\tdone: make(chan struct{}),\n\t}\n\tscheduler.schedule(func(ctx context.Context) error {\n\t\tp, err := do(ctx)\n\t\tif err != nil {\n\t\t\tcompletionSource.err = err\n\t\t\tclose(completionSource.done)\n\t\t\treturn err\n\t\t}\n\t\tgo func() {\n\t\t\t<-p.Done()\n\t\t\tcompletionSource.err = p.Err()\n\t\t\tclose(completionSource.done)\n\t\t}()\n\t\treturn nil\n\t})\n\treturn newPromise(scheduler, completionSource)\n}", "func (v OwnerFetcher) getOrCreatePromise(id types.UID) (*objectTreePromise, bool) {\n\tv.mu.Lock()\n\tdefer v.mu.Unlock()\n\tpromise, ok := v.cache[id]\n\tif !ok {\n\t\tpromise = newObjectTreePromise()\n\t\tv.cache[id] = promise\n\t}\n\treturn promise, ok\n}", "func newProvisioner(baseCtx context.Context, cl *restClient, callTimeout time.Duration) mode.Provisioner {\n\treturn provisioner{cl: cl, baseCtx: baseCtx, callTimeout: callTimeout}\n}", "func CreateFuture(cmd *Command) (future interface{}) {\n\tswitch cmd.RespType {\n\tcase BOOLEAN:\n\t\tfuture = newFutureBool()\n\tcase BULK:\n\t\tfuture = newFutureBytes()\n\tcase MULTI_BULK:\n\t\tfuture = newFutureBytesArray()\n\tcase NUMBER:\n\t\tfuture = newFutureInt64()\n\tcase STATUS:\n\t\t//\t\tfuture = newFutureString();\n\t\tfuture = newFutureBool()\n\tcase STRING:\n\t\tfuture = newFutureString()\n\t\t//\tcase VIRTUAL:\t\t// TODO\n\t\t//\t resp, err = getVirtualResponse ();\n\t}\n\treturn\n}", "func NewFuture(Func func() (Value, error)) Future {\n\treturn newFutureResult(Func)\n}", "func (t *task) newOperation(bq *InMemoryBuildQueue, priority int32, i *invocation, mayExistWithoutWaiters bool) *operation {\n\to := &operation{\n\t\tname: uuid.Must(bq.uuidGenerator()).String(),\n\t\ttask: t,\n\t\tpriority: priority,\n\t\tinvocation: i,\n\t\tmayExistWithoutWaiters: mayExistWithoutWaiters,\n\t\tqueueIndex: -1,\n\t}\n\tif _, ok := t.operations[i]; ok {\n\t\tpanic(\"Task is already associated with this invocation\")\n\t}\n\tt.operations[i] = o\n\tbq.operationsNameMap[o.name] = o\n\treturn o\n}", "func newRPCClientService() (*rpcClientService, error) {\n return &rpcClientService{rpcCh: make(chan *sendRPCState)}, nil\n}", "func newShadowResourceProvisioner(\n\tp ResourceProvisioner) (ResourceProvisioner, shadowResourceProvisioner) {\n\t// Create the shared data\n\tshared := shadowResourceProvisionerShared{\n\t\tValidate: shadow.ComparedValue{\n\t\t\tFunc: shadowResourceProvisionerValidateCompare,\n\t\t},\n\t}\n\n\t// Create the real provisioner that does actual work\n\treal := &shadowResourceProvisionerReal{\n\t\tResourceProvisioner: p,\n\t\tShared: &shared,\n\t}\n\n\t// Create the shadow that watches the real value\n\tshadow := &shadowResourceProvisionerShadow{\n\t\tShared: &shared,\n\t}\n\n\treturn real, shadow\n}", "func (_PromiseValidator *PromiseValidatorTransactor) SubmitPromise(opts *bind.TransactOpts, caseId [32]byte, serviceId [32]byte, beneficiary common.Address, blockNumber *big.Int, sigV uint8, sigR [32]byte, sigS [32]byte) (*types.Transaction, error) {\n\treturn _PromiseValidator.contract.Transact(opts, \"submitPromise\", caseId, serviceId, beneficiary, blockNumber, sigV, sigR, sigS)\n}", "func newResource(r interface{}) corev2.Resource {\n\treturn reflect.New(reflect.ValueOf(r).Elem().Type()).Interface().(corev2.Resource)\n}", "func (p *promise) Then(promise Promise) Promise {\n\treturn p.Thenf(func() Promise { return promise })\n}", "func (p *LightningPool) new(ctx context.Context) (*amqp.Channel, error) {\n\treturn p.conn.Channel(ctx)\n}", "func (*rootMessageProducer) RequestFuture(pid *PID, message interface{}, timeout time.Duration) *Future {\n\treturn pid.RequestFuture(message, timeout)\n}", "func (*rootMessageProducer) RequestFuture(pid *PID, message interface{}, timeout time.Duration) *Future {\n\treturn pid.RequestFuture(message, timeout)\n}", "func NewPar(P, Q Process) *Par { return &Par{Procs: []Process{P, Q}} }", "func newAsyncResult() *asyncResult {\n\treturn &asyncResult{state: pending, completions: []func(result interface{}){}, done: make(chan struct{}), async: newAsync()}\n}", "func newTask(ctx context.Context, cfg *taskConfig, f TaskFunc, args ...interface{}) *Task {\n\tctx, cancelCtx := context.WithCancel(ctx)\n\n\ttask := &Task{\n\t\tcfg: cfg,\n\n\t\tctx: ctx,\n\t\tcancelCtx: cancelCtx,\n\n\t\tf: f,\n\t\targs: args,\n\n\t\tstartedChan: make(chan struct{}),\n\t\trunningChan: make(chan struct{}),\n\t\tfinishedChan: make(chan struct{}),\n\n\t\tresultChan: make(chan TaskResult),\n\t}\n\n\treturn task\n}", "func (s *Scavenger) newTask(info *p.TaskListInfo) executor.Task {\n\treturn &executorTask{\n\t\ttaskListInfo: *info,\n\t\tscvg: s,\n\t}\n}", "func newProcess(pid int) (*Process, error) {\n\n\tstate := sigar.ProcState{}\n\tif err := state.Get(pid); err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting process state for pid=%d: %v\", pid, err)\n\t}\n\n\tproc := Process{\n\t\tPid: pid,\n\t\tPpid: state.Ppid,\n\t\tName: state.Name,\n\t\tState: getProcState(byte(state.State)),\n\t\tUsername: state.Username,\n\t\tctime: time.Now(),\n\t}\n\n\treturn &proc, nil\n}", "func NewPlanner()(*Planner) {\n m := &Planner{\n Entity: *NewEntity(),\n }\n return m\n}", "func createFork() Fork {\n return Fork { make(chan bool), make(chan bool)}\n}", "func newProject(projectName string) (p *project, err error) {\n\tmatches := reGithubProject.FindStringSubmatch(projectName)\n\tif len(matches) < 2 {\n\t\terr = fmt.Errorf(\"bad project name: %s\", projectName)\n\t\treturn\n\t}\n\n\tp = &project{\n\t\towner: matches[1],\n\t\trepo: matches[2],\n\t\tpath: matches[4],\n\t\tref: matches[6],\n\t}\n\n\t// Add \"/\" suffix to path.\n\tif len(p.path) > 0 && p.path[len(p.path)-1] != '/' {\n\t\tp.path = p.path + \"/\"\n\t}\n\n\t// If ref is Semver, add 'tags/' prefix to make it a valid ref.\n\tif reSemver.MatchString(p.ref) {\n\t\tp.ref = \"tags/\" + p.ref\n\t}\n\n\terr = verifyRef(p.ref)\n\treturn\n}", "func newTask(byteTask []byte, next *task) *task {\n return &task{byteTask, next}\n}", "func newBasePipe(taskc chan string, resultc chan []string) (basePipe, func() error) {\n\tpipe := basePipe{\n\t\twg: new(sync.WaitGroup),\n\t\tclosec: make(chan struct{}),\n\t\ttaskc: taskc,\n\t\tresultc: resultc,\n\t}\n\n\tpipe.wg.Add(1)\n\n\twait := func() error {\n\t\tpipe.wg.Done()\n\t\tpipe.wg.Wait()\n\t\tclose(pipe.taskc)\n\t\tselect {\n\t\tcase <-pipe.closec:\n\t\t\treturn Closed\n\t\tdefault:\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn pipe, wait\n}", "func NewFuture(ctx Context) (Future, Settable) {\n\timpl := &futureImpl{channel: NewChannel(ctx).(*channelImpl)}\n\treturn impl, impl\n}", "func (g *Group) newRequest(operation *request.Operation, input interface{}, output interface{}, handlers *request.Handlers) *request.Request {\n return request.New(g.Client, operation, input, output, handlers)\n}", "func newProjectService(session *r.Session) *projectService {\n\treturn &projectService{\n\t\tprojects: dai.NewRProjects(session),\n\t\tdirs: dai.NewRDirs(session),\n\t}\n}", "func newClient(project string) (*client, error) {\n\tctx := context.Background()\n\tcl, err := pubsub.NewClient(ctx, project)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &client{\n\t\tclient: cl,\n\t}, nil\n}", "func NewSynchronizationJob()(*SynchronizationJob) {\n m := &SynchronizationJob{\n Entity: *NewEntity(),\n }\n return m\n}", "func (_PromiseValidator *PromiseValidatorTransactorSession) SubmitPromise(caseId [32]byte, serviceId [32]byte, beneficiary common.Address, blockNumber *big.Int, sigV uint8, sigR [32]byte, sigS [32]byte) (*types.Transaction, error) {\n\treturn _PromiseValidator.Contract.SubmitPromise(&_PromiseValidator.TransactOpts, caseId, serviceId, beneficiary, blockNumber, sigV, sigR, sigS)\n}", "func (_PromiseValidator *PromiseValidatorSession) SubmitPromise(caseId [32]byte, serviceId [32]byte, beneficiary common.Address, blockNumber *big.Int, sigV uint8, sigR [32]byte, sigS [32]byte) (*types.Transaction, error) {\n\treturn _PromiseValidator.Contract.SubmitPromise(&_PromiseValidator.TransactOpts, caseId, serviceId, beneficiary, blockNumber, sigV, sigR, sigS)\n}", "func (s *Service) ExecNewArtifact(ctx context.Context, e NewArtifactEvent) error {\n\tspan, ctx := s.Tracer.FromCtx(ctx, \"flow.ExecNewArtifact\")\n\tdefer span.Finish()\n\n\tlogger := log.WithContext(ctx)\n\n\tartifactSpec, err := s.Storage.ArtifactSpecification(ctx, e.Service, e.ArtifactID)\n\tif err != nil {\n\t\treturn errors.WithMessagef(err, \"fetch artifact specification for service '%s' artifactId '%s'\", e.Service, e.ArtifactID)\n\t}\n\n\tlogger = logger.WithFields(\"branch\", artifactSpec.Application.Branch, \"service\", artifactSpec.Service, \"commit\", artifactSpec.Application.SHA)\n\t// lookup policies for branch\n\tautoReleases, err := s.Policy.GetAutoReleases(ctx, artifactSpec.Service, artifactSpec.Application.Branch)\n\tif err != nil {\n\t\tlogger.Errorf(\"flow: exec new artifact: service '%s' branch '%s': get auto release policies failed: %v\", artifactSpec.Service, artifactSpec.Application.Branch, err)\n\t\terr := s.Slack.NotifySlackPolicyFailed(ctx, artifactSpec.Application.AuthorEmail, \":rocket: Release Manager :no_entry:\", fmt.Sprintf(\"Auto release policy failed for service %s and %s\", artifactSpec.Service, artifactSpec.Application.Branch))\n\t\tif err != nil {\n\t\t\tlogger.Errorf(\"flow: exec new artifact: get auto-release policies: error notifying slack: %v\", err)\n\t\t}\n\t\treturn err\n\t}\n\tlogger.Infof(\"flow: exec new artifact: service '%s' branch '%s': found %d release policies\", artifactSpec.Service, artifactSpec.Application.Branch, len(autoReleases))\n\tvar errs error\n\tfor _, autoRelease := range autoReleases {\n\t\treleaseID, err := s.ReleaseArtifactID(ctx, Actor{\n\t\t\tName: artifactSpec.Application.AuthorName,\n\t\t\tEmail: artifactSpec.Application.AuthorEmail,\n\t\t}, autoRelease.Environment, artifactSpec.Service, artifactSpec.ID, intent.NewAutoRelease())\n\t\tif err != nil {\n\t\t\tif errorCause(err) != git.ErrNothingToCommit && errorCause(err) != ErrNothingToRelease {\n\t\t\t\terrs = multierr.Append(errs, err)\n\t\t\t\terr := s.Slack.NotifySlackPolicyFailed(ctx, artifactSpec.Application.AuthorEmail, \":rocket: Release Manager :no_entry:\", fmt.Sprintf(\"Service %s was not released into %s from branch %s.\\nYou can deploy manually using `hamctl`:\\nhamctl release --service %[1]s --branch %[3]s --env %[2]s\", artifactSpec.Service, autoRelease.Environment, autoRelease.Branch))\n\t\t\t\tif err != nil {\n\t\t\t\t\tlogger.Errorf(\"flow: exec new artifact: auto-release failed: error notifying slack: %v\", err)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlogger.Infof(\"flow: exec new artifact: service '%s': auto-release from policy '%s' to '%s': %v\", artifactSpec.Service, autoRelease.ID, autoRelease.Environment, err)\n\t\t\tcontinue\n\t\t}\n\t\t//TODO: Parse and switch to signoff user\n\t\terr = s.Slack.NotifySlackPolicySucceeded(ctx, artifactSpec.Application.AuthorEmail, \":rocket: Release Manager :white_check_mark:\", fmt.Sprintf(\"Service *%s* will be auto released to *%s*\\nArtifact: <%s|*%s*>\", artifactSpec.Service, autoRelease.Environment, artifactSpec.Application.URL, releaseID))\n\t\tif err != nil {\n\t\t\tif errors.Cause(err) != slack.ErrUnknownEmail {\n\t\t\t\tlogger.Errorf(\"flow: exec new artifact: auto-release succeeded: error notifying slack: %v\", err)\n\t\t\t}\n\t\t}\n\t\tlogger.Infof(\"flow: exec new artifact: service '%s': auto-release from policy '%s' of %s to %s\", artifactSpec.Service, autoRelease.ID, releaseID, autoRelease.Environment)\n\t}\n\tif errs != nil {\n\t\tlogger.Errorf(\"flow: exec new artifact: service '%s' branch '%s': auto-release failed with one or more errors: %v\", artifactSpec.Service, artifactSpec.Application.Branch, errs)\n\t\treturn errs\n\t}\n\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func newProjectService(sling *sling.Sling) *ProjectService {\n\treturn &ProjectService{\n\t\tsling: sling.Path(\"groups/\"),\n\t}\n}", "func newFetch(g *Goproxy, name, tempDir string) (*fetch, error) {\n\tf := &fetch{\n\t\tg: g,\n\t\tname: name,\n\t\ttempDir: tempDir,\n\t}\n\n\tvar escapedModulePath string\n\tif strings.HasSuffix(name, \"/@latest\") {\n\t\tescapedModulePath = strings.TrimSuffix(name, \"/@latest\")\n\t\tf.ops = fetchOpsResolve\n\t\tf.moduleVersion = \"latest\"\n\t\tf.contentType = \"application/json; charset=utf-8\"\n\t} else if strings.HasSuffix(name, \"/@v/list\") {\n\t\tescapedModulePath = strings.TrimSuffix(name, \"/@v/list\")\n\t\tf.ops = fetchOpsList\n\t\tf.moduleVersion = \"latest\"\n\t\tf.contentType = \"text/plain; charset=utf-8\"\n\t} else {\n\t\tnameParts := strings.SplitN(name, \"/@v/\", 2)\n\t\tif len(nameParts) != 2 {\n\t\t\treturn nil, errors.New(\"missing /@v/\")\n\t\t}\n\n\t\tescapedModulePath = nameParts[0]\n\n\t\tnameExt := path.Ext(nameParts[1])\n\t\tescapedModuleVersion := strings.TrimSuffix(\n\t\t\tnameParts[1],\n\t\t\tnameExt,\n\t\t)\n\t\tswitch nameExt {\n\t\tcase \".info\":\n\t\t\tf.ops = fetchOpsDownloadInfo\n\t\t\tf.contentType = \"application/json; charset=utf-8\"\n\t\tcase \".mod\":\n\t\t\tf.ops = fetchOpsDownloadMod\n\t\t\tf.contentType = \"text/plain; charset=utf-8\"\n\t\tcase \".zip\":\n\t\t\tf.ops = fetchOpsDownloadZip\n\t\t\tf.contentType = \"application/zip\"\n\t\tcase \"\":\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"no file extension in filename %q\",\n\t\t\t\tescapedModuleVersion,\n\t\t\t)\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"unexpected extension %q\",\n\t\t\t\tnameExt,\n\t\t\t)\n\t\t}\n\n\t\tvar err error\n\t\tf.moduleVersion, err = module.UnescapeVersion(\n\t\t\tescapedModuleVersion,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif f.moduleVersion == \"latest\" {\n\t\t\treturn nil, errors.New(\"invalid version\")\n\t\t} else if !semver.IsValid(f.moduleVersion) {\n\t\t\tif f.ops == fetchOpsDownloadInfo {\n\t\t\t\tf.ops = fetchOpsResolve\n\t\t\t} else {\n\t\t\t\treturn nil, errors.New(\"unrecognized version\")\n\t\t\t}\n\t\t}\n\t}\n\n\tvar err error\n\tf.modulePath, err = module.UnescapePath(escapedModulePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tf.modAtVer = fmt.Sprint(f.modulePath, \"@\", f.moduleVersion)\n\tf.requiredToVerify = g.goBinEnvGOSUMDB != \"off\" &&\n\t\t!globsMatchPath(g.goBinEnvGONOSUMDB, f.modulePath)\n\n\treturn f, nil\n}", "func newRequest(ctx context.Context, msg interface{}) *request {\n\treturn &request{\n\t\tctx: ctx,\n\t\tmsg: msg,\n\t\tfailure: make(chan error, 1),\n\t\tresponse: make(chan *Delivery, 1),\n\t}\n}", "func newReconciler(mgr manager.Manager) reconcile.Reconciler {\n\treturn &ReconcileProjectReference{client: mgr.GetClient(), scheme: mgr.GetScheme(), gcpClientBuilder: gcpclient.NewClient}\n}", "func (c *OutputService14ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func Delay(f func() interface{}) *Promise {\n\treturn &Promise{f: f}\n}", "func newPackage(ctx context.Context, repo *Repository, merkle string) (Package, error) {\n\t// Need to parse out the package meta.far to find the package contents.\n\tblob, err := repo.OpenBlob(ctx, merkle)\n\tif err != nil {\n\t\treturn Package{}, err\n\t}\n\tdefer blob.Close()\n\n\tf, err := far.NewReader(blob)\n\tif err != nil {\n\t\treturn Package{}, err\n\t}\n\tdefer f.Close()\n\n\tb, err := f.ReadFile(\"meta/contents\")\n\tif err != nil {\n\t\treturn Package{}, err\n\t}\n\n\tcontents, err := build.ParseMetaContents(bytes.NewReader(b))\n\tif err != nil {\n\t\treturn Package{}, err\n\t}\n\n\treturn Package{\n\t\tmerkle: merkle,\n\t\trepo: repo,\n\t\tcontents: contents,\n\t}, nil\n}", "func (client *Client) newRequest(method string, id string) (*http.Request, os.Error) {\n\trequest := new(http.Request)\n\tvar err os.Error\n\n\trequest.ProtoMajor = 1\n\trequest.ProtoMinor = 1\n\trequest.TransferEncoding = []string{\"chunked\"}\n\n\trequest.Method = method\n\n\t// Generate Resource-URI and parse it\n\turl := client.resource.String() + id\n\tif request.URL, err = http.ParseURL(url); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn request, nil\n}", "func newReconciler(mgr manager.Manager) reconcile.Reconciler {\n\treturn &ReconcileGatlingTask{client: mgr.GetClient(), scheme: mgr.GetScheme()}\n}", "func newPRReject() *prReject {\n\treturn &prReject{prCommon{Type: prTypeReject}}\n}", "func Resolve(resolution interface{}) *Promise {\n\treturn New(func(resolve func(interface{}), reject func(error)) {\n\t\tresolve(resolution)\n\t})\n}", "func newPeerService(sling *sling.Sling) *PeerService {\n\treturn &PeerService{\n\t\tsling: sling.Path(\"groups/\"),\n\t}\n}", "func (conn Connection) newRequest(method, cmd string, body io.Reader) *http.Request {\n\t// req, err := conn.jhReq(method, cmd, body)\n\treq, err := http.NewRequest(method, conn.HubURL+cmd, body)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Coulnd't generate HTTP request - %s\\n\", err.Error()))\n\t}\n\n\treq.Header.Add(\"Authorization\", fmt.Sprintf(\"token %s\", conn.Token))\n\n\treturn req\n}", "func (p promise) then(next func(ctx context.Context) error) promise {\n\tcompletionSource := &completionSource{\n\t\tdone: make(chan struct{}),\n\t}\n\tgo func() {\n\t\tdefer close(completionSource.done)\n\t\tselect {\n\t\tcase <-p.Done():\n\t\t\tif err := p.Err(); err != nil {\n\t\t\t\tcompletionSource.err = err\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcompletionSource.err = p.scheduler.schedule(next).wait()\n\t\t}\n\t}()\n\treturn newPromise(p.scheduler, completionSource)\n}", "func newPluginWithErr(errorMsg string) (p *slackscot.Plugin, err error) {\n\tif errorMsg != \"\" {\n\t\treturn nil, fmt.Errorf(errorMsg)\n\t}\n\n\treturn newPlugin(), nil\n}", "func (c *Container) GetNew(p *Provider) (interface{}, error) {\n\treturn (*p).New(c)\n}", "func (c *OutputService3ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func (c *OutputService3ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func New(fn interface{}) *Task {\n\t// Spin up some channels\n\tdone := make(chan struct{}, 1)\n\tstopper := make(chan struct{}, 1)\n\ttResolver := make(chan interface{}, 1)\n\ttRejector := make(chan error, 1)\n\ttiResolver := make(chan interface{}, 1)\n\ttiRejector := make(chan error, 1)\n\n\t// Create our task object\n\tt := &Task{\n\t\tResolver: tResolver,\n\t\tRejector: tRejector,\n\t\tStopper: &stopper,\n\t\tDone: &done,\n\t}\n\n\t// Execute the task asynchronously\n\tgo func() {\n\t\t// Regardless of what the function does we know that it is done\n\t\tdefer func() {\n\t\t\tclose(done)\n\t\t\tt.doneValue = true\n\t\t}()\n\n\t\t// Catch any panics and reject them\n\t\tdefer goerr.Handle(func(e error) {\n\t\t\tt.err = goerr.Trace(3, e)\n\t\t\ttRejector <- t.err\n\t\t})\n\n\t\t// Execute the task\n\t\tswitch v := fn.(type) {\n\t\tcase func():\n\t\t\tv()\n\t\tcase func(t *Internal):\n\t\t\tv(&Internal{\n\t\t\t\tResolver: tiResolver,\n\t\t\t\tRejector: tiRejector,\n\t\t\t\tStopper: t.Stopper,\n\t\t\t\tdone: &done,\n\t\t\t})\n\t\t}\n\n\t\t// Read the result in a non blocking manner. Keep in mind not every task\n\t\t// will actually resolve or reject anything, the simple fact that it is\n\t\t// done could be enough.\n\t\tselect {\n\t\tcase v := <-tiResolver:\n\t\t\tt.value = v\n\t\t\ttResolver <- t.value\n\t\tcase e := <-tiRejector:\n\t\t\tt.err = e\n\t\t\ttRejector <- t.err\n\t\tdefault:\n\t\t}\n\t}()\n\n\t// Return the task object\n\treturn t\n}", "func (promise *Promise) Then(fulfillment func(data interface{}) interface{}) *Promise {\n\tpromise.mutex.Lock()\n\tdefer promise.mutex.Unlock()\n\n\tif promise.state == pending {\n\t\tpromise.wg.Add(1)\n\t\tpromise.then = append(promise.then, fulfillment)\n\t} else if promise.state == fulfilled {\n\t\tpromise.result = fulfillment(promise.result)\n\t}\n\n\treturn promise\n}", "func (c *OutputService4ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func (c *OutputService4ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func (*proFactory) New(args xreg.Args, bck *cluster.Bck) xreg.Renewable {\n\tc := args.Custom.(*xreg.DirPromoteArgs)\n\tp := &proFactory{RenewBase: xreg.RenewBase{Args: args, Bck: bck}, dir: c.Dir, params: c.Params}\n\treturn p\n}", "func (c *Client) newRequest(method string, refURL string, params url.Values) (*http.Request, error) {\n\trel, err := url.Parse(refURL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif params != nil {\n\t\trel.RawQuery = params.Encode()\n\t}\n\tu := c.BaseURL.ResolveReference(rel)\n\n\tvar req *http.Request\n\n\treq, err = http.NewRequest(method, u.String(), nil)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "func NewArtifact()(*Artifact) {\n m := &Artifact{\n Entity: *iadcd81124412c61e647227ecfc4449d8bba17de0380ddda76f641a29edf2b242.NewEntity(),\n }\n return m\n}", "func newP(method, url, token string, body interface{}) (*http.Request, error) {\n\treader, err := encode(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trequest, err := NewRequest(method, url, reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbearer := fmt.Sprintf(\"Bearer %s\", token)\n\trequest.Header.Add(\"Authorization\", bearer)\n\trequest.Header.Add(\"Accept\", \"application/json\")\n\trequest.Header.Add(\"Content-Type\", \"application/json\")\n\treturn request, nil\n}", "func (m *manager) newRequest(ctx context.Context, selector ipld.Node, isPull bool, voucher datatransfer.Voucher, baseCid cid.Cid, to peer.ID) (datatransfer.Request, error) {\n\t// Generate a new transfer ID for the request\n\ttid := datatransfer.TransferID(m.transferIDGen.next())\n\treturn message.NewRequest(tid, false, isPull, voucher.Type(), voucher, baseCid, selector)\n}", "func (c *OutputService15ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func (p *Pool) new(ctx context.Context) (ChannelKeeper, error) {\n\tch, err := p.conn.Channel(ctx)\n\tif err != nil {\n\t\treturn ChannelKeeper{}, errors.Wrap(err, \"failed to receive channel from connection\")\n\t}\n\n\terrorCh := ch.NotifyClose(make(chan *amqp.Error, 1))\n\n\terr = ch.Confirm(false)\n\tif err != nil {\n\t\t_ = ch.Close() //nolint: gosec\n\n\t\treturn ChannelKeeper{}, errors.Wrap(err, \"failed to setup confirm mode for channel\")\n\t}\n\n\tconfirmCh := ch.NotifyPublish(make(chan amqp.Confirmation, 1))\n\n\treturnCh := ch.NotifyReturn(make(chan amqp.Return, 1))\n\n\treturn ChannelKeeper{ch, errorCh, confirmCh, returnCh}, nil\n}", "func newModule(moduleName, name string, vrf *VrfInfo) Module {\n\tfactory, found := moduleFactories[moduleName]\n\tif !found {\n\t\tLogger.Printf(\"Module '%s' doesn't exist.\\n\", moduleName)\n\t\treturn nil\n\t}\n\n\trp, ok := ringParams[name]\n\tif !ok {\n\t\trp = defaultRingParam\n\t}\n\trp.Flags = dpdk.RING_F_SC_DEQ\n\n\t// Create a parameter for the module\n\tmodType := moduleTypes[moduleName]\n\tparam := &ModuleParam{\n\t\tt: modType,\n\t\tname: name,\n\t\tvrf: vrf,\n\t\trp: rp,\n\t\tvrp: rp,\n\t\trules: newRules(),\n\t}\n\n\tswitch modType {\n\tcase TypeVif:\n\t\tparam.vif = newVif()\n\tcase TypeBridge:\n\t\tparam.bridge = newBridge()\n\tdefault:\n\t\t// nop\n\t}\n\n\tmodule, err := factory(param)\n\tif err != nil {\n\t\tLogger.Printf(\"Creating module '%s' with name '%s' failed.\\n\", moduleName, name)\n\t\treturn nil\n\t}\n\n\tswitch modType {\n\tcase TypeVif:\n\t\top, ok := module.(VifOp)\n\t\tif !ok {\n\t\t\tLogger.Fatalf(\"'%s' doesn't conform to VifModule interface!\\n\", moduleName)\n\t\t\tbreak\n\t\t}\n\t\tms, _ := module.(ModuleService)\n\t\tparam.vif.config(op, ms)\n\n\tdefault:\n\t\t// nop\n\t}\n\n\tmodules = append(modules, module)\n\n\treturn module\n}", "func (c *InputService14ProtocolTest) newRequest(op *request.Operation, params, data interface{}) *request.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func newPromExporter(subsystem string) *promExporter {\n\tRequestDurationBucket := []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 15, 20, 30, 40, 50, 60}\n\n\texporter := &promExporter{\n\t\trequestCount: prometheus.NewCounterVec(\n\t\t\tprometheus.CounterOpts{\n\t\t\t\tSubsystem: subsystem,\n\t\t\t\tName: \"requests_total\",\n\t\t\t\tHelp: \"Number of HTTP requests\",\n\t\t\t},\n\t\t\t[]string{\"code\", \"method\"},\n\t\t),\n\t\trequestDuration: prometheus.NewHistogramVec(\n\t\t\tprometheus.HistogramOpts{\n\t\t\t\tSubsystem: subsystem,\n\t\t\t\tName: \"request_duration_seconds\",\n\t\t\t\tHelp: \"HTTP request duration in seconds.\",\n\t\t\t\tBuckets: RequestDurationBucket,\n\t\t\t},\n\t\t\t[]string{\"code\"},\n\t\t),\n\t}\n\n\tprometheus.MustRegister(\n\t\texporter.requestCount,\n\t\texporter.requestDuration,\n\t)\n\treturn exporter\n}", "func NewFulfillment() {\n\t\n}", "func newReconciler(mgr manager.Manager) reconcile.Reconciler {\n\treturn &ReconcileProjectClaim{client: mgr.GetClient(), scheme: mgr.GetScheme()}\n}", "func newClaim(name, claimUID, capacity, boundToVolume string, phase v1.PersistentVolumeClaimPhase, class *string, annotations ...string) *v1.PersistentVolumeClaim {\n\tclaim := v1.PersistentVolumeClaim{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: name,\n\t\t\tNamespace: testNamespace,\n\t\t\tUID: types.UID(claimUID),\n\t\t\tResourceVersion: \"1\",\n\t\t},\n\t\tSpec: v1.PersistentVolumeClaimSpec{\n\t\t\tAccessModes: []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce, v1.ReadOnlyMany},\n\t\t\tResources: v1.ResourceRequirements{\n\t\t\t\tRequests: v1.ResourceList{\n\t\t\t\t\tv1.ResourceName(v1.ResourceStorage): resource.MustParse(capacity),\n\t\t\t\t},\n\t\t\t},\n\t\t\tVolumeName: boundToVolume,\n\t\t\tStorageClassName: class,\n\t\t},\n\t\tStatus: v1.PersistentVolumeClaimStatus{\n\t\t\tPhase: phase,\n\t\t},\n\t}\n\t// Make sure ref.GetReference(claim) works\n\tclaim.ObjectMeta.SelfLink = testapi.Default.SelfLink(\"pvc\", name)\n\n\tif len(annotations) > 0 {\n\t\tclaim.Annotations = make(map[string]string)\n\t\tfor _, a := range annotations {\n\t\t\tswitch a {\n\t\t\tcase annStorageProvisioner:\n\t\t\t\tclaim.Annotations[a] = mockPluginName\n\t\t\tdefault:\n\t\t\t\tclaim.Annotations[a] = \"yes\"\n\t\t\t}\n\t\t}\n\t}\n\n\t// Bound claims must have proper Status.\n\tif phase == v1.ClaimBound {\n\t\tclaim.Status.AccessModes = claim.Spec.AccessModes\n\t\t// For most of the tests it's enough to copy claim's requested capacity,\n\t\t// individual tests can adjust it using withExpectedCapacity()\n\t\tclaim.Status.Capacity = claim.Spec.Resources.Requests\n\t}\n\n\treturn &claim\n}", "func (p *promise) Thenf(factory Factory) Promise {\n\tresult := NewPromise()\n\n\tp.Always(func(p2 Controller) {\n\t\tif p2.IsSuccess() {\n\t\t\tfactory().Always(func(p3 Controller) {\n\t\t\t\tresult.DeliverWithPromise(p3)\n\t\t\t})\n\t\t} else {\n\t\t\tresult.DeliverWithPromise(p2)\n\t\t}\n\t})\n\n\treturn result\n}", "func newRoutine(wg *sync.WaitGroup) {\n\tfmt.Println(\"New Routine\")\n\twg.Done()\n}", "func newPluginProvider(pluginBinDir string, provider kubeletconfig.CredentialProvider) (*pluginProvider, error) {\n\tmediaType := \"application/json\"\n\tinfo, ok := runtime.SerializerInfoForMediaType(codecs.SupportedMediaTypes(), mediaType)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unsupported media type %q\", mediaType)\n\t}\n\n\tgv, ok := apiVersions[provider.APIVersion]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"invalid apiVersion: %q\", provider.APIVersion)\n\t}\n\n\tclock := clock.RealClock{}\n\n\treturn &pluginProvider{\n\t\tclock: clock,\n\t\tmatchImages: provider.MatchImages,\n\t\tcache: cache.NewExpirationStore(cacheKeyFunc, &cacheExpirationPolicy{clock: clock}),\n\t\tdefaultCacheDuration: provider.DefaultCacheDuration.Duration,\n\t\tlastCachePurge: clock.Now(),\n\t\tplugin: &execPlugin{\n\t\t\tname: provider.Name,\n\t\t\tapiVersion: provider.APIVersion,\n\t\t\tencoder: codecs.EncoderForVersion(info.Serializer, gv),\n\t\t\tpluginBinDir: pluginBinDir,\n\t\t\targs: provider.Args,\n\t\t\tenvVars: provider.Env,\n\t\t\tenviron: os.Environ,\n\t\t},\n\t}, nil\n}", "func CreateGofer(id int, goferQueue chan chan JobRequest) Gofer {\n\n gofer := Gofer {\n GoferID: id,\n JobChan: make(chan JobRequest),\n GoferQueue: goferQueue,\n ExitChan: make(chan bool),\n }\n\n return gofer\n}", "func newSimpleTransport(parent *Transport) (*simpleTransport, error) {\n\t// Establish the WebSocket connection.\n\tws, err := parent.dial(nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Instantiate a JSON-RPC client.\n\tclient := jsonrpc2.NewClient(ws)\n\n\t// Return a new simple transport.\n\treturn &simpleTransport{parent, ws, client}, nil\n}", "func (c *OutputService2ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func (c *OutputService2ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func (c *OutputService13ProtocolTest) newRequest(op *aws.Operation, params, data interface{}) *aws.Request {\n\treq := c.NewRequest(op, params, data)\n\n\treturn req\n}", "func (e *Exporter) newFetcher(hostname string) *Fetcher {\n\treturn NewFetcher(hostname, e.chAccessInfo.Username, e.chAccessInfo.Password, e.chAccessInfo.Port)\n}", "func newResource(tm unversioned.TypeMetadata) (unversioned.Resource, error) {\n\trh, ok := resourceToType[tm]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"Unknown resource type (%s) and/or version (%s)\", tm.Kind, tm.APIVersion)\n\t}\n\tlog.Debugf(\"Found resource helper: %s\", rh)\n\n\t// Create new resource and fill in the type metadata.\n\tnew := reflect.New(rh)\n\telem := new.Elem()\n\telem.FieldByName(\"Kind\").SetString(tm.GetTypeMetadata().Kind)\n\telem.FieldByName(\"APIVersion\").SetString(tm.GetTypeMetadata().APIVersion)\n\n\treturn new.Interface().(unversioned.Resource), nil\n}", "func newService(repo Repository) Service {\n\n\tif repo == nil {\n\t\treturn nil\n\t}\n\treturn &service{repo}\n}" ]
[ "0.6707661", "0.6399388", "0.62243986", "0.5719654", "0.57112944", "0.569883", "0.5536393", "0.54549676", "0.5106503", "0.50471157", "0.4955386", "0.49389923", "0.49148178", "0.4825148", "0.47839233", "0.47563744", "0.47542834", "0.4734377", "0.47324514", "0.47285217", "0.47256234", "0.4699247", "0.46935406", "0.4692654", "0.46458188", "0.463327", "0.4626893", "0.461978", "0.4611392", "0.46073475", "0.4590019", "0.4585952", "0.45841795", "0.4574587", "0.45663273", "0.45663273", "0.45653415", "0.456341", "0.4560271", "0.45547643", "0.45401746", "0.4512431", "0.4510467", "0.45015278", "0.45010465", "0.44904062", "0.44846106", "0.44837093", "0.44833064", "0.44808254", "0.44744572", "0.44711104", "0.4467341", "0.44631624", "0.44601387", "0.44432953", "0.44429675", "0.44406828", "0.44325462", "0.4430373", "0.44210917", "0.44158998", "0.44054568", "0.4395404", "0.4389725", "0.43879524", "0.438532", "0.43818566", "0.43787646", "0.43728322", "0.43662602", "0.43662602", "0.435446", "0.4352696", "0.43515986", "0.43515986", "0.43424422", "0.43317586", "0.43314493", "0.43306354", "0.4317974", "0.43134823", "0.43124488", "0.4307769", "0.430141", "0.4297715", "0.42973027", "0.42967707", "0.42918643", "0.42844012", "0.42739874", "0.42647642", "0.4263458", "0.42628422", "0.42614558", "0.42614558", "0.42597923", "0.425519", "0.42472273", "0.42471695" ]
0.7905479
0
Validate validates this alertable event type
Validate проверяет этот тип события, из которого можно получить оповещение
func (m *AlertableEventType) Validate(formats strfmt.Registry) error { var res []error if err := m.validateCategory(formats); err != nil { res = append(res, err) } if err := m.validateScope(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (e EEventType) Validate() error {\n switch e {\n case EV_UNKNOWN,EV_BASE,EV_SCRIPT,EV_PERL,EV_BIN,EV_URL,EV_RESULT,EV_WORKER_DONE,EV_COMMAND,EV_REPLY,EV_ERROR:\n return nil\n default:\n return e // error condition - Error() can be invoked on it\n } // switch\n}", "func ValidateEvent(e interface{}) error {\n\tswitch v := e.(type) {\n\tcase *Event:\n\tcase *File:\n\tcase *Message:\n\tcase *RichMessage:\n\tcase *SystemMessage:\n\tcase Event:\n\tcase File:\n\tcase Message:\n\tcase RichMessage:\n\tcase SystemMessage:\n\tdefault:\n\t\treturn fmt.Errorf(\"event type %T not supported\", v)\n\t}\n\n\treturn nil\n}", "func ValidateEvent(e interface{}) error {\n\tswitch v := e.(type) {\n\tcase *Event:\n\tcase *File:\n\tcase *Message:\n\tcase *RichMessage:\n\tcase *SystemMessage:\n\tcase Event:\n\tcase File:\n\tcase Message:\n\tcase RichMessage:\n\tcase SystemMessage:\n\tdefault:\n\t\treturn fmt.Errorf(\"event type %T not supported\", v)\n\t}\n\n\treturn nil\n}", "func (m *Event) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateCommandPatch(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateType(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (v BlockEventType) Validate() error {\n\tif !(v == \"block_added\" || v == \"block_removed\") {\n\t\treturn fmt.Errorf(\"api: invalid BlockEventType value: %q\", v)\n\t}\n\treturn nil\n}", "func (e VulnEvent) Validate() error {\n\tif e.SourceName == \"\" {\n\t\treturn fmt.Errorf(\"must set SourceName in event\")\n\t}\n\tif e.Asset.IPAddress == \"\" && e.Asset.Hostname == \"\" {\n\t\treturn fmt.Errorf(\"must set IPAddress or Hostname in event\")\n\t}\n\treturn nil\n}", "func (payload *PutEventPayload) Validate() (err error) {\n\tif payload.Etype == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"etype\"))\n\t}\n\tif payload.Action == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"action\"))\n\t}\n\tif payload.From == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"from\"))\n\t}\n\treturn\n}", "func (payload *putEventPayload) Validate() (err error) {\n\tif payload.Etype == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"etype\"))\n\t}\n\tif payload.Action == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"action\"))\n\t}\n\tif payload.From == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"from\"))\n\t}\n\treturn\n}", "func (e Event) Validate() error {\n\tif e.Title == \"\" {\n\t\treturn errors.New(\"title cannot be empty\")\n\t}\n\tif e.Description == \"\" {\n\t\treturn errors.New(\"description cannot be empty\")\n\t}\n\treturn nil\n}", "func (m *Event) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateEventType(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateMedium(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateTimestamp(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (e *Event) Validate(tx *pop.Connection) (*validate.Errors, error) {\n\treturn validate.Validate(\n\t\t&validators.StringIsPresent{Field: e.Title, Name: \"Title\"},\n\t), nil\n}", "func (ut *EventPayload) Validate() (err error) {\n\tif ut.SportID == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`type`, \"sportId\"))\n\t}\n\tif ut.EventID == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`type`, \"eventId\"))\n\t}\n\tif ut.Name == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`type`, \"name\"))\n\t}\n\tif ut.SubTitle == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`type`, \"subTitle\"))\n\t}\n\tif ut.StartDtTm == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`type`, \"startDtTm\"))\n\t}\n\tif ut.EndDtTm == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`type`, \"endDtTm\"))\n\t}\n\tif ut.LocationID == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`type`, \"locationId\"))\n\t}\n\tif ut.TeamAdvanceMethod == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`type`, \"teamAdvanceMethod\"))\n\t}\n\treturn\n}", "func (event Event) Validate() (err error) {\n\treturn\n}", "func (e *Event) Validate() error {\n\tif e.Message == \"\" || e.MessageOffset == \"\" || e.Time == nil || e.Type == \"\" {\n\t\treturn errs.ErrMissingParameters\n\t}\n\treturn nil\n}", "func (t *OpenconfigSystem_System_Aaa_Authorization_Events_Event) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigSystem_System_Aaa_Authorization_Events_Event\"], t, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (t *OpenconfigSystem_System_Aaa_Accounting_Events_Event) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigSystem_System_Aaa_Accounting_Events_Event\"], t, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (s *OpenconfigOfficeAp_System_Aaa_Authorization_Events_Event) Validate() error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigOfficeAp_System_Aaa_Authorization_Events_Event\"], s); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (payload *PostEventPayload) Validate() (err error) {\n\tif payload.Etype == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"etype\"))\n\t}\n\tif payload.Action == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"action\"))\n\t}\n\tif payload.From == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"from\"))\n\t}\n\treturn\n}", "func (v ExemptionType) Validate() error {\n\tif !(v == \"dynamic\" || v == \"greater_or_equal\" || v == \"less_or_equal\") {\n\t\treturn fmt.Errorf(\"api: invalid ExemptionType value: %q\", v)\n\t}\n\treturn nil\n}", "func (payload *postEventPayload) Validate() (err error) {\n\tif payload.Etype == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"etype\"))\n\t}\n\tif payload.Action == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"action\"))\n\t}\n\tif payload.From == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"from\"))\n\t}\n\treturn\n}", "func (et EventType) Valid() bool {\n\tswitch et {\n\tcase Reopened, Closed, Renamed, Labeled, Unlabeled, CommentDeleted:\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}", "func (ut *eventPayload) Validate() (err error) {\n\tif ut.SportID == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`request`, \"sportId\"))\n\t}\n\tif ut.EventID == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`request`, \"eventId\"))\n\t}\n\tif ut.Name == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`request`, \"name\"))\n\t}\n\tif ut.SubTitle == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`request`, \"subTitle\"))\n\t}\n\tif ut.StartDtTm == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`request`, \"startDtTm\"))\n\t}\n\tif ut.EndDtTm == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`request`, \"endDtTm\"))\n\t}\n\tif ut.LocationID == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`request`, \"locationId\"))\n\t}\n\tif ut.TeamAdvanceMethod == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`request`, \"teamAdvanceMethod\"))\n\t}\n\treturn\n}", "func (s *OpenconfigOfficeAp_System_Aaa_Accounting_Events_Event) Validate() error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigOfficeAp_System_Aaa_Accounting_Events_Event\"], s); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m *EventDescription) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (ec EventContextV03) Validate() ValidationError {\n\terrors := map[string]error{}\n\n\t// type\n\t// Type: String\n\t// Constraints:\n\t// REQUIRED\n\t// MUST be a non-empty string\n\t// SHOULD be prefixed with a reverse-DNS name. The prefixed domain dictates the organization which defines the semantics of this event type.\n\teventType := strings.TrimSpace(ec.Type)\n\tif eventType == \"\" {\n\t\terrors[\"type\"] = fmt.Errorf(\"MUST be a non-empty string\")\n\t}\n\n\t// source\n\t// Type: URI-reference\n\t// Constraints:\n\t// REQUIRED\n\tsource := strings.TrimSpace(ec.Source.String())\n\tif source == \"\" {\n\t\terrors[\"source\"] = fmt.Errorf(\"REQUIRED\")\n\t}\n\n\t// subject\n\t// Type: String\n\t// Constraints:\n\t// OPTIONAL\n\t// MUST be a non-empty string\n\tif ec.Subject != nil {\n\t\tsubject := strings.TrimSpace(*ec.Subject)\n\t\tif subject == \"\" {\n\t\t\terrors[\"subject\"] = fmt.Errorf(\"if present, MUST be a non-empty string\")\n\t\t}\n\t}\n\n\t// id\n\t// Type: String\n\t// Constraints:\n\t// REQUIRED\n\t// MUST be a non-empty string\n\t// MUST be unique within the scope of the producer\n\tid := strings.TrimSpace(ec.ID)\n\tif id == \"\" {\n\t\terrors[\"id\"] = fmt.Errorf(\"MUST be a non-empty string\")\n\n\t\t// no way to test \"MUST be unique within the scope of the producer\"\n\t}\n\n\t// time\n\t// Type: Timestamp\n\t// Constraints:\n\t// OPTIONAL\n\t// If present, MUST adhere to the format specified in RFC 3339\n\t// --> no need to test this, no way to set the time without it being valid.\n\n\t// schemaurl\n\t// Type: URI\n\t// Constraints:\n\t// OPTIONAL\n\t// If present, MUST adhere to the format specified in RFC 3986\n\tif ec.SchemaURL != nil {\n\t\tschemaURL := strings.TrimSpace(ec.SchemaURL.String())\n\t\t// empty string is not RFC 3986 compatible.\n\t\tif schemaURL == \"\" {\n\t\t\terrors[\"schemaurl\"] = fmt.Errorf(\"if present, MUST adhere to the format specified in RFC 3986\")\n\t\t}\n\t}\n\n\t// datacontenttype\n\t// Type: String per RFC 2046\n\t// Constraints:\n\t// OPTIONAL\n\t// If present, MUST adhere to the format specified in RFC 2046\n\tif ec.DataContentType != nil {\n\t\tdataContentType := strings.TrimSpace(*ec.DataContentType)\n\t\tif dataContentType == \"\" {\n\t\t\terrors[\"datacontenttype\"] = fmt.Errorf(\"if present, MUST adhere to the format specified in RFC 2046\")\n\t\t} else {\n\t\t\t_, _, err := mime.ParseMediaType(dataContentType)\n\t\t\tif err != nil {\n\t\t\t\terrors[\"datacontenttype\"] = fmt.Errorf(\"if present, MUST adhere to the format specified in RFC 2046\")\n\t\t\t}\n\t\t}\n\t}\n\n\t// datacontentencoding\n\t// Type: String per RFC 2045 Section 6.1\n\t// Constraints:\n\t// The attribute MUST be set if the data attribute contains string-encoded binary data.\n\t// Otherwise the attribute MUST NOT be set.\n\t// If present, MUST adhere to RFC 2045 Section 6.1\n\tif ec.DataContentEncoding != nil {\n\t\tdataContentEncoding := strings.ToLower(strings.TrimSpace(*ec.DataContentEncoding))\n\t\tif dataContentEncoding != Base64 {\n\t\t\terrors[\"datacontentencoding\"] = fmt.Errorf(\"if present, MUST adhere to RFC 2045 Section 6.1\")\n\t\t}\n\t}\n\n\tif len(errors) > 0 {\n\t\treturn errors\n\t}\n\treturn nil\n}", "func IsValidEventType(input string) bool {\n\tfor _, eventType := range eventTypes {\n\t\tif input == eventType {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (o *GetPostListParams) validateEventType(formats strfmt.Registry) error {\n\n\tif err := validate.EnumCase(\"eventType\", \"query\", *o.EventType, []interface{}{\"lecture\", \"masterClass\", \"conference\", \"training\", \"webinars\"}, true); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (m *AlertSummary) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateResolvedAt(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateTriggeredAt(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (t *OpenconfigSystem_System_Aaa_Authorization_Events) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigSystem_System_Aaa_Authorization_Events\"], t, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func ValidateCreateEvent(payload *model.CreateEventReq) error {\n\tif payload == nil {\n\t\terr := errors.New(\"invalid payload\")\n\t\treturn err\n\t}\n\n\tif strings.TrimSpace(payload.Title) == \"\" {\n\t\terr := errors.New(\"invalid title\")\n\t\treturn err\n\t}\n\n\tif payload.LocationID == 0 {\n\t\terr := errors.New(\"invalid location id\")\n\t\treturn err\n\t}\n\n\tif payload.StartDate.UTC().IsZero() {\n\t\terr := errors.New(\"invalid time. time format is YYYY:MM:dd HH:mm:ss\")\n\t\treturn err\n\t}\n\n\tif payload.EndDate.UTC().IsZero() {\n\t\terr := errors.New(\"invalid time. time format is YYYY:MM:dd HH:mm:ss\")\n\t\treturn err\n\t}\n\n\tif len(payload.TicketID) == 0 {\n\t\terr := errors.New(\"invalid ticket id\")\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (b *Event) Validate() []error {\n\terrorsList := []error{}\n\tif b.VisitorID == \"\" {\n\t\terrorsList = append(errorsList, errors.New(\"Visitor ID should not by empty\"))\n\t}\n\tif b.Type != \"CONTEXT\" {\n\t\terrorsList = append(errorsList, fmt.Errorf(\"Type %s, is not handled\", b.Type))\n\t}\n\n\tcontextErrs := b.Data.Validate()\n\tfor _, e := range contextErrs {\n\t\terrorsList = append(errorsList, e)\n\t}\n\treturn errorsList\n}", "func (t *OpenconfigSystem_System_Aaa_Accounting_Events) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigSystem_System_Aaa_Accounting_Events\"], t, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (d *disallowAlert) Validate() error {\n\tif d.lister == nil {\n\t\treturn fmt.Errorf(\"missing alert lister\")\n\t}\n\treturn nil\n}", "func (m ApplicationType) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// value enum\n\tif err := m.validateApplicationTypeEnum(\"\", \"body\", m); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (h *HazardType) Validate(tx *pop.Connection) (*validate.Errors, error) {\n\terrors := validate.Validate(\n\t\t&validators.StringIsPresent{Name: \"Label\", Field: h.Label, Message: \"A label is required.\"},\n\t\t&validators.StringIsPresent{Name: \"Description\", Field: h.Description, Message: \"Please provide a brief description.\"},\n\t)\n\n\treturn errors, nil\n}", "func (tS *testAInfo) Validate(msg actor.Msg) bool {\n\tswitch m := msg[0].(type) {\n\tcase int:\n\t\tif m > 0 && m < 10 {\n\t\t\treturn true\n\t\t}\n\tdefault:\n\t\tfor _, datum := range tS.allowed {\n\t\t\tif reflect.TypeOf(msg[0]) ==\n\t\t\t\treflect.TypeOf(datum) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\t// Does not match a valid type\n\treturn false\n}", "func (a AddEventRequest) Validate() error {\n\tif err := v2.Validate(a); err != nil {\n\t\treturn err\n\t}\n\n\t// BaseReading has the skip(\"-\") validation annotation for BinaryReading and SimpleReading\n\t// Otherwise error will occur as only one of them exists\n\t// Therefore, need to validate the nested BinaryReading and SimpleReading struct here\n\tfor _, r := range a.Event.Readings {\n\t\tif err := r.Validate(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (m *EngineType) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (s *OpenconfigOfficeAp_System_Aaa_Authorization_Events) Validate() error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigOfficeAp_System_Aaa_Authorization_Events\"], s); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m *MeasurementType) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *EventStatusMessage) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (t *OpenconfigSystem_System_Aaa_Authorization_Events_Event_Config) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigSystem_System_Aaa_Authorization_Events_Event_Config\"], t, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (a AddEventRequest) Validate() error {\n\tif err := contracts.Validate(a); err != nil {\n\t\treturn err\n\t}\n\n\t// BaseReading has the skip(\"-\") validation annotation for BinaryReading and SimpleReading\n\t// Otherwise error will occur as only one of them exists\n\t// Therefore, need to validate the nested BinaryReading and SimpleReading struct here\n\tfor _, r := range a.Event.Readings {\n\t\tif err := r.Validate(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (b *EventHit) Validate() []error {\n\terrorsList := b.validateBase()\n\tif b.Action == \"\" {\n\t\terrorsList = append(errorsList, errors.New(\"Event Action should not by empty\"))\n\t}\n\treturn errorsList\n}", "func (payload *UpdateListenPayload) Validate() (err error) {\n\tif payload.Etype == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"etype\"))\n\t}\n\tif payload.Hookurl == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"hookurl\"))\n\t}\n\tif payload.From == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"from\"))\n\t}\n\treturn\n}", "func (m Alerts) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tfor i := 0; i < len(m); i++ {\n\n\t\t// value enum\n\t\tif err := m.validateAlertsItemsEnum(strconv.Itoa(i), \"body\", m[i]); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (payload *addListenPayload) Validate() (err error) {\n\tif payload.Etype == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"etype\"))\n\t}\n\tif payload.Hookurl == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"hookurl\"))\n\t}\n\tif payload.From == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"from\"))\n\t}\n\tif payload.Hookurl != nil {\n\t\tif ok := goa.ValidatePattern(`^https?://((\\w)+.?)+/(\\w+)$`, *payload.Hookurl); !ok {\n\t\t\terr = goa.MergeErrors(err, goa.InvalidPatternError(`raw.hookurl`, *payload.Hookurl, `^https?://((\\w)+.?)+/(\\w+)$`))\n\t\t}\n\t}\n\treturn\n}", "func (payload *updateListenPayload) Validate() (err error) {\n\tif payload.Etype == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"etype\"))\n\t}\n\tif payload.Hookurl == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"hookurl\"))\n\t}\n\tif payload.From == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"from\"))\n\t}\n\treturn\n}", "func (payload *AddListenPayload) Validate() (err error) {\n\tif payload.Etype == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"etype\"))\n\t}\n\tif payload.Hookurl == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"hookurl\"))\n\t}\n\tif payload.From == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"from\"))\n\t}\n\tif ok := goa.ValidatePattern(`^https?://((\\w)+.?)+/(\\w+)$`, payload.Hookurl); !ok {\n\t\terr = goa.MergeErrors(err, goa.InvalidPatternError(`raw.hookurl`, payload.Hookurl, `^https?://((\\w)+.?)+/(\\w+)$`))\n\t}\n\treturn\n}", "func (m *AuditLogEvent) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateIdentity(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateRequestContext(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateResults(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (s *OpenconfigOfficeAp_System_Aaa_Accounting_Events) Validate() error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigOfficeAp_System_Aaa_Accounting_Events\"], s); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m *AlertAllOf1Body) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateContexts(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateType(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (s *OpenconfigOfficeAp_System_Aaa_Authorization_Events_Event_Config) Validate() error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigOfficeAp_System_Aaa_Authorization_Events_Event_Config\"], s); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (payload *CreateOfferPayload) Validate() (err error) {\n\n\treturn\n}", "func (m Type) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (o *PostAPIV2EventsBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.validateAttributes(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateEntityID(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := o.validateEvent(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (t *OpenconfigSystem_System_Aaa_Accounting_Events_Event_Config) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigSystem_System_Aaa_Accounting_Events_Event_Config\"], t, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (b EmployeeCreatedEvent) ValidateEmployeeCreatedEvent() error {\n\tvar validate *validator.Validate\n\tvalidate = validator.New()\n\terr := validate.Struct(b)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn err\n}", "func (t *OpenconfigSystem_System_Aaa_Authorization_Events_Event_State) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigSystem_System_Aaa_Authorization_Events_Event_State\"], t, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (o *GetEventsOKBody) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := o.validateEvents(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func IsValidEventer(eventer string) bool {\n\tswitch eventer {\n\tcase LogFile.String():\n\t\treturn true\n\tcase Journald.String():\n\t\treturn true\n\tcase Memory.String():\n\t\treturn true\n\tcase Null.String():\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}", "func (m BandSelectionType) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// value enum\n\tif err := m.validateBandSelectionTypeEnum(\"\", \"body\", m); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (e Event) Check() error {\n\tif len(e.Title) == 0 {\n\t\treturn fmt.Errorf(\"statsd.Event title is required\")\n\t}\n\tif len(e.Text) == 0 {\n\t\treturn fmt.Errorf(\"statsd.Event text is required\")\n\t}\n\treturn nil\n}", "func (vt VolumeType) Validate() error {\n\tswitch string(vt) {\n\tcase \"local\", \"instance\", \"\":\n\t\treturn nil\n\tdefault:\n\t\treturn maskAny(errgo.WithCausef(nil, ValidationError, \"invalid volume type '%s'\", string(vt)))\n\t}\n}", "func (m LolCollectionsCollectionsSummonerBackdropType) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// value enum\n\tif err := m.validateLolCollectionsCollectionsSummonerBackdropTypeEnum(\"\", \"body\", m); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m *DeviceEvent) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateAction(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateDevice(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m *LolPlayerLevelUpPlayerLevelUpEvent) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *SecurityArmStateEvent) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateArmState(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateOptionalArguments(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (payload *acceptOfferPayload) Validate() (err error) {\n\tif payload.OfferID == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"offer_id\"))\n\t}\n\treturn\n}", "func (m ModelErrorDatumType) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// value enum\n\tif err := m.validateModelErrorDatumTypeEnum(\"\", \"body\", m); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m *CreateSignal) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateClass(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateDescription(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateName(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateValueType(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (s *OpenconfigOfficeAp_System_Aaa_Authorization_Events_Event_State) Validate() error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigOfficeAp_System_Aaa_Authorization_Events_Event_State\"], s); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (t *OpenconfigSystem_System_Aaa_Accounting_Events_Event_State) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigSystem_System_Aaa_Accounting_Events_Event_State\"], t, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (wce WaitingChaosEvent) AsValidationFailedChaosEvent() (*ValidationFailedChaosEvent, bool) {\n\treturn nil, false\n}", "func (f *EventFilter) Validate() error {\n\tif err := ValidateName(f.Name); err != nil {\n\t\treturn errors.New(\"filter name \" + err.Error())\n\t}\n\n\tif found := utilstrings.InArray(f.Action, EventFilterAllActions); !found {\n\t\treturn fmt.Errorf(\"action '%s' is not valid\", f.Action)\n\t}\n\n\tif len(f.Expressions) == 0 {\n\t\treturn errors.New(\"filter must have one or more expressions\")\n\t}\n\n\tif err := js.ParseExpressions(f.Expressions); err != nil {\n\t\treturn err\n\t}\n\n\tif f.Namespace == \"\" {\n\t\treturn errors.New(\"namespace must be set\")\n\t}\n\n\treturn nil\n}", "func (e NetEvent) Validate() (bool, error) {\n\tif !e.isValidated {\n\t\tif e.NetDevice == \"\" {\n\t\t\treturn false, fmt.Errorf(\"source device for event not specified\")\n\t\t}\n\t}\n\treturn true, nil\n}", "func (m *ConsoleLogEvent) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with RealtimeBuildEvent\n\tif err := m.RealtimeBuildEvent.Validate(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateStepRecordID(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateTimelineID(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateTimelineRecordID(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (payload *createOfferPayload) Validate() (err error) {\n\tif payload.ItemID == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"item_id\"))\n\t}\n\tif payload.Price == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"price\"))\n\t}\n\tif payload.StartAt == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"start_at\"))\n\t}\n\tif payload.EndAt == nil {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, \"end_at\"))\n\t}\n\treturn\n}", "func (m *AlertCount) Validate(formats strfmt.Registry) error {\n\treturn nil\n}", "func (m *IncidentUrgencyType) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateType(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateUrgency(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m *UpsertEventRequest_Option) Validate() error {\n\tif m == nil {\n\t\treturn nil\n\t}\n\n\tif utf8.RuneCountInString(m.GetContent()) < 1 {\n\t\treturn UpsertEventRequest_OptionValidationError{\n\t\t\tfield: \"Content\",\n\t\t\treason: \"value length must be at least 1 runes\",\n\t\t}\n\t}\n\n\treturn nil\n}", "func (s *OpenconfigOfficeAp_System_Aaa_Accounting_Events_Event_Config) Validate() error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigOfficeAp_System_Aaa_Accounting_Events_Event_Config\"], s); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m *ModelsMultipleEventLevel) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateEventLevel(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (sel SelElitism) Validate() error {\n\treturn nil\n}", "func (self *ExceptionDef) Validate() error {\n\tif self.Type == \"\" {\n\t\treturn fmt.Errorf(\"ExceptionDef.type is missing but is a required field\")\n\t} else {\n\t\tval := Validate(RdlSchema(), \"String\", self.Type)\n\t\tif !val.Valid {\n\t\t\treturn fmt.Errorf(\"ExceptionDef.type does not contain a valid String (%v)\", val.Error)\n\t\t}\n\t}\n\tif self.Comment != \"\" {\n\t\tval := Validate(RdlSchema(), \"String\", self.Comment)\n\t\tif !val.Valid {\n\t\t\treturn fmt.Errorf(\"ExceptionDef.comment does not contain a valid String (%v)\", val.Error)\n\t\t}\n\t}\n\treturn nil\n}", "func (sce StartedChaosEvent) AsValidationFailedChaosEvent() (*ValidationFailedChaosEvent, bool) {\n\treturn nil, false\n}", "func (sce StoppedChaosEvent) AsValidationFailedChaosEvent() (*ValidationFailedChaosEvent, bool) {\n\treturn nil, false\n}", "func (ut *SportPayload) Validate() (err error) {\n\tif ut.Name == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`type`, \"name\"))\n\t}\n\n\tif ut.GameTerm == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`type`, \"gameTerm\"))\n\t}\n\tif ut.EventTerm == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`type`, \"eventTerm\"))\n\t}\n\treturn\n}", "func (v SignatureType) Validate() error {\n\tif !(v == \"ecdsa\" || v == \"ecdsa_recovery\" || v == \"ed25519\" || v == \"schnorr_1\" || v == \"schnorr_poseidon\") {\n\t\treturn fmt.Errorf(\"api: invalid SignatureType value: %q\", v)\n\t}\n\treturn nil\n}", "func (m ConsistentType) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// value enum\n\tif err := m.validateConsistentTypeEnum(\"\", \"body\", m); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m BrowserType) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// value enum\n\tif err := m.validateBrowserTypeEnum(\"\", \"body\", m); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (me TxsdCounterSimpleContentExtensionType) IsEvent() bool { return me.String() == \"event\" }", "func (s *OpenconfigOfficeAp_System_Aaa_Accounting_Events_Event_State) Validate() error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigOfficeAp_System_Aaa_Accounting_Events_Event_State\"], s); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m Type5) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// value enum\n\tif err := m.validateType5Enum(\"\", \"body\", m); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m ValidationStatus) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// value enum\n\tif err := m.validateValidationStatusEnum(\"\", \"body\", m); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m LocationType) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// value enum\n\tif err := m.validateLocationTypeEnum(\"\", \"body\", m); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m APIStepType) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// value enum\n\tif err := m.validateAPIStepTypeEnum(\"\", \"body\", m); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m *DeviceStateChangedEvent) Validate() error {\n\tif err := m.Device.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\tif m.Device == nil {\n\t\treturn oops.BadRequest(\"field 'device' is required\")\n\t}\n\treturn nil\n}", "func (a AfterRule) Validate(t interface{}) error {\n\tend, ok := t.(*timestamppb.Timestamp)\n\tif !ok {\n\t\treturn fmt.Errorf(\"end is not a timestamp\")\n\t}\n\n\tif a.Timestamp.AsTime().After(end.AsTime()) {\n\t\treturn fmt.Errorf(\"start timestamp must be before end\")\n\t}\n\n\treturn nil\n}", "func (time CueTime) Validate() bool {\n\tret := true\n\tif ret == true && time.up != (Time{}) {\n\t\tret = time.up.Validate()\n\t}\n\n\tif ret == true && time.down != (Time{}) {\n\t\tret = time.down.Validate()\n\t}\n\n\tif ret == true && time.delay != (Delay{}) {\n\t\tret = time.delay.Validate()\n\t}\n\n\tif ret == true && time.follow != (Follow{}) {\n\t\tret = time.follow.Validate()\n\t}\n\n\tif ret != true {\n\t\tlog.Println(\"Failed to validate time '\" + time.value + \"'\")\n\t}\n\treturn ret\n}" ]
[ "0.6919185", "0.6831296", "0.6831296", "0.65781534", "0.65171707", "0.6481075", "0.64781845", "0.64412445", "0.6433073", "0.6406382", "0.639938", "0.6387393", "0.6375404", "0.63410616", "0.63037986", "0.6226541", "0.6155873", "0.61534274", "0.61494", "0.6147093", "0.6144208", "0.60558426", "0.60365146", "0.6020375", "0.5914198", "0.58969736", "0.58957916", "0.58259696", "0.5811151", "0.58043563", "0.57814944", "0.57402503", "0.5716023", "0.5695312", "0.56820434", "0.5679717", "0.56751966", "0.56704205", "0.56648463", "0.5650474", "0.5647575", "0.562189", "0.56136173", "0.56106186", "0.5607722", "0.560521", "0.55922616", "0.557814", "0.55774903", "0.5566394", "0.55596226", "0.55493546", "0.5517668", "0.5513417", "0.5504277", "0.55035394", "0.54911065", "0.5486871", "0.5486761", "0.5486118", "0.5469829", "0.54560554", "0.5441268", "0.5433927", "0.54295045", "0.5423564", "0.5420101", "0.5420061", "0.5419002", "0.54085565", "0.5407436", "0.54004234", "0.5397685", "0.53965414", "0.5387045", "0.5386236", "0.53794", "0.5378181", "0.53741086", "0.5373219", "0.53506064", "0.53421277", "0.5340781", "0.5329012", "0.5326294", "0.5304115", "0.5301426", "0.5301303", "0.52934515", "0.52824825", "0.52782834", "0.52733904", "0.52532923", "0.5249731", "0.5249136", "0.52488047", "0.5237325", "0.52301997", "0.5229672", "0.5223393" ]
0.7226454
0
IsEmpty checks whether taskConfig has all it's fields declared properly or not.
IsEmpty проверяет, объявлены ли все поля taskConfig правильно или нет.
func (t TaskConfig) IsEmpty() bool { return t == TaskConfig{} || t.DbURL == "" || t.DbType == "" }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (t TaskConfig) IsNotEmpty() bool {\n\treturn !t.IsEmpty()\n}", "func (mgc Config) Empty() bool {\n\treturn mgc.AuthDB == \"\" &&\n\t\tmgc.DB == \"\" &&\n\t\tmgc.User == \"\" &&\n\t\tmgc.Password == \"\" &&\n\t\tmgc.Host == \"\"\n}", "func (c *ProjectConfig) NotEmpty() bool {\n\tif err := c.ValidateConfigVersion(); err != nil {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func TestCloudConfigEmpty(t *testing.T) {\n\tcfg, err := NewCloudConfig([]byte{})\n\tif err != nil {\n\t\tt.Fatalf(\"Encountered unexpected error :%v\", err)\n\t}\n\n\tkeys := cfg.SSH_Authorized_Keys\n\tif len(keys) != 0 {\n\t\tt.Error(\"Parsed incorrect number of SSH keys\")\n\t}\n\n\tif cfg.Coreos.Etcd.Discovery_URL != \"\" {\n\t\tt.Error(\"Parsed incorrect value of discovery url\")\n\t}\n\n\tif cfg.Coreos.Fleet.Autostart {\n\t\tt.Error(\"Expected AutostartFleet not to be defined\")\n\t}\n\n\tif len(cfg.Write_Files) != 0 {\n\t\tt.Error(\"Expected zero Write_Files\")\n\t}\n}", "func (e ExternalRubyPackageConfigV1) IsEmpty() bool {\n\treturn len(e.Except) == 0 && len(e.Override) == 0\n}", "func (e ExternalTypesConfigV1) IsEmpty() bool {\n\treturn len(e.Include) == 0\n}", "func (config *V1RegistriesConf) Nonempty() bool {\n\treturn (len(config.V1TOMLConfig.Search.Registries) != 0 ||\n\t\tlen(config.V1TOMLConfig.Insecure.Registries) != 0 ||\n\t\tlen(config.V1TOMLConfig.Block.Registries) != 0)\n}", "func (o *AutoscalerScaleDownConfig) Empty() bool {\n\treturn o == nil || o.bitmap_ == 0\n}", "func (e ExternalManagedConfigV1) IsEmpty() bool {\n\treturn e.CcEnableArenas == nil &&\n\t\te.JavaMultipleFiles == nil &&\n\t\te.JavaStringCheckUtf8 == nil &&\n\t\te.JavaPackagePrefix.IsEmpty() &&\n\t\te.CsharpNamespace.IsEmpty() &&\n\t\te.CsharpNamespace.IsEmpty() &&\n\t\te.OptimizeFor.IsEmpty() &&\n\t\te.GoPackagePrefix.IsEmpty() &&\n\t\te.ObjcClassPrefix.IsEmpty() &&\n\t\te.RubyPackage.IsEmpty() &&\n\t\tlen(e.Override) == 0\n}", "func isEmpty(c yaml.Constraint) bool {\n\treturn len(c.Include) == 0 && len(c.Exclude) == 0\n}", "func (r SoftwareConfigPage) IsEmpty() (bool, error) {\n\tis, err := ExtractSoftwareConfigs(r)\n\treturn len(is) == 0, err\n}", "func (r *ScalingConfigOrT[_]) IsEmpty() bool {\n\treturn r.ScalingConfig.IsEmpty() && r.Value == nil\n}", "func (c *ConfigurationFile) CheckEmpty() error {\n\tif c.Servers == nil || len(c.Servers) <= 0 || c.Roles == nil || len(c.Roles) <= 0 {\n\t\treturn errors.New(\"kishell is not configured. Use configure option before searching\")\n\t}\n\treturn nil\n}", "func (r *RangeConfig) IsEmpty() bool {\n\treturn r.Min == nil && r.Max == nil && r.SpotFrom == nil\n}", "func (r *RangeConfig) IsEmpty() bool {\n\treturn r.Min == nil && r.Max == nil && r.SpotFrom == nil\n}", "func (wq *TaskQueue) IsNotEmpty() bool {\n\treturn wq.totalTasks > 0\n}", "func (a *AdvancedScalingConfig[_]) IsEmpty() bool {\n\treturn a.Cooldown.IsEmpty() && a.Value == nil\n}", "func (config *V2RegistriesConf) Nonempty() bool {\n\treturn (len(config.Registries) != 0 ||\n\t\tlen(config.UnqualifiedSearchRegistries) != 0)\n}", "func (i ignore) HasConfig() bool {\n\treturn len(i) != 0\n}", "func (e ExternalOptimizeForConfigV1) IsEmpty() bool {\n\treturn e.Default == \"\" &&\n\t\tlen(e.Except) == 0 &&\n\t\tlen(e.Override) == 0\n}", "func (tl TaskList) IsEmpty() bool {\n\treturn tl.Value == nil || len(*tl.Value) == 0\n}", "func (tt TargetTable) IsEmpty() bool {\n\treturn tt.Task == \"\" // now we treat it as empty if no task name specified.\n}", "func (e ExternalCsharpNamespaceConfigV1) IsEmpty() bool {\n\treturn len(e.Except) == 0 &&\n\t\tlen(e.Override) == 0\n}", "func (clr ConfigurationListResult) IsEmpty() bool {\n return clr.Value == nil || len(*clr.Value) == 0\n }", "func (v *ConfigurationParams) IsNil() bool { return v == nil }", "func (o *FormField) HasConfig() bool {\n\tif o != nil && o.Config != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (tc *TaskConfig) Validate() error {\n\tif tc == nil {\n\t\treturn errors.New(\"unable to get task setup because task config is nil\")\n\t}\n\tif tc.Task == nil {\n\t\treturn errors.New(\"unable to get task setup because task is nil\")\n\t}\n\tif tc.Task.Version == \"\" {\n\t\treturn errors.New(\"task has no version\")\n\t}\n\tif tc.Project == nil {\n\t\treturn errors.New(\"project is nil\")\n\t}\n\treturn nil\n}", "func (b *AutoscalerScaleDownConfigBuilder) Empty() bool {\n\treturn b == nil || b.bitmap_ == 0\n}", "func (etlr ExportTaskListResult) IsEmpty() bool {\n\treturn etlr.Value == nil || len(*etlr.Value) == 0\n}", "func (a Config) IsZero() bool {\n\treturn a.AccessKeyID == \"\" || a.SecretAccessKey == \"\"\n}", "func isConfigFieldFilled(configPTR *Config, field string) bool {\n\tvalue := fmt.Sprintf(\"%v\", reflect.ValueOf(configPTR).Elem().FieldByName(field))\n\tif value == \"\" || value == \"false\" {\n\t\tsechubUtil.LogError(missingFieldHelpTexts[field])\n\t\treturn false\n\t}\n\treturn true\n}", "func isSessionAffinityConfigEmpty(sessionAffinityConfig *corev1.SessionAffinityConfig) bool {\n\treturn sessionAffinityConfig.ClientIP == nil || sessionAffinityConfig.ClientIP.TimeoutSeconds == nil\n}", "func (t *DataProcessorTask) HasConfigFiles() bool {\n\treturn t.Has(ConfigFiles)\n}", "func (o *WorkflowWorkflowDefinitionAllOf) HasTasks() bool {\n\tif o != nil && o.Tasks != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (o *IamLdapConfigParamsAllOf) HasConfigHost() bool {\n\tif o != nil && o.ConfigHost != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (mcDiff *machineConfigDiff) isEmpty() bool {\n\temptyDiff := machineConfigDiff{}\n\treturn reflect.DeepEqual(mcDiff, &emptyDiff)\n}", "func (o *V0037JobProperties) HasTasks() bool {\n\tif o != nil && o.Tasks != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (c *shortNameAliasConf) nonempty() bool {\n\tcopy := *c // A shallow copy\n\tif copy.Aliases != nil && len(copy.Aliases) == 0 {\n\t\tcopy.Aliases = nil\n\t}\n\treturn !reflect.DeepEqual(copy, shortNameAliasConf{})\n}", "func EmptyConfig(workingDir string) Config {\n\tlog.Printf(\"Creating empty config\\n\")\n\n\tcfg := Config{\n\t\tworkingDir: workingDir,\n\t}\n\n\tcfg.ServiceMap = make(map[string]*services.ServiceConfig)\n\tcfg.GroupMap = make(map[string]*services.ServiceGroupConfig)\n\n\treturn cfg\n}", "func (c *Config) IsEmpty(key string) bool {\n\tval, err := c.get(key)\n\tif err != nil {\n\t\treturn true\n\t}\n\tif !val.IsValid() {\n\t\treturn false\n\t}\n\treturn val.IsZero()\n}", "func (l *AutoscalerScaleDownConfigList) Empty() bool {\n\treturn l == nil || len(l.items) == 0\n}", "func (itlr ImportTaskListResult) IsEmpty() bool {\n\treturn itlr.Value == nil || len(*itlr.Value) == 0\n}", "func TestConvertToTaskDefinitionLaunchTypeEmpty(t *testing.T) {\n\tcontainerConfig := adapter.ContainerConfig{}\n\n\ttaskDefinition, err := convertToTaskDefinitionForTest(t, []adapter.ContainerConfig{containerConfig}, \"\", \"\", nil, nil)\n\tassert.NoError(t, err, \"Unexpected error converting Task Definition\")\n\tif len(taskDefinition.RequiresCompatibilities) > 0 {\n\t\tt.Error(\"Did not expect RequiresCompatibilities to be set\")\n\t}\n}", "func (b *Builder) Empty() bool { return len(b.keyHashes) == 0 }", "func (ssh *SSH) IsEmpty() bool {\n\tif len(ssh.PrivateKeyPEM) == 0 || len(ssh.PublicKeyPEM) == 0 {\n\t\treturn true\n\t}\n\treturn false\n\n}", "func (g *Google) ValidConfig() bool {\n\treturn g.AccountFileJSON != \"\" && g.ProjectID != \"\" && g.Zone != \"\"\n}", "func (config *Config) IsConfigReady() bool {\n\tif config.APIEndpoint == \"\" ||\n\t\tconfig.Certificate.Cert == \"\" ||\n\t\tconfig.Certificate.Key == \"\" ||\n\t\tconfig.Certificate.Ca == \"\" {\n\t\treturn false\n\t}\n\treturn true\n}", "func (c Config) IsZero() bool {\n\treturn c.Token == \"\" || c.Email == \"\"\n}", "func (t *Task) Valid() error {\n\tif t.Name == \"\" || t.Action == \"\" || t.ScheduledTime == \"\" {\n\t\treturn fmt.Errorf(\"name, action, and scheduled time required\")\n\t}\n\n\treturn nil\n}", "func (s *layoutStack) assertNotEmpty() {\n\t// Layout stack should never be empty.\n\tif len(s.data) == 0 {\n\t\tpanic(\"layout stack is empty\")\n\t}\n}", "func (o *Tasks) HasTasks() bool {\n\tif o != nil && o.Tasks != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (o *V0037JobProperties) HasTasksPerCore() bool {\n\tif o != nil && o.TasksPerCore != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func TestDirBlank(t *testing.T) {\n\tstack := StackConfig{}\n\tactual := stack.GetDir()\n\n\tassert.NotNil(t, actual, \"Unexpected config dir\")\n\tassert.NotEmpty(t, actual, \"Unexpected config dir\")\n}", "func (t TaskConfig) validate() error {\n\tvar err error\n\tif err = t.Platform.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"platform\": %w`, err)\n\t}\n\tif err = t.Count.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"count\": %w`, err)\n\t}\n\tif err = t.ExecuteCommand.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"exec\": %w`, err)\n\t}\n\tif err = t.Storage.validate(); err != nil {\n\t\treturn fmt.Errorf(`validate \"storage\": %w`, err)\n\t}\n\tfor n, v := range t.Variables {\n\t\tif err := v.validate(); err != nil {\n\t\t\treturn fmt.Errorf(`validate %q \"variables\": %w`, n, err)\n\t\t}\n\t}\n\tfor _, v := range t.Secrets {\n\t\tif err := v.validate(); err != nil {\n\t\t\treturn fmt.Errorf(`validate \"secret\": %w`, err)\n\t\t}\n\t}\n\tif t.EnvFile != nil {\n\t\tenvFile := aws.StringValue(t.EnvFile)\n\t\tif filepath.Ext(envFile) != envFileExt {\n\t\t\treturn fmt.Errorf(\"environment file %s must have a %s file extension\", envFile, envFileExt)\n\t\t}\n\t}\n\treturn nil\n}", "func (o *ViewProjectActivePages) HasTasks() bool {\n\tif o != nil && o.Tasks != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (e ExternalJavaPackagePrefixConfigV1) IsEmpty() bool {\n\treturn e.Default == \"\" &&\n\t\tlen(e.Except) == 0 &&\n\t\tlen(e.Override) == 0\n}", "func (o *InlineResponse20075Stats) HasTasks() bool {\n\tif o != nil && o.Tasks != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (p *AssetProperties) Empty() bool {\n\tif p.RenderAs.Value != nil {\n\t\treturn false\n\t}\n\n\tif p.Vector.preserveVectorData != nil {\n\t\treturn false\n\t}\n\n\tif p.Compression.Value != nil {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func HasConfigOut() bool {\n\tconfigOut := ConfigOut()\n\treturn strings.TrimSpace(configOut) != \"\"\n}", "func (o *WorkflowBuildTaskMeta) HasTaskList() bool {\n\tif o != nil && o.TaskList != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func isSimpleTask(task *TaskExpr) bool {\n\t// If Module or Args are zero values, task is a compound\n\t// task with a non-nil Body, as determined by the parser.\n\tif task.Module == \"\" {\n\t\treturn false\n\t}\n\tif task.Args == nil {\n\t\treturn false\n\t}\n\treturn true\n}", "func (o Args) Empty() bool { return o.Len() == 0 }", "func (t *DataProcessorTask) HasConfigDirs() bool {\n\treturn t.Has(ConfigDirs)\n}", "func (o *VirtualizationVmwareVirtualMachineAllOf) HasConfigName() bool {\n\tif o != nil && o.ConfigName != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (o *NetworkElementSummaryAllOf) HasConfModTs() bool {\n\tif o != nil && o.ConfModTs != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (r EnvironmentHooks) HasTasks() bool {\n\treturn r.Init.HasTasks() ||\n\t\tr.Create.HasTasks() ||\n\t\tr.Install.HasTasks() ||\n\t\tr.Deploy.HasTasks() ||\n\t\tr.Destroy.HasTasks()\n}", "func (a *Azure) ValidConfig() bool {\n\treturn a.SubscriptionID != \"\" && a.ClientID != \"\" && a.ClientSecret != \"\" && a.TenantID != \"\"\n}", "func AllowEmpty(c *commitConfig) { c.allowEmpty = true }", "func (c *Config) IsValid() bool {\n\tif len(c.GithubAccessToken) != 40 {\n\t\treturn false\n\t}\n\tif len(c.GitName) == 0 {\n\t\treturn false\n\t}\n\tif len(c.GitEmail) == 0 {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func (tnc TransactionNodeCollection) IsEmpty() bool {\n\treturn tnc.Value == nil || len(*tnc.Value) == 0\n}", "func (u *NativeServiceDiscoveryUsage) Empty() bool {\n\treturn u.Basic.Size() == 0 && u.Checks.Size() == 0\n}", "func (e ExternalGoPackagePrefixConfigV1) IsEmpty() bool {\n\treturn e.Default == \"\" &&\n\t\tlen(e.Except) == 0 &&\n\t\tlen(e.Override) == 0\n}", "func (ai *AppInfo) IsEmpty() bool {\n\tif ai.timestamp == 0 {\n\t\treturn true\n\t}\n\treturn false\n}", "func (config *Config) IsConfigReadyBrownfield() bool {\n\tif config.APIEndpoint == \"\" ||\n\t\tconfig.BrownfieldToken == \"\" {\n\t\treturn false\n\t}\n\treturn true\n}", "func (ral RegistrationAssignmentList) IsEmpty() bool {\n\treturn ral.Value == nil || len(*ral.Value) == 0\n}", "func (qs *QueueScaling) IsEmpty() bool {\n\treturn qs.AcceptableLatency == nil && qs.AvgProcessingTime == nil && qs.Cooldown.IsEmpty()\n}", "func (o *IaasMostRunTasksAllOf) HasTaskName() bool {\n\tif o != nil && o.TaskName != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (args *Args) isEmpty() bool {\n\treturn len(args.items) == 0\n}", "func checkAllOrNoneSet(config map[string]string, items []string) (bool, error) {\n\tvar length = 0\n\tfor i := 0; i < len(items); i++ {\n\t\tif val, exists := config[items[i]]; exists {\n\t\t\tlength += len(val)\n\t\t} else {\n\t\t\treturn false, fmt.Errorf(\"Config Item %s does not exist\", items[i])\n\t\t}\n\t}\n\tif length > 0 {\n\t\tfor i := 0; i < len(items); i++ {\n\t\t\tif len(config[items[i]]) == 0 {\n\t\t\t\treturn false, fmt.Errorf(\"All of %s must be set when one is set. %s is not set\", strings.Join(items, \",\"), items[i])\n\t\t\t}\n\t\t}\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}", "func (event *mappingEvent) isEmpty() bool {\n\treturn event.pending == 0\n}", "func (b *MonitoringStackResourcesBuilder) Empty() bool {\n\treturn b == nil || b.bitmap_ == 0\n}", "func (a *Config) HasUserData() bool {\n\treturn len(a.Bucket) > 0 && len(a.Key) > 0\n}", "func (s *SyncStatus) Empty() bool {\n\treturn s == nil || (s.LastDownload == nil && s.LastUpload == nil)\n}", "func (s *Section) IsEmpty() bool {\n\treturn (s.items == nil || len(s.items) == 0) && (s.sections == nil || len(s.sections) == 0)\n}", "func (l DeliveryResourceLocations) Empty() bool {\n\treturn l.Account == \"\" && len(l.Regions) == 0\n}", "func (object *Object) Empty() bool {\n\treturn object.properties.Empty()\n}", "func (o *IaasMostRunTasksAllOf) HasTaskType() bool {\n\tif o != nil && o.TaskType != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (a *AdvancedCount) IsEmpty() bool {\n\treturn a.Range == nil && a.CPU == nil && a.Memory == nil &&\n\t\ta.Requests == nil && a.ResponseTime == nil && a.Spot == nil\n}", "func (c *Config) valid() error {\n\tif c.Score == nil {\n\t\treturn errors.New(\"Expected Score to not be nil\")\n\t}\n\tif c.Sampler == nil {\n\t\treturn errors.New(\"Expected Sampler to not be nil\")\n\t}\n\treturn nil\n}", "func Empty(t Testing, v interface{}, formatAndArgs ...interface{}) bool {\n\tif !types.IsEmpty(v) {\n\t\treturn Fail(t,\n\t\t\tpretty.Sprintf(\"Expected to be empty, but got: %# v\", v),\n\t\t\tformatAndArgs...)\n\t}\n\n\treturn true\n}", "func (t *RbTree[K, V]) Empty() bool {\n\treturn t.size == 0\n}", "func (o *SummaryResponse) HasTasks() bool {\n\tif o != nil && o.Tasks != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (o *ViewCustomFieldTask) HasTask() bool {\n\tif o != nil && o.Task != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (mod Mod) Empty() bool {\n\tif (len(mod.Changed) + len(mod.Deleted) + len(mod.Added)) > 0 {\n\t\treturn false\n\t}\n\treturn true\n}", "func (this ActivityStreamsImageProperty) Empty() bool {\n\treturn this.Len() == 0\n}", "func (s *StateObject) empty() bool {\n\treturn len(s.data.UTXOs) <= 0\n}", "func (xcto XContentTypeOptions) Empty() bool {\n\treturn xcto.String() == \"\"\n}", "func (b *Builder) Empty() bool { return b.sz == 0 }", "func validateConfig() {\n\tif viper.Get(\"project\") == \"\" {\n\t\tlog.Fatal(\"Error: --project is required\")\n\t}\n\tif viper.Get(\"region\") == \"\" {\n\t\tlog.Fatal(\"Error: --region is required, e.g. us-west1\")\n\t}\n}", "func (o *V0037JobProperties) HasTasksPerNode() bool {\n\tif o != nil && o.TasksPerNode != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}" ]
[ "0.73253053", "0.6467472", "0.6240094", "0.6214254", "0.61029774", "0.6024805", "0.5966716", "0.5957692", "0.5953141", "0.5941145", "0.59353834", "0.58855903", "0.5875147", "0.5855564", "0.5855564", "0.58349985", "0.5823399", "0.58164424", "0.5781391", "0.5777357", "0.577365", "0.5759087", "0.5745837", "0.5700413", "0.5699007", "0.5683475", "0.5664133", "0.56469065", "0.56231964", "0.5621932", "0.5590819", "0.55790275", "0.5577578", "0.5545498", "0.55404043", "0.55210114", "0.55172765", "0.5514327", "0.5506594", "0.5426303", "0.5408387", "0.54041624", "0.53807676", "0.5372511", "0.5370194", "0.5344239", "0.53397405", "0.5334671", "0.5326873", "0.53087115", "0.53009886", "0.52936643", "0.5291359", "0.52913135", "0.5290736", "0.52872497", "0.5286032", "0.5283267", "0.5274904", "0.52618134", "0.52608216", "0.52535284", "0.5239507", "0.5236854", "0.522748", "0.52246135", "0.5212275", "0.5210196", "0.5209164", "0.51973474", "0.5193394", "0.51905733", "0.5189518", "0.51894045", "0.51876885", "0.5185803", "0.5183389", "0.51808923", "0.5180434", "0.5179586", "0.5176459", "0.5171237", "0.51712257", "0.5169952", "0.51680046", "0.5162192", "0.5143057", "0.51337373", "0.5129829", "0.5129402", "0.51275235", "0.51274294", "0.5123598", "0.5122326", "0.51212865", "0.512023", "0.5119355", "0.51143175", "0.5110879", "0.5109674" ]
0.74826217
0
TaskConfiguration returns configuration properties related to task server, which includes db details.
TaskConfiguration возвращает свойства конфигурации, связанные с сервером задач, включая сведения о базе данных.
func TaskConfiguration() TaskConfig { return conf.TaskConfig }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (j *AuroraJob) TaskConfig() *aurora.TaskConfig {\n\treturn j.jobConfig.TaskConfig\n}", "func (task *QueueTask) GetConfig() *TaskConfig {\n\treturn &TaskConfig{\n\t\tTaskID: task.taskID,\n\t\tTaskType: task.TaskType,\n\t\tIsRun: task.IsRun,\n\t\tHandler: task.handler,\n\t\tDueTime: task.DueTime,\n\t\tInterval: 0,\n\t\tExpress: \"\",\n\t\tTaskData: task.TaskData,\n\t}\n}", "func (m *BusinessScenarioPlanner) GetTaskConfiguration()(PlannerTaskConfigurationable) {\n val, err := m.GetBackingStore().Get(\"taskConfiguration\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(PlannerTaskConfigurationable)\n }\n return nil\n}", "func (d *Driver) TaskConfigSchema() (*hclspec.Spec, error) {\n\treturn taskConfigSpec, nil\n}", "func (t *TMDB) Configuration() (*Configuration, error) {\n\tc := new(Configuration)\n\tif err := t.get(c, \"/3/configuration\", url.Values{}); err != nil {\n\t\treturn nil, err\n\t}\n\treturn c, nil\n}", "func (c *CvpClient) GetConfigForTask(workOrderForID string) (ConfigForTask, error) {\n\tcft := ConfigForTask{}\n\turl := \"/provisioning/getconfigfortask.do?workorderid=\" + workOrderForID\n\tresp, err := c.Get(url)\n\tif err != nil {\n\t\treturn cft, err\n\t}\n\terr = json.Unmarshal(resp, &cft)\n\treturn cft, err\n}", "func ConfigForTask(taskInfo *mesos.TaskInfo) *docker.CreateContainerOptions {\n\tconfig := &docker.CreateContainerOptions{\n\t\tName: GetContainerName(taskInfo.TaskId),\n\t\tConfig: &docker.Config{\n\t\t\tEnv: EnvForTask(taskInfo),\n\t\t\tExposedPorts: PortsForTask(taskInfo),\n\t\t\tImage: *taskInfo.Container.Docker.Image,\n\t\t\tLabels: LabelsForTask(taskInfo),\n\t\t},\n\t\tHostConfig: &docker.HostConfig{\n\t\t\tBinds: BindsForTask(taskInfo),\n\t\t\tPortBindings: PortBindingsForTask(taskInfo),\n\t\t\tNetworkMode: NetworkForTask(taskInfo),\n\t\t\tCapAdd: CapAddForTask(taskInfo),\n\t\t\tCapDrop: CapDropForTask(taskInfo),\n\t\t},\n\t}\n\n\t// Check for and calculate CPU shares\n\tcpus := getResource(\"cpus\", taskInfo)\n\tif cpus != nil {\n\t\tconfig.Config.CPUShares = int64(*cpus.Scalar.Value * float64(1024))\n\t}\n\n\t// Check for and calculate memory limit\n\tmemory := getResource(\"memoryMb\", taskInfo)\n\tif memory != nil {\n\t\tconfig.Config.Memory = int64(*memory.Scalar.Value * float64(1024*1024))\n\t}\n\n\treturn config\n}", "func (cttsdtp ConnectToTargetSQLDbTaskProperties) AsProjectTaskProperties() (*ProjectTaskProperties, bool) {\n\treturn nil, false\n}", "func TaskTimeout(duration time.Duration) func(*Config) error {\n\treturn func(c *Config) error {\n\t\tc.TaskTimeout = duration\n\t\treturn nil\n\t}\n}", "func GetConfiguration() *Configuration {\n\n\treturn &Configuration{\n\t\tServer: &Server{\n\t\t\tHost: os.Getenv(\"SERVER_HOST\"),\n\t\t\tPort: os.Getenv(\"SERVER_PORT\"),\n\t\t},\n\t\tPsql: &Psql{\n\t\t\tDriverName: os.Getenv(\"PSQL_DRIVER_NAME\"),\n\t\t\tDBName: os.Getenv(\"PSQL_DB_NAME\"),\n\t\t\tUser: os.Getenv(\"PSQL_USER\"),\n\t\t\tHost: os.Getenv(\"PSQL_HOST\"),\n\t\t\tSSLMode: os.Getenv(\"PSQL_SSL_MODE\"),\n\t\t},\n\t}\n}", "func GetTaskConfig(name, action string, conf *config.ComposeConfig) (types.TaskConfig, error) {\n\tact, err := getAction(action, name, conf)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn types.NewTaskConfig(act.name, conf, act.deps, NewTask(act.Run, act.Stop)), nil\n}", "func (ctssstp ConnectToSourceSQLServerTaskProperties) AsProjectTaskProperties() (*ProjectTaskProperties, bool) {\n\treturn nil, false\n}", "func (cttsmtp ConnectToTargetSQLMITaskProperties) AsProjectTaskProperties() (*ProjectTaskProperties, bool) {\n\treturn nil, false\n}", "func (m *BusinessScenarioPlanner) SetTaskConfiguration(value PlannerTaskConfigurationable)() {\n err := m.GetBackingStore().Set(\"taskConfiguration\", value)\n if err != nil {\n panic(err)\n }\n}", "func dbConfig() (map[string]string, error) {\n\tconf := make(map[string]string)\n\thost, ok := os.LookupEnv(dbhost)\n\tif !ok {\n\t\treturn nil, errors.New(\"DBHOST environment variable required\")\n\t}\n\tport, ok := os.LookupEnv(dbport)\n\tif !ok {\n\t\treturn nil, errors.New(\"DBPORT environment variable required\")\n\t}\n\tuser, ok := os.LookupEnv(dbuser)\n\tif !ok {\n\t\treturn nil, errors.New(\"DBUSER environment variable required\")\n\t}\n\tpassword, ok := os.LookupEnv(dbpass)\n\tif !ok {\n\t\treturn nil, errors.New(\"DBPASS environment variable required\")\n\t}\n\tname, ok := os.LookupEnv(dbname)\n\tif !ok {\n\t\treturn nil, errors.New(\"DBNAME environment variable required\")\n\t}\n\tconf[dbhost] = host\n\tconf[dbport] = port\n\tconf[dbuser] = user\n\tconf[dbpass] = password\n\tconf[dbname] = name\n\treturn conf, nil\n}", "func GetConfig() *Config {\n\treturn &Config{\n\t\tDB: &DBConfig{\n\t\t\tUsername: \"postgres\",\n\t\t\tPassword: \"cristiano1994\",\n\t\t\tDatabase: \"spataro_visitas\",\n\t\t\tPort: 5432,\n\t\t\tHost: \"localhost\",\n\t\t},\n\t}\n}", "func (msssdtp MigrateSQLServerSQLDbTaskProperties) AsProjectTaskProperties() (*ProjectTaskProperties, bool) {\n\treturn nil, false\n}", "func (m *ExternalConnection) GetConfiguration()(Configurationable) {\n return m.configuration\n}", "func (b *BackendTransportService) Configuration() *flux.Configuration {\n\treturn b.configuration\n}", "func newConfig() *Config {\n\t// TODO: use config as default, allow setting some values per-job\n\t// and prevent config changes affecting already-running tasks\n\treturn &Config{\n\t\tPath: DefaultPath,\n\t\tDatastorePrefix: \"MP_\",\n\t\tDefaultQueue: \"\",\n\t\tShards: 8,\n\t\tOversampling: 32,\n\t\tLeaseDuration: time.Duration(30) * time.Second,\n\t\tLeaseTimeout: time.Duration(10)*time.Minute + time.Duration(30)*time.Second,\n\t\tTaskTimeout: time.Duration(10)*time.Minute - time.Duration(30)*time.Second,\n\t\tCursorTimeout: time.Duration(50) * time.Second,\n\t\tRetries: 31,\n\t\tLogVerbose: false,\n\t\tHost: \"\",\n\t}\n}", "func (cttsdtp ConnectToTargetSQLDbTaskProperties) AsMigrateSQLServerSQLDbTaskProperties() (*MigrateSQLServerSQLDbTaskProperties, bool) {\n\treturn nil, false\n}", "func (msssmtp MigrateSQLServerSQLMITaskProperties) AsProjectTaskProperties() (*ProjectTaskProperties, bool) {\n\treturn nil, false\n}", "func GetSMTPServerConfig() map[string]string {\n\tconfig := make(map[string]string)\n\n\tconfig[\"host\"] = SMTPHost\n\tconfig[\"port\"] = SMTPPort\n\tconfig[\"username\"] = SMTPUsername\n\tconfig[\"password\"] = SMTPPassword\n\n\treturn config\n}", "func (tp *TestParams) DBConfig() *DBConf {\n\treturn &(tp.DBConf)\n}", "func GetConfiguration() *ApplicationServerConfig {\n\treturn applicationServer.Config\n}", "func (cttsmtp ConnectToTargetSQLMITaskProperties) AsMigrateSQLServerSQLDbTaskProperties() (*MigrateSQLServerSQLDbTaskProperties, bool) {\n\treturn nil, false\n}", "func (transporter *IPCTransporter) GetConfig() *structures.Config {\n\treturn transporter.Config\n}", "func (cttsdtp ConnectToTargetSQLDbTaskProperties) AsBasicProjectTaskProperties() (BasicProjectTaskProperties, bool) {\n\treturn &cttsdtp, true\n}", "func GetConfiguration() (*Configuration, error) {\n\ttimeout, err := time.ParseDuration(getEnv(\"TIMEOUT\", \"1000ms\"))\n\tif err != nil {\n\t\tfmt.Errorf(\"Failed to parse TIMEOUT env variable: %v\", err)\n\t\treturn nil, err\n\t}\n\n\trecheck_interval, err := time.ParseDuration(getEnv(\"RECHECK_INTERVAL\", \"10s\"))\n\tif err != nil {\n\t\tfmt.Errorf(\"Failed to parse RECHECK_INTERVAL env variable: %v\", err)\n\t\treturn nil, err\n\t}\n\n\tmax_parallelism, err := strconv.Atoi(getEnv(\"MAX_PARALLELISM\", \"100\"))\n\tif err != nil {\n\t\tfmt.Errorf(\"Failed to parse MAX_PARALLELISM env variable: %v\", err)\n\t\treturn nil, err\n\t}\n\n\tgrace_period, err := time.ParseDuration(getEnv(\"GRACE_PERIOD\", \"180s\"))\n\tif err != nil {\n\t\tfmt.Errorf(\"Failed to parse GRACE_PERIOD env variable: %v\", err)\n\t\treturn nil, err\n\t}\n\n\tport, err := strconv.Atoi(getEnv(\"TCP_PORT\", \"80\"))\n\tif err != nil {\n\t\tfmt.Errorf(\"Failed to parse TCP_PORT env variable: %v\", err)\n\t\treturn nil, err\n\t}\n\n\tfilter := getEnv(\"FILTER\", \"\")\n\tif filter == \"\" {\n\t\tfilter = \"status = RUNNING\"\n\t} else {\n\t\tfilter = fmt.Sprintf(\"(status = RUNNING) AND (%s)\", filter)\n\t}\n\n\tproject := getEnv(\"PROJECT\", \"\")\n\tif project == \"\" {\n\t\tfmt.Errorf(\"Failed to get PROJECT env variable: %v\", err)\n\t\treturn nil, err\n\t}\n\n\tpubsub_topic := getEnv(\"PUBSUB_TOPIC\", \"\")\n\tif pubsub_topic == \"\" {\n\t\tfmt.Errorf(\"Failed to get PUBSUB_TOPIC env variable: %v\", err)\n\t\treturn nil, err\n\t}\n\n\treturn &Configuration{\n\t\tfilter: filter,\n\t\tgrace_period: grace_period,\n\t\tmax_parallelism: max_parallelism,\n\t\tport: port,\n\t\tproject: project,\n\t\tpubsub_topic: pubsub_topic,\n\t\trecheck_interval: recheck_interval,\n\t\ttimeout: timeout,\n\t}, nil\n}", "func configuration() (*config, error) {\n\tfilepath := \"./cmd/cli/config.yml\"\n\tdata, err := ioutil.ReadFile(filepath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tconfig := &config{}\n\terr = yaml.Unmarshal(data, &config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdb, err := gorm.Open(\"mysql\",\n\t\tfmt.Sprintf(\n\t\t\t\"%s:%s@/%s?charset=utf8&parseTime=True&loc=Local\",\n\t\t\tconfig.DBCfg.Login,\n\t\t\tconfig.DBCfg.Password,\n\t\t\tconfig.DBCfg.Name,\n\t\t),\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdb.DB().SetConnMaxLifetime(config.DBCfg.ConMaxLifetime * time.Second)\n\tdb.DB().SetMaxIdleConns(config.DBCfg.MaxIdleConns)\n\tdb.DB().SetMaxOpenConns(config.DBCfg.MaxOpenConns)\n\n\tdb.LogMode(false)\n\n\tconfig.db = db\n\treturn config, nil\n}", "func GetConfig() *Config {\n\tlog.SetLevel(log.ErrorLevel)\n\n\tc := &Config{\n\t\tPostgresDSN: \"postgres://localhost/loraserver?sslmode=disable\",\n\t\tRedisURL: \"redis://localhost:6379\",\n\t\tMQTTServer: \"tcp://localhost:1883\",\n\t}\n\n\tif v := os.Getenv(\"TEST_POSTGRES_DSN\"); v != \"\" {\n\t\tc.PostgresDSN = v\n\t}\n\n\tif v := os.Getenv(\"TEST_REDIS_URL\"); v != \"\" {\n\t\tc.RedisURL = v\n\t}\n\n\tif v := os.Getenv(\"TEST_MQTT_SERVER\"); v != \"\" {\n\t\tc.MQTTServer = v\n\t}\n\n\tif v := os.Getenv(\"TEST_MQTT_USERNAME\"); v != \"\" {\n\t\tc.MQTTUsername = v\n\t}\n\n\tif v := os.Getenv(\"TEST_MQTT_PASSWORD\"); v != \"\" {\n\t\tc.MQTTPassword = v\n\t}\n\n\treturn c\n}", "func GetConfig() *Config {\n\tlog.SetLevel(log.ErrorLevel)\n\n\tc := &Config{\n\t\tPostgresDSN: \"postgres://localhost/loraserver?sslmode=disable\",\n\t\tRedisURL: \"redis://localhost:6379\",\n\t\tMQTTServer: \"tcp://localhost:1883\",\n\t}\n\n\tif v := os.Getenv(\"TEST_POSTGRES_DSN\"); v != \"\" {\n\t\tc.PostgresDSN = v\n\t}\n\n\tif v := os.Getenv(\"TEST_REDIS_URL\"); v != \"\" {\n\t\tc.RedisURL = v\n\t}\n\n\tif v := os.Getenv(\"TEST_MQTT_SERVER\"); v != \"\" {\n\t\tc.MQTTServer = v\n\t}\n\n\tif v := os.Getenv(\"TEST_MQTT_USERNAME\"); v != \"\" {\n\t\tc.MQTTUsername = v\n\t}\n\n\tif v := os.Getenv(\"TEST_MQTT_PASSWORD\"); v != \"\" {\n\t\tc.MQTTPassword = v\n\t}\n\n\treturn c\n}", "func (b *AbstractBaseEntity) Config() string {\n\treturn b.node.RunningConfig()\n}", "func (conn *Conn) Config() *Config {\n\treturn conn.cfg\n}", "func GetConfig() config.Configuration {\n\tconfig := config.Configuration{\n\t\tWorkingDirectory: \"work\",\n\t}\n\treturn config\n}", "func (serv *Server) Config() Config {\n return serv.config\n}", "func (extDb *Database) GetConfig() *Config {\n\treturn extDb.config\n}", "func (ptp ProjectTaskProperties) AsMigrateSQLServerSQLDbTaskProperties() (*MigrateSQLServerSQLDbTaskProperties, bool) {\n\treturn nil, false\n}", "func GetDBConfig() *DBConfiguration {\n\treturn &DBConfiguration{\n\t\tUsername: os.Getenv(\"DB_USERNAME\"),\n\t\tPassword: os.Getenv(\"DB_PASSWORD\"),\n\t\tPort: os.Getenv(\"DB_PORT\"),\n\t\tHost: os.Getenv(\"DB_HOST\"),\n\t\tDBName: os.Getenv(\"DB_NAME\"),\n\t}\n}", "func GetDBConfig() datastore.DBConfiguration {\n\tconfig := datastore.DBConfiguration{}\n\tconfig.DBName = os.Getenv(\"MongoDBName\")\n\tconfig.HostID = os.Getenv(\"MongoHostID\")\n\tconfig.PORT = os.Getenv(\"MongoPORT\")\n\tconfig.Password = os.Getenv(\"MongoPassword\")\n\tconfig.Username = os.Getenv(\"MongoUsername\")\n\treturn config\n}", "func (ctssstp ConnectToSourceSQLServerTaskProperties) AsBasicProjectTaskProperties() (BasicProjectTaskProperties, bool) {\n\treturn &ctssstp, true\n}", "func (conf *config) GetDBConfig() DB {\n\treturn conf.DB\n}", "func Config() map[string]string {\n\n\tsetEnv()\n\n\tcfg := make(map[string]string)\n\n\tcfg[\"MYSQL_DB_ENDPOINT\"] = os.Getenv(\"MYSQL_DB_ENDPOINT\")\n\tcfg[\"MYSQL_DB_PORT\"] = os.Getenv(\"MYSQL_DB_PORT\")\n\tcfg[\"MYSQL_DB_SCHEMA\"] = os.Getenv(\"MYSQL_DB_SCHEMA\")\n\tcfg[\"MYSQL_DB_USER\"] = os.Getenv(\"MYSQL_DB_USER\")\n\tcfg[\"MYSQL_DB_PASSWORD\"] = os.Getenv(\"MYSQL_DB_PASSWORD\")\n\n\treturn cfg\n}", "func GetConfig() {\n\n\tenv := true\n\ttempcfgdbhostname := os.Getenv(\"APP_DB_HOSTNAME\")\n\ttempcfgport := os.Getenv(\"APP_PORT\")\n\tif tempcfgdbhostname != \"\" {\n\t\tglobalconfig.DBHostName = tempcfgdbhostname\n\t} else {\n\t\tenv = false\n\t}\n\tif tempcfgport != \"\" {\n\t\tglobalconfig.HTTPPortNumber = tempcfgport\n\t} else {\n\t\tenv = false\n\t}\n\n\tif env == false {\n\t\tconfigbytes, err := ioutil.ReadFile(\"config.json\")\n\t\tif err != nil {\n\t\t}\n\t\terr = json.Unmarshal(configbytes, &globalconfig)\n\t\tfmt.Println(globalconfig)\n\t\tif err == nil {\n\t\t\tglobalconfig.Method = \"CofigFile\"\n\t\t}\n\t} else {\n\t\tglobalconfig.Method = \"EnvironmentVars\"\n\t}\n}", "func (ctssstp ConnectToSourceSQLServerTaskProperties) AsMigrateSQLServerSQLDbTaskProperties() (*MigrateSQLServerSQLDbTaskProperties, bool) {\n\treturn nil, false\n}", "func (cttsmtp ConnectToTargetSQLMITaskProperties) AsBasicProjectTaskProperties() (BasicProjectTaskProperties, bool) {\n\treturn &cttsmtp, true\n}", "func (turingMachine *TuringMachine) GetConfiguration() string {\n return turingMachine.tape.GetConfiguration(turingMachine.currentState.name)\n}", "func (s *Server) Config() ServerConfig {\n\treturn s.cfg\n}", "func GetAppConfiguration() map[string] interface{} {\r\n\tif (appConfig != nil) {\r\n\t\treturn appConfig;\r\n\t}\r\n\r\n\tdir, _ := os.Getwd();\r\n\tplan, _ := ioutil.ReadFile(dir + \"/conf/config.json\") // filename is the JSON file to read\r\n\tvar data map[string] interface{}\r\n\terr := json.Unmarshal(plan, &data)\r\n\tif (err != nil) {\r\n\t\tpanic(err)\r\n\t}\r\n\r\n\tappConfig = data;\r\n\tprintConfig();\r\n\treturn data;\r\n}", "func (msssdtp MigrateSQLServerSQLDbTaskProperties) AsMigrateSQLServerSQLDbTaskProperties() (*MigrateSQLServerSQLDbTaskProperties, bool) {\n\treturn &msssdtp, true\n}", "func (cop *ConnPool) GetConf() config.Config {\n\tconf := *cop.conf\n\treturn conf\n}", "func DBconfig() DBcfg {\n\th := viper.GetString(\"local-host\")\n\t// maybe it's a windows thing\n\t// \"HOST\" is being return with quotes around the [\"string\"]\n\th2 := util.Trim(viper.GetString(\"HOST\"), \"\\\"\")\n\tvar sfg *viper.Viper\n\tif h == h2 {\n\t\tsfg = viper.Sub(\"app-db-local\")\n\t} else {\n\t\tsfg = viper.Sub(\"app-db-dev\")\n\t}\n\n\treturn dbSettings(sfg)\n}", "func GetTestDBConfig() datastore.DBConfiguration {\n\tconfig := datastore.DBConfiguration{}\n\tconfig.DBName = os.Getenv(\"TestMongoDBName\")\n\tconfig.HostID = os.Getenv(\"TestMongoHostID\")\n\tconfig.PORT = os.Getenv(\"TestMongoPORT\")\n\tconfig.Password = os.Getenv(\"TestMongoPassword\")\n\tconfig.Username = os.Getenv(\"TestMongoUsername\")\n\treturn config\n}", "func GetConfig() common.AresServerConfig {\n\treturn config\n}", "func (msssdtp MigrateSQLServerSQLDbTaskProperties) AsBasicProjectTaskProperties() (BasicProjectTaskProperties, bool) {\n\treturn &msssdtp, true\n}", "func GetConfig(item string) string {\n\tswitch item {\n\tcase \"dbtouse\":\n\t\treturn Conf.Dbtouse\n\tcase \"dburl\":\n\t\treturn Conf.Dburl\n\tcase \"connectString\":\n\t\treturn Conf.ConnectString\n\tcase \"Mapsfile\":\n\t\treturn Conf.Mapsfile\n\tcase \"Templatesdir\":\n\t\treturn Conf.Templatesdir\n\tcase \"Tcpport\":\n\t\treturn Conf.Tcpport\n\tcase \"Fnr\":\n\t\treturn fmt.Sprintf(\"%v\", Conf.Fnr)\n\t}\n\treturn \"unknown request\"\n}", "func (msssmtp MigrateSQLServerSQLMITaskProperties) AsMigrateSQLServerSQLDbTaskProperties() (*MigrateSQLServerSQLDbTaskProperties, bool) {\n\treturn nil, false\n}", "func (b *Backend) GetConfig() string {\n\tvar sb strings.Builder\n\tsb.WriteString(\"name \" + b.Config.Name + \"\\n\")\n\tsb.WriteString(\"method \" + b.Config.Method + \"\\n\")\n\tsb.WriteString(\"realm \" + b.Config.Realm + \"\\n\")\n\tsb.WriteString(\"provider \" + b.Config.Provider)\n\treturn sb.String()\n}", "func getConfig() (conf utils.Config) {\n\tconf = utils.Config{\n\t\tEndpoint: \"play.minio.io:9000\",\n\t\tAccessKey: \"minio\",\n\t\tSecretKey: \"minio123\",\n\t\tSecure: true,\n\t}\n\treturn\n}", "func GetConfig() *Configuration {\n\treturn config\n}", "func (o *Options) GetStorageConfig() (string, error) {\n\tparams := []string{}\n\tif o.Endpoint != \"\" {\n\t\tparams = append(params, fmt.Sprintf(`endpoint = \"%s\"`, o.Endpoint))\n\t}\n\tif o.HaEnabled {\n\t\tparams = append(params, `ha_enabled = \"true\"`)\n\t}\n\tif o.Region != \"\" {\n\t\tparams = append(params, fmt.Sprintf(`region = \"%s\"`, o.Region))\n\t}\n\tif o.ReadCapacity != 0 {\n\t\tparams = append(params, fmt.Sprintf(`read_capacity = %d`, o.ReadCapacity))\n\t}\n\tif o.WriteCapacity != 0 {\n\t\tparams = append(params, fmt.Sprintf(`write_capacity = %d`, o.WriteCapacity))\n\t}\n\tif o.Table != \"\" {\n\t\tparams = append(params, fmt.Sprintf(`table = \"%s\"`, o.Table))\n\t}\n\tif o.MaxParallel != 0 {\n\t\tparams = append(params, fmt.Sprintf(`max_parallel = %d`, o.MaxParallel))\n\t}\n\n\tstorageCfg := fmt.Sprintf(dynamodbStorageFmt, strings.Join(params, \"\\n\"))\n\treturn storageCfg, nil\n}", "func (cttsdtp ConnectToTargetSQLDbTaskProperties) AsMigrateSQLServerSQLMITaskProperties() (*MigrateSQLServerSQLMITaskProperties, bool) {\n\treturn nil, false\n}", "func (ptp ProjectTaskProperties) AsConnectToTargetSQLDbTaskProperties() (*ConnectToTargetSQLDbTaskProperties, bool) {\n\treturn nil, false\n}", "func GetConfig() *Config {\n\treturn &Config{\n\t\tDB: &DBConfig{\n\t\t\tDialect: \"mysql\",\n\t\t\tHost: os.Getenv(\"MYSQL_HOSTNAME\"),\n\t\t\tPort: porta,\n\t\t\tUsername: os.Getenv(\"MYSQL_USER\"),\n\t\t\tPassword: os.Getenv(\"MYSQL_PASSWORD\"),\n\t\t\tName: os.Getenv(\"MYSQL_DATABASE\"),\n\t\t\tCharset: \"utf8\",\n\t\t},\n\t}\n}", "func (s *Services) Config() *Configuration { return &s.config }", "func (fm *FakeManager) GetConfiguration(throttlerName string) (map[string]*throttlerdatapb.Configuration, error) {\n\tpanic(panicMsg)\n}", "func (gutstp GetUserTablesSQLTaskProperties) AsProjectTaskProperties() (*ProjectTaskProperties, bool) {\n\treturn nil, false\n}", "func GetConfig(appOpts servertypes.AppOptions) *Config {\n\treturn &Config{\n\t\tContractQueryGasLimit: cast.ToUint64(appOpts.Get(\"wasm.contract-query-gas-limit\")),\n\t\tContractDebugMode: cast.ToBool(appOpts.Get(\"wasm.contract-debug-mode\")),\n\t\tWriteVMMemoryCacheSize: cast.ToUint32(appOpts.Get(\"wasm.write-vm-memory-cache-size\")),\n\t\tReadVMMemoryCacheSize: cast.ToUint32(appOpts.Get(\"wasm.read-vm-memory-cache-size\")),\n\t\tNumReadVMs: cast.ToUint32(appOpts.Get(\"wasm.num-read-vms\")),\n\t}\n}", "func (c *Context) Config() (*Config, error) {\n\tconfig := Config{}\n\tret := C.tiledb_ctx_get_config(c.tiledbContext, &config.tiledbConfig)\n\n\tif ret == C.TILEDB_OOM {\n\t\treturn nil, fmt.Errorf(\"Out of Memory error in GetConfig\")\n\t} else if ret != C.TILEDB_OK {\n\t\treturn nil, fmt.Errorf(\"Unknown error in GetConfig\")\n\t}\n\n\t// Set finalizer for free C pointer on gc\n\truntime.SetFinalizer(&config, func(config *Config) {\n\t\tconfig.Free()\n\t})\n\n\treturn &config, nil\n}", "func (s *Split) Configurations() map[string]string {\n\treturn s.splitData.Configurations\n}", "func (server *Server) GetConfig() *config.Config {\n\treturn server.config\n}", "func readProjectConfig(c context.Context, task proto.Message) error {\n\tprojectID := task.(*internal.ReadProjectConfigTask).ProjectId\n\n\tctx, cancel := context.WithTimeout(c, 150*time.Second)\n\tdefer cancel()\n\n\tjobs, err := globalCatalog.GetProjectJobs(ctx, projectID)\n\tif err != nil {\n\t\tlogging.WithError(err).Errorf(c, \"Failed to query for a list of jobs\")\n\t\treturn err\n\t}\n\n\tif err := globalEngine.UpdateProjectJobs(ctx, projectID, jobs); err != nil {\n\t\tlogging.WithError(err).Errorf(c, \"Failed to update some jobs\")\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func GetTaskService() *taskService {\n\treturn taskSvr\n}", "func (*server) redshiftConfig() string {\n\treturn fmt.Sprintf(\"postgres://%s:%s@%s/%s?port=%s&connect_timeout=15\", user, pass, host, db, port)\n}", "func (conf *ProjectConfig) GetPublishedTask() (publishedTasks map[string]*Task) {\n\tpublishedTasks = map[string]*Task{}\n\tfor taskName, task := range conf.Tasks {\n\t\tif !task.Private {\n\t\t\tpublishedTasks[taskName] = task\n\t\t}\n\t}\n\treturn publishedTasks\n}", "func Get() (*Configuration, error) {\n\tif cfg != nil {\n\t\treturn cfg, nil\n\t}\n\n\tcfg = &Configuration{\n\t\tBindAddr: \":10100\",\n\t\tDefaultMaxResults: 1000,\n\t\tGracefulShutdownTimeout: 5 * time.Second,\n\t\tHost: \"http://localhost\",\n\t\tElasticSearchConfig: &ElasticSearchConfig{\n\t\t\tDestURL: \"http://localhost:9200\",\n\t\t\tDestIndex: \"courses\",\n\t\t\tShowScore: false,\n\t\t\tSignedRequests: true,\n\t\t},\n\t}\n\n\treturn cfg, envconfig.Process(\"\", cfg)\n}", "func (s *AppServer) Config() *AppConfig {\n\treturn s.config\n}", "func (cttsmtp ConnectToTargetSQLMITaskProperties) AsConnectToTargetSQLDbTaskProperties() (*ConnectToTargetSQLDbTaskProperties, bool) {\n\treturn nil, false\n}", "func (cttsdtp ConnectToTargetSQLDbTaskProperties) AsConnectToTargetSQLDbTaskProperties() (*ConnectToTargetSQLDbTaskProperties, bool) {\n\treturn &cttsdtp, true\n}", "func (msssmtp MigrateSQLServerSQLMITaskProperties) AsBasicProjectTaskProperties() (BasicProjectTaskProperties, bool) {\n\treturn &msssmtp, true\n}", "func (c *ConfigurationFile) GetServer() string {\n\treturn c.CurrentServer\n}", "func Configuration() Config {\n\tmongoidConfigMutex.Lock()\n\tdefer mongoidConfigMutex.Unlock()\n\t// be careful around this mutex\n\tvar retConfig Config\n\tretConfig = *mongoidConfig\n\treturn retConfig\n}", "func (n *resPool) ResourcePoolConfig() *respool.ResourcePoolConfig {\n\tn.RLock()\n\tdefer n.RUnlock()\n\treturn n.poolConfig\n}", "func (ptp ProjectTaskProperties) AsConnectToSourceSQLServerTaskProperties() (*ConnectToSourceSQLServerTaskProperties, bool) {\n\treturn nil, false\n}", "func GetConfig() *config {\n\tif instance == nil {\n\t\tinstance = new(config)\n\t\tinstance.SubmitSMResponseTimeLow = 0\n\t\tinstance.SubmitSMResponseTimeHigh = 0\n\t\tinstance.SubmitSMWindowMax = 100\n\t\tinstance.DeliverSMWindowMax = 99\n\t\tinstance.APIPort = 8090\n\t\tinstance.UcpPort = 8080\n\t\tinstance.MaxTPS = 100\n\n\t\treadConfig()\n\t}\n\treturn instance\n}", "func GetConfig() Config {\n\tport, ok := os.LookupEnv(\"PORT\")\n\tif !ok {\n\t\tport = \"8080\"\n\t}\n\n\tenv, ok := os.LookupEnv(\"ENV\")\n\tif !ok {\n\t\tenv = \"development\"\n\t}\n\n\tpgHost, ok := os.LookupEnv(\"PG_HOST\")\n\tif !ok {\n\t\tpgHost = \"localhost\"\n\t}\n\n\tpgPort, ok := os.LookupEnv(\"PG_PORT\")\n\tif !ok {\n\t\tpgPort = \"5432\"\n\t}\n\n\tpgUser, ok := os.LookupEnv(\"PG_USER\")\n\tif !ok {\n\t\tpgUser = \"postgres\"\n\t}\n\n\tpgPassword, ok := os.LookupEnv(\"PG_PASSWORD\")\n\tif !ok {\n\t\tpgPassword = \"\"\n\t}\n\n\tpgDBName, ok := os.LookupEnv(\"PG_DB_NAME\")\n\tif !ok {\n\t\tpgDBName = \"ginexamples\"\n\t}\n\n\tlogFile, ok := os.LookupEnv(\"LOGFILE\")\n\tif !ok {\n\t\tlogFile = \"\"\n\t}\n\n\treturn Config{\n\t\tPort: port,\n\t\tEnv: env,\n\t\tPGHost: pgHost,\n\t\tPGPort: pgPort,\n\t\tPGUser: pgUser,\n\t\tPGPassword: pgPassword,\n\t\tPGDBName: pgDBName,\n\t\tLogFile: logFile,\n\t}\n}", "func GetConfig() *Config {\n\treturn &Config{\n\t\tISI: isiConfig{\n\t\t\tUserName: *isiUserName,\n\t\t\tPassword: *isiPassword,\n\t\t\tMgmtPort: *isiMgmtPort,\n\t\t\tIsiURL: *isiURL,\n\t\t},\n\t\tExporter: exporterConfig{\n\t\t\tBindAddress: *listenAddress,\n\t\t\tBindPort: *listenPort,\n\t\t\tMultiQuery: *multiQuery,\n\t\t},\n\t}\n}", "func (gutstp GetUserTablesSQLTaskProperties) AsMigrateSQLServerSQLDbTaskProperties() (*MigrateSQLServerSQLDbTaskProperties, bool) {\n\treturn nil, false\n}", "func (vmisssmtp ValidateMigrationInputSQLServerSQLMITaskProperties) AsProjectTaskProperties() (*ProjectTaskProperties, bool) {\n\treturn nil, false\n}", "func GetConfig() Config {\n\theartbeatConfig, err := heartbeat.NewConfigFromEnv()\n\tutil.CheckErrFatal(err)\n\topen, close := getExchangeHours()\n\treturn Config{\n\t\tPriceDB: endpoint.NewPGConfig(\"PRICE_DB\"),\n\t\tTickerDB: endpoint.NewPGConfig(\"TICKER_DB\"),\n\t\tTimezone: util.GetEnvVar(\"TIMEZONE\", \"America/New_York\"),\n\t\tExchangeOpenHour: open,\n\t\tExchangeCloseHour: close,\n\t\tHeartbeat: heartbeatConfig,\n\t}\n}", "func (s *BoltState) GetDBConfig() (*DBConfig, error) {\n\tif !s.valid {\n\t\treturn nil, define.ErrDBClosed\n\t}\n\n\tcfg := new(DBConfig)\n\n\tdb, err := s.getDBCon()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer s.deferredCloseDBCon(db)\n\n\terr = db.View(func(tx *bolt.Tx) error {\n\t\tconfigBucket, err := getRuntimeConfigBucket(tx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Some of these may be nil\n\t\t// When we convert to string, Go will coerce them to \"\"\n\t\t// That's probably fine - we could raise an error if the key is\n\t\t// missing, but just not including it is also OK.\n\t\tlibpodRoot := configBucket.Get(staticDirKey)\n\t\tlibpodTmp := configBucket.Get(tmpDirKey)\n\t\tstorageRoot := configBucket.Get(graphRootKey)\n\t\tstorageTmp := configBucket.Get(runRootKey)\n\t\tgraphDriver := configBucket.Get(graphDriverKey)\n\t\tvolumePath := configBucket.Get(volPathKey)\n\n\t\tcfg.LibpodRoot = string(libpodRoot)\n\t\tcfg.LibpodTmp = string(libpodTmp)\n\t\tcfg.StorageRoot = string(storageRoot)\n\t\tcfg.StorageTmp = string(storageTmp)\n\t\tcfg.GraphDriver = string(graphDriver)\n\t\tcfg.VolumePath = string(volumePath)\n\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn cfg, nil\n}", "func serverConfig() (http.ServerConfig, error) {\n\tconfig := http.ServerConfig{}\n\tvar err error\n\tconfig.Port, err = os.GetIntFromEnvVar(\"PORT\", 8080)\n\tif err != nil {\n\t\treturn config, err\n\t}\n\tconfig.TLSEnabled, err = os.GetBoolFromEnvVar(\"TLS_ENABLED\", false)\n\tif err != nil {\n\t\treturn config, err\n\t}\n\tif config.TLSEnabled {\n\t\tconfig.TLSCertPath, err = os.GetRequiredEnvVar(\"TLS_CERT_PATH\")\n\t\tif err != nil {\n\t\t\treturn config, err\n\t\t}\n\t\tconfig.TLSKeyPath, err = os.GetRequiredEnvVar(\"TLS_KEY_PATH\")\n\t\tif err != nil {\n\t\t\treturn config, err\n\t\t}\n\t}\n\treturn config, nil\n}", "func GetConfig() *Configuration {\n\treturn Config\n}", "func GetConfig() *Configuration {\n\treturn Config\n}", "func (c *APIClient) GetConfig() *Configuration {\n\treturn c.cfg\n}", "func (c *APIClient) GetConfig() *Configuration {\n\treturn c.cfg\n}", "func (c *APIClient) GetConfig() *Configuration {\n\treturn c.cfg\n}", "func (tx *Tx) GetConfiguration() (*Configuration, error) {\n\tvar conf Configuration\n\terr := tx.Get(&conf, \"SELECT * FROM configuration;\")\n\tif err != nil {\n\t\tif strings.Contains(err.Error(), \"does not exist\") {\n\t\t\t// pq: relation \"configuration\" does not exist\n\t\t\t// TODO: find better detection when table does not exist\n\t\t\treturn nil, nil\n\t\t}\n\t\tif err == sql.ErrNoRows {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, errors.InternalError(err)\n\t}\n\treturn &conf, nil\n}", "func getConfig(t *testing.T) *cfg.Config {\n\tc := cfg.ResetTestRoot(t.Name())\n\n\t// and we use random ports to run in parallel\n\ttm, rpc, grpc := makeAddrs()\n\tc.P2P.ListenAddress = tm\n\tc.RPC.ListenAddress = rpc\n\tc.RPC.GRPCListenAddress = grpc\n\treturn c\n}", "func makeTasksCfg(t *testing.T, tasks, jobs map[string][]string) string {\n\ttaskSpecs := make(map[string]*TaskSpec, len(tasks))\n\tfor name, deps := range tasks {\n\t\ttaskSpecs[name] = &TaskSpec{\n\t\t\tCipdPackages: []*CipdPackage{},\n\t\t\tDependencies: deps,\n\t\t\tDimensions: []string{},\n\t\t\tIsolate: \"abc123\",\n\t\t\tPriority: 0.0,\n\t\t}\n\t}\n\tjobSpecs := make(map[string]*JobSpec, len(jobs))\n\tfor name, deps := range jobs {\n\t\tjobSpecs[name] = &JobSpec{\n\t\t\tTaskSpecs: deps,\n\t\t}\n\t}\n\tcfg := TasksCfg{\n\t\tTasks: taskSpecs,\n\t\tJobs: jobSpecs,\n\t}\n\treturn testutils.MarshalIndentJSON(t, &cfg)\n}" ]
[ "0.69888526", "0.6583979", "0.63950527", "0.62126625", "0.5957827", "0.5939605", "0.5886146", "0.5611155", "0.55858016", "0.55705434", "0.55193114", "0.55012417", "0.54126394", "0.5408065", "0.535299", "0.53333354", "0.5309216", "0.5296257", "0.52802205", "0.52377206", "0.5220272", "0.5220237", "0.5218131", "0.52160364", "0.52106375", "0.52017105", "0.51974005", "0.5166969", "0.5160348", "0.51588583", "0.51534367", "0.51534367", "0.51100105", "0.51068467", "0.508992", "0.5079935", "0.50599945", "0.5051883", "0.5043706", "0.5041227", "0.5038035", "0.50282097", "0.5006034", "0.5004294", "0.49976373", "0.49937674", "0.4987174", "0.49386066", "0.4937958", "0.49305907", "0.49188983", "0.4903269", "0.48916543", "0.48906058", "0.48888895", "0.488826", "0.48854533", "0.48806784", "0.48767024", "0.48740765", "0.48642424", "0.4843099", "0.48302338", "0.48290068", "0.48284978", "0.48206764", "0.48163563", "0.48112044", "0.4808826", "0.4805356", "0.48039994", "0.47955987", "0.4789807", "0.4789452", "0.47869393", "0.4782947", "0.47812605", "0.47808847", "0.47763515", "0.4776077", "0.4772315", "0.4771149", "0.47648594", "0.47630626", "0.47616106", "0.4757921", "0.47569665", "0.47556368", "0.47512674", "0.4746918", "0.47457585", "0.4741234", "0.47396743", "0.47396743", "0.47396657", "0.47396657", "0.47396657", "0.47389877", "0.47351065", "0.4732275" ]
0.7348872
0
NewSSHClientConfig returns client configuration for SSH client
NewSSHClientConfig возвращает конфигурацию клиента SSH
func NewSSHClientConfig(user, keyFile, passworkPhrase string) (*SSHClient, error) { publicKeyMenthod, err := publicKey(keyFile, passworkPhrase) if err != nil { return nil, err } sshConfig := &ssh.ClientConfig{ User: user, Auth: []ssh.AuthMethod{ publicKeyMenthod, }, HostKeyCallback: ssh.InsecureIgnoreHostKey(), } return &SSHClient{ config: sshConfig, }, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func newSSHClientConfig(host string, section *SSHConfigFileSection, userName, identity string, agentForwarding bool) (*sshClientConfig, error) {\n\tvar (\n\t\tconfig *sshClientConfig\n\t\terr error\n\t)\n\n\tif section != nil {\n\t\tupdateFromSSHConfigFile(section, &host, &userName, &agentForwarding)\n\t}\n\n\tif agentForwarding {\n\t\tconfig, err = newSSHAgentConfig(userName)\n\t} else {\n\t\tconfig, err = newSSHDefaultConfig(userName, identity)\n\t}\n\n\tif config != nil {\n\t\tconfig.host = host\n\t}\n\treturn config, err\n}", "func GetSSHClientConfig(opts *Options) (*ssh.ClientConfig, error) {\n\tauthMethod, err := opts.PrivateKey.ToSSHAuthMethod()\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclientConfig := &ssh.ClientConfig{\n\t\tUser: opts.Username,\n\t\tHostKeyCallback: ssh.InsecureIgnoreHostKey(),\n\t\tAuth: []ssh.AuthMethod{authMethod},\n\t}\n\n\treturn clientConfig, nil\n}", "func NewClientConfig(s *state.State, host kubeone.HostConfig) (*clientv3.Config, error) {\n\tsshconn, err := s.Connector.Connect(host)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tgrpcDialer, err := sshtunnel.NewGRPCDialer(s.Connector, host)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to create grpc tunnel dialer\")\n\t}\n\n\ttlsConf, err := LoadTLSConfig(sshconn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &clientv3.Config{\n\t\tEndpoints: []string{fmt.Sprintf(\"%s:2379\", host.PrivateAddress)},\n\t\tTLS: tlsConf,\n\t\tContext: s.Context,\n\t\tDialTimeout: 5 * time.Second,\n\t\tDialOptions: []grpc.DialOption{\n\t\t\tgrpc.WithBlock(),\n\t\t\tgrpcDialer,\n\t\t},\n\t}, nil\n}", "func (i *IdentityFile) SSHClientConfig() (*ssh.ClientConfig, error) {\n\tsshCert, err := sshutils.ParseCertificate(i.Certs.SSH)\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\n\tpriv, err := keys.ParsePrivateKey(i.PrivateKey)\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\n\tssh, err := sshutils.ProxyClientSSHConfig(sshCert, priv, i.CACerts.SSH...)\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\n\treturn ssh, nil\n}", "func newSSHAgentConfig(userName string) (*sshClientConfig, error) {\n\tagent, err := newAgent()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tconfig, err := sshAgentConfig(userName, agent)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &sshClientConfig{\n\t\tagent: agent,\n\t\tClientConfig: config,\n\t}, nil\n}", "func (c *Client) initClientConfig() error {\n\tif c.clientConfig != nil {\n\t\t// ssh.CLientConfig has been provided for us\n\t\treturn nil\n\t}\n\thostKeyCallback, err := knownhosts.New(fmt.Sprintf(\"%s/.ssh/known_hosts\", os.Getenv(\"HOME\")))\n\tif err != nil {\n\t\treturn err\n\t}\n\tsshAuthMethods := []ssh.AuthMethod{AgentAuth(), PublicKeyAuth(), PasswordAuth()}\n\tif c.agent != nil {\n\t\tsshAuthMethods = append(sshAuthMethods, ssh.PublicKeysCallback(c.agent.Signers))\n\t}\n\tc.clientConfig = &ssh.ClientConfig{\n\t\tUser: c.user,\n\t\tAuth: sshAuthMethods,\n\t\tHostKeyCallback: hostKeyCallback,\n\t\tTimeout: time.Duration(int64(time.Second * 20)),\n\t}\n\treturn nil\n}", "func newSSHDefaultConfig(userName, identity string) (*sshClientConfig, error) {\n\tconfig, err := sshDefaultConfig(userName, identity)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &sshClientConfig{ClientConfig: config}, nil\n}", "func ClientConfig(alias string, configFile string) (*ssh.ClientConfig, string, error) {\n\tvar err error\n\tvar connectHost string\n\n\tuserConfig, err := decodeSSHConfig(configFile)\n\tif err != nil {\n\t\treturn nil, connectHost, errors.Wrap(err, \"failed to decode ssh config file\")\n\t}\n\n\t/* TODO\n\t // Rand\n\t // BannerCallback\n\t // ClientVersion\n\t*/\n\n\tconfig := &ssh.Config{}\n\tmacs := userConfig.Get(alias, \"MACs\")\n\tif macs != \"\" {\n\t\tconfig.MACs = strings.Split(macs, \",\")\n\t}\n\tkexs := userConfig.Get(alias, \"KexAlgorithms\")\n\tif kexs != \"\" {\n\t\tconfig.KeyExchanges = strings.Split(kexs, \",\")\n\t}\n\tciphers := userConfig.Get(alias, \"Ciphers\")\n\tif ciphers != \"\" {\n\t\tconfig.Ciphers = strings.Split(ciphers, \",\")\n\t}\n\n\tclientConfig := &ssh.ClientConfig{\n\t\tConfig: *config,\n\t}\n\n\t// TODO handle known_hosts2\n\t// TODO default empty?\n\tuserKnownHostsFile := userConfig.Get(alias, \"UserKnownHostsFile\")\n\tif userKnownHostsFile == \"\" {\n\t\tuserKnownHostsFile, err = homedir.Expand(\"~/.ssh/known_hosts\")\n\t\tif err != nil {\n\t\t\treturn nil, connectHost, errors.Wrap(err, \"failed to expand ~/.ssh/known_hosts\")\n\t\t}\n\t}\n\thostKeyCallback, err := getHostKeyCallback(strings.Split(userKnownHostsFile, \" \"))\n\tif err != nil {\n\t\treturn nil, connectHost, errors.Wrap(err, \"failed to create host key callback\")\n\t}\n\tclientConfig.HostKeyCallback = hostKeyCallback\n\n\tuser := userConfig.Get(alias, \"User\")\n\tif user == \"\" {\n\t\tcurrentUser, err := osuser.Current()\n\t\tif err != nil {\n\t\t\treturn nil, connectHost, errors.Wrap(err, \"failed to detect current user\")\n\t\t}\n\t\tuser = currentUser.Username\n\t}\n\tclientConfig.User = user\n\n\tsigners := sshAgentSigners()\n\tidentityFile, err := homedir.Expand(userConfig.Get(alias, \"IdentityFile\"))\n\tif err != nil {\n\t\treturn nil, connectHost, errors.Wrap(err, \"failed to expand home directory for IdentityFile\")\n\t}\n\tpubkey := publicKeyFile(identityFile)\n\tif pubkey != nil {\n\t\tsigners = append(signers, pubkey)\n\t}\n\tclientConfig.Auth = []ssh.AuthMethod{ssh.PublicKeys(signers...)}\n\n\thostKeyAlgorithms := userConfig.Get(alias, \"HostKeyAlgorithms\")\n\tif hostKeyAlgorithms != \"\" {\n\t\tclientConfig.HostKeyAlgorithms = strings.Split(hostKeyAlgorithms, \",\")\n\t}\n\n\ttimeoutString := userConfig.Get(alias, \"ConnectTimeout\")\n\tif timeoutString != \"\" {\n\t\ttimeoutInt, err := strconv.ParseInt(timeoutString, 10, 64)\n\t\tif err != nil {\n\t\t\treturn nil, connectHost, errors.Wrap(err, \"failed to convert ConnectTimeout to int64\")\n\t\t}\n\t\tclientConfig.Timeout = time.Duration(timeoutInt) * time.Second\n\t}\n\n\thostname := userConfig.Get(alias, \"Hostname\")\n\tif hostname == \"\" {\n\t\thostname = alias\n\t}\n\tport := userConfig.Get(alias, \"Port\")\n\tif port == \"\" {\n\t\tport = \"22\"\n\t}\n\tconnectHost = hostname + \":\" + port\n\n\treturn clientConfig, connectHost, nil\n}", "func NewClient(sshconfig *ssh.ClientConfig, host string, port string, prompts []Prompt) *Client {\n\treturn &Client{\n\t\tSshconfig: sshconfig,\n\t\tHost: host,\n\t\tPort: port,\n\t\tPrompt: prompts,\n\t}\n}", "func newSSHClient(user, pass, host string) (*ssh.Client, error) {\n\tsshConfig := &ssh.ClientConfig{\n\t\tUser: user,\n\t\tAuth: []ssh.AuthMethod{ssh.Password(pass)},\n\t\tHostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {\n\t\t\treturn nil\n\t\t},\n\t}\n\tsshConfig.HostKeyCallback = ssh.InsecureIgnoreHostKey()\n\tclient, err := ssh.Dial(\"tcp\", host, sshConfig)\n\tif err != nil {\n\t\treturn nil, errors.New(strings.Join([]string{\"ssh dial error: \", err.Error()}, \"\"))\n\t}\n\treturn client, nil\n}", "func NewClientSSH(client *ssh.Client) Client {\n\treturn &sshClient{client: client}\n}", "func SSHConfig() *ssh.ClientConfig {\n\treturn &ssh.ClientConfig{\n\t\tUser: dockerUser(),\n\t\tAuth: []ssh.AuthMethod{\n\t\t\tPublicKeyFile(dockerCertPath()),\n\t\t},\n\t}\n}", "func NewSSHClient(ctx context.Context, projectID string, repo Repo) *SSHClient {\n\treturn &SSHClient{\n\t\tprojectID: projectID,\n\t\trepo: repo,\n\t\tlog: logFromContext(ctx).WithField(\"project-id\", projectID),\n\t}\n}", "func sshConfig(useAgent bool, username, privateKeyPath, password string) func(multistep.StateBag) (*ssh.ClientConfig, error) {\n\treturn func(state multistep.StateBag) (*ssh.ClientConfig, error) {\n\n\t\tif useAgent {\n\t\t\tlog.Println(\"Configuring SSH agent.\")\n\n\t\t\tauthSock := os.Getenv(\"SSH_AUTH_SOCK\")\n\t\t\tif authSock == \"\" {\n\t\t\t\treturn nil, fmt.Errorf(\"SSH_AUTH_SOCK is not set\")\n\t\t\t}\n\n\t\t\tsshAgent, err := net.Dial(\"unix\", authSock)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Cannot connect to SSH Agent socket %q: %s\", authSock, err)\n\t\t\t}\n\n\t\t\treturn &ssh.ClientConfig{\n\t\t\t\tUser: username,\n\t\t\t\tAuth: []ssh.AuthMethod{\n\t\t\t\t\tssh.PublicKeysCallback(agent.NewClient(sshAgent).Signers),\n\t\t\t\t},\n\t\t\t}, nil\n\t\t}\n\n\t\thasKey := privateKeyPath != \"\"\n\n\t\tif hasKey {\n\t\t\tlog.Printf(\"Configuring SSH private key '%s'.\", privateKeyPath)\n\n\t\t\tprivateKeyBytes, err := ioutil.ReadFile(privateKeyPath)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Unable to read SSH private key: %s\", err)\n\t\t\t}\n\n\t\t\tsigner, err := ssh.ParsePrivateKey(privateKeyBytes)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Error setting up SSH config: %s\", err)\n\t\t\t}\n\n\t\t\treturn &ssh.ClientConfig{\n\t\t\t\tUser: username,\n\t\t\t\tAuth: []ssh.AuthMethod{\n\t\t\t\t\tssh.PublicKeys(signer),\n\t\t\t\t},\n\t\t\t}, nil\n\t\t} else {\n\t\t\tlog.Println(\"Configuring SSH keyboard interactive.\")\n\n\t\t\treturn &ssh.ClientConfig{\n\t\t\t\tUser: username,\n\t\t\t\tAuth: []ssh.AuthMethod{\n\t\t\t\t\tssh.Password(password),\n\t\t\t\t\tssh.KeyboardInteractive(\n\t\t\t\t\t\tpackerssh.PasswordKeyboardInteractive(password)),\n\t\t\t\t}}, nil\n\t\t}\n\t}\n}", "func NewClient(config *Config) (*Client, error) {\n c := &Client{}\n\n client, err := ssh.Dial(\"tcp\", config.Host + \":\" + strconv.Itoa(config.Port), config.ClientConfig)\n if err != nil {\n return nil, err\n }\n\n c.client = client\n return c, nil\n}", "func NewClient(cfg *Config) (Client, error) {\n\tconfig, err := NewNativeConfig(cfg.User, cfg.version(), cfg.Auth, cfg.hostKey())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error getting config for native Go SSH: %s\", err)\n\t}\n\tconfig.Timeout = cfg.timeout()\n\n\treturn &NativeClient{\n\t\tConfig: config,\n\t\tHostname: cfg.Host,\n\t\tPort: cfg.port(),\n\t\tClientVersion: cfg.version(),\n\t}, nil\n}", "func NewClient(sshc *ssh.Client) (cl *Client, err error) {\n\tlogp := \"New\"\n\tcl = &Client{}\n\n\tcl.sess, err = sshc.NewSession()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: NewSession: %w\", logp, err)\n\t}\n\n\tcl.pipeIn, err = cl.sess.StdinPipe()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: StdinPipe: %w\", logp, err)\n\t}\n\tcl.pipeOut, err = cl.sess.StdoutPipe()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: StdoutPipe: %w\", logp, err)\n\t}\n\tcl.pipeErr, err = cl.sess.StderrPipe()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: StderrPipe: %w\", logp, err)\n\t}\n\n\terr = cl.sess.RequestSubsystem(subsystemNameSftp)\n\tif err != nil {\n\t\tif err.Error() == \"ssh: subsystem request failed\" {\n\t\t\treturn nil, ErrSubsystem\n\t\t}\n\t\treturn nil, fmt.Errorf(\"%s: RequestSubsystem: %w\", logp, err)\n\t}\n\n\tcl.requestId = uint32(time.Now().Unix())\n\n\terr = cl.init()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %w\", logp, err)\n\t}\n\n\treturn cl, nil\n}", "func (c *ClusterProvider) NewClientConfig() (*ClientConfig, error) {\n\tclusterName := fmt.Sprintf(\"%s.%s.eksctl.io\", c.cfg.ClusterName, c.cfg.Region)\n\tcontextName := fmt.Sprintf(\"%s@%s\", c.getUsername(), clusterName)\n\n\tclientConfig := &ClientConfig{\n\t\tCluster: c.cfg,\n\t\tClient: &clientcmdapi.Config{\n\t\t\tClusters: map[string]*clientcmdapi.Cluster{\n\t\t\t\tclusterName: {\n\t\t\t\t\tServer: c.cfg.MasterEndpoint,\n\t\t\t\t\tCertificateAuthorityData: c.cfg.CertificateAuthorityData,\n\t\t\t\t},\n\t\t\t},\n\t\t\tContexts: map[string]*clientcmdapi.Context{\n\t\t\t\tcontextName: {\n\t\t\t\t\tCluster: clusterName,\n\t\t\t\t\tAuthInfo: contextName,\n\t\t\t\t},\n\t\t\t},\n\t\t\tAuthInfos: map[string]*clientcmdapi.AuthInfo{\n\t\t\t\tcontextName: &clientcmdapi.AuthInfo{},\n\t\t\t},\n\t\t\tCurrentContext: contextName,\n\t\t},\n\t\tClusterName: clusterName,\n\t\tContextName: contextName,\n\t\troleARN: c.svc.arn,\n\t\tsts: c.svc.sts,\n\t}\n\n\treturn clientConfig, nil\n}", "func NewClient(cfg *Config) (*Client, error) {\n\tcc := &Client{\n\t\tconfig: cfg,\n\t\tauth: &Auth{},\n\t\tauthLock: &sync.Mutex{},\n\t\tencryptKeyLock: &sync.Mutex{},\n\t}\n\tjk, err := jwtKey(cfg.JWTKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcc.jwtPublicKey = jk\n\n\tsshKeys, err := findAuthKeys()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(sshKeys) == 0 { // We didn't find any keys; give up\n\t\treturn nil, ErrMissingSSHAuth\n\t}\n\n\t// Try and use the keys we found\n\tvar pkam ssh.AuthMethod\n\tfor i := 0; i < len(sshKeys); i++ {\n\t\tpkam, err = publicKeyAuthMethod(sshKeys[i])\n\t\tif err != nil && i == len(sshKeys)-1 {\n\t\t\treturn nil, ErrMissingSSHAuth\n\t\t}\n\t}\n\tcc.authKeyPaths = sshKeys\n\n\tcc.sshConfig = &ssh.ClientConfig{\n\t\tUser: \"charm\",\n\t\tAuth: []ssh.AuthMethod{pkam},\n\t\tHostKeyCallback: ssh.InsecureIgnoreHostKey(),\n\t}\n\treturn cc, nil\n}", "func (e *EdgeSwitchClient) newClient() (*ssh.Client, error) {\n\tsshConfig := &ssh.ClientConfig{\n\t\tUser: DEFAULT_USER,\n\t\tAuth: []ssh.AuthMethod{ssh.Password(DEFAULT_USER)},\n\t\tHostKeyCallback: ssh.InsecureIgnoreHostKey(),\n\t}\n\n\tclient, err := ssh.Dial(\"tcp\", e.ipaddress, sshConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn client, nil\n}", "func newClientConfig(fname, id, name, serverKey, serverUrl string) (err error) {\n\tconfig := Config{\n\t\tid,\n\t\tname,\n\t\t\"client\",\n\t\t\"\",\n\t\tserverKey,\n\t\tserverUrl,\n\t\tDEFAULT_PROCESS_USER,\n\t\tDEFAULT_PROCESS_LOCK,\n\t\tDEFAULT_PROCESS_LOG,\n\t\tDEFAULT_BASE_DIR,\n\t\tDEFAULT_DATA_DIR,\n\t\tDEFAULT_HTTP_LISTEN,\n\t\tfname,\n\t}\n\n\treturn SaveConfig(config)\n}", "func sshAgentConfig(userName string, a agent.Agent) (*ssh.ClientConfig, error) {\n\tsigners, err := a.Signers()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &ssh.ClientConfig{\n\t\tUser: userName,\n\t\tAuth: []ssh.AuthMethod{\n\t\t\tssh.PublicKeys(signers...),\n\t\t},\n\t}, nil\n}", "func NewClientConfigWithKeyFile(username string, sshKey string, host string, port int, checkHostKey bool) (*Config, error) {\n\tvar hostKey ssh.PublicKey\n\n\tc := &Config{\n\t\tHost: host,\n\t\tPort: port,\n\t}\n\n\t// Read private key\n\tkey, err := ioutil.ReadFile(sshKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create the Signer for this private key.\n\tsigner, err := ssh.ParsePrivateKey(key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif checkHostKey {\n\t\t//arr := strings.Split(host, \":\")\n\t\thostKey, err = getHostKey(host, strconv.Itoa(port))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tc.ClientConfig = &ssh.ClientConfig{\n\t\tUser: username,\n\t\tAuth: []ssh.AuthMethod{\n\t\t\t//ssh.Password(\"chrYsal1s-adm1n\"),\n\t\t\t//ssh.PublicKeyFile(\"/home/uthng/.ssh/ssh_servers\"),\n\t\t\tssh.PublicKeys(signer),\n\t\t},\n\t\t//HostKeyCallback: ssh.FixedHostKey(hostKey),\n\t\t//HostKeyCallback: ssh.InsecureIgnoreHostKey(),\n\t\t//HostKeyCallback: nil,\n\t}\n\n\tif checkHostKey {\n\t\tc.ClientConfig.HostKeyCallback = ssh.FixedHostKey(hostKey)\n\t} else {\n\t\tc.ClientConfig.HostKeyCallback = ssh.InsecureIgnoreHostKey()\n\t}\n\n\treturn c, nil\n}", "func (p *Plugin) getClientConfig(config *mux.Config, logger logging.Logger, topic string) (*client.Config, error) {\n\tclientCfg := client.NewConfig(logger)\n\t// Set brokers obtained from kafka config. In case there are none available, use a default one\n\tif len(config.Addrs) > 0 {\n\t\tclientCfg.SetBrokers(config.Addrs...)\n\t} else {\n\t\tclientCfg.SetBrokers(mux.DefAddress)\n\t}\n\t// Set group ID obtained from kafka config. In case there is none, use a service label\n\tif config.GroupID != \"\" {\n\t\tclientCfg.SetGroup(config.GroupID)\n\t} else {\n\t\tclientCfg.SetGroup(p.ServiceLabel.GetAgentLabel())\n\t}\n\tclientCfg.SetRecvMessageChan(p.subscription)\n\tclientCfg.SetInitialOffset(sarama.OffsetNewest)\n\tclientCfg.SetTopics(topic)\n\tif config.TLS.Enabled {\n\t\tp.Log.Info(\"TLS enabled\")\n\t\ttlsConfig, err := clienttls.CreateTLSConfig(config.TLS)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tclientCfg.SetTLS(tlsConfig)\n\t}\n\treturn clientCfg, nil\n}", "func New(username string, password string) core.SSHClient {\n\treturn &sshclient{\n\t\tconfig: &ssh.ClientConfig{\n\t\t\tUser: username,\n\t\t\tAuth: []ssh.AuthMethod{\n\t\t\t\tssh.Password(password),\n\t\t\t},\n\t\t\tTimeout: 5 * time.Second,\n\t\t\tHostKeyCallback: ssh.InsecureIgnoreHostKey(),\n\t\t},\n\t}\n}", "func (target *targetConfig) ClientConfig() (*ssh.ClientConfig, error) {\r\n\tif len(target.User) == 0 {\r\n\t\treturn nil, fmt.Errorf(\"target config requires a username\")\r\n\t}\r\n\r\n\t// Only supports password and pki methods. Soon interactive as well?\r\n\tswitch target.Auth.Method {\r\n\tcase \"password\":\r\n\t\treturn target.password()\r\n\tcase \"pki\":\r\n\t\treturn target.pki()\r\n\tdefault:\r\n\t\terr := fmt.Errorf(\"unknown authentication method %s\", target.Auth.Method)\r\n\t\treturn nil, err\r\n\t}\r\n}", "func DefaultClientConfig() ssh.ClientConfig {\n\treturn ssh.ClientConfig{\n\t\tAuth: []ssh.AuthMethod{\n\t\t\tAgent(),\n\t\t},\n\t\tHostKeyCallback: ssh.InsecureIgnoreHostKey(), // TODO - add ways to set host's public key\n\t}\n}", "func New(addr string, username string, password string) (*SSHClient, error) {\n\tcfg := &ssh.ClientConfig{\n\t\tUser: username,\n\t\tAuth: []ssh.AuthMethod{\n\t\t\tssh.Password(password),\n\t\t\tssh.KeyboardInteractive(func(user, instruction string, questions []string, echos []bool) ([]string, error) {\n\t\t\t\tif len(questions) == 0 {\n\t\t\t\t\treturn []string{}, nil\n\t\t\t\t}\n\t\t\t\tif len(questions) == 1 {\n\t\t\t\t\treturn []string{password}, nil\n\t\t\t\t}\n\t\t\t\treturn []string{}, fmt.Errorf(\"unsupported keyboard-interactive auth\")\n\t\t\t}),\n\t\t},\n\t\tHostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {\n\t\t\treturn nil\n\t\t},\n\t\tTimeout: clientTimeout,\n\t}\n\n\taddr, err := checkAndBuildAddr(addr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &SSHClient{addr: addr, config: cfg, lock: new(sync.Mutex)}, nil\n}", "func sshDefaultConfig(userName, identity string) (*ssh.ClientConfig, error) {\n\tcontents, err := loadIdentity(userName, identity)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsigner, err := ssh.ParsePrivateKey(contents)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &ssh.ClientConfig{\n\t\tUser: userName,\n\t\tAuth: []ssh.AuthMethod{\n\t\t\tssh.PublicKeys(signer),\n\t\t},\n\t}, nil\n}", "func NewClient(\n\tctx context.Context,\n\tuser,\n\thost,\n\tport,\n\tprivateKeyPath string,\n) (*Client, error) {\n\tauthMethod := []ssh.AuthMethod{}\n\tkey, err := ioutil.ReadFile(privateKeyPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsigner, err := ssh.ParsePrivateKey(key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tauthMethod = append(authMethod, ssh.PublicKeys(signer))\n\n\tsshConfig := &ssh.ClientConfig{\n\t\tUser: user,\n\t\tAuth: authMethod,\n\t\t// TOOD: change right callback\n\t\tHostKeyCallback: ssh.InsecureIgnoreHostKey(),\n\t}\n\taddr := fmt.Sprintf(\"%s:%s\", host, port)\n\treturn &Client{sshConfig, addr}, nil\n}", "func NewClientConfigWithUserPass(username string, password string, host string, port int, checkHostKey bool) (*Config, error) {\n\tvar hostKey ssh.PublicKey\n\tvar err error\n\n\tc := &Config{\n\t\tHost: host,\n\t\tPort: port,\n\t}\n\n\tif checkHostKey {\n\t\t//arr := strings.Split(host, \":\")\n\t\thostKey, err = getHostKey(host, strconv.Itoa(port))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tc.ClientConfig = &ssh.ClientConfig{\n\t\tUser: username,\n\t\tAuth: []ssh.AuthMethod{\n\t\t\tssh.Password(password),\n\t\t},\n\t}\n\n\tif checkHostKey {\n\t\tc.ClientConfig.HostKeyCallback = ssh.FixedHostKey(hostKey)\n\t} else {\n\t\tc.ClientConfig.HostKeyCallback = ssh.InsecureIgnoreHostKey()\n\t}\n\n\treturn c, nil\n}", "func NewClient(config ClientConfiguration) *Client {\n\tout := &Client{\n\t\tPort: 22,\n\t\tUser: \"ec2-user\",\n\t}\n\tif config.Host != \"\" {\n\t\tout.Host = config.Host\n\t}\n\tif config.Port != 0 {\n\t\tout.Port = config.Port\n\t}\n\tif config.User != \"\" {\n\t\tout.User = config.User\n\t}\n\tif config.PrivateKeyFile != \"\" {\n\t\tout.PrivateKeyFile = config.PrivateKeyFile\n\t}\n\treturn out\n}", "func NewSSHClient(keyPath, user, host string, port int) (*SSHClient, error) {\n\tkey, err := ioutil.ReadFile(keyPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tsigner, err := ssh.ParsePrivateKey(key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tconfig := &ssh.ClientConfig{\n\t\tUser: user,\n\t\tAuth: []ssh.AuthMethod{\n\t\t\tssh.PublicKeys(signer),\n\t\t},\n\t}\n\n\taddr := fmt.Sprintf(\"%s:%d\", host, port)\n\tclient, err := ssh.Dial(\"tcp\", addr, config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &SSHClient{client: client}, nil\n}", "func New(config *model.SFTP) (*server.Client, error) {\n\tvar err error\n\tvar client = &Client{cfg: config}\n\tvar sshConf *ssh.ClientConfig\n\tvar sshAuth []ssh.AuthMethod\n\n\t// SSH Auth\n\tif config.Key != \"\" {\n\t\tif sshAuth, err = client.readPublicKey(config.Key, config.Password); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to read SFTP public key, %v\", err)\n\t\t}\n\t} else {\n\t\tsshAuth = []ssh.AuthMethod{\n\t\t\tssh.Password(config.Password),\n\t\t}\n\t}\n\tsshConf = &ssh.ClientConfig{\n\t\tUser: config.Username,\n\t\tAuth: sshAuth,\n\t\tHostKeyCallback: ssh.InsecureIgnoreHostKey(),\n\t\tTimeout: config.Timeout * time.Second,\n\t}\n\n\tsshConf.SetDefaults()\n\tclient.ssh, err = ssh.Dial(\"tcp\", fmt.Sprintf(\"%s:%d\", config.Host, config.Port), sshConf)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot open ssh connection, %v\", err)\n\t}\n\n\tif client.sftp, err = sftp.NewClient(client.ssh, sftp.MaxPacket(config.MaxPacketSize)); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &server.Client{Handler: client}, err\n}", "func NewNativeConfig(user, clientVersion string, auth *Auth, hostKeyCallback ssh.HostKeyCallback) (ssh.ClientConfig, error) {\n\tvar (\n\t\tauthMethods []ssh.AuthMethod\n\t)\n\n\tif auth != nil {\n\t\trawKeys := auth.RawKeys\n\t\tfor _, k := range auth.Keys {\n\t\t\tkey, err := ioutil.ReadFile(k)\n\t\t\tif err != nil {\n\t\t\t\treturn ssh.ClientConfig{}, err\n\t\t\t}\n\n\t\t\trawKeys = append(rawKeys, key)\n\t\t}\n\n\t\tfor _, key := range rawKeys {\n\t\t\tprivateKey, err := ssh.ParsePrivateKey(key)\n\t\t\tif err != nil {\n\t\t\t\treturn ssh.ClientConfig{}, err\n\t\t\t}\n\n\t\t\tauthMethods = append(authMethods, ssh.PublicKeys(privateKey))\n\t\t}\n\n\t\tfor _, p := range auth.Passwords {\n\t\t\tauthMethods = append(authMethods, ssh.Password(p))\n\t\t}\n\t}\n\n\tif hostKeyCallback == nil {\n\t\thostKeyCallback = ssh.InsecureIgnoreHostKey()\n\t}\n\n\treturn ssh.ClientConfig{\n\t\tUser: user,\n\t\tAuth: authMethods,\n\t\tClientVersion: clientVersion,\n\t\tHostKeyCallback: hostKeyCallback,\n\t}, nil\n}", "func NewClient(c *ClientConfig) (*Client, error) {\n\tclient := new(Client)\n\n\tif len(c.BindAddr) == 0 {\n\t\treturn nil, errors.New(\"need bind address\")\n\t}\n\n\tif len(c.RemoteAddr) == 0 {\n\t\treturn nil, errors.New(\"need remote server address\")\n\t}\n\n\tif c.Timeout <= 0 {\n\t\treturn nil, errors.New(\"timeout value must at least 1 sec\")\n\t}\n\n\tif len(c.ServerName) == 0 { //set ServerName from RemoteAddr\n\t\thost, _, err := net.SplitHostPort(c.RemoteAddr)\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"cannot get the host address from the remote server address\")\n\t\t}\n\t\tc.ServerName = host\n\t}\n\n\tif c.MuxMaxStream < 1 || c.MuxMaxStream > defaultSmuxMaxStream {\n\t\treturn nil, fmt.Errorf(\"mux max stream should between 1 - 16\")\n\t}\n\n\t//init\n\n\t//logger\n\tclient.log = logrus.New()\n\tif c.Verbose {\n\t\tclient.log.SetLevel(logrus.DebugLevel)\n\t} else {\n\t\tclient.log.SetLevel(logrus.ErrorLevel)\n\t}\n\n\t//config\n\tclient.tcpConfig = &tcpConfig{tfo: c.EnableTFO, vpnMode: c.VpnMode}\n\tclient.tlsConf = &tls.Config{\n\t\tInsecureSkipVerify: c.InsecureSkipVerify,\n\t\tServerName: c.ServerName,\n\t\tClientSessionCache: tls.NewLRUClientSessionCache(16),\n\t}\n\n\t//net dialer\n\tclient.netDialer = &net.Dialer{\n\t\tControl: getControlFunc(client.tcpConfig),\n\t\tTimeout: defaultHandShakeTimeout,\n\t}\n\n\t//ws\n\tif !strings.HasPrefix(c.WSSPath, \"/\") {\n\t\tc.WSSPath = \"/\" + c.WSSPath\n\t}\n\tclient.wssURL = \"wss://\" + c.ServerName + c.WSSPath\n\tinternelDial := func(network, addr string) (net.Conn, error) {\n\t\t// overwrite url host addr\n\t\treturn client.dialServerRaw()\n\t}\n\tclient.wsDialer = &websocket.Dialer{\n\t\tTLSClientConfig: client.tlsConf,\n\t\tNetDial: internelDial,\n\n\t\tReadBufferSize: defaultWSIOBufferSize,\n\t\tWriteBufferSize: defaultWSIOBufferSize,\n\t\tWriteBufferPool: &sync.Pool{},\n\t\tHandshakeTimeout: defaultHandShakeTimeout,\n\t}\n\tif c.EnableMux {\n\t\tclient.wsDialer.Subprotocols = []string{websocketSubprotocolSmuxON}\n\t} else {\n\t\tclient.wsDialer.Subprotocols = []string{websocketSubprotocolSmuxOFF}\n\t}\n\n\t// fallback dns\n\tif len(c.FallbackDNS) != 0 {\n\t\t//set fallback dns server\n\t\tif net.ParseIP(c.FallbackDNS) == nil { //it's not a IP addr\n\t\t\treturn nil, fmt.Errorf(\"fallback dns server must be an IP addr, got %s\", c.FallbackDNS)\n\t\t}\n\n\t\t//just overwrite net.DefaultResolver\n\t\tnet.DefaultResolver.PreferGo = true\n\t\tnet.DefaultResolver.Dial = func(ctx context.Context, network, address string) (net.Conn, error) {\n\t\t\td := net.Dialer{}\n\t\t\td.Control = getControlFunc(client.tcpConfig)\n\t\t\treturn d.DialContext(ctx, \"tcp\", c.FallbackDNS)\n\t\t}\n\t}\n\n\t//smux pool\n\tclient.smuxSessPool = smuxSessPool{}\n\n\tclient.smuxConfig = defaultSmuxConfig()\n\tclient.conf = c\n\treturn client, nil\n}", "func (o *ClientConfig) NewClient(options ...ClientOption) (Client, error) {\n\n\t// Run provided ClientOption configuration options.\n\tfor _, opt := range options {\n\t\terr := opt(o)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed applying functional option: %w\", err)\n\t\t}\n\t}\n\n\t// Check mandatory option is provided.\n\tif o.githubUserClient == nil {\n\t\treturn nil, fmt.Errorf(\"github client not provided\")\n\t}\n\n\ttokenGenerator := secret.GetTokenGenerator(o.tokenPath)\n\n\tgitFactory, err := o.GitClient(o.githubUserClient, tokenGenerator, secret.Censor, false)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tgitClient := &client{}\n\t// Initialize map to enable writing to it in methods.\n\tgitClient.clonedRepos = make(map[string]string)\n\tgitClient.ClientFactory = gitFactory\n\treturn gitClient, err\n}", "func populateClientConfig(config *Config) *Config {\n\tif config == nil {\n\t\tconfig = &Config{}\n\t}\n\tversions := config.Versions\n\tif len(versions) == 0 {\n\t\tversions = protocol.SupportedVersions\n\t}\n\n\thandshakeTimeout := protocol.DefaultHandshakeTimeout\n\tif config.HandshakeTimeout != 0 {\n\t\thandshakeTimeout = config.HandshakeTimeout\n\t}\n\tidleTimeout := protocol.DefaultIdleTimeout\n\tif config.IdleTimeout != 0 {\n\t\tidleTimeout = config.IdleTimeout\n\t}\n\n\tmaxReceiveStreamFlowControlWindow := config.MaxReceiveStreamFlowControlWindow\n\tif maxReceiveStreamFlowControlWindow == 0 {\n\t\tmaxReceiveStreamFlowControlWindow = protocol.DefaultMaxReceiveStreamFlowControlWindowClient\n\t}\n\tmaxReceiveConnectionFlowControlWindow := config.MaxReceiveConnectionFlowControlWindow\n\tif maxReceiveConnectionFlowControlWindow == 0 {\n\t\tmaxReceiveConnectionFlowControlWindow = protocol.DefaultMaxReceiveConnectionFlowControlWindowClient\n\t}\n\n\treturn &Config{\n\t\tVersions: versions,\n\t\tHandshakeTimeout: handshakeTimeout,\n\t\tIdleTimeout: idleTimeout,\n\t\tRequestConnectionIDTruncation: config.RequestConnectionIDTruncation,\n\t\tMaxReceiveStreamFlowControlWindow: maxReceiveStreamFlowControlWindow,\n\t\tMaxReceiveConnectionFlowControlWindow: maxReceiveConnectionFlowControlWindow,\n\t\tKeepAlive: config.KeepAlive,\n\t\tCacheHandshake: config.CacheHandshake,\n\t\tCreatePaths: config.CreatePaths,\n\t}\n}", "func (s *SSHRunner) client() (*ssh.Client, error) {\n\tif s.c != nil {\n\t\treturn s.c, nil\n\t}\n\n\tc, err := sshutil.NewSSHClient(s.d)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"new client\")\n\t}\n\ts.c = c\n\treturn s.c, nil\n}", "func (b *backend) getClientConfig(s logical.Storage, region, stsRole, clientType string) (*aws.Config, error) {\n\n\tconfig, err := b.getRawClientConfig(s, region, clientType)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif config == nil {\n\t\treturn nil, fmt.Errorf(\"could not compile valid credentials through the default provider chain\")\n\t}\n\n\tif stsRole != \"\" {\n\t\tassumeRoleConfig, err := b.getRawClientConfig(s, region, \"sts\")\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif assumeRoleConfig == nil {\n\t\t\treturn nil, fmt.Errorf(\"could not configure STS client\")\n\t\t}\n\t\tassumedCredentials := stscreds.NewCredentials(session.New(assumeRoleConfig), stsRole)\n\t\t// Test that we actually have permissions to assume the role\n\t\tif _, err = assumedCredentials.Get(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tconfig.Credentials = assumedCredentials\n\t}\n\n\treturn config, nil\n}", "func NewClient(host string, port int, user string, key string) (Client, error) {\n\tif err := ValidUnencryptedPrivateKey(key); err != nil {\n\t\treturn nil, err\n\t}\n\n\tsshBinaryPath, err := exec.LookPath(\"ssh\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"command not found: ssh\")\n\t}\n\n\treturn newExternalClient(sshBinaryPath, user, host, port, key)\n}", "func NewClientConfig(credentials auth.CredentialProvider, tokenURL string) (*Config, error) {\n\n\tif len(credentials.GetAppID()) < 0 || len(credentials.GetAppPassword()) < 0 {\n\t\treturn &Config{}, errors.New(\"Invalid client credentials\")\n\t}\n\n\tparsedURL, err := url.Parse(tokenURL)\n\tif err != nil {\n\t\treturn &Config{}, errors.New(\"Invalid token URL\")\n\t}\n\n\treturn &Config{\n\t\tCredentials: credentials,\n\t\tAuthURL: *parsedURL,\n\t}, nil\n}", "func getSSHConfigString() string {\n\n\tconfigString := `Host *\nStrictHostKeyChecking yes\nIdentityFile /etc/ssh/id_ecdsa\nPort 2022\nUser postgres\n`\n\treturn configString\n}", "func NewInteractiveClientConfig(config clientcmdapi.Config, contextName string, overrides *ConfigOverrides, fallbackReader io.Reader, configAccess ConfigAccess) ClientConfig {\n\treturn &DirectClientConfig{config, contextName, overrides, fallbackReader, configAccess, promptedCredentials{}}\n}", "func newSSHConnectionAndAuth(c *model.Config) (Authentication, error) {\n\ts, err := ssh.Connect(c)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tssh := &SSH{\n\t\tconn: s,\n\t\thost: c.Host,\n\t\tport: c.Port,\n\t\tusername: c.Username,\n\t\tpassword: c.Password,\n\t\ttimeout: c.Timeout,\n\t\ttimeoutCommand: c.TimeoutCommand,\n\t}\n\tif err := ssh.setBannerName(); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn ssh, nil\n}", "func newSSH(ip net.IPAddr, port uint16, user string, pass string, key string) *inet.SSH {\n\tvar remoteConn = new(inet.SSH)\n\tremoteConn.Make(ip.String(), strconv.FormatUint(uint64(port), 10), user, pass, key)\n\tglog.Info(\"receiver host: \" + ip.String())\n\treturn remoteConn\n}", "func (cc *ClientConfig) initialize() (err error) {\n\tuserHomeDir, err := os.UserHomeDir()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"ssh: cannot get user's home directory: \" + err.Error())\n\t}\n\n\tif len(cc.WorkingDir) == 0 {\n\t\tcc.WorkingDir, err = os.Getwd()\n\t\tif err != nil {\n\t\t\tlog.Println(\"ssh: cannot get working directory, default to user's home\")\n\t\t\tcc.WorkingDir = userHomeDir\n\t\t}\n\t}\n\n\tif len(cc.PrivateKeyFile) == 0 {\n\t\tcc.PrivateKeyFile = filepath.Join(userHomeDir, \".ssh\", \"id_rsa\")\n\t}\n\n\t_, err = os.Stat(cc.PrivateKeyFile)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn fmt.Errorf(\"ssh: private key path %q does not exist\", cc.PrivateKeyFile)\n\t\t}\n\t\treturn fmt.Errorf(\"ssh: os.Stat %q: %s\", cc.PrivateKeyFile, err)\n\t}\n\n\tif len(cc.RemoteUser) == 0 {\n\t\treturn fmt.Errorf(\"ssh: remote user is not defined\")\n\t}\n\tif len(cc.RemoteHost) == 0 {\n\t\treturn fmt.Errorf(\"ssh: remote host is not defined\")\n\t}\n\tif cc.RemotePort <= 0 || cc.RemotePort >= 65535 {\n\t\tlog.Printf(\"ssh: using default port instead of %d\\n\", cc.RemotePort)\n\t\tcc.RemotePort = 22\n\t}\n\n\tcc.remotePort = strconv.Itoa(cc.RemotePort)\n\tcc.remoteAddr = fmt.Sprintf(\"%s:%d\", cc.RemoteHost, cc.RemotePort)\n\n\treturn nil\n}", "func NewClientConfigWithSignedPubKeyFile(username, sshKey, signedPubKey, host string, port int, checkHostKey bool) (*Config, error) {\n\tvar hostKey ssh.PublicKey\n\n\tc := &Config{\n\t\tHost: host,\n\t\tPort: port,\n\t}\n\n\t// Read private key\n\tkey, err := ioutil.ReadFile(sshKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create the Signer for this private key.\n\tsigner, err := ssh.ParsePrivateKey(key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Load the certificate\n\tcert, err := ioutil.ReadFile(signedPubKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpubKey, _, _, _, err := ssh.ParseAuthorizedKey(cert)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcertSigner, err := ssh.NewCertSigner(pubKey.(*ssh.Certificate), signer)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif checkHostKey {\n\t\t//arr := strings.Split(host, \":\")\n\t\thostKey, err = getHostKey(host, strconv.Itoa(port))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tc.ClientConfig = &ssh.ClientConfig{\n\t\tUser: username,\n\t\tAuth: []ssh.AuthMethod{\n\t\t\t//ssh.Password(\"chrYsal1s-adm1n\"),\n\t\t\t//ssh.PublicKeyFile(\"/home/uthng/.ssh/ssh_servers\"),\n\t\t\tssh.PublicKeys(certSigner),\n\t\t},\n\t\t//HostKeyCallback: ssh.FixedHostKey(hostKey),\n\t\t//HostKeyCallback: ssh.InsecureIgnoreHostKey(),\n\t\t//HostKeyCallback: nil,\n\t}\n\n\tif checkHostKey {\n\t\tc.ClientConfig.HostKeyCallback = ssh.FixedHostKey(hostKey)\n\t} else {\n\t\tc.ClientConfig.HostKeyCallback = ssh.InsecureIgnoreHostKey()\n\t}\n\n\treturn c, nil\n}", "func ConnectSSH(ip string) (*goph.Client, error) {\n\t// gets private ssh key\n\thome, err := os.UserHomeDir()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdir := home + \"/.ssh/id_rsa\"\n\treader := bufio.NewReader(os.Stdin)\n\tfmt.Printf(\"Type password of ssh key:\")\n\tpass, err := reader.ReadString('\\n')\n\tpass = strings.Trim(pass, \"\\n\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// gets an auth method goph.Auth for handling the connection request\n\tauth, err := goph.Key(dir, pass)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// asks for a new ssh connection returning the client for SSH\n\tclient, err := goph.NewConn(&goph.Config{\n\t\tUser: \"root\",\n\t\tAddr: ip,\n\t\tPort: 22,\n\t\tAuth: auth,\n\t\tCallback: VerifyHost, //HostCallBack custom (appends host to known_host if not exists)\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn client, nil\n}", "func NewClient(id ID, sshName, name, hash string, conn ssh.Channel, player *area.Player) *Client {\n\tif hash == \"\" {\n\t\thash = name //finally, hash fallsback to name\n\t}\n\tp := &Client{\n\t\tid: id,\n\t\thash: hash,\n\t\tSSHName: sshName,\n\t\tName: name,\n\t\tready: false,\n\t\tresizes: make(chan resize),\n\t\tconn: ansi.Wrap(conn),\n\t\tpromptBar: NewPromptBar(),\n\t\tPlayer: player,\n\t}\n\treturn p\n}", "func NewSSH(keyConfig *v1alpha1.KeyConfig) *SSH {\n\tssh := &SSH{\n\t\tName: keyConfig.Name,\n\t}\n\treturn ssh\n}", "func (c *Client) ClientConfig(conf ssh.ClientConfig) *Client {\n\tc.clientConfig = &conf\n\treturn c\n}", "func BuildClientConfig(kubeConfigPath string, clusterName string) (*rest.Config, error) {\n\toverrides := clientcmd.ConfigOverrides{}\n\t// Override the cluster name if provided.\n\tif clusterName != \"\" {\n\t\toverrides.Context.Cluster = clusterName\n\t}\n\treturn clientcmd.NewNonInteractiveDeferredLoadingClientConfig(\n\t\t&clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeConfigPath},\n\t\t&overrides).ClientConfig()\n}", "func newClient() *sts.STS {\n\tsess := session.Must(session.NewSessionWithOptions(session.Options{\n\t\tSharedConfigState: session.SharedConfigEnable,\n\t}))\n\tconfig := aws.NewConfig()\n\tif debug {\n\t\tconfig.WithLogLevel(aws.LogDebugWithHTTPBody)\n\t}\n\treturn sts.New(sess, config)\n}", "func (sshClient *SSHClient) connect() (*ssh.Session, error) {\n\tvar (\n\t\tauth []ssh.AuthMethod\n\t\taddr string\n\t\tclientConfig *ssh.ClientConfig\n\t\tclient *ssh.Client\n\t\tsession *ssh.Session\n\t\terr error\n\t)\n\n\t// get auth method\n\tauth = make([]ssh.AuthMethod, 0)\n\tauth = append(auth, ssh.Password(sshClient.Password))\n\n\thostKeyCallbk := func(hostname string, remote net.Addr, key ssh.PublicKey) error {\n\t\treturn nil\n\t}\n\n\tclientConfig = &ssh.ClientConfig{\n\t\tUser: sshClient.Username,\n\t\tAuth: auth,\n\t\tTimeout: 30 * time.Second,\n\t\tHostKeyCallback: hostKeyCallbk,\n\t}\n\n\tclientConfig.Ciphers = append(clientConfig.Ciphers, \"aes128-cbc\", \"aes128-ctr\")\n\n\tif sshClient.KexAlgorithms != \"\" {\n\t\tclientConfig.KeyExchanges = append(clientConfig.KeyExchanges, sshClient.KexAlgorithms)\n\t} else {\n\t\tclientConfig.KeyExchanges = append(clientConfig.KeyExchanges, \"diffie-hellman-group1-sha1\")\n\t}\n\n\t/*if sshClient.Cipher != \"\" {\n\t\tclientConfig.Cipher = append(clientConfig.Cipher, sshClient.Cipher)\n\t} else {\n\t\tclientConfig.Cipher = append(clientConfig.Cipher, \"diffie-hellman-group1-sha1\")\n\t}*/\n\n\t// connet to ssh\n\taddr = fmt.Sprintf(\"%s:%d\", sshClient.Host, sshClient.Port)\n\n\tif client, err = ssh.Dial(\"tcp\", addr, clientConfig); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// create session\n\tif session, err = client.NewSession(); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn session, nil\n}", "func getSSH(t *testing.T, vm *gcp.VM) (ssh.Client, error) {\n\tips, err := vm.GetIPs()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient := &ssh.SSHClient{\n\t\tCreds: &vm.SSHCreds,\n\t\tPort: 22,\n\t}\n\n\tif onKokoro, err := isStartedByKokoro(); err != nil {\n\t\treturn nil, err\n\t} else if onKokoro {\n\t\tclient.IP = ips[gcp.PrivateIP]\n\t\tt.Logf(\"Detected that VM is started by Kokoro, so using private IP: %v\", client.IP)\n\t} else {\n\t\tclient.IP = ips[gcp.PublicIP]\n\t\tt.Logf(\"Using public VM IP: %v\", client.IP)\n\t}\n\n\tif err := client.WaitForSSH(5 * time.Minute); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn client, nil\n}", "func (n *Node) GetClient() (*ssh.Client, error) {\n\n\tlog.WithFields(logrus.Fields{\n\t\t\"host\": n.IP,\n\t\t\"username\": n.Username,\n\t\t\"package\": \"connection\",\n\t\t\"color\": n.Color,\n\t}).Info(\"Opening SSH session\")\n\n\tsshConfig := &ssh.ClientConfig{\n\t\tUser: n.Username,\n\t\tAuth: []ssh.AuthMethod{\n\t\t\tssh.Password(n.Password),\n\t\t},\n\t}\n\n\tclient, err := ssh.Dial(\"tcp\", n.IP+\":22\", sshConfig)\n\tif err != nil {\n\t\treturn nil, errors.New(\"Failed to dial: \" + n.IP)\n\t}\n\n\tn.sshClient = client\n\n\treturn client, nil\n}", "func (c *ReplicaClient) Init(ctx context.Context) (_ *sftp.Client, err error) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tif c.sftpClient != nil {\n\t\treturn c.sftpClient, nil\n\t}\n\n\tif c.User == \"\" {\n\t\treturn nil, fmt.Errorf(\"sftp user required\")\n\t}\n\n\t// Build SSH configuration & auth methods\n\tconfig := &ssh.ClientConfig{\n\t\tUser: c.User,\n\t\tHostKeyCallback: ssh.InsecureIgnoreHostKey(),\n\t\tBannerCallback: ssh.BannerDisplayStderr(),\n\t}\n\tif c.Password != \"\" {\n\t\tconfig.Auth = append(config.Auth, ssh.Password(c.Password))\n\t}\n\n\tif c.KeyPath != \"\" {\n\t\tbuf, err := os.ReadFile(c.KeyPath)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot read sftp key path: %w\", err)\n\t\t}\n\n\t\tsigner, err := ssh.ParsePrivateKey(buf)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot parse sftp key path: %w\", err)\n\t\t}\n\t\tconfig.Auth = append(config.Auth, ssh.PublicKeys(signer))\n\t}\n\n\t// Append standard port, if necessary.\n\thost := c.Host\n\tif _, _, err := net.SplitHostPort(c.Host); err != nil {\n\t\thost = net.JoinHostPort(c.Host, \"22\")\n\t}\n\n\t// Connect via SSH.\n\tif c.sshClient, err = ssh.Dial(\"tcp\", host, config); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Wrap connection with an SFTP client.\n\tif c.sftpClient, err = sftp.NewClient(c.sshClient); err != nil {\n\t\tc.sshClient.Close()\n\t\tc.sshClient = nil\n\t\treturn nil, err\n\t}\n\n\treturn c.sftpClient, nil\n}", "func NewClient(config *Config) (c *Client, err error) {\n\tif config == nil {\n\t\treturn nil, errClientConfigNil\n\t}\n\n\tc = &Client{\n\t\trevocationTransport: http.DefaultTransport,\n\t}\n\n\tif c.transport, err = ghinstallation.NewAppsTransport(\n\t\thttp.DefaultTransport,\n\t\tint64(config.AppID),\n\t\t[]byte(config.PrvKey),\n\t); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif c.url, err = url.ParseRequestURI(fmt.Sprintf(\n\t\t\"%s/app/installations/%v/access_tokens\",\n\t\tstrings.TrimSuffix(fmt.Sprint(config.BaseURL), \"/\"),\n\t\tconfig.InsID,\n\t)); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif c.revocationURL, err = url.ParseRequestURI(fmt.Sprintf(\n\t\t\"%s/installation/token\",\n\t\tstrings.TrimSuffix(fmt.Sprint(config.BaseURL), \"/\"),\n\t)); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn c, nil\n}", "func (s *SSHNegotiator) initSSHServerConfig() *ssh.ServerConfig {\n\t// An SSH server is represented by a ServerConfig,\n\t// which holds certificate details and handles authentication of ServerConns.\n\tserverConfig := &ssh.ServerConfig{\n\t\tPublicKeyCallback: s.publicKeyAuth,\n\t}\n\n\t// Initialise map of authorized keys\n\ts.AuthKeys = make(map[string][]ssh.PublicKey)\n\n\ts.populateAuthorizedKeys()\n\n\terr := s.initPrivateKey()\n\tif err != nil {\n\t\tsimplelog.Fatal.Printf(\"Error generating private key: %q\", err)\n\t}\n\n\tserverConfig.AddHostKey(s.privateKey)\n\n\treturn serverConfig\n}", "func makeClients(cmd string, c *cli.Context) []*SSHClient.SSHClient {\n\tif c.String(\"user\") == \"\" {\n\t\tfmt.Fprintln(os.Stderr, \"Error: No --user/-u provided\")\n os.Exit(1)\n\t}\n\n\tif c.String(\"pkey\") == \"\" {\n\t\tfmt.Fprintln(os.Stderr, \"Error: No --pkey/-k provided\")\n os.Exit(1)\n\t}\n\n\tsshConfig := &ssh.ClientConfig{\n\t\tUser: c.String(\"user\"),\n\t\tAuth: []ssh.AuthMethod{\n\t\t\tSSHClient.PublicKeyFile(c.String(\"pkey\")),\n\t\t},\n\t}\n\n\thosts := deleteEmpty(c.StringSlice(\"host\"))\n\tif len(hosts) == 0 {\n\t\tfmt.Fprintln(os.Stderr, \"Error: No --hosts/-x provided\")\n os.Exit(1)\n\t}\n\n\tclients := make([]*SSHClient.SSHClient, len(hosts))\n\tfor i, host := range hosts {\n\t\t_cmd := &SSHClient.SSHCommand{\n\t\t\tCmd: cmd,\n\t\t}\n\t\tclient := &SSHClient.SSHClient{\n\t\t\tConfig: sshConfig,\n\t\t\tHost: host,\n\t\t\tPort: 22,\n\t\t\tCmd: _cmd,\n\t\t}\n\t\tclients[i] = client\n\t}\n\n\treturn clients\n}", "func (cf *clientFactory) newClient(authInfo *api.AuthInfo) (ClientInterface, error) {\n\tconfig := *cf.baseIstioConfig\n\n\tconfig.BearerToken = authInfo.Token\n\n\t// There is a feature when using OpenID strategy to allow using a proxy\n\t// for the cluster API. People may want to place a proxy in\n\t// front of the cluster API when using Kubernetes-as-a-service and\n\t// the provider does not support configuring OpenID integration.\n\t// If OpenID integration is not available, people may opt into\n\t// an API proxy (like kube-oidc-proxy) as a workaround for OIDC integration.\n\t// Clearly, under this scenario, the cluster API must be accessed\n\t// through the proxy (not directly).\n\t//\n\t// So, if OpenID strategy is active, check if a proxy is configured.\n\t// If there is, use it UNLESS the token is the one of the Kiali SA. If\n\t// the token is the one of the Kiali SA, the proxy can be bypassed.\n\tcfg := kialiConfig.Get()\n\tif cfg.Auth.Strategy == kialiConfig.AuthStrategyOpenId && cfg.Auth.OpenId.ApiProxy != \"\" && cfg.Auth.OpenId.ApiProxyCAData != \"\" {\n\t\tkialiToken, err := GetKialiToken()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif kialiToken != authInfo.Token {\n\t\t\t// Using `UseRemoteCreds` function as a helper\n\t\t\tapiProxyConfig, errProxy := UseRemoteCreds(&RemoteSecret{\n\t\t\t\tClusters: []RemoteSecretClusterListItem{\n\t\t\t\t\t{\n\t\t\t\t\t\tCluster: RemoteSecretCluster{\n\t\t\t\t\t\t\tCertificateAuthorityData: cfg.Auth.OpenId.ApiProxyCAData,\n\t\t\t\t\t\t\tServer: cfg.Auth.OpenId.ApiProxy,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tName: \"api_proxy\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tif errProxy != nil {\n\t\t\t\treturn nil, errProxy\n\t\t\t}\n\n\t\t\tconfig.Host = apiProxyConfig.Host\n\t\t\tconfig.TLSClientConfig = apiProxyConfig.TLSClientConfig\n\t\t}\n\t}\n\n\t// Impersonation is valid only for header authentication strategy\n\tif cfg.Auth.Strategy == kialiConfig.AuthStrategyHeader && authInfo.Impersonate != \"\" {\n\t\tconfig.Impersonate.UserName = authInfo.Impersonate\n\t\tconfig.Impersonate.Groups = authInfo.ImpersonateGroups\n\t\tconfig.Impersonate.Extra = authInfo.ImpersonateUserExtra\n\t}\n\n\treturn NewClientFromConfig(&config)\n}", "func configSSH(l *logrus.Logger, ssh *sshd.SSHServer, c *config.C) (func(), error) {\n\t//TODO conntrack list\n\t//TODO print firewall rules or hash?\n\n\tlisten := c.GetString(\"sshd.listen\", \"\")\n\tif listen == \"\" {\n\t\treturn nil, fmt.Errorf(\"sshd.listen must be provided\")\n\t}\n\n\t_, port, err := net.SplitHostPort(listen)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid sshd.listen address: %s\", err)\n\t}\n\tif port == \"22\" {\n\t\treturn nil, fmt.Errorf(\"sshd.listen can not use port 22\")\n\t}\n\n\t//TODO: no good way to reload this right now\n\thostKeyFile := c.GetString(\"sshd.host_key\", \"\")\n\tif hostKeyFile == \"\" {\n\t\treturn nil, fmt.Errorf(\"sshd.host_key must be provided\")\n\t}\n\n\thostKeyBytes, err := ioutil.ReadFile(hostKeyFile)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error while loading sshd.host_key file: %s\", err)\n\t}\n\n\terr = ssh.SetHostKey(hostKeyBytes)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error while adding sshd.host_key: %s\", err)\n\t}\n\n\trawKeys := c.Get(\"sshd.authorized_users\")\n\tkeys, ok := rawKeys.([]interface{})\n\tif ok {\n\t\tfor _, rk := range keys {\n\t\t\tkDef, ok := rk.(map[interface{}]interface{})\n\t\t\tif !ok {\n\t\t\t\tl.WithField(\"sshKeyConfig\", rk).Warn(\"Authorized user had an error, ignoring\")\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tuser, ok := kDef[\"user\"].(string)\n\t\t\tif !ok {\n\t\t\t\tl.WithField(\"sshKeyConfig\", rk).Warn(\"Authorized user is missing the user field\")\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tk := kDef[\"keys\"]\n\t\t\tswitch v := k.(type) {\n\t\t\tcase string:\n\t\t\t\terr := ssh.AddAuthorizedKey(user, v)\n\t\t\t\tif err != nil {\n\t\t\t\t\tl.WithError(err).WithField(\"sshKeyConfig\", rk).WithField(\"sshKey\", v).Warn(\"Failed to authorize key\")\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\tcase []interface{}:\n\t\t\t\tfor _, subK := range v {\n\t\t\t\t\tsk, ok := subK.(string)\n\t\t\t\t\tif !ok {\n\t\t\t\t\t\tl.WithField(\"sshKeyConfig\", rk).WithField(\"sshKey\", subK).Warn(\"Did not understand ssh key\")\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\terr := ssh.AddAuthorizedKey(user, sk)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tl.WithError(err).WithField(\"sshKeyConfig\", sk).Warn(\"Failed to authorize key\")\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tl.WithField(\"sshKeyConfig\", rk).Warn(\"Authorized user is missing the keys field or was not understood\")\n\t\t\t}\n\t\t}\n\t} else {\n\t\tl.Info(\"no ssh users to authorize\")\n\t}\n\n\tvar runner func()\n\tif c.GetBool(\"sshd.enabled\", false) {\n\t\tssh.Stop()\n\t\trunner = func() {\n\t\t\tif err := ssh.Run(listen); err != nil {\n\t\t\t\tl.WithField(\"err\", err).Warn(\"Failed to run the SSH server\")\n\t\t\t}\n\t\t}\n\t} else {\n\t\tssh.Stop()\n\t}\n\n\treturn runner, nil\n}", "func (d *SSHDialer) GetSSHUserPassConfig() (*ssh.ClientConfig, error) {\n\tsshUserPassConfig := &ssh.ClientConfig{\n\t\tUser: d.DialerTargetInfo.TargetUser,\n\t\t// todo : change this implementation to be passed from the idp / secret manage\n\t\tAuth: []ssh.AuthMethod{ssh.Password(cfg.Dialer_Config.Password)},\n\t\tTimeout: 15 * time.Second,\n\t}\n\tsshUserPassConfig.HostKeyCallback = ssh.InsecureIgnoreHostKey()\n\n\tif sshUserPassConfig == nil {\n\t\treturn nil, fmt.Errorf(\"No ssh user pass config\")\n\t}\n\treturn sshUserPassConfig, nil\n}", "func InitClientWithConf(\n\ttls *config.TLS, scram *config.SCRAM, brokers ...string,\n) (sarama.Client, error) {\n\tc, err := LoadConfig(tls, scram)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// sarama shuffles the addresses, so there's no need to do it.\n\treturn sarama.NewClient(brokers, c)\n}", "func NewClient(conf Config) (*Client, error) {\n\tif conf.Timeout == time.Duration(0) {\n\t\tconf.Timeout = defaultTimeout\n\t}\n\tsop, err := conf.ToSecureOptions(newSelfSignedTLSCert)\n\tif err != nil {\n\t\treturn nil, errors.WithStack(err)\n\t}\n\tcc := comm.ClientConfig{\n\t\tSecOpts: sop,\n\t\tDialTimeout: conf.Timeout,\n\t}\n\treturn &Client{config: cc, TLSCertHash: util.ComputeSHA256(sop.Certificate)}, nil\n}", "func copyConnect(user, host string, port int) (*sftp.Client, error) {\n\tvar (\n\t\tauth \t\t\t[]ssh.AuthMethod\n\t\taddr \t\t\tstring\n\t\tclientConfig \t*ssh.ClientConfig\n\t\tsshClient \t\t*ssh.Client\n\t\tsftpClient \t\t*sftp.Client\n\t\terr \t\t\terror\n\t)\n\tauth = make([]ssh.AuthMethod, 0)\n\ttestPrivateKeys, err := ssh.ParseRawPrivateKey([]byte(`-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEApnIg4Q/g2thAR3vAUw6EPjqgWIEJ7+FZ+AQZtHUc7b920VJI\n7JPmZ1xwdUArlCpQIMAt6mAwV9Z/C+Nc9qIpIeQwKaAd6YWVdr3jFyHLC9rqIT2g\nVifCDnMkSnV7Lvuu5QTvgURGOYpyUhUDJBdBY4YAu9q1ITy35oB0xLh1vUCwuDxI\noM5lMc+HsPjf4/SyfyAacBuoD7BvAJsxJ6xuXBaIlmWcw8o76O/Y5PGcYKPS9/bI\nrN8TrstuWILp2Nvi4WoxVMIQ98i1S6jM47arI+vNGlFrwolrCanH8GBj1NOBh4BF\nJwJisi0Z3+RrtxOVRtgZ9S/tKdK73X6EpbN4hwIDAQABAoIBAAuBRAiKgm5eGENY\nqHiVPkrW3pJ/iOJN31wnXGd+2NsOKvZZC7Vem8R1PUi9gMWjDxrUbdgPggfwSaPW\nuWxK1TEEhte5u5eSpjwo7/N/YHuXTCu0CMsrwFwjVVTYPgWHXBV0e+GhiIEdsr09\nupPaD6kDcDWL7o03lzaVlnyqi2jjXT6kUDyEFCbIAGtoxaYf3clT5e30FnyZhiCH\nm8/Qqv5M1wcVIVdsItHqMsQXQF34eT/Lg3r/Ui1bQcUldc6yYjGpC08EdDNKhGT2\nf2QwAv7UJ+GB8RNl12w3fAh3ReuiW8NEtDQ1nuSahkX5YlIWkqRDOd6Sjrg1ZkfW\nu0/zPZECgYEA2m+w90vb3ui7M/Q0AYJivo88YKhT3ismQs2+CkkgWJ7IohJj3VSh\nREljeAwEVEKv8G8lXgjTNKQ+B4sPFckIvIWGkwo7cuerIwn9n41K20oGb6gEl0jW\nmVbhv0dy6yfp8deBCOZB4YgonXWsuv4lw8DaUoakGxZgFfChjH0VvbUCgYEAwxGj\nrmq+RQWYYna9WWn2GPEJoX0SBU39pHQYBKfQ++pMIUrrryCjPvBNnIICng82RjTp\nMU8BvudvDCJgj3J79TDetBnwVt8/nAGIkleyuWzDMQwF7khBS9/TqUUqmH88GmOt\n40BPThCBx8YgKiPpmGYgPnUww1bqpvxKT9O0IssCgYEAjFH7qKD+mW9/8pwJXH7Z\n1/hDnQQE/E9TwM5SKmFXehZmZFbT+DaJckiCsXdmwIomY5nCs2mP490uS8I06pW+\nGvzbulF0ZxgTg+rDFl+5mq0u/UM9z8FmuhJp6mqHlDCLxGPf7EuePrctABm74FOr\nBtk4ZpM/kHcLOozd+lXQRZECgYBipWr26zgpQ3kaYh3DN9iiKFLMfak9UYFxRtxW\njl8a5hN1yqOBPqoPTAqTmROlxt+VhXBf5Spm1jbMFh5qrGSPTBVzUqK968wJIqVk\nDEFvj9bt2LyvEY8jxZ8OPNIbqExGtB3djEoOmj5nPoRJizu4O/0WWME+J5gmtfMG\nh3LTHQKBgDlITGqdIM4Pp54X5ppOW9S55yaAMBJUUhgUsJ73vEcQsBCZ8xkJXg/Q\nmuPfcFzSD/IgeFoWxYrJIk0CBov3ah+14z5YV1JoKIXAlL7V18f7Omaav8/bozOP\nx78MQ06CGEFRcD4LPMITxTDj6zDm1h7iPhG4m2c9Shy0rwpFmFdd\n-----END RSA PRIVATE KEY-----`))\n\tif err != nil {\n\t\t// fmt.Println(\"Unable to parse test key :\", err)\n\t\treturn nil, err\n\t}\n\ttestSingers, _ := ssh.NewSignerFromKey(testPrivateKeys)\n\tauth = append(auth, ssh.PublicKeys(testSingers))\n\tclientConfig = &ssh.ClientConfig{\n\t\tUser: \t\t\t\tuser,\n\t\tAuth: \t\t\t\tauth,\n\t\tTimeout: \t\t\t30 * time.Second,\n\t\tHostKeyCallback: \tfunc(hostname string, remote net.Addr, key ssh.PublicKey) error {\n\t\t\treturn nil\n\t\t},\n\t}\n\taddr = fmt.Sprintf(\"%s:%d\", host, port)\n\tif sshClient, err = ssh.Dial(\"tcp\", addr, clientConfig); err != nil {\n\t\treturn nil, err\n\t}\n\tif sftpClient, err = sftp.NewClient(sshClient); err != nil {\n\t\treturn nil, err\n\t}\n\treturn sftpClient, nil\n}", "func connect(user, host string, port int) (*ssh.Client, error) {\n\tvar (\n\t\tauth \t\t\t[]ssh.AuthMethod\n\t\taddr \t\t\tstring\n\t\tclientConfig \t*ssh.ClientConfig\n\t\tclient \t\t\t*ssh.Client\n\t\terr \t\t\terror\n\t)\n\tauth = make([]ssh.AuthMethod, 0)\n\ttestPrivateKeys, err := ssh.ParseRawPrivateKey([]byte(`-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEApnIg4Q/g2thAR3vAUw6EPjqgWIEJ7+FZ+AQZtHUc7b920VJI\n7JPmZ1xwdUArlCpQIMAt6mAwV9Z/C+Nc9qIpIeQwKaAd6YWVdr3jFyHLC9rqIT2g\nVifCDnMkSnV7Lvuu5QTvgURGOYpyUhUDJBdBY4YAu9q1ITy35oB0xLh1vUCwuDxI\noM5lMc+HsPjf4/SyfyAacBuoD7BvAJsxJ6xuXBaIlmWcw8o76O/Y5PGcYKPS9/bI\nrN8TrstuWILp2Nvi4WoxVMIQ98i1S6jM47arI+vNGlFrwolrCanH8GBj1NOBh4BF\nJwJisi0Z3+RrtxOVRtgZ9S/tKdK73X6EpbN4hwIDAQABAoIBAAuBRAiKgm5eGENY\nqHiVPkrW3pJ/iOJN31wnXGd+2NsOKvZZC7Vem8R1PUi9gMWjDxrUbdgPggfwSaPW\nuWxK1TEEhte5u5eSpjwo7/N/YHuXTCu0CMsrwFwjVVTYPgWHXBV0e+GhiIEdsr09\nupPaD6kDcDWL7o03lzaVlnyqi2jjXT6kUDyEFCbIAGtoxaYf3clT5e30FnyZhiCH\nm8/Qqv5M1wcVIVdsItHqMsQXQF34eT/Lg3r/Ui1bQcUldc6yYjGpC08EdDNKhGT2\nf2QwAv7UJ+GB8RNl12w3fAh3ReuiW8NEtDQ1nuSahkX5YlIWkqRDOd6Sjrg1ZkfW\nu0/zPZECgYEA2m+w90vb3ui7M/Q0AYJivo88YKhT3ismQs2+CkkgWJ7IohJj3VSh\nREljeAwEVEKv8G8lXgjTNKQ+B4sPFckIvIWGkwo7cuerIwn9n41K20oGb6gEl0jW\nmVbhv0dy6yfp8deBCOZB4YgonXWsuv4lw8DaUoakGxZgFfChjH0VvbUCgYEAwxGj\nrmq+RQWYYna9WWn2GPEJoX0SBU39pHQYBKfQ++pMIUrrryCjPvBNnIICng82RjTp\nMU8BvudvDCJgj3J79TDetBnwVt8/nAGIkleyuWzDMQwF7khBS9/TqUUqmH88GmOt\n40BPThCBx8YgKiPpmGYgPnUww1bqpvxKT9O0IssCgYEAjFH7qKD+mW9/8pwJXH7Z\n1/hDnQQE/E9TwM5SKmFXehZmZFbT+DaJckiCsXdmwIomY5nCs2mP490uS8I06pW+\nGvzbulF0ZxgTg+rDFl+5mq0u/UM9z8FmuhJp6mqHlDCLxGPf7EuePrctABm74FOr\nBtk4ZpM/kHcLOozd+lXQRZECgYBipWr26zgpQ3kaYh3DN9iiKFLMfak9UYFxRtxW\njl8a5hN1yqOBPqoPTAqTmROlxt+VhXBf5Spm1jbMFh5qrGSPTBVzUqK968wJIqVk\nDEFvj9bt2LyvEY8jxZ8OPNIbqExGtB3djEoOmj5nPoRJizu4O/0WWME+J5gmtfMG\nh3LTHQKBgDlITGqdIM4Pp54X5ppOW9S55yaAMBJUUhgUsJ73vEcQsBCZ8xkJXg/Q\nmuPfcFzSD/IgeFoWxYrJIk0CBov3ah+14z5YV1JoKIXAlL7V18f7Omaav8/bozOP\nx78MQ06CGEFRcD4LPMITxTDj6zDm1h7iPhG4m2c9Shy0rwpFmFdd\n-----END RSA PRIVATE KEY-----`))\n\tif err != nil {\n\t\t// fmt.Println(\"Unable to parse test key :\", err)\n\t\treturn nil, err\n\t}\n\ttestSingers, _ := ssh.NewSignerFromKey(testPrivateKeys)\n\n\tauth = append(auth, ssh.PublicKeys(testSingers))\n\tclientConfig = &ssh.ClientConfig{\n\t\tUser: \t\t\t\tuser,\n\t\tAuth: \t\t\t\tauth,\n\t\tTimeout: \t\t\t30 * time.Second,\n\t\tHostKeyCallback: \tfunc(hostname string, remote net.Addr, key ssh.PublicKey) error {\n\t\t\treturn nil\n\t\t},\n\t}\n\taddr = fmt.Sprintf(\"%s:%d\", host, port)\n\tif client, err = ssh.Dial(\"tcp\", addr, clientConfig); err != nil {\n\t\treturn nil, err\n\t}\n\treturn client, nil\n}", "func (cfg *Config) newClient(args []interface{}) (connector endpoint.Connector, err error) {\n\n\tvar clientArgs *newClientArgs\n\tclientArgs, err = getNewClientArguments(args)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar connectionTrustBundle *x509.CertPool\n\n\tif cfg.ConnectionTrust != \"\" {\n\t\tlog.Println(\"You specified a trust bundle.\")\n\t\tconnectionTrustBundle = x509.NewCertPool()\n\t\tif !connectionTrustBundle.AppendCertsFromPEM([]byte(cfg.ConnectionTrust)) {\n\t\t\treturn nil, fmt.Errorf(\"%w: failed to parse PEM trust bundle\", verror.UserDataError)\n\t\t}\n\t}\n\n\tswitch cfg.ConnectorType {\n\tcase endpoint.ConnectorTypeCloud:\n\t\tconnector, err = cloud.NewConnector(cfg.BaseUrl, cfg.Zone, cfg.LogVerbose, connectionTrustBundle)\n\tcase endpoint.ConnectorTypeTPP:\n\t\tconnector, err = tpp.NewConnector(cfg.BaseUrl, cfg.Zone, cfg.LogVerbose, connectionTrustBundle)\n\tcase endpoint.ConnectorTypeFirefly:\n\t\tconnector, err = firefly.NewConnector(cfg.BaseUrl, cfg.Zone, cfg.LogVerbose, connectionTrustBundle)\n\tcase endpoint.ConnectorTypeFake:\n\t\tconnector = fake.NewConnector(cfg.LogVerbose, connectionTrustBundle)\n\tdefault:\n\t\terr = fmt.Errorf(\"%w: ConnectorType is not defined\", verror.UserDataError)\n\t}\n\tif err != nil {\n\t\treturn\n\t}\n\n\tconnector.SetZone(cfg.Zone)\n\tconnector.SetHTTPClient(cfg.Client)\n\n\tif clientArgs.authenticate {\n\t\terr = connector.Authenticate(cfg.Credentials)\n\t}\n\n\treturn\n}", "func sshAuthKey(username string, ssh_key_path string, passphrase string) *ssh.ClientConfig {\n\tprivateKey, err := ioutil.ReadFile(ssh_key_path)\n\tif err != nil {\n\t\treturn &ssh.ClientConfig{}\n\t}\n\n\tsigner, err := ssh.ParsePrivateKeyWithPassphrase(privateKey, []byte(passphrase))\n\tif err != nil {\n\t\treturn &ssh.ClientConfig{}\n\t}\n\n\tconfig := &ssh.ClientConfig{\n\t\tUser: username,\n\t\tAuth: []ssh.AuthMethod{\n\t\t\tssh.PublicKeys(signer),\n\t\t},\n\t\tHostKeyCallback: ssh.InsecureIgnoreHostKey(),\n\t}\n\n\treturn config\n}", "func initClient(protocol string) {\n\tclientConf = GetDefaultClientConfig()\n\tif protocol == \"\" {\n\t\treturn\n\t}\n\n\t// load client config from rootConfig.Protocols\n\t// default use dubbo\n\tif config.GetApplicationConfig() == nil {\n\t\treturn\n\t}\n\tif config.GetRootConfig().Protocols == nil {\n\t\treturn\n\t}\n\n\tprotocolConf := config.GetRootConfig().Protocols[protocol]\n\tif protocolConf == nil {\n\t\tlogger.Info(\"use default getty client config\")\n\t\treturn\n\t} else {\n\t\t//client tls config\n\t\ttlsConfig := config.GetRootConfig().TLSConfig\n\t\tif tlsConfig != nil {\n\t\t\tclientConf.SSLEnabled = true\n\t\t\tclientConf.TLSBuilder = &getty.ClientTlsConfigBuilder{\n\t\t\t\tClientKeyCertChainPath: tlsConfig.TLSCertFile,\n\t\t\t\tClientPrivateKeyPath: tlsConfig.TLSKeyFile,\n\t\t\t\tClientTrustCertCollectionPath: tlsConfig.CACertFile,\n\t\t\t}\n\t\t}\n\t\t//getty params\n\t\tgettyClientConfig := protocolConf.Params\n\t\tif gettyClientConfig == nil {\n\t\t\tlogger.Debugf(\"gettyClientConfig is nil\")\n\t\t\treturn\n\t\t}\n\t\tgettyClientConfigBytes, err := yaml.Marshal(gettyClientConfig)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\terr = yaml.Unmarshal(gettyClientConfigBytes, clientConf)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\tif err := clientConf.CheckValidity(); err != nil {\n\t\tlogger.Warnf(\"[CheckValidity] error: %v\", err)\n\t\treturn\n\t}\n\tsetClientGrPool()\n\n\trand.Seed(time.Now().UnixNano())\n}", "func NewClient(clientConf DestinationClientConfiguration) (*DestinationClient, error) {\n\tconf := &clientcredentials.Config{\n\t\tClientID: clientConf.ClientID,\n\t\tClientSecret: clientConf.ClientSecret,\n\t\tTokenURL: clientConf.TokenURL + \"/oauth/token\",\n\t\tScopes: []string{},\n\t}\n\tclient := conf.Client(context.Background())\n\n\trestyClient := resty.NewWithClient(client).\n\t\tSetHostURL(clientConf.ServiceURL+\"/destination-configuration/v1\").\n\t\tSetHeader(\"Accept\", \"application/json\").\n\t\tSetTimeout(60 * time.Second)\n\n\treturn &DestinationClient{\n\t\trestyClient: restyClient,\n\t}, nil\n}", "func (b *backend) getClientConfig(ctx context.Context, s logical.Storage, region, stsRole, accountID, clientType string) (*aws.Config, error) {\n\n\tconfig, err := b.getRawClientConfig(ctx, s, region, clientType)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif config == nil {\n\t\treturn nil, fmt.Errorf(\"could not compile valid credentials through the default provider chain\")\n\t}\n\n\tstsConfig, err := b.getRawClientConfig(ctx, s, region, \"sts\")\n\tif stsConfig == nil {\n\t\treturn nil, fmt.Errorf(\"could not configure STS client\")\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif stsRole != \"\" {\n\t\tassumedCredentials := stscreds.NewCredentials(session.New(stsConfig), stsRole)\n\t\t// Test that we actually have permissions to assume the role\n\t\tif _, err = assumedCredentials.Get(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tconfig.Credentials = assumedCredentials\n\t} else {\n\t\tif b.defaultAWSAccountID == \"\" {\n\t\t\tclient := sts.New(session.New(stsConfig))\n\t\t\tif client == nil {\n\t\t\t\treturn nil, errwrap.Wrapf(\"could not obtain sts client: {{err}}\", err)\n\t\t\t}\n\t\t\tinputParams := &sts.GetCallerIdentityInput{}\n\t\t\tidentity, err := client.GetCallerIdentity(inputParams)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errwrap.Wrapf(\"unable to fetch current caller: {{err}}\", err)\n\t\t\t}\n\t\t\tif identity == nil {\n\t\t\t\treturn nil, fmt.Errorf(\"got nil result from GetCallerIdentity\")\n\t\t\t}\n\t\t\tb.defaultAWSAccountID = *identity.Account\n\t\t}\n\t\tif b.defaultAWSAccountID != accountID {\n\t\t\treturn nil, fmt.Errorf(\"unable to fetch client for account ID %q -- default client is for account %q\", accountID, b.defaultAWSAccountID)\n\t\t}\n\t}\n\n\treturn config, nil\n}", "func NewForConfig(config clientcmd.ClientConfig) (client *Client, err error) {\n\tif config == nil {\n\t\t// initialize client-go clients\n\t\tloadingRules := clientcmd.NewDefaultClientConfigLoadingRules()\n\t\tconfigOverrides := &clientcmd.ConfigOverrides{}\n\t\tconfig = clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides)\n\t}\n\n\tclient = new(Client)\n\tclient.KubeConfig = config\n\n\tclient.KubeClientConfig, err = client.KubeConfig.ClientConfig()\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, errorMsg)\n\t}\n\n\tclient.KubeClient, err = kubernetes.NewForConfig(client.KubeClientConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient.Namespace, _, err = client.KubeConfig.Namespace()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient.OperatorClient, err = operatorsclientset.NewForConfig(client.KubeClientConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient.DynamicClient, err = dynamic.NewForConfig(client.KubeClientConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient.appsClient, err = appsclientset.NewForConfig(client.KubeClientConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient.serviceCatalogClient, err = servicecatalogclienset.NewForConfig(client.KubeClientConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient.discoveryClient, err = discovery.NewDiscoveryClientForConfig(client.KubeClientConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient.checkIngressSupports = true\n\n\tclient.userClient, err = userclientset.NewForConfig(client.KubeClientConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient.projectClient, err = projectclientset.NewForConfig(client.KubeClientConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient.routeClient, err = routeclientset.NewForConfig(client.KubeClientConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn client, nil\n}", "func ClientConfig(m discovery.PluginMeta) *plugin.ClientConfig {\n\tlogger := hclog.New(&hclog.LoggerOptions{\n\t\tName: \"plugin\",\n\t\tLevel: hclog.Trace,\n\t\tOutput: os.Stderr,\n\t})\n\n\treturn &plugin.ClientConfig{\n\t\tCmd: exec.Command(m.Path),\n\t\tHandshakeConfig: Handshake,\n\t\tVersionedPlugins: VersionedPlugins,\n\t\tManaged: true,\n\t\tLogger: logger,\n\t\tAllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC},\n\t\tAutoMTLS: true,\n\t}\n}", "func clientConfig(m discovery.PluginMeta, loglevel hclog.Level) *goPlugin.ClientConfig {\n\tlogger := hclog.New(&hclog.LoggerOptions{\n\t\tName: \"plugin\",\n\t\tLevel: loglevel,\n\t\tOutput: os.Stderr,\n\t})\n\n\treturn &goPlugin.ClientConfig{\n\t\tCmd: exec.Command(m.Path), //nolint:gosec\n\t\tHandshakeConfig: plugin.Handshake,\n\t\tVersionedPlugins: plugin.VersionedPlugins,\n\t\tManaged: true,\n\t\tLogger: logger,\n\t\tAllowedProtocols: []goPlugin.Protocol{goPlugin.ProtocolGRPC},\n\t\tAutoMTLS: true,\n\t}\n}", "func NewNativeClient(user, host, clientVersion string, port int, auth *Auth, hostKeyCallback ssh.HostKeyCallback) (Client, error) {\n\tif clientVersion == \"\" {\n\t\tclientVersion = \"SSH-2.0-Go\"\n\t}\n\n\tconfig, err := NewNativeConfig(user, clientVersion, auth, hostKeyCallback)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error getting config for native Go SSH: %s\", err)\n\t}\n\n\treturn &NativeClient{\n\t\tConfig: config,\n\t\tHostname: host,\n\t\tPort: port,\n\t\tClientVersion: clientVersion,\n\t}, nil\n}", "func NewClient(c *Config) (*Client, error) {\n\tdef := DefaultConfig()\n\tif def == nil {\n\t\treturn nil, fmt.Errorf(\"could not create/read default configuration\")\n\t}\n\tif def.Error != nil {\n\t\treturn nil, errwrap.Wrapf(\"error encountered setting up default configuration: {{err}}\", def.Error)\n\t}\n\n\tif c == nil {\n\t\tc = def\n\t}\n\n\tc.modifyLock.Lock()\n\tdefer c.modifyLock.Unlock()\n\n\tif c.MinRetryWait == 0 {\n\t\tc.MinRetryWait = def.MinRetryWait\n\t}\n\n\tif c.MaxRetryWait == 0 {\n\t\tc.MaxRetryWait = def.MaxRetryWait\n\t}\n\n\tif c.HttpClient == nil {\n\t\tc.HttpClient = def.HttpClient\n\t}\n\tif c.HttpClient.Transport == nil {\n\t\tc.HttpClient.Transport = def.HttpClient.Transport\n\t}\n\n\taddress := c.Address\n\tif c.AgentAddress != \"\" {\n\t\taddress = c.AgentAddress\n\t}\n\n\tu, err := c.ParseAddress(address)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient := &Client{\n\t\taddr: u,\n\t\tconfig: c,\n\t\theaders: make(http.Header),\n\t}\n\n\tif c.ReadYourWrites {\n\t\tclient.replicationStateStore = &replicationStateStore{}\n\t}\n\n\t// Add the VaultRequest SSRF protection header\n\tclient.headers[RequestHeaderName] = []string{\"true\"}\n\n\tif token := os.Getenv(EnvVaultToken); token != \"\" {\n\t\tclient.token = token\n\t}\n\n\tif namespace := os.Getenv(EnvVaultNamespace); namespace != \"\" {\n\t\tclient.setNamespace(namespace)\n\t}\n\n\treturn client, nil\n}", "func NewClient(cfg *Config) (*Client, error) {\r\n\tBaseURL := new(url.URL)\r\n\tvar err error\r\n\r\n\tviper.SetEnvPrefix(\"TS\")\r\n\tviper.BindEnv(\"LOG\")\r\n\r\n\tswitch l := viper.Get(\"LOG\"); l {\r\n\tcase \"trace\":\r\n\t\tlog.SetLevel(log.TraceLevel)\r\n\tcase \"debug\":\r\n\t\tlog.SetLevel(log.DebugLevel)\r\n\tcase \"info\":\r\n\t\tlog.SetLevel(log.InfoLevel)\r\n\tcase \"warn\":\r\n\t\tlog.SetLevel(log.WarnLevel)\r\n\tcase \"fatal\":\r\n\t\tlog.SetLevel(log.FatalLevel)\r\n\tcase \"panic\":\r\n\t\tlog.SetLevel(log.PanicLevel)\r\n\t}\r\n\r\n\tif cfg.BaseURL != \"\" {\r\n\t\tBaseURL, err = url.Parse(cfg.BaseURL)\r\n\t\tif err != nil {\r\n\t\t\treturn nil, err\r\n\t\t}\r\n\t} else {\r\n\t\tBaseURL, err = url.Parse(defaultBaseURL)\r\n\t\tif err != nil {\r\n\t\t\treturn nil, err\r\n\t\t}\r\n\t}\r\n\r\n\tnewClient := &Client{\r\n\t\tBaseURL: BaseURL,\r\n\t\tclient: http.DefaultClient,\r\n\t\tcreds: &Credentials{\r\n\t\t\tAPIKey: cfg.APIKey,\r\n\t\t\tOrganizationID: cfg.OrganizationID,\r\n\t\t\tUserID: cfg.UserID,\r\n\t\t},\r\n\t}\r\n\r\n\tnewClient.Rulesets = &RulesetService{newClient}\r\n\tnewClient.Rules = &RuleService{newClient}\r\n\r\n\treturn newClient, nil\r\n}", "func defaultClientConfig(flags *pflag.FlagSet) clientcmd.ClientConfig {\n\tloadingRules := clientcmd.NewDefaultClientConfigLoadingRules()\n\t// use the standard defaults for this client command\n\t// DEPRECATED: remove and replace with something more accurate\n\tloadingRules.DefaultClientConfig = &clientcmd.DefaultClientConfig\n\n\tflags.StringVar(&loadingRules.ExplicitPath, \"kubeconfig\", \"\", \"Path to the kubeconfig file to use for CLI requests.\")\n\n\toverrides := &clientcmd.ConfigOverrides{ClusterDefaults: clientcmd.ClusterDefaults}\n\n\tflagNames := clientcmd.RecommendedConfigOverrideFlags(\"\")\n\t// short flagnames are disabled by default. These are here for compatibility with existing scripts\n\tflagNames.ClusterOverrideFlags.APIServer.ShortName = \"s\"\n\n\tclientcmd.BindOverrideFlags(overrides, flags, flagNames)\n\tclientConfig := clientcmd.NewInteractiveDeferredLoadingClientConfig(loadingRules, overrides, os.Stdin)\n\n\treturn clientConfig\n}", "func getClientConfig(kubeconfig string) (*rest.Config, error) {\n\tif kubeconfig != \"\" {\n\t\treturn clientcmd.BuildConfigFromFlags(\"\", kubeconfig)\n\t}\n\treturn rest.InClusterConfig()\n}", "func (s *HostListener) SSH(ctx context.Context, in *protocol.Reference) (sc *protocol.SshConfig, err error) {\n\tdefer fail.OnExitConvertToGRPCStatus(&err)\n\tdefer fail.OnExitWrapError(&err, \"cannot get host SSH information\")\n\tdefer fail.OnPanic(&err)\n\n\tif s == nil {\n\t\treturn nil, fail.InvalidInstanceError()\n\t}\n\tif in == nil {\n\t\treturn nil, fail.InvalidParameterError(\"in\", \"cannot be nil\")\n\t}\n\tif ctx == nil {\n\t\treturn nil, fail.InvalidParameterError(\"ctx\", \"cannot be nil\")\n\t}\n\n\tif ok, err := govalidator.ValidateStruct(in); err == nil && !ok {\n\t\tlogrus.Warnf(\"Structure validation failure: %v\", in) // FIXME: Generate json tags in protobuf\n\t}\n\n\tref, refLabel := srvutils.GetReference(in)\n\tif ref == \"\" {\n\t\treturn nil, fail.InvalidRequestError(\"neither name nor id given as reference\")\n\t}\n\n\tjob, xerr := PrepareJob(ctx, in.GetTenantId(), fmt.Sprintf(\"/host/%s/sshconfig\", ref))\n\tif xerr != nil {\n\t\treturn nil, xerr\n\t}\n\tdefer job.Close()\n\n\ttracer := debug.NewTracer(job.Task(), tracing.ShouldTrace(\"listeners.host\"), \"(%s)\", refLabel).WithStopwatch().Entering()\n\tdefer tracer.Exiting()\n\tdefer fail.OnExitLogError(&err, tracer.TraceMessage())\n\n\tsshHandler := handlers.NewSSHHandler(job)\n\tsshConfig, xerr := sshHandler.GetConfig(ref)\n\tif xerr != nil {\n\t\treturn nil, xerr\n\t}\n\n\ttracer.Trace(\"SSH config of host %s successfully loaded\", refLabel)\n\treturn converters.SSHConfigFromAbstractToProtocol(*sshConfig), nil\n}", "func newKubeClientConfig() (*client.Config, error) {\n\tvar (\n\t\tconfig *client.Config\n\t\terr error\n\t\tapiServerURL string\n\t)\n\t// If the user specified --kube-apiserver-url, expand env vars and verify it.\n\tif *argKubeMasterURL != \"\" {\n\t\tapiServerURL, err = expandKubeMasterURL()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif apiServerURL != \"\" && *argKubecfgFile == \"\" {\n\t\t// Only --kube-apiserver-url was provided.\n\t\tconfig = &client.Config{\n\t\t\tHost: apiServerURL,\n\t\t\tVersion: \"v1\",\n\t\t}\n\t} else {\n\t\t// We either have:\n\t\t// 1) --kube-apiserver-url and --kubecfg-file\n\t\t// 2) just --kubecfg-file\n\t\t// 3) neither flag\n\t\t// In any case, the logic is the same. If (3), this will automatically\n\t\t// fall back on the service account token.\n\t\toverrides := &clientcmd.ConfigOverrides{}\n\t\toverrides.ClusterInfo.Server = apiServerURL // might be \"\", but that is OK\n\t\trules := &clientcmd.ClientConfigLoadingRules{ExplicitPath: *argKubecfgFile} // might be \"\", but that is OK\n\t\tif config, err = clientcmd.NewNonInteractiveDeferredLoadingClientConfig(rules, overrides).ClientConfig(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tglog.Infof(\"Using %s for kubernetes API server\", config.Host)\n\tglog.Infof(\"Using kubernetes API version %s\", config.Version)\n\n\treturn config, nil\n}", "func NewClient(clientID string, clientSecret string, redirectURI string, httpClient *http.Client, tr TokenRepository) *Config {\n\treturn &Config{\n\t\tclientID: clientID,\n\t\tclientSecret: clientSecret,\n\t\tredirectURI: redirectURI,\n\t\tHTTPClient: httpClient,\n\t\ttokenRepository: tr,\n\t}\n}", "func NewClient(host string, port int, password, cipherName string) (Client, error) {\n\t// TODO: consider using net.LookupIP to get a list of IPs, and add logic for optimal selection.\n\tproxyIP, err := net.ResolveIPAddr(\"ip\", host)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to resolve proxy address: %w\", err)\n\t}\n\tkey, err := shadowsocks.NewEncryptionKey(cipherName, password)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create encryption key: %w\", err)\n\t}\n\treturn &ssClient{\n\t\tkey: key,\n\t\tproxyAddress: net.JoinHostPort(proxyIP.String(), fmt.Sprint(port)),\n\t}, nil\n}", "func NewSSH(user, host string, port int, privateKey []byte) (*SSH, error) {\n\treturn &SSH{\n\t\tuser: user,\n\t\thost: host,\n\t\tport: port,\n\t\tprivateKey: privateKey,\n\t}, nil\n}", "func NewRemoteClient(config *Config) *Client {\n\tif config == nil {\n\t\tconfig = &Config{}\n\t}\n\n\tclient := api.NewShell(config.Host)\n\thost := config.Host\n\tif host == \"\" {\n\t\tvar err error\n\t\thost, err = getIpfsAPIURL()\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}\n\n\treturn &Client{\n\t\tclient: client,\n\t\tisRemote: true,\n\t\thost: host,\n\t\tgatewayURL: config.GatewayURL,\n\t}\n}", "func SSHConnect(resource *OpenAmResource, port string) (*ssh.Client, *ssh.Session, error) {\n\n\tsshConfig := &ssh.ClientConfig{\n\t\tUser: resource.Username,\n\t\tAuth: []ssh.AuthMethod{ssh.Password(resource.Password)},\n\t}\n\n\tserverString := resource.Hostname + \":\" + port\n\n\tsshConfig.HostKeyCallback = ssh.InsecureIgnoreHostKey()\n\tclient, err := ssh.Dial(\"tcp\", serverString, sshConfig)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tsession, err := client.NewSession()\n\tif err != nil {\n\t\tclient.Close()\n\t\treturn nil, nil, err\n\t}\n\n\treturn client, session, nil\n}", "func sftpconnect(n *Node) (*sftp.Client, error) {\n\tuser := n.UserName\n\thost := n.Addr\n\tport := 22\n\tvar (\n\t\tauth []ssh.AuthMethod\n\t\taddr string\n\t\tclientConfig *ssh.ClientConfig\n\t\tsshClient *ssh.Client\n\t\tsftpClient *sftp.Client\n\t\terr error\n\t)\n\t// Get auth method\n\tif n.AuthMethod == \"privateKey\" {\n\t\tauth = make([]ssh.AuthMethod, 0)\n\t\tauth = append(auth, publicKeyAuthFunc(n.PrivateKey))\n\t} else if n.AuthMethod == \"password\" {\n\t\tauth = make([]ssh.AuthMethod, 0)\n\t\tauth = append(auth, ssh.Password(n.Password))\n\t}\n\n\thostKeyCallbk := func(hostname string, remote net.Addr, key ssh.PublicKey) error {\n\t\treturn nil\n\t}\n\n\tclientConfig = &ssh.ClientConfig{\n\t\tUser: user,\n\t\tAuth: auth,\n\t\tTimeout: 30 * time.Second,\n\t\tHostKeyCallback: hostKeyCallbk,\n\t}\n\n\t// Connet to ssh\n\taddr = fmt.Sprintf(\"%s:%d\", host, port)\n\n\tif sshClient, err = ssh.Dial(\"tcp\", addr, clientConfig); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create sftp client\n\tif sftpClient, err = sftp.NewClient(sshClient); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn sftpClient, nil\n}", "func NewClient(\n\tprovider iaas.Provider,\n\ttfCLI terraform.CLIInterface,\n\tboshClientFactory bosh.ClientFactory,\n\tflyClientFactory func(fly.Credentials, io.Writer, io.Writer, []byte) (fly.IClient, error),\n\tcertGenerator func(constructor func(u *certs.User) (certs.AcmeClient, error), caName string, ip ...string) (*certs.Certs, error),\n\tconfigClient config.IClient,\n\tdeployArgs *deploy.Args,\n\tstdout, stderr io.Writer,\n\tipChecker func() (string, error),\n\tacmeClientConstructor func(u *certs.User) (certs.AcmeClient, error),\n\tversion string) *Client {\n\treturn &Client{\n\t\tprovider: provider,\n\t\ttfCLI: tfCLI,\n\t\tboshClientFactory: boshClientFactory,\n\t\tflyClientFactory: flyClientFactory,\n\t\tconfigClient: configClient,\n\t\tcertGenerator: certGenerator,\n\t\tdeployArgs: deployArgs,\n\t\tstdout: stdout,\n\t\tstderr: stderr,\n\t\tipChecker: ipChecker,\n\t\tacmeClientConstructor: acmeClientConstructor,\n\t\tversionFile: versionFile,\n\t\tversion: version,\n\t}\n}", "func GetClientConfig(kubeConfig string) (*rest.Config, error) {\n\tif kubeConfig != \"\" {\n\t\treturn clientcmd.BuildConfigFromFlags(\"\", kubeConfig)\n\t}\n\treturn rest.InClusterConfig()\n\n}", "func NewSshConnection(conf *SshClientConf) *SshConnection {\n\tparsed := utils.ParseSSHUrl(conf.ServerURI)\n\tvar knownHostsPath string\n\tif conf.KnownHosts == \"\" {\n\t\tusr, _ := user.Current()\n\t\tknownHostsPath = filepath.Join(usr.HomeDir, \".ssh\", \"known_hosts\")\n\t} else {\n\t\tknownHostsPath, _ = utils.ExpandUserHome(conf.KnownHosts)\n\t}\n\n\tc := &SshConnection{\n\t\tusername: parsed.Username,\n\t\tidentity: conf.Identity,\n\t\tknownHosts: knownHostsPath,\n\t\tserverEndpoint: conf.GetServerEndpoint(),\n\t\tinsecure: conf.Insecure,\n\t\tjumpHosts: conf.JumpHosts,\n\n\t\tkeepAliveInterval: 5 * time.Second,\n\t\treconnectionInterval: 5 * time.Second,\n\t\tconnectionStatus: STATUS_CONNECTING,\n\t}\n\t// client is not connected on startup, so add 1 here\n\tc.Connected.Add(1)\n\treturn c\n}", "func (c *service) Client() *ssh.Client {\n\treturn c.client\n}", "func loadClientConfig() *client.Config {\n\tcfg := &client.Config{\n\t\tHost: viper.GetString(\"host\"),\n\t\tPort: viper.GetInt(\"port\"),\n\t\tSSL: viper.GetBool(\"insecure\"),\n\t\tInsecure: viper.GetBool(\"insecure\"),\n\t\tBindDN: viper.GetString(\"bind\"),\n\t\tBindPassword: viper.GetString(\"password\"),\n\t}\n\tlog.WithFields(log.Fields{\n\t\t\"host\": cfg.Host,\n\t\t\"port\": cfg.Port,\n\t\t\"bind\": cfg.BindDN,\n\t}).Debug(\"LDAP client config\")\n\treturn cfg\n}", "func newClient(configuration *Configuration, options ...ClientOption) (Client, error) {\n\tclientCfg, err := newTLSClientConfig(configuration)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading and/or parsing the certification files. Cause: %w\", err)\n\t}\n\n\tnetClient := http.Client{\n\t\tTransport: &http.Transport{\n\t\t\tTLSClientConfig: clientCfg,\n\t\t},\n\t}\n\n\tinstance := &client{client: &netClient, configuration: configuration, encoder: newJSONEncoder(), decoder: newJSONDecoder()}\n\n\t// Apply options if there are any, can overwrite default\n\tfor _, option := range options {\n\t\toption(instance)\n\t}\n\n\treturn instance, nil\n}", "func NewClient(config *Config) *Client {\n\tc := &Client{config: defaultConfig.Merge(config)}\n\n\treturn c\n}", "func sshTestConfig() *ssh.ServerConfig {\n\tvar c ssh.ServerConfig\n\tc.PublicKeyCallback = func(c ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) {\n\t\t// Always allow public key connections, regardless of the key.\n\t\treturn nil, nil\n\t}\n\tkey, err := rsa.GenerateKey(rand.Reader, 4096)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\ts, err := ssh.NewSignerFromKey(key)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tc.AddHostKey(s)\n\n\treturn &c\n}", "func NewSSHConfig(user, KeyFilename, HostIPOrAddr string) (result *SSHConfig) {\n\tif expandedKeyFilename, err := Expand(KeyFilename); err == nil {\n\t\tKeyFilename = expandedKeyFilename\n\t}\n\tprivateKey, _ := ReadDataFromFile(KeyFilename)\n\treturn NewSSHConfigKeyBytes(user, privateKey, HostIPOrAddr)\n}", "func NewClient(registry *syncbase.Registry, dispatcher orchestrator.Dispatcher) ConfigClient {\n\treturn &client{\n\t\tregistry: registry,\n\t\tdispatcher: dispatcher,\n\t}\n}", "func GetClientConfig(kubeconfig string) (*rest.Config, error) {\n\tif kubeconfig != \"\" {\n\t\treturn clientcmd.BuildConfigFromFlags(\"\", kubeconfig)\n\t}\n\treturn rest.InClusterConfig()\n}" ]
[ "0.7974541", "0.76709026", "0.74759793", "0.74258846", "0.740708", "0.70316577", "0.70175177", "0.6997534", "0.6675493", "0.6624891", "0.65838957", "0.64609164", "0.64464515", "0.6420268", "0.6418195", "0.6396556", "0.6309854", "0.6309701", "0.6296322", "0.6200176", "0.6194428", "0.6062632", "0.6052205", "0.6008543", "0.60052264", "0.5992918", "0.59734976", "0.5922433", "0.59138554", "0.589566", "0.58330095", "0.58006483", "0.5787271", "0.576775", "0.5722682", "0.56952626", "0.56133896", "0.5588351", "0.5561255", "0.554614", "0.55264044", "0.5511056", "0.550267", "0.5487305", "0.5464362", "0.54630774", "0.5461915", "0.5458004", "0.54541594", "0.54417515", "0.5432036", "0.5424801", "0.5417879", "0.5413843", "0.54121834", "0.5411861", "0.54074603", "0.54010206", "0.53897995", "0.53890234", "0.5381132", "0.5379459", "0.5373565", "0.5354804", "0.53268975", "0.53258824", "0.5324072", "0.5309132", "0.52822304", "0.52780694", "0.5277372", "0.5268377", "0.52663106", "0.5260155", "0.52548987", "0.52446723", "0.52360564", "0.5228644", "0.5220139", "0.5199413", "0.51890475", "0.5184676", "0.5179707", "0.5179169", "0.517906", "0.51608545", "0.5158959", "0.5158613", "0.51566875", "0.5155222", "0.51522", "0.51496613", "0.5149008", "0.5146992", "0.5129242", "0.51283777", "0.5126773", "0.51266843", "0.512664", "0.5121181" ]
0.78421795
1
ExecuteBatch execute bach commands
Выполнить пакет выполнить команды пакета
func (c *SSHClient) ExecuteBatch(commands []string, prependSudo bool) error { fmt.Printf("**** Host: %s ****\n", c.client.RemoteAddr().String()) for _, cmd := range commands { fmt.Printf("** Execute command: %s **\n", cmd) stdout, stderr, err := c.ExecuteOne(cmd, prependSudo) if err != nil { return err } if len(stdout) > 0 { fmt.Println(stdout) } if len(stderr) > 0 { fmt.Printf("Error: %s\n", stderr) } fmt.Println() } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (_BaseContentSpace *BaseContentSpaceTransactor) ExecuteBatch(opts *bind.TransactOpts, _v []uint8, _r [][32]byte, _s [][32]byte, _from []common.Address, _dest []common.Address, _value []*big.Int, _ts []*big.Int) (*types.Transaction, error) {\n\treturn _BaseContentSpace.contract.Transact(opts, \"executeBatch\", _v, _r, _s, _from, _dest, _value, _ts)\n}", "func (s *Stmt) ExecBatch(args [][]interface{}) (Result, error) {\n\treturn s.execBatchContext(context.Background(), &args)\n}", "func (tb *Batch) ExecuteBatch(session *gocql.Session) error {\n\tspan := tb.newChildSpan(tb.ctx)\n\terr := session.ExecuteBatch(tb.Batch)\n\ttb.finishSpan(span, err)\n\treturn err\n}", "func (c *cassandra) ExecuteBatch(batchType gocql.BatchType, queries []string, params [][]interface{}) error {\n\tcount := len(queries)\n\n\t// quick sanity check\n\tif count != len(params) {\n\t\treturn errors.New(\"Amount of queries and params does not match\")\n\t}\n\n\tbatch := c.session.NewBatch(batchType)\n\tbatch.Cons = c.wcl\n\tfor idx := 0; idx < count; idx++ {\n\t\tbatch.Query(queries[idx], params[idx]...)\n\t}\n\n\treturn c.session.ExecuteBatch(batch)\n}", "func (w *Writer) ExecuteBatch(batch store.KVBatch) (err error) {\n\temulatedBatch, ok := batch.(*store.EmulatedBatch)\n\tif !ok {\n\t\treturn fmt.Errorf(\"wrong type of batch\")\n\t}\n\n\ttxn := w.s.db.NewTransaction(true)\n\n\tdefer (func() {\n\t\ttxn.Commit()\n\t})()\n\n\tfor k, mergeOps := range emulatedBatch.Merger.Merges {\n\t\tkb := []byte(k)\n\t\titem, err := txn.Get(kb)\n\t\texistingVal := []byte{}\n\t\tif err == nil {\n\t\t\texistingVal, _ = item.ValueCopy(nil)\n\t\t}\n\t\tmergedVal, fullMergeOk := w.s.mo.FullMerge(kb, existingVal, mergeOps)\n\t\tif !fullMergeOk {\n\t\t\treturn fmt.Errorf(\"merge operator returned failure\")\n\t\t}\n\t\terr = txn.Set(kb, mergedVal)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tfor _, op := range emulatedBatch.Ops {\n\t\tif op.V != nil {\n\t\t\terr = txn.Set(op.K, op.V)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\terr = txn.Delete(op.K)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (runner *TestRunner) executeBatch (batchResultId string, batchParams BatchExecParams, testCasePaths []string, stopRequest <-chan struct{}, executionLogAppend chan<- string) {\n\n\ttype BatchExecutionStatus int\n\tconst (\n\t\tBATCH_EXEC_STATUS_RUNNING BatchExecutionStatus = iota\n\t\tBATCH_EXEC_STATUS_DONE\n\t\tBATCH_EXEC_STATUS_LINK_ERROR\n\t\tBATCH_EXEC_STATUS_GENERIC_ERROR\n\t)\n\n\t// Start running batch result.\n\n\t{\n\t\topSet := rtdb.NewOpSet()\n\t\topSet.Call(typeBatchResult, batchResultId, \"SetStatus\", BATCH_STATUS_CODE_RUNNING)\n\t\terr := runner.rtdbServer.ExecuteOpSet(opSet)\n\t\tif err != nil { panic(err) }\n\t}\n\n\tvar appendExecutionLog = func(content string) {\n\t\texecutionLogAppend <- content\n\t}\n\n\tvar appendTestInfoLog = func(content string) {\n\t\twrappedContent := \"**** Test binary info log chunk begins ****\\n\"\n\t\twrappedContent += content\n\t\twrappedContent += \"**** Test binary info log chunk ends ****\\n\"\n\t\tappendExecutionLog(wrappedContent)\n\t}\n\n\tvar appendCherryLogLine = func(content string) {\n\t\tappendExecutionLog(content + \"\\n\")\n\t}\n\n\tvar appendRunnerLogLine = func(content string) {\n\t\tlog.Printf(\"[runner] %s\\n\", content)\n\t\tappendCherryLogLine(content)\n\t}\n\n\tappendRunnerLogLine(fmt.Sprintf(\"Starting test batch execution at %v\", time.Now().Format(defaultHumanReadableTimeFormat)))\n\n\tvar deviceConfig DeviceConfig\n\tadbOk\t\t\t:= true\n\trunCanceled\t\t:= false\n\n\t{\n\t\terr := runner.rtdbServer.GetObject(batchParams.DeviceId, &deviceConfig)\n\t\tif err != nil { panic(err) }\n\t}\n\n\tif deviceConfig.IsADBDevice {\n\t\terr := LaunchAndroidExecServer(deviceConfig.ADBSerialNumber, batchParams.TargetPort)\n\t\tif err != nil {\n\t\t\tappendRunnerLogLine(fmt.Sprintf(\"Failed to launch ExecServer on Android via ADB: %v\", err))\n\t\t\tadbOk = false\n\t\t}\n\t}\n\n\tif adbOk {\n\t\t// Processed cases (to avoid re-executing them).\n\t\tprocessedCasePaths := make(map[string]bool)\n\n\t\t// Spawn execution as long as more cases to handle.\n\t\tappendRunnerLogLine(fmt.Sprintf(\"Execute %d tests...\", len(testCasePaths)))\n\t\tfor len(testCasePaths) > 0 {\n\t\t\t// Choose next batch to execute & encode case list trie.\n\t\t\tpackageName, launchCaseList := getNextTestCaseBatch(testCasePaths)\n\t\t\tencodedCaseList := prefixEncode(launchCaseList)\n\t\t\tappendRunnerLogLine(fmt.Sprintf(\"Launch %d cases from package '%s'...\", len(launchCaseList), packageName))\n\t\t\ttestPackage := runner.testPackages[packageName]\n\n\t\t\tdidProgress := false\n\t\t\tvar executionStatus BatchExecutionStatus = BATCH_EXEC_STATUS_RUNNING\n\n\t\t\t// Try a few times (in case of connection errors).\n\t\t\tfor tryNdx := 0; tryNdx < 3; tryNdx++ {\n\t\t\t\tif tryNdx > 0 {\n\t\t\t\t\tappendRunnerLogLine(fmt.Sprintf(\"Try again: %d\", tryNdx))\n\t\t\t\t\ttime.Sleep((time.Duration)(tryNdx) * 500 * time.Millisecond)\n\t\t\t\t}\n\n\t\t\t\t// If previous error was link error, relaunch execserver just to be sure\n\t\t\t\tif executionStatus == BATCH_EXEC_STATUS_LINK_ERROR && deviceConfig.IsADBDevice {\n\t\t\t\t\tappendRunnerLogLine(\"Relaunching execserver\")\n\t\t\t\t\terr := RelaunchAndroidExecServer(deviceConfig.ADBSerialNumber, batchParams.TargetPort)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tappendRunnerLogLine(fmt.Sprintf(\"Failed to relaunch ExecServer on Android via ADB: %v\", err))\n\t\t\t\t\t\tcontinue // Just try again, if tries left\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Create link to target.\n\t\t\t\tlinkParams := CommLinkParams {\n\t\t\t\t\tSpawnProcessPath:\tbatchParams.SpawnLocalProcess,\n\t\t\t\t\tTargetAddress:\t\tbatchParams.TargetAddress,\n\t\t\t\t\tTargetPort:\t\t\tbatchParams.TargetPort,\n\t\t\t\t}\n\t\t\t\tlink := NewCommLinkTcpIp(linkParams, appendCherryLogLine)\n\t\t\t\terr := link.Start()\n\t\t\t\tif err != nil {\n\t\t\t\t\tappendRunnerLogLine(fmt.Sprintf(\"WARNING: failed to start link: %s\", err))\n\t\t\t\t\tcontinue // Just try again, if tries left\n\t\t\t\t}\n\n\t\t\t\t// Execute test case on target device.\n\t\t\t\texecEventChan := make(chan TestExecutorEvent, 4)\n\t\t\t\tlinkStopRequest := make(chan struct{}, 1)\n\t\t\t\texecParams := CommLinkExecParams {\n\t\t\t\t\tbinaryName:\t\tstrings.Replace(batchParams.TestBinaryName, \"${TestPackageName}\", testPackage.binaryName, -1),\n\t\t\t\t\tcommandLine:\tbatchParams.TestBinaryCommandLine,\n\t\t\t\t\tworkingDir:\t\tstrings.Replace(batchParams.TestBinaryWorkingDir, \"${TestPackageDir}\", testPackage.binaryDir, -1),\n\t\t\t\t\ttestCasePaths:\tencodedCaseList,\n\t\t\t\t}\n\t\t\t\terr = link.Execute(execParams, execEventChan, linkStopRequest)\n\t\t\t\tif err != nil {\n\t\t\t\t\tappendRunnerLogLine(fmt.Sprintf(\"WARNING: connecting to target device failed: %s\", err))\n\t\t\t\t\tlink.Stop()\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tcurrentlyRunningCases := make(map[string]bool) // Paths of the test cases currently running.\n\n\t\t\t\t// Handle all events from comm link, as well as stop requests.\n\t\t\t\texecutionStatus = BATCH_EXEC_STATUS_RUNNING\n\t\t\t\tfor executionStatus == BATCH_EXEC_STATUS_RUNNING {\n\t\t\t\t\tselect {\n\t\t\t\t\t\tcase <-stopRequest:\n\t\t\t\t\t\t\trunCanceled = true\n\t\t\t\t\t\t\tappendRunnerLogLine(\"Got stop request\")\n\t\t\t\t\t\t\tselect {\n\t\t\t\t\t\t\t\tcase linkStopRequest <- struct{}{}:\n\t\t\t\t\t\t\t\t\tappendRunnerLogLine(\"Sent stop request to comm link\")\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\tappendRunnerLogLine(\"Stop request already sent to comm link\")\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcase event := <-execEventChan:\n\t\t\t\t\t\t\tswitch event.(type) {\n\t\t\t\t\t\t\t\tcase EventSessionInfoRead:\n\t\t\t\t\t\t\t\t\tappendRunnerLogLine(\"Session info received\")\n\t\t\t\t\t\t\t\t\topSet := rtdb.NewOpSet()\n\t\t\t\t\t\t\t\t\topSet.Call(typeBatchResult, batchResultId, \"SetSessionInfo\", event.(EventSessionInfoRead).sessionInfo)\n\t\t\t\t\t\t\t\t\terr := runner.rtdbServer.ExecuteOpSet(opSet)\n\t\t\t\t\t\t\t\t\tif err != nil { panic(err) }\n\n\t\t\t\t\t\t\t\tcase EventInfoLogRead:\n\t\t\t\t\t\t\t\t\tlogContent := event.(EventInfoLogRead).infoLog\n\t\t\t\t\t\t\t\t\tappendTestInfoLog(logContent)\n\n\t\t\t\t\t\t\t\tcase EventTestCaseStarted:\n\t\t\t\t\t\t\t\t\ttestCasePath := event.(EventTestCaseStarted).testCasePath\n\n\t\t\t\t\t\t\t\t\tif _, isAlreadyProcessed := processedCasePaths[testCasePath]; isAlreadyProcessed {\n\t\t\t\t\t\t\t\t\t\tappendRunnerLogLine(fmt.Sprintf(\"WARNING: got EventTestCaseStarted for already-processed test case '%s'; ignoring\", testCasePath))\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\trunner.setTestCaseStatus(batchResultId, testCasePath, TEST_STATUS_CODE_RUNNING)\n\t\t\t\t\t\t\t\t\t\tcurrentlyRunningCases[testCasePath] = true\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tcase EventTestCaseFinished:\n\t\t\t\t\t\t\t\t\ttestCaseInfo\t:= event.(EventTestCaseFinished)\n\t\t\t\t\t\t\t\t\tpath\t\t\t:= testCaseInfo.path\n\n\t\t\t\t\t\t\t\t\tif _, isCurrentlyRunning := currentlyRunningCases[path]; !isCurrentlyRunning {\n\t\t\t\t\t\t\t\t\t\tif _, isAlreadyProcessed := processedCasePaths[path]; !isAlreadyProcessed {\n\t\t\t\t\t\t\t\t\t\t\tappendRunnerLogLine(fmt.Sprintf(\"WARNING: got EventTestCaseFinished for test case '%s' that isn't running; ignoring\", path))\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tdelete(currentlyRunningCases, path)\n\t\t\t\t\t\t\t\t\t\tprocessedCasePaths[path] = true\n\t\t\t\t\t\t\t\t\t\trunner.finishTestCase(batchResultId, testCaseInfo) // upload to rtdb\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tcase EventProcessStarted:\n\t\t\t\t\t\t\t\t\tappendRunnerLogLine(\"Test process started\")\n\n\t\t\t\t\t\t\t\tcase EventProcessLaunchFailed:\n\t\t\t\t\t\t\t\t\tlaunchFailed := event.(EventProcessLaunchFailed)\n\t\t\t\t\t\t\t\t\tappendRunnerLogLine(fmt.Sprintf(\"Process launch failed: %s\", launchFailed.reason))\n\t\t\t\t\t\t\t\t\texecutionStatus = BATCH_EXEC_STATUS_GENERIC_ERROR\n\n\t\t\t\t\t\t\t\tcase EventExecutionFinished:\n\t\t\t\t\t\t\t\t\tappendRunnerLogLine(fmt.Sprintf(\"Test execution finished with status %#v\", event.(EventExecutionFinished).status))\n\t\t\t\t\t\t\t\t\tswitch (event.(EventExecutionFinished).status) {\n\t\t\t\t\t\t\t\t\t\tcase EXEC_STATUS_DONE:\n\t\t\t\t\t\t\t\t\t\t\texecutionStatus = BATCH_EXEC_STATUS_DONE\n\t\t\t\t\t\t\t\t\t\tcase EXEC_STATUS_LINK_ERROR:\n\t\t\t\t\t\t\t\t\t\t\texecutionStatus = BATCH_EXEC_STATUS_LINK_ERROR\n\t\t\t\t\t\t\t\t\t\tcase EXEC_STATUS_TIMEOUT:\n\t\t\t\t\t\t\t\t\t\t\texecutionStatus = BATCH_EXEC_STATUS_GENERIC_ERROR\n\t\t\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t\t\tappendRunnerLogLine(fmt.Sprintf(\"WARNING: unknown end status received: %#v\", event.(EventExecutionFinished).status))\n\t\t\t\t\t\t\t\t\t\t\texecutionStatus = BATCH_EXEC_STATUS_GENERIC_ERROR\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\tappendRunnerLogLine(fmt.Sprintf(\"WARNING: unknown execute event received: %#v\", event))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Disconnect from target.\n\t\t\t\t// \\todo [petri] keep link active for longer?\n\t\t\t\tlink.Stop()\n\n\t\t\t\t// Reset unfinished (running) cases to pending, so they can be re-run in the future.\n\t\t\t\tfor testCasePath, _ := range currentlyRunningCases {\n\t\t\t\t\trunner.setTestCaseStatus(batchResultId, testCasePath, TEST_STATUS_CODE_PENDING)\n\t\t\t\t}\n\n\t\t\t\t// Remove processed cases from the list\n\t\t\t\tdstNdx := 0\n\t\t\t\tfor srcNdx := 0; srcNdx < len(testCasePaths); srcNdx++ {\n\t\t\t\t\tcasePath := testCasePaths[srcNdx]\n\t\t\t\t\tif _, ok := processedCasePaths[casePath]; !ok {\n\t\t\t\t\t\ttestCasePaths[dstNdx] = testCasePaths[srcNdx]\n\t\t\t\t\t\tdstNdx++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnumProcessed := len(testCasePaths) - dstNdx\n\t\t\t\tif numProcessed > 0 {\n\t\t\t\t\tappendRunnerLogLine(fmt.Sprintf(\"%d test case(s) processed\", numProcessed))\n\t\t\t\t\ttestCasePaths = testCasePaths[0:dstNdx]\n\t\t\t\t\tdidProgress = true\n\t\t\t\t}\n\n\t\t\t\tif runCanceled {\n\t\t\t\t\tappendRunnerLogLine(\"Run canceled\")\n\t\t\t\t}\n\n\t\t\t\tif runCanceled || didProgress {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tappendRunnerLogLine(\"WARNING: no test cases processed\")\n\t\t\t}\n\n\t\t\t// Exit loop if run was stopped or no progress was made.\n\t\t\tif runCanceled || !didProgress {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t// Mark the batch inactive and set its status.\n\tvar batchStatus BatchStatusCode\n\tif runCanceled {\n\t\tbatchStatus = BATCH_STATUS_CODE_CANCELED\n\t} else if len(testCasePaths) > 0 {\n\t\tbatchStatus = BATCH_STATUS_CODE_INTERRUPTED\n\t} else {\n\t\tbatchStatus = BATCH_STATUS_CODE_FINISHED\n\t}\n\n\t// Write status of batch result (in batchResult itself and in list of active batchResults).\n\t{\n\t\topSet := rtdb.NewOpSet()\n\t\topSet.Call(typeBatchResult, batchResultId, \"SetStatus\", batchStatus)\n\t\topSet.Call(typeActiveBatchResultList, \"activeBatchResultList\", \"Remove\", batchResultId)\n\t\terr := runner.rtdbServer.ExecuteOpSet(opSet)\n\t\tif err != nil { panic(err) }\n\t}\n\n\tif deviceConfig.IsADBDevice {\n\t\terr := RemoveADBPortForward(deviceConfig.ADBSerialNumber, batchParams.TargetPort)\n\t\tif err != nil {\n\t\t\tappendRunnerLogLine(fmt.Sprintf(\"WARNING: Failed to remove ADB port forward: %v\", err))\n\t\t}\n\t}\n\n\tappendRunnerLogLine(fmt.Sprintf(\"Ending test batch execution at %v\", time.Now().Format(defaultHumanReadableTimeFormat)))\n}", "func (_BaseContentFactoryExt *BaseContentFactoryExtTransactor) ExecuteAccessBatch(opts *bind.TransactOpts, _opCodes []uint32, _contentAddrs []common.Address, _userAddrs []common.Address, _ctxHashes [][32]byte, _ts []*big.Int, _amt []*big.Int) (*types.Transaction, error) {\n\treturn _BaseContentFactoryExt.contract.Transact(opts, \"executeAccessBatch\", _opCodes, _contentAddrs, _userAddrs, _ctxHashes, _ts, _amt)\n}", "func (runner *TestRunner) ExecuteTestBatch (batchName string, batchParams BatchExecParams, timestamp time.Time) (string, error) {\n\t// Resolve test case list to execute.\n\t// \\todo [petri] fetch testCaseList dynamically from target?\n\tlog.Printf(\"[runner] test name filters: %q\\n\", batchParams.TestNameFilters)\n\ttestCasePaths := filterTestCaseNames(runner.fullTestCaseList, batchParams.TestNameFilters)\n\tlog.Printf(\"[runner] filtered from %d cases to %d\\n\", len(runner.fullTestCaseList), len(testCasePaths))\n\n\treturn runner.ExecuteTestBatchWithCaseList(batchName, batchParams, timestamp, testCasePaths)\n}", "func (bw *blockWriter) batchExecute(db *sql.DB, tableNum int) {\n\t// buffer values\n\tfor i := 0; i < blockWriterBatchSize; i++ {\n\t\tblockID := bw.rand.Int63()\n\t\tblockData := bw.randomBlock()\n\t\tbw.blockCount++\n\t\tbw.values[i] = fmt.Sprintf(\"(%d,'%s',%d,'%s')\", blockID, bw.id, bw.blockCount, blockData)\n\t}\n\tstart := time.Now()\n\tvar (\n\t\terr error\n\t\tindex string\n\t)\n\n\tif bw.index > 0 {\n\t\tindex = fmt.Sprintf(\"%d\", bw.index)\n\t}\n\t_, err = db.Exec(\n\t\tfmt.Sprintf(\n\t\t\t\"INSERT INTO block_writer%s (block_id, writer_id, block_num, raw_bytes) VALUES %s\",\n\t\t\tindex, strings.Join(bw.values, \",\")),\n\t)\n\n\tif err != nil {\n\t\tblockWriteFailedCounter.Inc()\n\t\tlog.Errorf(\"[block writer] insert err %v\", err)\n\t\treturn\n\t}\n\tbw.index = (bw.index + 1) % tableNum\n\tblockBatchWriteDuration.Observe(time.Since(start).Seconds())\n}", "func (c *Conn) SendBatch(ctx context.Context, b *Batch) (br BatchResults) {\n\tif c.batchTracer != nil {\n\t\tctx = c.batchTracer.TraceBatchStart(ctx, c, TraceBatchStartData{Batch: b})\n\t\tdefer func() {\n\t\t\terr := br.(interface{ earlyError() error }).earlyError()\n\t\t\tif err != nil {\n\t\t\t\tc.batchTracer.TraceBatchEnd(ctx, c, TraceBatchEndData{Err: err})\n\t\t\t}\n\t\t}()\n\t}\n\n\tif err := c.deallocateInvalidatedCachedStatements(ctx); err != nil {\n\t\treturn &batchResults{ctx: ctx, conn: c, err: err}\n\t}\n\n\tmode := c.config.DefaultQueryExecMode\n\n\tfor _, bi := range b.queuedQueries {\n\t\tvar queryRewriter QueryRewriter\n\t\tsql := bi.query\n\t\targuments := bi.arguments\n\n\toptionLoop:\n\t\tfor len(arguments) > 0 {\n\t\t\tswitch arg := arguments[0].(type) {\n\t\t\tcase QueryRewriter:\n\t\t\t\tqueryRewriter = arg\n\t\t\t\targuments = arguments[1:]\n\t\t\tdefault:\n\t\t\t\tbreak optionLoop\n\t\t\t}\n\t\t}\n\n\t\tif queryRewriter != nil {\n\t\t\tvar err error\n\t\t\tsql, arguments, err = queryRewriter.RewriteQuery(ctx, c, sql, arguments)\n\t\t\tif err != nil {\n\t\t\t\treturn &batchResults{ctx: ctx, conn: c, err: fmt.Errorf(\"rewrite query failed: %v\", err)}\n\t\t\t}\n\t\t}\n\n\t\tbi.query = sql\n\t\tbi.arguments = arguments\n\t}\n\n\tif mode == QueryExecModeSimpleProtocol {\n\t\treturn c.sendBatchQueryExecModeSimpleProtocol(ctx, b)\n\t}\n\n\t// All other modes use extended protocol and thus can use prepared statements.\n\tfor _, bi := range b.queuedQueries {\n\t\tif sd, ok := c.preparedStatements[bi.query]; ok {\n\t\t\tbi.sd = sd\n\t\t}\n\t}\n\n\tswitch mode {\n\tcase QueryExecModeExec:\n\t\treturn c.sendBatchQueryExecModeExec(ctx, b)\n\tcase QueryExecModeCacheStatement:\n\t\treturn c.sendBatchQueryExecModeCacheStatement(ctx, b)\n\tcase QueryExecModeCacheDescribe:\n\t\treturn c.sendBatchQueryExecModeCacheDescribe(ctx, b)\n\tcase QueryExecModeDescribeExec:\n\t\treturn c.sendBatchQueryExecModeDescribeExec(ctx, b)\n\tdefault:\n\t\tpanic(\"unknown QueryExecMode\")\n\t}\n}", "func (s *rpcServer) BatchCommands(ss tikvpb.Tikv_BatchCommandsServer) error {\n\tdefer func() {\n\t\tif v := recover(); v != nil {\n\t\t\tlogutil.BgLogger().Error(\"panic when RPC server handing batch commands\", zap.Reflect(\"r\", v),\n\t\t\t\tzap.Stack(\"stack trace\"))\n\t\t}\n\t}()\n\tfor {\n\t\treqs, err := ss.Recv()\n\t\tif err != nil {\n\t\t\tlogutil.BgLogger().Error(\"RPC server batch commands receive fail\", zap.Error(err))\n\t\t\treturn err\n\t\t}\n\n\t\tresponses := make([]*tikvpb.BatchCommandsResponse_Response, 0, len(reqs.Requests))\n\t\tfor _, req := range reqs.Requests {\n\t\t\tvar response *tikvpb.BatchCommandsResponse_Response\n\t\t\tswitch request := req.Cmd.(type) {\n\t\t\tcase *tikvpb.BatchCommandsRequest_Request_Coprocessor:\n\t\t\t\tcop := request.Coprocessor\n\t\t\t\tresp, err := s.Coprocessor(context.Background(), cop)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tresponse = &tikvpb.BatchCommandsResponse_Response{\n\t\t\t\t\tCmd: &tikvpb.BatchCommandsResponse_Response_Coprocessor{\n\t\t\t\t\t\tCoprocessor: resp,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\tcase *tikvpb.BatchCommandsRequest_Request_Empty:\n\t\t\t\tresponse = &tikvpb.BatchCommandsResponse_Response{\n\t\t\t\t\tCmd: &tikvpb.BatchCommandsResponse_Response_Empty{\n\t\t\t\t\t\tEmpty: &tikvpb.BatchCommandsEmptyResponse{\n\t\t\t\t\t\t\tTestId: request.Empty.TestId,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tlogutil.BgLogger().Info(\"RPC server batch commands receive unknown request\", zap.Any(\"req\", request))\n\t\t\t\tresponse = &tikvpb.BatchCommandsResponse_Response{\n\t\t\t\t\tCmd: &tikvpb.BatchCommandsResponse_Response_Empty{\n\t\t\t\t\t\tEmpty: &tikvpb.BatchCommandsEmptyResponse{},\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t\tresponses = append(responses, response)\n\t\t}\n\n\t\terr = ss.Send(&tikvpb.BatchCommandsResponse{\n\t\t\tResponses: responses,\n\t\t\tRequestIds: reqs.GetRequestIds(),\n\t\t})\n\t\tif err != nil {\n\t\t\tlogutil.BgLogger().Error(\"RPC server batch commands send fail\", zap.Error(err))\n\t\t\treturn err\n\t\t}\n\t}\n}", "func execlist(tx migration.LimitedTx, stms []string) error {\n\tvar err error\n\tfor _, s := range stms {\n\t\t_, err = tx.Exec(s)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn err\n}", "func batch(sqls ...string) func(db migrations.DB) error {\n\treturn func(db migrations.DB) error {\n\t\tfor _, sql := range sqls {\n\t\t\tif _, err := db.Exec(sql); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n}", "func (s *Stmt) ExecBatchContext(ctx context.Context, args [][]interface{}) (Result, error) {\n\treturn s.execBatchContext(ctx, &args)\n}", "func (c *Client) Batch(cmds ...*Cmd) error {\n\t_, err := c.Exec(\"batch\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlines := make([]string, len(cmds)+1)\n\tfor i, c := range cmds {\n\t\tlines[i] = c.String()\n\t}\n\tlines[len(cmds)] = \".\\n\"\n\n\tif err = c.setDeadline(); err != nil {\n\t\treturn err\n\t}\n\n\tif _, err = c.conn.Write([]byte(strings.Join(lines, \"\"))); err != nil {\n\t\treturn err\n\t}\n\n\tif err = c.setDeadline(); err != nil {\n\t\treturn err\n\t}\n\n\tif !c.scanner.Scan() {\n\t\treturn c.scanErr()\n\t}\n\n\tl := c.scanner.Text()\n\tmatches := respRe.FindStringSubmatch(l)\n\tif len(matches) != 3 {\n\t\treturn NewInvalidResponseError(\"batch: invalid matches\", l)\n\t}\n\n\tcnt, err := strconv.Atoi(matches[1])\n\tif err != nil {\n\t\t// This should be impossible given the regexp matched.\n\t\treturn NewInvalidResponseError(\"batch: invalid count\", l)\n\t}\n\n\tif cnt == 0 {\n\t\treturn nil\n\t}\n\n\tif err := c.setDeadline(); err != nil {\n\t\treturn err\n\t}\n\trlines := make([]string, 0, cnt)\n\tfor c.scanner.Scan() && len(rlines) < cnt {\n\t\trlines = append(rlines, c.scanner.Text())\n\t\tif err := c.setDeadline(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(rlines) != cnt {\n\t\t// Short response.\n\t\treturn c.scanErr()\n\t}\n\n\treturn NewError(0-cnt, strings.Join(rlines, \"\\n\"))\n}", "func (stc *ScatterConn) ExecuteBatch(queries []tproto.BoundQuery, keyspace string, shards []string) (qrs *tproto.QueryResultList, err error) {\n\tstc.mu.Lock()\n\tdefer stc.mu.Unlock()\n\n\tqrs = &tproto.QueryResultList{List: make([]mproto.QueryResult, len(queries))}\n\tallErrors := new(concurrency.AllErrorRecorder)\n\tif len(shards) == 0 {\n\t\treturn qrs, nil\n\t}\n\tresults := make(chan *tproto.QueryResultList, len(shards))\n\tvar wg sync.WaitGroup\n\tfor shard := range unique(shards) {\n\t\twg.Add(1)\n\t\tgo func(shard string) {\n\t\t\tdefer wg.Done()\n\t\t\tsdc, err := stc.getConnection(keyspace, shard)\n\t\t\tif err != nil {\n\t\t\t\tallErrors.RecordError(err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tinnerqrs, err := sdc.ExecuteBatch(queries)\n\t\t\tif err != nil {\n\t\t\t\tallErrors.RecordError(err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tresults <- innerqrs\n\t\t}(shard)\n\t}\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(results)\n\t}()\n\tfor innerqr := range results {\n\t\tfor i := range qrs.List {\n\t\t\tappendResult(&qrs.List[i], &innerqr.List[i])\n\t\t}\n\t}\n\tif allErrors.HasErrors() {\n\t\tif stc.transactionId != 0 {\n\t\t\terrstr := allErrors.Error().Error()\n\t\t\t// We cannot recover from these errors\n\t\t\tif strings.Contains(errstr, \"tx_pool_full\") || strings.Contains(errstr, \"not_in_tx\") {\n\t\t\t\tstc.rollback()\n\t\t\t}\n\t\t}\n\t\treturn nil, allErrors.Error()\n\t}\n\treturn qrs, nil\n}", "func (b *Batch) Execute() error {\n\tif len(b.jobs) == 0 {\n\t\treturn errors.New(\"No job provided\")\n\t}\n\n\tif _, err := b.redisClient.Pipelined(func(pipe *redis.Pipeline) error {\n\t\tpipe.SAdd(fmt.Sprintf(\"%s:queues\", b.namespace), b.queue)\n\n\t\tfor _, job := range b.jobs {\n\t\t\tbuffer, err := job.Marshal()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif err := pipe.RPush(\n\t\t\t\tfmt.Sprintf(\"%s:queue:%s\", b.namespace, b.queue),\n\t\t\t\tbuffer,\n\t\t\t).Err(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t}); err != nil {\n\t\treturn err\n\t}\n\n\tb.jobs = b.jobs[:0]\n\n\treturn nil\n}", "func (a *MocksAndTestsApiService) MockBatchUpdateExecute(r ApiMockBatchUpdateRequest) (*_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodPost\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t)\n\n\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \"MocksAndTestsApiService.MockBatchUpdate\")\n\tif err != nil {\n\t\treturn nil, GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/api/v1/tests/mockBatchUpdate\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\tif r.mockBatchUpdateParams == nil {\n\t\treturn nil, reportError(\"mockBatchUpdateParams is required and must be specified\")\n\t}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{\"application/json\"}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\tif r.xRequestId != nil {\n\t\tlocalVarHeaderParams[\"X-Request-Id\"] = parameterToString(*r.xRequestId, \"\")\n\t}\n\t// body params\n\tlocalVarPostBody = r.mockBatchUpdateParams\n\treq, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(req)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tlocalVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody))\n\tif err != nil {\n\t\treturn localVarHTTPResponse, err\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 400 {\n\t\t\tvar v ErrorMessage\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 401 {\n\t\t\tvar v BadCredentialsError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 403 {\n\t\t\tvar v ErrorMessage\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 404 {\n\t\t\tvar v ErrorMessage\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 422 {\n\t\t\tvar v ErrorMessage\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 500 {\n\t\t\tvar v ErrorMessage\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t}\n\t\treturn localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarHTTPResponse, nil\n}", "func (l *CassandraBulkLoad) processBatches(session *gocql.Session, waitGroup *sync.WaitGroup) error {\n\tvar rerr error\n\tfor batch := range l.batchChan {\n\t\tif !bulk_load.Runner.DoLoad {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Write the batch.\n\t\terr := session.ExecuteBatch(batch)\n\t\tif err != nil {\n\t\t\trerr = fmt.Errorf(\"Error writing: %s\\n\", err.Error())\n\t\t\tbreak\n\t\t}\n\t}\n\twaitGroup.Done()\n\treturn rerr\n}", "func (runner *TestRunner) ExecuteTestBatchWithCaseList (batchName string, batchParams BatchExecParams, timestamp time.Time, testCasePaths []string) (string, error) {\n\tbatchResultId := runner.rtdbServer.MakeUniqueID()\n\topSet := rtdb.NewOpSet()\n\n\t// Empty batch result.\n\tbatchResult := BatchResult {\n\t\tName:\t\t\tbatchName,\n\t\tExecParams:\t\tbatchParams,\n\t\tStatus:\t\t\tBATCH_STATUS_CODE_INITIALIZING,\n\t\tTimestamp:\t\ttimestamp,\n\t}\n\n\t// Header to batch result list.\n\tbatchResultHeader := BatchResultHeader {\n\t\tId:\t\tbatchResultId,\n\t\tName:\tbatchName,\n\t}\n\n\t// Store in rtdb. \\note Also initialize root group node already, so that the batch result list may show something sensible.\n\topSet.Call(typeBatchResultList, \"batchResultList\", \"Append\", batchResultHeader)\n\topSet.Call(typeActiveBatchResultList, \"activeBatchResultList\", \"Append\", batchResultId)\n\topSet.Call(typeBatchResult, batchResultId, \"Init\", batchResult)\n\topSet.Call(typeTestCaseList, batchResultId, \"Init\", TestCaseList { Paths: testCasePaths })\n\topSet.Call(typeTestCaseTreeGroup, batchResultId + \"/\", \"Init\", TestCaseTreeGroup { NumTotalCases: len(testCasePaths) })\n\topSet.Call(typeBatchResultExecutionLog, batchResultId, \"Init\")\n\n\terr := runner.rtdbServer.ExecuteOpSet(opSet)\n\tif err != nil { panic(err) }\n\n\t// Initialize and enqueue in background.\n\tgo func () {\n\t\trunner.initializeBatchResult(batchResultId);\n\n\t\trunner.queueControl <- batchExecQueueControlEnqueue {\n\t\t\tbatchResultId:\tbatchResultId,\n\t\t\tqueueId:\t\tbatchQueueId(batchParams),\n\t\t}\n\t}()\n\n\treturn batchResultId, nil\n}", "func runBatch(fn ...runBatchFunc) error {\n\teg := errgroup.Group{}\n\tfor _, f := range fn {\n\t\teg.Go(f)\n\t}\n\treturn eg.Wait()\n}", "func executeCommands(ctx context.Context, artifactsFolder string, debug bool, logDir, machineIP, bastionIP, machineUser string, commands []command) {\n\tprivateKey, err := os.ReadFile(filepath.Join(artifactsFolder, \"ssh\", DefaultSSHKeyPairName))\n\tif err != nil {\n\t\t_, _ = fmt.Fprintf(GinkgoWriter, \"could not load private key from artifacts folder: %s\\n\", err)\n\t\treturn\n\t}\n\tsigner, err := ssh.ParsePrivateKey(privateKey)\n\tif err != nil {\n\t\t_, _ = fmt.Fprintf(GinkgoWriter, \"could not parse private key from artifacts folder: %s\\n\", err)\n\t\treturn\n\t}\n\n\tfor _, cmd := range commands {\n\t\tif err := executeCommand(ctx, commandParameter{\n\t\t\tsigner: signer,\n\t\t\tdebug: debug,\n\t\t\tlogDir: logDir,\n\t\t\tbastionIP: bastionIP,\n\t\t\tmachineIP: machineIP,\n\t\t\tmachineUser: machineUser,\n\t\t\tcmd: cmd,\n\t\t}); err != nil {\n\t\t\t_, _ = fmt.Fprintln(GinkgoWriter, err.Error())\n\t\t}\n\t}\n}", "func (_Coordinatorproxy *CoordinatorproxySession) SubmitBatch(_txs [][]byte, _updatedRoot [32]byte) (*types.Transaction, error) {\n\treturn _Coordinatorproxy.Contract.SubmitBatch(&_Coordinatorproxy.TransactOpts, _txs, _updatedRoot)\n}", "func (committer *subNsCommitter) execute() error {\n\treturn commitUpdates(committer.db, committer.batchUpdateMap)\n}", "func (_Coordinatorproxy *CoordinatorproxyTransactor) SubmitBatch(opts *bind.TransactOpts, _txs [][]byte, _updatedRoot [32]byte) (*types.Transaction, error) {\n\treturn _Coordinatorproxy.contract.Transact(opts, \"submitBatch\", _txs, _updatedRoot)\n}", "func Execute(dir string, commands []string, out, err io.Writer) error {\n\tfor _, cmd := range commands {\n\t\terr := executeSingle(dir, cmd, out, err)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (zp *ZPackIns) CommitBatch(olabels []string) {\n\tzp.commitBatch(olabels)\n}", "func (c *cassandra) ExecuteUnloggedBatch(queries []string, params [][]interface{}) error {\n\treturn c.ExecuteBatch(gocql.UnloggedBatch, queries, params)\n}", "func (c *ContainerClient) ExecuteTransactionalBatch(ctx context.Context, b TransactionalBatch, o *TransactionalBatchOptions) (TransactionalBatchResponse, error) {\n\tif len(b.operations) == 0 {\n\t\treturn TransactionalBatchResponse{}, errors.New(\"no operations in batch\")\n\t}\n\n\th := headerOptionsOverride{\n\t\tpartitionKey: &b.partitionKey,\n\t}\n\n\tif o == nil {\n\t\to = &TransactionalBatchOptions{}\n\t} else {\n\t\th.enableContentResponseOnWrite = &o.EnableContentResponseOnWrite\n\t}\n\n\t// If contentResponseOnWrite is not enabled at the client level the\n\t// service will not even send a batch response payload\n\t// Instead we should automatically enforce contentResponseOnWrite for all\n\t// batch requests whenever at least one of the item operations requires a content response (read operation)\n\tenableContentResponseOnWriteForReadOperations := true\n\tfor _, op := range b.operations {\n\t\tif op.getOperationType() == operationTypeRead {\n\t\t\th.enableContentResponseOnWrite = &enableContentResponseOnWriteForReadOperations\n\t\t\tbreak\n\t\t}\n\t}\n\n\toperationContext := pipelineRequestOptions{\n\t\tresourceType: resourceTypeDocument,\n\t\tresourceAddress: c.link,\n\t\tisWriteOperation: true,\n\t\theaderOptionsOverride: &h}\n\n\tpath, err := generatePathForNameBased(resourceTypeDocument, operationContext.resourceAddress, true)\n\tif err != nil {\n\t\treturn TransactionalBatchResponse{}, err\n\t}\n\n\tazResponse, err := c.database.client.sendBatchRequest(\n\t\tctx,\n\t\tpath,\n\t\tb.operations,\n\t\toperationContext,\n\t\to,\n\t\tnil)\n\tif err != nil {\n\t\treturn TransactionalBatchResponse{}, err\n\t}\n\n\treturn newTransactionalBatchResponse(azResponse)\n}", "func (c *BlockWriterCase) Execute(db *sql.DB, index int) error {\n\tc.bws[index].batchExecute(db, c.cfg.TableNum)\n\treturn nil\n}", "func (_Coordinatorproxy *CoordinatorproxyTransactorSession) SubmitBatch(_txs [][]byte, _updatedRoot [32]byte) (*types.Transaction, error) {\n\treturn _Coordinatorproxy.Contract.SubmitBatch(&_Coordinatorproxy.TransactOpts, _txs, _updatedRoot)\n}", "func (batchItems BatchItems) RunBatch(identityID string) BatchResponse {\n\n\tbatchResponseChans := make([]chan interface{}, len(batchItems))\n\tfor idx, batchItem := range batchItems {\n\t\tbatchResponseChans[idx] = make(chan interface{})\n\t\tgo batchItem.RequestItemAsync(batchResponseChans[idx], identityID)\n\t}\n\n\tbatchResponse := make(BatchResponse, len(batchItems))\n\tfor idx, batchResponseChan := range batchResponseChans {\n\t\titemResponse := <-batchResponseChan\n\n\t\tswitch itemResponse := itemResponse.(type) {\n\t\tcase error:\n\t\t\tbatchResponse[idx] = batchItems.MakeError(500, itemResponse)\n\n\t\tcase BatchResponseItem:\n\t\t\tbatchResponse[idx] = itemResponse\n\n\t\t}\n\t}\n\n\treturn batchResponse\n}", "func (builder *nsCommittersBuilder) execute() error {\n\tif err := addRevisionsForMissingKeys(builder.revisions, builder.db, builder.updates); err != nil {\n\t\treturn err\n\t}\n\tmaxBacthSize := ledgerconfig.GetMaxBatchUpdateSize()\n\tbatchUpdateMap := make(map[string]*batchableDocument)\n\tfor key, vv := range builder.updates {\n\t\tmongoDoc, err := keyValToMongoDoc(&keyValue{key: key, VersionedValue: vv}, builder.revisions[key])\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tbatchUpdateMap[key] = &batchableDocument{MongoDoc: *mongoDoc, Deleted: vv.Value == nil}\n\t\tif len(batchUpdateMap) == maxBacthSize {\n\t\t\tbuilder.subNsCommitters = append(builder.subNsCommitters, &subNsCommitter{builder.db, batchUpdateMap})\n\t\t\tbatchUpdateMap = make(map[string]*batchableDocument)\n\t\t}\n\t}\n\tif len(batchUpdateMap) > 0 {\n\t\tbuilder.subNsCommitters = append(builder.subNsCommitters, &subNsCommitter{builder.db, batchUpdateMap})\n\t}\n\treturn nil\n}", "func (bcb *BouncerCreateBulk) Exec(ctx context.Context) error {\n\t_, err := bcb.Save(ctx)\n\treturn err\n}", "func (h *RepairingHandler) HandleBatch(keys []serialization.Data, sources []types.UUID, partitions []types.UUID, seqs []int64) error {\n\t// port of: com.hazelcast.internal.nearcache.impl.invalidation.RepairingHandler#handle(java.util.Collection<com.hazelcast.internal.serialization.Data>, java.util.Collection<java.util.UUID>, java.util.Collection<java.util.UUID>, java.util.Collection<java.lang.Long>)\n\t// assumes len(keys) == len(source) -- len(partitions) == len(seqs)\n\tsz := len(keys)\n\tfor i := 0; i < sz; i++ {\n\t\tif err := h.Handle(keys[i], sources[i], partitions[i], seqs[i]); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func RunCommands(t *testing.T, tp *Tapestry, c []int) {\n\tfor _, comm := range c {\n\t\tswitch comm {\n\t\tcase PUB:\n\t\t\tPublish(t, tp)\n\t\t\tbreak\n\t\tcase GET:\n\t\t\tRetrieve(t, tp)\n\t\t\tbreak\n\t\tcase ADD:\n\t\t\tAdd(t, tp)\n\t\t\tbreak\n\t\tcase LEAVE:\n\t\t\tLeave(t, tp)\n\t\t\tbreak\n\t\tcase DEL:\n\t\t\tDelete(t, tp)\n\t\tcase KILL:\n\t\t\tKill(t, tp)\n\t\tdefault:\n\t\t\tt.Errorf(\"invalid command\")\n\t\t}\n\t\ttime.Sleep(time.Duration(tp.Rand.Intn(MAX_CMD_DELAY_MS)) * time.Millisecond)\n\t}\n}", "func (c *NOOPConnection) SendMessageBatch(batch raftpb.MessageBatch) error {\n\tif c.req.Fail() {\n\t\treturn ErrRequestedToFail\n\t}\n\tfor c.req.Blocked() {\n\t\ttime.Sleep(50 * time.Millisecond)\n\t}\n\treturn nil\n}", "func ExecuteCommands(scanner *bufio.Scanner) {\n\tnewline := getNewlineStr()\n\texit := false\n\n\tfor !exit && scanner.Scan() {\n\t\tcommandStr := strings.TrimRight(scanner.Text(), newline)\n\t\tparsedCommand := parse(commandStr)\n\n\t\tif len(parsedCommand) < 1 {\n\t\t\tlog.Fatal(\"Insufficient command line params\")\n\t\t\treturn\n\t\t}\n\n\t\tcommand := parsedCommand[0]\n\n\t\tswitch {\n\t\tcase command == CreateParkingLot:\n\t\t\tcmdCreateParking := NewCommandCreateParking(command, parsedCommand)\n\t\t\terr := cmdCreateParking.Execute()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err.Error())\n\t\t\t}\n\t\t\tfmt.Println(cmdCreateParking.Output)\n\n\t\tcase command == ParkVehicle:\n\t\t\tcmdPark := NewCommandPark(command, parsedCommand)\n\t\t\terr := cmdPark.Execute()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err.Error())\n\t\t\t}\n\t\t\tfmt.Println(cmdPark.Output)\n\n\t\tcase command == RemoveVehicle:\n\t\t\tcmdRemove := NewCommandRemove(command, parsedCommand)\n\t\t\terr := cmdRemove.Execute()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err.Error())\n\t\t\t}\n\t\t\tfmt.Println(cmdRemove.Output)\n\n\t\tcase command == GetParkingLotStatus:\n\t\t\tcmdStatus := NewCommandStatus(command, parsedCommand)\n\t\t\terr := cmdStatus.Execute()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err.Error())\n\t\t\t}\n\t\t\tfmt.Println(cmdStatus.Output)\n\n\t\tcase command == GetRegNumWithColor:\n\t\t\tcmdGetRegNumWithColor := NewCommandGetRegNumWithColor(command, parsedCommand)\n\t\t\terr := cmdGetRegNumWithColor.Execute()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err.Error())\n\t\t\t}\n\t\t\tfmt.Println(cmdGetRegNumWithColor.Output)\n\n\t\tcase command == GetSlotNumWithColor:\n\t\t\tcmdGetSlotNumWithColor := NewCommandGetSlotNumWithColor(command, parsedCommand)\n\t\t\terr := cmdGetSlotNumWithColor.Execute()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err.Error())\n\t\t\t}\n\t\t\tfmt.Println(cmdGetSlotNumWithColor.Output)\n\n\t\tcase command == GetSlotNumWithRegNum:\n\t\t\tcmdGetSlotNumWithRegNum := NewCommandGetSlotNumWithRegNum(command, parsedCommand)\n\t\t\terr := cmdGetSlotNumWithRegNum.Execute()\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(err.Error())\n\t\t\t}\n\t\t\tfmt.Println(cmdGetSlotNumWithRegNum.Output)\n\n\t\tcase command == ExitParkingLot && len(parsedCommand) == 1:\n\t\t\texit = true\n\t\tdefault:\n\t\t\tfmt.Println(perror.ErrInvalidCommand)\n\t\t}\n\t}\n}", "func execCommand(cmd string, conn sql.DB) {\n\tvar id int\n\tvar response string\n\treceived := false\n\titerations := 0\n\n\tinsertSql := \"insert into requests (cmd) output inserted.ID values ('\" + cmd + \"'); select SCOPE_IDENTITY();\"\n\t\n\terr := conn.QueryRow(insertSql).Scan(&id)\n\tif err != nil {\n\t\tlog.Println(\"Unable to execute insert:\", err)\n\t\treturn\n\t}\n\tlog.Println(\"[i] Queued tasking: \", cmd)\n\tfor received == false && iterations < 10 {\n\t\ttime.Sleep(3 * time.Second)\n\n\t\tselectSql := \"select response from responses where request_id = \"\n\t\tselectErr := conn.QueryRow(selectSql + strconv.Itoa(id)).Scan(&response)\n\t\tif selectErr != nil {\n\t\t\tlog.Println(\"Waiting for response...\")\n\t\t\titerations++\n\t\t\tif iterations == 10 {\n\t\t\t\tlog.Println(\"Unable to receive response: \", selectErr)\n\t\t\t}\n\t\t} else {\n\t\t\treceived = true\n\t\t\tlog.Println(response)\n\t\t}\n\t}\n}", "func (d Dispatcher) Batch(jrs []string) (string, error) {\n\t//TODO: send result to message broker\n\tvar requests []job.Request\n\tfor _, jr := range jrs {\n\t\tvar request job.Request\n\t\terr := helpers.Deserialize([]byte(jr), &request)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\trequests = append(requests, request)\n\t}\n\n\tb, err := batch.NewBatch(requests, d.GetBC(), d.GetJobPQ(), d.GetJC())\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tb.Dispatch()\n\tresult, err := json.Marshal(b.Result())\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(result), nil\n}", "func (pushbots *PushBots) Batch(platform, msg, sound, badge string, tags, exceptTags, notificationTypes, exceptNotificationTypes []string,\n\talias, exceptAlias string, payload map[string]interface{}) error {\n\n\tif platform != PlatformIos && platform != PlatformAndroid {\n\t\treturn errors.New(\"Platform must be either PlatformIos or PlatformAndroid\")\n\t}\n\n\tif msg == \"\" {\n\t\treturn errors.New(\"No message specified\")\n\t}\n\n\tif sound == \"\" && platform != PlatformIos {\n\t\treturn errors.New(\"No sound specified\")\n\t} else if sound == \"\" && platform == PlatformIos {\n\t\tsound = \"default\"\n\t}\n\n\tif badge == \"\" {\n\t\tbadge = \"0\"\n\t}\n\n\targs := apiRequest{\n\t\tPayload: payload,\n\t\tAlias: alias,\n\t\tExceptAlias: exceptAlias,\n\t\tPlatform: platform,\n\t\tMsg: msg,\n\t\tSound: sound,\n\t\tBadge: badge,\n\t\tTags: tags,\n\t\tExceptTags: exceptTags,\n\t\tNotificationType: notificationTypes,\n\t\tExceptNotificationTypes: exceptNotificationTypes,\n\t}\n\n\treturn checkAndReturn(pushbots.sendToEndpoint(\"batch\", args))\n}", "func (r apiUpdateCouponBatchRequest) Execute() (*_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodPut\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t)\n\n\tlocalBasePath, err := r.apiService.client.cfg.ServerURLWithContext(r.ctx, \"ManagementApiService.UpdateCouponBatch\")\n\tif err != nil {\n\t\treturn nil, GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/v1/applications/{applicationId}/campaigns/{campaignId}/coupons\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"applicationId\"+\"}\", _neturl.QueryEscape(parameterToString(r.applicationId, \"\")), -1)\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"campaignId\"+\"}\", _neturl.QueryEscape(parameterToString(r.campaignId, \"\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\tif r.body == nil {\n\t\treturn nil, reportError(\"body is required and must be specified\")\n\t}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{\"application/json\"}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\t// body params\n\tlocalVarPostBody = r.body\n\tif r.ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {\n\t\t\tif auth, ok := auth[\"Authorization\"]; ok {\n\t\t\t\tvar key string\n\t\t\t\tif auth.Prefix != \"\" {\n\t\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t\t} else {\n\t\t\t\t\tkey = auth.Key\n\t\t\t\t}\n\t\t\t\tlocalVarHeaderParams[\"Authorization\"] = key\n\t\t\t}\n\t\t}\n\t}\n\tif r.ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {\n\t\t\tif auth, ok := auth[\"Authorization\"]; ok {\n\t\t\t\tvar key string\n\t\t\t\tif auth.Prefix != \"\" {\n\t\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t\t} else {\n\t\t\t\t\tkey = auth.Key\n\t\t\t\t}\n\t\t\t\tlocalVarHeaderParams[\"Authorization\"] = key\n\t\t\t}\n\t\t}\n\t}\n\treq, err := r.apiService.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := r.apiService.client.callAPI(req)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarHTTPResponse, err\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\t\treturn localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarHTTPResponse, nil\n}", "func (e *executor) Execute() error {\n\tif len(e.executables) < 1 {\n\t\treturn errors.New(\"nothing to Work\")\n\t}\n\n\tlog(e.id).Infof(\"processing %d item(s)\", len(e.executables))\n\treturn nil\n}", "func (ExecutionResultRepoCassandra) DeleteBatch(ctx context.Context, executionResults []ExecutionResult) error {\n\tbatch := cassandra.Session.NewBatch(gocql.UnloggedBatch)\n\n\tfor i, e := range executionResults {\n\t\teFields := []interface{}{\n\t\t\te.ManagedEndpointID,\n\t\t\te.TaskInstanceID,\n\t\t}\n\n\t\tbatch.Query(deleteScriptExecutionResultCQL, eFields...)\n\t\tbatch.Query(deleteScriptExecutionResultMatViewCQL, eFields...)\n\n\t\t// no more than config.Config.CassandraBatchSize in 1 batch or all if it's the last iteration\n\t\tif (i+1)%config.Config.CassandraBatchSize == 0 || i+1 == len(executionResults) {\n\t\t\terr := cassandra.Session.ExecuteBatch(batch)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tbatch = cassandra.Session.NewBatch(gocql.UnloggedBatch)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (c *fileStorageClient) Batch(ops ...Operation) error {\n\tbatch := func(tx *bbolt.Tx) error {\n\t\tbucket := tx.Bucket(defaultBucket)\n\t\tif bucket == nil {\n\t\t\treturn errors.New(\"storage not initialized\")\n\t\t}\n\n\t\tvar err error\n\t\tfor _, op := range ops {\n\t\t\tswitch op.Type {\n\t\t\tcase Get:\n\t\t\t\top.Value = bucket.Get([]byte(op.Key))\n\t\t\tcase Set:\n\t\t\t\terr = bucket.Put([]byte(op.Key), op.Value)\n\t\t\tcase Delete:\n\t\t\t\terr = bucket.Delete([]byte(op.Key))\n\t\t\tdefault:\n\t\t\t\treturn errors.New(\"wrong operation type\")\n\t\t\t}\n\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t}\n\n\treturn c.db.Update(batch)\n}", "func (c *UpdateSpaceQuotasCommand) Execute([]string) error {\n\tvar cfMgmt *CFMgmt\n\tvar err error\n\tif cfMgmt, err = InitializeManagers(c.BaseCFConfigCommand); err == nil {\n\t\terr = cfMgmt.SpaceManager.CreateQuotas(c.ConfigDirectory)\n\t}\n\treturn err\n}", "func executePipeline(commandList []exec.Cmd) error {\n\t//TODO: Handle case where the command is built in\n\t// Start execution in reverse pipe order\n\tfor i := len(commandList) - 1; i > 0; i-- {\n\t\tcommandList[i].Start()\n\t}\n\n\t// Make the commands wait for completion\n\tfor i := range commandList {\n\t\tif i == 0 {\n\t\t\terr := commandList[i].Run()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\terr := commandList[i].Wait()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (s BoltStore) BatchUpdate(ids []interface{}, data []interface{}, store string, opts ObjectStoreOptions) (err error) {\n\treturn ErrNotImplemented\n}", "func (b *Blueprint) Execute(conn Connection) []string {\n\tgrammar := conn.GetQueryGrammar()\n\tstatements := b.toSQL(&conn, grammar)\n\n\tfor _, statement := range statements {\n\t\tfmt.Println(statement)\n\t\tif _, err := conn.Exec(statement); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\treturn statements\n}", "func (s *Store) Batch([]newstorage.Operation) error {\n\treturn errors.New(\"batch failure\")\n}", "func (b *Bazooka) SubmitBatch(commitments []Commitment) error {\n\t// b.log.Info(\n\t// \t\"Attempting to submit a new batch\",\n\t// \t\"NumOfCommitments\",\n\t// \tlen(commitments),\n\t// )\n\n\t// if len(commitments) == 0 {\n\t// \tb.log.Info(\"No transactions to submit, waiting....\")\n\t// \treturn nil\n\t// }\n\n\t// var txs [][]byte\n\t// var updatedRoots [][32]byte\n\t// var aggregatedSig [][2]*big.Int\n\t// var totalTransactionsBeingCommitted int\n\t// for _, commitment := range commitments {\n\t// \tcompressedTxs, err := b.CompressTxs(commitment.Txs)\n\t// \tif err != nil {\n\t// \t\tb.log.Error(\"Unable to compress txs\", \"error\", err)\n\t// \t\treturn err\n\t// \t}\n\t// \ttxs = append(txs, compressedTxs)\n\t// \tupdatedRoots = append(updatedRoots, commitment.UpdatedRoot)\n\t// \ttotalTransactionsBeingCommitted += len(commitment.Txs)\n\t// \tsig1 := commitment.AggregatedSignature[0:32]\n\t// \tsig2 := commitment.AggregatedSignature[32:64]\n\t// \tsig1bigInt := big.NewInt(0)\n\t// \tsig1bigInt.SetBytes(sig1)\n\t// \tsig2bigInt := big.NewInt(0)\n\t// \tsig2bigInt.SetBytes(sig2)\n\t// \taggregatedSigBigInt := [2]*big.Int{sig1bigInt, sig2bigInt}\n\t// \tfmt.Println(\"creeated aggregated sig\", aggregatedSigBigInt)\n\t// \taggregatedSig = append(aggregatedSig, aggregatedSigBigInt)\n\t// }\n\n\t// b.log.Info(\"Batch prepared\", \"totalTransactions\", totalTransactionsBeingCommitted)\n\t// data, err := b.ContractABI[common.ROLLUP_CONTRACT_KEY].Pack(\"submitBatch\", txs, updatedRoots, uint8(commitments[0].BatchType), aggregatedSig)\n\t// if err != nil {\n\t// \tb.log.Error(\"Error packing data for submitBatch\", \"err\", err)\n\t// \treturn err\n\t// }\n\n\t// rollupAddress := ethCmn.HexToAddress(config.GlobalCfg.RollupAddress)\n\t// stakeAmount := big.NewInt(0)\n\t// stakeAmount.SetString(\"3200000000000000000\", 10)\n\n\t// // generate call msg\n\t// callMsg := ethereum.CallMsg{\n\t// \tTo: &rollupAddress,\n\t// \tData: data,\n\t// \tValue: stakeAmount,\n\t// }\n\n\t// auth, err := b.GenerateAuthObj(b.EthClient, callMsg)\n\t// if err != nil {\n\t// \tb.log.Error(\"Error creating auth object\", \"error\", err)\n\t// \treturn err\n\t// }\n\n\t// // lastTxBroadcasted, err := DBInstance.GetLastTransaction()\n\t// // if err != nil {\n\t// // \treturn err\n\t// // }\n\n\t// // if lastTxBroadcasted.Nonce+1 != auth.Nonce.Uint64() {\n\t// // \tb.log.Info(\"Replacing nonce\", \"nonceEstimated\", auth.Nonce.String(), \"replacedBy\", lastTxBroadcasted.Nonce+1)\n\t// // \tauth.Nonce = big.NewInt(int64(lastTxBroadcasted.Nonce + 1))\n\t// // }\n\n\t// // latestBatch, err := DBInstance.GetLatestBatch()\n\t// // if err != nil {\n\t// // \treturn err\n\t// // }\n\n\t// // newBatch := Batch{\n\t// // \tBatchID: latestBatch.BatchID + 1,\n\t// // \tStateRoot: updatedRoot.String(),\n\t// // \tCommitter: config.OperatorAddress.String(),\n\t// // \tStatus: BATCH_BROADCASTED,\n\t// // }\n\n\t// // b.log.Info(\"Broadcasting a new batch\", \"newBatch\", newBatch)\n\t// // err = DBInstance.AddNewBatch(newBatch)\n\t// // if err != nil {\n\t// // \treturn err\n\t// // }\n\n\t// tx, err := b.RollupContract.SubmitBatch(auth, txs, updatedRoots, uint8(commitments[0].BatchType), aggregatedSig)\n\t// if err != nil {\n\t// \tb.log.Error(\"Error submitting batch\", \"err\", err)\n\t// \treturn err\n\t// }\n\t// b.log.Info(\"Sent a new batch!\", \"TxHash\", tx.Hash().String())\n\n\t// // err = DBInstance.LogBatch(0, txs[0].Type, updatedRoot.String(), compressedTxs)\n\t// // if err != nil {\n\t// // \treturn err\n\t// // }\n\n\treturn nil\n}", "func (ggcb *GithubGistCreateBulk) Exec(ctx context.Context) error {\n\t_, err := ggcb.Save(ctx)\n\treturn err\n}", "func (output *MySQLOutput) Execute(msgs []*core.Msg) error {\n\tvar targetTableDef *schema_store.Table\n\tvar targetMsgs []*core.Msg\n\n\tfor _, msg := range msgs {\n\t\t// ddl msg filter\n\t\tif !output.cfg.EngineConfig.EnableDDL && msg.Type == core.MsgDDL {\n\t\t\tcontinue\n\t\t}\n\n\t\tmatched := false\n\t\tvar targetSchema string\n\t\tvar targetTable string\n\t\tfor _, route := range output.routes {\n\t\t\tif route.Match(msg) {\n\t\t\t\tmatched = true\n\t\t\t\ttargetSchema, targetTable = route.GetTarget(msg.Database, msg.Table)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// none of the routes matched, skip this msg\n\t\tif !matched {\n\t\t\tcontinue\n\t\t}\n\n\t\tif targetTableDef == nil {\n\t\t\tschema, err := output.targetSchemaStore.GetSchema(targetSchema)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Trace(err)\n\t\t\t}\n\n\t\t\ttargetTableDef = schema[targetTable]\n\t\t}\n\n\t\t// go through a serial of filters inside this output plugin\n\t\t// right now, we only support AddMissingColumn\n\t\tif _, err := AddMissingColumn(msg, targetTableDef); err != nil {\n\t\t\treturn errors.Trace(err)\n\t\t}\n\n\t\ttargetMsgs = append(targetMsgs, msg)\n\t}\n\n\tbatches := splitMsgBatchWithDelete(targetMsgs)\n\n\tfor _, batch := range batches {\n\t\tif batch[0].Type == core.MsgDML && targetTableDef == nil {\n\t\t\treturn errors.Errorf(\"[output-mysql] schema: %v, table: %v, targetTable nil\", batch[0].Database, batch[0].Table)\n\t\t}\n\n\t\terr := output.sqlExecutionEngine.Execute(batch, targetTableDef)\n\t\tif err != nil {\n\t\t\treturn errors.Trace(err)\n\t\t}\n\t\tif batch[0].DdlMsg != nil {\n\t\t\tif err := output.targetSchemaStore.InvalidateCache(); err != nil {\n\t\t\t\treturn errors.Trace(err)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (downloader *ConcurrentDownloader) Execute() {\n\tfor path := range downloader.DownloadContent {\n\t\tgo func(path string) {\n\t\t\tcontent, err := GetS3Service(downloader.region).ReadFromS3Concurrently(downloader.bucketName, path)\n\t\t\tif err == nil {\n\t\t\t\tdownloader.downloadChan <- map[string][]byte{\n\t\t\t\t\tpath: content,\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdownloader.downloadChan <- map[string][]byte{\n\t\t\t\t\tpath: []byte(\"error\"),\n\t\t\t\t}\n\t\t\t}\n\n\t\t}(path)\n\t}\n\n\tdownloader.checkProgress()\n}", "func Batch(cfg *config.Configuration, objects []*ObjectResource, operation string, transferAdapters []string) (objs []*ObjectResource, transferAdapter string, e error) {\n\tif len(objects) == 0 {\n\t\treturn nil, \"\", nil\n\t}\n\n\t// Compatibility; omit transfers list when only basic\n\t// older schemas included `additionalproperties=false`\n\tif len(transferAdapters) == 1 && transferAdapters[0] == \"basic\" {\n\t\ttransferAdapters = nil\n\t}\n\n\to := &batchRequest{Operation: operation, Objects: objects, TransferAdapterNames: transferAdapters}\n\tby, err := json.Marshal(o)\n\tif err != nil {\n\t\treturn nil, \"\", errors.Wrap(err, \"batch request\")\n\t}\n\n\treq, err := NewBatchRequest(cfg, operation)\n\tif err != nil {\n\t\treturn nil, \"\", errors.Wrap(err, \"batch request\")\n\t}\n\n\treq.Header.Set(\"Content-Type\", MediaType)\n\treq.Header.Set(\"Content-Length\", strconv.Itoa(len(by)))\n\treq.ContentLength = int64(len(by))\n\treq.Body = tools.NewReadSeekCloserWrapper(bytes.NewReader(by))\n\n\ttracerx.Printf(\"api: batch %d files\", len(objects))\n\n\tres, bresp, err := DoBatchRequest(cfg, req)\n\n\tif err != nil {\n\t\tif res == nil {\n\t\t\treturn nil, \"\", errors.NewRetriableError(err)\n\t\t}\n\n\t\tif res.StatusCode == 0 {\n\t\t\treturn nil, \"\", errors.NewRetriableError(err)\n\t\t}\n\n\t\tif errors.IsAuthError(err) {\n\t\t\thttputil.SetAuthType(cfg, req, res)\n\t\t\treturn Batch(cfg, objects, operation, transferAdapters)\n\t\t}\n\n\t\tswitch res.StatusCode {\n\t\tcase 404, 410:\n\t\t\treturn nil, \"\", errors.NewNotImplementedError(errors.Errorf(\"api: batch not implemented: %d\", res.StatusCode))\n\t\t}\n\n\t\ttracerx.Printf(\"api error: %s\", err)\n\t\treturn nil, \"\", errors.Wrap(err, \"batch response\")\n\t}\n\thttputil.LogTransfer(cfg, \"lfs.batch\", res)\n\n\tif res.StatusCode != 200 {\n\t\treturn nil, \"\", errors.Errorf(\"Invalid status for %s: %d\", httputil.TraceHttpReq(req), res.StatusCode)\n\t}\n\n\treturn bresp.Objects, bresp.TransferAdapterName, nil\n}", "func (sa *SeaweedAdmin) ProcessCommands(cmds string) error {\n\tfor _, c := range strings.Split(cmds, \";\") {\n\t\tif err := sa.ProcessCommand(c); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (_Trebuchet *TrebuchetTransactor) Execute(opts *bind.TransactOpts, _data [][]byte) (*types.Transaction, error) {\n\treturn _Trebuchet.contract.Transact(opts, \"execute\", _data)\n}", "func (prod *InfluxDB) sendBatch() core.AssemblyFunc {\n\tif prod.writer.isConnectionUp() {\n\t\treturn prod.assembly.Write\n\t} else if prod.IsStopping() {\n\t\treturn prod.assembly.Flush\n\t}\n\n\treturn nil\n}", "func execute(cars []*single.Car, function int, increment ...int) {\n\n\t// excute command for all cars\n\tfor _, car := range cars {\n\t\tswitch function {\n\t\tcase turnOn:\n\t\t\tcar.TurnOn()\n\t\tcase turnOff:\n\t\t\tcar.TurnOff()\n\t\tcase accelerate:\n\t\t\tcar.Accelerate(increment[0])\n\t\t}\n\t}\n}", "func (c *BlockWriterCase) Execute(db *sql.DB) error {\n\tconcurrency := len(c.bws)\n\tch := make(chan error, concurrency)\n\tfor i := 0; i < concurrency; i++ {\n\t\tgo c.bws[i].execute(db, ch)\n\t}\n\n\tfor i := 0; i < concurrency; i++ {\n\t\terr := <-ch\n\t\tif err != nil {\n\t\t\treturn errors.Trace(err)\n\t\t}\n\t}\n\treturn nil\n}", "func executeListCmd(t *gotesting.T, stdout io.Writer, args []string, wrapper *stubRunWrapper) subcommands.ExitStatus {\n\ttd := testutil.TempDir(t)\n\tdefer os.RemoveAll(td)\n\n\tcmd := newListCmd(stdout, td)\n\tcmd.wrapper = wrapper\n\tflags := flag.NewFlagSet(\"\", flag.ContinueOnError)\n\tcmd.SetFlags(flags)\n\tif err := flags.Parse(args); err != nil {\n\t\tt.Fatal(err)\n\t}\n\tflags.Set(\"build\", \"false\") // DeriveDefaults fails if -build=true and bundle dirs are missing\n\treturn cmd.Execute(context.Background(), flags)\n}", "func (a *addTask) Execute([]string) error {\n\ttask, err := a.newTask()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating task: %w\", err)\n\t}\n\n\treturn dal.CreateTask(a.getDbConfig(), task)\n}", "func (icb *ItemCreateBulk) Exec(ctx context.Context) error {\n\t_, err := icb.Save(ctx)\n\treturn err\n}", "func doBatchTransfer(ctx context.Context, o batchTransferOptions) error {\n\t// Prepare and do parallel operations.\n\tnumChunks := uint16(((o.transferSize - 1) / o.chunkSize) + 1)\n\toperationChannel := make(chan func() error, o.parallelism) // Create the channel that release 'parallelism' goroutines concurrently\n\toperationResponseChannel := make(chan error, numChunks) // Holds each response\n\tctx, cancel := context.WithCancel(ctx)\n\tdefer cancel()\n\n\t// Create the goroutines that process each operation (in parallel).\n\tif o.parallelism == 0 {\n\t\to.parallelism = 5 // default parallelism\n\t}\n\tfor g := uint16(0); g < o.parallelism; g++ {\n\t\t//grIndex := g\n\t\tgo func() {\n\t\t\tfor f := range operationChannel {\n\t\t\t\t//fmt.Printf(\"[%s] gr-%d start action\\n\", o.operationName, grIndex)\n\t\t\t\terr := f()\n\t\t\t\toperationResponseChannel <- err\n\t\t\t\t//fmt.Printf(\"[%s] gr-%d end action\\n\", o.operationName, grIndex)\n\t\t\t}\n\t\t}()\n\t}\n\n\t// Add each chunk's operation to the channel.\n\tfor chunkNum := uint16(0); chunkNum < numChunks; chunkNum++ {\n\t\tcurChunkSize := o.chunkSize\n\n\t\tif chunkNum == numChunks-1 { // Last chunk\n\t\t\tcurChunkSize = o.transferSize - (int64(chunkNum) * o.chunkSize) // Remove size of all transferred chunks from total\n\t\t}\n\t\toffset := int64(chunkNum) * o.chunkSize\n\n\t\toperationChannel <- func() error {\n\t\t\treturn o.operation(offset, curChunkSize)\n\t\t}\n\t}\n\tclose(operationChannel)\n\n\t// Wait for the operations to complete.\n\tfor chunkNum := uint16(0); chunkNum < numChunks; chunkNum++ {\n\t\tresponseError := <-operationResponseChannel\n\t\tif responseError != nil {\n\t\t\tcancel() // As soon as any operation fails, cancel all remaining operation calls\n\t\t\treturn responseError // No need to process anymore responses\n\t\t}\n\t}\n\treturn nil\n}", "func (t *IPDCChaincode) invoke_bulk(stub shim.ChaincodeStubInterface, args []string) pb.Response {\r\n\r\n\tfmt.Println(\"***********Entering invoke_bulk***********\")\r\n\r\n\tif len(args) > (PROCESSING_LIMIT + 10) {\r\n\r\n\t\tfmt.Println(\"Error: Too many invoke calls in bulk invoke\")\r\n\r\n\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\treturn shim.Error(\"Error: Too many invoke calls in bulk invoke\")\r\n\r\n\t}\r\n\r\n\tsuccess_string := \"[\"\r\n\r\n\tfor i_number, individual_invoke_args := range args {\r\n\r\n\t\ti := fmt.Sprint(i_number)\r\n\r\n\t\tvar list_args_interface []interface{}\r\n\r\n\t\terr_json := json.Unmarshal([]byte(individual_invoke_args), &list_args_interface)\r\n\r\n\t\tif err_json != nil {\r\n\r\n\t\t\tfmt.Println(\"Error: Unable to read the arguments for Invoke no. \" + i + err_json.Error())\r\n\r\n\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\treturn shim.Error(\"Error: Unable to read the arguments for Invoke no. \" + i + err_json.Error())\r\n\t\t}\r\n\r\n\t\tif len(list_args_interface) < 1 {\r\n\r\n\t\t\tfmt.Println(\"Error: empty payload for Invoke no. \" + i)\r\n\r\n\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\treturn shim.Error(\"Error: empty payload for Invoke no. \" + i)\r\n\t\t}\r\n\r\n\t\tvar list_args []string\r\n\r\n\t\t//list_args = make([]string, len(list_args_interface))\r\n\r\n\t\tfor _, value_interface := range list_args_interface {\r\n\r\n\t\t\tvalue_string, ok_value_string := value_interface.(string)\r\n\r\n\t\t\tif !ok_value_string {\r\n\r\n\t\t\t\tfmt.Println(\"Error: Invalid format of payload for Invoke no. \" + i)\r\n\r\n\t\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\t\treturn shim.Error(\"Error: Invalid format of payload for Invoke no. \" + i)\r\n\t\t\t}\r\n\r\n\t\t\tlist_args = append(list_args, value_string)\r\n\t\t}\r\n\r\n\t\tfunction_name := list_args[0]\r\n\r\n\t\targs_to_pass := list_args[1:]\r\n\r\n\t\tkey_for_func := \"FunctionName*\" + function_name\r\n\r\n\t\tvalAsBytes, err := stub.GetState(key_for_func)\r\n\r\n\t\tif err != nil {\r\n\r\n\t\t\tfmt.Println(fmt.Sprintf(\"Error: Failed to get state: \" + err.Error() + \" for Invoke no. \" + i))\r\n\r\n\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\treturn shim.Error(\"Error: Failed to get state: \" + err.Error() + \" for Invoke no. \" + i)\r\n\r\n\t\t} else if valAsBytes == nil {\r\n\r\n\t\t\tfmt.Println(\"Error: No value for key : \" + key_for_func + \" for Invoke no. \" + i)\r\n\r\n\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\treturn shim.Error(\"Error: No value for key : \" + key_for_func + \" for Invoke no. \" + i)\r\n\t\t}\r\n\r\n\t\tvar json_specification interface{}\r\n\r\n\t\terr = json.Unmarshal(valAsBytes, &json_specification)\r\n\r\n\t\tif err != nil {\r\n\r\n\t\t\tfmt.Println(\"Error in decoding Specification JSON\" + \" for Invoke no. \" + i)\r\n\r\n\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\treturn shim.Error(\"Error in decoding Specification JSON\" + \" for Invoke no. \" + i)\r\n\t\t}\r\n\r\n\t\tmap_specification, ok1 := json_specification.(map[string]interface{})\r\n\r\n\t\tif !ok1 {\r\n\t\t\tfmt.Println(\"Error Parsing map_specification\" + \" for Invoke no. \" + i)\r\n\r\n\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\treturn shim.Error(\"Error Parsing map_specification\" + \" for Invoke no. \" + i)\r\n\t\t}\r\n\r\n\t\toperation, ok2 := map_specification[\"operation\"]\r\n\r\n\t\tif !ok2 {\r\n\t\t\tfmt.Println(\"Error Parsing operation\" + \" for Invoke no. \" + i)\r\n\r\n\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\treturn shim.Error(\"Error Parsing operation\" + \" for Invoke no. \" + i)\r\n\t\t}\r\n\r\n\t\tprimitive_list, ok3 := operation.(map[string]interface{})\r\n\r\n\t\tif !ok3 {\r\n\t\t\tfmt.Println(\"Error Parsing primitive list\" + \" for Invoke no. \" + i)\r\n\r\n\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\treturn shim.Error(\"Error Parsing primitive list\" + \" for Invoke no. \" + i)\r\n\t\t}\r\n\r\n\t\tif _, ok3 = primitive_list[\"primitive\"]; !ok3 {\r\n\r\n\t\t\tfmt.Println(\"Error: no primitive operation\" + \" for Invoke no. \" + i)\r\n\r\n\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\treturn shim.Error(\"Error: no primitive operation\" + \" for Invoke no. \" + i)\r\n\t\t}\r\n\r\n\t\tvar primitive_operation string\r\n\r\n\t\tprimitive_operation, ok3 = primitive_list[\"primitive\"].(string)\r\n\r\n\t\tif !ok3 {\r\n\r\n\t\t\tfmt.Println(\"Error: Invalid primitive operation\" + \" for Invoke no. \" + i)\r\n\r\n\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\treturn shim.Error(\"Error: Invalid primitive operation\" + \" for Invoke no. \" + i)\r\n\t\t}\r\n\r\n\t\tfmt.Println(\"Primitive operation for Invoke no. \" + i + \" : \" + primitive_operation)\r\n\r\n\t\tvar invoke_response pb.Response\r\n\r\n\t\tif primitive_operation == \"invoke_insert_update\" {\r\n\r\n\t\t\tinvoke_response = t.invoke_insert_update(stub, args_to_pass, map_specification)\r\n\r\n\t\t} else if primitive_operation == \"invoke_update_status\" {\r\n\r\n\t\t\tinvoke_response = t.invoke_update_status(stub, args_to_pass, map_specification)\r\n\r\n\t\t} else if primitive_operation == \"invoke_update_status_with_modification_check\" {\r\n\r\n\t\t\tinvoke_response = t.invoke_update_status_with_modification_check(stub, args_to_pass, map_specification)\r\n\r\n\t\t} else if primitive_operation == \"invoke_delete_record\" {\r\n\r\n\t\t\tinvoke_response = t.invoke_delete_record(stub, args_to_pass, map_specification)\r\n\r\n\t\t} else if primitive_operation == \"query_primary_key\" || primitive_operation == \"query_primary_key_history\" || primitive_operation == \"query_update_status\" || primitive_operation == \"query_customer_invoice_disbursed\" || primitive_operation == \"query_customer_invoice_asn_disbursed\" {\r\n\r\n\t\t\tfmt.Println(\"Error: Query function received as Invoke no. \" + i)\r\n\r\n\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\treturn shim.Error(\"Error: Query function received as Invoke no. \" + i)\r\n\r\n\t\t} else if primitive_operation == \"invoke_delete_all_records\" {\r\n\r\n\t\t\tfmt.Println(\"Error: Delete all invoke call not allowed but received as Invoke no. \" + i)\r\n\r\n\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\treturn shim.Error(\"Error: Delete all invoke call not allowed but received as Invoke no. \" + i)\r\n\r\n\t\t} else {\r\n\r\n\t\t\tfmt.Println(\"Error: Invalid function \" + function_name + \" for Invoke no. \" + i)\r\n\r\n\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\treturn shim.Error(\"Error: Invalid function \" + function_name + \" for Invoke no. \" + i)\r\n\t\t}\r\n\r\n\t\tif invoke_response.Status != shim.OK {\r\n\r\n\t\t\tfmt.Println(\"Error in executing Invoke no. \" + i + \" : \" + string(invoke_response.Message))\r\n\r\n\t\t\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\t\t\treturn shim.Error(\"Error in executing Invoke no. \" + i + \" : \" + string(invoke_response.Message))\r\n\r\n\t\t} else if i_number == 0 {\r\n\r\n\t\t\tsuccess_string = success_string + string(invoke_response.Message)\r\n\t\t} else {\r\n\r\n\t\t\tsuccess_string = success_string + \",\" + string(invoke_response.Message)\r\n\t\t}\r\n\r\n\t\tfmt.Println(\"Response of executing Invoke no. \" + i + \" : \" + string(invoke_response.Message))\r\n\r\n\t}\r\n\r\n\tsuccess_string = success_string + \"]\"\r\n\r\n\tfmt.Println(\"***********Exiting invoke_bulk***********\")\r\n\r\n\treturn shim.Success([]byte(success_string))\r\n\r\n}", "func updateBatch(db *IndexerDb, updateQuery string, data [][]interface{}) error {\n\tdb.accountingLock.Lock()\n\tdefer db.accountingLock.Unlock()\n\n\ttx, err := db.db.Begin()\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer tx.Rollback() // ignored if .Commit() first\n\n\tupdate, err := tx.Prepare(updateQuery)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error preparing update query: %v\", err)\n\t}\n\tdefer update.Close()\n\n\tfor _, txpr := range data {\n\t\t_, err = update.Exec(txpr...)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"problem updating row (%v): %v\", txpr, err)\n\t\t}\n\t}\n\n\treturn tx.Commit()\n}", "func (p *Processor) ExecuteTasks() error {\n\treturn nil\n}", "func (bcb *BouncerCreateBulk) ExecX(ctx context.Context) {\n\tif err := bcb.Exec(ctx); err != nil {\n\t\tpanic(err)\n\t}\n}", "func Execute() {\n\t// Load config\n\tloadConfig()\n\n\t// Init Redis Client\n\tinitRedisClient()\n\n\t// Synchronize composer.phar\n\tgo composerPhar(\"composerPhar\", 1)\n\n\t// Synchronize packages.json\n\tgo packagesJsonFile(\"PackagesJson\", 1)\n\n\t// Update status\n\tgo status(\"Status\", 1)\n\n\tWg.Add(1)\n\n\tfor i := 0; i < 12; i++ {\n\t\tgo providers(\"Provider\", i)\n\t}\n\n\tfor i := 0; i < 30; i++ {\n\t\tgo packages(\"Packages\", i)\n\t}\n\n\tfor i := 0; i < 50; i++ {\n\t\tgo dists(\"Dists\", i)\n\t}\n\n\tfor i := 0; i < 1; i++ {\n\t\tgo distsRetry(403, i)\n\t}\n\n\tfor i := 0; i < 1; i++ {\n\t\tgo distsRetry(500, i)\n\t}\n\n\tfor i := 0; i < 1; i++ {\n\t\tgo distsRetry(502, i)\n\t}\n\n}", "func (s *API) SendMessageBatch(w http.ResponseWriter, req *http.Request) {\n\tlog.Debug(\"SendMessageBatch\")\n\tw.WriteHeader(http.StatusNotImplemented)\n}", "func auroraWritebackBatch(\n\tch chan []*CoPathPair, \n\tquit chan bool, \n\tdb *angelaDB, \n\tprefix string, \n\tepochNumber uint64, \n\tbatchWriteSize int,\n\ttotalNumTransactions int) {\n\n\tbufferList := make([]*CoPathPair, 0)\n\tcounter := 0\n for {\n \tselect {\n \tcase delta := <-ch:\n \t\t// write back to aurora of the changelist from the channel\n \t\t// fmt.Println(\"Changelist\")\n \t\t// fmt.Println(delta)\n \t\tbufferList = append(bufferList, delta...)\n \t\tcounter += 1\n \t\tif counter % batchWriteSize == 0 || counter == totalNumTransactions {\n \t\t\tnumRowsAffected, err := db.insertChangeList(prefix, bufferList, epochNumber)\n\t \t\tif err != nil {\n\t \t\t\tfmt.Println(err)\n\t \t\t}\n\t \t\tfmt.Println(\"Printing the number of rows affected\", numRowsAffected)\n\t \t\tbufferList = nil\n \t\t}\n \t\tif counter == totalNumTransactions {\n \t\t\tdb.Close()\n \t\t}\n \tcase <-quit:\n \t\t// if len(bufferList) > 0 {\n \t\t// \tnumRowsAffected, err := db.insertChangeList(bufferList, epochNumber)\n\t \t// \tif err != nil {\n\t \t// \t\tfmt.Println(err)\n\t \t// \t}\n\t \t// \tfmt.Println(\"Printing the number of rows affected\", numRowsAffected)\t\t\n \t\t// }\n \t\tfmt.Println(\"Done Writing\")\n \t\treturn\n \t}\n }\n}", "func (as ActionList) unsafeExecute(lg *zap.Logger, tx backend.UnsafeReadWriter) error {\n\tvar revertActions = make(ActionList, 0, len(as))\n\tfor _, a := range as {\n\t\trevert, err := a.unsafeDo(tx)\n\n\t\tif err != nil {\n\t\t\trevertActions.unsafeExecuteInReversedOrder(lg, tx)\n\t\t\treturn err\n\t\t}\n\t\trevertActions = append(revertActions, revert)\n\t}\n\treturn nil\n}", "func RunMultipleCommands(commands []entity.Command) error {\n\tvar dir string\n\tfor _, command := range commands {\n\t\tlookPath, err := exec.LookPath(command.Name)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"installing %s is in your future\", command.Name)\n\t\t\treturn err\n\t\t}\n\t\tcmd := exec.Command(lookPath, command.Args...)\n\t\tif strings.Contains(command.Name, \"cd\") {\n\t\t\tdir = command.Args[0]\n\t\t} else {\n\t\t\tcmd.Dir = dir\n\t\t\tif err := cmd.Run(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tvar out bytes.Buffer\n\t\t\tcmd.Stdout = &out\n\t\t\tlog.Printf(\"command: %s, %q\\r\\n %s\", command.Name, command.Args, out.String())\n\t\t}\n\t}\n\treturn nil\n}", "func (icb *ItemCreateBulk) ExecX(ctx context.Context) {\n\tif err := icb.Exec(ctx); err != nil {\n\t\tpanic(err)\n\t}\n}", "func SafeExpectBatch(vmi *v1.VirtualMachineInstance, expected []expect.Batcher, wait int) error {\n\t_, err := SafeExpectBatchWithResponse(vmi, expected, wait)\n\treturn err\n}", "func (s service) BatchDelete(\n\tctx context.Context,\n\tids []string,\n) (data BatchInfo, err error) {\n\terr = s.svc.ResourceOp(\n\t\tctx,\n\t\thttp.MethodDelete,\n\t\tbatchDeletePathFormat,\n\t\tbatchParams(ids),\n\t\t&data,\n\t)\n\treturn\n}", "func (scb *SessionCreateBulk) Exec(ctx context.Context) error {\n\t_, err := scb.Save(ctx)\n\treturn err\n}", "func (c *Collection) writeBatch(b *Batch) (err error) {\n\terr = c.putSendToWriteAndWaitForResponse(b.tr)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn c.putLoopForIndexes(b.tr)\n}", "func (bcb *BadgeCreateBulk) Exec(ctx context.Context) error {\n\t_, err := bcb.Save(ctx)\n\treturn err\n}", "func (stmt *Statement) Run(params ...interface{}) (res *Result, err os.Error) {\n defer stmt.db.unlockIfError(&err)\n defer catchOsError(&err)\n stmt.db.lock()\n\n if stmt.db.conn == nil {\n return nil, NOT_CONN_ERROR\n }\n if stmt.db.unreaded_rows {\n return nil, UNREADED_ROWS_ERROR\n }\n\n // Bind parameters if any\n if len(params) != 0 {\n stmt.BindParams(params...)\n }\n\n // Send EXEC command with binded parameters\n stmt.sendCmdExec()\n // Get response\n res = stmt.db.getResponse(true)\n res.binary = true\n return\n}", "func (a createBulkCharityMrysInteractor) Execute(ctx context.Context, input CreateBulkCharityMrysInput) ([]CreateBulkCharityMrysOutput, error) {\n\tctx, cancel := context.WithTimeout(ctx, a.ctxTimeout)\n\tdefer cancel()\n\n\tdata := []domain.CharityMrys{}\n\tfor i := input.MonthFrom; i <= input.MonthTo; i++ {\n\t\tvar model = domain.NewCharityMrys(\n\t\t\tdomain.NewUUID(),\n\t\t\tinput.Name,\n\t\t\tdomain.Money(input.Amount),\n\t\t\ti,\n\t\t\tinput.Year,\n\t\t\tinput.Description,\n\t\t\tinput.Branch,\n\t\t\ttime.Now(),\n\t\t)\n\t\tmodel.UserID = a.auth.Id\n\t\tmodel.Username = a.auth.Username\n\t\tdata = append(data, model)\n\t}\n\n\tresult, err := a.repo.CreateBulk(ctx, data)\n\tif err != nil {\n\t\treturn a.presenter.Output([]domain.CharityMrys{}), err\n\t}\n\n\treturn a.presenter.Output(result), nil\n}", "func (_Trebuchet *TrebuchetSession) Execute(_data [][]byte) (*types.Transaction, error) {\n\treturn _Trebuchet.Contract.Execute(&_Trebuchet.TransactOpts, _data)\n}", "func ExpectBatch(vmi *v1.VirtualMachineInstance, expected []expect.Batcher, timeout time.Duration) error {\n\tvirtClient := kubevirt.Client()\n\n\texpecter, _, err := NewExpecter(virtClient, vmi, consoleConnectionTimeout)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer expecter.Close()\n\n\tresp, err := expecter.ExpectBatch(expected, timeout)\n\tif err != nil {\n\t\tlog.DefaultLogger().Object(vmi).Infof(\"%v\", resp)\n\t}\n\treturn err\n}", "func (e *sqlExecutor) Execute(ctx context.Context, c *sqlconf.Config) error {\n\tif err := c.Validate(); err != nil {\n\t\treturn err\n\t}\n\tdb, err := c.DB()\n\tif err != nil {\n\t\treturn nil\n\t}\n\tif err := setupDB(db, c); err != nil {\n\t\treturn err\n\t}\n\tif c.Concurrent {\n\t\treturn e.execParallel(ctx, db, c)\n\t}\n\tfor _, payload := range c.Payloads {\n\t\t_, err := db.ExecContext(ctx, payload.Exec)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (ocb *OAuth2ClientCreateBulk) ExecX(ctx context.Context) {\n\tif err := ocb.Exec(ctx); err != nil {\n\t\tpanic(err)\n\t}\n}", "func (rcb *RentalCreateBulk) Exec(ctx context.Context) error {\n\t_, err := rcb.Save(ctx)\n\treturn err\n}", "func BatchRPLS(ctx iris.Context) {\n\tvar req models.RPLSBatch\n\tif err := ctx.ReadJSON(&req); err != nil {\n\t\tctx.StatusCode(http.StatusInternalServerError)\n\t\tctx.JSON(jsonError{\"Batch RPLS, décodage : \" + err.Error()})\n\t\treturn\n\t}\n\tdb := ctx.Values().Get(\"db\").(*sql.DB)\n\tif err := req.Save(db); err != nil {\n\t\tctx.StatusCode(http.StatusInternalServerError)\n\t\tctx.JSON(jsonError{\"Batch RPLS, requête : \" + err.Error()})\n\t\treturn\n\t}\n\tctx.StatusCode(http.StatusOK)\n\tctx.JSON(jsonMessage{\"Batch RPLS importé\"})\n}", "func BufferedExec(name string, args ...string) (*BufferedCmd, error) {\n\tcmd := ExecCommand(name, args...)\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tstderr, err := cmd.StderrPipe()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tstdin, err := cmd.StdinPipe()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := cmd.Start(); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &BufferedCmd{\n\t\tcmd,\n\t\tstdin,\n\t\tbufio.NewReaderSize(stdout, stdoutBufSize),\n\t\tbufio.NewReaderSize(stderr, stdoutBufSize),\n\t}, nil\n}", "func BufferedExec(name string, args ...string) (*BufferedCmd, error) {\n\tcmd := ExecCommand(name, args...)\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tstderr, err := cmd.StderrPipe()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tstdin, err := cmd.StdinPipe()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := cmd.Start(); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &BufferedCmd{\n\t\tcmd,\n\t\tstdin,\n\t\tbufio.NewReaderSize(stdout, stdoutBufSize),\n\t\tbufio.NewReaderSize(stderr, stdoutBufSize),\n\t}, nil\n}", "func (c *Conn) Exec(cmd string, args ...interface{}) error {\n\tfor len(cmd) > 0 {\n\t\ts, err := c.prepare(cmd)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t} else if s.stmt == nil {\n\t\t\t// this happens for a comment or white-space\n\t\t\tcmd = s.tail\n\t\t\tcontinue\n\t\t}\n\t\tvar subargs []interface{}\n\t\tcount := s.BindParameterCount()\n\t\tif len(s.tail) > 0 && len(args) >= count {\n\t\t\tsubargs = args[:count]\n\t\t\targs = args[count:]\n\t\t} else {\n\t\t\tsubargs = args\n\t\t}\n\t\terr = s.Exec(subargs...)\n\t\tif err != nil {\n\t\t\t_ = s.finalize()\n\t\t\treturn err\n\t\t}\n\t\tif err = s.finalize(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcmd = s.tail\n\t}\n\treturn nil\n}", "func (js *JobSession) RunBulkJobs(jt drmaa2interface.JobTemplate, begin, end, step, maxParallel int) (drmaa2interface.ArrayJob, error) {\n\tid, err := js.tracker[0].AddArrayJob(jt, begin, end, step, maxParallel)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn js.GetJobArray(id)\n}", "func (ggcb *GithubGistCreateBulk) ExecX(ctx context.Context) {\n\tif err := ggcb.Exec(ctx); err != nil {\n\t\tpanic(err)\n\t}\n}", "func (ocb *OAuth2ClientCreateBulk) Exec(ctx context.Context) error {\n\t_, err := ocb.Save(ctx)\n\treturn err\n}", "func Run(ctx context.Context, tx pgx.Tx, qs []string) error {\n\tfor _, q := range qs {\n\t\t_, err := tx.Exec(ctx, q)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (d Adapter) Exec(command []string) error {\n\treturn d.componentAdapter.Exec(command)\n}", "func (c *CentralCacheTestImpl) DeleteBatch(key []string) error {\n\treturn nil\n}", "func executeAction(ctx context.Context, binaries *compile.Binaries, args ...string) error {\n\tlocalInquire, err := inquire(ctx, &binaries.Local)\n\tif err != nil {\n\t\treturn err\n\t}\n\tplanInquire, err := inquire(ctx, &binaries.Plan)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmdToExecute := args[0]\n\n\tfor _, cmd := range localInquire {\n\t\tif cmd == cmdToExecute {\n\t\t\treturn executeBinaryAction(ctx, &binaries.Local, args...)\n\t\t}\n\t}\n\n\tfor _, cmd := range planInquire {\n\t\tif cmd == cmdToExecute {\n\t\t\treturn executeBinaryAction(ctx, &binaries.Plan, args...)\n\t\t}\n\t}\n\n\tcombinedOptions := make(map[string]struct{}, 0)\n\tfor _, cmd := range localInquire {\n\t\tcombinedOptions[cmd] = struct{}{}\n\t}\n\tfor _, cmd := range planInquire {\n\t\tcombinedOptions[cmd] = struct{}{}\n\t}\n\n\treturn fmt.Errorf(\"no action available in commds, available options are: %s\", combinedOptions)\n}", "func scanBatchSpecExecutions(rows *sql.Rows, queryErr error) (_ []*btypes.BatchSpecExecution, err error) {\n\tif queryErr != nil {\n\t\treturn nil, queryErr\n\t}\n\tdefer func() { err = basestore.CloseRows(rows, err) }()\n\n\tvar execs []*btypes.BatchSpecExecution\n\tfor rows.Next() {\n\t\texec := &btypes.BatchSpecExecution{}\n\t\tif err := scanBatchSpecExecution(exec, rows); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\texecs = append(execs, exec)\n\t}\n\n\treturn execs, nil\n}", "func scanBatchSpecExecutions(rows *sql.Rows, queryErr error) (_ []*btypes.BatchSpecExecution, err error) {\n\tif queryErr != nil {\n\t\treturn nil, queryErr\n\t}\n\tdefer func() { err = basestore.CloseRows(rows, err) }()\n\n\tvar execs []*btypes.BatchSpecExecution\n\tfor rows.Next() {\n\t\texec := &btypes.BatchSpecExecution{}\n\t\tif err := scanBatchSpecExecution(exec, rows); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\texecs = append(execs, exec)\n\t}\n\n\treturn execs, nil\n}", "func (bcb *BadgeCreateBulk) ExecX(ctx context.Context) {\n\tif err := bcb.Exec(ctx); err != nil {\n\t\tpanic(err)\n\t}\n}" ]
[ "0.7461896", "0.6927233", "0.6790663", "0.66519415", "0.66327494", "0.6507953", "0.6506933", "0.61729884", "0.60851747", "0.60139984", "0.5971583", "0.59487164", "0.59240067", "0.58766514", "0.5826821", "0.58085674", "0.57520205", "0.5663675", "0.5636446", "0.55858546", "0.55740905", "0.5570371", "0.5514922", "0.5514485", "0.54974574", "0.54930013", "0.5486517", "0.5470631", "0.5459015", "0.5442723", "0.54375", "0.54245967", "0.5418383", "0.54146713", "0.53873307", "0.5375804", "0.53402907", "0.5333827", "0.53043693", "0.5300431", "0.53004164", "0.52938724", "0.5293587", "0.5288632", "0.5287328", "0.52784616", "0.5250981", "0.5246434", "0.5228522", "0.52151597", "0.5213911", "0.5210679", "0.5205363", "0.5201774", "0.5201373", "0.5194423", "0.51799804", "0.5167706", "0.5161624", "0.51610094", "0.5160665", "0.5154163", "0.5149669", "0.51488084", "0.51466775", "0.514428", "0.51429784", "0.51403594", "0.5138423", "0.51325697", "0.5090482", "0.50795025", "0.5073512", "0.5072086", "0.5069375", "0.50564", "0.5053731", "0.50533533", "0.5048765", "0.50487095", "0.50261", "0.50243706", "0.5018286", "0.5016138", "0.5011247", "0.500986", "0.5008649", "0.50022906", "0.50022906", "0.50020534", "0.49922866", "0.49905273", "0.498673", "0.49830085", "0.49826872", "0.49724102", "0.4969372", "0.49688518", "0.49688518", "0.496851" ]
0.70663935
1
NewServicesHandler creates a new handler to return all specs.
NewServicesHandler создает новый обработчик для возврата всех спецификаций.
func NewServicesHandler(storage storage.Storage) func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) { specs, err := storage.GetSpecs() if err != nil { http.Error(w, fmt.Sprintf("Error getting the specs from the storage %s", err), http.StatusInternalServerError) return } json, err := json.Marshal(specs) if err != nil { http.Error(w, fmt.Sprintf("Error converting the specs to json %s", err), http.StatusInternalServerError) return } w.Header().Set("Content-Type", "application/json") w.Write(json) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewHandlers() *Handlers {\n\thandlers := new(Handlers)\n\thandlers.services = services.GetServices()\n\n\treturn handlers\n}", "func NewHandler(ctx context.Context, endpoint string) (Handler, error) {\n\tif len(endpoint) == 0 {\n\t\treturn nil, errors.New(\"endpoint is empty\")\n\t}\n\n\t// Get the client\n\tcfg := openapi.NewConfiguration()\n\tapiClient := openapi.NewAPIClient(cfg)\n\tif endpoint != \"localhost/cnwan\" {\n\t\tapiClient.ChangeBasePath(strings.Replace(cfg.BasePath, \"localhost/cnwan\", endpoint, 1))\n\t}\n\n\treturn &servicesHandler{\n\t\tclient: apiClient,\n\t\tmainCtx: ctx,\n\t}, nil\n}", "func NewServiceHandler(r *mux.Router, mw middleware.Middleware, cfg Config) {\n\n\tctx := logger.NewContext(context.Background(), nil)\n\tlog := logger.WithContext(ctx)\n\n\tlog.Infof(\"%s:> init service routes\", logPrefix)\n\n\thandler := &Handler{\n\t\tConfig: cfg,\n\t}\n\n\tr.Handle(\"/namespace/{namespace}/service\", h.Handle(mw.Authenticate(handler.ServiceCreateH))).Methods(http.MethodPost)\n\tr.Handle(\"/namespace/{namespace}/service\", h.Handle(mw.Authenticate(handler.ServiceListH))).Methods(http.MethodGet)\n\tr.Handle(\"/namespace/{namespace}/service/{service}\", h.Handle(mw.Authenticate(handler.ServiceInfoH))).Methods(http.MethodGet)\n\tr.Handle(\"/namespace/{namespace}/service/{service}\", h.Handle(mw.Authenticate(handler.ServiceUpdateH))).Methods(http.MethodPut)\n\tr.Handle(\"/namespace/{namespace}/service/{service}\", h.Handle(mw.Authenticate(handler.ServiceRemoveH))).Methods(http.MethodDelete)\n\tr.Handle(\"/namespace/{namespace}/service/{service}/logs\", h.Handle(mw.Authenticate(handler.ServiceLogsH))).Methods(http.MethodGet)\n}", "func NewHandler(cfg Config) http.Handler {\n\tr := resolver.New(\n\t\tresolver.Config{\n\t\t\tLogger: cfg.Logger,\n\t\t\tReceiverFactory: cfg.ReceiverFactory,\n\t\t},\n\t)\n\tu := &jobs{cfg.Logger, r}\n\trouter := mux.NewRouter()\n\trouter.Use(\n\t\tfunc(next http.Handler) http.Handler {\n\t\t\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t\t\tctx := newServicesContext(r.Context())\n\t\t\t\tnext.ServeHTTP(w, r.WithContext(ctx))\n\t\t\t})\n\t\t})\n\troutes := []struct {\n\t\tname string\n\t\thandler http.HandlerFunc\n\t}{\n\t\t{\"sync_services\", u.syncServices},\n\t\t{\"gc\", u.garbageCollector},\n\t}\n\tfor _, route := range routes {\n\t\trouter.Path(\"/\" + route.name).\n\t\t\tMethods(http.MethodPost).\n\t\t\tHandlerFunc(route.handler).\n\t\t\tName(route.name)\n\t}\n\treturn router\n}", "func (s *Server) HandleGetServices() http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\n\t\tdefer utils.CloseTheCloser(r.Body)\n\n\t\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\t\tdefer cancel()\n\n\t\t// Verify token\n\t\t_, err := s.auth.VerifyToken(utils.GetToken(r))\n\t\tif err != nil {\n\t\t\t_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), \"Failed to apply service\", err, nil)\n\t\t\t_ = helpers.Response.SendErrorResponse(ctx, w, http.StatusUnauthorized, err)\n\t\t\treturn\n\t\t}\n\n\t\tvars := mux.Vars(r)\n\t\tprojectID := vars[\"project\"]\n\t\tserviceID, serviceIDExists := r.URL.Query()[\"serviceId\"]\n\t\tversion, versionExists := r.URL.Query()[\"version\"]\n\n\t\tservices, err := s.driver.GetServices(ctx, projectID)\n\t\tif err != nil {\n\t\t\t_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), \"Failed to apply service\", err, nil)\n\t\t\t_ = helpers.Response.SendErrorResponse(ctx, w, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\n\t\tvar result []*model.Service\n\t\tif serviceIDExists && versionExists {\n\t\t\tfor _, val := range services {\n\t\t\t\tif val.ProjectID == projectID && val.ID == serviceID[0] && val.Version == version[0] {\n\t\t\t\t\tresult = append(result, val)\n\t\t\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t\t\t\tw.WriteHeader(http.StatusOK)\n\t\t\t\t\t_ = json.NewEncoder(w).Encode(model.Response{Result: result})\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\t_ = json.NewEncoder(w).Encode(map[string]string{\"error\": fmt.Sprintf(\"serviceID(%s) or version(%s) not present in state\", serviceID[0], version[0])})\n\t\t\treturn\n\t\t}\n\n\t\tif serviceIDExists && !versionExists {\n\t\t\tfor _, val := range services {\n\t\t\t\tif val.ID == serviceID[0] {\n\t\t\t\t\tresult = append(result, val)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t\tw.WriteHeader(http.StatusOK)\n\t\t\t_ = json.NewEncoder(w).Encode(model.Response{Result: result})\n\t\t\treturn\n\t\t}\n\n\t\tresult = services\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(http.StatusOK)\n\t\t_ = json.NewEncoder(w).Encode(model.Response{Result: result})\n\t}\n}", "func NewHandler(srv Service) http.Handler {\n\th := handlers{srv}\n\tr := chi.NewRouter()\n\tr.Get(\"/\", h.handleGetDemoSample)\n\tr.Get(\"/error_demo\", h.handleGetErrorDemoSample)\n\treturn r\n}", "func NewHandler(service Service) Handler {\n\treturn Handler{service: service}\n}", "func NewHandler(transporteService domain.TransporteService) http.Handler {\n\thandler := &handler{\n\t\ttransporteService: transporteService,\n\t}\n\n\tgin.SetMode(gin.ReleaseMode)\n\n\trouter := gin.New()\n\trouter.Use(handler.recovery())\n\trouter.GET(\"/\", func(c *gin.Context) {\n\t\tc.HTML(http.StatusOK, \"index.html\", gin.H{\n\t\t\t\"title\": \"Home Page\",\n\t\t})\n\t})\n\n\tv1 := router.Group(\"/v1\")\n\n\tv1.GET(\"/calcularTransporte\", handler.PostCalcularTransporte)\n\tv1.GET(\"/veiculos\", handler.GetVeiculos)\n\n\treturn router\n}", "func NewService() http.Handler {\n\th := http.NewServeMux()\n\th.HandleFunc(\"/ip\", IP)\n\th.HandleFunc(\"/headers\", Headers)\n\treturn h\n}", "func MakeHandler(s Service, logger kitlog.Logger) http.Handler {\n opts := []kithttp.ServerOption{\n kithttp.ServerErrorLogger(logger),\n kithttp.ServerErrorEncoder(encodeError),\n }\n\n\te := MakeServerEndpoints(s)\n\n tickersHandler := kithttp.NewServer(\n e.TickersEndpoint,\n decodeTickerRequest,\n kithttp.EncodeJSONResponse,\n opts...,\n )\n\n r := mux.NewRouter()\n\n r.Handle(\"/ex/v1/tickers/{base}\", tickersHandler).Methods(\"GET\")\n /*\n getTickersHandler := kithttp.NewServer(\n makeGetTickersEndpoint(es),\n decodeEmptyRequest,\n kithttp.EncodeJSONResponse,\n opts...,\n )\n */\n\n //r.Handle(\"/pub/ex/v1/getTicker/{pair}\", getTickerHandler).Methods(\"GET\")\n //r.Handle(\"/pub/ex/v1/getTickers\", getTickersHandler).Methods(\"GET\")\n\n\treturn r\n}", "func New(s *service.Service) http.Handler {\n\th := &handler{s}\n\n\tapi := chi.NewRouter()\n\n\tapi.Get(\"/\", root)\n\tapi.Post(\"/login\", h.login)\n\tapi.Post(\"/register\", h.registerPatient)\n\n\tapiWithCors := cors.Default().Handler(api)\n\treturn apiWithCors\n}", "func New(service storage.Service) http.Handler {\n\tr := mux.NewRouter()\n\n\th := handler{service}\n\n\tr.HandleFunc(\"/health\", health)\n\tr.HandleFunc(\"/insfile\", responseJSONWithModules(h.insfileWithModules)).Methods(http.MethodPost)\n\tr.HandleFunc(\"/insfile/text\", responseTextWithModules(h.insfileWithModules)).Methods(http.MethodPost)\n\tr.HandleFunc(\"/insfile/traverse\", responseJSON(h.insfile)).Methods(http.MethodPost)\n\tr.HandleFunc(\"/insfile/traverse/text\", responseText(h.insfile)).Methods(http.MethodPost)\n\n\treturn r\n}", "func CreateHandler(svc ServiceModel) *http.Server {\n\treturn http.NewServer(\n\t\tmakeCreateEndpoint(svc),\n\t\tdecodeCreateRequest,\n\t\thttp.EncodeJSONResponse,\n\t)\n}", "func NewHandlers(logger logging.Logging, db *pg.DB, authServerArg *server.Server) *Handlers {\n\tproductCategoryRepository = NewRepository(db)\n\tproductCategoryService = NewService(productCategoryRepository)\n\tproductCategoryHandlerLogging = logger\n\tauthServer = authServerArg\n\n\treturn &Handlers{}\n}", "func NewHandler(s service) *chi.Mux {\n\tr := chi.NewRouter()\n\n\tcors := cors.New(cors.Options{\n\t\t// AllowedOrigins: []string{\"https://foo.com\"}, // Use this to allow specific origin hosts\n\t\tAllowedOrigins: []string{\"*\"},\n\t\t// AllowOriginFunc: func(r *http.Request, origin string) bool { return true },\n\t\tAllowedMethods: []string{\"GET\", \"POST\", \"OPTIONS\"},\n\t\tAllowedHeaders: []string{\"Accept\", \"Authorization\", \"Content-Type\", \"X-CSRF-Token\"},\n\t\tExposedHeaders: []string{\"Link\"},\n\t\tAllowCredentials: true,\n\t\tMaxAge: 300, // Maximum value not ignored by any of major browsers\n\t})\n\tr.Use(cors.Handler)\n\n\t// Public routes\n\tr.Group(func(r chi.Router) {\n\t\tr.Get(\"/list\", getPluginListHandler(s))\n\t\tr.Get(\"/{plugin}/{format}\", getFeedHandler(s))\n\t})\n\n\tr.Group(func(r chi.Router) {\n\t\tr.Use(s.authenticator)\n\t\tr.Post(\"/{plugin}/refresh\", refreshFeedHandler(s))\n\t})\n\n\treturn r\n}", "func MakeHandler(svc manager.Service) http.Handler {\n\topts := []kithttp.ServerOption{\n\t\tkithttp.ServerErrorEncoder(encodeError),\n\t}\n\n\tregistration := kithttp.NewServer(\n\t\tregistrationEndpoint(svc),\n\t\tdecodeCredentials,\n\t\tencodeResponse,\n\t\topts...,\n\t)\n\n\tlogin := kithttp.NewServer(\n\t\tloginEndpoint(svc),\n\t\tdecodeCredentials,\n\t\tencodeResponse,\n\t\topts...,\n\t)\n\n\taddClient := kithttp.NewServer(\n\t\taddClientEndpoint(svc),\n\t\tdecodeAddClient,\n\t\tencodeResponse,\n\t\topts...,\n\t)\n\n\tviewClient := kithttp.NewServer(\n\t\tviewClientEndpoint(svc),\n\t\tdecodeViewClient,\n\t\tencodeResponse,\n\t\topts...,\n\t)\n\n\tremoveClient := kithttp.NewServer(\n\t\tremoveClientEndpoint(svc),\n\t\tdecodeViewClient,\n\t\tencodeResponse,\n\t\topts...,\n\t)\n\n\tr := bone.New()\n\n\tr.Post(\"/users\", registration)\n\tr.Post(\"/tokens\", login)\n\tr.Post(\"/clients\", addClient)\n\tr.Get(\"/clients/:id\", viewClient)\n\tr.Delete(\"/clients/:id\", removeClient)\n\tr.Handle(\"/metrics\", promhttp.Handler())\n\n\treturn r\n}", "func NewHandler(service service.Interface) *Handler {\n\treturn &Handler{service: service}\n}", "func newService(serviceName string) *Service {\n\treturn &Service{\n\t\tpluginDir: serverless.PluginDir,\n\t\tname: serviceName,\n\t\tinterf: nil,\n\t}\n}", "func NewService(opts ...Option) Service {\n\toptions := newOptions(opts...)\n\n\tm := chi.NewMux()\n\tm.Use(options.Middleware...)\n\n\tm.Use(\n\t\totelchi.Middleware(\n\t\t\t\"thumbnails\",\n\t\t\totelchi.WithChiRoutes(m),\n\t\t\totelchi.WithTracerProvider(options.TraceProvider),\n\t\t\totelchi.WithPropagators(tracing.GetPropagator()),\n\t\t),\n\t)\n\n\tlogger := options.Logger\n\tresolutions, err := thumbnail.ParseResolutions(options.Config.Thumbnail.Resolutions)\n\tif err != nil {\n\t\tlogger.Fatal().Err(err).Msg(\"resolutions not configured correctly\")\n\t}\n\tsvc := Thumbnails{\n\t\tconfig: options.Config,\n\t\tmux: m,\n\t\tlogger: options.Logger,\n\t\tmanager: thumbnail.NewSimpleManager(\n\t\t\tresolutions,\n\t\t\toptions.ThumbnailStorage,\n\t\t\tlogger,\n\t\t),\n\t}\n\n\tm.Route(options.Config.HTTP.Root, func(r chi.Router) {\n\t\tr.Use(svc.TransferTokenValidator)\n\t\tr.Get(\"/data\", svc.GetThumbnail)\n\t})\n\n\t_ = chi.Walk(m, func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error {\n\t\toptions.Logger.Debug().Str(\"method\", method).Str(\"route\", route).Int(\"middlewares\", len(middlewares)).Msg(\"serving endpoint\")\n\t\treturn nil\n\t})\n\n\treturn svc\n}", "func New(h []IHandler) *Handler {\n\treturn &Handler{handler: h}\n}", "func MakeHandler(svc notifiers.Service, tracer opentracing.Tracer, logger logger.Logger) http.Handler {\n\topts := []kithttp.ServerOption{\n\t\tkithttp.ServerErrorEncoder(apiutil.LoggingErrorEncoder(logger, encodeError)),\n\t}\n\n\tmux := bone.New()\n\n\tmux.Post(\"/subscriptions\", kithttp.NewServer(\n\t\tkitot.TraceServer(tracer, \"create_subscription\")(createSubscriptionEndpoint(svc)),\n\t\tdecodeCreate,\n\t\tencodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Get(\"/subscriptions/:id\", kithttp.NewServer(\n\t\tkitot.TraceServer(tracer, \"view_subscription\")(viewSubscriptionEndpint(svc)),\n\t\tdecodeSubscription,\n\t\tencodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Get(\"/subscriptions\", kithttp.NewServer(\n\t\tkitot.TraceServer(tracer, \"list_subscriptions\")(listSubscriptionsEndpoint(svc)),\n\t\tdecodeList,\n\t\tencodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Delete(\"/subscriptions/:id\", kithttp.NewServer(\n\t\tkitot.TraceServer(tracer, \"delete_subscription\")(deleteSubscriptionEndpint(svc)),\n\t\tdecodeSubscription,\n\t\tencodeResponse,\n\t\topts...,\n\t))\n\n\tmux.GetFunc(\"/health\", mainflux.Health(\"notifier\"))\n\tmux.Handle(\"/metrics\", promhttp.Handler())\n\n\treturn mux\n}", "func NewServices(\n\tconfig Configuration,\n\tstore Store,\n\taccess Access,\n\tbrowser BrowserDetector) *Services {\n\tvar s Services\n\ts.config = config\n\ts.store = store\n\ts.access = access\n\ts.browser = browser\n\treturn &s\n}", "func New(u IUserSvc, s IShopSvc) *Handler {\n\treturn &Handler{\n\t\tusrSvc: u,\n\t\tshopSvc: s,\n\t}\n}", "func NewHandler(ctx context.Context, rsService store.RulesetService, cfg Config) http.Handler {\n\ts := service{\n\t\trulesets: rsService,\n\t}\n\n\tvar logger zerolog.Logger\n\n\tif cfg.Logger != nil {\n\t\tlogger = *cfg.Logger\n\t} else {\n\t\tlogger = zerolog.New(os.Stderr).With().Timestamp().Logger()\n\t}\n\n\tif cfg.Timeout == 0 {\n\t\tcfg.Timeout = 5 * time.Second\n\t}\n\n\tif cfg.WatchTimeout == 0 {\n\t\tcfg.WatchTimeout = 30 * time.Second\n\t}\n\n\trs := rulesetService{\n\t\tservice: &s,\n\t\ttimeout: cfg.Timeout,\n\t\twatchTimeout: cfg.WatchTimeout,\n\t}\n\n\t// router\n\tmux := http.NewServeMux()\n\tmux.Handle(\"/rulesets/\", &rs)\n\n\t// middlewares\n\tchain := []func(http.Handler) http.Handler{\n\t\thlog.NewHandler(logger),\n\t\thlog.AccessHandler(func(r *http.Request, status, size int, duration time.Duration) {\n\t\t\thlog.FromRequest(r).Info().\n\t\t\t\tStr(\"method\", r.Method).\n\t\t\t\tStr(\"url\", r.URL.String()).\n\t\t\t\tInt(\"status\", status).\n\t\t\t\tInt(\"size\", size).\n\t\t\t\tDur(\"duration\", duration).\n\t\t\t\tMsg(\"request received\")\n\t\t}),\n\t\thlog.RemoteAddrHandler(\"ip\"),\n\t\thlog.UserAgentHandler(\"user_agent\"),\n\t\thlog.RefererHandler(\"referer\"),\n\t\tfunc(http.Handler) http.Handler {\n\t\t\treturn mux\n\t\t},\n\t}\n\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t// playing the middleware chain\n\t\tvar cur http.Handler\n\t\tfor i := len(chain) - 1; i >= 0; i-- {\n\t\t\tcur = chain[i](cur)\n\t\t}\n\n\t\t// serving the request\n\t\tcur.ServeHTTP(w, r.WithContext(ctx))\n\t})\n}", "func NewHandler(_ context.Context, svr *server.Server) (http.Handler, apiutil.APIServiceGroup, error) {\n\tautoScalingHandler := http.NewServeMux()\n\trd := render.New(render.Options{\n\t\tIndentJSON: true,\n\t})\n\tautoScalingHandler.Handle(autoScalingPrefix, negroni.New(\n\t\tserverapi.NewRedirector(svr),\n\t\tnegroni.Wrap(NewHTTPHandler(svr, rd))),\n\t)\n\treturn autoScalingHandler, autoscalingServiceGroup, nil\n}", "func NewHandler(cfg config.ServiceConfig,\n\trouter *mux.Router,\n\tregistry *prometheus.Registry) {\n\thandler := Handler{\n\t\tcfg: cfg,\n\t\tregistry: registry,\n\t}\n\n\thandler.routesBuilder(router)\n}", "func MakeHandler(service Service, logger kitlog.Logger, ml machineLearning.Service) http.Handler {\n\topts := gokit.GetServerOpts(logger, ml)\n\n\talertHandler := kithttp.NewServer(makeAlertEndpoint(service), gokit.DecodeString, gokit.EncodeResponse, opts...)\n\timageAlertHandler := kithttp.NewServer(makeImageAlertEndpoint(service), gokit.DecodeFromBase64, gokit.EncodeResponse, opts...)\n\n\theartbeatAlertHandler := kithttp.NewServer(makeHeartbeatMessageEncpoint(service), gokit.DecodeString, gokit.EncodeResponse, opts...)\n\theartbeatImageHandler := kithttp.NewServer(makeImageHeartbeatEndpoint(service), gokit.DecodeFromBase64, gokit.EncodeResponse, opts...)\n\n\tbusienssAlertHandler := kithttp.NewServer(makeBusinessAlertEndpoint(service), gokit.DecodeString, gokit.EncodeResponse, opts...)\n\n\talertErrorHandler := kithttp.NewServer(makeAlertErrorHandler(service), gokit.DecodeString, gokit.EncodeResponse, opts...)\n\n\tr := mux.NewRouter()\n\n\tr.Handle(\"/alert/\", alertHandler).Methods(\"POST\")\n\tr.Handle(\"/alert/image\", imageAlertHandler).Methods(\"POST\")\n\n\tr.Handle(\"/alert/heartbeat\", heartbeatAlertHandler).Methods(\"POST\")\n\tr.Handle(\"/alert/heartbeat/image\", heartbeatImageHandler).Methods(\"POST\")\n\n\tr.Handle(\"/alert/error\", alertErrorHandler).Methods(\"POST\")\n\n\tr.Handle(\"/alert/business\", busienssAlertHandler).Methods(\"POST\")\n\n\treturn r\n}", "func NewHandler(service *Service) *Handler {\n\treturn &Handler{\n\t\tservice: service,\n\t}\n}", "func New(middleware []Middleware) DealService {\n\tvar svc DealService = NewBasicDealService()\n\tfor _, m := range middleware {\n\t\tsvc = m(svc)\n\t}\n\treturn svc\n}", "func Newhandler(service *comment.Service) *Handler {\n\treturn &Handler{\n\t\tService: service,\n\t}\n}", "func createServiceHandler(event *api.Event) error {\n\tlogdog.Infof(\"create service handler\")\n\topts := workerOptions.DeepCopy()\n\tworker, err := CloudController.Provision(string(event.EventID), opts)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = worker.Do()\n\tif err != nil {\n\t\tlogdog.Error(\"run worker err\", logdog.Fields{\"err\": err})\n\t\treturn err\n\t}\n\n\t// set worker info to event\n\tevent.Worker = worker.GetWorkerInfo()\n\tSaveEventToEtcd(event)\n\tgo CheckWorkerTimeout(event)\n\n\treturn nil\n}", "func New(ctx context.Context, profileEndpoint, projectEndpoint, assessmentEndpoint, joblistingEndpoint string) (http.Handler, error) {\n\tmux := runtime.NewServeMux()\n\topts := []grpc.DialOption{grpc.WithInsecure()}\n\terr := profilegw.RegisterProfileServiceHandlerFromEndpoint(ctx, mux, profileEndpoint, opts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = projectgw.RegisterProjectServiceHandlerFromEndpoint(ctx, mux, projectEndpoint, opts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = joblistinggw.RegisterJoblistingServiceHandlerFromEndpoint(ctx, mux, joblistingEndpoint, opts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = assessmentgw.RegisterAssessmentServiceHandlerFromEndpoint(ctx, mux, assessmentEndpoint, opts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn mux, nil\n}", "func NewHandler(\n\tcustomerService objects.CustomerService,\n\tbookService objects.BookService,\n) *Handler {\n\th := &Handler{\n\t\tcustomerService: customerService,\n\t\tbookService: bookService,\n\t}\n\treturn h\n}", "func NewHandlers(proxy types.ProxyComponent) *Handlers {\n\treturn &Handlers{\n\t\tproxy: proxy,\n\t}\n}", "func MakeHandler(bs Service, logger kitlog.Logger) http.Handler {\n\topts := []kithttp.ServerOption{\n\t\tkithttp.ServerErrorLogger(logger),\n\t\tkithttp.ServerErrorEncoder(encodeError),\n\t}\n\n\tgetBaseDataHandler := kithttp.NewServer(\n\t\tmakeGetBaseDataEndpoint(bs),\n\t\tdecodeGetBaseDataRequest,\n\t\tencodeResponse,\n\t\topts...,\n\t)\n\n\taddBaseDataHandler := kithttp.NewServer(\n\t\tmakePostBaseDataEndpoint(bs),\n\t\tdecodePostBaseDataRequest,\n\t\tencodeResponse,\n\t\topts...,\n\t)\n\n\tgetAllBaseDataHandler := kithttp.NewServer(\n\t\tmakeGetAllBaseDataEndpoint(bs),\n\t\tdecodeGetAllBaseDataRequest,\n\t\tencodeResponse,\n\t\topts...,\n\t)\n\n\tupdateMultiBaseDataHandler := kithttp.NewServer(\n\t\tmakePutMultiBaseDataEndpoint(bs),\n\t\tdecodePutMultiBaseDataRequest,\n\t\tencodeResponse,\n\t\topts...,\n\t)\n\n\tdeleteMultiBaseDataHandler := kithttp.NewServer(\n\t\tmakeDeleteMultiBaseDataEndpoint(bs),\n\t\tdecodeDeleteMultiBaseDataRequest,\n\t\tencodeResponse,\n\t\topts...,\n\t)\n\n\tdeleteMultiLabelHandler := kithttp.NewServer(\n\t\tmakeDeleteMultiLabelEndpoint(bs),\n\t\tdecodeDeleteMultiLabelRequest,\n\t\tencodeResponse,\n\t\topts...,\n\t)\n\n\tr := mux.NewRouter()\n\n\tr.Handle(\"/baseing/v1/data/{id}\", getBaseDataHandler).Methods(\"GET\")\n\tr.Handle(\"/baseing/v1/data\", getAllBaseDataHandler).Methods(\"GET\")\n\tr.Handle(\"/baseing/v1/data\", addBaseDataHandler).Methods(\"POST\")\n\tr.Handle(\"/baseing/v1/data\", updateMultiBaseDataHandler).Methods(\"PUT\")\n\tr.Handle(\"/baseing/v1/data\", deleteMultiBaseDataHandler).Methods(\"DELETE\")\n\tr.Handle(\"/baseing/v1/data/label\", deleteMultiLabelHandler).Methods(\"DELETE\")\n\treturn r\n}", "func New(logger log.Logger, db store.DriversStore) http.Handler {\n\tvar (\n\t\tsvc = service.NewDriversService(db)\n\t\toptions = []httptransport.ServerOption{\n\t\t\thttptransport.ServerErrorEncoder(encodeError),\n\t\t}\n\t)\n\n\trouter := mux.NewRouter().PathPrefix(\"/api/\").Subrouter()\n\trouter.Methods(\"POST\").Path(\"/import\").Handler(httptransport.NewServer(\n\t\tlogRecoverMiddleware(logger)(service.MakeDriversImportEndpoint(svc)),\n\t\tservice.DecodeDriversImportRequest,\n\t\tencodeResponse,\n\t\toptions...,\n\t))\n\trouter.Methods(\"GET\").Path(\"/driver/{id}\").Handler(httptransport.NewServer(\n\t\tlogRecoverMiddleware(logger)(service.MakeDriversGetByIDEndpoint(svc)),\n\t\tservice.DecodeDriversGetByIDRequest,\n\t\tencodeResponse,\n\t\toptions...,\n\t))\n\trouter.NotFoundHandler = notFoundHandler{}\n\trouter.MethodNotAllowedHandler = methodNotAllowedHandler{}\n\n\thandler := http.Handler(router)\n\thandler = &requestIDMiddleware{router}\n\n\treturn handler\n}", "func newHTTPHandler(c ServiceController, k8sStorage ServiceStorage) *httpHandler {\n\treturn &httpHandler{\n\t\tcontroller: c,\n\t\tk8sStorage: k8sStorage,\n\t}\n}", "func New(middleware []Middleware, productRepository repository.ProductRepositoryInterface) ProductsService {\n\tvar svc ProductsService = NewBasicProductsService(productRepository)\n\tfor _, m := range middleware {\n\t\tsvc = m(svc)\n\t}\n\treturn svc\n}", "func New(middleware []Middleware) AddService {\n\tvar svc AddService = NewBasicAddService()\n\tfor _, m := range middleware {\n\t\tsvc = m(svc)\n\t}\n\treturn svc\n}", "func New(sto store.Service) *server {\n\ts := &server{sto: sto}\n\n\trouter := mux.NewRouter()\n\n\trouter.Handle(\"/todo\", allowedMethods(\n\t\t[]string{\"OPTIONS\", \"GET\", \"POST\"},\n\t\thandlers.MethodHandler{\n\t\t\t\"GET\": http.HandlerFunc(s.getTodos),\n\t\t\t\"POST\": http.HandlerFunc(s.createTodo),\n\t\t}))\n\n\trouter.Handle(\"/todo/{id}\", idMiddleware(allowedMethods(\n\t\t[]string{\"OPTIONS\", \"GET\", \"PUT\", \"PATCH\", \"DELETE\"},\n\t\thandlers.MethodHandler{\n\t\t\t\"GET\": http.HandlerFunc(s.getTodo),\n\t\t\t\"PUT\": http.HandlerFunc(s.putTodo),\n\t\t\t\"PATCH\": http.HandlerFunc(s.patchTodo),\n\t\t\t\"DELETE\": http.HandlerFunc(s.deleteTodo),\n\t\t})))\n\n\ts.handler = limitBody(defaultHeaders(router))\n\n\treturn s\n}", "func NewHandler(bouncer security.BouncerService,\n\tstatus *portainer.Status,\n\tdemoService *demo.Service,\n\tdataStore dataservices.DataStore,\n\tupgradeService upgrade.Service) *Handler {\n\n\th := &Handler{\n\t\tRouter: mux.NewRouter(),\n\t\tdataStore: dataStore,\n\t\tdemoService: demoService,\n\t\tstatus: status,\n\t\tupgradeService: upgradeService,\n\t}\n\n\trouter := h.PathPrefix(\"/system\").Subrouter()\n\n\tadminRouter := router.PathPrefix(\"/\").Subrouter()\n\tadminRouter.Use(bouncer.AdminAccess)\n\n\tadminRouter.Handle(\"/upgrade\", httperror.LoggerHandler(h.systemUpgrade)).Methods(http.MethodPost)\n\n\tauthenticatedRouter := router.PathPrefix(\"/\").Subrouter()\n\tauthenticatedRouter.Use(bouncer.AuthenticatedAccess)\n\n\tauthenticatedRouter.Handle(\"/version\", http.HandlerFunc(h.version)).Methods(http.MethodGet)\n\tauthenticatedRouter.Handle(\"/nodes\", httperror.LoggerHandler(h.systemNodesCount)).Methods(http.MethodGet)\n\tauthenticatedRouter.Handle(\"/info\", httperror.LoggerHandler(h.systemInfo)).Methods(http.MethodGet)\n\n\tpublicRouter := router.PathPrefix(\"/\").Subrouter()\n\tpublicRouter.Use(bouncer.PublicAccess)\n\n\tpublicRouter.Handle(\"/status\", httperror.LoggerHandler(h.systemStatus)).Methods(http.MethodGet)\n\n\t// Deprecated /status endpoint, will be removed in the future.\n\th.Handle(\"/status\",\n\t\tbouncer.PublicAccess(httperror.LoggerHandler(h.statusInspectDeprecated))).Methods(http.MethodGet)\n\th.Handle(\"/status/version\",\n\t\tbouncer.AuthenticatedAccess(http.HandlerFunc(h.versionDeprecated))).Methods(http.MethodGet)\n\th.Handle(\"/status/nodes\",\n\t\tbouncer.AuthenticatedAccess(httperror.LoggerHandler(h.statusNodesCountDeprecated))).Methods(http.MethodGet)\n\n\treturn h\n}", "func New(logger log.Logger, ints, chars metrics.Counter) AddServer {\n\tvar svc Service\n\t{\n\t\tsvc = NewBasicService()\n\t\tsvc = LoggingMiddleware(logger)(svc)\n\t\tsvc = InstrumentingMiddleware(ints, chars)(svc)\n\t}\n\treturn svc\n}", "func NewServices(dbName string) (srv *Services) {\n\n\tCheckEnv()\n\n\t// Establish connection to DB as specificed in database.go\n\tdb, err := InitDB(dbName)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Return a new App struct with all these things.\n\treturn &Services{dbName, db}\n}", "func newStainlessService(context *onet.Context) (onet.Service, error) {\n\tservice := &Stainless{\n\t\tServiceProcessor: onet.NewServiceProcessor(context),\n\t}\n\n\tfor _, srv := range []interface{}{\n\t\tservice.Verify,\n\t\tservice.GenBytecode,\n\t\tservice.DeployContract,\n\t\tservice.ExecuteTransaction,\n\t\tservice.FinalizeTransaction,\n\t\tservice.Call,\n\t} {\n\t\terr := service.RegisterHandler(srv)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn service, nil\n}", "func NewHandlers(cfg *Config) *Handlers {\n\thnd := &Handlers{}\n\thnd.cfg = cfg\n\n\treturn hnd\n}", "func NewHandler(server ServiceControllerServer, hh []*PrefixAndHandler, opts ...func(*Handler)) *Handler {\n\th := &Handler{\n\t\tServer: server,\n\t\tReportHandlers: hh,\n\t\treadf: ioutil.ReadAll,\n\t\tmarshal: proto.Marshal,\n\t\tunmarshal: proto.Unmarshal,\n\t}\n\tfor _, opt := range opts {\n\t\topt(h)\n\t}\n\treturn h\n}", "func New(ctrl *storagecluster.Controller) *Handler {\n\treturn &Handler{\n\t\tctrl: ctrl,\n\t\tclient: ctrl.GetKubernetesClient(),\n\t\tdriver: ctrl.Driver,\n\t}\n}", "func NewHandler(config *api.APIConfig, service Service, databaseClient database.Client) Handler {\n\treturn Handler{\n\t\tconfig: config,\n\t\tservice: service,\n\t\tdatabaseClient: databaseClient,\n\t}\n}", "func MakeHandler(csvc clients.Service, psvc policies.Service, mux *bone.Mux, logger logger.Logger) http.Handler {\n\topts := []kithttp.ServerOption{\n\t\tkithttp.ServerErrorEncoder(apiutil.LoggingErrorEncoder(logger, api.EncodeError)),\n\t}\n\tmux.Post(\"/connect\", kithttp.NewServer(\n\t\totelkit.EndpointMiddleware(otelkit.WithOperation(\"connect\"))(connectThingsEndpoint(psvc)),\n\t\tdecodeConnectList,\n\t\tapi.EncodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Post(\"/disconnect\", kithttp.NewServer(\n\t\totelkit.EndpointMiddleware(otelkit.WithOperation(\"disconnect\"))(disconnectThingsEndpoint(psvc)),\n\t\tdecodeConnectList,\n\t\tapi.EncodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Post(\"/channels/:chanID/things/:thingID\", kithttp.NewServer(\n\t\totelkit.EndpointMiddleware(otelkit.WithOperation(\"connect_thing\"))(connectEndpoint(psvc)),\n\t\tdecodeConnectThing,\n\t\tapi.EncodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Delete(\"/channels/:chanID/things/:thingID\", kithttp.NewServer(\n\t\totelkit.EndpointMiddleware(otelkit.WithOperation(\"disconnect_thing\"))(disconnectEndpoint(psvc)),\n\t\tdecodeDisconnectThing,\n\t\tapi.EncodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Post(\"/identify\", kithttp.NewServer(\n\t\totelkit.EndpointMiddleware(otelkit.WithOperation(\"identify\"))(identifyEndpoint(csvc)),\n\t\tdecodeIdentify,\n\t\tapi.EncodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Put(\"/things/policies\", kithttp.NewServer(\n\t\totelkit.EndpointMiddleware(otelkit.WithOperation(\"update_policy\"))(updatePolicyEndpoint(psvc)),\n\t\tdecodeUpdatePolicy,\n\t\tapi.EncodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Get(\"/things/policies\", kithttp.NewServer(\n\t\totelkit.EndpointMiddleware(otelkit.WithOperation(\"list_policies\"))(listPoliciesEndpoint(psvc)),\n\t\tdecodeListPolicies,\n\t\tapi.EncodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Post(\"/channels/:chanID/access\", kithttp.NewServer(\n\t\totelkit.EndpointMiddleware(otelkit.WithOperation(\"authorize\"))(authorizeEndpoint(psvc)),\n\t\tdecodeCanAccess,\n\t\tapi.EncodeResponse,\n\t\topts...,\n\t))\n\treturn mux\n\n}", "func NewService(config Config) (*common.HTTPHandler, error) {\n\tnewServer := rpc.NewServer()\n\tcodec := json.NewCodec()\n\tnewServer.RegisterCodec(codec, \"application/json\")\n\tnewServer.RegisterCodec(codec, \"application/json;charset=UTF-8\")\n\tif err := newServer.RegisterService(&Admin{\n\t\tConfig: config,\n\t\tprofiler: profiler.New(config.ProfileDir),\n\t}, \"admin\"); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &common.HTTPHandler{Handler: newServer}, nil\n}", "func NewHandlers(datastore Database) *Handlers {\n\treturn &Handlers{\n\t\tdb: datastore,\n\t}\n}", "func SessionsNewHandler(c buffalo.Context) error {\n\treturn c.Render(200, r.HTML(\"sessions/new.html\"))\n}", "func New() []di.Def {\n\t// add user services\n\tsvc := append(services, user.Services...)\n\treturn svc\n}", "func NewHandler(intfs *Interfaces) infra.Handler {\n\tf := func(r *infra.Request) *infra.HandlerResult {\n\t\thandler := &handler{\n\t\t\tintfs: intfs,\n\t\t\trequest: r,\n\t\t}\n\t\treturn handler.Handle()\n\t}\n\treturn infra.HandlerFunc(f)\n}", "func AddHandlers(\n\tservices *Services,\n\tmalformedHandler func(w http.ResponseWriter, r *http.Request)) {\n\thttp.HandleFunc(\"/swift/register\", HandlerRegister(services))\n\thttp.HandleFunc(\"/swift/api/v1/create\", HandlerCreate(services))\n\thttp.HandleFunc(\"/swift/api/v1/encrypt\", HandlerEncrypt(services))\n\thttp.HandleFunc(\"/swift/api/v1/decrypt\", HandlerDecrypt(services))\n\thttp.HandleFunc(\"/swift/api/v1/decode-as-json\", HandlerDecodeAsJSON(services))\n\thttp.HandleFunc(\"/\", HandlerStore(services, malformedHandler))\n}", "func MakeInfoServiceHandler(srv TimeService, logger log.Logger) http.Handler {\n\t//uses Go-Kit for handling\n\n\toptions := []httptransport.ServerOption{\n\t\t//How should errors get encoded\n\t\thttptransport.ServerErrorEncoder(errorEncoder),\n\t\t//The server will use the provided log.Logger object to log errors\n\t\thttptransport.ServerErrorLogger(logger),\n\t}\n\n\tm := http.NewServeMux()\n\n\tvar timeEndpoint endpoint.Endpoint\n\t{\n\t\ttimeEndpoint = MakeAppInfoEndpoint(srv)\n\t\ttimeEndpoint = LoggingMiddleware(log.With(logger, \"method\", \"GetTime\"))(timeEndpoint)\n\t}\n\n\tm.Handle(V1GetTime, httptransport.NewServer(\n\t\ttimeEndpoint,\n\t\tdecodeEmptyRequest,\n\t\tencodeGenericResponse,\n\t\toptions...,\n\t))\n\treturn m\n}", "func New(ctx context.Context, fs afs.Service, done OnDone, routines int) Service {\n\tsrv := &service{\n\t\tOnDone: done,\n\t\tWaitGroup: &sync.WaitGroup{},\n\t\terrChannel: make(chan error, 1),\n\t\tfs: fs,\n\t}\n\tsrv.init(ctx, routines)\n\treturn srv\n}", "func NewServices(a AuthService, v ViewService, g GroupService, u UserService, r RoleService, c ChoreService) *Services {\n\treturn &Services{\n\t\tauth: a,\n\t\tviews: v,\n\t\tgroups: g,\n\t\tusers: u,\n\t\troles: r,\n\t\tchores: c,\n\t}\n}", "func NewService() *Service {\n\tservice := &Service{\n\t\tCodec: serviceCodec{},\n\t\tMaxRequestLength: 0x7FFFFFFF,\n\t\tOptions: NewSafeDict(),\n\t\thandlers: make(map[string]Handler),\n\t}\n\thandlerFactories.Range(func(key, value interface{}) bool {\n\t\thandler := value.(HandlerFactory).New(service)\n\t\tservice.handlers[key.(string)] = handler\n\t\treturn true\n\t})\n\tservice.ioManager = NewIOManager(service.Process)\n\tservice.invokeManager = NewInvokeManager(service.Execute)\n\tservice.AddFunction(service.methodManager.Names, \"~\")\n\treturn service\n}", "func NewHandler(adventure Adventure) http.Handler {\n\treturn handler{adventure}\n}", "func NewHandler(k Keeper) sdk.Handler {\n\treturn func(ctx sdk.Context, msg sdk.Msg) sdk.Result {\n\t\tswitch msg := msg.(type) {\n\t\tcase MsgFactoryIssueFiats:\n\t\t\treturn handleMsgFactoryIssueFiat(ctx, k, msg)\n\t\tcase MsgFactoryRedeemFiats:\n\t\t\treturn handleMsgFactoryRedeemFiat(ctx, k, msg)\n\t\tcase MsgFactorySendFiats:\n\t\t\treturn handleMsgFactorySendFiats(ctx, k, msg)\n\t\tcase MsgFactoryExecuteFiats:\n\t\t\treturn handleMsgFactoryExecuteFiats(ctx, k, msg)\n\t\tdefault:\n\t\t\terrMsg := \"Unrecognized fiatFactory Msg type: \" + reflect.TypeOf(msg).Name()\n\t\t\treturn sdk.ErrUnknownRequest(errMsg).Result()\n\t\t}\n\t}\n}", "func NewHandler(config configuration.ServiceConfig, templateEngine template.TemplateEngine) ServerHandler {\n\treturn ServerHandler{\n\t\tTmplEngine: templateEngine,\n\t\tConfig: config,\n\t}\n}", "func MakeHTTPSHandler(s Service) http.Handler {\n\tr := chi.NewRouter()\n\n\t//Obtener personas por su identificador\n\tgetPersonByHandler := kithttp.NewServer(\n\t\tmakeGetPersonByIDEndPoint(s),\n\t\tgetPersonByIDRequestDecoder,\n\t\tkithttp.EncodeJSONResponse,\n\t)\n\tr.Method(http.MethodGet, \"/id/{id}\", getPersonByHandler)\n\n\t//Obtener personas paginadas\n\tgetPersonHandler := kithttp.NewServer(\n\t\tmakeGetPersonsEndPoint(s),\n\t\tgetPersonsRequestDecoder,\n\t\tkithttp.EncodeJSONResponse,\n\t)\n\tr.Method(http.MethodPost, \"/paginated\", getPersonHandler)\n\n\t//Agregar a una persona\n\taddPersonHandler := kithttp.NewServer(\n\t\tmakeAddPersonEndpoint(s),\n\t\taddPersonRequestDecoder,\n\t\tkithttp.EncodeJSONResponse,\n\t)\n\tr.Method(http.MethodPost, \"/insert\", addPersonHandler)\n\n\t//Actualizar personas\n\tupdatePersonHandler := kithttp.NewServer(\n\t\tmakeUpdatePersonEndpoint(s),\n\t\tupdatePersonRequestDecoder,\n\t\tkithttp.EncodeJSONResponse,\n\t)\n\tr.Method(http.MethodPut, \"/update\", updatePersonHandler)\n\n\t//Eliminar PERSONA\n\tdeletePersonHandler := kithttp.NewServer(\n\t\tmakeDeletePersonEndPoint(s),\n\t\tdeletePersonRequestDecoder,\n\t\tkithttp.EncodeJSONResponse,\n\t)\n\tr.Method(http.MethodDelete, \"/delete/{id}\", deletePersonHandler)\n\treturn r\n}", "func DefaultServices() Services {\n\treturn Services{\n\t\tReposGithubWebhook: &emptyWebhookHandler{name: \"github sync webhook\"},\n\t\tReposGitLabWebhook: &emptyWebhookHandler{name: \"gitlab sync webhook\"},\n\t\tReposBitbucketServerWebhook: &emptyWebhookHandler{name: \"bitbucket server sync webhook\"},\n\t\tReposBitbucketCloudWebhook: &emptyWebhookHandler{name: \"bitbucket cloud sync webhook\"},\n\t\tPermissionsGitHubWebhook: &emptyWebhookHandler{name: \"permissions github webhook\"},\n\t\tBatchesGitHubWebhook: &emptyWebhookHandler{name: \"batches github webhook\"},\n\t\tBatchesGitLabWebhook: &emptyWebhookHandler{name: \"batches gitlab webhook\"},\n\t\tBatchesBitbucketServerWebhook: &emptyWebhookHandler{name: \"batches bitbucket server webhook\"},\n\t\tBatchesBitbucketCloudWebhook: &emptyWebhookHandler{name: \"batches bitbucket cloud webhook\"},\n\t\tBatchesChangesFileGetHandler: makeNotFoundHandler(\"batches file get handler\"),\n\t\tBatchesChangesFileExistsHandler: makeNotFoundHandler(\"batches file exists handler\"),\n\t\tBatchesChangesFileUploadHandler: makeNotFoundHandler(\"batches file upload handler\"),\n\t\tSCIMHandler: makeNotFoundHandler(\"SCIM handler\"),\n\t\tNewCodeIntelUploadHandler: func(_ bool) http.Handler { return makeNotFoundHandler(\"code intel upload\") },\n\t\tRankingService: stubRankingService{},\n\t\tNewExecutorProxyHandler: func() http.Handler { return makeNotFoundHandler(\"executor proxy\") },\n\t\tNewGitHubAppSetupHandler: func() http.Handler { return makeNotFoundHandler(\"Sourcegraph GitHub App setup\") },\n\t\tNewComputeStreamHandler: func() http.Handler { return makeNotFoundHandler(\"compute streaming endpoint\") },\n\t\tCodeInsightsDataExportHandler: makeNotFoundHandler(\"code insights data export handler\"),\n\t}\n}", "func NewTodoServiceHandler(usecase *usecase.Todo) *TodoServiceHandler {\n\treturn &TodoServiceHandler{\n\t\tusecase: usecase,\n\t}\n}", "func CreateHandler(provider string) IHandler {\n\tvar handler IHandler\n\n\tswitch provider {\n\tcase godns.CLOUDFLARE:\n\t\thandler = IHandler(&cloudflare.Handler{})\n\tcase godns.DNSPOD:\n\t\thandler = IHandler(&dnspod.Handler{})\n\tcase godns.HE:\n\t\thandler = IHandler(&he.Handler{})\n\tcase godns.ALIDNS:\n\t\thandler = IHandler(&alidns.Handler{})\n\tcase godns.GOOGLE:\n\t\thandler = IHandler(&google.Handler{})\n\tcase godns.DUCK:\n\t\thandler = IHandler(&duck.Handler{})\n\t}\n\n\treturn handler\n}", "func NewHandler(ctx context.Context, endpoints endpoints.Endpoints, tracer stdopentracing.Tracer, logger log.Logger) pb.VaultServer {\n\toptions := []grpctransport.ServerOption{\n\t\tgrpctransport.ServerErrorLogger(logger),\n\t}\n\treturn &grpcServer{\n\t\tinitstatus: grpctransport.NewServer(\n\t\t\tctx,\n\t\t\tendpoints.InitStatusEndpoint,\n\t\t\tDecodeInitStatusRequest,\n\t\t\tEncodeInitStatusResponse,\n\t\t\tappend(options, grpctransport.ServerBefore(opentracing.FromGRPCRequest(tracer, \"InitStatus\", logger)))...,\n\t\t),\n\t\tinit: grpctransport.NewServer(\n\t\t\tctx,\n\t\t\tendpoints.InitEndpoint,\n\t\t\tDecodeInitRequest,\n\t\t\tEncodeInitResponse,\n\t\t\tappend(options, grpctransport.ServerBefore(opentracing.FromGRPCRequest(tracer, \"Init\", logger)))...,\n\t\t),\n\t\tsealstatus: grpctransport.NewServer(\n\t\t\tctx,\n\t\t\tendpoints.SealStatusEndpoint,\n\t\t\tDecodeSealStatusRequest,\n\t\t\tEncodeSealStatusResponse,\n\t\t\tappend(options, grpctransport.ServerBefore(opentracing.FromGRPCRequest(tracer, \"SealStatus\", logger)))...,\n\t\t),\n\t\tunseal: grpctransport.NewServer(\n\t\t\tctx,\n\t\t\tendpoints.UnsealEndpoint,\n\t\t\tDecodeUnsealRequest,\n\t\t\tEncodeUnsealResponse,\n\t\t\tappend(options, grpctransport.ServerBefore(opentracing.FromGRPCRequest(tracer, \"Unseal\", logger)))...,\n\t\t),\n\t\tconfigure: grpctransport.NewServer(\n\t\t\tctx,\n\t\t\tendpoints.ConfigureEndpoint,\n\t\t\tDecodeConfigureRequest,\n\t\t\tEncodeConfigureResponse,\n\t\t\tappend(options, grpctransport.ServerBefore(opentracing.FromGRPCRequest(tracer, \"Configure\", logger)))...,\n\t\t),\n\t}\n}", "func MakeHandler(svc Service, opts []kithttp.ServerOption, responseEncoder kithttp.EncodeResponseFunc) http.Handler {\n\tauthMid := middleware.AuthMiddleware(svc.(*service).authenticator, \"\", \"\")\n\tlistHandler := kithttp.NewServer(\n\t\tauthMid(makeListEndpoint(svc)),\n\t\tdecodeListRequest,\n\t\tresponseEncoder, opts...)\n\tauthMid = middleware.AuthMiddleware(svc.(*service).authenticator, \"\", permission.StartCampaign)\n\tstartHandler := kithttp.NewServer(\n\t\tauthMid(makeStartEndpoint(svc)),\n\t\tdecodeStartRequest,\n\t\tresponseEncoder, opts...)\n\tprogressHandler := kithttp.NewServer(\n\t\tauthMid(makeProgressEndpoint(svc)),\n\t\tdecodeProgressRequest,\n\t\tresponseEncoder, opts...)\n\treportHandler := kithttp.NewServer(\n\t\tauthMid(makeReportEndpoint(svc)),\n\t\tdecodeReportRequest,\n\t\tresponseEncoder, opts...)\n\tauthMid = middleware.AuthMiddleware(svc.(*service).authenticator, \"\", permission.StopCampaign)\n\tstopHandler := kithttp.NewServer(\n\t\tauthMid(makeStopEndpoint(svc)),\n\t\tdecodeStopRequest,\n\t\tresponseEncoder, opts...)\n\tr := mux.NewRouter()\n\n\tr.Handle(\"/campaign/v1/list\", listHandler).Methods(\"GET\", \"POST\")\n\tr.Handle(\"/campaign/v1/start\", startHandler).Methods(\"POST\")\n\tr.Handle(\"/campaign/v1/progress\", progressHandler).Methods(\"GET\", \"POST\")\n\tr.Handle(\"/campaign/v1/stop\", stopHandler).Methods(\"POST\")\n\tr.Handle(\"/campaign/v1/report\", reportHandler).Methods(\"GET\", \"POST\")\n\treturn r\n}", "func NewHandler(methodFQN, serviceFQN, packageFQN string, impl Func, opts ...HandlerOption) *Handler {\n\tvar cfg handlerCfg\n\tfor _, opt := range opts {\n\t\topt.applyToHandler(&cfg)\n\t}\n\tif reg := cfg.Registrar; reg != nil {\n\t\treg.register(serviceFQN)\n\t}\n\treturn &Handler{\n\t\tmethodFQN: methodFQN,\n\t\tserviceFQN: serviceFQN,\n\t\tpackageFQN: packageFQN,\n\t\timplementation: impl,\n\t\tconfig: cfg,\n\t}\n}", "func NewServiceHTTPHandler(e *echo.Echo, linebot *linebot.Client, servicesInfo *models.ServicesInfo) {\n\n\thanlders := &HTTPCallBackHanlder{Bot: linebot, ServicesInfo: servicesInfo}\n\te.GET(\"/ping\", func(c echo.Context) error {\n\n\t\treturn c.String(200, \"Line boi Service : We are good thank you for asking us.\")\n\t})\n\te.POST(\"/callback\", hanlders.Callback)\n}", "func MakeHTTPSHandler(s Service) http.Handler {\n\tr := chi.NewRouter()\n\n\t// Registrar curso a la bd\n\taddCursoHandler := kithttp.NewServer(\n\t\tmakeAddCursoEndPoint(s),\n\t\taddCursoRequestDecoder,\n\t\tkithttp.EncodeJSONResponse,\n\t)\n\tr.Method(http.MethodPost, \"/registrar\", addCursoHandler)\n\n\t// Obtene curso por el ID\n\tgetCursoByIDHandler := kithttp.NewServer(\n\t\tmakeGetCursoByIDEndPoint(s),\n\t\tgetCursoByIDRequestDecoder,\n\t\tkithttp.EncodeJSONResponse,\n\t)\n\tr.Method(http.MethodGet, \"/id/{id}\", getCursoByIDHandler)\n\n\t// Actualizar el curso por ID\n\tupdateCursoByIDHandler := kithttp.NewServer(\n\t\tmakeUpdateCursoByIDEndPoint(s),\n\t\tupdateCursoRequestDecoder,\n\t\tkithttp.EncodeJSONResponse,\n\t)\n\tr.Method(http.MethodPut, \"/actualizar\", updateCursoByIDHandler)\n\n\t// Obtener todos los cursos\n\tgetAllCursoByIDHandler := kithttp.NewServer(\n\t\tmakeGetAllCursoEndPoint(s),\n\t\tgetAllCursoRequestDecoder,\n\t\tkithttp.EncodeJSONResponse,\n\t)\n\tr.Method(http.MethodGet, \"/allCurso\", getAllCursoByIDHandler)\n\n\t// Subir Imagen todos los cursos\n\tuploadFondoCursoByIDHandler := kithttp.NewServer(\n\t\tmakeUploadImageCursoEndPoint(s),\n\t\tuploadFondoCursoRequestDecoder,\n\t\tkithttp.EncodeJSONResponse,\n\t)\n\tr.Method(http.MethodPut, \"/fondo/id/{id}\", uploadFondoCursoByIDHandler)\n\n\t// Subir Imagen todos los cursos\n\tgetFondoCursoByIDHandler := kithttp.NewServer(\n\t\tmakeGetFondoCursoEndPoint(s),\n\t\tgetFondoCursoRequestDecoder,\n\t\tEncodeJSONResponseFileImgUpload,\n\t)\n\tr.Method(http.MethodGet, \"/fondo/id/{id}\", getFondoCursoByIDHandler)\n\n\treturn r\n}", "func GetAllBudgetsHandlerFactory(ctx context.Context) Handler {\n\treturn func(w http.ResponseWriter, r *http.Request) error {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tbudgets, err := ctx.BudgetService.GetAll()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tbytes, err := json.Marshal(budgets)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn ServeContent(w, r, string(bytes), http.StatusOK)\n\t}\n}", "func NewHandler(s *Server) *Handler {\n\th := &Handler{\n\t\tserver: s,\n\t\tmux: pat.New(),\n\t}\n\n\t// Series routes.\n\th.mux.Get(\"/db/:db/series\", http.HandlerFunc(h.serveQuery))\n\th.mux.Post(\"/db/:db/series\", http.HandlerFunc(h.serveWriteSeries))\n\th.mux.Del(\"/db/:db/series/:series\", http.HandlerFunc(h.serveDeleteSeries))\n\th.mux.Get(\"/db\", http.HandlerFunc(h.serveDatabases))\n\th.mux.Post(\"/db\", http.HandlerFunc(h.serveCreateDatabase))\n\th.mux.Del(\"/db/:name\", http.HandlerFunc(h.serveDeleteDatabase))\n\n\t// Cluster admins routes.\n\th.mux.Get(\"/cluster_admins/authenticate\", http.HandlerFunc(h.serveAuthenticateClusterAdmin))\n\th.mux.Get(\"/cluster_admins\", http.HandlerFunc(h.serveClusterAdmins))\n\th.mux.Post(\"/cluster_admins\", http.HandlerFunc(h.serveCreateClusterAdmin))\n\th.mux.Post(\"/cluster_admins/:user\", http.HandlerFunc(h.serveUpdateClusterAdmin))\n\th.mux.Del(\"/cluster_admins/:user\", http.HandlerFunc(h.serveDeleteClusterAdmin))\n\n\t// Database users routes.\n\th.mux.Get(\"/db/:db/authenticate\", http.HandlerFunc(h.serveAuthenticateDBUser))\n\th.mux.Get(\"/db/:db/users\", http.HandlerFunc(h.serveDBUsers))\n\th.mux.Post(\"/db/:db/users\", http.HandlerFunc(h.serveCreateDBUser))\n\th.mux.Get(\"/db/:db/users/:user\", http.HandlerFunc(h.serveDBUser))\n\th.mux.Post(\"/db/:db/users/:user\", http.HandlerFunc(h.serveUpdateDBUser))\n\th.mux.Del(\"/db/:db/users/:user\", http.HandlerFunc(h.serveDeleteDBUser))\n\n\t// Utilities\n\th.mux.Get(\"/ping\", http.HandlerFunc(h.servePing))\n\th.mux.Get(\"/interfaces\", http.HandlerFunc(h.serveInterfaces))\n\n\t// Shard routes.\n\th.mux.Get(\"/cluster/shards\", http.HandlerFunc(h.serveShards))\n\th.mux.Post(\"/cluster/shards\", http.HandlerFunc(h.serveCreateShard))\n\th.mux.Del(\"/cluster/shards/:id\", http.HandlerFunc(h.serveDeleteShard))\n\n\t// Shard space routes.\n\th.mux.Get(\"/cluster/shard_spaces\", http.HandlerFunc(h.serveShardSpaces))\n\th.mux.Post(\"/cluster/shard_spaces/:db\", http.HandlerFunc(h.serveCreateShardSpace))\n\th.mux.Post(\"/cluster/shard_spaces/:db/:name\", http.HandlerFunc(h.serveUpdateShardSpace))\n\th.mux.Del(\"/cluster/shard_spaces/:db/:name\", http.HandlerFunc(h.serveDeleteShardSpace))\n\n\t// Cluster config endpoints\n\th.mux.Get(\"/cluster/servers\", http.HandlerFunc(h.serveServers))\n\th.mux.Del(\"/cluster/servers/:id\", http.HandlerFunc(h.serveDeleteServer))\n\n\treturn h\n}", "func newServices(\n\tsettingsFile string,\n\tswanAccess Access,\n\tswiftAccess swift.Access,\n\towidAccess owid.Access) *services {\n\tvar swiftStore swift.Store\n\tvar owidStore owid.Store\n\n\t// Use the file provided to get the SWIFT settings.\n\tswiftConfig := swift.NewConfig(settingsFile)\n\terr := swiftConfig.Validate()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Use the file provided to get the OWID settings.\n\towidConfig := owid.NewConfig(settingsFile)\n\terr = owidConfig.Validate()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Link to the SWIFT storage.\n\tswiftStore = swift.NewStore(swiftConfig)\n\n\t// Link to the OWID storage.\n\towidStore = owid.NewStore(owidConfig)\n\n\t// Get the default browser detector.\n\tb, err := swift.NewBrowserRegexes()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Create the swan configuration.\n\tc := newConfig(settingsFile)\n\n\t// Get the SWIFT access node for the SWAN network. Log any errors rather\n\t// than panic because it may be that a network has yet to be established\n\t// for SWAN in the storage tables.\n\tan, err := swiftStore.GetAccessNode(c.Network)\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\tlog.Printf(\"Has a '%s' network been created?\", c.Network)\n\t}\n\n\t// Return the services.\n\treturn &services{\n\t\tc,\n\t\tswift.NewServices(swiftConfig, swiftStore, swiftAccess, b),\n\t\towid.NewServices(owidConfig, owidStore, owidAccess),\n\t\tan,\n\t\tswanAccess}\n}", "func (s *Server) newHandler() http.Handler {\n\tr := mux.NewRouter()\n\tr.HandleFunc(\"/register\", s.wrapMiddleware(registerHandler)).Methods(\"POST\")\n\tr.HandleFunc(\"/session/{id}\", s.wrapMiddleware(getHandler)).Methods(\"GET\")\n\tr.HandleFunc(\"/session\", s.wrapMiddleware(createHandler)).Methods(\"POST\")\n\tr.HandleFunc(\"/readiness\", predis.NewReadinessCheck(s.pool))\n\n\treturn r\n}", "func New(cfg config.Proxy, bp httputil.BufferPool, token ntokend.TokenProvider, access service.AccessProvider, role service.RoleProvider, svcCert service.SvcCertProvider) Handler {\n\treturn &handler{\n\t\tproxy: &httputil.ReverseProxy{\n\t\t\tBufferPool: bp,\n\t\t},\n\t\ttoken: token,\n\t\taccess: access,\n\t\trole: role,\n\t\tcfg: cfg,\n\t\tsvcCert: svcCert,\n\t}\n}", "func NewHandler(s Service, v *validator.Validate, c *cache.Cache) FundHandler {\n\treturn FundHandler{service: s, validate: v, cache: c}\n}", "func NewUserServiceHandler(svc UserServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {\n\tuserServiceCreateUserHandler := connect.NewUnaryHandler(\n\t\tUserServiceCreateUserProcedure,\n\t\tsvc.CreateUser,\n\t\tconnect.WithIdempotency(connect.IdempotencyIdempotent),\n\t\tconnect.WithHandlerOptions(opts...),\n\t)\n\tuserServiceGetUserHandler := connect.NewUnaryHandler(\n\t\tUserServiceGetUserProcedure,\n\t\tsvc.GetUser,\n\t\tconnect.WithIdempotency(connect.IdempotencyNoSideEffects),\n\t\tconnect.WithHandlerOptions(opts...),\n\t)\n\tuserServiceGetUserByUsernameHandler := connect.NewUnaryHandler(\n\t\tUserServiceGetUserByUsernameProcedure,\n\t\tsvc.GetUserByUsername,\n\t\tconnect.WithIdempotency(connect.IdempotencyNoSideEffects),\n\t\tconnect.WithHandlerOptions(opts...),\n\t)\n\tuserServiceListUsersHandler := connect.NewUnaryHandler(\n\t\tUserServiceListUsersProcedure,\n\t\tsvc.ListUsers,\n\t\tconnect.WithIdempotency(connect.IdempotencyNoSideEffects),\n\t\tconnect.WithHandlerOptions(opts...),\n\t)\n\tuserServiceListOrganizationUsersHandler := connect.NewUnaryHandler(\n\t\tUserServiceListOrganizationUsersProcedure,\n\t\tsvc.ListOrganizationUsers,\n\t\tconnect.WithIdempotency(connect.IdempotencyNoSideEffects),\n\t\tconnect.WithHandlerOptions(opts...),\n\t)\n\tuserServiceDeleteUserHandler := connect.NewUnaryHandler(\n\t\tUserServiceDeleteUserProcedure,\n\t\tsvc.DeleteUser,\n\t\tconnect.WithIdempotency(connect.IdempotencyIdempotent),\n\t\tconnect.WithHandlerOptions(opts...),\n\t)\n\tuserServiceDeactivateUserHandler := connect.NewUnaryHandler(\n\t\tUserServiceDeactivateUserProcedure,\n\t\tsvc.DeactivateUser,\n\t\tconnect.WithIdempotency(connect.IdempotencyIdempotent),\n\t\tconnect.WithHandlerOptions(opts...),\n\t)\n\tuserServiceUpdateUserServerRoleHandler := connect.NewUnaryHandler(\n\t\tUserServiceUpdateUserServerRoleProcedure,\n\t\tsvc.UpdateUserServerRole,\n\t\topts...,\n\t)\n\tuserServiceCountUsersHandler := connect.NewUnaryHandler(\n\t\tUserServiceCountUsersProcedure,\n\t\tsvc.CountUsers,\n\t\tconnect.WithIdempotency(connect.IdempotencyNoSideEffects),\n\t\tconnect.WithHandlerOptions(opts...),\n\t)\n\tuserServiceUpdateUserSettingsHandler := connect.NewUnaryHandler(\n\t\tUserServiceUpdateUserSettingsProcedure,\n\t\tsvc.UpdateUserSettings,\n\t\topts...,\n\t)\n\treturn \"/buf.alpha.registry.v1alpha1.UserService/\", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tswitch r.URL.Path {\n\t\tcase UserServiceCreateUserProcedure:\n\t\t\tuserServiceCreateUserHandler.ServeHTTP(w, r)\n\t\tcase UserServiceGetUserProcedure:\n\t\t\tuserServiceGetUserHandler.ServeHTTP(w, r)\n\t\tcase UserServiceGetUserByUsernameProcedure:\n\t\t\tuserServiceGetUserByUsernameHandler.ServeHTTP(w, r)\n\t\tcase UserServiceListUsersProcedure:\n\t\t\tuserServiceListUsersHandler.ServeHTTP(w, r)\n\t\tcase UserServiceListOrganizationUsersProcedure:\n\t\t\tuserServiceListOrganizationUsersHandler.ServeHTTP(w, r)\n\t\tcase UserServiceDeleteUserProcedure:\n\t\t\tuserServiceDeleteUserHandler.ServeHTTP(w, r)\n\t\tcase UserServiceDeactivateUserProcedure:\n\t\t\tuserServiceDeactivateUserHandler.ServeHTTP(w, r)\n\t\tcase UserServiceUpdateUserServerRoleProcedure:\n\t\t\tuserServiceUpdateUserServerRoleHandler.ServeHTTP(w, r)\n\t\tcase UserServiceCountUsersProcedure:\n\t\t\tuserServiceCountUsersHandler.ServeHTTP(w, r)\n\t\tcase UserServiceUpdateUserSettingsProcedure:\n\t\t\tuserServiceUpdateUserSettingsHandler.ServeHTTP(w, r)\n\t\tdefault:\n\t\t\thttp.NotFound(w, r)\n\t\t}\n\t})\n}", "func New(o *Options, logger common.Logger, broker *broker.Broker) *Handler {\n\trouter := route.New()\n\n\th := &Handler{\n\t\toptions: o,\n\t\tlogger: logger,\n\t\trouter: router,\n\t\tbroker: broker,\n\t}\n\n\t// Setup HTTP endpoints\n\trouter.Get(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\thttp.Redirect(w, r, \"/overview\", http.StatusFound)\n\t})\n\trouter.Get(\"/overview\", h.handleOverview)\n\trouter.Get(\"/logs\", func(w http.ResponseWriter, r *http.Request) {\n\t\thttp.Redirect(w, r, \"/logs/*\", http.StatusFound)\n\t})\n\trouter.Get(\"/logs/:pattern\", h.handleLogs)\n\trouter.Get(\"/request\", h.handleRequest)\n\trouter.Post(\"/request\", h.handleRequestPost)\n\n\t// Static files\n\trouter.Get(\"/static/*filepath\", route.FileServe(path.Join(o.AssetsPath, \"static\")))\n\n\t// Prometheus HTTP endpoint\n\trouter.Get(\"/metrics\", promhttp.HandlerFor(prometheus.Gatherers{prometheus.DefaultGatherer, broker.Monitoring.Registry}, promhttp.HandlerOpts{}).ServeHTTP)\n\n\t// cellaserv HTTP API\n\trouter.Get(\"/api/v1/request/:service/:method\", h.apiRequest)\n\trouter.Post(\"/api/v1/request/:service/:method\", h.apiRequest)\n\trouter.Post(\"/api/v1/publish/:event\", h.apiPublish)\n\trouter.Get(\"/api/v1/subscribe/:event\", h.apiSubscribe)\n\t// TODO(halfr): spy\n\n\t// Go debug\n\trouter.Get(\"/debug/*subpath\", handleDebug)\n\trouter.Post(\"/debug/*subpath\", handleDebug)\n\n\treturn h\n}", "func CreateHandler(config *Config) http.Handler {\n\trouter := httprouter.New()\n\trouter.RedirectTrailingSlash = false\n\n\trouter.GET(\"/\", indexHandler{config: config}.Handle)\n\n\tfor name, pkg := range config.Packages {\n\t\thandle := packageHandler{\n\t\t\tpkgName: name,\n\t\t\tpkg: pkg,\n\t\t\tconfig: config,\n\t\t}.Handle\n\t\trouter.GET(fmt.Sprintf(\"/%s\", name), handle)\n\t\trouter.GET(fmt.Sprintf(\"/%s/*path\", name), handle)\n\t}\n\n\treturn router\n}", "func newHelloService() HelloService {\n\treturn &helloServiceImpl{}\n}", "func NewHandler(clusterService agent.ClusterService, agentTags *agent.InfoTags, notaryService *security.NotaryService) *Handler {\n\th := &Handler{\n\t\tRouter: mux.NewRouter(),\n\t\tconnectionUpgrader: websocket.Upgrader{},\n\t\tclusterService: clusterService,\n\t\tagentTags: agentTags,\n\t}\n\n\th.Handle(\"/websocket/attach\", notaryService.DigitalSignatureVerification(httperror.LoggerHandler(h.websocketAttach)))\n\th.Handle(\"/websocket/exec\", notaryService.DigitalSignatureVerification(httperror.LoggerHandler(h.websocketExec)))\n\treturn h\n}", "func newService(c *onet.Context) (onet.Service, error) {\n\ts := &Service{\n\t\tServiceProcessor: onet.NewServiceProcessor(c),\n\t}\n\ts.RegisterProcessorFunc(cosiSendRawID, s.HandleRaw)\n\t_, err := c.ProtocolRegister(protoName, s.NewDefaultProtocol)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := s.RegisterHandlers(s.GenesisTx, s.Setup, s.TreesBLSCoSi, s.MemoryAllocated); err != nil {\n\t\treturn nil, errors.New(\"Couldn't register messages\")\n\t}\n\n\ts.propagateF, s.mypi, err = propagate.NewPropagationFunc(c, \"Propagate\", s.propagateHandler, -1)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ts.trees = make(map[onet.TreeID]*onet.Tree)\n\ts.coinToAtomic = make(map[string]int)\n\ts.atomicCoinReserved = make([]int32, 0)\n\n\tdb, bucketNameTx := s.GetAdditionalBucket([]byte(\"Tx\"))\n\t_, bucketNameLastTx := s.GetAdditionalBucket([]byte(\"LastTx\"))\n\ts.bucketNameTx = bucketNameTx\n\ts.bucketNameLastTx = bucketNameLastTx\n\ts.db = db\n\treturn s, nil\n}", "func New(s *service.Service) http.Handler {\n\th := handler{s}\n\tapi := way.NewRouter()\n\tapi.HandleFunc(\"POST\", \"/\", h.twillioHandler)\n\tapi.HandleFunc(\"POST\", \"/passcodes\", h.generatePasswords)\n\tapi.HandleFunc(\"GET\", \"/passcodes\", h.getPasscodes)\n\t// api.HandleFunc(\"POST\", \"/passcode/validate\", h.validatePasscode)\n\treturn api\n}", "func NewHandler(params Params) *Handler {\n\treturn &Handler{\n\t\tstan: params.StanClient,\n\t\tmatcherSvc: params.MatcherSvc,\n\t}\n}", "func NewHandler(containerNames []string) *Handler {\n\th := &Handler{\n\t\tcontainerPaths: make(ContainerPaths, len(containerNames)),\n\t\tConfig: defaults,\n\t}\n\tif len(containerNames) > 0 {\n\t\th.defaultContainerName = containerNames[0]\n\t}\n\tfor _, containerName := range containerNames {\n\t\th.containerPaths[containerName] = FilePaths{}\n\t}\n\treturn h\n}", "func MakeHandler(svc users.Service, tracer opentracing.Tracer, l log.Logger) http.Handler {\n\tlogger = l\n\n\topts := []kithttp.ServerOption{\n\t\tkithttp.ServerErrorEncoder(encodeError),\n\t}\n\n\tmux := bone.New()\n\n\tmux.Post(\"/users\", kithttp.NewServer(\n\t\tkitot.TraceServer(tracer, \"register\")(registrationEndpoint(svc)),\n\t\tdecodeCredentials,\n\t\tencodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Get(\"/users\", kithttp.NewServer(\n\t\tkitot.TraceServer(tracer, \"user_info\")(userInfoEndpoint(svc)),\n\t\tdecodeViewInfo,\n\t\tencodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Put(\"/users\", kithttp.NewServer(\n\t\tkitot.TraceServer(tracer, \"update_user\")(updateUserEndpoint(svc)),\n\t\tdecodeUpdateUser,\n\t\tencodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Post(\"/password/reset-request\", kithttp.NewServer(\n\t\tkitot.TraceServer(tracer, \"res-req\")(passwordResetRequestEndpoint(svc)),\n\t\tdecodePasswordResetRequest,\n\t\tencodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Put(\"/password/reset\", kithttp.NewServer(\n\t\tkitot.TraceServer(tracer, \"reset\")(passwordResetEndpoint(svc)),\n\t\tdecodePasswordReset,\n\t\tencodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Patch(\"/password\", kithttp.NewServer(\n\t\tkitot.TraceServer(tracer, \"reset\")(passwordChangeEndpoint(svc)),\n\t\tdecodePasswordChange,\n\t\tencodeResponse,\n\t\topts...,\n\t))\n\n\tmux.Post(\"/tokens\", kithttp.NewServer(\n\t\tkitot.TraceServer(tracer, \"login\")(loginEndpoint(svc)),\n\t\tdecodeCredentials,\n\t\tencodeResponse,\n\t\topts...,\n\t))\n\n\tmux.GetFunc(\"/version\", mainflux.Version(\"users\"))\n\tmux.Handle(\"/metrics\", promhttp.Handler())\n\n\treturn mux\n}", "func NewHandler() inputs.Handler {\n\treturn &Handler{\n\t\tin: make(chan inputs.Data, 20),\n\t\thosts: []string{},\n\t\tcreds: []scanners.Credential{},\n\t}\n}", "func ServiceBrowserNew(conn *dbus.Conn, path dbus.ObjectPath) (*ServiceBrowser, error) {\n\tc := new(ServiceBrowser)\n\n\tc.object = conn.Object(\"org.freedesktop.Avahi\", path)\n\tc.AddChannel = make(chan Service)\n\tc.RemoveChannel = make(chan Service)\n\tc.closeCh = make(chan struct{})\n\n\treturn c, nil\n}", "func NewHandler() *Handler {\n\th := &Handler{\n\t\tHandler: client.NewHandler(),\n\t}\n\th.Handler.RequestService = &h.RequestService\n\n\treturn h\n}", "func MakeDeleteHandler(cfg *types.Config, back types.ServerlessBackend) gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\t// First get the Service\n\t\tservice, _ := back.ReadService(c.Param(\"serviceName\"))\n\n\t\tif err := back.DeleteService(c.Param(\"serviceName\")); err != nil {\n\t\t\t// Check if error is caused because the service is not found\n\t\t\tif errors.IsNotFound(err) || errors.IsGone(err) {\n\t\t\t\tc.Status(http.StatusNotFound)\n\t\t\t} else {\n\t\t\t\tc.String(http.StatusInternalServerError, err.Error())\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\t// Disable input notifications\n\t\tif err := disableInputNotifications(service.GetMinIOWebhookARN(), service.Input, service.StorageProviders.MinIO[types.DefaultProvider]); err != nil {\n\t\t\tlog.Printf(\"Error disabling MinIO input notifications for service \\\"%s\\\": %v\\n\", service.Name, err)\n\t\t}\n\n\t\t// Remove the service's webhook in MinIO config and restart the server\n\t\tif err := removeMinIOWebhook(service.Name, cfg); err != nil {\n\t\t\tlog.Printf(\"Error removing MinIO webhook for service \\\"%s\\\": %v\\n\", service.Name, err)\n\t\t}\n\n\t\t// Add Yunikorn queue if enabled\n\t\tif cfg.YunikornEnable {\n\t\t\tif err := utils.DeleteYunikornQueue(cfg, back.GetKubeClientset(), service); err != nil {\n\t\t\t\tlog.Println(err.Error())\n\t\t\t}\n\t\t}\n\n\t\tc.Status(http.StatusNoContent)\n\t}\n}", "func MakeHandler(svc Service, opts ...kithttp.ServerOption) http.Handler {\n\tr := mux.NewRouter()\n\tr.StrictSlash(true)\n\n\tr.Methods(\"GET\").Path(`/`).Name(\"ruleList\").Handler(\n\t\tkithttp.NewServer(\n\t\t\tlistEndpoint(svc),\n\t\t\tdecodeListRequest,\n\t\t\tkithttp.EncodeJSONResponse,\n\t\t\topts...,\n\t\t),\n\t)\n\n\tr.Methods(\"GET\").Path(`/{id:[a-zA-Z0-9]+}`).Name(\"ruleGet\").Handler(\n\t\tkithttp.NewServer(\n\t\t\tgetEndpoint(svc),\n\t\t\tdecodeGetRequest,\n\t\t\tkithttp.EncodeJSONResponse,\n\t\t\tappend(\n\t\t\t\topts,\n\t\t\t\tkithttp.ServerBefore(extractMuxVars(varID)),\n\t\t\t)...,\n\t\t),\n\t)\n\n\tr.Methods(\"PUT\").Path(`/{id:[a-zA-Z0-9]+}/activate`).Name(\"ruleActivate\").Handler(\n\t\tkithttp.NewServer(\n\t\t\tactivateEndpoint(svc),\n\t\t\tdecodeActivateRequest,\n\t\t\tkithttp.EncodeJSONResponse,\n\t\t\tappend(\n\t\t\t\topts,\n\t\t\t\tkithttp.ServerBefore(extractMuxVars(varID)),\n\t\t\t)...,\n\t\t),\n\t)\n\n\tr.Methods(\"PUT\").Path(`/{id:[a-zA-Z0-9]+}/deactivate`).Name(\"ruleDeactivate\").Handler(\n\t\tkithttp.NewServer(\n\t\t\tdeactivateEndpoint(svc),\n\t\t\tdecodeDeactivateRequest,\n\t\t\tkithttp.EncodeJSONResponse,\n\t\t\tappend(\n\t\t\t\topts,\n\t\t\t\tkithttp.ServerBefore(extractMuxVars(varID)),\n\t\t\t)...,\n\t\t),\n\t)\n\n\tr.Methods(\"PUT\").Path(`/{id:[a-zA-Z0-9]+}/rollout`).Name(\"ruleUpdateRollout\").Handler(\n\t\tkithttp.NewServer(\n\t\t\tupdateRolloutEndpoint(svc),\n\t\t\tdecodeUpdateRolloutRequest,\n\t\t\tkithttp.EncodeJSONResponse,\n\t\t\tappend(\n\t\t\t\topts,\n\t\t\t\tkithttp.ServerBefore(extractMuxVars(varID)),\n\t\t\t)...,\n\t\t),\n\t)\n\n\treturn r\n}", "func NewService(m map[string]interface{}) Service {\n\treturn m\n}", "func MakeHandler(service Service, logger log.Logger) http.Handler {\n\topts := []khttp.ServerOption{\n\t\tkhttp.ServerErrorLogger(logger),\n\t\tkhttp.ServerErrorEncoder(kit.EncodeError),\n\t}\n\n\troutes := kit.Routes{\n\t\tkit.Route{\n\t\t\tName: \"UUID\",\n\t\t\tMethod: \"GET\",\n\t\t\tPattern: \"/five/v1/uuid\",\n\t\t\tHandler: khttp.NewServer(\n\t\t\t\tmakeUuidEndpoint(service),\n\t\t\t\tdecodeUuidRequest,\n\t\t\t\tkit.Encode,\n\t\t\t\topts...,\n\t\t\t),\n\t\t\tQueries: []string{\n\t\t\t\t\"namespace\",\n\t\t\t\t\"{namespace:[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}}\",\n\t\t\t\t\"name\",\n\t\t\t\t\"{name:*}\",\n\t\t\t},\n\t\t},\n\t}\n\n\treturn kit.AddRoutes(routes...)\n}", "func NewHandler(service *comment.Service) *Handler {\n\treturn &Handler{\n\t\tService: service,\n\t}\n}", "func newSvcPaths() *svcPaths {\n\treturn &svcPaths{StoPs: make(map[string]set.Set)}\n}", "func (s *SidecarApi) oneServiceHandler(response http.ResponseWriter, req *http.Request, params map[string]string) {\n\tdefer req.Body.Close()\n\n\tresponse.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tresponse.Header().Set(\"Access-Control-Allow-Methods\", \"GET\")\n\tresponse.Header().Set(\"Content-Type\", \"application/json\")\n\n\tif params[\"extension\"] != \"json\" {\n\t\tsendJsonError(response, 404, \"Not Found - Invalid content type extension\")\n\t\treturn\n\t}\n\n\tname, ok := params[\"name\"]\n\tif !ok {\n\t\tsendJsonError(response, 404, \"Not Found - No service name provided\")\n\t\treturn\n\t}\n\n\tif s.state == nil {\n\t\tsendJsonError(response, 500, \"Internal Server Error - Something went terribly wrong\")\n\t\treturn\n\t}\n\n\tvar instances []*service.Service\n\t// Enter critical section\n\ts.state.RLock()\n\tdefer s.state.RUnlock()\n\ts.state.EachService(func(hostname *string, id *string, svc *service.Service) {\n\t\tif svc.Name == name {\n\t\t\tinstances = append(instances, svc)\n\t\t}\n\t})\n\n\t// Did we have any entries for this service in the catalog?\n\tif len(instances) == 0 {\n\t\tsendJsonError(response, 404, fmt.Sprintf(\"no instances of %s found\", name))\n\t\treturn\n\t}\n\n\tclusterName := \"\"\n\tif s.list != nil {\n\t\tclusterName = s.list.ClusterName()\n\t}\n\n\t// Everything went fine, we found entries for this service.\n\t// Send the json back.\n\tsvcInstances := make(map[string][]*service.Service)\n\tsvcInstances[name] = instances\n\tresult := ApiServices{\n\t\tServices: svcInstances,\n\t\tClusterName: clusterName,\n\t}\n\n\tjsonBytes, err := json.MarshalIndent(&result, \"\", \" \")\n\tif err != nil {\n\t\tlog.Errorf(\"Error marshaling state in oneServiceHandler: %s\", err.Error())\n\t\tsendJsonError(response, 500, \"Internal server error\")\n\t\treturn\n\t}\n\n\t_, err = response.Write(jsonBytes)\n\tif err != nil {\n\t\tlog.Errorf(\"Error writing one service response to client: %s\", err)\n\t}\n}", "func ServiceHandler(ctx context.Context, svc Service, logger kitlog.Logger) http.Handler {\r\n\topts := []kithttp.ServerOption{\r\n\t\tkithttp.ServerErrorLogger(logger),\r\n\t\tkithttp.ServerBefore(updateContext),\r\n\t}\r\n\r\n\tscepHandler := kithttp.NewServer(\r\n\t\tmakeSCEPEndpoint(svc),\r\n\t\tdecodeSCEPRequest,\r\n\t\tencodeSCEPResponse,\r\n\t\topts...,\r\n\t)\r\n\r\n\tmux := http.NewServeMux()\r\n\tmux.Handle(\"/scep\", scepHandler)\r\n\treturn mux\r\n}", "func NewHandler(ctx context.Context, cfg diag.Config, logger *zap.Logger) (http.Handler, error) {\n\tdiagSvc, err := diag.NewService(ctx, cfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\th := handler{\n\t\tdiagSvc: diagSvc,\n\t\tlogger: logger,\n\t}\n\n\texpConfigHandler, err := exposureConfig(cfg.ExposureConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tmux := http.NewServeMux()\n\n\tmux.HandleFunc(\"/diagnosis-keys\", h.diagnosisKeys)\n\tmux.HandleFunc(\"/exposure-config\", expConfigHandler)\n\tmux.HandleFunc(\"/health\", h.health)\n\n\treturn mux, nil\n}", "func regHandlers(version string) error {\n\tihandler, err := newIndexHandler(version)\n\tif err != nil {\n\t\treturn err\n\t}\n\thttp.Handle(\"/\", ihandler)\n\thttp.Handle(\"/by-cost\", citiesHandler{\"cost\"})\n\thttp.Handle(\"/by-population\", citiesHandler{\"population\"})\n\thttp.Handle(\"/by-climate\", citiesHandler{\"climate\"})\n\thttp.HandleFunc(\"/city\", addCityHandler)\n\thttp.HandleFunc(\"/talk\", talkHandler)\n\thttp.HandleFunc(\"/message\", messageHandler)\n\treturn nil\n}" ]
[ "0.6721812", "0.6599959", "0.6413891", "0.6336606", "0.6182184", "0.6086837", "0.6082766", "0.6016732", "0.6008815", "0.5951964", "0.59366834", "0.5931475", "0.5915596", "0.5904584", "0.58656454", "0.58620006", "0.5828751", "0.5819641", "0.5806342", "0.58059764", "0.5799651", "0.57862324", "0.57858557", "0.5774564", "0.5772928", "0.5772655", "0.5759494", "0.57515526", "0.5716732", "0.5714425", "0.570958", "0.57086134", "0.5700747", "0.56819326", "0.5678493", "0.56547844", "0.5645201", "0.56448245", "0.5643403", "0.5636559", "0.56297", "0.5624985", "0.5621363", "0.56132936", "0.5594676", "0.55936354", "0.5593104", "0.5570695", "0.5570324", "0.5568687", "0.5553866", "0.5553023", "0.55473006", "0.5537115", "0.5528223", "0.5516265", "0.5513884", "0.5513211", "0.54984605", "0.54970694", "0.54935837", "0.54911655", "0.54903847", "0.5483942", "0.5476608", "0.5476604", "0.54761815", "0.5473631", "0.5470351", "0.5464469", "0.5462325", "0.5455131", "0.54507506", "0.54506344", "0.54498184", "0.5448727", "0.5447204", "0.5446795", "0.5444744", "0.54411083", "0.54381025", "0.5437882", "0.54345524", "0.542002", "0.54133475", "0.54102635", "0.54089886", "0.5403576", "0.5400338", "0.53906596", "0.5364618", "0.53534913", "0.53456974", "0.53449386", "0.53434604", "0.53420705", "0.5338553", "0.5338531", "0.5331152", "0.53260046" ]
0.8023489
0
NewDataCollectionEndpointsClient creates a new instance of DataCollectionEndpointsClient with the specified values.
NewDataCollectionEndpointsClient создает новый экземпляр DataCollectionEndpointsClient с указанными значениями.
func NewDataCollectionEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *DataCollectionEndpointsClient { cp := arm.ClientOptions{} if options != nil { cp = *options } if len(cp.Host) == 0 { cp.Host = arm.AzurePublicCloud } return &DataCollectionEndpointsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewDataCollectionEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *DataCollectionEndpointsClient {\n\tcp := arm.ClientOptions{}\n\tif options != nil {\n\t\tcp = *options\n\t}\n\tif len(cp.Endpoint) == 0 {\n\t\tcp.Endpoint = arm.AzurePublicCloud\n\t}\n\tclient := &DataCollectionEndpointsClient{\n\t\tsubscriptionID: subscriptionID,\n\t\thost: string(cp.Endpoint),\n\t\tpl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, &cp),\n\t}\n\treturn client\n}", "func NewClient(endpoints ...[]string) *Client {\n\tclient := &Client{\n\t\tevents: make(chan *models.Event),\n\t\tcancel: make(chan struct{}),\n\t}\n\tfor _, v := range endpoints {\n\t\tclient.endpoints = v\n\t}\n\tclient.address = client.GetServiceIP()\n\treturn client\n}", "func New(endpoints ...string) *Client {\n\treturn &Client{\n\t\tendpoints: newEndpoints(endpoints...),\n\t\tMaxTries: len(endpoints),\n\t\tEndpointTimeout: defaultTimeout,\n\t}\n}", "func NewClient(userList, getUser, createUser, updateUser, deleteUser goa.Endpoint) *Client {\n\treturn &Client{\n\t\tUserListEndpoint: userList,\n\t\tGetUserEndpoint: getUser,\n\t\tCreateUserEndpoint: createUser,\n\t\tUpdateUserEndpoint: updateUser,\n\t\tDeleteUserEndpoint: deleteUser,\n\t}\n}", "func NewClient(list, show, add, remove, rate, multiAdd, multiUpdate goa.Endpoint) *Client {\n\treturn &Client{\n\t\tListEndpoint: list,\n\t\tShowEndpoint: show,\n\t\tAddEndpoint: add,\n\t\tRemoveEndpoint: remove,\n\t\tRateEndpoint: rate,\n\t\tMultiAddEndpoint: multiAdd,\n\t\tMultiUpdateEndpoint: multiUpdate,\n\t}\n}", "func newEndpoints() *Endpoints {\n\treturn &Endpoints{\n\t\tBackends: map[string]service.PortConfiguration{},\n\t}\n}", "func NewClient(list, create, show, update, delete_ goa.Endpoint) *Client {\n\treturn &Client{\n\t\tListEndpoint: list,\n\t\tCreateEndpoint: create,\n\t\tShowEndpoint: show,\n\t\tUpdateEndpoint: update,\n\t\tDeleteEndpoint: delete_,\n\t}\n}", "func NewClient(find, list, submit goa.Endpoint) *Client {\n\treturn &Client{\n\t\tFindEndpoint: find,\n\t\tListEndpoint: list,\n\t\tSubmitEndpoint: submit,\n\t}\n}", "func NewCloudEndpointsClient(subscriptionID string) CloudEndpointsClient {\n\treturn NewCloudEndpointsClientWithBaseURI(DefaultBaseURI, subscriptionID)\n}", "func NewClient(add, get, transfer, defaultPhoto, update, listMine, listProject, listAssociated, listProjectAssociated, downloadPhoto, listAll, delete_, adminSearch, progress, updateModule goa.Endpoint) *Client {\n\treturn &Client{\n\t\tAddEndpoint: add,\n\t\tGetEndpoint: get,\n\t\tTransferEndpoint: transfer,\n\t\tDefaultPhotoEndpoint: defaultPhoto,\n\t\tUpdateEndpoint: update,\n\t\tListMineEndpoint: listMine,\n\t\tListProjectEndpoint: listProject,\n\t\tListAssociatedEndpoint: listAssociated,\n\t\tListProjectAssociatedEndpoint: listProjectAssociated,\n\t\tDownloadPhotoEndpoint: downloadPhoto,\n\t\tListAllEndpoint: listAll,\n\t\tDeleteEndpoint: delete_,\n\t\tAdminSearchEndpoint: adminSearch,\n\t\tProgressEndpoint: progress,\n\t\tUpdateModuleEndpoint: updateModule,\n\t}\n}", "func NewClient(endpoints []string) (client.Client, error) {\n\tkey := strings.Join(endpoints, \",\")\n\tif cc, ok := clientCache[key]; ok {\n\t\treturn cc, nil\n\t}\n\n\tvar transport client.CancelableTransport = &http.Transport{\n\t\tProxy: http.ProxyFromEnvironment,\n\t\tDial: (&net.Dialer{\n\t\t\tTimeout: DEFALUT_CLIENT_TIMEOUT,\n\t\t\tKeepAlive: DEFAULT_CLIENT_KEEPALIVE,\n\t\t}).Dial,\n\t\tTLSHandshakeTimeout: DEFALUT_CLIENT_TLS_SHAKE_TIMEOUT,\n\t}\n\n\tcfg := client.Config{\n\t\tEndpoints: endpoints,\n\t\tTransport: transport,\n\t\t// set timeout per request to fail fast when the target endpoint is unavailable\n\t\tHeaderTimeoutPerRequest: time.Second,\n\t}\n\n\tclientNew, err := client.New(cfg)\n\t//03.11 Bug the client state is ok\n\tif err == nil {\n\t\tclientCache[key] = clientNew\n\t}\n\n\treturn clientNew, err\n}", "func NewCloudEndpointsClientWithBaseURI(baseURI string, subscriptionID string) CloudEndpointsClient {\n\treturn CloudEndpointsClient{NewWithBaseURI(baseURI, subscriptionID)}\n}", "func NewClient(query, list, versionsByID, byCatalogKindNameVersion, byCatalogKindNameVersionReadme, byCatalogKindNameVersionYaml, byVersionID, byCatalogKindName, byID, getRawYamlByCatalogKindNameVersion, getLatestRawYamlByCatalogKindName goa.Endpoint) *Client {\n\treturn &Client{\n\t\tQueryEndpoint: query,\n\t\tListEndpoint: list,\n\t\tVersionsByIDEndpoint: versionsByID,\n\t\tByCatalogKindNameVersionEndpoint: byCatalogKindNameVersion,\n\t\tByCatalogKindNameVersionReadmeEndpoint: byCatalogKindNameVersionReadme,\n\t\tByCatalogKindNameVersionYamlEndpoint: byCatalogKindNameVersionYaml,\n\t\tByVersionIDEndpoint: byVersionID,\n\t\tByCatalogKindNameEndpoint: byCatalogKindName,\n\t\tByIDEndpoint: byID,\n\t\tGetRawYamlByCatalogKindNameVersionEndpoint: getRawYamlByCatalogKindNameVersion,\n\t\tGetLatestRawYamlByCatalogKindNameEndpoint: getLatestRawYamlByCatalogKindName,\n\t}\n}", "func New(endpoints []string, ca, cert, key string) (*Client, error) {\n\tclient := Client{Endpoints: endpoints}\n\n\tvar err error\n\tvar tlsConfig *tls.Config\n\tif ca != \"\" || cert != \"\" || key != \"\" {\n\t\ttlsInfo := transport.TLSInfo{\n\t\t\tCertFile: cert,\n\t\t\tKeyFile: key,\n\t\t\tTrustedCAFile: ca,\n\t\t}\n\t\ttlsConfig, err = tlsInfo.ClientConfig()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tclient.newEtcdClient = func(endpoints []string) (etcdClient, error) {\n\t\treturn clientv3.New(clientv3.Config{\n\t\t\tEndpoints: endpoints,\n\t\t\tDialTimeout: etcdTimeout,\n\t\t\tDialOptions: []grpc.DialOption{\n\t\t\t\tgrpc.WithBlock(), // block until the underlying connection is up\n\t\t\t},\n\t\t\tTLS: tlsConfig,\n\t\t})\n\t}\n\n\treturn &client, nil\n}", "func NewClient(refresh, refreshAll, catalogError goa.Endpoint) *Client {\n\treturn &Client{\n\t\tRefreshEndpoint: refresh,\n\t\tRefreshAllEndpoint: refreshAll,\n\t\tCatalogErrorEndpoint: catalogError,\n\t}\n}", "func (flags Etcd) CreateClientEndpoints(sctx *ServiceContext) string {\n\treturn flags.createEndpoints(sctx, defaultEtcdClientPort, nil)\n}", "func NewClient(batchGetWaitEstimates, createWaitlistEntry, getWaitlistEntry, deleteWaitlistEntry goa.Endpoint) *Client {\n\treturn &Client{\n\t\tBatchGetWaitEstimatesEndpoint: batchGetWaitEstimates,\n\t\tCreateWaitlistEntryEndpoint: createWaitlistEntry,\n\t\tGetWaitlistEntryEndpoint: getWaitlistEntry,\n\t\tDeleteWaitlistEntryEndpoint: deleteWaitlistEntry,\n\t}\n}", "func NewEndpoints() *Endpoints {\n\treturn &Endpoints{}\n}", "func NewClient(c *rpc.Client) endpoint.Endpoint {\n\treturn func(ctx context.Context, request interface{}) (interface{}, error) {\n\t\tvar (\n\t\t\terrs = make(chan error, 1)\n\t\t\tresponses = make(chan interface{}, 1)\n\t\t)\n\t\tgo func() {\n\t\t\tvar response reqrep.AddResponse\n\t\t\tif err := c.Call(\"addsvc.Add\", request, &response); err != nil {\n\t\t\t\terrs <- err\n\t\t\t\treturn\n\t\t\t}\n\t\t\tresponses <- response\n\t\t}()\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn nil, context.DeadlineExceeded\n\t\tcase err := <-errs:\n\t\t\treturn nil, err\n\t\tcase response := <-responses:\n\t\t\treturn response, nil\n\t\t}\n\t}\n}", "func New(c rest.Interface) *Clientset {\n\tvar cs Clientset\n\tcs.autoscalingV1alpha1 = autoscalingv1alpha1.New(c)\n\tcs.clusterV1alpha1 = clusterv1alpha1.New(c)\n\tcs.configV1alpha1 = configv1alpha1.New(c)\n\tcs.networkingV1alpha1 = networkingv1alpha1.New(c)\n\tcs.policyV1alpha1 = policyv1alpha1.New(c)\n\tcs.searchV1alpha1 = searchv1alpha1.New(c)\n\tcs.workV1alpha1 = workv1alpha1.New(c)\n\tcs.workV1alpha2 = workv1alpha2.New(c)\n\n\tcs.DiscoveryClient = discovery.NewDiscoveryClient(c)\n\treturn &cs\n}", "func NewClient(endpoint string, options ...Option) *Client {\n\tc := &Client{endpoint: endpoint}\n\n\tfor _, option := range options {\n\t\toption(c)\n\t}\n\n\tif c.httpClient == nil {\n\t\tc.httpClient = http.DefaultClient\n\t}\n\n\treturn c\n}", "func New(c rest.Interface) *Clientset {\n\tvar cs Clientset\n\tcs.propsyV1 = propsyv1.New(c)\n\n\tcs.DiscoveryClient = discovery.NewDiscoveryClient(c)\n\treturn &cs\n}", "func NewEndpoints(c Configuration, alternate func() (Endpoints, error)) (Endpoints, error) {\n\tif endpoints := c.endpoints(); len(endpoints) > 0 {\n\t\treturn ParseURLs(endpoints...)\n\t}\n\n\tif alternate != nil {\n\t\treturn alternate()\n\t}\n\n\treturn nil, errNoConfiguredEndpoints\n}", "func New(c rest.Interface) *Clientset {\n\tvar cs Clientset\n\tcs.policiesV1alpha2 = policiesv1alpha2.New(c)\n\n\tcs.DiscoveryClient = discovery.NewDiscoveryClient(c)\n\treturn &cs\n}", "func NewEndpoints() Endpoints {\n\treturn Endpoints{\n\t\tendpoints: make([]*Endpoint, 0),\n\t\tmapUUID: make(map[string]int),\n\t}\n}", "func NewEndpoints(s Service) Endpoints {\n\treturn endpoints{\n\t\tservice: s,\n\t}\n}", "func New(endpoint string) BaseClient {\n\treturn NewWithoutDefaults(endpoint)\n}", "func New(nodes []string, opts ...Option) (*Client, error) {\n\tvar options Options\n\tfor _, o := range opts {\n\t\to(&options)\n\t}\n\n\tconf := api.DefaultConfig()\n\n\tconf.Scheme = options.Scheme\n\n\tif len(nodes) > 0 {\n\t\tconf.Address = nodes[0]\n\t}\n\n\ttlsConfig := api.TLSConfig{}\n\tif options.TLS.ClientCert != \"\" && options.TLS.ClientKey != \"\" {\n\t\ttlsConfig.CertFile = options.TLS.ClientCert\n\t\ttlsConfig.KeyFile = options.TLS.ClientKey\n\t}\n\n\tif options.TLS.ClientCaKeys != \"\" {\n\t\ttlsConfig.CAFile = options.TLS.ClientCaKeys\n\t}\n\n\tconf.TLSConfig = tlsConfig\n\n\tclient, err := api.NewClient(conf)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Client{client.KV()}, nil\n}", "func NewEndpoints(s Service) *Endpoints {\n\t// Casting service to Auther interface\n\ta := s.(Auther)\n\treturn &Endpoints{\n\t\tDataEventsEndpoint: NewDataEventsEndpointEndpoint(s, a.JWTAuth),\n\t\tAddDataEvent: NewAddDataEventEndpoint(s, a.JWTAuth),\n\t\tUpdateDataEvent: NewUpdateDataEventEndpoint(s, a.JWTAuth),\n\t\tDeleteDataEvent: NewDeleteDataEventEndpoint(s, a.JWTAuth),\n\t}\n}", "func NewClient(healthcheck, listDevices, createDevice, updateCharge, getChargeHistory, updateDevice goa.Endpoint) *Client {\n\treturn &Client{\n\t\tHealthcheckEndpoint: healthcheck,\n\t\tListDevicesEndpoint: listDevices,\n\t\tCreateDeviceEndpoint: createDevice,\n\t\tUpdateChargeEndpoint: updateCharge,\n\t\tGetChargeHistoryEndpoint: getChargeHistory,\n\t\tUpdateDeviceEndpoint: updateDevice,\n\t}\n}", "func NewDataFlowClient(endpoint string) DataFlowClient {\n\treturn DataFlowClient{New(endpoint)}\n}", "func NewEndpoints(s Service) *Endpoints {\n\treturn &Endpoints{\n\t\tDomains: NewDomainsEndpoint(s),\n\t}\n}", "func New(opts ...Option) *Client {\n\tc := defaultCfg()\n\n\tfor _, opt := range opts {\n\t\topt(c)\n\t}\n\n\treturn &Client{\n\t\tcfg: c,\n\t}\n}", "func New(endpoint string) *Client {\n\treturn &Client{\n\t\tendpoint: endpoint,\n\t}\n}", "func NewClient(health, deposit, withdraw, transfer, balance, adminWallets goa.Endpoint) *Client {\n\treturn &Client{\n\t\tHealthEndpoint: health,\n\t\tDepositEndpoint: deposit,\n\t\tWithdrawEndpoint: withdraw,\n\t\tTransferEndpoint: transfer,\n\t\tBalanceEndpoint: balance,\n\t\tAdminWalletsEndpoint: adminWallets,\n\t}\n}", "func New(minLat, maxLat, minLong, maxLong float64) Client {\n\treturn Client{\n\t\tminLat: minLat,\n\t\tmaxLat: maxLat,\n\t\tminLong: minLong,\n\t\tmaxLong: maxLong,\n\t}\n}", "func NewClient(confs ...ClientConfiguration) *Client {\n\tq := setupClient()\n\n\t// Loop through the configurations and apply them to the client.\n\tfor _, c := range confs {\n\t\tc(q)\n\t}\n\n\treturn q\n}", "func MakeClientEndpoints(instance string) (Endpoints, error) {\n\n\t// Check to see if the url passed is NOT prefixed with http\n\tif !strings.HasPrefix(instance, \"http\") {\n\n\t\t// Prepend http to the passed in URL\n\t\tinstance = fmt.Sprintf(\"http://%s\", instance)\n\t}\n\n\t// Create a new value of type URL based on the instance string passed.\n\ttgt, err := url.Parse(instance)\n\n\t// Check to see if err is nil\n\tif err != nil {\n\t\t// Panic!\n\t\tpanic(err)\n\t}\n\n\t// Clear the URL (tgt) Path field. Warning: I am not sure why we do this...\n\ttgt.Path = \"\"\n\n\toptions := []httptransport.ClientOption{}\n\n\t// Create an Endpoionts struct literal.\n\t// This is done by creating a new GoKit client for each Endpoint. Then using the Endpoint method\n\treturn Endpoints{\n\t\tPostProfileEndpoint: httptransport.NewClient(\"POST\", tgt, encReqPostProfile, decRespPostProfile, options...).Endpoint(),\n\t\tGetProfileEndpoint: httptransport.NewClient(\"GET\", tgt, encReqGetProfile, decRespGetProfile, options...).Endpoint(),\n\t\tPutProfileEndpoint: httptransport.NewClient(\"PUT\", tgt, encReqPutProfile, decRespPutProfile, options...).Endpoint(),\n\t\tPatchProfileEndpoint: httptransport.NewClient(\"PATCH\", tgt, encReqPatchProfile, decRespPatchProfile, options...).Endpoint(),\n\t\tDeleteProfileEndpoint: httptransport.NewClient(\"DELETE\", tgt, encReqDeleteProfile, decRespDeleteProfile, options...).Endpoint(),\n\t\tGetAddressesEndpoint: httptransport.NewClient(\"GET\", tgt, encReqGetAddresses, decRespGetAddresses, options...).Endpoint(),\n\t\tGetAddressEndpoint: httptransport.NewClient(\"GET\", tgt, encReqGetAddress, decRespGetAddress, options...).Endpoint(),\n\t\tPostAddressEndpoint: httptransport.NewClient(\"POST\", tgt, encReqPostAddress, decRespPostAddress, options...).Endpoint(),\n\t\tDeleteAddressEndpoint: httptransport.NewClient(\"DELETE\", tgt, encReqDeleteAddress, decRespDeleteAddress, options...).Endpoint(),\n\t}, nil\n}", "func newClient(cfg upspin.Config, server, cache *upspin.Endpoint) (upspin.Config, upspin.Client) {\n\tcfg = setCertPool(cfg)\n\tcfg = config.SetStoreEndpoint(cfg, *server)\n\tcfg = config.SetDirEndpoint(cfg, *server)\n\tcfg = config.SetCacheEndpoint(cfg, *cache)\n\treturn cfg, client.New(cfg)\n}", "func New(opts ...Opt) *Client {\n\tc := &Client{\n\t\tendpoint: DefaultEndpoint,\n\t\tprotocol: DefaultProtocol,\n\t\thttpClient: DefaultHTTPClient,\n\t}\n\n\tfor _, opt := range opts {\n\t\topt(c)\n\t}\n\treturn c\n}", "func NewClient(endpoint string, opts ...ClientOption) *Client {\n\tc := &Client{\n\t\tendpoint: endpoint,\n\t\tLog: func(string) {},\n\t}\n\tfor _, optionFunc := range opts {\n\t\toptionFunc(c)\n\t}\n\tif c.httpClient == nil {\n\t\tc.httpClient = http.DefaultClient\n\t}\n\treturn c\n}", "func NewClient(endPoint, id, key string) (*Client, error) {\n\treturn &Client{endPoint, id, key, \"\", false}, nil\n}", "func NewEndpoints(s Service) *Endpoints {\n\treturn &Endpoints{\n\t\tList: NewListEndpoint(s),\n\t\tGet: NewGetEndpoint(s),\n\t\tRandomFacts: NewRandomFactsEndpoint(s),\n\t}\n}", "func NewEndpoints(endpoint string) (*Endpoints, error) {\n\tif endpoint == \"\" {\n\t\treturn nil, fmt.Errorf(\"endpoint is required\")\n\t}\n\tep, err := url.Parse(endpoint)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\troles, err := urlJoin(ep, \"roles\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tusers, err := urlJoin(ep, \"users\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tinputs, err := urlJoin(ep, \"system/inputs\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tindexSets, err := urlJoin(ep, \"system/indices/index_sets\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tindexSetStats, err := urlJoin(indexSets, \"stats\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tstreams, err := urlJoin(ep, \"streams\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tenabledStreams, err := urlJoin(streams, \"enabled\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\talertConditions, err := urlJoin(ep, \"alerts/conditions\")\n\treturn &Endpoints{\n\t\troles: roles,\n\t\tusers: users,\n\t\tinputs: inputs,\n\t\tindexSets: indexSets,\n\t\tindexSetStats: indexSetStats,\n\t\tstreams: streams,\n\t\tenabledStreams: enabledStreams,\n\t\talertConditions: alertConditions,\n\t}, nil\n}", "func NewClientEndpoints() []*api.Endpoint {\n\treturn []*api.Endpoint{}\n}", "func NewClient(ctx context.Context, dInfo *backend.DataSourceInstanceSettings) (*Client, error) {\n\tc := Client{}\n\tvar err error\n\tc.dataSourceData, err = newDataSourceData(dInfo)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tconf := clientcredentials.Config{\n\t\tClientID: c.ClientID,\n\t\tClientSecret: c.Secret,\n\t\tTokenURL: microsoft.AzureADEndpoint(c.TenantID).TokenURL,\n\t\tScopes: []string{\"https://kusto.kusto.windows.net/.default\"},\n\t}\n\n\t// I hope this correct? The goal is to have a timeout for the\n\t// the client that talks to the actual Data explorer API.\n\t// One can attach a a variable, oauth2.HTTPClient, to the context of conf.Client(),\n\t// but that is the timeout for the token retrieval I believe.\n\t// https://github.com/golang/oauth2/issues/206\n\t// https://github.com/golang/oauth2/issues/368\n\tauthClient := oauth2.NewClient(ctx, conf.TokenSource(ctx))\n\n\tc.Client = &http.Client{\n\t\tTransport: authClient.Transport,\n\t\t// We add five seconds to the timeout so the client does not timeout before the server.\n\t\t// This is because the QueryTimeout property is used to set the server execution timeout\n\t\t// for queries. The server execution timeout does not apply to retrieving data, so when\n\t\t// a query returns a large amount of data, timeouts will still occur while the data is\n\t\t// being downloaded.\n\t\t// In the future, if we get the timeout value from Grafana's data source proxy setting, we\n\t\t// may have to flip this to subtract time.\n\t\tTimeout: c.dataSourceData.QueryTimeout + 5*time.Second,\n\t}\n\n\treturn &c, nil\n}", "func NewClient(getLicense, updateDeviceLicense, updateDeviceLicenseWithValue goa.Endpoint) *Client {\n\treturn &Client{\n\t\tGetLicenseEndpoint: getLicense,\n\t\tUpdateDeviceLicenseEndpoint: updateDeviceLicense,\n\t\tUpdateDeviceLicenseWithValueEndpoint: updateDeviceLicenseWithValue,\n\t}\n}", "func NewEndpoints(s Service) *Endpoints {\n\treturn &Endpoints{\n\t\tAdd: NewAddEndpoint(s),\n\t}\n}", "func New(endpoint string) *Client {\n\treturn &Client{endpoint, &http.Client{}, \"\"}\n}", "func New(opts ...ClientOpt) (*Client, error) {\n\tc := NewClient()\n\tfor _, opt := range opts {\n\t\tif err := opt(c); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn c, nil\n}", "func New(opts ...FnOption) (c Client, err error) {\n\to := new(Option).Assign(opts...).Default()\n\terr = o.Validate()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tc = (new(client)).Assign(o)\n\treturn\n}", "func NewDataClient(conf *DataClientConfig) (*DataClient, error) {\n\t// TODO: Don't hardcode region\n\tsess, err := session.NewSession(&aws.Config{\n\t\tCredentials: conf.Credentials,\n\t\tRegion: aws.String(nerd.GetCurrentUser().Region),\n\t})\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"could not create AWS sessions\")\n\t}\n\treturn &DataClient{\n\t\tSession: sess,\n\t\tService: s3.New(sess),\n\t\tDataClientConfig: conf,\n\t}, nil\n}", "func NewEndpoints(s Service) *Endpoints {\n\treturn &Endpoints{\n\t\tAdd: NewAddEndpoint(s),\n\t\tResta: NewRestaEndpoint(s),\n\t\tMultiplicacion: NewMultiplicacionEndpoint(s),\n\t\tDivision: NewDivisionEndpoint(s),\n\t}\n}", "func NewEndpointSlice(l log.Logger, eps cache.SharedIndexInformer, svc, pod, node cache.SharedInformer) *EndpointSlice {\n\tif l == nil {\n\t\tl = log.NewNopLogger()\n\t}\n\te := &EndpointSlice{\n\t\tlogger: l,\n\t\tendpointSliceInf: eps,\n\t\tendpointSliceStore: eps.GetStore(),\n\t\tserviceInf: svc,\n\t\tserviceStore: svc.GetStore(),\n\t\tpodInf: pod,\n\t\tpodStore: pod.GetStore(),\n\t\tnodeInf: node,\n\t\twithNodeMetadata: node != nil,\n\t\tqueue: workqueue.NewNamed(\"endpointSlice\"),\n\t}\n\n\t_, err := e.endpointSliceInf.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: func(o interface{}) {\n\t\t\tepslAddCount.Inc()\n\t\t\te.enqueue(o)\n\t\t},\n\t\tUpdateFunc: func(_, o interface{}) {\n\t\t\tepslUpdateCount.Inc()\n\t\t\te.enqueue(o)\n\t\t},\n\t\tDeleteFunc: func(o interface{}) {\n\t\t\tepslDeleteCount.Inc()\n\t\t\te.enqueue(o)\n\t\t},\n\t})\n\tif err != nil {\n\t\tlevel.Error(l).Log(\"msg\", \"Error adding endpoint slices event handler.\", \"err\", err)\n\t}\n\n\tserviceUpdate := func(o interface{}) {\n\t\tsvc, err := convertToService(o)\n\t\tif err != nil {\n\t\t\tlevel.Error(e.logger).Log(\"msg\", \"converting to Service object failed\", \"err\", err)\n\t\t\treturn\n\t\t}\n\n\t\t// TODO(brancz): use cache.Indexer to index endpoints by\n\t\t// disv1beta1.LabelServiceName so this operation doesn't have to\n\t\t// iterate over all endpoint objects.\n\t\tfor _, obj := range e.endpointSliceStore.List() {\n\t\t\tesa, err := e.getEndpointSliceAdaptor(obj)\n\t\t\tif err != nil {\n\t\t\t\tlevel.Error(e.logger).Log(\"msg\", \"converting to EndpointSlice object failed\", \"err\", err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif lv, exists := esa.labels()[esa.labelServiceName()]; exists && lv == svc.Name {\n\t\t\t\te.enqueue(esa.get())\n\t\t\t}\n\t\t}\n\t}\n\t_, err = e.serviceInf.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\tAddFunc: func(o interface{}) {\n\t\t\tsvcAddCount.Inc()\n\t\t\tserviceUpdate(o)\n\t\t},\n\t\tUpdateFunc: func(_, o interface{}) {\n\t\t\tsvcUpdateCount.Inc()\n\t\t\tserviceUpdate(o)\n\t\t},\n\t\tDeleteFunc: func(o interface{}) {\n\t\t\tsvcDeleteCount.Inc()\n\t\t\tserviceUpdate(o)\n\t\t},\n\t})\n\tif err != nil {\n\t\tlevel.Error(l).Log(\"msg\", \"Error adding services event handler.\", \"err\", err)\n\t}\n\n\tif e.withNodeMetadata {\n\t\t_, err = e.nodeInf.AddEventHandler(cache.ResourceEventHandlerFuncs{\n\t\t\tAddFunc: func(o interface{}) {\n\t\t\t\tnode := o.(*apiv1.Node)\n\t\t\t\te.enqueueNode(node.Name)\n\t\t\t},\n\t\t\tUpdateFunc: func(_, o interface{}) {\n\t\t\t\tnode := o.(*apiv1.Node)\n\t\t\t\te.enqueueNode(node.Name)\n\t\t\t},\n\t\t\tDeleteFunc: func(o interface{}) {\n\t\t\t\tnode := o.(*apiv1.Node)\n\t\t\t\te.enqueueNode(node.Name)\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\tlevel.Error(l).Log(\"msg\", \"Error adding nodes event handler.\", \"err\", err)\n\t\t}\n\t}\n\n\treturn e\n}", "func NewClient(user string, password string, url string, port string, database string, collection string) (*mongo.Collection, error) {\n\tconnectionUrl := \"mongodb://\" + user + \":\" + password + \"@\" + url + \":\" + port\n\tclientOpts := options.Client().ApplyURI(connectionUrl)\n\tclient, err := mongo.Connect(context.TODO(), clientOpts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tc := client.Database(database).Collection(collection)\n\treturn c, nil\n}", "func newClient(opts *ClientOpts) (*Client, error) {\n\tbaseClient, err := newAPIClient(opts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient := &Client{\n\t\tAPIClient: *baseClient,\n\t}\n\n\t// init base operator\n\tclient.Node = newNodeClient(client)\n\tclient.Namespace = newNameSpaceClient(client)\n\tclient.ConfigMap = newConfigMapClient(client)\n\tclient.Service = newServiceClient(client)\n\tclient.Pod = newPodClient(client)\n\tclient.ReplicationController = newReplicationControllerClient(client)\n\tclient.StatefulSet = newStatefulSetClient(client)\n\tclient.DaemonSet = newDaemonSetClient(client)\n\tclient.Deployment = newDeploymentClient(client)\n\tclient.ReplicaSet = newReplicaSetClient(client)\n\n\treturn client, nil\n}", "func New(instance string, options ...ClientOption) (pb.UsersServer, error) {\n\tvar cc clientConfig\n\n\tfor _, f := range options {\n\t\terr := f(&cc)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"cannot apply option\")\n\t\t}\n\t}\n\n\tif !strings.HasPrefix(instance, \"http\") {\n\t\tinstance = \"http://\" + instance\n\t}\n\tu, err := url.Parse(instance)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t_ = u\n\n\tpanic(\"No HTTP Endpoints, this client will not work, define bindings in your proto definition\")\n\n\treturn svc.Endpoints{}, nil\n}", "func NewEndpoints(s Service) *Endpoints {\n\t// Casting service to Auther interface\n\ta := s.(Auther)\n\treturn &Endpoints{\n\t\tList: NewListEndpoint(s),\n\t\tReserve: NewReserveEndpoint(s, a.JWTAuth),\n\t\tPickup: NewPickupEndpoint(s, a.JWTAuth),\n\t\tReturn: NewReturnEndpoint(s, a.JWTAuth),\n\t\tSubscribe: NewSubscribeEndpoint(s, a.JWTAuth),\n\t}\n}", "func NewData(g func(ctx context.Context) (*grpc.ClientConn, error)) *Data {\n\treturn &Data{g}\n}", "func NewClient(concat goa.Endpoint) *Client {\n\treturn &Client{\n\t\tConcatEndpoint: concat,\n\t}\n}", "func New(c rest.Interface) *Clientset {\n\tvar cs Clientset\n\tcs.testsV1alpha1 = testsv1alpha1.New(c)\n\n\tcs.DiscoveryClient = discovery.NewDiscoveryClient(c)\n\treturn &cs\n}", "func NewClient(name string, initAddrs ...string) (*Client, error) {\n\tc := new(Client)\n\n\tlog.Debugf(\"pd-client: initial pds, pds=<%v>\",\n\t\tinitAddrs)\n\n\tc.name = name\n\tc.addrs = append(c.addrs, initAddrs...)\n\tc.seq = 0\n\n\terr := c.resetConn()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn c, nil\n}", "func NewClient(endpoint string, headers map[string]string) *Client {\n\treturn &Client{\n\t\tEndpoint: endpoint,\n\t\tHeaders: headers,\n\t\tclient: &http.Client{},\n\t}\n}", "func NewEndpoints(s Service) *Endpoints {\n\treturn &Endpoints{\n\t\tShow: NewShowEndpoint(s),\n\t\tPlainList0: NewPlainList0Endpoint(s),\n\t\tPlainList1: NewPlainList1Endpoint(s),\n\t\tList0: NewList0Endpoint(s),\n\t\tList1: NewList1Endpoint(s),\n\t\tList2: NewList2Endpoint(s),\n\t\tList3: NewList3Endpoint(s),\n\t}\n}", "func New(c rest.Interface) *Clientset {\n\tvar cs Clientset\n\tcs.scalerV1alpha1 = scalerv1alpha1.New(c)\n\tcs.sparkschedulerV1beta1 = sparkschedulerv1beta1.New(c)\n\n\tcs.DiscoveryClient = discovery.NewDiscoveryClient(c)\n\treturn &cs\n}", "func New(client *httpclient.Client, baseURL string) Data {\n\td := Data{\n\t\tclient: client,\n\t\tbaseURL: baseURL,\n\t}\n\n\treturn d\n}", "func New(c rest.Interface) *Clientset {\n\tvar cs Clientset\n\tcs.ApiextensionsV1beta1Client = apiextensionsv1beta1.New(c)\n\tcs.ConfigV1alpha1Client = configv1alpha1.New(c)\n\tcs.LoadbalanceV1alpha2Client = loadbalancev1alpha2.New(c)\n\tcs.ReleaseV1alpha1Client = releasev1alpha1.New(c)\n\tcs.ResourceV1alpha1Client = resourcev1alpha1.New(c)\n\tcs.ResourceV1beta1Client = resourcev1beta1.New(c)\n\n\tcs.Clientset = kubernetes.New(c)\n\treturn &cs\n}", "func (c *Client) New() goa.Endpoint {\n\tvar (\n\t\tdecodeResponse = DecodeNewResponse(c.decoder, c.RestoreResponseBody)\n\t)\n\treturn func(ctx context.Context, v interface{}) (interface{}, error) {\n\t\treq, err := c.BuildNewRequest(ctx, v)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresp, err := c.NewDoer.Do(req)\n\t\tif err != nil {\n\t\t\treturn nil, goahttp.ErrRequestError(\"spin-broker\", \"new\", err)\n\t\t}\n\t\treturn decodeResponse(resp)\n\t}\n}", "func New(context *contexter.Context) (*Client) {\n return &Client {\n urlBaseIndex: 0,\n\t\tcontext: context,\n }\n}", "func New(opt ...Option) Client {\n\n\topts := &Options{}\n\tfor _, o := range opt {\n\t\to(opts)\n\t}\n\n\treturn &defaultClient {\n\t\topts: opts,\n\t\tTransport: transport.DefaultClientTransport,\n\t}\n}", "func New(endpoint string) (*Client, error) {\n\tservers, err := clusterNodes(endpoint)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tss := new(memcache.ServerList)\n\tif err := ss.SetServers(servers...); err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient := &Client{\n\t\tClient: memcache.NewFromSelector(ss),\n\t\tServerList: ss,\n\t\tEndpoint: endpoint,\n\t}\n\n\treturn client, nil\n}", "func NewEndpoints(s Service) *Endpoints {\n\treturn &Endpoints{\n\t\tHello: NewHelloEndpoint(s),\n\t}\n}", "func NewClient(d *schema.ResourceData, terraformVersion string, options client.Options) (client.Client, error) {\n\t// Config initialization\n\tcfg, err := GetConfig(d, terraformVersion)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn client.New(cfg, options)\n}", "func (cfg *Config) newClient(args []interface{}) (connector endpoint.Connector, err error) {\n\n\tvar clientArgs *newClientArgs\n\tclientArgs, err = getNewClientArguments(args)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar connectionTrustBundle *x509.CertPool\n\n\tif cfg.ConnectionTrust != \"\" {\n\t\tlog.Println(\"You specified a trust bundle.\")\n\t\tconnectionTrustBundle = x509.NewCertPool()\n\t\tif !connectionTrustBundle.AppendCertsFromPEM([]byte(cfg.ConnectionTrust)) {\n\t\t\treturn nil, fmt.Errorf(\"%w: failed to parse PEM trust bundle\", verror.UserDataError)\n\t\t}\n\t}\n\n\tswitch cfg.ConnectorType {\n\tcase endpoint.ConnectorTypeCloud:\n\t\tconnector, err = cloud.NewConnector(cfg.BaseUrl, cfg.Zone, cfg.LogVerbose, connectionTrustBundle)\n\tcase endpoint.ConnectorTypeTPP:\n\t\tconnector, err = tpp.NewConnector(cfg.BaseUrl, cfg.Zone, cfg.LogVerbose, connectionTrustBundle)\n\tcase endpoint.ConnectorTypeFirefly:\n\t\tconnector, err = firefly.NewConnector(cfg.BaseUrl, cfg.Zone, cfg.LogVerbose, connectionTrustBundle)\n\tcase endpoint.ConnectorTypeFake:\n\t\tconnector = fake.NewConnector(cfg.LogVerbose, connectionTrustBundle)\n\tdefault:\n\t\terr = fmt.Errorf(\"%w: ConnectorType is not defined\", verror.UserDataError)\n\t}\n\tif err != nil {\n\t\treturn\n\t}\n\n\tconnector.SetZone(cfg.Zone)\n\tconnector.SetHTTPClient(cfg.Client)\n\n\tif clientArgs.authenticate {\n\t\terr = connector.Authenticate(cfg.Credentials)\n\t}\n\n\treturn\n}", "func NewClient(config *config.Config) *Client {\n\tclient := &Client{\n\t\tConfig: config,\n\t\telbv2Svc: map[string]*elbv2.ELBV2{},\n\t\tecsSvc: map[string]*ecs.ECS{},\n\t}\n\n\tfor service := range config.Services {\n\t\tsession := session.New(&aws.Config{\n\t\t\tRegion: aws.String(config.GetRegion(service)),\n\t\t})\n\n\t\tclient.elbv2Svc[service] = elbv2.New(session)\n\t\tclient.ecsSvc[service] = ecs.New(session)\n\t}\n\n\treturn client\n}", "func NewClient(endpoint string) *Client {\n\treturn &Client{\n\t\tendpoint: endpoint,\n\t}\n}", "func New(endpoint string) *EcomClient {\n\ttr := &http.Transport{\n\t\tMaxIdleConnsPerHost: 10,\n\t}\n\tclient := &http.Client{\n\t\tTransport: tr,\n\t\tTimeout: timeout,\n\t}\n\n\turl, err := url.Parse(endpoint)\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"%+v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\n\treturn &EcomClient{\n\t\tendpoint: endpoint,\n\t\tscheme: url.Scheme,\n\t\thostname: url.Host,\n\t\tport: url.Port(),\n\t\tclient: client,\n\t}\n}", "func NewEndpoints(s Service) *Endpoints {\n\treturn &Endpoints{\n\t\tUpload: NewUploadEndpoint(s),\n\t\tDownload: NewDownloadEndpoint(s),\n\t}\n}", "func NewClient(name string, configuration map[string]string, nodeLister corelistersv1.NodeLister) (autoscaling.Engine, error) {\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"name must be provided\")\n\t}\n\n\tif nodeLister == nil {\n\t\treturn nil, errors.New(\"node lister must be provided\")\n\t}\n\n\tconfig := cloudConfig{}\n\tif err := config.defaultAndValidate(configuration); err != nil {\n\t\treturn nil, errors.Wrap(err, \"validating configuration\")\n\t}\n\n\ttoken := os.Getenv(config.TokenEnvVarName)\n\toauthClient := oauth2.NewClient(oauth2.NoContext, &tokenSource{\n\t\tAccessToken: token,\n\t})\n\tdoClient, err := godo.New(oauthClient)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"creating godo client\")\n\t}\n\n\te := Engine{\n\t\tname: name,\n\t\tnodeLister: nodeLister,\n\t\tconfig: &config,\n\t\tclient: doClient,\n\t}\n\n\treturn e, nil\n}", "func New(endpoint *url.URL, client *http.Client) *Client {\n\tif client == nil {\n\t\tclient = httpClient\n\t}\n\n\tif len(endpoint.Path) > 0 && !strings.HasSuffix(endpoint.Path, \"/\") {\n\t\tendpoint.Path = endpoint.Path + \"/\"\n\t}\n\n\treturn &Client{client, endpoint, make(http.Header), endpoint.Query()}\n}", "func NewEndpoints(s Service) *Endpoints {\n\t// Casting service to Auther interface\n\ta := s.(Auther)\n\treturn &Endpoints{\n\t\tLogin: NewLoginEndpoint(s),\n\t\tUpdatePassword: NewUpdatePasswordEndpoint(s, a.JWTAuth),\n\t\tCaptchaImage: NewCaptchaImageEndpoint(s),\n\t}\n}", "func newClient(origin, ignoreDestCSV, excludeSecretsCSV string) (*client, error) {\n\tconfig, err := rest.InClusterConfig()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load in-cluster config: %s\", err)\n\t}\n\n\tclientset, err := kubernetes.NewForConfig(config)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load clientset: %s\", err)\n\t}\n\n\tsv := strings.Split(ignoreDestCSV, \",\")\n\tignoreDests := map[string]int{\n\t\torigin: 0, // ignore origin\n\t}\n\tfor _, dest := range sv {\n\t\tignoreDests[dest] = 0 // meaningless value\n\t}\n\n\tes := strings.Split(excludeSecretsCSV, \",\")\n\texcludeSecrets := make(map[string]struct{}, len(es))\n\tfor _, secret := range es {\n\t\texcludeSecrets[secret] = struct{}{}\n\t}\n\n\treturn &client{\n\t\tclientset: clientset,\n\t\torigin: origin,\n\t\tignoreDests: ignoreDests,\n\t\texcludeSecrets: excludeSecrets,\n\t}, nil\n}", "func NewEndpoints(s service.Service) Endpoints {\n\treturn Endpoints{\n\t\tGenerateEndpoint: MakeGenerateEndpoint(s),\n\t\tVerifyEndpoint: MakeVerifyEndpoint(s),\n\t}\n}", "func NewNODES(config configuration.CONFIGURATION) *NODES_IMPL {\r\n client := new(NODES_IMPL)\r\n client.config = config\r\n return client\r\n}", "func NewEndpoints(s Service) *Endpoints {\n\t// Casting service to Auther interface\n\ta := s.(Auther)\n\treturn &Endpoints{\n\t\tListen: NewListenEndpoint(s),\n\t\tSeen: NewSeenEndpoint(s, a.JWTAuth),\n\t}\n}", "func New() datastore.Datastore {\n\tctx := context.Background()\n\n\tc, err := fc.New(ctx)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\treturn &client{\n\t\tfirestoreClient: c,\n\t\tctx: ctx,\n\t}\n}", "func NewEndpoints(s service.Service) Endpoints {\n\treturn Endpoints{\n\t\tAllEndpoint: MakeAllEndpoint(s),\n\t\tGetEndpoint: MakeGetEndpoint(s),\n\t}\n}", "func NewClient(batchAvailabilityLookup, checkAvailability, createBooking, updateBooking, getBookingStatus, listBookings goa.Endpoint) *Client {\n\treturn &Client{\n\t\tBatchAvailabilityLookupEndpoint: batchAvailabilityLookup,\n\t\tCheckAvailabilityEndpoint: checkAvailability,\n\t\tCreateBookingEndpoint: createBooking,\n\t\tUpdateBookingEndpoint: updateBooking,\n\t\tGetBookingStatusEndpoint: getBookingStatus,\n\t\tListBookingsEndpoint: listBookings,\n\t}\n}", "func NewEndpointsAdapter(endpointClient corev1client.EndpointsGetter, endpointSliceClient discoveryclient.EndpointSlicesGetter) EndpointsAdapter {\n\treturn EndpointsAdapter{\n\t\tendpointClient: endpointClient,\n\t\tendpointSliceClient: endpointSliceClient,\n\t}\n}", "func New(opts ...Option) Client {\n\treturn newClient(opts...)\n}", "func NewClient(endpoint string) *Client {\n\tc := &Client{\n\t\tendpoint: endpoint,\n\t}\n\n\tif c.httpClient == nil {\n\t\tc.httpClient = http.DefaultClient\n\t}\n\treturn c\n}", "func NewEndpointsBuilder(nn NamespacedName) *EndpointsBuilder {\n\treturn &EndpointsBuilder{\n\t\tObjectBuilder: ObjectBuilder{\n\t\t\tName: nn.Name,\n\t\t\tNamespace: nn.Namespace,\n\t\t},\n\t}\n}", "func NewClient(elastic *elasticsearch.Client, usersIndex string) Client {\n\treturn &client{\n\t\telastic: elastic,\n\t\tusersIndex: usersIndex,\n\t}\n}", "func New(opts ...ClientOption) *Client {\n\tcl := newDefaultClient()\n\tcl.opts = opts\n\treturn cl\n}", "func NewEndpoints(s Service) *Endpoints {\n\treturn &Endpoints{\n\t\tGetPerson: NewGetPersonEndpoint(s),\n\t\tGetFam: NewGetFamEndpoint(s),\n\t}\n}", "func New(options Options, optFns ...func(*Options)) *Client {\n\toptions = options.Copy()\n\n\tresolveRetryer(&options)\n\n\tresolveHTTPClient(&options)\n\n\tresolveHTTPSignerV4(&options)\n\n\tresolveDefaultEndpointConfiguration(&options)\n\n\tresolveIdempotencyTokenProvider(&options)\n\n\tfor _, fn := range optFns {\n\t\tfn(&options)\n\t}\n\n\tclient := &Client{\n\t\toptions: options,\n\t}\n\n\treturn client\n}", "func NewEndpoints(s Service) *Endpoints {\n\t// Casting service to Auther interface\n\ta := s.(Auther)\n\treturn &Endpoints{\n\t\tDeviceLayout: NewDeviceLayoutEndpoint(s, a.JWTAuth),\n\t\tFirmwareStatistics: NewFirmwareStatisticsEndpoint(s, a.JWTAuth),\n\t}\n}", "func NewClient(login, echoer, listener, summary, subscribe, history goa.Endpoint) *Client {\n\treturn &Client{\n\t\tLoginEndpoint: login,\n\t\tEchoerEndpoint: echoer,\n\t\tListenerEndpoint: listener,\n\t\tSummaryEndpoint: summary,\n\t\tSubscribeEndpoint: subscribe,\n\t\tHistoryEndpoint: history,\n\t}\n}", "func newClient(auth azure.Authorizer) *azureClient {\n\treturn &azureClient{\n\t\tscalesetvms: newVirtualMachineScaleSetVMsClient(auth.SubscriptionID(), auth.BaseURI(), auth.Authorizer()),\n\t}\n}", "func NewClient(userNumber goa.Endpoint) *Client {\n\treturn &Client{\n\t\tUserNumberEndpoint: userNumber,\n\t}\n}" ]
[ "0.78429055", "0.65928674", "0.6467306", "0.6371158", "0.6291373", "0.62236565", "0.6148884", "0.6108226", "0.6043531", "0.60381436", "0.5991876", "0.59719115", "0.59348714", "0.59159476", "0.5858524", "0.5855671", "0.5831717", "0.5796945", "0.57908535", "0.5731177", "0.57162124", "0.5708438", "0.56894124", "0.5667736", "0.56500477", "0.56382746", "0.5622743", "0.5607495", "0.5568469", "0.5566295", "0.5530855", "0.55303735", "0.5521091", "0.5521008", "0.5520811", "0.55141526", "0.5509746", "0.5509713", "0.55080223", "0.54967827", "0.54922587", "0.548692", "0.5485816", "0.5481582", "0.5470637", "0.5468866", "0.5458624", "0.5444008", "0.5426375", "0.54000676", "0.5386357", "0.5383668", "0.5374549", "0.5370227", "0.53632796", "0.5355299", "0.5349449", "0.53491503", "0.5349049", "0.53461677", "0.53454846", "0.5329189", "0.53289175", "0.532483", "0.5323494", "0.5319438", "0.5313296", "0.5312849", "0.53125197", "0.53039765", "0.530382", "0.5298185", "0.52960557", "0.52931035", "0.5291836", "0.5291242", "0.5290988", "0.5288229", "0.52833396", "0.5280621", "0.5280546", "0.5279304", "0.5279272", "0.52773446", "0.52746236", "0.52729416", "0.527113", "0.52706474", "0.5267493", "0.52572876", "0.5253182", "0.5252361", "0.5245604", "0.5241389", "0.52360284", "0.5235561", "0.52337164", "0.52333206", "0.5230812", "0.5225965" ]
0.7870675
0
createHandleResponse handles the Create response.
createHandleResponse обрабатывает ответ Create.
func (client *DataCollectionEndpointsClient) createHandleResponse(resp *http.Response) (DataCollectionEndpointsCreateResponse, error) { result := DataCollectionEndpointsCreateResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.DataCollectionEndpointResource); err != nil { return DataCollectionEndpointsCreateResponse{}, runtime.NewResponseError(err, resp) } return result, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *CustomAssessmentAutomationsClient) createHandleResponse(resp *http.Response) (CustomAssessmentAutomationsCreateResponse, error) {\n\tresult := CustomAssessmentAutomationsCreateResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.CustomAssessmentAutomation); err != nil {\n\t\treturn CustomAssessmentAutomationsCreateResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ContainerClient) createHandleResponse(resp *http.Response) (ContainerClientCreateResponse, error) {\n\tresult := ContainerClientCreateResponse{}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = (*azcore.ETag)(&val)\n\t}\n\tif val := resp.Header.Get(\"Last-Modified\"); val != \"\" {\n\t\tlastModified, err := time.Parse(time.RFC1123, val)\n\t\tif err != nil {\n\t\t\treturn ContainerClientCreateResponse{}, err\n\t\t}\n\t\tresult.LastModified = &lastModified\n\t}\n\tif val := resp.Header.Get(\"x-ms-client-request-id\"); val != \"\" {\n\t\tresult.ClientRequestID = &val\n\t}\n\tif val := resp.Header.Get(\"x-ms-request-id\"); val != \"\" {\n\t\tresult.RequestID = &val\n\t}\n\tif val := resp.Header.Get(\"x-ms-version\"); val != \"\" {\n\t\tresult.Version = &val\n\t}\n\tif val := resp.Header.Get(\"Date\"); val != \"\" {\n\t\tdate, err := time.Parse(time.RFC1123, val)\n\t\tif err != nil {\n\t\t\treturn ContainerClientCreateResponse{}, err\n\t\t}\n\t\tresult.Date = &date\n\t}\n\treturn result, nil\n}", "func (client *ActionsClient) createOrUpdateHandleResponse(resp *http.Response) (ActionsClientCreateOrUpdateResponse, error) {\n\tresult := ActionsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ActionResponse); err != nil {\n\t\treturn ActionsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DataCollectionEndpointsClient) createHandleResponse(resp *http.Response) (DataCollectionEndpointsClientCreateResponse, error) {\n\tresult := DataCollectionEndpointsClientCreateResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DataCollectionEndpointResource); err != nil {\n\t\treturn DataCollectionEndpointsClientCreateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *SpatialAnchorsAccountsClient) createHandleResponse(resp *http.Response) (SpatialAnchorsAccountsClientCreateResponse, error) {\n\tresult := SpatialAnchorsAccountsClientCreateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SpatialAnchorsAccount); err != nil {\n\t\treturn SpatialAnchorsAccountsClientCreateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *PipelinesClient) createOrUpdateHandleResponse(resp *http.Response) (PipelinesClientCreateOrUpdateResponse, error) {\n\tresult := PipelinesClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PipelineResource); err != nil {\n\t\treturn PipelinesClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func CreateResponse(w *gin.Context, payload interface{}) {\n\tw.JSON(200, payload)\n}", "func (client *PipelinesClient) createRunHandleResponse(resp *http.Response) (PipelinesClientCreateRunResponse, error) {\n\tresult := PipelinesClientCreateRunResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.CreateRunResponse); err != nil {\n\t\treturn PipelinesClientCreateRunResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *KeyVaultClient) createKeyHandleResponse(resp *http.Response) (KeyVaultClientCreateKeyResponse, error) {\n\tresult := KeyVaultClientCreateKeyResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.KeyBundle); err != nil {\n\t\treturn KeyVaultClientCreateKeyResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *RoleAssignmentsClient) createHandleResponse(resp *http.Response) (RoleAssignmentsCreateResponse, error) {\n\tresult := RoleAssignmentsCreateResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil {\n\t\treturn RoleAssignmentsCreateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *KeyVaultClient) createKeyHandleResponse(resp *http.Response) (KeyVaultClientCreateKeyResponse, error) {\n\tresult := KeyVaultClientCreateKeyResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.KeyBundle); err != nil {\n\t\treturn KeyVaultClientCreateKeyResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *RecordSetsClient) createOrUpdateHandleResponse(resp *azcore.Response) (RecordSetResponse, error) {\n\tvar val *RecordSet\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn RecordSetResponse{}, err\n\t}\n\treturn RecordSetResponse{RawResponse: resp.Response, RecordSet: val}, nil\n}", "func (client *OutputsClient) createOrReplaceHandleResponse(resp *http.Response) (OutputsClientCreateOrReplaceResponse, error) {\n\tresult := OutputsClientCreateOrReplaceResponse{}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Output); err != nil {\n\t\treturn OutputsClientCreateOrReplaceResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *AgentsClient) createOrUpdateHandleResponse(resp *http.Response) (AgentsClientCreateOrUpdateResponse, error) {\n\tresult := AgentsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Agent); err != nil {\n\t\treturn AgentsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ServerVulnerabilityAssessmentClient) createOrUpdateHandleResponse(resp *http.Response) (ServerVulnerabilityAssessmentClientCreateOrUpdateResponse, error) {\n\tresult := ServerVulnerabilityAssessmentClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ServerVulnerabilityAssessment); err != nil {\n\t\treturn ServerVulnerabilityAssessmentClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *PolicyDefinitionsClient) createOrUpdateHandleResponse(resp *http.Response) (PolicyDefinitionsCreateOrUpdateResponse, error) {\n\tresult := PolicyDefinitionsCreateOrUpdateResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PolicyDefinition); err != nil {\n\t\treturn PolicyDefinitionsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *OutputsClient) createOrReplaceHandleResponse(resp *http.Response) (OutputsCreateOrReplaceResponse, error) {\n\tresult := OutputsCreateOrReplaceResponse{RawResponse: resp}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Output); err != nil {\n\t\treturn OutputsCreateOrReplaceResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) createDeploymentHandleResponse(resp *http.Response) (WebAppsCreateDeploymentResponse, error) {\n\tresult := WebAppsCreateDeploymentResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Deployment); err != nil {\n\t\treturn WebAppsCreateDeploymentResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func CreateResponse(result interface{}, err error) *Response {\n\tif err == nil {\n\t\treturn CreateSuccessResponse(result)\n\t}\n\treturn CreateErrorResponse(err)\n}", "func (client *FactoriesClient) createOrUpdateHandleResponse(resp *http.Response) (FactoriesClientCreateOrUpdateResponse, error) {\n\tresult := FactoriesClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Factory); err != nil {\n\t\treturn FactoriesClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *VideosClient) createOrUpdateHandleResponse(resp *http.Response) (VideosClientCreateOrUpdateResponse, error) {\n\tresult := VideosClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VideoEntity); err != nil {\n\t\treturn VideosClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WCFRelaysClient) createOrUpdateHandleResponse(resp *http.Response) (WCFRelaysClientCreateOrUpdateResponse, error) {\n\tresult := WCFRelaysClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.WcfRelay); err != nil {\n\t\treturn WCFRelaysClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (c *WSCodec) CreateResponse(id interface{}, reply interface{}) interface{} {\n\treturn &jsonSuccessResponse{Version: jsonrpcVersion, Id: id, Result: reply}\n}", "func (client *AlertProcessingRulesClient) createOrUpdateHandleResponse(resp *http.Response) (AlertProcessingRulesClientCreateOrUpdateResponse, error) {\n\tresult := AlertProcessingRulesClientCreateOrUpdateResponse{RawResponse: resp}\n\tif val := resp.Header.Get(\"x-ms-request-id\"); val != \"\" {\n\t\tresult.XMSRequestID = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AlertProcessingRule); err != nil {\n\t\treturn AlertProcessingRulesClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DatasetsClient) createOrUpdateHandleResponse(resp *http.Response) (DatasetsClientCreateOrUpdateResponse, error) {\n\tresult := DatasetsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DatasetResource); err != nil {\n\t\treturn DatasetsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *IotSecuritySolutionClient) createOrUpdateHandleResponse(resp *http.Response) (IotSecuritySolutionClientCreateOrUpdateResponse, error) {\n\tresult := IotSecuritySolutionClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.IoTSecuritySolutionModel); err != nil {\n\t\treturn IotSecuritySolutionClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ServersClient) createOrUpdateHandleResponse(resp *http.Response) (ServersClientCreateOrUpdateResponse, error) {\n\tresult := ServersClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Server); err != nil {\n\t\treturn ServersClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func createOrderHandle(response http.ResponseWriter, request *http.Request) {\n\tlog.Println(\"Create new Order in System\")\n\tcreateOrderCommand := commands.CreateOrder{}\n\torderId := <-orderHandler.CreateOrder(createOrderCommand)\n\twriteResponse(response, orderId)\n}", "func (client *GroupClient) createOrUpdateHandleResponse(resp *http.Response) (GroupCreateOrUpdateResponse, error) {\n\tresult := GroupCreateOrUpdateResponse{RawResponse: resp}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.GroupContract); err != nil {\n\t\treturn GroupCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *PortalConfigClient) createOrUpdateHandleResponse(resp *http.Response) (PortalConfigClientCreateOrUpdateResponse, error) {\n\tresult := PortalConfigClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PortalConfigContract); err != nil {\n\t\treturn PortalConfigClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *RoleDefinitionsClient) createOrUpdateHandleResponse(resp *http.Response) (RoleDefinitionsCreateOrUpdateResponse, error) {\n\tresult := RoleDefinitionsCreateOrUpdateResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil {\n\t\treturn RoleDefinitionsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *IncidentsClient) createTeamHandleResponse(resp *http.Response) (IncidentsClientCreateTeamResponse, error) {\n\tresult := IncidentsClientCreateTeamResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.TeamInformation); err != nil {\n\t\treturn IncidentsClientCreateTeamResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *IncidentsClient) createOrUpdateHandleResponse(resp *http.Response) (IncidentsClientCreateOrUpdateResponse, error) {\n\tresult := IncidentsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Incident); err != nil {\n\t\treturn IncidentsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ManagementAssociationsClient) createOrUpdateHandleResponse(resp *http.Response) (ManagementAssociationsCreateOrUpdateResponse, error) {\n\tresult := ManagementAssociationsCreateOrUpdateResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagementAssociation); err != nil {\n\t\treturn ManagementAssociationsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *SchemaRegistryClient) createOrUpdateHandleResponse(resp *http.Response) (SchemaRegistryClientCreateOrUpdateResponse, error) {\n\tresult := SchemaRegistryClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SchemaGroup); err != nil {\n\t\treturn SchemaRegistryClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func CreateCreateFileSystemResponse() (response *CreateFileSystemResponse) {\n\tresponse = &CreateFileSystemResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client *SubscriptionClient) createOrUpdateHandleResponse(resp *http.Response) (SubscriptionClientCreateOrUpdateResponse, error) {\n\tresult := SubscriptionClientCreateOrUpdateResponse{}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionContract); err != nil {\n\t\treturn SubscriptionClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *GalleryImageVersionsClient) createOrUpdateHandleResponse(resp *azcore.Response) (GalleryImageVersionResponse, error) {\n\tvar val *GalleryImageVersion\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn GalleryImageVersionResponse{}, err\n\t}\n\treturn GalleryImageVersionResponse{RawResponse: resp.Response, GalleryImageVersion: val}, nil\n}", "func CreateCreatedResponse(w http.ResponseWriter, data interface{}) {\n\tif data != nil {\n\t\tbytes, err := json.Marshal(data)\n\n\t\tif err != nil {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\n\t\tw.WriteHeader(http.StatusCreated)\n\t\tw.Write(bytes)\n\t}\n}", "func (client *KeyVaultClient) createCertificateHandleResponse(resp *http.Response) (KeyVaultClientCreateCertificateResponse, error) {\n\tresult := KeyVaultClientCreateCertificateResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.CertificateOperation); err != nil {\n\t\treturn KeyVaultClientCreateCertificateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client appendBlobClient) createResponder(resp pipeline.Response) (pipeline.Response, error) {\n\terr := validateResponse(resp, http.StatusOK, http.StatusCreated)\n\tif resp == nil {\n\t\treturn nil, err\n\t}\n\tio.Copy(ioutil.Discard, resp.Response().Body)\n\tresp.Response().Body.Close()\n\treturn &AppendBlobCreateResponse{rawResponse: resp.Response()}, err\n}", "func (client *NotificationRecipientEmailClient) createOrUpdateHandleResponse(resp *http.Response) (NotificationRecipientEmailClientCreateOrUpdateResponse, error) {\n\tresult := NotificationRecipientEmailClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RecipientEmailContract); err != nil {\n\t\treturn NotificationRecipientEmailClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) createOrUpdateDomainOwnershipIdentifierSlotHandleResponse(resp *http.Response) (WebAppsCreateOrUpdateDomainOwnershipIdentifierSlotResponse, error) {\n\tresult := WebAppsCreateOrUpdateDomainOwnershipIdentifierSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Identifier); err != nil {\n\t\treturn WebAppsCreateOrUpdateDomainOwnershipIdentifierSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *VirtualNetworkTapsClient) createOrUpdateHandleResponse(resp *azcore.Response) (VirtualNetworkTapResponse, error) {\n\tvar val *VirtualNetworkTap\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn VirtualNetworkTapResponse{}, err\n\t}\n\treturn VirtualNetworkTapResponse{RawResponse: resp.Response, VirtualNetworkTap: val}, nil\n}", "func CreateCreateVSwitchResponse() (response *CreateVSwitchResponse) {\n\tresponse = &CreateVSwitchResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client *HCRPAssignmentsClient) createOrUpdateHandleResponse(resp *http.Response) (HCRPAssignmentsClientCreateOrUpdateResponse, error) {\n\tresult := HCRPAssignmentsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Assignment); err != nil {\n\t\treturn HCRPAssignmentsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DedicatedHostsClient) createOrUpdateHandleResponse(resp *azcore.Response) (DedicatedHostResponse, error) {\n\tvar val *DedicatedHost\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn DedicatedHostResponse{}, err\n\t}\n\treturn DedicatedHostResponse{RawResponse: resp.Response, DedicatedHost: val}, nil\n}", "func (client *SourceControlConfigurationsClient) createOrUpdateHandleResponse(resp *http.Response) (SourceControlConfigurationsClientCreateOrUpdateResponse, error) {\n\tresult := SourceControlConfigurationsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SourceControlConfiguration); err != nil {\n\t\treturn SourceControlConfigurationsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ProductPolicyClient) createOrUpdateHandleResponse(resp *http.Response) (ProductPolicyClientCreateOrUpdateResponse, error) {\n\tresult := ProductPolicyClientCreateOrUpdateResponse{}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PolicyContract); err != nil {\n\t\treturn ProductPolicyClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) createOrUpdateDomainOwnershipIdentifierHandleResponse(resp *http.Response) (WebAppsCreateOrUpdateDomainOwnershipIdentifierResponse, error) {\n\tresult := WebAppsCreateOrUpdateDomainOwnershipIdentifierResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Identifier); err != nil {\n\t\treturn WebAppsCreateOrUpdateDomainOwnershipIdentifierResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func CreateCreateStackResponse() (response *CreateStackResponse) {\n\tresponse = &CreateStackResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func CreateResponse() *application.HTTPResponse {\n\tresponse := &application.HTTPResponse{}\n\tresponse.Headers = make(map[string]*application.HTTPResponse_HTTPHeaderParameter)\n\treturn response\n}", "func (client *WebAppsClient) createDeploymentSlotHandleResponse(resp *http.Response) (WebAppsCreateDeploymentSlotResponse, error) {\n\tresult := WebAppsCreateDeploymentSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Deployment); err != nil {\n\t\treturn WebAppsCreateDeploymentSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func CreateCreateFileDetectResponse() (response *CreateFileDetectResponse) {\n\tresponse = &CreateFileDetectResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func HandleCreate(wf workflow.CreateFunc) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tdecoder := json.NewDecoder(r.Body)\n\t\tvar requestDTO CreateRequestDTO\n\t\terr := decoder.Decode(&requestDTO)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tcreateRequest := createRequestFromCreateRequestDTO(requestDTO)\n\t\tcustomer, err := wf(createRequest)\n\t\tif err != nil {\n\t\t\thandleWorkflowError(err, w)\n\t\t\treturn\n\t\t}\n\t\tresponse := createResponseDTOFromCustomer(*customer)\n\t\tencodeErr := json.NewEncoder(w).Encode(response)\n\t\tif encodeErr != nil {\n\t\t\tlog.Fatal(encodeErr)\n\t\t}\n\t}\n}", "func (client *VirtualApplianceSitesClient) createOrUpdateHandleResponse(resp *azcore.Response) (VirtualApplianceSiteResponse, error) {\n\tvar val *VirtualApplianceSite\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn VirtualApplianceSiteResponse{}, err\n\t}\n\treturn VirtualApplianceSiteResponse{RawResponse: resp.Response, VirtualApplianceSite: val}, nil\n}", "func (client *MetricAlertsClient) createOrUpdateHandleResponse(resp *http.Response) (MetricAlertsClientCreateOrUpdateResponse, error) {\n\tresult := MetricAlertsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.MetricAlertResource); err != nil {\n\t\treturn MetricAlertsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func CreateCreateAgentResponse() (response *CreateAgentResponse) {\n\tresponse = &CreateAgentResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client *AvailabilitySetsClient) createOrUpdateHandleResponse(resp *http.Response) (AvailabilitySetsCreateOrUpdateResponse, error) {\n\tresult := AvailabilitySetsCreateOrUpdateResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AvailabilitySet); err != nil {\n\t\treturn AvailabilitySetsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ManagedDatabaseSecurityAlertPoliciesClient) createOrUpdateHandleResponse(resp *http.Response) (ManagedDatabaseSecurityAlertPoliciesClientCreateOrUpdateResponse, error) {\n\tresult := ManagedDatabaseSecurityAlertPoliciesClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedDatabaseSecurityAlertPolicy); err != nil {\n\t\treturn ManagedDatabaseSecurityAlertPoliciesClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DefenderSettingsClient) createOrUpdateHandleResponse(resp *http.Response) (DefenderSettingsClientCreateOrUpdateResponse, error) {\n\tresult := DefenderSettingsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DefenderSettingsModel); err != nil {\n\t\treturn DefenderSettingsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *BuildServiceClient) createOrUpdateBuildHandleResponse(resp *http.Response) (BuildServiceClientCreateOrUpdateBuildResponse, error) {\n\tresult := BuildServiceClientCreateOrUpdateBuildResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Build); err != nil {\n\t\treturn BuildServiceClientCreateOrUpdateBuildResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ApplyUpdatesClient) createOrUpdateHandleResponse(resp *http.Response) (ApplyUpdatesClientCreateOrUpdateResponse, error) {\n\tresult := ApplyUpdatesClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ApplyUpdate); err != nil {\n\t\treturn ApplyUpdatesClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func createHandler (w http.ResponseWriter, r *http.Request) {\n\terr := create.ExecuteTemplate(w, \"create.html\", nil)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n}", "func (client *FirewallRulesClient) createOrUpdateHandleResponse(resp *http.Response) (FirewallRulesClientCreateOrUpdateResponse, error) {\n\tresult := FirewallRulesClientCreateOrUpdateResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.FirewallRule); err != nil {\n\t\treturn FirewallRulesClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func createResponse(req *http.Request) *http.Response {\n\treturn &http.Response{\n\t\tStatusCode: http.StatusOK,\n\t\tRequest: req,\n\t\tHeader: make(http.Header),\n\t\tBody: ioutil.NopCloser(bytes.NewBuffer([]byte{})),\n\t}\n}", "func CreateCreateMeetingResponse() (response *CreateMeetingResponse) {\n\tresponse = &CreateMeetingResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (e *RegisterRequest) CreateResponse() RegisterResponse {\n\treturn RegisterResponse{\n\t\tID: e.ID,\n\t}\n}", "func CreatePhotoProcessResponse() (response *PhotoProcessResponse) {\n\tresponse = &PhotoProcessResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func CreateCreateExchangeResponse() (response *CreateExchangeResponse) {\n\tresponse = &CreateExchangeResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func CreateCreateGatewayFileShareResponse() (response *CreateGatewayFileShareResponse) {\n\tresponse = &CreateGatewayFileShareResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client *PolicyDefinitionsClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse, error) {\n\tresult := PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PolicyDefinition); err != nil {\n\t\treturn PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *UserMetricsKeysClient) createOrUpdateHandleResponse(resp *http.Response) (UserMetricsKeysClientCreateOrUpdateResponse, error) {\n\tresult := UserMetricsKeysClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.UserMetricsModel); err != nil {\n\t\treturn UserMetricsKeysClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func DecodeCreateResponse(decoder func(*http.Response) goahttp.Decoder, restoreBody bool) func(*http.Response) (interface{}, error) {\n\treturn func(resp *http.Response) (interface{}, error) {\n\t\tif restoreBody {\n\t\t\tb, err := ioutil.ReadAll(resp.Body)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tresp.Body = ioutil.NopCloser(bytes.NewBuffer(b))\n\t\t\tdefer func() {\n\t\t\t\tresp.Body = ioutil.NopCloser(bytes.NewBuffer(b))\n\t\t\t}()\n\t\t} else {\n\t\t\tdefer resp.Body.Close()\n\t\t}\n\t\tswitch resp.StatusCode {\n\t\tcase http.StatusCreated:\n\t\t\tvar (\n\t\t\t\tbody CreateResponseBody\n\t\t\t\terr error\n\t\t\t)\n\t\t\terr = decoder(resp).Decode(&body)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, goahttp.ErrDecodingError(\"blog\", \"create\", err)\n\t\t\t}\n\t\t\terr = ValidateCreateResponseBody(&body)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, goahttp.ErrValidationError(\"blog\", \"create\", err)\n\t\t\t}\n\t\t\tres := NewCreateBlogCreated(&body)\n\t\t\treturn res, nil\n\t\tdefault:\n\t\t\tbody, _ := ioutil.ReadAll(resp.Body)\n\t\t\treturn nil, goahttp.ErrInvalidResponse(\"blog\", \"create\", resp.StatusCode, string(body))\n\t\t}\n\t}\n}", "func MockCreateResponse(t *testing.T) {\n\tth.Mux.HandleFunc(shareEndpoint, func(w http.ResponseWriter, r *http.Request) {\n\t\tth.TestMethod(t, r, \"POST\")\n\t\tth.TestHeader(t, r, \"X-Auth-Token\", fake.TokenID)\n\t\tth.TestHeader(t, r, \"Content-Type\", \"application/json\")\n\t\tth.TestHeader(t, r, \"Accept\", \"application/json\")\n\t\tth.TestJSONRequest(t, r, createRequest)\n\t\tw.Header().Add(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(http.StatusOK)\n\t\tfmt.Fprintf(w, createResponse)\n\t})\n}", "func (client *ConfigurationProfilesVersionsClient) createOrUpdateHandleResponse(resp *http.Response) (ConfigurationProfilesVersionsClientCreateOrUpdateResponse, error) {\n\tresult := ConfigurationProfilesVersionsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ConfigurationProfile); err != nil {\n\t\treturn ConfigurationProfilesVersionsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func CreateCreateIntegrationResponse() (response *CreateIntegrationResponse) {\n\tresponse = &CreateIntegrationResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client *WebAppsClient) createOrUpdateHostNameBindingSlotHandleResponse(resp *http.Response) (WebAppsCreateOrUpdateHostNameBindingSlotResponse, error) {\n\tresult := WebAppsCreateOrUpdateHostNameBindingSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.HostNameBinding); err != nil {\n\t\treturn WebAppsCreateOrUpdateHostNameBindingSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func createHandler(w http.ResponseWriter, r *http.Request) {\n\n\tlog.Printf(\"CreateHandler Called...\\n\")\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tparams := mux.Vars(r)\n\tgameName := params[\"gameName\"]\n\tplayerName := params[\"playerName\"]\n\tdieNum, _ := strconv.Atoi(params[\"dieNum\"])\n\tgameId := storewrapper.GreateUniqueGameId(game_db)\n\tplayerId := storewrapper.GreateUniquePlayerId(player_db, gameId)\n\tgame := NewDiceChessGame(gameId, gameName, playerName, \"\", dieNum)\n\tvalue, err := json.Marshal(game)\n\tif err != nil {\n\t\tlog.Println(\"Failed to parse inputs.\")\n\t\tReturnFailure(w, \"Failed to parse inputs.\")\n\t\treturn\n\t}\n\tgame_db.Set(gameId, string(value), 0)\n\tresp := createResponse{RESPONSE_CREATE, gameId, playerId, gameName, playerName, int(WAITING), strconv.Itoa(dieNum)}\n\tjson.NewEncoder(w).Encode(resp)\n}", "func (client DatasetClient) CreateResponder(resp *http.Response) (result LongRunningOperationResult, err error) {\n err = autorest.Respond(\n resp,\n azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusAccepted),\n autorest.ByUnmarshallingJSON(&result),\n autorest.ByClosing())\n result.Response = autorest.Response{Response: resp}\n return\n }", "func (client *WebAppsClient) createOrUpdateHybridConnectionSlotHandleResponse(resp *http.Response) (WebAppsCreateOrUpdateHybridConnectionSlotResponse, error) {\n\tresult := WebAppsCreateOrUpdateHybridConnectionSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.HybridConnection); err != nil {\n\t\treturn WebAppsCreateOrUpdateHybridConnectionSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) createOrUpdateFunctionSecretSlotHandleResponse(resp *http.Response) (WebAppsCreateOrUpdateFunctionSecretSlotResponse, error) {\n\tresult := WebAppsCreateOrUpdateFunctionSecretSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.KeyInfo); err != nil {\n\t\treturn WebAppsCreateOrUpdateFunctionSecretSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func HandleCreateEvent(w rest.ResponseWriter, req *rest.Request) {\n\tif err := RequireWriteKey(w, req); err != nil {\n\t\trest.Error(w, err.Error(), err.(StatusError).Code)\n\t\treturn\n\t}\n\n\tproject := currentProject(req)\n\tevent := req.PathParam(\"event_name\")\n\n\tvar data CreateSingleEventParams\n\tvar err error\n\tif err = eventData(req, &data); err != nil {\n\t\trest.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tevents := make(map[string][]interface{})\n\tevents[event] = []interface{}{data}\n\n\tresult, err := createEvent(project, event, data)\n\n\tif err != nil {\n\t\trest.Error(w, err.Error(), http.StatusBadRequest)\n\t} else {\n\t\tw.WriteJson(result)\n\t}\n}", "func CreateCancelInstanceResponse() (response *CancelInstanceResponse) {\n\tresponse = &CancelInstanceResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client *WCFRelaysClient) createOrUpdateAuthorizationRuleHandleResponse(resp *http.Response) (WCFRelaysClientCreateOrUpdateAuthorizationRuleResponse, error) {\n\tresult := WCFRelaysClientCreateOrUpdateAuthorizationRuleResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AuthorizationRule); err != nil {\n\t\treturn WCFRelaysClientCreateOrUpdateAuthorizationRuleResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) createOrUpdateHostSecretSlotHandleResponse(resp *http.Response) (WebAppsCreateOrUpdateHostSecretSlotResponse, error) {\n\tresult := WebAppsCreateOrUpdateHostSecretSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.KeyInfo); err != nil {\n\t\treturn WebAppsCreateOrUpdateHostSecretSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (apiHandler *ApiHandler) handleCreateNamespace(request *restful.Request,\n\tresponse *restful.Response) {\n\tnamespaceSpec := new(NamespaceSpec)\n\tif err := request.ReadEntity(namespaceSpec); err != nil {\n\t\thandleInternalError(response, err)\n\t\treturn\n\t}\n\tif err := CreateNamespace(namespaceSpec, apiHandler.client); err != nil {\n\t\thandleInternalError(response, err)\n\t\treturn\n\t}\n\n\tresponse.WriteHeaderAndEntity(http.StatusCreated, namespaceSpec)\n}", "func (client *WebAppsClient) createOrUpdateHostNameBindingHandleResponse(resp *http.Response) (WebAppsCreateOrUpdateHostNameBindingResponse, error) {\n\tresult := WebAppsCreateOrUpdateHostNameBindingResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.HostNameBinding); err != nil {\n\t\treturn WebAppsCreateOrUpdateHostNameBindingResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) createOrUpdateHybridConnectionHandleResponse(resp *http.Response) (WebAppsCreateOrUpdateHybridConnectionResponse, error) {\n\tresult := WebAppsCreateOrUpdateHybridConnectionResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.HybridConnection); err != nil {\n\t\treturn WebAppsCreateOrUpdateHybridConnectionResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ApplyUpdatesClient) createOrUpdateParentHandleResponse(resp *http.Response) (ApplyUpdatesClientCreateOrUpdateParentResponse, error) {\n\tresult := ApplyUpdatesClientCreateOrUpdateParentResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ApplyUpdate); err != nil {\n\t\treturn ApplyUpdatesClientCreateOrUpdateParentResponse{}, err\n\t}\n\treturn result, nil\n}", "func CreateCreateScheduleResponse() (response *CreateScheduleResponse) {\n\tresponse = &CreateScheduleResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client *WebAppsClient) createOrUpdatePublicCertificateSlotHandleResponse(resp *http.Response) (WebAppsCreateOrUpdatePublicCertificateSlotResponse, error) {\n\tresult := WebAppsCreateOrUpdatePublicCertificateSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PublicCertificate); err != nil {\n\t\treturn WebAppsCreateOrUpdatePublicCertificateSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (hnd Handlers) CreateResponseWrapper(status string) map[string]interface{} {\n\twrapper := make(map[string]interface{})\n\twrapper[\"status\"] = status\n\twrapper[\"version\"] = \"1.0\"\n\twrapper[\"ts\"] = time.Now()\n\n\treturn wrapper\n}", "func decodeCreateResponse(_ context.Context, reply interface{}) (interface{}, error) {\n\tresp, found := reply.(*pb.CreateReply)\n\tif !found {\n\t\treturn nil, fmt.Errorf(\"pb CreateReply type assertion error\")\n\t}\n\treturn endpoint1.CreateResponse{E1: nil, UUID: resp.Uuid}, nil\n}", "func CreateCreateTopicResponse() (response *CreateTopicResponse) {\n\tresponse = &CreateTopicResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func CreateCreateTagTaskResponse() (response *CreateTagTaskResponse) {\n\tresponse = &CreateTagTaskResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client *WebAppsClient) createOrUpdateConfigurationSlotHandleResponse(resp *http.Response) (WebAppsCreateOrUpdateConfigurationSlotResponse, error) {\n\tresult := WebAppsCreateOrUpdateConfigurationSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SiteConfigResource); err != nil {\n\t\treturn WebAppsCreateOrUpdateConfigurationSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func CreateCreateETLJobResponse() (response *CreateETLJobResponse) {\n\tresponse = &CreateETLJobResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func CreateAddHDMInstanceResponse() (response *AddHDMInstanceResponse) {\n\tresponse = &AddHDMInstanceResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func CreateResponse(resultCode uint32, internalCommand []byte) ([]byte, error) {\n\t// Response frame:\n\t// - uint32 (size of response)\n\t// - []byte (response)\n\t// - uint32 (code)\n\tvar buf bytes.Buffer\n\n\tif err := binary.Write(&buf, binary.BigEndian, uint32(len(internalCommand))); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif _, err := buf.Write(internalCommand); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := binary.Write(&buf, binary.BigEndian, resultCode); err != nil {\n\t\treturn nil, err\n\t}\n\treturn buf.Bytes(), nil\n}" ]
[ "0.7475178", "0.74203277", "0.7417456", "0.7413159", "0.733554", "0.7333074", "0.73066825", "0.7273078", "0.7259064", "0.724303", "0.7237097", "0.7163568", "0.71246636", "0.7106025", "0.7076806", "0.7073281", "0.7029697", "0.7013574", "0.70115906", "0.69892377", "0.6987544", "0.6961907", "0.6959455", "0.69249994", "0.6923288", "0.6919756", "0.6905221", "0.68825793", "0.68728274", "0.6862766", "0.6853538", "0.68490916", "0.6821596", "0.68109226", "0.68024105", "0.6786394", "0.6775544", "0.67724985", "0.6764891", "0.6751726", "0.6744842", "0.6741842", "0.6739306", "0.67329156", "0.67319924", "0.6700202", "0.6697019", "0.6691992", "0.6688158", "0.66880125", "0.66858757", "0.66801286", "0.66738373", "0.66685045", "0.666732", "0.6662596", "0.6653075", "0.66527635", "0.6629417", "0.6621616", "0.6619635", "0.65910643", "0.65639204", "0.65426576", "0.65353084", "0.6529493", "0.6526815", "0.6517074", "0.6503834", "0.64960384", "0.6489198", "0.6484642", "0.6475312", "0.6466488", "0.6460424", "0.6444528", "0.6431369", "0.6402543", "0.63778347", "0.6356582", "0.63354665", "0.6330926", "0.63287723", "0.63180137", "0.6315512", "0.63084865", "0.63044965", "0.6299635", "0.6292096", "0.6271096", "0.62701", "0.626634", "0.6256929", "0.62534446", "0.6229525", "0.6227976", "0.6226831", "0.62091374", "0.6203661", "0.618781" ]
0.7425054
1
listBySubscriptionHandleResponse handles the ListBySubscription response.
listBySubscriptionHandleResponse обрабатывает ответ ListBySubscription.
func (client *DataCollectionEndpointsClient) listBySubscriptionHandleResponse(resp *http.Response) (DataCollectionEndpointsListBySubscriptionResponse, error) { result := DataCollectionEndpointsListBySubscriptionResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.DataCollectionEndpointResourceListResult); err != nil { return DataCollectionEndpointsListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) } return result, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *RedisClient) listBySubscriptionHandleResponse(resp *http.Response) (RedisListBySubscriptionResponse, error) {\n\tresult := RedisListBySubscriptionResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RedisListResult); err != nil {\n\t\treturn RedisListBySubscriptionResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *DataCollectionEndpointsClient) listBySubscriptionHandleResponse(resp *http.Response) (DataCollectionEndpointsClientListBySubscriptionResponse, error) {\n\tresult := DataCollectionEndpointsClientListBySubscriptionResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DataCollectionEndpointResourceListResult); err != nil {\n\t\treturn DataCollectionEndpointsClientListBySubscriptionResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DevicesClient) listBySubscriptionHandleResponse(resp *http.Response) (DevicesClientListBySubscriptionResponse, error) {\n\tresult := DevicesClientListBySubscriptionResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DeviceListResult); err != nil {\n\t\treturn DevicesClientListBySubscriptionResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *SpatialAnchorsAccountsClient) listBySubscriptionHandleResponse(resp *http.Response) (SpatialAnchorsAccountsClientListBySubscriptionResponse, error) {\n\tresult := SpatialAnchorsAccountsClientListBySubscriptionResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SpatialAnchorsAccountPage); err != nil {\n\t\treturn SpatialAnchorsAccountsClientListBySubscriptionResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WorkspacesClient) listBySubscriptionHandleResponse(resp *http.Response) (WorkspacesListBySubscriptionResponse, error) {\n\tresult := WorkspacesListBySubscriptionResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceListResult); err != nil {\n\t\treturn WorkspacesListBySubscriptionResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ServersClient) listBySubscriptionHandleResponse(resp *http.Response) (ServersClientListBySubscriptionResponse, error) {\n\tresult := ServersClientListBySubscriptionResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ServerList); err != nil {\n\t\treturn ServersClientListBySubscriptionResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *MetricAlertsClient) listBySubscriptionHandleResponse(resp *http.Response) (MetricAlertsClientListBySubscriptionResponse, error) {\n\tresult := MetricAlertsClientListBySubscriptionResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.MetricAlertResourceCollection); err != nil {\n\t\treturn MetricAlertsClientListBySubscriptionResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *CustomAssessmentAutomationsClient) listBySubscriptionHandleResponse(resp *http.Response) (CustomAssessmentAutomationsListBySubscriptionResponse, error) {\n\tresult := CustomAssessmentAutomationsListBySubscriptionResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.CustomAssessmentAutomationsListResult); err != nil {\n\t\treturn CustomAssessmentAutomationsListBySubscriptionResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *AvailabilitySetsClient) listBySubscriptionHandleResponse(resp *http.Response) (AvailabilitySetsListBySubscriptionResponse, error) {\n\tresult := AvailabilitySetsListBySubscriptionResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AvailabilitySetListResult); err != nil {\n\t\treturn AvailabilitySetsListBySubscriptionResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *LocalRulestacksClient) listBySubscriptionHandleResponse(resp *http.Response) (LocalRulestacksClientListBySubscriptionResponse, error) {\n\tresult := LocalRulestacksClientListBySubscriptionResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.LocalRulestackResourceListResult); err != nil {\n\t\treturn LocalRulestacksClientListBySubscriptionResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *IotSecuritySolutionClient) listBySubscriptionHandleResponse(resp *http.Response) (IotSecuritySolutionClientListBySubscriptionResponse, error) {\n\tresult := IotSecuritySolutionClientListBySubscriptionResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.IoTSecuritySolutionsList); err != nil {\n\t\treturn IotSecuritySolutionClientListBySubscriptionResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ManagementAssociationsClient) listBySubscriptionHandleResponse(resp *http.Response) (ManagementAssociationsListBySubscriptionResponse, error) {\n\tresult := ManagementAssociationsListBySubscriptionResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagementAssociationPropertiesList); err != nil {\n\t\treturn ManagementAssociationsListBySubscriptionResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *CassandraClustersClient) listBySubscriptionHandleResponse(resp *http.Response) (CassandraClustersClientListBySubscriptionResponse, error) {\n\tresult := CassandraClustersClientListBySubscriptionResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ListClusters); err != nil {\n\t\treturn CassandraClustersClientListBySubscriptionResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ConnectedEnvironmentsClient) listBySubscriptionHandleResponse(resp *http.Response) (ConnectedEnvironmentsClientListBySubscriptionResponse, error) {\n\tresult := ConnectedEnvironmentsClientListBySubscriptionResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ConnectedEnvironmentCollection); err != nil {\n\t\treturn ConnectedEnvironmentsClientListBySubscriptionResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *AlertProcessingRulesClient) listBySubscriptionHandleResponse(resp *http.Response) (AlertProcessingRulesClientListBySubscriptionResponse, error) {\n\tresult := AlertProcessingRulesClientListBySubscriptionResponse{RawResponse: resp}\n\tif val := resp.Header.Get(\"x-ms-request-id\"); val != \"\" {\n\t\tresult.XMSRequestID = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AlertProcessingRulesList); err != nil {\n\t\treturn AlertProcessingRulesClientListBySubscriptionResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client AccountClient) ListBySubscriptionResponder(resp *http.Response) (result AccountResourceDescriptionList, err error) {\n err = autorest.Respond(\n resp,\n azure.WithErrorUnlessStatusCode(http.StatusOK),\n autorest.ByUnmarshallingJSON(&result),\n autorest.ByClosing())\n result.Response = autorest.Response{Response: resp}\n return\n }", "func (client *TriggersClient) listByShareSubscriptionHandleResponse(resp *http.Response) (TriggersClientListByShareSubscriptionResponse, error) {\n\tresult := TriggersClientListByShareSubscriptionResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.TriggerList); err != nil {\n\t\treturn TriggersClientListByShareSubscriptionResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *SubscriptionClient) listHandleResponse(resp *http.Response) (SubscriptionClientListResponse, error) {\n\tresult := SubscriptionClientListResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionCollection); err != nil {\n\t\treturn SubscriptionClientListResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client ServicesClient) ListBySubscriptionResponder(resp *http.Response) (result ServiceResourceList, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client IotHubResourceClient) ListBySubscriptionResponder(resp *http.Response) (result IotHubDescriptionListResult, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client LabClient) ListBySubscriptionResponder(resp *http.Response) (result ResponseWithContinuationLab, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tclient.ByInspecting(),\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client *ProviderShareSubscriptionsClient) listByShareHandleResponse(resp *http.Response) (ProviderShareSubscriptionsClientListByShareResponse, error) {\n\tresult := ProviderShareSubscriptionsClientListByShareResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ProviderShareSubscriptionList); err != nil {\n\t\treturn ProviderShareSubscriptionsClientListByShareResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client ServicesClient) ListBySubscription(ctx context.Context) (result ServiceResourceListPage, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/ServicesClient.ListBySubscription\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.srl.Response.Response != nil {\n\t\t\t\tsc = result.srl.Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tresult.fn = client.listBySubscriptionNextResults\n\treq, err := client.ListBySubscriptionPreparer(ctx)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"appplatform.ServicesClient\", \"ListBySubscription\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.ListBySubscriptionSender(req)\n\tif err != nil {\n\t\tresult.srl.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"appplatform.ServicesClient\", \"ListBySubscription\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult.srl, err = client.ListBySubscriptionResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"appplatform.ServicesClient\", \"ListBySubscription\", resp, \"Failure responding to request\")\n\t\treturn\n\t}\n\tif result.srl.hasNextLink() && result.srl.IsEmpty() {\n\t\terr = result.NextWithContext(ctx)\n\t\treturn\n\t}\n\n\treturn\n}", "func (client IotHubResourceClient) ListBySubscription(ctx context.Context) (result IotHubDescriptionListResultPage, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/IotHubResourceClient.ListBySubscription\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.ihdlr.Response.Response != nil {\n\t\t\t\tsc = result.ihdlr.Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tresult.fn = client.listBySubscriptionNextResults\n\treq, err := client.ListBySubscriptionPreparer(ctx)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"devices.IotHubResourceClient\", \"ListBySubscription\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.ListBySubscriptionSender(req)\n\tif err != nil {\n\t\tresult.ihdlr.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"devices.IotHubResourceClient\", \"ListBySubscription\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult.ihdlr, err = client.ListBySubscriptionResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"devices.IotHubResourceClient\", \"ListBySubscription\", resp, \"Failure responding to request\")\n\t\treturn\n\t}\n\tif result.ihdlr.hasNextLink() && result.ihdlr.IsEmpty() {\n\t\terr = result.NextWithContext(ctx)\n\t\treturn\n\t}\n\n\treturn\n}", "func (c *DefaultApiService) ListSubscription(params *ListSubscriptionParams) (*ListSubscriptionResponse, error) {\n\tpath := \"/v1/Subscriptions\"\n\n\tdata := url.Values{}\n\theaders := make(map[string]interface{})\n\n\tif params != nil && params.SinkSid != nil {\n\t\tdata.Set(\"SinkSid\", *params.SinkSid)\n\t}\n\tif params != nil && params.PageSize != nil {\n\t\tdata.Set(\"PageSize\", fmt.Sprint(*params.PageSize))\n\t}\n\n\tresp, err := c.requestHandler.Get(c.baseURL+path, data, headers)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer resp.Body.Close()\n\n\tps := &ListSubscriptionResponse{}\n\tif err := json.NewDecoder(resp.Body).Decode(ps); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn ps, err\n}", "func (client LabClient) ListBySubscription(ctx context.Context, filter string, top *int32, orderBy string) (result ResponseWithContinuationLabPage, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/LabClient.ListBySubscription\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.rwcl.Response.Response != nil {\n\t\t\t\tsc = result.rwcl.Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tresult.fn = client.listBySubscriptionNextResults\n\treq, err := client.ListBySubscriptionPreparer(ctx, filter, top, orderBy)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"dtl.LabClient\", \"ListBySubscription\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.ListBySubscriptionSender(req)\n\tif err != nil {\n\t\tresult.rwcl.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"dtl.LabClient\", \"ListBySubscription\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult.rwcl, err = client.ListBySubscriptionResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"dtl.LabClient\", \"ListBySubscription\", resp, \"Failure responding to request\")\n\t}\n\n\treturn\n}", "func (client AccountClient) ListBySubscription(ctx context.Context) (result AccountResourceDescriptionListPage, err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/AccountClient.ListBySubscription\")\n defer func() {\n sc := -1\n if result.ardl.Response.Response != nil {\n sc = result.ardl.Response.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n result.fn = client.listBySubscriptionNextResults\n req, err := client.ListBySubscriptionPreparer(ctx)\n if err != nil {\n err = autorest.NewErrorWithError(err, \"microsoftazuremanagementaisupercomputer.AccountClient\", \"ListBySubscription\", nil , \"Failure preparing request\")\n return\n }\n\n resp, err := client.ListBySubscriptionSender(req)\n if err != nil {\n result.ardl.Response = autorest.Response{Response: resp}\n err = autorest.NewErrorWithError(err, \"microsoftazuremanagementaisupercomputer.AccountClient\", \"ListBySubscription\", resp, \"Failure sending request\")\n return\n }\n\n result.ardl, err = client.ListBySubscriptionResponder(resp)\n if err != nil {\n err = autorest.NewErrorWithError(err, \"microsoftazuremanagementaisupercomputer.AccountClient\", \"ListBySubscription\", resp, \"Failure responding to request\")\n }\n if result.ardl.hasNextLink() && result.ardl.IsEmpty() {\n err = result.NextWithContext(ctx)\n }\n\n return\n}", "func (client AccountClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {\n return client.Send(req, azure.DoRetryWithRegistration(client.Client))\n }", "func (client LabClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {\n\treturn autorest.SendWithSender(client, req,\n\t\tazure.DoRetryWithRegistration(client.Client))\n}", "func (client ServicesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {\n\treturn client.Send(req, azure.DoRetryWithRegistration(client.Client))\n}", "func (client IotHubResourceClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {\n\treturn client.Send(req, azure.DoRetryWithRegistration(client.Client))\n}", "func (client *VendorSKUPreviewClient) listHandleResponse(resp *http.Response) (VendorSKUPreviewClientListResponse, error) {\n\tresult := VendorSKUPreviewClientListResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PreviewSubscriptionsList); err != nil {\n\t\treturn VendorSKUPreviewClientListResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *PermissionsClient) listByBillingProfileHandleResponse(resp *http.Response) (PermissionsClientListByBillingProfileResponse, error) {\n\tresult := PermissionsClientListByBillingProfileResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PermissionsListResult); err != nil {\n\t\treturn PermissionsClientListByBillingProfileResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client DataControllersClient) ListInSubscriptionResponder(resp *http.Response) (result PageOfDataControllerResource, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client ProviderShareSubscriptionsClient) ListByShareResponder(resp *http.Response) (result ProviderShareSubscriptionList, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client *PermissionsClient) listByBillingAccountHandleResponse(resp *http.Response) (PermissionsClientListByBillingAccountResponse, error) {\n\tresult := PermissionsClientListByBillingAccountResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PermissionsListResult); err != nil {\n\t\treturn PermissionsClientListByBillingAccountResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client AccountClient) ListBySubscriptionComplete(ctx context.Context) (result AccountResourceDescriptionListIterator, err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/AccountClient.ListBySubscription\")\n defer func() {\n sc := -1\n if result.Response().Response.Response != nil {\n sc = result.page.Response().Response.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n result.page, err = client.ListBySubscription(ctx)\n return\n }", "func (client *WCFRelaysClient) listByNamespaceHandleResponse(resp *http.Response) (WCFRelaysClientListByNamespaceResponse, error) {\n\tresult := WCFRelaysClientListByNamespaceResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.WcfRelaysListResult); err != nil {\n\t\treturn WCFRelaysClientListByNamespaceResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *KpiClient) listByHubHandleResponse(resp *http.Response) (KpiClientListByHubResponse, error) {\n\tresult := KpiClientListByHubResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.KpiListResult); err != nil {\n\t\treturn KpiClientListByHubResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *PermissionBindingsClient) listByNamespaceHandleResponse(resp *http.Response) (PermissionBindingsClientListByNamespaceResponse, error) {\n\tresult := PermissionBindingsClientListByNamespaceResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PermissionBindingsListResult); err != nil {\n\t\treturn PermissionBindingsClientListByNamespaceResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client NotificationDataPlaneClient) ListSubscriptions(ctx context.Context, request ListSubscriptionsRequest) (response ListSubscriptionsResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.listSubscriptions, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tresponse = ListSubscriptionsResponse{RawResponse: ociResponse.HTTPResponse()}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(ListSubscriptionsResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into ListSubscriptionsResponse\")\n\t}\n\treturn\n}", "func (s *API) ListSubscriptions(status SubscriptionStatus) (data SubscriptionsResponse, err error) {\n\tif status == \"\" {\n\t\tstatus = SubscriptionStatusAll\n\t}\n\tendpoint := zoho.Endpoint{\n\t\tName: \"subscriptions\",\n\t\tURL: fmt.Sprintf(\"https://subscriptions.zoho.%s/api/v1/subscriptions\", s.ZohoTLD),\n\t\tMethod: zoho.HTTPGet,\n\t\tResponseData: &SubscriptionsResponse{},\n\t\tURLParameters: map[string]zoho.Parameter{\n\t\t\t\"filter_by\": zoho.Parameter(status),\n\t\t},\n\t\tHeaders: map[string]string{\n\t\t\tZohoSubscriptionsEndpointHeader: s.OrganizationID,\n\t\t},\n\t}\n\n\terr = s.Zoho.HTTPRequest(&endpoint)\n\tif err != nil {\n\t\treturn SubscriptionsResponse{}, fmt.Errorf(\"Failed to retrieve subscriptions: %s\", err)\n\t}\n\n\tif v, ok := endpoint.ResponseData.(*SubscriptionsResponse); ok {\n\t\treturn *v, nil\n\t}\n\n\treturn SubscriptionsResponse{}, fmt.Errorf(\"Data retrieved was not 'SubscriptionsResponse'\")\n}", "func (client *AvailabilitySetsClient) ListBySubscription(options *AvailabilitySetsListBySubscriptionOptions) *AvailabilitySetsListBySubscriptionPager {\n\treturn &AvailabilitySetsListBySubscriptionPager{\n\t\tclient: client,\n\t\trequester: func(ctx context.Context) (*policy.Request, error) {\n\t\t\treturn client.listBySubscriptionCreateRequest(ctx, options)\n\t\t},\n\t\tadvancer: func(ctx context.Context, resp AvailabilitySetsListBySubscriptionResponse) (*policy.Request, error) {\n\t\t\treturn runtime.NewRequest(ctx, http.MethodGet, *resp.AvailabilitySetListResult.NextLink)\n\t\t},\n\t}\n}", "func (client NotificationDataPlaneClient) listSubscriptions(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) {\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/subscriptions\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response ListSubscriptionsResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (client *OutputsClient) listByStreamingJobHandleResponse(resp *http.Response) (OutputsClientListByStreamingJobResponse, error) {\n\tresult := OutputsClientListByStreamingJobResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.OutputListResult); err != nil {\n\t\treturn OutputsClientListByStreamingJobResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *OutputsClient) listByStreamingJobHandleResponse(resp *http.Response) (OutputsListByStreamingJobResponse, error) {\n\tresult := OutputsListByStreamingJobResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.OutputListResult); err != nil {\n\t\treturn OutputsListByStreamingJobResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *RoleAssignmentsClient) listByBillingProfileHandleResponse(resp *http.Response) (RoleAssignmentsClientListByBillingProfileResponse, error) {\n\tresult := RoleAssignmentsClientListByBillingProfileResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignmentListResult); err != nil {\n\t\treturn RoleAssignmentsClientListByBillingProfileResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *RoleAssignmentsClient) listByBillingProfileHandleResponse(resp *http.Response) (RoleAssignmentsClientListByBillingProfileResponse, error) {\n\tresult := RoleAssignmentsClientListByBillingProfileResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignmentListResult); err != nil {\n\t\treturn RoleAssignmentsClientListByBillingProfileResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client LabClient) ListBySubscriptionComplete(ctx context.Context, filter string, top *int32, orderBy string) (result ResponseWithContinuationLabIterator, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/LabClient.ListBySubscription\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.Response().Response.Response != nil {\n\t\t\t\tsc = result.page.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tresult.page, err = client.ListBySubscription(ctx, filter, top, orderBy)\n\treturn\n}", "func (client *SubscriptionClient) listSecretsHandleResponse(resp *http.Response) (SubscriptionClientListSecretsResponse, error) {\n\tresult := SubscriptionClientListSecretsResponse{}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionKeysContract); err != nil {\n\t\treturn SubscriptionClientListSecretsResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *SchemaRegistryClient) listByNamespaceHandleResponse(resp *http.Response) (SchemaRegistryClientListByNamespaceResponse, error) {\n\tresult := SchemaRegistryClientListByNamespaceResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SchemaGroupListResult); err != nil {\n\t\treturn SchemaRegistryClientListByNamespaceResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client ServicesClient) ListBySubscriptionComplete(ctx context.Context) (result ServiceResourceListIterator, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/ServicesClient.ListBySubscription\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.Response().Response.Response != nil {\n\t\t\t\tsc = result.page.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tresult.page, err = client.ListBySubscription(ctx)\n\treturn\n}", "func (client *InteractionsClient) listByHubHandleResponse(resp *http.Response) (InteractionsClientListByHubResponse, error) {\n\tresult := InteractionsClientListByHubResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.InteractionListResult); err != nil {\n\t\treturn InteractionsClientListByHubResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client IotHubResourceClient) ListBySubscriptionComplete(ctx context.Context) (result IotHubDescriptionListResultIterator, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/IotHubResourceClient.ListBySubscription\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.Response().Response.Response != nil {\n\t\t\t\tsc = result.page.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tresult.page, err = client.ListBySubscription(ctx)\n\treturn\n}", "func (client *PermissionsClient) listByCustomerHandleResponse(resp *http.Response) (PermissionsClientListByCustomerResponse, error) {\n\tresult := PermissionsClientListByCustomerResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PermissionsListResult); err != nil {\n\t\treturn PermissionsClientListByCustomerResponse{}, err\n\t}\n\treturn result, nil\n}", "func (ss *SubscriptionsService) List(ctx context.Context, cID string, opts *SubscriptionListOptions) (\n\tres *Response,\n\tsl *SubscriptionList,\n\terr error,\n) {\n\tu := fmt.Sprintf(\"v2/customers/%s/subscriptions\", cID)\n\n\tres, err = ss.list(ctx, u, opts)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif err = json.Unmarshal(res.content, &sl); err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (client *RoleAssignmentsClient) listByBillingAccountHandleResponse(resp *http.Response) (RoleAssignmentsClientListByBillingAccountResponse, error) {\n\tresult := RoleAssignmentsClientListByBillingAccountResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignmentListResult); err != nil {\n\t\treturn RoleAssignmentsClientListByBillingAccountResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ProviderShareSubscriptionsClient) getByShareHandleResponse(resp *http.Response) (ProviderShareSubscriptionsClientGetByShareResponse, error) {\n\tresult := ProviderShareSubscriptionsClientGetByShareResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ProviderShareSubscription); err != nil {\n\t\treturn ProviderShareSubscriptionsClientGetByShareResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ClientImpl) ListSubscriptions(ctx context.Context, args ListSubscriptionsArgs) (*[]Subscription, error) {\n\tqueryParams := url.Values{}\n\tif args.PublisherId != nil {\n\t\tqueryParams.Add(\"publisherId\", *args.PublisherId)\n\t}\n\tif args.EventType != nil {\n\t\tqueryParams.Add(\"eventType\", *args.EventType)\n\t}\n\tif args.ConsumerId != nil {\n\t\tqueryParams.Add(\"consumerId\", *args.ConsumerId)\n\t}\n\tif args.ConsumerActionId != nil {\n\t\tqueryParams.Add(\"consumerActionId\", *args.ConsumerActionId)\n\t}\n\tlocationId, _ := uuid.Parse(\"fc50d02a-849f-41fb-8af1-0a5216103269\")\n\tresp, err := client.Client.Send(ctx, http.MethodGet, locationId, \"7.1-preview.1\", nil, queryParams, nil, \"\", \"application/json\", nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar responseValue []Subscription\n\terr = client.Client.UnmarshalCollectionBody(resp, &responseValue)\n\treturn &responseValue, err\n}", "func (client *ReplicationsClient) listHandleResponse(resp *azcore.Response) (ReplicationListResultResponse, error) {\n\tvar val *ReplicationListResult\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn ReplicationListResultResponse{}, err\n\t}\n\treturn ReplicationListResultResponse{RawResponse: resp.Response, ReplicationListResult: val}, nil\n}", "func (client *RoleAssignmentsClient) listByBillingAccountHandleResponse(resp *http.Response) (RoleAssignmentsClientListByBillingAccountResponse, error) {\n\tresult := RoleAssignmentsClientListByBillingAccountResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignmentListResult); err != nil {\n\t\treturn RoleAssignmentsClientListByBillingAccountResponse{}, err\n\t}\n\treturn result, nil\n}", "func (o *GetAllSubscriptionsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\t// return empty array\n\t\tpayload = models.SubscriptionList{}\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func (a Accessor) GetSubscriptionList(service, servicePath string, subscriptions *[]Subscription) error {\n\treturn a.access(&AccessParameter{\n\t\tEpID: EntryPointIDs.Subscriptions,\n\t\tMethod: gohttp.HttpMethods.GET,\n\t\tService: service,\n\t\tServicePath: servicePath,\n\t\tPath: \"\",\n\t\tReceivedBody: subscriptions,\n\t})\n}", "func (d *DatastoreSubscription) List() ([]*Subscription, error) {\n\treturn d.collectByField(func(s *Subscription) bool {\n\t\treturn true\n\t})\n}", "func (client *ReplicationsClient) listHandleResponse(resp *http.Response) (ReplicationsClientListResponse, error) {\n\tresult := ReplicationsClientListResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ReplicationListResult); err != nil {\n\t\treturn ReplicationsClientListResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) listHybridConnectionsSlotHandleResponse(resp *http.Response) (WebAppsListHybridConnectionsSlotResponse, error) {\n\tresult := WebAppsListHybridConnectionsSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.HybridConnection); err != nil {\n\t\treturn WebAppsListHybridConnectionsSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func UnmarshalSubscriptionList(m map[string]json.RawMessage, result interface{}) (err error) {\n\tobj := new(SubscriptionList)\n\terr = core.UnmarshalPrimitive(m, \"total_count\", &obj.TotalCount)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"offset\", &obj.Offset)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalPrimitive(m, \"limit\", &obj.Limit)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalModel(m, \"subscriptions\", &obj.Subscriptions, UnmarshalSubscriptionListItem)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalModel(m, \"first\", &obj.First, UnmarshalPageHrefResponse)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalModel(m, \"previous\", &obj.Previous, UnmarshalPageHrefResponse)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalModel(m, \"next\", &obj.Next, UnmarshalPageHrefResponse)\n\tif err != nil {\n\t\treturn\n\t}\n\treflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))\n\treturn\n}", "func (client *subscriptionClient) getHandleResponse(resp *http.Response) (SubscriptionGetResponse, error) {\n\tresult := SubscriptionGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsXML(resp, &result.Object); err != nil {\n\t\treturn SubscriptionGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ProductPolicyClient) listByProductHandleResponse(resp *http.Response) (ProductPolicyClientListByProductResponse, error) {\n\tresult := ProductPolicyClientListByProductResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PolicyCollection); err != nil {\n\t\treturn ProductPolicyClientListByProductResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *APIClient) listByServiceHandleResponse(resp *http.Response) (APIClientListByServiceResponse, error) {\n\tresult := APIClientListByServiceResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.APICollection); err != nil {\n\t\treturn APIClientListByServiceResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *RegistrationDefinitionsClient) listHandleResponse(resp *http.Response) (RegistrationDefinitionsClientListResponse, error) {\n\tresult := RegistrationDefinitionsClientListResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RegistrationDefinitionList); err != nil {\n\t\treturn RegistrationDefinitionsClientListResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *NotificationRecipientEmailClient) listByNotificationHandleResponse(resp *http.Response) (NotificationRecipientEmailClientListByNotificationResponse, error) {\n\tresult := NotificationRecipientEmailClientListByNotificationResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RecipientEmailCollection); err != nil {\n\t\treturn NotificationRecipientEmailClientListByNotificationResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *GroupClient) listByServiceHandleResponse(resp *http.Response) (GroupListByServiceResponse, error) {\n\tresult := GroupListByServiceResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.GroupCollection); err != nil {\n\t\treturn GroupListByServiceResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *HardwareComponentGroupsClient) listByDeviceHandleResponse(resp *http.Response) (HardwareComponentGroupsClientListByDeviceResponse, error) {\n\tresult := HardwareComponentGroupsClientListByDeviceResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.HardwareComponentGroupList); err != nil {\n\t\treturn HardwareComponentGroupsClientListByDeviceResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client DataControllersClient) ListInSubscription(ctx context.Context) (result PageOfDataControllerResourcePage, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/DataControllersClient.ListInSubscription\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.podcr.Response.Response != nil {\n\t\t\t\tsc = result.podcr.Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tresult.fn = client.listInSubscriptionNextResults\n\treq, err := client.ListInSubscriptionPreparer(ctx)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"azuredata.DataControllersClient\", \"ListInSubscription\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.ListInSubscriptionSender(req)\n\tif err != nil {\n\t\tresult.podcr.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"azuredata.DataControllersClient\", \"ListInSubscription\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult.podcr, err = client.ListInSubscriptionResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"azuredata.DataControllersClient\", \"ListInSubscription\", resp, \"Failure responding to request\")\n\t\treturn\n\t}\n\tif result.podcr.hasNextLink() && result.podcr.IsEmpty() {\n\t\terr = result.NextWithContext(ctx)\n\t\treturn\n\t}\n\n\treturn\n}", "func (client *DicomServicesClient) listByWorkspaceHandleResponse(resp *http.Response) (DicomServicesClientListByWorkspaceResponse, error) {\n\tresult := DicomServicesClientListByWorkspaceResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DicomServiceCollection); err != nil {\n\t\treturn DicomServicesClientListByWorkspaceResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ReplicationvCentersClient) listByReplicationFabricsHandleResponse(resp *http.Response) (ReplicationvCentersClientListByReplicationFabricsResponse, error) {\n\tresult := ReplicationvCentersClientListByReplicationFabricsResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VCenterCollection); err != nil {\n\t\treturn ReplicationvCentersClientListByReplicationFabricsResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *AccountsClient) listHandleResponse(resp *http.Response) (AccountsClientListResponse, error) {\n\tresult := AccountsClientListResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AccountListResult); err != nil {\n\t\treturn AccountsClientListResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) listRelayServiceConnectionsSlotHandleResponse(resp *http.Response) (WebAppsListRelayServiceConnectionsSlotResponse, error) {\n\tresult := WebAppsListRelayServiceConnectionsSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RelayServiceConnectionEntity); err != nil {\n\t\treturn WebAppsListRelayServiceConnectionsSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *PortalConfigClient) listByServiceHandleResponse(resp *http.Response) (PortalConfigClientListByServiceResponse, error) {\n\tresult := PortalConfigClientListByServiceResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PortalConfigCollection); err != nil {\n\t\treturn PortalConfigClientListByServiceResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebhooksClient) listHandleResponse(resp *http.Response) (WebhooksClientListResponse, error) {\n\tresult := WebhooksClientListResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.WebhookListResult); err != nil {\n\t\treturn WebhooksClientListResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ChargesClient) listHandleResponse(resp *http.Response) (ChargesClientListResponse, error) {\n\tresult := ChargesClientListResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ChargesListResult); err != nil {\n\t\treturn ChargesClientListResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client DataControllersClient) ListInSubscriptionSender(req *http.Request) (*http.Response, error) {\n\treturn client.Send(req, azure.DoRetryWithRegistration(client.Client))\n}", "func (client *LiveOutputsClient) listHandleResponse(resp *http.Response) (LiveOutputsClientListResponse, error) {\n\tresult := LiveOutputsClientListResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.LiveOutputListResult); err != nil {\n\t\treturn LiveOutputsClientListResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client IdentityClient) ListRegionSubscriptions(ctx context.Context, request ListRegionSubscriptionsRequest) (response ListRegionSubscriptionsResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.listRegionSubscriptions, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = ListRegionSubscriptionsResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = ListRegionSubscriptionsResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(ListRegionSubscriptionsResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into ListRegionSubscriptionsResponse\")\n\t}\n\treturn\n}", "func (client *WebAppsClient) listPublicCertificatesSlotHandleResponse(resp *http.Response) (WebAppsListPublicCertificatesSlotResponse, error) {\n\tresult := WebAppsListPublicCertificatesSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PublicCertificateCollection); err != nil {\n\t\treturn WebAppsListPublicCertificatesSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *VpnLinkConnectionsClient) listByVpnConnectionHandleResponse(resp *azcore.Response) (ListVpnSiteLinkConnectionsResultResponse, error) {\n\tvar val *ListVpnSiteLinkConnectionsResult\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn ListVpnSiteLinkConnectionsResultResponse{}, err\n\t}\n\treturn ListVpnSiteLinkConnectionsResultResponse{RawResponse: resp.Response, ListVpnSiteLinkConnectionsResult: val}, nil\n}", "func (client *ReplicationProtectionContainersClient) listByReplicationFabricsHandleResponse(resp *http.Response) (ReplicationProtectionContainersClientListByReplicationFabricsResponse, error) {\n\tresult := ReplicationProtectionContainersClientListByReplicationFabricsResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ProtectionContainerCollection); err != nil {\n\t\treturn ReplicationProtectionContainersClientListByReplicationFabricsResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *SubscriptionClient) getHandleResponse(resp *http.Response) (SubscriptionClientGetResponse, error) {\n\tresult := SubscriptionClientGetResponse{}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SubscriptionContract); err != nil {\n\t\treturn SubscriptionClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *CustomDomainsClient) listHandleResponse(resp *http.Response) (CustomDomainsListResponse, error) {\n\tresult := CustomDomainsListResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.CustomDomainResourceCollection); err != nil {\n\t\treturn CustomDomainsListResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *CompliancesClient) listHandleResponse(resp *http.Response) (CompliancesClientListResponse, error) {\n\tresult := CompliancesClientListResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ComplianceList); err != nil {\n\t\treturn CompliancesClientListResponse{}, err\n\t}\n\treturn result, nil\n}", "func (r *ProjectsLocationsDataExchangesListingsService) ListSubscriptions(resource string) *ProjectsLocationsDataExchangesListingsListSubscriptionsCall {\n\tc := &ProjectsLocationsDataExchangesListingsListSubscriptionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.resource = resource\n\treturn c\n}", "func (client ProviderShareSubscriptionsClient) ListByShareSender(req *http.Request) (*http.Response, error) {\n\treturn client.Send(req, azure.DoRetryWithRegistration(client.Client))\n}", "func (client *AnalysisResultsClient) listHandleResponse(resp *http.Response) (AnalysisResultsClientListResponse, error) {\n\tresult := AnalysisResultsClientListResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AnalysisResultListResult); err != nil {\n\t\treturn AnalysisResultsClientListResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *APIClient) listByTagsHandleResponse(resp *http.Response) (APIClientListByTagsResponse, error) {\n\tresult := APIClientListByTagsResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.TagResourceCollection); err != nil {\n\t\treturn APIClientListByTagsResponse{}, err\n\t}\n\treturn result, nil\n}", "func (p *Proxy) List() (data [][]string) {\n\tlumber.Trace(\"Proxy listing subscriptions...\")\n\tp.RLock()\n\tdata = p.subscriptions.ToSlice()\n\tp.RUnlock()\n\n\treturn\n}", "func (client *WebAppsClient) listWebJobsSlotHandleResponse(resp *http.Response) (WebAppsListWebJobsSlotResponse, error) {\n\tresult := WebAppsListWebJobsSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.WebJobCollection); err != nil {\n\t\treturn WebAppsListWebJobsSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) listBasicPublishingCredentialsPoliciesSlotHandleResponse(resp *http.Response) (WebAppsListBasicPublishingCredentialsPoliciesSlotResponse, error) {\n\tresult := WebAppsListBasicPublishingCredentialsPoliciesSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PublishingCredentialsPoliciesCollection); err != nil {\n\t\treturn WebAppsListBasicPublishingCredentialsPoliciesSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *AccountsClient) listSKUsHandleResponse(resp *http.Response) (AccountsClientListSKUsResponse, error) {\n\tresult := AccountsClientListSKUsResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AccountSKUListResult); err != nil {\n\t\treturn AccountsClientListSKUsResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ReplicationvCentersClient) listHandleResponse(resp *http.Response) (ReplicationvCentersClientListResponse, error) {\n\tresult := ReplicationvCentersClientListResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VCenterCollection); err != nil {\n\t\treturn ReplicationvCentersClientListResponse{}, err\n\t}\n\treturn result, nil\n}" ]
[ "0.83168864", "0.8227859", "0.81885844", "0.81504506", "0.81241256", "0.81087255", "0.809703", "0.8004202", "0.79758334", "0.79476243", "0.7904227", "0.771174", "0.76578695", "0.7624304", "0.7593285", "0.75220805", "0.74099624", "0.7322869", "0.73116237", "0.7243065", "0.70872605", "0.69773", "0.6870088", "0.685828", "0.6819468", "0.680039", "0.67371535", "0.6694174", "0.6685893", "0.66402906", "0.658273", "0.65754855", "0.6389965", "0.6314984", "0.624315", "0.6230946", "0.6225418", "0.61957043", "0.61902225", "0.6170078", "0.6166001", "0.61590093", "0.6158858", "0.61366403", "0.6109965", "0.60313", "0.603126", "0.6021949", "0.5976554", "0.5959777", "0.5951298", "0.5934279", "0.59334075", "0.5925338", "0.59096843", "0.58972335", "0.58581275", "0.5855637", "0.58533734", "0.58514977", "0.58468246", "0.58335173", "0.5824375", "0.58156157", "0.57803017", "0.5778849", "0.5764164", "0.5757568", "0.5747066", "0.5745535", "0.57236946", "0.56864893", "0.5684645", "0.5653464", "0.56485367", "0.56177855", "0.5616872", "0.56167233", "0.559794", "0.55928075", "0.55924916", "0.5589153", "0.5588475", "0.55868834", "0.5581491", "0.55785966", "0.55748004", "0.55694795", "0.556523", "0.556331", "0.556122", "0.5545853", "0.5543168", "0.5539117", "0.5515161", "0.5514001", "0.550871", "0.55054474", "0.54965156", "0.54954106" ]
0.82509714
1
StartService Starts selenium server
StartService Запускает сервер selenium
func StartService() { opts := []selenium.ServiceOption{ selenium.ChromeDriver(helpers.AutomationPath + driverPath), // Specify the path to GeckoDriver in order to use Firefox. selenium.Output(os.Stderr), // Output debug information to STDERR. } selenium.SetDebug(false) selenium, err := selenium.NewSeleniumService(helpers.AutomationPath+seleniumPath, port, opts...) if err != nil { panic(err) } seleniumService = selenium }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *Service) StartService() {\n\tutils.Logger().Info().Msg(\"Starting explorer service.\")\n\ts.Init(true)\n\ts.server = s.Run()\n}", "func (s *Service) StartService() {\n\tutils.Logger().Info().Msg(\"Starting explorer service.\")\n\ts.Init(true)\n\ts.server = s.Run()\n}", "func (env Env) StartService(c *cli.Context) error {\n\tservice := env.GetServiceDef(c)\n\tproject, err := env.GetProject()\n\tutil.CheckErrFatal(err)\n\tstartCommand := service.RunCommand(project.Network)\n\tfmt.Println(startCommand.ToString())\n\tjsonCMD, err := json.Marshal(startCommand)\n\tutil.CheckErrFatal(err)\n\tstatus := env.SendToMaster(\"start\", jsonCMD)\n\tfmt.Println(status)\n\treturn nil\n}", "func (s JSONHTTPServer) StartService(status chan bool) {\n\tgo s.startInternal(status)\n}", "func (s JSONHTTPServer) StartService(status chan bool) {\n\tgo s.startInternal(status)\n}", "func StartService(service string) error {\n\treturn doService(service, \"start\")\n}", "func StartSelenium() {\n\tvar err error\n\tcheckWebDriver()\n\tdriver, err = core.Selenium()\n\tcheckFailure(err)\n\tcheckFailure(driver.Start())\n}", "func (rs *RatchetServer) StartService() {\n\tif rs.isStarted {\n\t\treturn\n\t}\n\trs.GenerateKeys()\n\trs.fountain.StartService()\n\trs.ticker = timesource.Clock.NewTicker(time.Minute * 5)\n\tgo func() {\n\t\tfor range rs.ticker.Chan() {\n\t\t\t// Pregenerate.\n\t\t\trs.GenerateKeys()\n\t\t\t// Call persistence.\n\t\t\tif err := rs.persist(); err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t}\n\t}()\n}", "func startSeleniumServerOrCrash() *exec.Cmd {\n\tmyLog.Info(\"Starting Selenium server...\")\n\tcmd := exec.Command(\"/opt/bin/entry_point.sh\")\n\n\tstderr, err := cmd.StderrPipe()\n\tif err != nil {\n\t\tmyLog.Fatal(err)\n\t}\n\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\tmyLog.Fatal(err)\n\t}\n\n\tgo func() {\n\t\tscanner := bufio.NewScanner(stderr)\n\t\tfor scanner.Scan() {\n\t\t\tmyLog.Error(scanner.Text())\n\t\t}\n\t\tif err := scanner.Err(); err != nil {\n\t\t\tmyLog.Fatal(err)\n\t\t}\n\t}()\n\n\tgo func() {\n\t\tscanner := bufio.NewScanner(stdout)\n\t\tfor scanner.Scan() {\n\t\t\tmyLog.Info(scanner.Text())\n\t\t}\n\t\tif err := scanner.Err(); err != nil {\n\t\t\tmyLog.Fatal(err)\n\t\t}\n\t}()\n\n\terr = cmd.Start()\n\tif err != nil {\n\t\tmyLog.Fatal(\"Cannot start Selenium process:\", err)\n\t}\n\n\treturn cmd\n}", "func (m *mockService) Start() {\n\tif err := m.server.Bootstrap(); err != nil {\n\t\tpanic(err)\n\t}\n\tm.started = true\n}", "func StartTelemetryService() error {\n\tplatform.KillProcessByName(telemetryServiceProcessName)\n\n\ttelemetryLogger.Printf(\"[Telemetry] Starting telemetry service process\")\n\tpath := fmt.Sprintf(\"%v/%v\", cniInstallDir, telemetryServiceProcessName)\n\tif err := common.StartProcess(path); err != nil {\n\t\ttelemetryLogger.Printf(\"[Telemetry] Failed to start telemetry service process :%v\", err)\n\t\treturn err\n\t}\n\n\ttelemetryLogger.Printf(\"[Telemetry] Telemetry service started\")\n\n\tfor attempt := 0; attempt < 5; attempt++ {\n\t\tif checkIfSockExists() {\n\t\t\tbreak\n\t\t}\n\n\t\ttime.Sleep(200 * time.Millisecond)\n\t}\n\n\treturn nil\n}", "func (s *JSONHTTPServer) StartService() {\n\tgo s.startInternal()\n}", "func StartService() {\n\tlog.Printf(\"Starting weather web service\\n\")\n\tmux := http.NewServeMux()\n\n\tmux.HandleFunc(\"/weather\", weatherHandler)\n\tmux.HandleFunc(\"/health-check\", healthCheck)\n\tlog.Fatal(http.ListenAndServe(fmt.Sprintf(\":%d\", shared.WeatherPort), mux))\n}", "func (n *Node) StartService() {\n\tif n.stopServer != nil {\n\t\treturn\n\t}\n\n\tif n.service.listen == nil {\n\t\tn.service.listen = network.TCPListener\n\t}\n\n\tvar genesis hash.Hash\n\tif n.consensus != nil {\n\t\tgenesis = n.consensus.GetGenesisHash()\n\t}\n\n\tbind := n.NetAddrOf(n.host)\n\t_, n.Addr, n.stopServer = api.StartService(bind, n.key, genesis, n, n.Infof, n.service.listen)\n}", "func Start() {\n\tdriver.Main(func(app oswin.App) {\n\t\tatomic.AddInt32(&started, 1)\n\t\t<-quit\n\t})\n}", "func (s *AngularService) Start() (err error) {\n\tif s.options.Cd != \"\" {\n\t\tvar currDir string\n\t\tif currDir, err = os.Getwd(); err != nil {\n\t\t\treturn\n\t\t}\n\t\tif err = os.Chdir(s.options.Cd); err != nil {\n\t\t\treturn\n\t\t}\n\t\tdefer os.Chdir(currDir)\n\t}\n\n\tvar ctx context.Context\n\n\tctx, s.ctxCancel = context.WithCancel(context.Background())\n\ts.done = ctx.Done()\n\n\tcmdArgs := []string{\"serve\"}\n\tif s.options.Port > 0 {\n\t\tcmdArgs = append(cmdArgs, \"--port\", strconv.Itoa(s.options.Port))\n\t}\n\n\tif s.options.Args != nil {\n\t\tcmdArgs = append(cmdArgs, s.options.Args...)\n\t}\n\n\tcmd := exec.CommandContext(ctx, \"ng\", cmdArgs...)\n\n\tif s.options.Stdout != nil {\n\t\tcmd.Stdout = s.options.Stdout\n\t}\n\tif s.options.Stderr != nil {\n\t\tcmd.Stderr = s.options.Stderr\n\t}\n\n\treturn cmd.Start()\n}", "func (s *JSONHTTPServer) StartService(\n\tctx context.Context,\n\tservices ...ServiceAPI,\n) <-chan struct{} {\n\tstarted := make(chan struct{})\n\n\t// This will block, so run it in a goroutine\n\tgo s.startInternal(\n\t\tctx,\n\t\tstarted,\n\t\tservices...)\n\n\treturn started\n}", "func main() {\n\tservice.StartWebServer(\"8081\")\n}", "func (s *MockServer) Start(ctx context.Context, cancelFunc context.CancelFunc) error {\n\ts.LogInfo(nil, \"starting http mock server on: %s\", s.cfg.Address)\n\tlistener, err := net.Listen(\"tcp\", s.cfg.Address)\n\tif err != nil {\n\t\treturn err\n\t}\n\tutil.StartServiceAsync(ctx, cancelFunc, s.Logger, func() error {\n\t\treturn http.Serve(listener, s)\n\t}, func() error {\n\t\treturn listener.Close()\n\t})\n\treturn nil\n}", "func (sv *Unit) Start() (err error) {\n\te := log.WithField(\"ExecStart\", sv.Definition.Service.ExecStart)\n\n\te.Debug(\"sv.Start\")\n\n\tswitch sv.Definition.Service.Type {\n\tcase \"simple\":\n\t\tif err = sv.Cmd.Start(); err == nil {\n\t\t\tgo sv.Cmd.Wait()\n\t\t}\n\tcase \"oneshot\":\n\t\terr = sv.Cmd.Run()\n\tdefault:\n\t\tpanic(\"Unknown service type\")\n\t}\n\n\te.WithField(\"err\", err).Debug(\"started\")\n\treturn\n}", "func StopService() {\n\tseleniumService.Stop()\n}", "func WDInit() selenium.WebDriver {\n\tvar err error\n\n\tops := []selenium.ServiceOption{\n\t\tselenium.ChromeDriver(seleniumPath),\n\t}\n\n\t//service, err := selenium.NewSeleniumService(seleniumPath, port, ops...)\n\tservice, err := selenium.NewChromeDriverService(chromeDriverPath, port, ops...)\n\tif err != nil {\n\t\tlog.Printf(\"Error starting the ChromeDriver server: %v\", err)\n\t}\n\t//Delay service shutdown\n\tdefer service.Stop()\n\n\t//log.Println(\"Service => \", service)\n\n\tcaps := selenium.Capabilities(map[string]interface{}{\"browserName\": \"chrome\"})\n\t//log.Println(\"Capabilities => \", caps)\n\n\tdriver, err := selenium.NewRemote(caps, \"\")\n\n\tif err != nil {\n\t\tlog.Println(\"support/base | Error al instanciar el driver de Selenium : \", err.Error())\n\t}\n\t//driver.ResizeWindow(\"note\", 1920, 1080)\n\treturn driver\n}", "func (m *MockCSIDriver) Start() error {\n\t// Listen on a port assigned by the net package\n\treturn m.StartOnAddress(\"tcp\", \"127.0.0.1:0\")\n}", "func StartTaskService(brain *brain.Manager, errChan chan error) {\n\tlis, err := net.Listen(\"tcp\", taskServicePort)\n\tif err != nil {\n\t\terrChan <- err\n\t\treturn\n\t}\n\n\tgrpcServer := grpc.NewServer()\n\n\tRegisterTaskServiceServer(grpcServer, TaskService{Manager: brain})\n\n\tlog.LogInfo(\"starting taask-server task service on :3688\")\n\tif err := grpcServer.Serve(lis); err != nil {\n\t\terrChan <- err\n\t}\n}", "func StartTelemetryService(path string, args []string) error {\n\tplatform.KillProcessByName(TelemetryServiceProcessName)\n\n\tlog.Logf(\"[Telemetry] Starting telemetry service process :%v args:%v\", path, args)\n\n\tif err := common.StartProcess(path, args); err != nil {\n\t\tlog.Logf(\"[Telemetry] Failed to start telemetry service process :%v\", err)\n\t\treturn err\n\t}\n\n\tlog.Logf(\"[Telemetry] Telemetry service started\")\n\n\treturn nil\n}", "func StartTelemetryService(path string, args []string) error {\n\tplatform.KillProcessByName(TelemetryServiceProcessName)\n\n\tlog.Logf(\"[Telemetry] Starting telemetry service process :%v args:%v\", path, args)\n\n\tif err := common.StartProcess(path, args); err != nil {\n\t\tlog.Logf(\"[Telemetry] Failed to start telemetry service process :%v\", err)\n\t\treturn err\n\t}\n\n\tlog.Logf(\"[Telemetry] Telemetry service started\")\n\n\treturn nil\n}", "func (s *Envoy) Start() error {\n\terr := s.cmd.Start()\n\tif err == nil {\n\t\turl := fmt.Sprintf(\"http://localhost:%v/server_info\", s.ports.AdminPort)\n\t\tWaitForHTTPServer(url)\n\t\tWaitForPort(s.ports.ClientProxyPort)\n\t\tWaitForPort(s.ports.ServerProxyPort)\n\t\tWaitForPort(s.ports.TCPProxyPort)\n\t}\n\treturn err\n}", "func StartService() *service.Service {\n\t//TODO StartService could return an error in case it fails to start\n\n\taccessManager := CreateAccessManager()\n\tmessageStore := CreateMessageStore()\n\tkvStore := CreateKVStore()\n\n\tvar cl *cluster.Cluster\n\tvar err error\n\n\tif *Config.Cluster.NodeID > 0 {\n\t\texitIfInvalidClusterParams(*Config.Cluster.NodeID, *Config.Cluster.NodePort, *Config.Cluster.Remotes)\n\t\tlogger.Info(\"Starting in cluster-mode\")\n\t\tcl, err = cluster.New(&cluster.Config{\n\t\t\tID: *Config.Cluster.NodeID,\n\t\t\tPort: *Config.Cluster.NodePort,\n\t\t\tRemotes: *Config.Cluster.Remotes,\n\t\t})\n\t\tif err != nil {\n\t\t\tlogger.WithField(\"err\", err).Fatal(\"Module could not be started (cluster)\")\n\t\t}\n\t} else {\n\t\tlogger.Info(\"Starting in standalone-mode\")\n\t}\n\n\tr := router.New(accessManager, messageStore, kvStore, cl)\n\twebsrv := webserver.New(*Config.HttpListen)\n\n\tsrv := service.New(r, websrv).\n\t\tHealthEndpoint(*Config.HealthEndpoint).\n\t\tMetricsEndpoint(*Config.MetricsEndpoint)\n\n\tsrv.RegisterModules(0, 6, kvStore, messageStore)\n\tsrv.RegisterModules(4, 3, CreateModules(r)...)\n\n\tif err = srv.Start(); err != nil {\n\t\tlogger.WithField(\"error\", err.Error()).Error(\"errors occurred while starting service\")\n\t\tif err = srv.Stop(); err != nil {\n\t\t\tlogger.WithField(\"error\", err.Error()).Error(\"errors occurred when stopping service after it failed to start\")\n\t\t}\n\t\treturn nil\n\t}\n\n\treturn srv\n}", "func (s *GrpcServer) startGrpcService() {\n\t// Start listening for requests\n\treflection.Register(s.server)\n\tlogrus.Infof(\"%s gRPC Server ready on %s\", s.name, s.Address())\n\twaitForServer := make(chan bool)\n\ts.goServe(waitForServer)\n\t<-waitForServer\n\ts.running = true\n}", "func (p *PodmanTestIntegration) StartRemoteService() {\n}", "func StartDownloadService() {\n\tdownloadYoutubeDLIfRequiredWithConsoleOutput(GetConfVal(\"youtubeDownloader\"))\n\tdownloadLoop()\n}", "func Start(ctx context.Context, config *Config) error {\n\tlog.Debug(\"start application\")\n\n\tserviceRepo := service.NewRepository()\n\n\tserviceConfig := service.Config{\n\t\tNoTrackMode: config.NoTrackMode,\n\t\tConnDefaults: config.Defaults,\n\t\tConnsSettings: config.ServicesConnsSettings,\n\t\tDatabasesRE: config.DatabasesRE,\n\t\tDisabledCollectors: config.DisableCollectors,\n\t\tCollectorsSettings: config.CollectorsSettings,\n\t}\n\n\tvar wg sync.WaitGroup\n\tctx, cancel := context.WithCancel(ctx)\n\n\tif config.ServicesConnsSettings == nil || len(config.ServicesConnsSettings) == 0 {\n\t\t// run background discovery, the service repo will be fulfilled at first iteration\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tserviceRepo.StartBackgroundDiscovery(ctx, serviceConfig)\n\t\t\twg.Done()\n\t\t}()\n\t} else {\n\t\t// fulfill service repo using passed services\n\t\tserviceRepo.AddServicesFromConfig(serviceConfig)\n\n\t\t// setup exporters for all services\n\t\terr := serviceRepo.SetupServices(serviceConfig)\n\t\tif err != nil {\n\t\t\tcancel()\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Start auto-update loop if it is enabled.\n\tif config.AutoUpdate != \"off\" {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tac := &autoupdate.Config{\n\t\t\t\tBinaryPath: config.BinaryPath,\n\t\t\t\tBinaryVersion: config.BinaryVersion,\n\t\t\t\tUpdatePolicy: config.AutoUpdate,\n\t\t\t}\n\t\t\tautoupdate.StartAutoupdateLoop(ctx, ac)\n\t\t\twg.Done()\n\t\t}()\n\t}\n\n\terrCh := make(chan error)\n\tdefer close(errCh)\n\n\t// Start HTTP metrics listener.\n\twg.Add(1)\n\tgo func() {\n\t\tif err := runMetricsListener(ctx, config); err != nil {\n\t\t\terrCh <- err\n\t\t}\n\t\twg.Done()\n\t}()\n\n\t// Start metrics sender if necessary.\n\tif config.SendMetricsURL != \"\" {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tif err := runSendMetricsLoop(ctx, config, serviceRepo); err != nil {\n\t\t\t\terrCh <- err\n\t\t\t}\n\t\t\twg.Done()\n\t\t}()\n\t}\n\n\t// Waiting for errors or context cancelling.\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tlog.Info(\"exit signaled, stop application\")\n\t\t\tcancel()\n\t\t\twg.Wait()\n\t\t\treturn nil\n\t\tcase err := <-errCh:\n\t\t\tcancel()\n\t\t\twg.Wait()\n\t\t\treturn err\n\t\t}\n\t}\n}", "func StartSomeService(serviceName string) {\n\tsrv := service.NewDefaultService(serviceName)\n\t_ = srv.Start()\n}", "func runService(ctx context.Context, targetDir string, service string) {\n\t// Save and restore lsater current working dir\n\twd, err := os.Getwd()\n\tcheck(err)\n\tdefer os.Chdir(wd)\n\n\t// Build the server if needed\n\t_, err = os.Stat(\"./\" + service)\n\tif os.IsNotExist(err) {\n\t\tout, err := exec.Command(\"go\", \"build\", \".\").CombinedOutput()\n\t\tlog.Println(out)\n\t\tcheck(err)\n\t}\n\n\tcmd := exec.CommandContext(ctx, \"./\"+service)\n\terr = cmd.Start()\n\tcheck(err)\n}", "func Start(r chi.Router, lg *logrus.Logger, cfg *Config) {\n\ts := &http.Server{\n\t\tAddr: cfg.Port,\n\t\tReadTimeout: time.Duration(cfg.ReadTimeoutSeconds) * time.Second,\n\t\tWriteTimeout: time.Duration(cfg.WriteTimeoutSeconds) * time.Second,\n\t\tHandler: r,\n\t}\n\n\tgo func() {\n\t\tlg.Infof(\"service started from port: %v\", cfg.Port)\n\t\tif err := s.ListenAndServe(); err != nil {\n\t\t\tlg.Info(\"Shutting down the server\")\n\t\t}\n\t}()\n\n\t// Wait for interrupt signal to gracefully shutdown the server with\n\t// a timeout of 10 seconds.\n\tquit := make(chan os.Signal)\n\tsignal.Notify(quit, os.Interrupt)\n\t<-quit\n\tlg.Info(\"server stoped\")\n\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\tdefer cancel()\n\tif err := s.Shutdown(ctx); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n}", "func (env *Environment) StartService(ctx context.Context, conf *config.Config) ([]net.Listener, error) {\n\tif err := env.InitGenesisChunks(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tenv.Listeners = []string{\n\t\tfmt.Sprintf(\"Listener(@%v)\", conf.P2P.ExternalAddress),\n\t}\n\n\tlistenAddrs := strings.SplitAndTrimEmpty(conf.RPC.ListenAddress, \",\", \" \")\n\troutes := NewRoutesMap(env, &RouteOptions{\n\t\tUnsafe: conf.RPC.Unsafe,\n\t})\n\n\tcfg := rpcserver.DefaultConfig()\n\tcfg.MaxBodyBytes = conf.RPC.MaxBodyBytes\n\tcfg.MaxHeaderBytes = conf.RPC.MaxHeaderBytes\n\tcfg.MaxOpenConnections = conf.RPC.MaxOpenConnections\n\t// If necessary adjust global WriteTimeout to ensure it's greater than\n\t// TimeoutBroadcastTxCommit.\n\t// See https://github.com/tendermint/tendermint/issues/3435\n\tif cfg.WriteTimeout <= conf.RPC.TimeoutBroadcastTxCommit {\n\t\tcfg.WriteTimeout = conf.RPC.TimeoutBroadcastTxCommit + 1*time.Second\n\t}\n\n\t// If the event log is enabled, subscribe to all events published to the\n\t// event bus, and forward them to the event log.\n\tif lg := env.EventLog; lg != nil {\n\t\t// TODO(creachadair): This is kind of a hack, ideally we'd share the\n\t\t// observer with the indexer, but it's tricky to plumb them together.\n\t\t// For now, use a \"normal\" subscription with a big buffer allowance.\n\t\t// The event log should always be able to keep up.\n\t\tconst subscriberID = \"event-log-subscriber\"\n\t\tsub, err := env.EventBus.SubscribeWithArgs(ctx, tmpubsub.SubscribeArgs{\n\t\t\tClientID: subscriberID,\n\t\t\tQuery: query.All,\n\t\t\tLimit: 1 << 16, // essentially \"no limit\"\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"event log subscribe: %w\", err)\n\t\t}\n\t\tgo func() {\n\t\t\t// N.B. Use background for unsubscribe, ctx is already terminated.\n\t\t\tdefer env.EventBus.UnsubscribeAll(context.Background(), subscriberID) // nolint:errcheck\n\t\t\tfor {\n\t\t\t\tmsg, err := sub.Next(ctx)\n\t\t\t\tif err != nil {\n\t\t\t\t\tenv.Logger.Error(\"Subscription terminated\", \"err\", err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tetype, ok := eventlog.FindType(msg.Events())\n\t\t\t\tif ok {\n\t\t\t\t\t_ = lg.Add(etype, msg.Data())\n\t\t\t\t}\n\t\t\t}\n\t\t}()\n\n\t\tenv.Logger.Info(\"Event log subscription enabled\")\n\t}\n\n\t// We may expose the RPC over both TCP and a Unix-domain socket.\n\tlisteners := make([]net.Listener, len(listenAddrs))\n\tfor i, listenAddr := range listenAddrs {\n\t\tmux := http.NewServeMux()\n\t\trpcLogger := env.Logger.With(\"module\", \"rpc-server\")\n\t\trpcserver.RegisterRPCFuncs(mux, routes, rpcLogger)\n\n\t\tif conf.RPC.ExperimentalDisableWebsocket {\n\t\t\trpcLogger.Info(\"Disabling websocket endpoints (experimental-disable-websocket=true)\")\n\t\t} else {\n\t\t\trpcLogger.Info(\"WARNING: Websocket RPC access is deprecated and will be removed \" +\n\t\t\t\t\"in Tendermint v0.37. See https://tinyurl.com/adr075 for more information.\")\n\t\t\twmLogger := rpcLogger.With(\"protocol\", \"websocket\")\n\t\t\twm := rpcserver.NewWebsocketManager(wmLogger, routes,\n\t\t\t\trpcserver.OnDisconnect(func(remoteAddr string) {\n\t\t\t\t\terr := env.EventBus.UnsubscribeAll(context.Background(), remoteAddr)\n\t\t\t\t\tif err != nil && err != tmpubsub.ErrSubscriptionNotFound {\n\t\t\t\t\t\twmLogger.Error(\"Failed to unsubscribe addr from events\", \"addr\", remoteAddr, \"err\", err)\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\trpcserver.ReadLimit(cfg.MaxBodyBytes),\n\t\t\t)\n\t\t\tmux.HandleFunc(\"/websocket\", wm.WebsocketHandler)\n\t\t}\n\n\t\tlistener, err := rpcserver.Listen(\n\t\t\tlistenAddr,\n\t\t\tcfg.MaxOpenConnections,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvar rootHandler http.Handler = mux\n\t\tif conf.RPC.IsCorsEnabled() {\n\t\t\tcorsMiddleware := cors.New(cors.Options{\n\t\t\t\tAllowedOrigins: conf.RPC.CORSAllowedOrigins,\n\t\t\t\tAllowedMethods: conf.RPC.CORSAllowedMethods,\n\t\t\t\tAllowedHeaders: conf.RPC.CORSAllowedHeaders,\n\t\t\t})\n\t\t\trootHandler = corsMiddleware.Handler(mux)\n\t\t}\n\t\tif conf.RPC.IsTLSEnabled() {\n\t\t\tgo func() {\n\t\t\t\tif err := rpcserver.ServeTLS(\n\t\t\t\t\tctx,\n\t\t\t\t\tlistener,\n\t\t\t\t\trootHandler,\n\t\t\t\t\tconf.RPC.CertFile(),\n\t\t\t\t\tconf.RPC.KeyFile(),\n\t\t\t\t\trpcLogger,\n\t\t\t\t\tcfg,\n\t\t\t\t); err != nil {\n\t\t\t\t\tenv.Logger.Error(\"error serving server with TLS\", \"err\", err)\n\t\t\t\t}\n\t\t\t}()\n\t\t} else {\n\t\t\tgo func() {\n\t\t\t\tif err := rpcserver.Serve(\n\t\t\t\t\tctx,\n\t\t\t\t\tlistener,\n\t\t\t\t\trootHandler,\n\t\t\t\t\trpcLogger,\n\t\t\t\t\tcfg,\n\t\t\t\t); err != nil {\n\t\t\t\t\tenv.Logger.Error(\"error serving server\", \"err\", err)\n\t\t\t\t}\n\t\t\t}()\n\t\t}\n\n\t\tlisteners[i] = listener\n\t}\n\n\treturn listeners, nil\n\n}", "func (vs *VolMgrServer) StartService() {\n\n\tlis, err := net.Listen(\"tcp\", vs.Addr.Grpc)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Failed to listen on:%v\", vs.Addr.Grpc))\n\t}\n\ts := grpc.NewServer()\n\tvp.RegisterVolMgrServer(s, vs)\n\treflection.Register(s)\n\tif err := s.Serve(lis); err != nil {\n\t\tpanic(\"Failed to serve\")\n\t}\n}", "func Start(ctx context.Context, config *Config) error {\n\tlog.Debug(\"start application\")\n\n\tserviceRepo := service.NewRepository()\n\n\tserviceConfig := service.Config{\n\t\tNoTrackMode: config.NoTrackMode,\n\t\tConnDefaults: config.Defaults,\n\t\tConnsSettings: config.ServicesConnsSettings,\n\t\tDatabasesRE: config.DatabasesRE,\n\t\tDisabledCollectors: config.DisableCollectors,\n\t\tCollectorsSettings: config.CollectorsSettings,\n\t}\n\n\tvar wg sync.WaitGroup\n\tctx, cancel := context.WithCancel(ctx)\n\n\tif config.ServicesConnsSettings == nil {\n\t\t// run background discovery, the service repo will be fulfilled at first iteration\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tserviceRepo.StartBackgroundDiscovery(ctx, serviceConfig)\n\t\t\twg.Done()\n\t\t}()\n\t} else {\n\t\t// fulfill service repo using passed services\n\t\tserviceRepo.AddServicesFromConfig(serviceConfig)\n\n\t\t// setup exporters for all services\n\t\terr := serviceRepo.SetupServices(serviceConfig)\n\t\tif err != nil {\n\t\t\tcancel()\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Start auto-update loop if it is enabled.\n\tif config.AutoUpdate != \"off\" {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tac := &autoupdate.Config{\n\t\t\t\tBinaryPath: config.BinaryPath,\n\t\t\t\tBinaryVersion: config.BinaryVersion,\n\t\t\t\tUpdatePolicy: config.AutoUpdate,\n\t\t\t}\n\t\t\tautoupdate.StartAutoupdateLoop(ctx, ac)\n\t\t\twg.Done()\n\t\t}()\n\t}\n\n\terrCh := make(chan error)\n\tdefer close(errCh)\n\n\t// Start HTTP metrics listener.\n\twg.Add(1)\n\tgo func() {\n\t\tif err := runMetricsListener(ctx, config); err != nil {\n\t\t\terrCh <- err\n\t\t}\n\t\twg.Done()\n\t}()\n\n\t// Start metrics sender if necessary.\n\tif config.SendMetricsURL != \"\" {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tif err := runSendMetricsLoop(ctx, config, serviceRepo); err != nil {\n\t\t\t\terrCh <- err\n\t\t\t}\n\t\t\twg.Done()\n\t\t}()\n\t}\n\n\t// Waiting for errors or context cancelling.\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tlog.Info(\"exit signaled, stop application\")\n\t\t\tcancel()\n\t\t\twg.Wait()\n\t\t\treturn nil\n\t\tcase err := <-errCh:\n\t\t\tcancel()\n\t\t\twg.Wait()\n\t\t\treturn err\n\t\t}\n\t}\n}", "func main() {\n\tservice := service.Service{}\n\tservice.Start(\"\")\n}", "func start() {\n\n\tif LOGERR != nil {\n\t\tpanic(LOGERR)\n\t}\n\n\tservicePath := &CONFIG.ServiceConfig.Path\n\tremoveSlashes(servicePath)\n\n\tdb := new(DB)\n\tdb.getClient()\n\n\tLOGGER.Warning(fmt.Sprintf(\"Scanning %s\\n\", *servicePath))\n\n\tif _, err := os.Stat(\"/\" + *servicePath); err != nil {\n\t\tif crErr := os.Mkdir(\"/\"+*servicePath, 0755); crErr != nil {\n\t\t\tLOGGER.Crit(fmt.Sprintf(\"Scanning %s failed - directory does not exist and is not creatable\\n\", *servicePath))\n\t\t\tfmt.Printf(\"Scanning %s failed - directory does not exist and is not creatable\\n\", *servicePath)\n\t\t\tusage(1)\n\t\t}\n\t}\n\n\trunningServices := make(map[string]*Service)\n\n\t// Loop knownServices and services in directory\n\t// If differ, decide which to remove or add\n\tfor {\n\t\tservicesInDir := readServiceDir(servicePath)\n\t\tdb.createNewServicesIfNeeded(&servicesInDir, servicePath)\n\t\tknownServices := db.getServices()\n\n\t\tfor serviceName, service := range knownServices {\n\t\t\tserviceName := serviceName\n\t\t\tservice := service\n\n\t\t\tsrvDone := make(chan error, 1)\n\n\t\t\t_, ok := runningServices[serviceName]\n\t\t\tif ok != true {\n\t\t\t\t// service is not yet running\n\t\t\t\t// so start it and a logger\n\t\t\t\tgo func() {\n\t\t\t\t\terr1 := updateServicePaths(&knownServices, servicePath)\n\t\t\t\t\terr2 := removeServiceBefore(&servicesInDir, serviceName)\n\t\t\t\t\tif err1 == nil && err2 == nil {\n\t\t\t\t\t\tLOGGER.Debug(fmt.Sprintf(\"%s not yet running\\n\", serviceName))\n\t\t\t\t\t\ttime.Sleep(1 * time.Second)\n\t\t\t\t\t\tsv := new(ServiceHandler)\n\t\t\t\t\t\tsv.mutex = &sync.Mutex{}\n\t\t\t\t\t\tsv.service = service\n\t\t\t\t\t\tsv.startService(srvDone, runningServices, serviceName)\n\t\t\t\t\t}\n\t\t\t\t}()\n\t\t\t} else {\n\t\t\t\t// the service is running\n\t\t\t\t// but might have been removed manually (rm)\n\t\t\t\terr := removeServiceAfter(&servicesInDir, serviceName, runningServices[serviceName], srvDone)\n\t\t\t\tif err == nil {\n\t\t\t\t\tLOGGER.Debug(fmt.Sprintf(\"%s already running\\n\", serviceName))\n\t\t\t\t} else {\n\t\t\t\t\tdelete(runningServices, serviceName)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\ttime.Sleep(5 * time.Second)\n\t}\n\n\tLOGGER.Warning(\"exiting\")\n}", "func Start(args ...string) {\n runInstances(\"Start\", func(i int, id string) error {\n return runDaemon(\"run\", settingsToParams(i, true)...)\n })\n\n if cfg.UseNginx {\n UpdateNginxConf()\n }\n}", "func (s *Service) Start() error {\r\n\ts.logger.Debug(\"Starting health monitor service\")\r\n\r\n\t//todo - create web servier\r\n\t//\t - expose prometheus endpoint from metric manager\r\n\r\n\tsAdminPort := fmt.Sprintf(\":%v\", s.adminPort)\r\n\ts.logger.Debug(fmt.Sprintf(\"running /metrics endpoint on %s\", sAdminPort))\r\n\r\n\thttp.Handle(\"/metrics\", s.metrics.MetricEndpoint())\r\n\tgo http.ListenAndServe(sAdminPort, nil)\r\n\r\n\ts.logger.Debug(\"Running metrics service\")\r\n\tgo s.metrics.Run()\r\n\r\n\t// if err := s.Admin.Serve(); err != nil {\r\n\t// \treturn fmt.Errorf(\"cannot start the admin server: %w\", err)\r\n\t// }\r\n\r\n\tfor _, val := range s.monitors {\r\n\t\ts.logger.Debug(fmt.Sprintf(\"Starting monitor %s [%T] \", val.Identifier(), val))\r\n\t\tval.Start()\r\n\t}\r\n\r\n\treturn nil\r\n}", "func (s *Service) BeforeStart(ctx context.Context) error {\n\tlog.Info(ctx, \"ui> Starting service %s %s...\", s.Cfg.Name, sdk.VERSION)\n\ts.StartupTime = time.Now()\n\n\tfromTmpl, err := s.prepareIndexHTML()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := s.checkStaticFiles(ctx); err != nil {\n\t\treturn err\n\t}\n\n\tif fromTmpl {\n\t\t// if we have a index.tmpl, it's from a ui.tar.gz\n\t\t// we can check the checksum or files based on FILES_UI\n\t\tif err := s.checkChecksumFiles(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif err := s.indexHTMLReplaceVar(); err != nil {\n\t\treturn err\n\t}\n\n\t//Init the http server\n\ts.initRouter(ctx)\n\ts.Server = &http.Server{\n\t\tAddr: fmt.Sprintf(\"%s:%d\", s.Cfg.HTTP.Addr, s.Cfg.HTTP.Port),\n\t\tHandler: s.Router.Mux,\n\t\tReadTimeout: 10 * time.Minute,\n\t\tWriteTimeout: 10 * time.Minute,\n\t\tMaxHeaderBytes: 1 << 20,\n\t}\n\n\t// Start the http server\n\ts.GoRoutines.Run(ctx, \"ui-http-serve\", func(ctx context.Context) {\n\t\tlog.Info(ctx, \"ui> Starting HTTP Server on port %d\", s.Cfg.HTTP.Port)\n\t\tif err := s.Server.ListenAndServe(); err != nil {\n\t\t\tlog.Error(ctx, \"ui> Listen and serve failed: %s\", err)\n\t\t}\n\t})\n\n\treturn nil\n}", "func Start() {\n\tglobalLock.Lock()\n\tif started {\n\t\tglobalLock.Unlock()\n\t\treturn\n\t}\n\tstarted = true\n\tglobalLock.Unlock()\n\n\tconst svcName = \"gopherbot\"\n\tvar err error\n\tisIntSess, err = svc.IsAnInteractiveSession()\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to determine if we are running in an interactive session: %v\", err)\n\t}\n\n\tvar installdir, localdir string\n\n\t// Process command-line flags\n\tvar configDir string\n\tcusage := \"path to the local configuration directory\"\n\tflag.StringVar(&configDir, \"config\", \"\", cusage)\n\tflag.StringVar(&configDir, \"c\", \"\", cusage+\" (shorthand)\")\n\tvar logFile string\n\tlusage := \"path to robot's log file\"\n\tflag.StringVar(&logFile, \"log\", \"\", lusage)\n\tflag.StringVar(&logFile, \"l\", \"\", lusage+\" (shorthand)\")\n\tvar winCommand string\n\tif isIntSess {\n\t\twusage := \"manage Windows service, one of: install, remove, start, stop\"\n\t\tflag.StringVar(&winCommand, \"winsvc\", \"\", wusage)\n\t\tflag.StringVar(&winCommand, \"w\", \"\", wusage+\" (shorthand)\")\n\t}\n\tflag.Parse()\n\n\tif winCommand != \"\" {\n\t\tswitch winCommand {\n\t\tcase \"install\":\n\t\t\tvar args []string\n\t\t\tif configDir != \"\" {\n\t\t\t\targs = append(args, \"-c\", configDir)\n\t\t\t}\n\t\t\terr = installService(svcName, \"Gopherbot ChatOps chat bot\", args)\n\t\tcase \"remove\":\n\t\t\terr = removeService(svcName)\n\t\tcase \"start\":\n\t\t\terr = startService(svcName)\n\t\tcase \"stop\":\n\t\t\terr = controlService(svcName, svc.Stop, svc.Stopped)\n\t\tcase \"pause\":\n\t\t\terr = controlService(svcName, svc.Pause, svc.Paused)\n\t\tcase \"continue\":\n\t\t\terr = controlService(svcName, svc.Continue, svc.Running)\n\t\tdefault:\n\t\t\tlog.Fatalf(\"invalid command %s\", winCommand)\n\t\t}\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed to %s %s: %v\", winCommand, svcName, err)\n\t\t}\n\t\treturn\n\t}\n\n\tif isIntSess {\n\t\tbotLogger = log.New(os.Stdout, \"\", log.LstdFlags)\n\t} else {\n\t\tif logFile == \"\" {\n\t\t\tlogFile = \"C:/Windows/Temp/gopherbot-startup.log\"\n\t\t}\n\t\tvar f *os.File\n\t\tf, err = os.Create(logFile)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"Unable to open log file\")\n\t\t}\n\t\tbotLogger = log.New(f, \"\", log.LstdFlags)\n\t}\n\tbotLogger.Println(\"Starting up ...\")\n\n\t// Installdir is where the default config and stock external\n\t// plugins are. Search some likely locations in case installDir\n\t// wasn't passed on the command line, or Gopherbot isn't installed\n\t// in one of the usual system locations.\n\tex, err := os.Executable()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tinstalldir, err = filepath.Abs(filepath.Dir(ex))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Localdir is where all user-supplied configuration and\n\t// external plugins are.\n\tconfSearchPath := []string{\n\t\tconfigDir,\n\t\t`C:/ProgramData/Gopherbot`,\n\t}\n\thome := os.Getenv(\"USERPROFILE\")\n\tif len(home) > 0 {\n\t\tconfSearchPath = append(confSearchPath, home+\"/.gopherbot\")\n\t}\n\tfor _, spath := range confSearchPath {\n\t\tif len(spath) > 0 && dirExists(spath) {\n\t\t\tlocaldir = spath\n\t\t\tbreak\n\t\t}\n\t}\n\tif len(localdir) == 0 {\n\t\tbotLogger.Println(\"Couldn't locate local configuration directory, exiting\")\n\t\tos.Exit(0)\n\t}\n\n\t// Create the 'bot and load configuration, supplying configdir and installdir.\n\t// When loading configuration, gopherbot first loads default configuration\n\t// from internal config, then loads from localdir/conf/..., which\n\t// overrides defaults.\n\tos.Setenv(\"GOPHER_INSTALLDIR\", installdir)\n\tos.Setenv(\"GOPHER_CONFIGDIR\", localdir)\n\tbotLogger.Printf(\"Starting up with local config dir: %s, and install dir: %s\\n\", localdir, installdir)\n\terr = newBot(localdir, installdir, botLogger)\n\tif err != nil {\n\t\tbotLogger.Fatal(fmt.Errorf(\"Error loading initial configuration: %v\", err))\n\t}\n\n\tconnectionStarter, ok := connectors[robot.protocol]\n\tif !ok {\n\t\tbotLogger.Fatal(\"No connector registered with name:\", robot.protocol)\n\t}\n\n\t// handler{} is just a placeholder struct for implementing the Handler interface\n\th := handler{}\n\tconn = connectionStarter(h, log.New(ioutil.Discard, \"\", 0))\n\n\t// Initialize the robot with a valid connector\n\tbotInit(conn)\n\n\t// Start the brain loop\n\tgo runBrain()\n\tif isIntSess {\n\t\t// Start the connector's main loop for interactive sessions\n\t\tconn.Run(finish)\n\t} else {\n\t\t// Stop logging to startup log when running as a service\n\t\trobot.logger.SetOutput(ioutil.Discard)\n\t\t// Started as a Windows Service\n\t\trunService(svcName)\n\t}\n}", "func (serv *webService) Start(ctx context.Context) error {\n\tvar err error\n\tserv.RPC, err = rpchttp.New(fmt.Sprintf(\"http://127.0.0.1:%d\", serv.RPCPort), \"/websocket\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tserv.Server = &http.Server{Addr: \":21478\", Handler: serv.Mux}\n\treturn serv.Server.ListenAndServe()\n}", "func (ms *MockOpenIDDiscoveryServer) Start() error {\n\trouter := mux.NewRouter()\n\trouter.HandleFunc(\"/.well-known/openid-configuration\", ms.openIDCfg).Methods(\"GET\")\n\n\tserver := &http.Server{\n\t\tAddr: \":\" + strconv.Itoa(ms.port),\n\t\tHandler: router,\n\t}\n\n\t// Starts the HTTP and waits for it to begin receiving requests.\n\t// Returns an error if the server doesn't serve traffic within about 2 seconds.\n\tgo func() {\n\t\tserver.ListenAndServe()\n\t}()\n\n\twait := 300 * time.Millisecond\n\tfor try := 0; try < 3; try++ {\n\t\ttime.Sleep(wait)\n\t\t// Try to call the server\n\t\tif _, err := http.Get(fmt.Sprintf(\"%s/.well-known/openid-configuration\", ms.url)); err != nil {\n\t\t\tlog.Infof(\"Server not yet serving: %v\", err)\n\t\t\t// Retry after some sleep.\n\t\t\twait *= 2\n\t\t\tcontinue\n\t\t}\n\n\t\tlog.Infof(\"Successfully serving on %s\", ms.url)\n\t\tms.HitNum = 0\n\t\tms.server = server\n\t\treturn nil\n\t}\n\n\tms.Stop()\n\treturn errors.New(\"server failed to start\")\n}", "func startWsServer(listen_addr string) {\n\t//hub = newHub()\n\tgo hub.Run()\n\n\t//http.HandleFunc(\"/\", cmdHandler)\n\thttp.HandleFunc(\"/upgrade\", func(w http.ResponseWriter, r *http.Request) {\n\t\tserveWs(hub, w, r)\n\t})\n\terr := http.ListenAndServe(listen_addr, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"Could not listen to %s: %s\", listen_addr, err)\n\t}\n}", "func (s *Server) Start(ctx context.Context) {\n\trunCtx, cancel := context.WithCancel(ctx)\n\n\trouter := mux.NewRouter()\n\ts.registerAPI(router)\n\n\tsrv := http.Server{\n\t\tAddr: s.option.Address,\n\t\tHandler: router,\n\t}\n\n\tenableTLS := s.option.CertFile != \"\" && s.option.KeyFile != \"\"\n\n\t// enable TLS\n\tif enableTLS {\n\t\tsrv.TLSConfig = &tls.Config{\n\t\t\tServerName: s.option.Name,\n\t\t\tMinVersion: tls.VersionTLS12,\n\t\t}\n\t}\n\n\trunner.\n\t\tRun(runCtx, func(ctx context.Context) error {\n\t\t\ts.started = true\n\n\t\t\tif enableTLS {\n\t\t\t\tlog.Println(\"Starting HTTPS service\")\n\t\t\t\tlog.Printf(\"HTTPS service is started on %s\\n\", s.option.Address)\n\n\t\t\t\treturn srv.ListenAndServeTLS(s.option.CertFile, s.option.KeyFile)\n\t\t\t}\n\n\t\t\tlog.Println(\"Starting HTTP service\")\n\t\t\tlog.Printf(\"HTTP service is started on %s\\n\", s.option.Address)\n\n\t\t\treturn srv.ListenAndServe()\n\t\t}).\n\t\tHandle(func(sig os.Signal) {\n\t\t\tif sig == syscall.SIGHUP {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tlog.Println(\"Shutting down...\")\n\t\t\tcancel()\n\t\t})\n\n}", "func RunService() {\n\tforever := make(chan bool)\n\tworkers := 10\n\tlog.Printf(\"Create %d Workers \\n\", workers)\n\tcreateWorker(workers)\n\t<-forever\n}", "func startServer() {\r\n\t//G = NewGroup(ConnectionMax)\r\n\tserver := httptest.NewServer(new(myServer))\r\n\tserverAddr = server.Listener.Addr().String()\r\n\tlog.Print(\"Test WebSocket server listening on \", serverAddr)\r\n\r\n}", "func (server *testHTTPServerImpl) Start() {\n\tbinding := fmt.Sprintf(\":%d\", server.GetPort())\n\tsrv := &http.Server{\n\t\tAddr: binding,\n\t\tHandler: server.router,\n\t\tReadHeaderTimeout: 5 * time.Second,\n\t}\n\tgo func() {\n\t\trootFolder, err := GetRootFolder()\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Failed to get root folder of project: %s\", err)\n\t\t\treturn\n\t\t}\n\t\tcertFile := fmt.Sprintf(\"%s/testutils/test-server.pem\", rootFolder)\n\t\tkeyFile := fmt.Sprintf(\"%s/testutils/test-server.key\", rootFolder)\n\t\tif err = srv.ListenAndServeTLS(certFile, keyFile); !errors.Is(err, http.ErrServerClosed) {\n\t\t\tlog.Fatalf(\"Failed to start http server using binding %s: %s\", binding, err)\n\t\t}\n\n\t}()\n\tserver.httpServer = srv\n\n\tserver.waitForServerAlive()\n}", "func (ms *MockServer) Start() error {\n\trouter := mux.NewRouter()\n\trouter.HandleFunc(\"/v1/identitybindingtoken\", ms.getFederatedToken).Methods(\"POST\")\n\n\tserver := &http.Server{\n\t\tAddr: \":\",\n\t\tHandler: router,\n\t}\n\tln, err := net.Listen(\"tcp\", \":0\")\n\tif err != nil {\n\t\tlog.Errorf(\"Server failed to listen %v\", err)\n\t\treturn err\n\t}\n\n\tport := ln.Addr().(*net.TCPAddr).Port\n\tms.Port = port\n\tms.URL = fmt.Sprintf(\"http://localhost:%d\", port)\n\tserver.Addr = \":\" + strconv.Itoa(port)\n\n\tgo func() {\n\t\tif err := server.Serve(ln); err != nil {\n\t\t\tlog.Errorf(\"Server failed to serve in %q: %v\", ms.URL, err)\n\t\t}\n\t}()\n\n\t// sleep a while for mock server to start.\n\ttime.Sleep(time.Second)\n\n\treturn nil\n}", "func (sw *Switcher) Start() {\n\tsw.Server.Start()\n}", "func (s *TestServer) run() error {\n\n\tret := s.cmd.Start()\n\n\tch := make(chan error)\n\n\t// we wait for LaunchWaitTimeout and see if the server quit due to an error\n\tgo func() {\n\t\terr := s.cmd.Wait()\n\t\tselect {\n\t\tcase ch <- err:\n\t\tdefault:\n\t\t}\n\t}()\n\n\tselect {\n\tcase e := <-ch:\n\t\tlog.Println(\"Error waiting for process:\", e)\n\t\treturn e\n\tcase <-time.After(launchWaitTimeout):\n\t\tbreak\n\n\t}\n\n\treturn ret\n}", "func (s *Server) Start() error {\n\tidleConnsClosed := make(chan struct{})\n\n\tgo func() {\n\t\tsigint := make(chan os.Signal, 1)\n\t\tsignal.Notify(sigint, syscall.SIGINT, syscall.SIGTERM)\n\t\t<-sigint\n\n\t\ts.logger.Info(\"Shutting down HTTP server\")\n\n\t\terr := s.httpServer.Shutdown()\n\t\tfailpoint.Inject(\"shutdownErr\", func() {\n\t\t\terr = errors.New(\"mock shutdown error\")\n\t\t})\n\t\tif err != nil {\n\t\t\ts.logger.Error(\"srv.Shutdown: %v\", zap.Error(err))\n\t\t}\n\t\ts.logger.Info(\"HTTP server is stopped\")\n\n\t\tclose(idleConnsClosed)\n\t}()\n\n\ts.logger.Info(\"Starting HTTP server\", zap.String(\"address\", s.addr))\n\terr := s.httpServer.ListenAndServe(s.addr)\n\tfailpoint.Inject(\"listenAndServeErr\", func() {\n\t\terr = errors.New(\"mock listen and serve error\")\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"ListenAndServe error: %w\", err)\n\t}\n\n\t<-idleConnsClosed\n\n\tif err := s.afterShutdown(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func startServer(t *testing.T, server *http.Server) {\n\tgo func() {\n\t\terr := server.ListenAndServe()\n\t\tif !errors.Is(err, http.ErrServerClosed) {\n\t\t\trequire.NoError(t, err)\n\t\t}\n\t}()\n}", "func Start() {\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\n\t\tlog.Printf(\"http server started on %s\\n\", server.Server.Addr)\n\t\tif err := server.StartServer(server.Server); err != nil && err != http.ErrServerClosed {\n\t\t\tlog.Fatalf(\"error starting http server: %v\", err)\n\t\t}\n\t\tlog.Println(\"http server stopped\")\n\t}()\n}", "func (srv *Server) Start() {\n\tvar config *rest.Config\n\tvar err error\n\n\tif strings.ToUpper(srv.RunMode) == \"KUBE\" {\n\t\t// Create the Kubernetes in-cluster config\n\t\tconfig, err = rest.InClusterConfig()\n\t\tif err != nil {\n\t\t\tpanic(err.Error())\n\t\t}\n\t} else {\n\t\t// use the current context in kubeconfig\n\t\tconfig, err = clientcmd.BuildConfigFromFlags(\"\", filepath.Join(util.HomeDir(), \".kube\", \"config\"))\n\t\tif err != nil {\n\t\t\tpanic(err.Error())\n\t\t}\n\t}\n\n\t// Create the clientset\n\tclientset, err := kubernetes.NewForConfig(config)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\n\t// Create a watcher\n\twatcher, err := clientset.CoreV1().Services(\"\").Watch(metav1.ListOptions{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\n\t// Create a channel for the events to come in from the watcher\n\teventChannel := watcher.ResultChan()\n\n\t// Start an indefinite loop\n\tfor {\n\t\tevt := <-eventChannel\n\t\tsrv.handleEvent(evt)\n\t}\n}", "func (ms *MicroService) Start() {\n \tms.StartOnPort(8080)\n}", "func startServer(wg *sync.WaitGroup) {\n\tdefer wg.Done()\n\n\tlistener, err := net.Listen(\"tcp\", fmt.Sprintf(\"%s:%d\", MyHandle.Host, MyHandle.Port))\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to startServer: %v\", err)\n\t}\n\n\tgrpcServer := grpc.NewServer()\n\tapi.RegisterGoChatServer(grpcServer, &chatServer{})\n\n\terr = grpcServer.Serve(listener)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to serve: %v\", err)\n\t}\n}", "func start_cs() *gsi.MockServer {\n\treturn gsi.Start_cs(true)\n}", "func (a *API) StartService(serviceID string) error {\n\treturn newServiceStarter(a).Start(serviceID)\n}", "func RunService(isDebug bool) {\n\tvar err error\n\tif isDebug {\n\t\telog = debug.New(config.ServiceName)\n\t} else {\n\t\telog, err = eventlog.Open(config.ServiceName)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\tdefer elog.Close()\n\n\telog.Info(0x40000007, config.ServiceName)\n\trun := svc.Run\n\n\terr = run(config.ServiceName, &agentWindowsService{})\n\tif err != nil {\n\t\telog.Error(0xc0000008, err.Error())\n\t\treturn\n\t}\n\telog.Info(0x40000004, config.ServiceName)\n}", "func StartService() *Service {\n\treturn &Service{\n\t\tstreamch: hwinfo.StreamSharedMem(),\n\t}\n}", "func (s *server) Start(stop <-chan struct{}) error {\n\tlistener, err := newListener(s.bindAddress)\n\tif err != nil {\n\t\treturn err\n\t}\n\tserver := http.Server{\n\t\tHandler: s.mux,\n\t}\n\t// Run the server\n\tgo func() {\n\t\tlog.Info(\"starting http server\")\n\t\tif err := server.Serve(listener); err != nil && err != http.ErrServerClosed {\n\t\t\tlog.Error(err, \"http server error\")\n\t\t}\n\t}()\n\n\t// Shutdown the server when stop is close\n\t<-stop\n\treturn server.Shutdown(context.Background())\n}", "func Service() {\n\ts, err := NewServerFromOptions()\n\tif err != nil {\n\t\tlog.Fatal(err, \"Error starting server\")\n\t}\n\tgo s.Serve()\n}", "func Start() {\n\twebServer.Engine.Run(\":\" + strconv.Itoa(cfg.Read().App.WebServerPort))\n}", "func ServiceStart(service string, cmd string) (bool, error) {\n\tlog.Infof(\"ServiceStart called for '%s'\\n\", service)\n\tsvcStatus, pid, err := GetServiceStatus(service)\n\tif err != nil {\n\t\treturn false, errors.New(\"Could not get status for '\" + service + \"' : \" + err.Error())\n\t} else if svcStatus == SvcRunning && cmd == \"start\" {\n\t\tlog.Infof(\"service '%s' is already running, pid: %d\\n\", service, pid)\n\t} else {\n\t\t_, rc, err := ExecCommand(\"/usr/sbin/service\", service, cmd)\n\t\tif err != nil {\n\t\t\treturn false, errors.New(\"Could not \" + cmd + \" the '\" + service + \"' service: \" + err.Error())\n\t\t} else if rc == 0 {\n\t\t\t// service was sucessfully started\n\t\t\treturn true, nil\n\t\t}\n\t}\n\t// not started, service is already running\n\treturn false, nil\n}", "func (service *APIService) Start() error {\n\tlis, err := net.Listen(\"tcp\", fmt.Sprintf(\":%d\", service.port))\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to listen to TCP port %d for RPC\", service.port)\n\t}\n\n\tlog.Info(\"Server started\", \"address\", service.Address)\n\tif err := service.GrpcServer.Serve(lis); err != http.ErrServerClosed {\n\t\treturn errors.Wrapf(err, \"failed to start HTTP server\")\n\t}\n\treturn nil\n}", "func (s *serviceStarter) Start(serviceID string) error {\n\tsr, err := s.api.db.Get(serviceID)\n\tif err != nil {\n\t\treturn err\n\t}\n\tsr, err = service.FromService(sr, service.ContainerOption(s.api.container))\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = sr.Start()\n\treturn err\n}", "func (s *Service) Start() {\n\tr := NewRouter()\n\thttp.Handle(\"/\", r)\n\n\tport := fmt.Sprintf(\"%d\", s.Port)\n\tlog.Println(\"Starting HTTP service at \" + port)\n\n\terr := http.ListenAndServe(\"0.0.0.0:\"+port, nil)\n\tif err != nil {\n\t\tlog.Println(\"An error occured starting HTTP listener at port \" + port)\n\t\tlog.Println(\"Error: \" + err.Error())\n\t}\n}", "func (mng *Manager) Start() {\n\tgo func() {\n\t\tif err := mng.srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {\n\t\t\tmng.lgr.Fatal(\"Error starting HTTP service: \" + err.Error())\n\t\t}\n\t}()\n}", "func (w *Webserver) Start() error {\n\n\t// listenAndServe the server\n\tgo func() {\n\t\tw.logger.Infof(\"Http server listening at %d!\", w.config.Port)\n\t\terr := w.listenAndServe()\n\t\tif err != nil && err != http.ErrServerClosed {\n\t\t\tw.logger.Errorw(fmt.Sprintf(\"webserver listening at port [%v] stopped\", w.config.Port), \"error\", err.Error())\n\t\t}\n\t}()\n\n\treturn nil\n}", "func TestServiceStart(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.GetResource(func(r res.GetRequest) { r.NotFound() }))\n\t}, nil)\n}", "func startServer(dataSlice []string) {\n\te := echo.New()\n\n\te.GET(\"/\", func(f echo.Context) error {\n\t\treturn f.JSON(http.StatusOK, dataSlice)\n\t})\n\n\tfmt.Println(\"Server running: http://localhost:8000\")\n\te.Logger.Fatal(e.Start(\":8000\"))\n}", "func StartChrome() {\n\tvar err error\n\tcheckWebDriver()\n\tdriver, err = core.Chrome()\n\tcheckFailure(err)\n\tcheckFailure(driver.Start())\n}", "func main() {\n\tdrv := serverless.NewDriver(os.Args[1]) // the 1st cmd-line argument: driver hostname and ip addr\n\tserviceName := os.Args[2] // the 2nd cmd-line argument: plugin Service name\n\n\tgo drv.Run(serviceName)\n\n\tdrv.Wait()\n}", "func (srv Web) Start() error {\n\tfmt.Printf(\"Starting service on port %s\\n\", srv.Settings.Port)\n\treturn http.ListenAndServe(srv.Settings.Port, srv.Router())\n}", "func Start(logger xlog.Logger) error {\n\tconst op string = \"chrome.Start\"\n\tlogger.DebugOp(op, \"starting new Google Chrome headless process on port 9222...\")\n\tresolver := func() error {\n\t\tcmd, err := cmd(logger)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// we try to start the process.\n\t\txexec.LogBeforeExecute(logger, cmd)\n\t\tif err := cmd.Start(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// if the process failed to start correctly,\n\t\t// we have to restart it.\n\t\tif !isViable(logger) {\n\t\t\treturn restart(logger, cmd.Process)\n\t\t}\n\t\treturn nil\n\t}\n\tif err := resolver(); err != nil {\n\t\treturn xerror.New(op, err)\n\t}\n\treturn nil\n}", "func (sn *SimNode) Start(snapshots map[string][]byte) error {\n\tnewService := func(name string) func(ctx *node.ServiceContext) (node.Service, error) {\n\t\treturn func(nodeCtx *node.ServiceContext) (node.Service, error) {\n\t\t\tctx := &ServiceContext{\n\t\t\t\tRPCDialer: sn.adapter,\n\t\t\t\tNodeContext: nodeCtx,\n\t\t\t\tConfig: sn.config,\n\t\t\t}\n\t\t\tif snapshots != nil {\n\t\t\t\tctx.Snapshot = snapshots[name]\n\t\t\t}\n\t\t\tserviceFunc := sn.adapter.services[name]\n\t\t\tservice, err := serviceFunc(ctx)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tsn.running[name] = service\n\t\t\treturn service, nil\n\t\t}\n\t}\n\n\t// ensure we only register the services once in the case of the node\n\t// being stopped and then started again\n\tvar regErr error\n\tsn.registerOnce.Do(func() {\n\t\tfor _, name := range sn.config.Services {\n\t\t\tif err := sn.node.Register(newService(name)); err != nil {\n\t\t\t\tregErr = err\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t})\n\tif regErr != nil {\n\t\treturn regErr\n\t}\n\n\tif err := sn.node.Start(); err != nil {\n\t\treturn err\n\t}\n\n\t// create an in-process RPC client\n\thandler, err := sn.node.RPCHandler()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tsn.lock.Lock()\n\tsn.client = rpc.DialInProc(handler)\n\tsn.lock.Unlock()\n\n\treturn nil\n}", "func StartTestService(t *testing.T) {\n\tdb, err := sqorc.Open(\"sqlite3\", \":memory:\")\n\trequire.NoError(t, err)\n\tstartService(t, db)\n}", "func (s *service) Start() error {\n\tservice := &http.Server{Addr: s.host, Handler: s.mux}\n\n\treturn service.ListenAndServe()\n}", "func StartReplicatorService() {\n\tserviceName := common.ReplicatorServiceName\n\tcfg := common.SetupServerConfig(configure.NewCommonConfigure())\n\tif e := os.Setenv(\"port\", fmt.Sprintf(\"%d\", cfg.GetServiceConfig(serviceName).GetPort())); e != nil {\n\t\tlog.Panic(e)\n\t}\n\n\tmeta, err := metadata.NewCassandraMetadataService(cfg.GetMetadataConfig())\n\tif err != nil {\n\t\t// no metadata service - just fail early\n\t\tlog.WithField(common.TagErr, err).Fatal(`frontendhost: unable to instantiate metadata service`)\n\t}\n\thwInfoReader := common.NewHostHardwareInfoReader(meta)\n\treporter := common.NewMetricReporterWithHostname(cfg.GetServiceConfig(serviceName))\n\tdClient := dconfigclient.NewDconfigClient(cfg.GetServiceConfig(serviceName), serviceName)\n\tsCommon := common.NewService(serviceName, uuid.New(), cfg.GetServiceConfig(serviceName), common.NewUUIDResolver(meta), hwInfoReader, reporter, dClient, common.NewBypassAuthManager())\n\n\th, tc := replicator.NewReplicator(serviceName, sCommon, meta, replicator.NewReplicatorClientFactory(cfg, common.GetDefaultLogger()), cfg)\n\th.Start(tc)\n\n\t// start websocket server\n\tcommon.WSStart(cfg.GetServiceConfig(serviceName).GetListenAddress().String(),\n\t\tcfg.GetServiceConfig(serviceName).GetWebsocketPort(), h)\n\n\t// start diagnosis local http server\n\tcommon.ServiceLoop(cfg.GetServiceConfig(serviceName).GetPort()+diagnosticPortOffset, cfg, sCommon)\n}", "func (s *ServiceManager) StartService(name string) error {\n\t// Return error if service has already been started\n\tfor id, service := range s.services {\n\t\tif strings.IndexAny(id, name) >= 0 && service != nil {\n\t\t\treturn fmt.Errorf(\"The service '%s' has already been started\", name)\n\t\t}\n\t}\n\tch := make(chan ServiceCommand)\n\tservice, err := CreateService(name, s.config, ch)\n\tif err != nil {\n\t\tglog.Errorf(\"%s\", err)\n\t} else {\n\t\tglog.Infof(\"Create service '%s' success\", name)\n\t\ts.services[name] = service\n\t\ts.chs[name] = ch\n\t}\n\treturn nil\n}", "func (ser *Server) Start() error {\n\tlog.Printf(\"System webapp start at %s\", ser.addr)\n\treturn manners.ListenAndServe(ser.addr, ser.m)\n}", "func RunService(serviceinfo *ServiceInfo, handler ServiceHandler) error {\n\taddress, err := GetRegistryAddress()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tconnection, err := net.DialTCP(TCP_PROTOCOL, nil, address)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer connection.Close()\n\n\tlistener, err := net.ListenTCP(TCP_PROTOCOL, TCP_ANY_ADDR)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer listener.Close()\n\n\taddress, err = net.ResolveTCPAddr(TCP_PROTOCOL, listener.Addr().String())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tbytes, err := json.Marshal(ServiceInfoAddress{strconv.Itoa(address.Port), *serviceinfo})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = connection.Write(bytes)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor {\n\t\tconnection, err := listener.AcceptTCP()\n\t\tif err == nil {\n\t\t\tgo handleServiceConnection(connection, handler)\n\t\t}\n\t}\n\n\treturn nil\n}", "func startHTTPServer(ch chan<- bool) {\n\tserver := http.Server{\n\t\tAddr: \":80\",\n\t}\n\tlog.Println(\"HTTP server started (listening on port 80).\")\n\tlog.Println(\"HTTP server stopped with error:\", server.ListenAndServe())\n\tch <- true\n}", "func (s * Service)Start(port string) {\n\tr := chi.NewRouter()\n\n\tr.Use(middleware.Logger)\n\tr.Use(middleware.Timeout(5 * time.Second))\n\n\trpc := rpc.RPC{\n\t\tApp: &app.App{},\n\t}\n\tif len(port) == 0 {\n\t\t// default port 3000\n\t\tport = \"3000\"\n\t}\n\tr.Post(\"/generate_pricing\", rpc.GeneratePricing)\n\tr.Get(\"/generate_pricing\", rpc.GeneratePricingConfig)\n\ts.ListenAndServe(\":\"+port, r)\n}", "func (b *Bot) Start(stop <-chan struct{}) error {\n\tlog.Info(\"start the bot ...\")\n\n\t// Now start all of the components.\n\tif err := b.server.Start(stop); err != nil {\n\t\treturn err\n\t}\n\n\tb.waitForShutdown(stop)\n\n\tlog.Info(\"bot started\")\n\treturn nil\n}", "func (d *Driver) Start() error {\n\tclient, err := d.getClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn client.StartVirtualMachine(d.vmName())\n}", "func StartServer() {\n\tif server == nil {\n\t\tGetInstance()\n\t}\n\n\tlog.Println(\"starting server on http://localhost\" + defaultPort)\n\tserver.Run(defaultPort)\n}", "func StartService(ctx context.Context, opener entroq.BackendOpener) (*grpc.Server, Dialer, error) {\n\tlis := bufconn.Listen(bufSize)\n\tsvc, err := qsvc.New(ctx, opener)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"start service: %w\", err)\n\t}\n\ts := grpc.NewServer()\n\thpb.RegisterHealthServer(s, health.NewServer())\n\tpb.RegisterEntroQServer(s, svc)\n\tgo s.Serve(lis)\n\n\treturn s, lis.Dial, nil\n}", "func StartService() {\n\tlogger, err := zap.NewProduction()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tdefer func() {\n\t\t_ = logger.Sync()\n\t}()\n\n\terr = setupDependencies(logger)\n\tif err != nil {\n\t\tlogger.Fatal(\"Failed to setup dependecies\", zap.Error(err))\n\t}\n\n\thttpsTransportService, err := https.NewTransportService(\n\t\tlogger,\n\t\tconfigurationService,\n\t\tendpointCreatorService,\n\t\tmiddlewareProviderService)\n\tif err != nil {\n\t\tlogger.Fatal(\"Failed to create GraphQL transport service\", zap.Error(err))\n\t}\n\n\tsignalChan := make(chan os.Signal, 1)\n\tcleanupDone := make(chan struct{})\n\tsignal.Notify(signalChan, os.Interrupt)\n\n\tgo func() {\n\t\tif serviceErr := httpsTransportService.Start(); serviceErr != nil {\n\t\t\tlogger.Fatal(\"Failed to start HTTPS transport service\", zap.Error(serviceErr))\n\t\t}\n\t}()\n\n\tgo func() {\n\t\t<-signalChan\n\t\tlogger.Info(\"Received an interrupt, stopping services...\")\n\n\t\tif err := httpsTransportService.Stop(); err != nil {\n\t\t\tlogger.Error(\"Failed to stop HTTPS transport service\", zap.Error(err))\n\t\t}\n\n\t\tclose(cleanupDone)\n\t}()\n\t<-cleanupDone\n}", "func (server *TempestServer) Start() {\n\tif server.running {\n\t\treturn\n\t}\n\n\tserver.running = true\n\n\tserver.serverWaitGroup.Add(1)\n\tgo server.startServer()\n\tserver.serverWaitGroup.Wait()\n}", "func start() error {\n\tcfg, err := config.NewConfig()\n\tif err != nil {\n\t\treturn xerrors.Errorf(\"get config: %w\", err)\n\t}\n\n\trestclientCfg, apiShutdown, err := k8sapiserver.StartAPIServer(cfg.EtcdURL)\n\tif err != nil {\n\t\treturn xerrors.Errorf(\"start API server: %w\", err)\n\t}\n\tdefer apiShutdown()\n\n\tclient := clientset.NewForConfigOrDie(restclientCfg)\n\n\tpvshutdown, err := pvcontroller.StartPersistentVolumeController(client)\n\tif err != nil {\n\t\treturn xerrors.Errorf(\"start pv controller: %w\", err)\n\t}\n\tdefer pvshutdown()\n\n\tsched := scheduler.NewSchedulerService(client, restclientCfg)\n\n\tsc, err := defaultconfig.DefaultSchedulerConfig()\n\tif err != nil {\n\t\treturn xerrors.Errorf(\"create scheduler config\")\n\t}\n\n\tif err := sched.StartScheduler(sc); err != nil {\n\t\treturn xerrors.Errorf(\"start scheduler: %w\", err)\n\t}\n\tdefer sched.ShutdownScheduler()\n\n\terr = scenario(client)\n\tif err != nil {\n\t\treturn xerrors.Errorf(\"start scenario: %w\", err)\n\t}\n\n\treturn nil\n}", "func (s *LocalService) Start() error {\n\twatcher, err := fsnotify.NewWatcher()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, route := range s.routes {\n\t\tpath := filepath.Join(s.chroot, route.Username)\n\t\tif err := watcher.Add(path); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\ts.watcher = watcher\n\n\tgo s.watch()\n\n\treturn nil\n}", "func StartControllerService() {\n\tserviceName := common.ControllerServiceName\n\tcfg := common.SetupServerConfig(configure.NewCommonConfigure())\n\tif e := os.Setenv(\"port\", fmt.Sprintf(\"%d\", cfg.GetServiceConfig(serviceName).GetPort())); e != nil {\n\t\tlog.Panic(e)\n\t}\n\n\tmeta, err := metadata.NewCassandraMetadataService(cfg.GetMetadataConfig())\n\tif err != nil {\n\t\t// no metadata service - just fail early\n\t\tlog.WithField(common.TagErr, err).Fatal(`unable to instantiate metadata service (did you run ./scripts/setup_cassandra_schema.sh?)`)\n\t}\n\thwInfoReader := common.NewHostHardwareInfoReader(meta)\n\treporter := common.NewMetricReporterWithHostname(cfg.GetServiceConfig(serviceName))\n\tdClient := dconfigclient.NewDconfigClient(cfg.GetServiceConfig(serviceName), serviceName)\n\tsVice := common.NewService(serviceName, uuid.New(), cfg.GetServiceConfig(serviceName), common.NewUUIDResolver(meta), hwInfoReader, reporter, dClient, common.NewBypassAuthManager())\n\tmcp, tc := controllerhost.NewController(cfg, sVice, meta, common.NewDummyZoneFailoverManager())\n\tmcp.Start(tc)\n\tcommon.ServiceLoop(cfg.GetServiceConfig(serviceName).GetPort()+diagnosticPortOffset, cfg, mcp.Service)\n}", "func StartHTTPServer() chan struct{} {\n\thttpDone := make(chan struct{}, 1)\n\tgo func() {\n\t\tcfg := struct {\n\t\t\tHTTPListenPort string `mapstructure:\"httpListenPort\"`\n\t\t}{}\n\t\tapplyConfig(\"\", &cfg)\n\n\t\tloginfof(\"Starting http listen server on :%s\", cfg.HTTPListenPort)\n\t\tif err := http.ListenAndServe(\":\"+cfg.HTTPListenPort, nil); err != nil {\n\t\t\tfmt.Println(err.Error())\n\t\t}\n\t\thttpDone <- struct{}{}\n\t}()\n\treturn httpDone\n}", "func (d *Driver) Start() error {\n\tcs := d.client()\n\t_, err := cs.AsyncRequest(&egoscale.StartVirtualMachine{\n\t\tID: d.ID,\n\t}, d.async)\n\n\treturn err\n}", "func Start() error {\n\tvar service Service\n\n\tservice.router = InitRouter()\n\tservice.RegisterRoutes()\n\n\treturn service.router.Run(\":8080\")\n}" ]
[ "0.65938157", "0.65938157", "0.65253013", "0.63578004", "0.63578004", "0.63268375", "0.6300758", "0.6254333", "0.6249277", "0.62008077", "0.6186681", "0.61138135", "0.6103919", "0.60101557", "0.6006752", "0.5996253", "0.59815216", "0.596186", "0.5913349", "0.5891949", "0.58751696", "0.5874221", "0.5873712", "0.5832628", "0.5798888", "0.5798888", "0.57734156", "0.577121", "0.57684267", "0.5760323", "0.57325953", "0.5721237", "0.5712176", "0.57081974", "0.57066774", "0.57019943", "0.56869763", "0.5671978", "0.56538475", "0.5651428", "0.5650993", "0.56385946", "0.56006277", "0.559885", "0.55773294", "0.55735284", "0.5573453", "0.55598885", "0.5558409", "0.55465", "0.55432373", "0.5541942", "0.5532239", "0.55245763", "0.55112725", "0.55082595", "0.5500279", "0.549475", "0.54833513", "0.5482305", "0.5479315", "0.54766953", "0.5475253", "0.54746467", "0.5467663", "0.54675364", "0.5457162", "0.545079", "0.54470515", "0.54467976", "0.5444495", "0.54356915", "0.54342395", "0.5432754", "0.5430014", "0.54297423", "0.542744", "0.54261315", "0.54211855", "0.5417305", "0.54162264", "0.540503", "0.5399878", "0.5399812", "0.5395128", "0.5394582", "0.5391496", "0.5387302", "0.5376532", "0.53752327", "0.5371384", "0.53670377", "0.5364234", "0.5359883", "0.5352933", "0.5345683", "0.5345256", "0.5339273", "0.53381175", "0.5334798" ]
0.79222965
0
StopService stops selenium server
StopService останавливает сервер selenium
func StopService() { seleniumService.Stop() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func StopService() {\n\tserver.Stop()\n}", "func (n *Node) StopService() {\n\tif n.stopServer == nil {\n\t\treturn\n\t}\n\tn.stopServer()\n\tn.stopServer = nil\n}", "func (s *Service) StopService() {\n\tutils.Logger().Info().Msg(\"Shutting down explorer service.\")\n\tif err := s.server.Shutdown(context.Background()); err != nil {\n\t\tutils.Logger().Error().Err(err).Msg(\"Error when shutting down explorer server\")\n\t} else {\n\t\tutils.Logger().Info().Msg(\"Shutting down explorer server successufully\")\n\t}\n}", "func (s *Service) StopService() {\n\tutils.Logger().Info().Msg(\"Shutting down explorer service.\")\n\tif err := s.server.Shutdown(context.Background()); err != nil {\n\t\tutils.Logger().Error().Err(err).Msg(\"Error when shutting down explorer server\")\n\t} else {\n\t\tutils.Logger().Info().Msg(\"Shutting down explorer server successufully\")\n\t}\n}", "func Stop() {\n\tdriver.Stop()\n}", "func (m *mockService) Stop() {\n\t// m.ctrl.Finish() calls runtime.Goexit() on errors\n\t// put it in defer so cleanup is always done\n\tdefer func() {\n\t\tm.server.Shutdown()\n\t\tm.started = false\n\t}()\n\tm.ctrl.Finish()\n}", "func (htmlServer *HTMLServer) Stop() error {\n\n\tconst timeout = 5 * time.Second\n\tctx, cancel := context.WithTimeout(context.Background(), timeout)\n\tdefer cancel()\n\n\tlog.Println(Detail(\"SERVER : Service stopping.\"))\n\n\tif e := htmlServer.server.Shutdown(ctx); e != nil {\n\n\t\tif e := htmlServer.server.Close(); e != nil {\n\t\t\tlog.Printf(Warn(\"SERVER : Service stopping : Error=%s\"), e)\n\t\t\treturn e\n\t\t}\n\t}\n\n\thtmlServer.wg.Wait()\n\tlog.Println(Detail(\"SERVER : Stopped\"))\n\treturn nil\n}", "func (i *ServiceInitializer) StopService(s turbo.Servable) {\n}", "func (s JSONHTTPServer) StopService() {\n\tlog.Debug(\"Stopping json-http service...\")\n\ts.stop <- true\n}", "func (s JSONHTTPServer) StopService() {\n\tlog.Debug(\"Stopping json-http service...\")\n\ts.stop <- true\n}", "func (srv *Server) Stop() {\n Warn(fmt.Sprintf(\"stopping server %s\", srv.addrURL.String()))\n srv.mu.Lock()\n if srv.httpServer == nil {\n srv.mu.Unlock()\n return\n }\n graceTimeOut := time.Duration(50)\n ctx, cancel := context.WithTimeout(context.Background(), graceTimeOut)\n defer cancel()\n if err := srv.httpServer.Shutdown(ctx); err != nil {\n Debug(\"Wait is over due to error\")\n if err := srv.httpServer.Close(); err != nil {\n Debug(err.Error())\n }\n Debug(err.Error())\n }\n close(srv.stopc)\n <-srv.donec\n srv.mu.Unlock()\n Warn(fmt.Sprintf(\"stopped server %s\", srv.addrURL.String()))\n}", "func StopTestServer(server *http.Server) error {\n\terror := server.Shutdown(nil)\n\tif error != nil {\n\t\tfmt.Printf(\"Could not stop test websocket server in test_utils: %s\", error.Error())\n\t\treturn error\n\t}\n\treturn nil\n}", "func stopServer(w http.ResponseWriter, r *http.Request) {\n\tgo localServer.Shutdown(context.Background())\n}", "func (s * Service)Stop() {\n\tlog.Println(\"Stopping Server!\")\n\tctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\n\tdefer cancel()\n\tif s.Server != nil {\n\t\tlog.Println(\" Initiating Server Shutdown!\")\n\t\tif err := s.Server.Shutdown(ctx); err != nil {\n\t\t\t// handle err\n\t\t\tlog.Println(\"Error while stopping Server!\", err)\n\t\t}\n\t}\n}", "func (serv *webService) Stop(ctx context.Context) error {\n\tvar err error\n\tif serv.Server != nil {\n\t\terr = serv.Server.Shutdown(ctx)\n\t\tserv.Server = nil\n\t}\n\tif serv.RPC != nil {\n\t\terr2 := serv.RPC.Stop()\n\t\tif err2 != nil {\n\t\t\terr = err2\n\t\t}\n\t}\n\treturn err\n}", "func (h *Harness) Stop() {\n\tfin := make(chan struct{})\n\tgo func() {\n\t\tdefer close(fin)\n\t\tif err := h.Client.Close(); err != nil {\n\t\t\th.t.Fatal(err)\n\t\t}\n\n\t\tif err := h.cmd.Process.Kill(); err != nil {\n\t\t\th.t.Fatal(err)\n\t\t}\n\n\t\tif err := os.Remove(h.configPath); err != nil {\n\t\t\th.t.Fatal(err)\n\t\t}\n\t}()\n\tselect {\n\tcase <-fin:\n\tcase <-time.After(h.StopTimeout):\n\t}\n}", "func (s *Server) Stop() {\n\tclose(s.quit)\n\ts.listener.Close()\n\ts.eventLogger.Info(uint32(windows.NO_ERROR), fmt.Sprintf(\"remove all %+v\", s.proxy.portMappings))\n\tif err := s.proxy.removeAll(); err != nil {\n\t\ts.eventLogger.Warning(uint32(windows.ERROR_EXCEPTION_IN_SERVICE), err.Error())\n\t}\n\ts.stopped = true\n}", "func (m *DevicePluginStub) Stop() error {\n\tglog.V(2).Infof(\"Stopping server %s\", m.SocketName())\n\n\tm.server.Stop()\n\tclose(m.stop)\n\n\tif err := m.waitTimeout(); err != nil {\n\t\treturn err\n\t}\n\n\treturn m.cleanup()\n}", "func (s Server) stop(ctx context.Context) {\n\ts.grpcServer.Stop()\n\terr := s.httpServer.Shutdown(ctx)\n\tif err != nil {\n\t\tlog.Err(err).Msg(\"error shutting down the http server\")\n\t}\n}", "func (srv *Server) Stop() error {\n\tif err := srv.app.Shutdown(); err != nil {\n\t\treturn err\n\t}\n\tif err := srv.config.StorageDriver.Disconnect(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func stopServer(grpcServer *grpc.Server, v *Vibranium) error {\n\ttime.Sleep(1 * time.Second) // to aviod \"read: connection reset by peer\"\n\tdefer time.Sleep(1 * time.Second) // to aviod \"bind error\"\n\tgrpcServer.GracefulStop()\n\tlog.Info(\"gRPC server stopped gracefully.\")\n\n\tlog.Info(\"Now check if cluster still have running tasks...\")\n\twait := make(chan interface{})\n\tgo func() {\n\t\tv.Wait()\n\t\twait <- \"\"\n\t}()\n\ttimer := time.NewTimer(time.Second * 30)\n\tselect {\n\tcase <-timer.C:\n\t\t// force quit(terminate all running tasks/goroutines)\n\t\tfor {\n\t\t\tif v.TaskNum == 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tv.taskDone(\"\", false)\n\t\t}\n\t\tlog.Info(\"Cluster stopped FORCEFULLY\")\n\tcase <-wait:\n\t\tlog.Info(\"Cluster stopped gracefully\")\n\t}\n\treturn nil\n}", "func StopService(service string) error {\n\treturn doService(service, \"stop\")\n}", "func (sv *Unit) Stop() (err error) {\n\tif cmd := strings.Fields(sv.Definition.Service.ExecStop); len(cmd) > 0 {\n\t\treturn exec.Command(cmd[0], cmd[1:]...).Run()\n\t}\n\tif sv.Cmd.Process != nil {\n\t\treturn sv.Cmd.Process.Kill()\n\t}\n\treturn nil\n}", "func (d *Driver) Stop() error {\n\tclient, err := d.getClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn client.ShutdownVirtualMachine(d.vmName(), true)\n}", "func Stop() {\n\t// /bin/dbus-send --system --dest=org.ganesha.nfsd --type=method_call /org/ganesha/nfsd/admin org.ganesha.nfsd.admin.shutdown\n}", "func (service *APIService) Stop() {\n\tservice.GrpcServer.GracefulStop()\n\tservice.HttpServer.Close()\n}", "func (ms *MarvinServer) Stop() {\n\n}", "func (s *ServiceManager) StopService(id string) error {\n\tfor name, service := range s.services {\n\t\tif name == id && service != nil {\n\t\t\tservice.Stop()\n\t\t\ts.services[name] = nil\n\t\t\tclose(s.chs[name])\n\t\t}\n\t}\n\treturn nil\n}", "func StopWebdriver() {\n\tif driver == nil {\n\t\tginkgo.Fail(\"WebDriver not started\", 1)\n\t}\n\tdriver.Stop()\n\tdriver = nil\n}", "func (s *LocalService) Stop() error {\n\t// This is really nasty but it works\n\t// Wait for the channels to be drained\n\tfor {\n\t\twriteNotifications := reflect.ValueOf(s.writeNotifications)\n\n\t\tif writeNotifications.Len() == 0 {\n\t\t\tbreak\n\t\t}\n\n\t\ttime.Sleep(1 * time.Second)\n\t}\n\n\tclose(s.writeNotifications)\n\n\tif err := s.watcher.Close(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (s *GenericGrpcServer) Stop() {\n\tif s.Listener != nil {\n\t\tlog.Infof(\"Stopping service at %s\", s.Listener.Addr())\n\t}\n\tif s.Server != nil {\n\t\ts.Server.GracefulStop()\n\t}\n}", "func (server *TempestServer) Stop() {\n\tserver.running = false\n\tserver.serverWaitGroup.Wait()\n}", "func (server *Server) Stop() {\n\tctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\n\tif cancel != nil {\n\t\tserver.srv.Shutdown(ctx)\n\t\tserver.srv = nil\n\t}\n\tif server.hub != nil {\n\t\tserver.hub.stop()\n\t}\n}", "func (p *Pebble) Stop(t *testing.T) {\n\tstopCMD(t, p.pebbleCMD)\n\tstopCMD(t, p.challtestsrvCMD)\n}", "func Stop(server *TestDex) {\n\tserver.webServer.CloseClientConnections()\n\tserver.webServer.Close()\n}", "func Stop(r *registry.Registry) error {\n\treturn r.Server.Shutdown(context.Background())\n}", "func Test_WAIS_stopSystemTest(t *testing.T) {\n\terr := deleteScenario(\"wais-system-test\")\n\tif err != nil {\n\t\tlog.Error(\"cannot delete scenario :\", err)\n\t}\n}", "func (d *Driver) Stop() error {\n\tif err := d.verifyRootPermissions(); err != nil {\n\t\treturn err\n\t}\n\n\ts, err := d.GetState()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif s != state.Stopped {\n\t\terr := d.sendSignal(syscall.SIGTERM)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"hyperkit sigterm failed\")\n\t\t}\n\t\t// wait 120s for graceful shutdown\n\t\tfor i := 0; i < 60; i++ {\n\t\t\ttime.Sleep(2 * time.Second)\n\t\t\ts, _ := d.GetState()\n\t\t\tlog.Debugf(\"VM state: %s\", s)\n\t\t\tif s == state.Stopped {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\treturn errors.New(\"VM Failed to gracefully shutdown, try the kill command\")\n\t}\n\treturn nil\n}", "func (s *RegistryServer) Stop() error {\n\treturn s.listener.Close()\n}", "func (tm *ServiceTracerouteManager) Stop() {\n\ttm.StopChan <- true\n}", "func (s *Server) Stop() {\n\ts.cmd.Process.Kill()\n\tos.RemoveAll(s.DataDir)\n}", "func (s *DeviceService) Stop(force bool) {\n\tif s.initialized {\n\t\t_ = s.driver.Stop(false)\n\t}\n\tautoevent.GetManager().StopAutoEvents()\n}", "func (s *Server) Stop() error {\n\n\tizap.Logger.Info(\"Stopping http server\", zap.String(\"address\", s.srv.Addr))\n\treturn s.srv.Shutdown(context.Background())\n}", "func (a *Agent) Stop() {\n\tif a.ha != nil {\n\t\tif err := a.ha.Stop(); err != nil {\n\t\t\tlevel.Error(a.logger).Log(\"msg\", \"failed to stop scraping service server\", \"err\", err)\n\t\t}\n\t}\n\ta.cm.Stop()\n}", "func (proxy *proxyService) Stop() error {\n\tproxy.logger.Infof(\"Stopping service\")\n\tproxy.done = true\n\treturn proxy.listener.Close()\n}", "func (m *WebsocketRoutineManager) Stop() error {\n\tif m == nil {\n\t\treturn fmt.Errorf(\"websocket routine manager %w\", ErrNilSubsystem)\n\t}\n\n\tm.mu.Lock()\n\tif atomic.LoadInt32(&m.state) == stoppedState {\n\t\tm.mu.Unlock()\n\t\treturn fmt.Errorf(\"websocket routine manager %w\", ErrSubSystemNotStarted)\n\t}\n\tatomic.StoreInt32(&m.state, stoppedState)\n\tm.mu.Unlock()\n\n\tclose(m.shutdown)\n\tm.wg.Wait()\n\n\treturn nil\n}", "func (srv *RegistryServer) Stop() {\n\tif srv.server != nil {\n\t\tfmt.Printf(\"Stopping registration server..\")\n\t\tsrv.server.Stop()\n\t}\n}", "func (w *Webserver) Stop() error {\n\tw.logger.Infof(\"gracefully shutting down http server at %d...\", w.config.Port)\n\n\terr := w.Server.Shutdown(context.Background())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tclose(w.jobs)\n\treturn nil\n}", "func cmdStop() {\n\tswitch state := status(B2D.VM); state {\n\tcase vmUnregistered:\n\t\tlog.Fatalf(\"%s is not registered.\", B2D.VM)\n\tcase vmRunning:\n\t\tlog.Printf(\"Shutting down %s...\", B2D.VM)\n\t\tif err := vbm(\"controlvm\", B2D.VM, \"acpipowerbutton\"); err != nil {\n\t\t\tlog.Fatalf(\"failed to shutdown vm: %s\", err)\n\t\t}\n\t\tfor status(B2D.VM) == vmRunning {\n\t\t\ttime.Sleep(1 * time.Second)\n\t\t}\n\tdefault:\n\t\tlog.Printf(\"%s is not running.\", B2D.VM)\n\t}\n}", "func (d *Driver) Stop() error {\n\tcs := d.client()\n\t_, err := cs.AsyncRequest(&egoscale.StopVirtualMachine{\n\t\tID: d.ID,\n\t}, d.async)\n\n\treturn err\n}", "func (hsp HistoryServicePrecacher) Stop() { hsp.pc.Stop() }", "func (s *MockMetricsServer) Stop() {\n\t_ = s.e.Close()\n}", "func (srv *Server) Stop() {\n\terr := srv.httpServer.Shutdown(context.Background())\n\tif err != nil {\n\t\tsrv.log.Errorf(\"Unexpected error while shutting down HTTP server - %s\", err)\n\t}\n\tdefer srv.runCancel()\n}", "func (s *server) Stop() error {\n\t// Make sure this only happens once.\n\tif atomic.AddInt32(&s.shutdown, 1) != 1 {\n\t\tlogging.CPrint(logging.INFO, \"server is already in the process of shutting down\", logging.LogFormat{})\n\t\treturn nil\n\t}\n\n\ts.syncManager.Stop()\n\n\t// Signal the remaining goroutines to quit.\n\tclose(s.quit)\n\n\ts.wg.Done()\n\n\treturn nil\n}", "func runStop(cmd *types.Command, args []string) {\n\tif stopHelp {\n\t\tcmd.PrintUsage()\n\t}\n\tif len(args) < 1 {\n\t\tcmd.PrintShortUsage()\n\t}\n\n\thasError := false\n\tfor _, needle := range args {\n\t\tserverID := cmd.API.GetServerID(needle)\n\t\taction := \"poweroff\"\n\t\tif stopT {\n\t\t\taction = \"terminate\"\n\t\t}\n\t\terr := cmd.API.PostServerAction(serverID, action)\n\t\tif err != nil {\n\t\t\tif err.Error() != \"server should be running\" && err.Error() != \"server is being stopped or rebooted\" {\n\t\t\t\tlog.Warningf(\"failed to stop server %s: %s\", serverID, err)\n\t\t\t\thasError = true\n\t\t\t}\n\t\t} else {\n\t\t\tif stopW {\n\t\t\t\t// We wait for 10 seconds which is the minimal amount of time needed for a server to stop\n\t\t\t\ttime.Sleep(10 * time.Second)\n\t\t\t\t_, err = api.WaitForServerStopped(cmd.API, serverID)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Errorf(\"failed to wait for server %s: %v\", serverID, err)\n\t\t\t\t\thasError = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tfmt.Println(needle)\n\t\t}\n\t}\n\n\tif hasError {\n\t\tos.Exit(1)\n\t}\n}", "func (s *Server) Stop() error {\n\t// Stop operations server\n\terr := s.Operations.Stop()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif s.listener == nil {\n\t\treturn nil\n\t}\n\n\t_, port, err := net.SplitHostPort(s.listener.Addr().String())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = s.closeListener()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif s.wait == nil {\n\t\treturn nil\n\t}\n\n\tfor i := 0; i < 10; i++ {\n\t\tselect {\n\t\tcase <-s.wait:\n\t\t\tlog.Debugf(\"Stop: successful stop on port %s\", port)\n\t\t\tclose(s.wait)\n\t\t\ts.wait = nil\n\t\t\treturn nil\n\t\tdefault:\n\t\t\tlog.Debugf(\"Stop: waiting for listener on port %s to stop\", port)\n\t\t\ttime.Sleep(time.Second)\n\t\t}\n\t}\n\tlog.Debugf(\"Stop: timed out waiting for stop notification for port %s\", port)\n\t// make sure DB is closed\n\terr = s.closeDB()\n\tif err != nil {\n\t\tlog.Errorf(\"Close DB failed: %s\", err)\n\t}\n\n\treturn nil\n}", "func (srv *Server) Stop() {\n\tsrv.s.Close()\n\tsrv.wg.Wait()\n}", "func (s *Service) Stop() {\n\ts.s.Shutdown()\n}", "func (s *server) Stop() {\n\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\tdefer cancel()\n\n\ts.httpServer.SetKeepAlivesEnabled(false)\n\terr := s.httpServer.Shutdown(ctx)\n\tif err != nil {\n\t\ts.logger.Fatalf(\"could not gracefully shutdown the server: %v\\n\", err)\n\t}\n\n\t<-s.done\n}", "func (f *feeService) stop() {\n\tif err := f.srv.Shutdown(context.Background()); err != nil {\n\t\tfmt.Printf(\"error: cannot stop fee api: %v\", err)\n\t}\n\n\tf.wg.Wait()\n}", "func (t *TcpServer) Stop() {\n\tt.isRunning = false\n}", "func (wsServer *WsServer) Stop() {\n\tif atomic.AddInt32(&wsServer.shutdown, 1) != 1 {\n\t\tLogger.log.Info(\"RPC server is already in the process of shutting down\")\n\t}\n\tLogger.log.Info(\"RPC server shutting down\")\n\tif wsServer.started != 0 {\n\t\twsServer.server.Close()\n\t}\n\tfor _, listen := range wsServer.config.HttpListenters {\n\t\tlisten.Close()\n\t}\n\tLogger.log.Warn(\"RPC server shutdown complete\")\n\twsServer.started = 0\n\twsServer.shutdown = 1\n}", "func (s *Service) Stop() {\n\tclose(s.stopChan)\n}", "func (w *Web) Stop() error {\n\tw.L(\"Stopping web server on %s:%s\", w.Address, w.Port)\n\tctx, cancel := context.WithTimeout(context.Background(), nonZeroDuration(w.Timeouts.Shutdown, time.Second*30))\n\tdefer cancel()\n\terr := w.Shutdown(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tw.running = false\n\treturn nil\n}", "func (service *Service) Stop() {\n\tlog.Info(\"close TaskService size:\")\n\tif err := service.kafka.Stop(); err != nil {\n\t\tpanic(err)\n\t}\n\t<-service.stopped\n\t_ = service.clickhouse.Close()\n\tlog.Info(\"closed TaskService size:\")\n}", "func (r *server) Stop() {\n\t// TODO: pass context in as a parameter.\n\tctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\n\tdefer cancel()\n\n\tif err := r.stopHTTPServers(ctx); err != nil {\n\t\tlog.WithError(err).Error(\"Some HTTP servers failed to shutdown.\")\n\t}\n\n\tr.Server.Stop()\n}", "func shutDown(ctx context.Context, logger *log.Logger, srv *http.Server) {\n\tquit := make(chan os.Signal, 1)\n\tsignal.Notify(quit, os.Interrupt)\n\t<-quit\n\n\tlogger.Info(\"msg\", \"Shutting down HTTP/REST gateway server...\")\n\n\tctx, cancel := context.WithTimeout(ctx, 5*time.Second)\n\tdefer cancel()\n\n\tif err := srv.Shutdown(ctx); err != nil {\n\t\tlogger.Error(\"err\", fmt.Sprintf(\"Shutdown HTTP/REST gateway server: %s\", err.Error()))\n\t}\n\n\tlogger.Info(\"msg\", \"Shutdown done HTTP/REST gateway server\")\n}", "func (s *daemonServer) Stop() {\n\ts.grpcServer.Stop()\n}", "func (app *App) Stop() error {\n\t// Close already uploaded file tracker\n\tapp.Logger.Debug(\"Shutting down File Tracker service...\")\n\tif err := app.FileTracker.Close(); err != nil {\n\t\treturn err\n\t}\n\n\t// Close upload session tracker\n\tapp.Logger.Debug(\"Shutting down Upload Tracker service...\")\n\tif err := app.UploadTracker.Close(); err != nil {\n\t\treturn err\n\t}\n\n\t// Close token manager\n\tapp.Logger.Debug(\"Shutting down Token Manager service...\")\n\tif err := app.TokenManager.Close(); err != nil {\n\t\treturn err\n\t}\n\n\tapp.Logger.Debug(\"All services has been shut down successfully\")\n\treturn nil\n}", "func (ts *Server) Stop() error {\n\tif ts.Server == nil {\n\t\treturn nil\n\t}\n\tif err := ts.Server.Shutdown(context.Background()); err != nil {\n\t\treturn err\n\t}\n\tts.Server = nil\n\treturn nil\n}", "func Stop(args ...string) {\n switch {\n case cfg.Kill:\n Kill(args...)\n default:\n runInstances(\"Stopping\", func(i int, id string) error {\n defer os.Remove(pidFileName(i))\n return run(\"stop\", id)\n })\n }\n}", "func (c *Controller) Stop() {\n\tglog.Info(\"shutdown http service\")\n}", "func (s *RepService) Stop() {\n\ts.running = false\n}", "func TearDownSuite(suiteCtx *types.SuiteContext) {\n\tBy(\"tearing down the test environment\")\n\n\tselenium.RemoveSeleniumIfNeeded(suiteCtx)\n\n\terr := suiteCtx.TestEnv.Stop()\n\tExpect(err).ToNot(HaveOccurred())\n}", "func (service *HTTPRestService) Stop() {\n\tservice.Uninitialize()\n\tlog.Printf(\"[Azure CNS] Service stopped.\")\n}", "func (s *Service) Stop() error {\n\treturn s.client.Close()\n}", "func (k *k8sService) Stop() {\n\t// prevent other Start/Stop operations until we are done\n\tk.startStopMutex.Lock()\n\tdefer k.startStopMutex.Unlock()\n\n\t// Protect state access from other go-routines\n\tk.Lock()\n\tif !k.running {\n\t\tk.Unlock()\n\t\treturn\n\t}\n\tlog.Infof(\"Stopping k8s service\")\n\n\tk.running = false\n\tk.isLeader = false\n\tif k.modCh != nil {\n\t\tclose(k.modCh)\n\t}\n\tif k.cancel != nil {\n\t\tk.cancel()\n\t}\n\n\t// release lock so that goroutines can make progress and terminate cleanly\n\tk.Unlock()\n\n\t// Wait for goroutines to terminate\n\tk.Wait()\n\n\tk.client = nil\n\tk.strClient = nil\n\tk.cancel = nil\n\tk.modCh = nil\n}", "func (server *Server) stop() {\n\tfor address, connection := range server.connections {\n\t\tif server.breakConnection(connection) {\n\t\t\tserver.Logger.Info(\"Close connection at\", address)\n\t\t} else {\n\t\t\tserver.Logger.Warning(\"Impossible to close connection at\", address)\n\t\t}\n\t}\n\tif server.tcp_socket != nil {\n//\t\tfor conn_type, socket := range server.tcp_socket {\n//\t\t\terr := socket.Close()\n//\t\t\tif err != nil {\n//\t\t\t\tserver.Logger.Error(\"Error occured during closing \" + conn_type + \" socket:\", err)\n//\t\t\t}\n//\t\t}\n\t\terr := server.tcp_socket.Close()\n\t\tif err != nil {\n\t\t\tserver.Logger.Error(\"Error occured during closing \" + \"tcp\" + \" socket:\", err)\n\t\t}\n\t\tserver.tcp_socket = nil\n\t} else {\n\t\tserver.Logger.Error(\"Server can't be stoped, because socket is undefined.\")\n\t}\n\tserver.Logger.Info(\"Waiting for ending process of goroutines...\")\n\tserver.Wait()\n\tserver.storage.FlushAll()\n}", "func (s *SystemService) Stop() error {\n\terr := s.control(svc.Stop, svc.Stopped)\n\tif err != nil {\n\t\te := err.Error()\n\t\tif strings.Contains(e, \"service does not exist\") {\n\t\t\treturn nil\n\t\t}\n\t\treturn err\n\t}\n\n\tattempt := 0\n\tmaxAttempts := 10\n\twait := 3 * time.Second\n\tfor {\n\t\tattempt++\n\n\t\tlogger.Log(\"waiting for service to stop\")\n\n\t\t// // Wait a few seconds before retrying.\n\t\ttime.Sleep(wait)\n\n\t\t// // Attempt to start the service again.\n\t\tstat, err := s.Status()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// // Check the status to see if it is running yet.\n\t\t// stat, err := system.Service.Status()\n\t\t// if err != nil {\n\t\t// \texit(err, stop)\n\t\t// }\n\n\t\t// // If it is now running, exit the retry loop.\n\t\tif !stat.Running {\n\t\t\tbreak\n\t\t}\n\n\t\tif attempt == maxAttempts {\n\t\t\treturn errors.New(\"could not stop system service after multiple attempts\")\n\t\t}\n\t}\n\n\treturn nil\n\t// _, err := runScCommand(\"stop\", fmt.Sprintf(\"\\\"%s\\\"\", s.Command.Name))\n\n\t// if err != nil {\n\t// \tlogger.Log(\"stop service error: \", err)\n\n\t// \tif strings.Contains(err.Error(), \"exit status 1062\") {\n\t// \t\tlogger.Log(\"service already stopped\")\n\t// \t} else {\n\t// \t\treturn err\n\t// \t}\n\t// }\n\n\t// return nil\n}", "func (s *Service) Stop() {\n\tclose(s.ch)\n\ts.waitGroup.Wait()\n}", "func (b *Bot) Stop() {\n\tb.serversProtect.RLock()\n\tfor _, srv := range b.servers {\n\t\tb.stopServer(srv)\n\t}\n\tb.serversProtect.RUnlock()\n}", "func (s *Server) Stop() {\n\tclose(s.stopChan)\n\tfor _, l := range s.listeners {\n\t\tl.Stop()\n\t}\n\tif s.Statistics != nil {\n\t\ts.Statistics.Stop()\n\t}\n\ts.health.Deregister() //nolint:errcheck\n\ts.Started = false\n}", "func (hSvr *HTTPServer) Stop(ctx context.Context) error {\n\treturn hSvr.svr.Shutdown(ctx)\n}", "func (ms *MockOpenIDDiscoveryServer) Stop() error {\n\tms.HitNum = 0\n\treturn ms.server.Close()\n}", "func (o *Object) StopHttpServer() {\n\t_ = o.server.Shutdown(context.Background())\n}", "func (ms *MockServer) Stop() error {\n\tif ms.server == nil {\n\t\treturn nil\n\t}\n\n\treturn ms.server.Close()\n}", "func (m *ntpManager) Stop() error {\n\tif m == nil {\n\t\treturn fmt.Errorf(\"ntp manager %w\", ErrNilSubsystem)\n\t}\n\tif atomic.LoadInt32(&m.started) == 0 {\n\t\treturn fmt.Errorf(\"NTP manager %w\", ErrSubSystemNotStarted)\n\t}\n\tdefer func() {\n\t\tlog.Debugf(log.TimeMgr, \"NTP manager %s\", MsgSubSystemShutdown)\n\t\tatomic.CompareAndSwapInt32(&m.started, 1, 0)\n\t}()\n\tlog.Debugf(log.TimeMgr, \"NTP manager %s\", MsgSubSystemShuttingDown)\n\tclose(m.shutdown)\n\treturn nil\n}", "func (a API) Stop(ctx context.Context) error {\n\treturn a.srv.Shutdown(ctx)\n}", "func (s SystemdInitSystem) DisableAndStopService() error {\n\tenabled, err := s.isEnabled()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error checking if etcd service is enabled: %w\", err)\n\t}\n\tif enabled {\n\t\tif err := s.disable(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tactive, err := s.IsActive()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error checking if etcd service is active: %w\", err)\n\t}\n\n\tif active {\n\t\tif err := s.stop(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (s *Server) Stop(ctx context.Context) {\n\ts.shutdownFuncsM.Lock()\n\tdefer s.shutdownFuncsM.Unlock()\n\ts.shutdownOnce.Do(func() {\n\t\tclose(s.shuttingDown)\n\t\t// Shut down the HTTP server in parallel to calling any custom shutdown functions\n\t\twg := sync.WaitGroup{}\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tif err := s.srv.Shutdown(ctx); err != nil {\n\t\t\t\tslog.Debug(ctx, \"Graceful shutdown failed; forcibly closing connections 👢\")\n\t\t\t\tif err := s.srv.Close(); err != nil {\n\t\t\t\t\tslog.Critical(ctx, \"Forceful shutdown failed, exiting 😱: %v\", err)\n\t\t\t\t\tpanic(err) // Something is super hosed here\n\t\t\t\t}\n\t\t\t}\n\t\t}()\n\t\tfor _, f := range s.shutdownFuncs {\n\t\t\tf := f // capture range variable\n\t\t\twg.Add(1)\n\t\t\tgo func() {\n\t\t\t\tdefer wg.Done()\n\t\t\t\tf(ctx)\n\t\t\t}()\n\t\t}\n\t\twg.Wait()\n\t})\n}", "func (r *AgentServer) Stop() {\n\tr.listener.Close()\n\tr.wg.Wait()\n}", "func Test_RNIS_stopSystemTest(t *testing.T) {\n\terr := deleteScenario(\"rnis-system-test\")\n\tif err != nil {\n\t\tlog.Error(\"cannot delete scenario :\", err)\n\t}\n}", "func (s *Server) OnStop() {}", "func (v *vtStopCrawler) stop() {\n\tfor _, worker := range v.workers {\n\t\tworker.stop()\n\t}\n\tclose(v.done)\n}", "func (p *PrivNegAPI) Stop() {\n\tif err := p.server.Shutdown(nil); err != nil {\n\t\tpanic(err)\n\t}\n}", "func (this *SimulateLocationService) Stop() error {\n\tif _, err := this.service.GetConnection().Write([]byte{0x00, 0x00, 0x00, 0x01}); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (svc *Service) Stop(s service.Service) (err error) {\n\tif svc.daemon.exited.Get() {\n\t\treturn nil\n\t}\n\tlog.Info(\"service is stopping. notifying agent process.\")\n\n\tsvc.daemon.Lock()\n\tdefer svc.daemon.Unlock()\n\n\tsvc.daemon.stopRequested.Set(true)\n\n\t// notify the agent to gracefully stop\n\twindows.PostNotificationMessage(windows.GetPipeName(svcName), ipc.Stop)\n\n\treturn svc.terminate(err)\n}", "func RemoteStop(host string, port string) error {\n\tclient := &http.Client{}\n\treq, err := http.NewRequest(\"GET\", \"http://\"+host+\":\"+port+\"/stop\", nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq.Close = true\n\treq.Header.Set(\"Content-Type\", \"application/text\")\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tbs := string(body)\n\tfmt.Printf(\"checkme: %s\\n\", bs)\n\n\treturn nil\n}", "func StopDefaultServer() {\n\tDefaultServer.StopService()\n}", "func handleStop(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {\n\tselect {\n\tcase s.requestProcessShutdown <- struct{}{}:\n\tdefault:\n\t}\n\treturn \"kaspad stopping.\", nil\n}" ]
[ "0.70196897", "0.6680899", "0.66318434", "0.66318434", "0.66209775", "0.64933527", "0.6451682", "0.6430011", "0.6388342", "0.6388342", "0.6270665", "0.6192106", "0.61838084", "0.6182933", "0.61214626", "0.6117665", "0.60970193", "0.6061633", "0.60576785", "0.60330755", "0.60320735", "0.60318935", "0.60080284", "0.59994376", "0.5989082", "0.59443283", "0.59346735", "0.59337455", "0.5919091", "0.5915639", "0.59020025", "0.5901632", "0.5891067", "0.5864932", "0.5864047", "0.58559364", "0.5847781", "0.5847426", "0.5834038", "0.583301", "0.5809361", "0.5807444", "0.58051765", "0.5801658", "0.5800131", "0.57983994", "0.5796868", "0.5796411", "0.57937545", "0.5782394", "0.5781536", "0.5779614", "0.5771035", "0.5762901", "0.5762505", "0.5753524", "0.57528144", "0.57433695", "0.5737611", "0.57283306", "0.57255155", "0.5719444", "0.57142526", "0.57104015", "0.5708173", "0.57067513", "0.5704591", "0.5686042", "0.5683895", "0.5681114", "0.5680379", "0.56735843", "0.56645006", "0.56579846", "0.5657303", "0.56512374", "0.56415206", "0.5635641", "0.5631651", "0.56252104", "0.5623119", "0.5621463", "0.5619028", "0.5611796", "0.5611285", "0.56099755", "0.5609232", "0.56064343", "0.56018764", "0.5599246", "0.55977917", "0.55977297", "0.5595132", "0.5593844", "0.559082", "0.55848753", "0.5583347", "0.55762106", "0.5574213", "0.5570039" ]
0.8379308
0
NewDriver create new browser driver
NewDriver создает новый браузерный драйвер
func NewDriver(browser string) selenium.WebDriver { StartService() caps := selenium.Capabilities{"browserName": browser} switch browser { case "chrome": chrCaps := chrome.Capabilities{ Args: []string{ "--no-sandbox", }, W3C: true, } if headless { chrCaps.Args = append(chrCaps.Args, "--headless") } caps.AddChrome(chrCaps) case "htmlunit": caps["javascriptEnabled"] = true } wd, err := selenium.NewRemote(caps, fmt.Sprintf("http://localhost:%d/wd/hub", port)) if err != nil { } driver = wd return wd }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewDriver() godfish.Driver { return &driver{} }", "func newDriver() *driver {\n\treturn &driver{\n\t\tnetworks: map[string]*bridgeNetwork{},\n\t\tportAllocator: portallocator.Get(),\n\t}\n}", "func RegisterNewDriver(driver string, defaultscopes []string, callback func(client *http.Client, u *models.User), endpoint oauth2.Endpoint, apimap, usermap map[string]string) {\n\tapiMap[driver] = apimap\n\tuserMap[driver] = usermap\n\tendpointMap[driver] = endpoint\n\tcallbackMap[driver] = callback\n\tdefaultScopesMap[driver] = defaultscopes\n}", "func NewDriver(root string) *Driver {\n\treturn &Driver{\n\t\troot: root,\n\t}\n}", "func NewDriver(cfg *config.Config) *Driver {\n\tdriver := &Driver{\n\t\tcfg: cfg,\n\t}\n\n\treturn driver\n}", "func NewDriver(baseURL string, token string) (*Driver, error) {\n\traw, err := hype.New(baseURL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\td := &Driver{\n\t\traw,\n\t\ttoken,\n\t\thype.NewHeader(\"Accept\", \"application/json\"),\n\t\thype.NewHeader(\"Content-Type\", \"application/json\"),\n\t\thype.NewHeader(\"User-Agent\", \"fbz/0.1.0 (https://github.com/ess/fbz)\"),\n\t}\n\n\treturn d, nil\n}", "func NewDriver(name string) (*App, error) {\n\treturn newApp(\"driver.\" + name)\n}", "func NewDriver() *Driver {\n\treturn &Driver{\n\t\tServer: http.Server{\n\t\t\tReadTimeout: 30 * time.Second,\n\t\t\tWriteTimeout: 30 * time.Second,\n\t\t\tIdleTimeout: 120 * time.Second,\n\t\t},\n\t}\n}", "func NewDriver(root string, client *pilosa.Client) *Driver {\n\treturn &Driver{\n\t\troot: root,\n\t\tclient: client,\n\t}\n}", "func NewDriver(machineID string, secretData map[string][]byte, classKind string, machineClass interface{}, machineName string) Driver {\n\n\tswitch classKind {\n\tcase \"OpenStackMachineClass\":\n\t\treturn &OpenStackDriver{\n\t\t\tOpenStackMachineClass: machineClass.(*v1alpha1.OpenStackMachineClass),\n\t\t\tCredentialsData: secretData,\n\t\t\tUserData: string(secretData[\"userData\"]),\n\t\t\tMachineID: machineID,\n\t\t\tMachineName: machineName,\n\t\t}\n\n\tcase \"AWSMachineClass\":\n\t\treturn &AWSDriver{\n\t\t\tAWSMachineClass: machineClass.(*v1alpha1.AWSMachineClass),\n\t\t\tCredentialsData: secretData,\n\t\t\tUserData: string(secretData[\"userData\"]),\n\t\t\tMachineID: machineID,\n\t\t\tMachineName: machineName,\n\t\t}\n\n\tcase \"AzureMachineClass\":\n\t\treturn &AzureDriver{\n\t\t\tAzureMachineClass: machineClass.(*v1alpha1.AzureMachineClass),\n\t\t\tCredentialsData: secretData,\n\t\t\tUserData: string(secretData[\"userData\"]),\n\t\t\tMachineID: machineID,\n\t\t\tMachineName: machineName,\n\t\t}\n\n\tcase \"GCPMachineClass\":\n\t\treturn &GCPDriver{\n\t\t\tGCPMachineClass: machineClass.(*v1alpha1.GCPMachineClass),\n\t\t\tCredentialsData: secretData,\n\t\t\tUserData: string(secretData[\"userData\"]),\n\t\t\tMachineID: machineID,\n\t\t\tMachineName: machineName,\n\t\t}\n\n\tcase \"AlicloudMachineClass\":\n\t\treturn &AlicloudDriver{\n\t\t\tAlicloudMachineClass: machineClass.(*v1alpha1.AlicloudMachineClass),\n\t\t\tCredentialsData: secretData,\n\t\t\tUserData: string(secretData[\"userData\"]),\n\t\t\tMachineID: machineID,\n\t\t\tMachineName: machineName,\n\t\t}\n\tcase \"PacketMachineClass\":\n\t\treturn &PacketDriver{\n\t\t\tPacketMachineClass: machineClass.(*v1alpha1.PacketMachineClass),\n\t\t\tCredentialsData: secretData,\n\t\t\tUserData: string(secretData[\"userData\"]),\n\t\t\tMachineID: machineID,\n\t\t\tMachineName: machineName,\n\t\t}\n\t}\n\n\treturn NewFakeDriver(\n\t\tfunc() (string, string, error) {\n\t\t\tfakeVMs[\"fake\"] = \"fake_ip\"\n\t\t\treturn \"fake\", \"fake_ip\", nil\n\t\t},\n\t\tfunc(machineID string, machineName string) error {\n\t\t\tfakeVMs[machineID] = machineName\n\t\t\treturn nil\n\t\t},\n\t\tfunc(machineID string) error {\n\t\t\t// delete(fakeVMs, \"fake\")\n\t\t\tdelete(fakeVMs, machineID)\n\t\t\treturn nil\n\t\t},\n\t\tfunc() (string, error) {\n\t\t\treturn \"\", nil\n\t\t},\n\t\tfunc() (VMs, error) {\n\t\t\treturn fakeVMs, nil\n\t\t},\n\t\tfunc([]corev1.PersistentVolumeSpec) ([]string, error) {\n\t\t\treturn []string{}, nil\n\t\t},\n\t\tfunc() string {\n\t\t\treturn \"\"\n\t\t},\n\t\tfunc(string) {\n\t\t\treturn\n\t\t},\n\t)\n}", "func NewRemote(capabilities Capabilities, urlPrefix string) (WebDriver, error) {\n\tif urlPrefix == \"\" {\n\t\turlPrefix = DefaultURLPrefix\n\t}\n\n\twd := &remoteWD{\n\t\turlPrefix: urlPrefix,\n\t\tcapabilities: capabilities,\n\t}\n\tif b := capabilities[\"browserName\"]; b != nil {\n\t\twd.browser = b.(string)\n\t}\n\tif _, err := wd.NewSession(); err != nil {\n\t\treturn nil, err\n\t}\n\treturn wd, nil\n}", "func CreateDriver(url string, capabilities map[string]string) *Driver {\n\tnewDriver := &Driver{\n\t\tclient.CreateClient(url),\n\t\tcapabilities,\n\t\t\"\",\n\t}\n\n\treturn newDriver\n}", "func NewDriver(machineName string, storePath string) *Driver {\n\tbmlog.DebugLevel = 5\n\tdefaultDiscs := brain.Discs{\n\t\tbrain.Disc{\n\t\t\tLabel: \"disk-1\",\n\t\t\tStorageGrade: \"sata\",\n\t\t\tSize: 25600,\n\t\t},\n\t}\n\n\treturn &Driver{\n\t\tspec: brain.VirtualMachineSpec{\n\t\t\tVirtualMachine: brain.VirtualMachine{\n\t\t\t\tCores: defaultCores,\n\t\t\t\tDiscs: defaultDiscs,\n\n\t\t\t\tMemory: defaultMemory,\n\t\t\t\tZoneName: defaultZone,\n\t\t\t\tName: defaultName,\n\t\t\t},\n\t\t\tReimage: &brain.ImageInstall{\n\t\t\t\tDistribution: \"stretch\",\n\t\t\t\t// TODO: generate a random root password.\n\t\t\t\tRootPassword: \"Shohshu9mi9aephahnaigi5l\",\n\t\t\t},\n\t\t},\n\t\tBaseDriver: &drivers.BaseDriver{\n\t\t\tSSHUser: defaultUser,\n\t\t\tMachineName: machineName,\n\t\t\tStorePath: storePath,\n\t\t},\n\t}\n}", "func NewDriver(ca CABackend, client *client.Client) (*Driver, error) {\n\treturn &Driver{\n\t\tca: ca,\n\t\tclient: client,\n\t}, nil\n}", "func New() (d *Driver) {\n\treturn &Driver{}\n}", "func NewDriver(ctx context.Context, name string, opts DriverOptions) (Driver, error) {\n\tfactory, ok := factories[name]\n\tif !ok {\n\t\treturn nil, errors.Errorf(\"unsupported driver type: %q\", name)\n\t}\n\treturn factory(ctx, opts)\n}", "func NewDriver(endpoint, driverName, nodeID string) *Driver {\n\tglog.Infof(\"NewDriver for CHDFS, driverName: %v version: %v nodeID: %v\", driverName, version, nodeID)\n\n\tcsiDriver := csicommon.NewCSIDriver(driverName, version, nodeID)\n\tcsiDriver.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{\n\t\tcsi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,\n\t})\n\n\treturn &Driver{\n\t\tcsiDriver: csiDriver,\n\t\tendpoint: endpoint,\n\t}\n}", "func (m *Manager) GetNewDriver(machineName string) (Driver, error) {\n\tif driverFactory, ok := m.drivers[machineName]; ok {\n\t\treturn driverFactory(), nil\n\t}\n\n\treturn nil, errors.New(\"No such driver: \" + machineName)\n}", "func NewDriver(options *DriverOptions) CSIDriver {\n\tif !*useDriverV2 {\n\t\treturn newDriverV1(options)\n\t} else {\n\t\treturn newDriverV2(options)\n\t}\n}", "func NewDriver(cfg *configv1.InfrastructureStatus, clnt client.Client) Driver {\n\n\tctx := context.Background()\n\tvar driver Driver\n\n\tif cfg.PlatformStatus.Type == \"AWS\" {\n\t\tdriver = s3.NewDriver(ctx, cfg, clnt)\n\t}\n\n\tif cfg.PlatformStatus.Type == \"GCP\" {\n\t\tdriver = gcs.NewDriver(ctx, cfg, clnt)\n\t}\n\n\treturn driver\n}", "func NewDriver(name string, loader func(interface{}) error) (Driver, error) {\n\tfactorysMu.RLock()\n\tfactoryi, ok := factories[name]\n\tfactorysMu.RUnlock()\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"file: unknown driver %q (forgotten import?)\", name)\n\t}\n\treturn factoryi(loader)\n}", "func NewDriver(hostName, storePath string) drivers.Driver {\n\treturn &Driver{\n\t\tBaseDriver: &drivers.BaseDriver{\n\t\t\tSSHUser: \"docker\",\n\t\t\tMachineName: hostName,\n\t\t\tStorePath: storePath,\n\t\t},\n\t}\n}", "func (r *Relwarc) NewBrowser() *Browser {\n\tctx, cancel := chromedp.NewContext(r.ctx)\n\n\t// make sure a browser and its first tab are created.\n\tif err := chromedp.Run(ctx); err != nil {\n\t\tpanic(err)\n\t}\n\n\t// enable network by default.\n\tif err := chromedp.Run(ctx, network.Enable()); err != nil {\n\t\tpanic(err)\n\t}\n\n\ttgt := chromedp.FromContext(ctx).Target\n\n\ttab := Tab{\n\t\tctx: ctx,\n\t\tcancel: cancel,\n\t\ttarget: tgt,\n\t\trequestMap: map[network.RequestID]*Request{},\n\t}\n\n\tchromedp.ListenTarget(ctx, tab.onTargetEvent)\n\n\tbrowser := Browser{\n\t\tctx: ctx,\n\t\tfirst: &tab,\n\t\ttabs: map[target.ID]*Tab{},\n\t}\n\n\treturn &browser\n}", "func NewDriver(machineName, storePath string) drivers.Driver {\n\treturn &Driver{\n\t\tInstanceProfile: defaultInstanceProfile,\n\t\tDiskSize: defaultDiskSize,\n\t\tImage: defaultImage,\n\t\tAvailabilityZone: defaultAvailabilityZone,\n\t\tasync: egoscale.AsyncInfo{\n\t\t\tRetries: 3,\n\t\t\tDelay: 20,\n\t\t},\n\t\tBaseDriver: &drivers.BaseDriver{\n\t\t\tMachineName: machineName,\n\t\t\tStorePath: storePath,\n\t\t},\n\t}\n}", "func CreatePage(browserName ...string) core.Page {\n\tcapabilities := core.Use()\n\tif len(browserName) > 0 {\n\t\tcapabilities.Browser(browserName[0])\n\t}\n\tnewPage, err := driver.Page(capabilities)\n\tcheckFailure(err)\n\treturn newPage\n}", "func NewDriver(version string, ctx *cli.Context) (*Driver, error) {\n\tdocker, err := client.NewEnvClient()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not connect to docker: %s\", err)\n\t}\n\n\td := &Driver{\n\t\tnetworks: networkTable{},\n\t\tdClient: docker,\n\t}\n\treturn d, nil\n}", "func WDInit() selenium.WebDriver {\n\tvar err error\n\n\tops := []selenium.ServiceOption{\n\t\tselenium.ChromeDriver(seleniumPath),\n\t}\n\n\t//service, err := selenium.NewSeleniumService(seleniumPath, port, ops...)\n\tservice, err := selenium.NewChromeDriverService(chromeDriverPath, port, ops...)\n\tif err != nil {\n\t\tlog.Printf(\"Error starting the ChromeDriver server: %v\", err)\n\t}\n\t//Delay service shutdown\n\tdefer service.Stop()\n\n\t//log.Println(\"Service => \", service)\n\n\tcaps := selenium.Capabilities(map[string]interface{}{\"browserName\": \"chrome\"})\n\t//log.Println(\"Capabilities => \", caps)\n\n\tdriver, err := selenium.NewRemote(caps, \"\")\n\n\tif err != nil {\n\t\tlog.Println(\"support/base | Error al instanciar el driver de Selenium : \", err.Error())\n\t}\n\t//driver.ResizeWindow(\"note\", 1920, 1080)\n\treturn driver\n}", "func newHub(scheme string, vendorID uint16, productIDs []uint16, usageID uint16, endpointID int, makeDriver func(bgmlogs.bgmlogsger) driver) (*Hub, error) {\n\tif !hid.Supported() {\n\t\treturn nil, errors.New(\"unsupported platform\")\n\t}\n\thub := &Hub{\n\t\tscheme: scheme,\n\t\tvendorID: vendorID,\n\t\tproductIDs: productIDs,\n\t\tusageID: usageID,\n\t\tendpointID: endpointID,\n\t\tmakeDriver: makeDriver,\n\t\tquit: make(chan chan error),\n\t}\n\thubPtr.refreshWallets()\n\treturn hub, nil\n}", "func NewDriver() Driver {\n\treturn &boltDriver{}\n}", "func NewDriver() *Driver {\n\treturn &Driver{\n\t\tVMDriver: &drivers.VMDriver{\n\t\t\tBaseDriver: &drivers.BaseDriver{},\n\t\t\tCPU: DefaultCPUs,\n\t\t\tMemory: DefaultMemory,\n\t\t},\n\t}\n}", "func NewDriver(dialect string, c Conn) *Driver {\n\treturn &Driver{dialect: dialect, Conn: c}\n}", "func newMongoDriver(name string, opts MongoDBOptions) (*mongoDriver, error) {\n\thost, _ := os.Hostname() // nolint\n\n\tif err := opts.Validate(); err != nil {\n\t\treturn nil, errors.Wrap(err, \"invalid mongo driver options\")\n\t}\n\n\treturn &mongoDriver{\n\t\tname: name,\n\t\topts: opts,\n\t\tinstanceID: fmt.Sprintf(\"%s.%s.%s\", name, host, uuid.New()),\n\t}, nil\n}", "func newStubDriver() *stubDriver {\n\treturn &stubDriver{\n\t\tdedupedBlocks: make(map[string][]byte),\n\t\theaders: make(map[string][]byte),\n\t}\n}", "func openNewMongoDriver(ctx context.Context, name string, opts MongoDBOptions, client *mongo.Client) (*mongoDriver, error) {\n\td, err := newMongoDriver(name, opts)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"could not create driver\")\n\t}\n\n\tif err := d.start(ctx, clientStartOptions{client: client}); err != nil {\n\t\treturn nil, errors.Wrap(err, \"problem starting driver\")\n\t}\n\n\treturn d, nil\n}", "func newVideoDriver(scaleFactor float64, unlimitedFPS bool) (*videoDriver, error) {\n\tvar vd videoDriver\n\n\tvd.unlimitedFPS = unlimitedFPS\n\n\terr := sdl.Init(sdl.INIT_EVERYTHING)\n\tif err != nil {\n\t\treturn nil, xerrors.Errorf(\"initializing SDL: %v\", err)\n\t}\n\n\tvd.window, err = sdl.CreateWindow(\n\t\t\"Gopherboy\",\n\t\tsdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,\n\t\tint32(gameboy.ScreenWidth*scaleFactor),\n\t\tint32(gameboy.ScreenHeight*scaleFactor),\n\t\tsdl.WINDOW_OPENGL)\n\tif err != nil {\n\t\treturn nil, xerrors.Errorf(\"initializing window: %v\", err)\n\t}\n\n\tvd.renderer, err = sdl.CreateRenderer(vd.window, -1, sdl.RENDERER_ACCELERATED)\n\tif err != nil {\n\t\treturn nil, xerrors.Errorf(\"initializing renderer: %v\", err)\n\t}\n\n\tvd.renderer.SetDrawColor(255, 255, 255, 255)\n\n\tvd.readyForNewFrame = true\n\n\treturn &vd, nil\n}", "func NewDriver(context *base.Context) (drivers.Driver, error) {\n\ttokens := strings.SplitN(context.Region, \":\", 2)\n\tif len(tokens) != 2 {\n\t\treturn nil, util.Errorf(\"invalid region syntax, expected <driver>:<region name>, got: %q\", context.Region)\n\t}\n\n\tvar driver drivers.Driver\n\n\tprovider := tokens[0]\n\tregion := tokens[1]\n\tswitch provider {\n\tcase \"aws\":\n\t\tdriver = amazon.NewDriver(context, region)\n\tcase \"gce\":\n\t\tdriver = google.NewDriver(context, region)\n\tdefault:\n\t\treturn nil, util.Errorf(\"unknown driver: %s\", driver)\n\t}\n\n\terr := driver.Init()\n\treturn driver, err\n}", "func NewDriver(hostName, storePath string) *Driver {\n\treturn &Driver{\n\t\tBaseDriver: &drivers.BaseDriver{\n\t\t\tMachineName: hostName,\n\t\t\tStorePath: storePath,\n\t\t},\n\t\tBoot2DockerIsoVersion: defaultBoot2DockerIsoVersion,\n\t\tBoot2DockerURL: defaultBoot2DockerURL,\n\t\tBootCmd: defaultBootCmd,\n\t\tCPU: defaultCPU,\n\t\tCaCertPath: defaultCaCertPath,\n\t\tDiskSize: defaultDiskSize,\n\t\tMacAddr: defaultMacAddr,\n\t\tMemory: defaultMemory,\n\t\tPrivateKeyPath: defaultPrivateKeyPath,\n\t\tUUID: defaultUUID,\n\t\tNFSShare: defaultNFSShare,\n\t}\n}", "func newDriverV2(options *DriverOptions) *DriverV2 {\n\tklog.Warning(\"Using DriverV2\")\n\tdriver := DriverV2{}\n\tdriver.Name = options.DriverName\n\tdriver.Version = driverVersion\n\tdriver.NodeID = options.NodeID\n\tdriver.VolumeAttachLimit = options.VolumeAttachLimit\n\tdriver.volumeLocks = volumehelper.NewVolumeLocks()\n\tdriver.perfOptimizationEnabled = options.EnablePerfOptimization\n\tdriver.cloudConfigSecretName = options.CloudConfigSecretName\n\tdriver.cloudConfigSecretNamespace = options.CloudConfigSecretNamespace\n\tdriver.customUserAgent = options.CustomUserAgent\n\tdriver.userAgentSuffix = options.UserAgentSuffix\n\tdriver.useCSIProxyGAInterface = options.UseCSIProxyGAInterface\n\tdriver.enableOtelTracing = options.EnableOtelTracing\n\tdriver.ioHandler = azureutils.NewOSIOHandler()\n\tdriver.hostUtil = hostutil.NewHostUtil()\n\n\ttopologyKey = fmt.Sprintf(\"topology.%s/zone\", driver.Name)\n\treturn &driver\n}", "func NewDriver(config dbmate.DriverConfig) dbmate.Driver {\n\treturn &Driver{\n\t\tmigrationsTableName: config.MigrationsTableName,\n\t\tdatabaseURL: config.DatabaseURL,\n\t\tlog: config.Log,\n\t}\n}", "func NewDriver(driveClient drive.APIClient) (drive.Driver, error) {\n\treturn newDriver(driveClient)\n}", "func NewChromium(profile, key, name, storage string) (Browser, error) {\n\treturn &Chromium{profilePath: profile, keyPath: key, name: name, storage: storage}, nil\n}", "func NewDriver(storage StorageDriver, mountPath string) Driver {\n\treturn &driverInfo{\n\t\tstorage: storage,\n\t\tmountPath: mountPath,\n\t\tvolumes: make(map[string]*Volume),\n\t}\n}", "func NewDriver(nodeID string, endpoint string, synoOption *options.SynologyOptions) (Driver, error) {\n\tglog.Infof(\"Driver: %v\", DriverName)\n\n\tsession, _, err := Login(synoOption)\n\tif err != nil {\n\t\tglog.V(3).Infof(\"Failed to login: %v\", err)\n\t\treturn nil, err\n\t}\n\n\td := &driver{\n\t\tendpoint: endpoint,\n\t\tsynologyHost: synoOption.Host,\n\t\tsession: *session,\n\t}\n\n\tcsiDriver := csicommon.NewCSIDriver(DriverName, version, nodeID)\n\tcsiDriver.AddControllerServiceCapabilities(\n\t\t[]csi.ControllerServiceCapability_RPC_Type{\n\t\t\tcsi.ControllerServiceCapability_RPC_LIST_VOLUMES,\n\t\t\tcsi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME,\n\t\t\tcsi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME,\n\t\t\tcsi.ControllerServiceCapability_RPC_EXPAND_VOLUME,\n\t\t})\n\tcsiDriver.AddVolumeCapabilityAccessModes(\n\t\t[]csi.VolumeCapability_AccessMode_Mode{csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER})\n\n\td.csiDriver = csiDriver\n\n\treturn d, nil\n}", "func ServiceBrowserNew(conn *dbus.Conn, path dbus.ObjectPath) (*ServiceBrowser, error) {\n\tc := new(ServiceBrowser)\n\n\tc.object = conn.Object(\"org.freedesktop.Avahi\", path)\n\tc.AddChannel = make(chan Service)\n\tc.RemoveChannel = make(chan Service)\n\tc.closeCh = make(chan struct{})\n\n\treturn c, nil\n}", "func New(params DriverParameters) (*Driver, error) {\n defer obs.CloseLog()\n //obs.SyncLog() \n\tclient, _ := obs.New(\n\t\tparams.AccessKey,\n\t\tparams.SecretKey,\n\t\tparams.Endpoint,\n\t\tobs.WithRegion(params.Region),\n\t\tobs.WithSslVerify(params.Secure),\n\t\tobs.WithSignature(params.V2Auth),\n\t\tobs.WithPathStyle(params.PathStyle),\n\t\t//obs.WithSecurityToken(params.SecurityToken),\n\t)\n \n\n\td := &driver{\n\t\tClient: client,\n\t\tBucket: params.Bucket,\n\t\tChunkSize: params.ChunkSize,\n\t\tMultipartCopyChunkSize: params.MultipartCopyChunkSize,\n\t\tMultipartCopyMaxConcurrency: params.MultipartCopyMaxConcurrency,\n\t\tMultipartCopyThresholdSize: params.MultipartCopyThresholdSize,\n\t\tRootDirectory: params.RootDirectory,\n\t\tStorageClass: params.StorageClass,\n\t\tObjectACL: params.ObjectACL,\n\t\tPathStyle: params.PathStyle,\n\t}\n\treturn &Driver{\n\t\tbaseEmbed: baseEmbed{\n\t\t\tBase: base.Base{\n\t\t\t\tStorageDriver: d,\n\t\t\t},\n\t\t},\n\t}, nil\n}", "func New(strs ...interface{}) (*Browser, error) {\n\tvar err error\n\tb := &Browser{}\n\tfor _, str := range strs {\n\t\tif errr := rpc.Register(str); errr != nil {\n\t\t\treturn nil, errr\n\t\t}\n\t}\n\tport := js.Global.Get(\"window\").Get(\"location\").Get(\"port\").String()\n\tb.s, err = websocket.Dial(\"ws://localhost:\" + port + \"/ws-client\") // Blocks until connection is established\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlog.Println(\"connected to ws-client\")\n\tgo jsonrpc.ServeConn(b.s)\n\n\tb.c, err = websocket.Dial(\"ws://localhost:\" + port + \"/ws-server\") // Blocks until connection is established\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlog.Println(\"connected to ws-server\")\n\tb.Client = jsonrpc.NewClient(b.c)\n\treturn b, nil\n}", "func New(lDs, gDs Placeholder, dfn DriverNotifyFunc, ifn Placeholder, pg plugingetter.PluginGetter) (*DrvRegistry, error) {\n\treturn &DrvRegistry{\n\t\tNetworks: Networks{Notify: dfn},\n\t\tpluginGetter: pg,\n\t}, nil\n}", "func NewDriver(client *redis.Client, prefix string) *Driver {\n\treturn &Driver{\n\t\tclient: client,\n\t\tprefix: prefix,\n\t}\n}", "func New(image, rootfs string) (Driver, error) {\n\tfor _, name := range drivers {\n\t\tv := reflect.New(driverRegistry[name])\n\t\td, ok := v.Interface().(Driver)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"%s driver doesn't seem to implement the fsdriver.Driver interface\")\n\t\t}\n\n\t\tif err := d.Init(image, rootfs); err == nil {\n\t\t\treturn d, nil\n\t\t}\n\t}\n\n\treturn nil, fmt.Errorf(\"none of %v drivers are supported on the host\", drivers)\n}", "func NewChromeDriver(url string, port, threadsCount int, timeout time.Duration) *ChromeDriver {\n\td := &ChromeDriver{}\n\td.url = url\n\td.Port = port\n\td.Threads = threadsCount\n\td.StartTimeout = timeout\n\treturn d\n}", "func NewDriver(p *Periph) *Driver {\n\treturn &Driver{p: p, timeoutRx: -1, timeoutTx: -1}\n}", "func NewDriver(ctx context.Context, signupDisabled bool, cfg ldap.Config) (sdk.AuthDriver, error) {\n\tvar d = AuthDriver{\n\t\tsignupDisabled: signupDisabled,\n\t}\n\n\tldap, err := ldap.NewLdapDriver(ctx, cfg)\n\tif err != nil {\n\t\treturn d, err\n\t}\n\td.driver = ldap\n\n\treturn d, nil\n}", "func NewDriver(options *DriverOptions) *Driver {\n\td := Driver{\n\t\tvolLockMap: util.NewLockMap(),\n\t\tsubnetLockMap: util.NewLockMap(),\n\t\tvolumeLocks: newVolumeLocks(),\n\t\tcloudConfigSecretName: options.CloudConfigSecretName,\n\t\tcloudConfigSecretNamespace: options.CloudConfigSecretNamespace,\n\t\tcustomUserAgent: options.CustomUserAgent,\n\t\tuserAgentSuffix: options.UserAgentSuffix,\n\t\tblobfuseProxyEndpoint: options.BlobfuseProxyEndpoint,\n\t\tenableBlobfuseProxy: options.EnableBlobfuseProxy,\n\t\tblobfuseProxyConnTimout: options.BlobfuseProxyConnTimout,\n\t\tenableBlobMockMount: options.EnableBlobMockMount,\n\t\tallowEmptyCloudConfig: options.AllowEmptyCloudConfig,\n\t\tenableGetVolumeStats: options.EnableGetVolumeStats,\n\t\tmountPermissions: options.MountPermissions,\n\t}\n\td.Name = options.DriverName\n\td.Version = driverVersion\n\td.NodeID = options.NodeID\n\n\td.DefaultControllerServer.Driver = &d.CSIDriver\n\td.DefaultIdentityServer.Driver = &d.CSIDriver\n\td.DefaultNodeServer.Driver = &d.CSIDriver\n\n\tvar err error\n\tgetter := func(key string) (interface{}, error) { return nil, nil }\n\tif d.accountSearchCache, err = azcache.NewTimedcache(time.Minute, getter); err != nil {\n\t\tklog.Fatalf(\"%v\", err)\n\t}\n\treturn &d\n}", "func NewDriver(libType string) (Driver, bool) {\n\tvar ecosystem dbTypes.Ecosystem\n\tvar comparer compare.Comparer\n\n\tswitch libType {\n\tcase ftypes.Bundler, ftypes.GemSpec:\n\t\tecosystem = vulnerability.RubyGems\n\t\tcomparer = rubygems.Comparer{}\n\tcase ftypes.RustBinary, ftypes.Cargo:\n\t\tecosystem = vulnerability.Cargo\n\t\tcomparer = compare.GenericComparer{}\n\tcase ftypes.Composer:\n\t\tecosystem = vulnerability.Composer\n\t\tcomparer = compare.GenericComparer{}\n\tcase ftypes.GoBinary, ftypes.GoModule:\n\t\tecosystem = vulnerability.Go\n\t\tcomparer = compare.GenericComparer{}\n\tcase ftypes.Jar, ftypes.Pom, ftypes.Gradle:\n\t\tecosystem = vulnerability.Maven\n\t\tcomparer = maven.Comparer{}\n\tcase ftypes.Npm, ftypes.Yarn, ftypes.Pnpm, ftypes.NodePkg, ftypes.JavaScript:\n\t\tecosystem = vulnerability.Npm\n\t\tcomparer = npm.Comparer{}\n\tcase ftypes.NuGet, ftypes.DotNetCore:\n\t\tecosystem = vulnerability.NuGet\n\t\tcomparer = compare.GenericComparer{}\n\tcase ftypes.Pipenv, ftypes.Poetry, ftypes.Pip, ftypes.PythonPkg:\n\t\tecosystem = vulnerability.Pip\n\t\tcomparer = pep440.Comparer{}\n\tcase ftypes.Pub:\n\t\tecosystem = vulnerability.Pub\n\t\tcomparer = compare.GenericComparer{}\n\tcase ftypes.Hex:\n\t\tecosystem = vulnerability.Erlang\n\t\tcomparer = compare.GenericComparer{}\n\tcase ftypes.Conan:\n\t\tecosystem = vulnerability.Conan\n\t\t// Only semver can be used for version ranges\n\t\t// https://docs.conan.io/en/latest/versioning/version_ranges.html\n\t\tcomparer = compare.GenericComparer{}\n\tcase ftypes.Swift:\n\t\t// Swift uses semver\n\t\t// https://www.swift.org/package-manager/#importing-dependencies\n\t\tecosystem = vulnerability.Swift\n\t\tcomparer = compare.GenericComparer{}\n\tcase ftypes.Cocoapods:\n\t\t// CocoaPods uses RubyGems version specifiers\n\t\t// https://guides.cocoapods.org/making/making-a-cocoapod.html#cocoapods-versioning-specifics\n\t\tecosystem = vulnerability.Cocoapods\n\t\tcomparer = rubygems.Comparer{}\n\tcase ftypes.CondaPkg:\n\t\tlog.Logger.Warn(\"Conda package is supported for SBOM, not for vulnerability scanning\")\n\t\treturn Driver{}, false\n\tdefault:\n\t\tlog.Logger.Warnf(\"The %q library type is not supported for vulnerability scanning\", libType)\n\t\treturn Driver{}, false\n\t}\n\treturn Driver{\n\t\tecosystem: ecosystem,\n\t\tcomparer: comparer,\n\t\tdbc: db.Config{},\n\t}, true\n}", "func getWD() (svc *selenium.Service, wd selenium.WebDriver, err error) {\n\topts := []selenium.ServiceOption{}\n\tsvc, err = selenium.NewChromeDriverService(*seleniumPath, *port, opts...)\n\tif nil != err {\n\t\tfmt.Println(\"start a chromedriver service falid\", err.Error())\n\t\treturn nil, nil, err\n\t}\n\n\t//注意这里,server关闭之后,chrome窗口也会关闭\n\t//defer svc.Stop()\n\n\t//链接本地的浏览器 chrome\n\tcaps := selenium.Capabilities{\n\t\t\"browserName\": \"chrome\",\n\t}\n\n\t//禁止图片加载,加快渲染速度\n\timagCaps := map[string]interface{}{\n\t\t\"profile.managed_default_content_settings.images\": 2,\n\t}\n\tchromeCaps := chrome.Capabilities{\n\t\tPrefs: imagCaps,\n\t\tPath: \"\",\n\t}\n\t//以上是设置浏览器参数\n\tcaps.AddChrome(chromeCaps)\n\n\t// 调起chrome浏览器\n\twd, err = selenium.NewRemote(caps, fmt.Sprintf(\"http://localhost:%d/wd/hub\", *port))\n\tif err != nil {\n\t\tfmt.Println(\"connect to the webDriver faild\", err.Error())\n\t\treturn nil, nil, err\n\t}\n\n\treturn\n}", "func NewDriver(ctx context.Context, prefix string) workers.Driver {\n\tdriver, err := redis.NewDriver(\n\t\tctx,\n\t\tredis.WithQueuePrefix(prefix),\n\t\tredis.WithRedisPool(client),\n\t)\n\tassert.Nil(err)\n\treturn driver\n}", "func newcomputer(brand string) *computer {\n\treturn &computer{brand: brand}\n}", "func newTestEnv(ctx context.Context, t *testing.T, pipelineInfo *pps.PipelineInfo, realEnv *realenv.RealEnv) *testEnv {\n\tlogger := logs.New(pctx.Child(ctx, t.Name()))\n\tworkerDir := filepath.Join(realEnv.Directory, \"worker\")\n\tdriver, err := driver.NewDriver(\n\t\tctx,\n\t\trealEnv.ServiceEnv,\n\t\trealEnv.PachClient,\n\t\tpipelineInfo,\n\t\tworkerDir,\n\t)\n\trequire.NoError(t, err)\n\n\tctx, cancel := pctx.WithCancel(realEnv.PachClient.Ctx())\n\tt.Cleanup(cancel)\n\tdriver = driver.WithContext(ctx)\n\n\treturn &testEnv{\n\t\tRealEnv: realEnv,\n\t\tlogger: logger,\n\t\tdriver: &testDriver{driver},\n\t}\n}", "func openNewMongoGroupDriver(ctx context.Context, name string, opts MongoDBOptions, group string, client *mongo.Client) (*mongoDriver, error) {\n\td, err := newMongoGroupDriver(name, opts, group)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"could not create driver\")\n\t}\n\n\topts.UseGroups = true\n\topts.GroupName = group\n\n\tif err := d.start(ctx, clientStartOptions{client: client}); err != nil {\n\t\treturn nil, errors.Wrap(err, \"starting driver\")\n\t}\n\n\treturn d, nil\n}", "func New(fsys fs.FS, path string) (source.Driver, error) {\n\tvar i driver\n\tif err := i.Init(fsys, path); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to init driver with path %s: %w\", path, err)\n\t}\n\treturn &i, nil\n}", "func NewDefaultDriver() *DefaultDriver {\n\treturn &DefaultDriver{\n\t\tServer: http.Server{\n\t\t\tReadTimeout: 30 * time.Second,\n\t\t\tWriteTimeout: 30 * time.Second,\n\t\t\tIdleTimeout: 120 * time.Second,\n\t\t},\n\t}\n}", "func NewDriver(rootPath string) (*Driver, error) {\n\tfileDriver := new(Driver)\n\tfileDriver.secretsDataFilePath = filepath.Join(rootPath, secretsDataFile)\n\t// the lockfile functions require that the rootPath dir is executable\n\tif err := os.MkdirAll(rootPath, 0o700); err != nil {\n\t\treturn nil, err\n\t}\n\n\tlock, err := lockfile.GetLockFile(filepath.Join(rootPath, \"secretsdata.lock\"))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfileDriver.lockfile = lock\n\n\treturn fileDriver, nil\n}", "func New(apiVersion, maestroVersion string) (*Driver, error) {\n\tdClient, dockerErr := dockerEngine.NewEnvClient()\n\tif dockerErr != nil {\n\t\treturn nil, dockerErr\n\t}\n\treturn &Driver{\n\t\tclient: dClient,\n\t\timage: fmt.Sprintf(\"cpg1111/maestro:%s\", maestroVersion),\n\t}, nil\n}", "func New(addr string, root string) *Driver {\n\tdefer debugTime()()\n\tshell := shell.NewShell(addr)\n\tinfo, err := shell.ID()\n\tif err != nil {\n\t\tlog.Error(\"error constructing node: \", err)\n\t\treturn nil\n\t}\n\tif strings.HasPrefix(root, \"/ipns/local/\") {\n\t\troot = strings.Replace(root, \"local\", info.ID, 1)\n\t}\n\tif !strings.HasPrefix(root, \"/ipns/\") {\n\t\tlog.Error(\"tried to use non-ipns root\")\n\t\treturn nil\n\t}\n\n\tipnsroot, err := shell.Resolve(info.ID)\n\tif err != nil {\n\t\tlog.Error(\"failed to resolve ipns root: \", err)\n\t\treturn nil\n\t}\n\n\tlog.Error(\"ID: \", info.ID)\n\tlog.Error(\"IPNSROOT: \", ipnsroot)\n\thash, err := shell.ResolvePath(ipnsroot + \"/docker-registry\")\n\tif err != nil {\n\t\tif !strings.Contains(err.Error(), \"no link named\") {\n\t\t\tlog.Error(\"failed to resolve docker-registry dir: \", err)\n\t\t\treturn nil\n\t\t}\n\n\t\th, err := shell.NewObject(\"unixfs-dir\")\n\t\tif err != nil {\n\t\t\tlog.Error(\"failed to get new empty dir: \", err)\n\t\t\treturn nil\n\t\t}\n\n\t\thash = h\n\t}\n\n\td := &driver{\n\t\tshell: shell,\n\t\troot: root,\n\t\troothash: hash,\n\t}\n\td.publish = d.runPublisher(info.ID)\n\n\treturn &Driver{\n\t\tbaseEmbed: baseEmbed{\n\t\t\tBase: base.Base{\n\t\t\t\tStorageDriver: d,\n\t\t\t},\n\t\t},\n\t}\n}", "func newW3CCapabilities(caps Capabilities) Capabilities {\n\tisValidW3CCapability := map[string]bool{}\n\tfor _, name := range w3cCapabilityNames {\n\t\tisValidW3CCapability[name] = true\n\t}\n\tif b, ok := caps[\"browserName\"]; ok && b == \"chrome\" {\n\t\tfor _, name := range chromeCapabilityNames {\n\t\t\tisValidW3CCapability[name] = true\n\t\t}\n\t}\n\n\talwaysMatch := make(Capabilities)\n\tfor name, value := range caps {\n\t\tif isValidW3CCapability[name] || strings.Contains(name, \":\") {\n\t\t\talwaysMatch[name] = value\n\t\t}\n\t}\n\n\t// Move the Firefox profile setting from the old location to the new\n\t// location.\n\tif prof, ok := caps[\"firefox_profile\"]; ok {\n\t\tif c, ok := alwaysMatch[firefox.CapabilitiesKey]; ok {\n\t\t\tfirefoxCaps := c.(firefox.Capabilities)\n\t\t\tif firefoxCaps.Profile == \"\" {\n\t\t\t\tfirefoxCaps.Profile = prof.(string)\n\t\t\t}\n\t\t} else {\n\t\t\talwaysMatch[firefox.CapabilitiesKey] = firefox.Capabilities{\n\t\t\t\tProfile: prof.(string),\n\t\t\t}\n\t\t}\n\t}\n\n\treturn Capabilities{\n\t\t\"alwaysMatch\": alwaysMatch,\n\t}\n}", "func (d DriverFactory) NewDriver() (ftp.Driver, error) {\n\tlogrus.Debugf(\"Trying to create an aws session with: Region: %q, PathStyle: %v, Endpoint: %q\", d.s3Region, d.s3PathStyle, d.s3Endpoint)\n\ts3Session, err := session.NewSession(&aws.Config{\n\t\tRegion: aws.String(d.s3Region),\n\t\tS3ForcePathStyle: aws.Bool(d.s3PathStyle),\n\t\tEndpoint: aws.String(d.s3Endpoint),\n\t\tCredentials: d.awsCredentials,\n\t})\n\tif err != nil {\n\t\treturn nil, goErrors.Wrapf(err, \"Failed to instantiate driver\")\n\t}\n\ts3Client := s3.New(s3Session)\n\n\tvar metricsSender MetricsSender\n\tif d.DisableCloudWatch {\n\t\tmetricsSender = NopSender{}\n\t} else {\n\t\tcloudwatchSession, err := session.NewSession(&aws.Config{\n\t\t\tRegion: aws.String(d.s3Region),\n\t\t\tCredentials: d.awsCredentials,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, goErrors.Wrapf(err, \"Failed to create cloudwatch session\")\n\t\t}\n\n\t\tmetricsSender, err = NewCloudwatchSender(cloudwatchSession)\n\t\tif err != nil {\n\t\t\treturn nil, goErrors.Wrapf(err, \"Failed to instantiate cloudwatch sender\")\n\t\t}\n\t}\n\treturn S3Driver{\n\t\tfeatureFlags: d.featureFlags,\n\t\tnoOverwrite: d.noOverwrite,\n\t\ts3: s3Client,\n\t\tuploader: s3manager.NewUploaderWithClient(s3Client),\n\t\tmetrics: metricsSender,\n\t\tbucketName: d.bucketName,\n\t\tbucketURL: d.bucketURL,\n\t}, nil\n}", "func New(capabilities ...string) *Capability {\n\treturn &Capability{\n\t\tCapabilities: capabilities,\n\t}\n}", "func createChrome(ctx context.Context, chromeOpts ...chrome.Option) (*chrome.Chrome, *chrome.TestConn, error) {\n\t// Create a fresh login.\n\tcr, err := chrome.New(ctx, chromeOpts...)\n\tif err != nil {\n\t\treturn nil, nil, errors.Wrap(err, \"failed to create Chrome\")\n\t}\n\ttconn, err := cr.TestAPIConn(ctx)\n\tif err != nil {\n\t\treturn nil, nil, errors.Wrap(err, \"failed to connect to Test API\")\n\t}\n\n\treturn cr, tconn, nil\n}", "func newVideoTrackFromDriver(d driver.Driver, recorder driver.VideoRecorder, constraints MediaTrackConstraints, selector *CodecSelector) (Track, error) {\n\treader, err := recorder.VideoRecord(constraints.selectedMedia)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn newVideoTrackFromReader(d, reader, selector), nil\n}", "func NewBrowserSiteList()(*BrowserSiteList) {\n m := &BrowserSiteList{\n Entity: *NewEntity(),\n }\n return m\n}", "func NewCapabilities() *Capabilities {\n\treturn &Capabilities{\n\t\tm: make(map[string]*Capability, 0),\n\t}\n}", "func NewVDENetworkDriver(socketRoot string) *VDENetworkDriver {\n\treturn &VDENetworkDriver{\n\t\tsocketRoot: socketRoot,\n\t\tnetworks: make(map[string]*VDENetworkDesc),\n\t\tipam: make(map[string]*IPAMNetworkPool),\n\t}\n}", "func (a *api) newScenario(i interface{}) {\n\ta.c = nil\n\ta.resp = nil\n\ta.err = nil\n\ta.c = client.New(goaclient.HTTPClientDoer(http.DefaultClient))\n\ta.c.Host = \"localhost:8080\"\n}", "func NewCapabilities(features ...string) Capabilities {\n\tc := Capabilities{}\n\tfor _, feature := range features {\n\t\tc.With(feature)\n\t}\n\treturn c\n}", "func NewStackDriver(projectID string) (*StackDriver, error) {\n\tctx := context.Background()\n\tmetricsClient, err := stackmoni.NewMetricClient(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tloggingClient, err := logging.NewClient(ctx, projectID)\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to create client: %v\", err)\n\t}\n\treturn &StackDriver{metricsClient: metricsClient, loggingClient: loggingClient, projectID: projectID, ctx: ctx}, nil\n}", "func RegisterDriver(factory DriverFactory, driver string) {\n\tif _, ok := factories[driver]; ok {\n\t\tlogger.Panicf(\"power driver %q already registered!\", driver)\n\t}\n\tfactories[driver] = factory\n}", "func (m *Manager) AddDriver(machineName string, driverFactory func() Driver) {\n\tm.drivers[machineName] = driverFactory\n}", "func New(\n\tflags ChromiumFlags,\n\tbinary string,\n\tworkdir string,\n\tstdout string,\n\tstderr string,\n) *Chrome {\n\treturn &Chrome{\n\t\tflags: flags,\n\t\tbinary: binary,\n\t\tstderr: stderr,\n\t\tstdout: stdout,\n\t\tworkdir: workdir,\n\t}\n}", "func newCommand(tb DirCleaner, opts ...server.CommandOption) *Command {\n\tpath := tb.TempDir()\n\n\t// Set aggressive close timeout by default to avoid hanging tests. This was\n\t// a problem with PDK tests which used pilosa/client as well. We put it at the\n\t// beginning of the option slice so that it can be overridden by user-passed\n\t// options.\n\topts = append([]server.CommandOption{\n\t\tserver.OptCommandCloseTimeout(time.Millisecond * 2),\n\t}, opts...)\n\n\tm := &Command{commandOptions: opts}\n\toutput := io.Discard\n\tif testing.Verbose() {\n\t\toutput = os.Stderr\n\t}\n\tm.Command = server.NewCommand(output, opts...)\n\t// pick etcd ports using a socket rather than a real port\n\terr := GetPortsGenConfigs(tb, []*Command{m})\n\tif err != nil {\n\t\ttb.Fatalf(\"generating config: %v\", err)\n\t}\n\tm.Config.DataDir = path\n\tdefaultConf := server.NewConfig()\n\n\tif m.Config.Bind == defaultConf.Bind {\n\t\tm.Config.Bind = \"http://localhost:0\"\n\t}\n\n\tif m.Config.BindGRPC == defaultConf.BindGRPC {\n\t\tm.Config.BindGRPC = \"http://localhost:0\"\n\t}\n\n\tm.Config.Translation.MapSize = 140000\n\tm.Config.WorkerPoolSize = 2\n\n\treturn m\n}", "func NewPage(c PageConfig) Page {\n\treturn driver.NewPage(c)\n}", "func newAudioTrackFromDriver(d driver.Driver, recorder driver.AudioRecorder, constraints MediaTrackConstraints, selector *CodecSelector) (Track, error) {\n\treader, err := recorder.AudioRecord(constraints.selectedMedia)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn newAudioTrackFromReader(d, reader, selector), nil\n}", "func NewDBDriver(log *logrus.Logger) Driver {\n\treturn &DBDriver{log: log}\n}", "func handleNewCommand() {\n\tneoCliRoot := os.Getenv(\"GOPATH\") + \"/src/github.com/ivpusic/neo/cmd/neo\"\n\n\tif len(*templateName) == 0 {\n\t\tlogger.Info(\"Creating Neo project\")\n\t\trunCmd(neoCliRoot+\"/scripts/neo-template\", []string{*projectName})\n\n\t} else {\n\t\tswitch *templateName {\n\t\tcase \"angular\":\n\t\t\tlogger.Info(\"Creating Neo Angular project\")\n\t\t\trunCmd(neoCliRoot+\"/scripts/angular-template\", []string{*projectName})\n\t\tcase \"html\":\n\t\t\tlogger.Info(\"Creating Neo HTML project\")\n\t\t\trunCmd(neoCliRoot+\"/scripts/neo-html-template\", []string{*projectName})\n\t\tdefault:\n\t\t\tlogger.Errorf(\"Unkonown template %s!\", *projectName)\n\t\t}\n\t}\n}", "func New(logger log.Logger, db store.DriversStore) http.Handler {\n\tvar (\n\t\tsvc = service.NewDriversService(db)\n\t\toptions = []httptransport.ServerOption{\n\t\t\thttptransport.ServerErrorEncoder(encodeError),\n\t\t}\n\t)\n\n\trouter := mux.NewRouter().PathPrefix(\"/api/\").Subrouter()\n\trouter.Methods(\"POST\").Path(\"/import\").Handler(httptransport.NewServer(\n\t\tlogRecoverMiddleware(logger)(service.MakeDriversImportEndpoint(svc)),\n\t\tservice.DecodeDriversImportRequest,\n\t\tencodeResponse,\n\t\toptions...,\n\t))\n\trouter.Methods(\"GET\").Path(\"/driver/{id}\").Handler(httptransport.NewServer(\n\t\tlogRecoverMiddleware(logger)(service.MakeDriversGetByIDEndpoint(svc)),\n\t\tservice.DecodeDriversGetByIDRequest,\n\t\tencodeResponse,\n\t\toptions...,\n\t))\n\trouter.NotFoundHandler = notFoundHandler{}\n\trouter.MethodNotAllowedHandler = methodNotAllowedHandler{}\n\n\thandler := http.Handler(router)\n\thandler = &requestIDMiddleware{router}\n\n\treturn handler\n}", "func NewDb(db *sql.DB, driverName string) *DB {\n return &DB{DB: db, driverName: driverName, Mapper: mapper()}\n}", "func newScenario(name string) *Instruction {\n\treturn &Instruction{\n\t\tType: ScenarioInst,\n\t\tName: name,\n\t\tVersion: &Version{},\n\t}\n}", "func newControllerCapabilities() []*csi.ControllerServiceCapability {\n\tfromType := func(cap csi.ControllerServiceCapability_RPC_Type) *csi.ControllerServiceCapability {\n\t\treturn &csi.ControllerServiceCapability{\n\t\t\tType: &csi.ControllerServiceCapability_Rpc{\n\t\t\t\tRpc: &csi.ControllerServiceCapability_RPC{\n\t\t\t\t\tType: cap,\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t}\n\n\tvar capabilities []*csi.ControllerServiceCapability\n\tfor _, cap := range []csi.ControllerServiceCapability_RPC_Type{\n\t\tcsi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME,\n\t\tcsi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT,\n\t\tcsi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS,\n\t\tcsi.ControllerServiceCapability_RPC_LIST_VOLUMES,\n\t} {\n\t\tcapabilities = append(capabilities, fromType(cap))\n\t}\n\treturn capabilities\n}", "func NewSimulationAutomationRun()(*SimulationAutomationRun) {\n m := &SimulationAutomationRun{\n Entity: *NewEntity(),\n }\n return m\n}", "func newDatabase(info extraInfo, db *sql.DB) *database {\n\treturn &database{\n\t\tname: info.dbName,\n\t\tdriverName: info.driverName,\n\t\tdb: db,\n\t}\n}", "func NewQemuDriver(ctx *DriverContext) Driver {\n\treturn &QemuDriver{DriverContext: *ctx}\n}", "func (factory *sharedInMemoryDriverFactory) Create(parameters map[string]interface{}) (storagedriver.StorageDriver, error) {\n\tn, ok := parameters[\"name\"]\n\tif !ok {\n\t\treturn nil, errors.New(\"sharedInMemoryDriverFactory: parameter 'name' must be specified\")\n\t}\n\n\tname, ok := n.(string)\n\tif !ok {\n\t\treturn nil, errors.New(\"sharedInMemoryDriverFactory: parameter 'name' must be a string\")\n\t}\n\n\tif _, ok := factory.drivers[name]; !ok {\n\t\tfactory.drivers[name] = inmemory.New()\n\t}\n\n\treturn factory.drivers[name], nil\n}", "func LocateBrowser(preferredBrowser string) BrowserProtocol {\n\tp := BrowserProtocol{}\n\n\tswitch preferredBrowser {\n\tcase \"chrome\":\n\t\tp = LocateChrome()\n\tcase \"edge\":\n\t\tp = LocateEdge()\n\tcase \"brave\":\n\t\tp = LocateBrave()\n\t// case \"firefox\":\n\t// \tp = LocateFirefox()\n\tdefault:\n\t\tswitch runtime.GOOS {\n\t\tcase \"darwin\":\n\t\tcase \"windows\":\n\t\t\tp = LocateEdge()\n\t\tdefault:\n\t\t\t// p = LocateFirefox()\n\t\t\t// ! In Firefox, remote debugging port needs to be enabled explicitly.\n\t\t}\n\t}\n\n\tif p.Path == \"\" {\n\t\tp = LocateChrome()\n\t}\n\n\tif p.Path == \"\" {\n\t\tp = LocateBrave()\n\t}\n\n\tif p.Path == \"\" {\n\t\tp = LocateEdge()\n\t}\n\n\t// if p.Path == \"\" {\n\t// \tp = LocateFirefox()\n\t// }\n\n\treturn p\n}", "func newMongoGroupDriver(name string, opts MongoDBOptions, group string) (*mongoDriver, error) {\n\thost, _ := os.Hostname() // nolint\n\n\tif err := opts.Validate(); err != nil {\n\t\treturn nil, errors.Wrap(err, \"invalid mongo driver options\")\n\t}\n\n\topts.UseGroups = true\n\topts.GroupName = group\n\n\treturn &mongoDriver{\n\t\tname: name,\n\t\topts: opts,\n\t\tinstanceID: fmt.Sprintf(\"%s.%s.%s.%s\", name, group, host, uuid.New()),\n\t}, nil\n}", "func New(executor executor.Executor, name, arguments string) executor.Launcher {\n\treturn stressng{\n\t\texecutor: executor,\n\t\targuments: arguments,\n\t\tname: name,\n\t}\n}", "func newCollection(d driver.Collection) *Collection {\n\treturn &Collection{driver: d}\n}", "func loadDrivers(wd string) error {\n\tskipDirs := []string{\"completer\", \"metadata\"}\n\terr := fs.WalkDir(os.DirFS(wd), \".\", func(n string, d fs.DirEntry, err error) error {\n\t\tswitch {\n\t\tcase err != nil:\n\t\t\treturn err\n\t\tcase d.IsDir():\n\t\t\treturn nil\n\t\t}\n\t\tm := dirRE.FindAllStringSubmatch(n, -1)\n\t\tif m == nil || m[0][1] != m[0][2] || slices.Contains(skipDirs, m[0][1]) {\n\t\t\treturn nil\n\t\t}\n\t\ttag, dest := m[0][1], mostDrivers\n\t\tdriver, err := parseDriverInfo(tag, filepath.Join(wd, n))\n\t\tswitch {\n\t\tcase err != nil:\n\t\t\treturn err\n\t\tcase driver.Group == \"base\":\n\t\t\tdest = baseDrivers\n\t\tcase driver.Group == \"most\":\n\t\tcase driver.Group == \"all\":\n\t\t\tdest = allDrivers\n\t\tcase driver.Group == \"bad\":\n\t\t\tdest = badDrivers\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"driver %s has invalid group %q\", tag, driver.Group)\n\t\t}\n\t\tdest[tag] = driver\n\t\tif dest[tag].Aliases != nil {\n\t\t\tfor _, alias := range dest[tag].Aliases {\n\t\t\t\twireDrivers[alias[0]] = DriverInfo{\n\t\t\t\t\tTag: tag,\n\t\t\t\t\tDriver: alias[0],\n\t\t\t\t\tPkg: dest[tag].Pkg,\n\t\t\t\t\tDesc: alias[1],\n\t\t\t\t\tWire: true,\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func newServer() *negroni.Negroni {\n\tn := negroni.Classic()\n\tn.UseHandler(router())\n\treturn n\n}", "func (c *DriversController) AddDriver() {\n\tvar driver models.Driver\n\tjson.Unmarshal(c.Ctx.Input.RequestBody, &driver)\n\tresult := models.AddDriver(driver)\n\tbuildResponse(result, c.Ctx, driver)\n}", "func NewNodeDriver(ctx *pulumi.Context,\n\tname string, args *NodeDriverArgs, opts ...pulumi.ResourceOption) (*NodeDriver, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.Active == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Active'\")\n\t}\n\tif args.Builtin == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Builtin'\")\n\t}\n\tif args.Url == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Url'\")\n\t}\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource NodeDriver\n\terr := ctx.RegisterResource(\"rancher2:index/nodeDriver:NodeDriver\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (plugin *flexProvisioner) NewDriverCall(execPath, command string) *DriverCall {\n\treturn plugin.NewDriverCallWithTimeout(execPath, command, 0)\n}" ]
[ "0.678176", "0.6750688", "0.6364941", "0.62132597", "0.6142062", "0.61376053", "0.6127721", "0.6018265", "0.60131764", "0.5968937", "0.59261644", "0.592092", "0.5875122", "0.5862739", "0.58357203", "0.5813662", "0.580961", "0.58073485", "0.5793834", "0.57759947", "0.5756461", "0.57492083", "0.5714924", "0.5674313", "0.56598437", "0.56355065", "0.5608847", "0.55671406", "0.5563688", "0.5563599", "0.5527457", "0.5523985", "0.55228174", "0.55218256", "0.5516527", "0.55098456", "0.5501041", "0.54970914", "0.5462325", "0.54037076", "0.5397357", "0.53958464", "0.53742284", "0.5353503", "0.535344", "0.5347493", "0.52348584", "0.52144253", "0.5185292", "0.51770866", "0.5147021", "0.5141222", "0.5099769", "0.5083045", "0.5080358", "0.5068259", "0.50675434", "0.5061458", "0.50095993", "0.4971977", "0.49617794", "0.4925792", "0.49165148", "0.4913952", "0.48609996", "0.48555496", "0.48532495", "0.48244643", "0.4819102", "0.48174244", "0.47953904", "0.47777206", "0.4744596", "0.47431934", "0.47404787", "0.47369114", "0.47095513", "0.46943572", "0.46643394", "0.46451288", "0.46369913", "0.46296248", "0.46273094", "0.46232298", "0.4619219", "0.45874453", "0.456762", "0.45657536", "0.4546927", "0.45332554", "0.4530385", "0.45298138", "0.45223567", "0.45134348", "0.45002198", "0.45000112", "0.44893765", "0.44842598", "0.44812888", "0.44772357" ]
0.73467785
0
Address will create a new Address service that can interact with the Swyftx addresses endpoints The asset code is required for the Deposit, Withdraw and CheckDeposit endpoints
Адресс создаст новый сервис Address, который может взаимодействовать с конечными точками Swyftx по адресам. Код актива необходим для конечных точек Deposit, Withdraw и CheckDeposit
func (c *Client) Address(assetCode ...string) *AddressService { if len(assetCode) == 0 { assetCode[0] = "" } return &AddressService{service{c}, assetCode[0]} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (as *AddressService) Create(name string) (*Address, error) {\n\tif isEmptyStr(as.assetCode) {\n\t\treturn nil, errAssetCode\n\t}\n\n\tvar (\n\t\taddresses []*Address\n\t\tbody struct {\n\t\t\tAddress struct {\n\t\t\t\tName string `json:\"name\"`\n\t\t\t} `json:\"address\"`\n\t\t}\n\t)\n\tbody.Address.Name = name\n\n\tif err := as.client.Post(buildString(\"address/deposit/\", as.assetCode), &body, &addresses); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn addresses[0], nil\n}", "func (as *ApiService) CreateDepositAddress(currency string) (*ApiResponse, error) {\n\treq := NewRequest(http.MethodPost, \"/api/v1/deposit-addresses\", map[string]string{\"currency\": currency})\n\treturn as.Call(req)\n}", "func (as *AddressbookService) CreateAddress(addr models.Address) (models.Address, error) {\n\treturn as.repo.AddAddress(addr)\n}", "func CreateAddress() *addresspb.Address {\n\ta := addresspb.Address{\n\t\tCorrespondanceAddr: &addresspb.Location{\n\t\t\tLocation: \"loc 1\",\n\t\t\tCity: &addresspb.City{\n\t\t\t\tName: \"Mumbai\",\n\t\t\t\tZipCode: \"400005\",\n\t\t\t\tRegion: addresspb.Division_WEST,\n\t\t\t},\n\t\t},\n\n\t\tAdditionalAddr: []*addresspb.Location{\n\t\t\t{\n\t\t\t\tLocation: \"loc 2\",\n\t\t\t\tCity: &addresspb.City{\n\t\t\t\t\tName: \"Srinagar\",\n\t\t\t\t\tZipCode: \"190001\",\n\t\t\t\t\tRegion: addresspb.Division_NORTH,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tLocation: \"loc 3\",\n\t\t\t\tCity: &addresspb.City{\n\t\t\t\t\tName: \"Imphal\",\n\t\t\t\t\tZipCode: \"795001\",\n\t\t\t\t\tRegion: addresspb.Division_EAST,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tLocation: \"loc 4\",\n\t\t\t\tCity: &addresspb.City{\n\t\t\t\t\tName: \"Mysore\",\n\t\t\t\t\tZipCode: \"570001\",\n\t\t\t\t\tRegion: addresspb.Division_SOUTH,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\treturn &a\n}", "func CreateAddress(address models.RequestAddress) (bool, models.ResponseAddress, error) {\n\n\t//Create request\n\trequest := models.Request{}\n\trequest.AddBody(address)\n\trequest.SetUri(\"https://api.easypost.com/v2/addresses\")\n\trequest.SetMethod(\"POST\")\n\n\t//Send request\n\tresponseBody, err := SendRequest(request)\n\n\t//Initialize response address\n\tresponseAddress := models.ResponseAddress{}\n\n\terr = json.Unmarshal(responseBody, &responseAddress)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false, responseAddress, fmt.Errorf(\"Unrecognized response from easypost %s\", err.Error())\n\t}\n\n\treturn responseAddress.Verifications.Delivery.Success, responseAddress, err\n}", "func (handler *Handler) CreateAddress(ctx context.Context, in *candyland_grpc.CreateAddressRequest) (*candyland_grpc.CreateAddressReply, error) {\n\terr := handler.CreateAddressUsecase.Create(in.UserId, in.CountryId, in.StateId, in.CityId, in.StreetId, in.Number, in.Complement.String())\n\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\treturn nil, err\n\t}\n\n\tres := &candyland_grpc.CreateAddressReply{\n\t\tWasCreated: true,\n\t}\n\n\treturn res, nil\n}", "func (id *Public) CreateAddress(version, stream uint64) {\n\tid.Address.Version = version\n\tid.Address.Stream = stream\n\tcopy(id.Address.Ripe[:], id.hash())\n}", "func CreateAddress(amount int) (string, []Wallet) {\n\n\twallets := []Wallet{}\n\tfor i := 0; i < amount; i++ {\n\t\twif, _ := network.CreatePrivateKey()\n\t\taddress, _ := network.GetAddress(wif)\n\t\tvar wallet = Wallet{ADDRESS: address.EncodeAddress(), PRIVKEY: wif.String()}\n\t\twallets = append(wallets, wallet)\n\t}\n\n\tjson := ConvertToJSON(&wallets)\n\n\tlog.Println(\"Generated\", amount, \"addresses\")\n\n\treturn json, wallets\n\n}", "func (lu *litUiClient) Address() (string, error) {\n\n\t// cointype of 0 means default, not mainnet.\n\t// this is ugly but does prevent mainnet use for now.\n\n\tvar cointype, numadrs uint32\n\n\t// if no arguments given, generate 1 new address.\n\t// if no cointype given, assume type 1 (testnet)\n\n\tnumadrs = 0\n\n\treply := new(litrpc.AddressReply)\n\n\targs := new(litrpc.AddressArgs)\n\targs.CoinType = cointype\n\targs.NumToMake = numadrs\n\n\tfmt.Printf(\"adr cointye: %d num:%d\\n\", args.CoinType, args.NumToMake)\n\terr := lu.rpccon.Call(\"LitRPC.Address\", args, reply)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tresponse := reply.WitAddresses[len(reply.WitAddresses)-1]\n\treturn response, nil\n}", "func CreateAddress(b types.Address, nonce *big.Int) types.Address {\n\tdata, _ := rlp.EncodeToBytes([]interface{}{b, nonce})\n\treturn types.BytesToAddress(keccak.Keccak256(data)[12:])\n}", "func (e Endpoints) PostAddress(ctx context.Context, profileID string, a Address) error {\n\n\t// TODO: Create detailed ref spec\n\trequest := postAddressRequest{ProfileID: profileID, Address: a}\n\n\tresponse, err := e.PostAddressEndpoint(ctx, request)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresp := response.(postAddressResponse)\n\n\treturn resp.Err\n}", "func (dcr *ExchangeWallet) NewAddress() (string, error) {\n\treturn dcr.DepositAddress()\n}", "func Address(props *AddressProps, children ...Element) *AddressElem {\n\trProps := &_AddressProps{\n\t\tBasicHTMLElement: newBasicHTMLElement(),\n\t}\n\n\tif props != nil {\n\t\tprops.assign(rProps)\n\t}\n\n\treturn &AddressElem{\n\t\tElement: createElement(\"address\", rProps, children...),\n\t}\n}", "func CreateAddress(b common.Address, nonce uint64) common.Address {\n\tdata, _ := rlp.EncodeToBytes([]interface{}{b, nonce})\n\taddr := common.BytesToAddress(Keccak512(data)[:])\n\treturn common.DarmaAddressToContractAddress(addr)\n}", "func (lu *litUiClient) NewAddress() (string, error) {\n\n\t// cointype of 0 means default, not mainnet.\n\t// this is ugly but does prevent mainnet use for now.\n\n\tvar cointype, numadrs uint32\n\n\t// if no arguments given, generate 1 new address.\n\t// if no cointype given, assume type 1 (testnet)\n\n\tnumadrs = 1\n\n\treply := new(litrpc.AddressReply)\n\n\targs := new(litrpc.AddressArgs)\n\targs.CoinType = cointype\n\targs.NumToMake = numadrs\n\n\tfmt.Printf(\"adr cointye: %d num:%d\\n\", args.CoinType, args.NumToMake)\n\terr := lu.rpccon.Call(\"LitRPC.Address\", args, reply)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tresponse := reply.WitAddresses[0]\n\t//\tfmt.Fprintf(color.Output, \"new adr(s): %s\\nold: %s\\n\",\n\t//\t\tlnutil.Address(reply.WitAddresses), lnutil.Address(reply.LegacyAddresses))\n\treturn response, nil // reply.WitAddresses[]\n\n}", "func (s *SOC) Address() (swarm.Address, error) {\n\tif len(s.owner) != crypto.AddressSize {\n\t\treturn swarm.ZeroAddress, errInvalidAddress\n\t}\n\treturn CreateAddress(s.id, s.owner)\n}", "func (c *Client) Addresses(ctx context.Context, foreignID, currency string) (Address, error) {\n\treqBody := map[string]string{\n\t\t\"foreign_id\": foreignID,\n\t\t\"currency\": currency,\n\t}\n\n\treqJSON, err := json.Marshal(reqBody)\n\tif err != nil {\n\t\treturn Address{}, fmt.Errorf(\"request body marshaling error: %w\", err)\n\t}\n\n\taddressesURL, err := joinURL(c.api, addressesEndpoint)\n\tif err != nil {\n\t\treturn Address{}, fmt.Errorf(\"request url creating error: %w\", err)\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, addressesURL.String(), bytes.NewBuffer(reqJSON))\n\tif err != nil {\n\t\treturn Address{}, fmt.Errorf(\"request creating error: %w\", err)\n\t}\n\n\tsig, err := createHmac(c.secret, reqJSON)\n\tif err != nil {\n\t\treturn Address{}, fmt.Errorf(\"hmac signature creationg error: %w\", err)\n\t}\n\n\treq.Header.Set(contentTypeHeader, jsonContentType)\n\treq.Header.Set(keyHeader, c.apiKey)\n\treq.Header.Set(signatureHeader, sig)\n\n\tresp, err := c.client.Do(req)\n\tif err != nil {\n\t\treturn Address{}, fmt.Errorf(\"request error: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\terr = ensureSuccessResponse(resp)\n\tif err != nil {\n\t\treturn Address{}, fmt.Errorf(\"request failed: %w\", err)\n\t}\n\n\trespBody := struct {\n\t\tData Address `json:\"data\"`\n\t}{}\n\n\terr = json.NewDecoder(resp.Body).Decode(&respBody)\n\tif err != nil {\n\t\treturn Address{}, fmt.Errorf(\"response unmarshaling error: %w\", err)\n\t}\n\n\treturn respBody.Data, nil\n}", "func createAddress(creator *Account) Word256 {\n\tnonce := creator.Nonce\n\tcreator.Nonce += 1\n\ttemp := make([]byte, 32+8)\n\tcopy(temp, creator.Address[:])\n\tPutUint64BE(temp[32:], nonce)\n\treturn LeftPadWord256(sha3.Sha3(temp)[:20])\n}", "func CreateAddress(id ID, owner []byte) (swarm.Address, error) {\n\tsum, err := hash(id, owner)\n\tif err != nil {\n\t\treturn swarm.ZeroAddress, err\n\t}\n\treturn swarm.NewAddress(sum), nil\n}", "func NewAddress() platformservices.Address {\n\n\tvar lat = 37.7917146\n\tvar lng = -122.397054\n\n\treturn platformservices.Address{\n\t\tAddressType: platformservices.AddressTypeLegal,\n\t\tStreetAddress: \"100 Main Street\",\n\t\tCity: \"San Francisco\",\n\t\tState: \"CA\",\n\t\tCountry: \"US\",\n\t\tPostalCode: \"94100\",\n\t\tLatitude: &lat,\n\t\tLongitude: &lng,\n\t}\n}", "func (c *CompaniesGetCall) Address(address string) *CompaniesGetCall {\n\tc.urlParams_.Set(\"address\", address)\n\treturn c\n}", "func NewAccountAddress(\n\taccountConfiguration *signing.Configuration,\n\tkeyPath signing.RelativeKeypath,\n\tnet *chaincfg.Params,\n\tlog *logrus.Entry,\n) *AccountAddress {\n\n\tvar address btcutil.Address\n\tvar redeemScript []byte\n\tconfiguration, err := accountConfiguration.Derive(keyPath)\n\tif err != nil {\n\t\tlog.WithError(err).Panic(\"Failed to derive the configuration.\")\n\t}\n\tlog = log.WithFields(logrus.Fields{\n\t\t\"key-path\": configuration.AbsoluteKeypath().Encode(),\n\t\t\"configuration\": configuration.String(),\n\t})\n\tlog.Debug(\"Creating new account address\")\n\n\tpublicKeyHash := btcutil.Hash160(configuration.PublicKey().SerializeCompressed())\n\tswitch configuration.ScriptType() {\n\tcase signing.ScriptTypeP2PKH:\n\t\taddress, err = btcutil.NewAddressPubKeyHash(publicKeyHash, net)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Panic(\"Failed to get P2PKH addr. from public key hash.\")\n\t\t}\n\tcase signing.ScriptTypeP2WPKHP2SH:\n\t\tvar segwitAddress *btcutil.AddressWitnessPubKeyHash\n\t\tsegwitAddress, err = btcutil.NewAddressWitnessPubKeyHash(publicKeyHash, net)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Panic(\"Failed to get p2wpkh-p2sh addr. from publ. key hash.\")\n\t\t}\n\t\tredeemScript, err = txscript.PayToAddrScript(segwitAddress)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Panic(\"Failed to get redeem script for segwit address.\")\n\t\t}\n\t\taddress, err = btcutil.NewAddressScriptHash(redeemScript, net)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Panic(\"Failed to get a P2SH address for segwit.\")\n\t\t}\n\tcase signing.ScriptTypeP2WPKH:\n\t\taddress, err = btcutil.NewAddressWitnessPubKeyHash(publicKeyHash, net)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Panic(\"Failed to get p2wpkh addr. from publ. key hash.\")\n\t\t}\n\tcase signing.ScriptTypeP2TR:\n\t\toutputKey := txscript.ComputeTaprootKeyNoScript(configuration.PublicKey())\n\t\taddress, err = btcutil.NewAddressTaproot(schnorr.SerializePubKey(outputKey), net)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Panic(\"Failed to get p2tr addr\")\n\t\t}\n\tdefault:\n\t\tlog.Panic(fmt.Sprintf(\"Unrecognized script type: %s\", configuration.ScriptType()))\n\t}\n\n\treturn &AccountAddress{\n\t\tAddress: address,\n\t\tAccountConfiguration: accountConfiguration,\n\t\tConfiguration: configuration,\n\t\tredeemScript: redeemScript,\n\t\tlog: log,\n\t}\n}", "func (gen *AddressGenerator) Address() Address {\n\treturn generateAddress(gen.chainID, gen.state)\n}", "func (_Token *TokenCaller) FactoryAddress(opts *bind.CallOpts) (common.Address, error) {\n\tvar out []interface{}\n\terr := _Token.contract.Call(opts, &out, \"factoryAddress\")\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "func (mc *MoacChain) createChainAddress(tradePassword string) (addr string, err error) {\n\n\tdefer func() {\n\t\tif re := recover(); re != nil {\n\t\t\terr = re.(error)\n\t\t}\n\t}()\n\n\terr = rpcClient.Call(&addr, \"personal_newAccount\", tradePassword)\n\n\treturn addr, err\n}", "func CreateAddress(a *AddressDAL) (*AddressDAL, error) {\n\tresult := db.DB().Create(a)\n\tif result.Error != nil {\n\t\treturn nil, result.Error\n\t}\n\treturn a, nil\n}", "func (app *App) Address(addr string) *App {\n\tapp.Addr = addr\n\treturn app\n}", "func (a *Api) Address(address string) (*AddressResult, error) {\n\treturn a.AddressAtHeight(address, LatestBlockHeight)\n}", "func ExampleServiceClient_ValidateAddress() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armdatabox.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := clientFactory.NewServiceClient().ValidateAddress(ctx, \"westus\", armdatabox.ValidateAddress{\n\t\tValidationType: to.Ptr(armdatabox.ValidationInputDiscriminatorValidateAddress),\n\t\tDeviceType: to.Ptr(armdatabox.SKUNameDataBox),\n\t\tShippingAddress: &armdatabox.ShippingAddress{\n\t\t\tAddressType: to.Ptr(armdatabox.AddressTypeCommercial),\n\t\t\tCity: to.Ptr(\"XXXX XXXX\"),\n\t\t\tCompanyName: to.Ptr(\"XXXX XXXX\"),\n\t\t\tCountry: to.Ptr(\"XX\"),\n\t\t\tPostalCode: to.Ptr(\"00000\"),\n\t\t\tStateOrProvince: to.Ptr(\"XX\"),\n\t\t\tStreetAddress1: to.Ptr(\"XXXX XXXX\"),\n\t\t\tStreetAddress2: to.Ptr(\"XXXX XXXX\"),\n\t\t},\n\t}, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.AddressValidationOutput = armdatabox.AddressValidationOutput{\n\t// \tProperties: &armdatabox.AddressValidationProperties{\n\t// \t\tValidationType: to.Ptr(armdatabox.ValidationInputDiscriminatorValidateAddress),\n\t// \t\tAlternateAddresses: []*armdatabox.ShippingAddress{\n\t// \t\t\t{\n\t// \t\t\t\tAddressType: to.Ptr(armdatabox.AddressTypeNone),\n\t// \t\t\t\tCity: to.Ptr(\"XXXX XXXX\"),\n\t// \t\t\t\tCountry: to.Ptr(\"XX\"),\n\t// \t\t\t\tPostalCode: to.Ptr(\"00000\"),\n\t// \t\t\t\tStateOrProvince: to.Ptr(\"XX\"),\n\t// \t\t\t\tStreetAddress1: to.Ptr(\"XXXX XXXX\"),\n\t// \t\t\t\tStreetAddress2: to.Ptr(\"XXXX XXXX\"),\n\t// \t\t\t\tStreetAddress3: to.Ptr(\"\"),\n\t// \t\t}},\n\t// \t\tValidationStatus: to.Ptr(armdatabox.AddressValidationStatusValid),\n\t// \t},\n\t// }\n}", "func (ms MockSOC) Address() boson.Address {\n\taddr, _ := soc.CreateAddress(ms.ID, ms.Owner)\n\treturn addr\n}", "func (f *Factory) Address() string { return f.address }", "func Address(val string) Argument {\n\treturn func(request *requests.Request) error {\n\t\trequest.AddArgument(\"address\", val)\n\t\treturn nil\n\t}\n}", "func Address(ctx context.Context, name string) (*apis.URL, error) {\n\treturn k8s.Address(ctx, svc.GVR(), name)\n}", "func (a *Transactions) Address(ctx context.Context, address proto.WavesAddress, limit uint) ([]proto.Transaction, *Response, error) {\n\turl, err := joinUrl(a.options.BaseUrl, fmt.Sprintf(\"/transactions/address/%s/limit/%d\", address.String(), limit))\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treq, err := http.NewRequest(\"GET\", url.String(), nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tvar out []TransactionsField\n\tresponse, err := doHttp(ctx, a.options, req, &out)\n\tif err != nil {\n\t\treturn nil, response, err\n\t}\n\tif len(out) == 0 {\n\t\treturn nil, response, nil\n\t}\n\treturn out[0], response, nil\n}", "func (e Exchange) DepositAddress(exch string, currencyCode currency.Code) (out string, err error) {\n\tif currencyCode.IsEmpty() {\n\t\terr = errors.New(\"currency code is empty\")\n\t\treturn\n\t}\n\treturn engine.Bot.DepositAddressManager.GetDepositAddressByExchange(exch, currencyCode)\n}", "func (c *CompaniesListCall) Address(address string) *CompaniesListCall {\n\tc.urlParams_.Set(\"address\", address)\n\treturn c\n}", "func (id *publicAddress) Address() Address {\n\tvar a Address\n\ta, _ = id.address()\n\treturn a\n}", "func NewAddress(address common.Address, backend bind.ContractBackend) (*Address, error) {\n\tcontract, err := bindAddress(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Address{AddressCaller: AddressCaller{contract: contract}, AddressTransactor: AddressTransactor{contract: contract}, AddressFilterer: AddressFilterer{contract: contract}}, nil\n}", "func NewAddress(address common.Address, backend bind.ContractBackend) (*Address, error) {\n\tcontract, err := bindAddress(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Address{AddressCaller: AddressCaller{contract: contract}, AddressTransactor: AddressTransactor{contract: contract}, AddressFilterer: AddressFilterer{contract: contract}}, nil\n}", "func NewAddress(address common.Address, backend bind.ContractBackend) (*Address, error) {\n\tcontract, err := bindAddress(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Address{AddressCaller: AddressCaller{contract: contract}, AddressTransactor: AddressTransactor{contract: contract}, AddressFilterer: AddressFilterer{contract: contract}}, nil\n}", "func NewAddress(address common.Address, backend bind.ContractBackend) (*Address, error) {\n\tcontract, err := bindAddress(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Address{AddressCaller: AddressCaller{contract: contract}, AddressTransactor: AddressTransactor{contract: contract}, AddressFilterer: AddressFilterer{contract: contract}}, nil\n}", "func NewAddress(address common.Address, backend bind.ContractBackend) (*Address, error) {\n\tcontract, err := bindAddress(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Address{AddressCaller: AddressCaller{contract: contract}, AddressTransactor: AddressTransactor{contract: contract}, AddressFilterer: AddressFilterer{contract: contract}}, nil\n}", "func makeAddress(keyPair *keypair.KeyPair, testnet bool) *account.Account {\n\n\treturn &account.Account{\n\t\tAccountInterface: &account.ED25519Account{\n\t\t\tTest: testnet,\n\t\t\tPublicKey: keyPair.PublicKey[:],\n\t\t},\n\t}\n}", "func CreateAddress(address string) string {\n\tnumeric := []string{\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"}\n\talpha := []string{\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\"}\n\n\tindexZero := RandomIndex(0, 10)\n\tindexOne := RandomIndex(0, 10)\n\tindexTwo := RandomIndex(0, 10)\n\n\treturn fmt.Sprintf(\"%s %s%s%s\", address, alpha[indexZero], numeric[indexOne], alpha[indexTwo])\n}", "func ExampleSnowball_CreateAddress_shared00() {\n\tsvc := snowball.New(session.New())\n\tinput := &snowball.CreateAddressInput{\n\t\tAddress: &snowball.Address{\n\t\t\tCity: aws.String(\"Seattle\"),\n\t\t\tCompany: aws.String(\"My Company's Name\"),\n\t\t\tCountry: aws.String(\"USA\"),\n\t\t\tName: aws.String(\"My Name\"),\n\t\t\tPhoneNumber: aws.String(\"425-555-5555\"),\n\t\t\tPostalCode: aws.String(\"98101\"),\n\t\t\tStateOrProvince: aws.String(\"WA\"),\n\t\t\tStreet1: aws.String(\"123 Main Street\"),\n\t\t},\n\t}\n\n\tresult, err := svc.CreateAddress(input)\n\tif err != nil {\n\t\tif aerr, ok := err.(awserr.Error); ok {\n\t\t\tswitch aerr.Code() {\n\t\t\tcase snowball.ErrCodeInvalidAddressException:\n\t\t\t\tfmt.Println(snowball.ErrCodeInvalidAddressException, aerr.Error())\n\t\t\tcase snowball.ErrCodeUnsupportedAddressException:\n\t\t\t\tfmt.Println(snowball.ErrCodeUnsupportedAddressException, aerr.Error())\n\t\t\tdefault:\n\t\t\t\tfmt.Println(aerr.Error())\n\t\t\t}\n\t\t} else {\n\t\t\t// Print the error, cast err to awserr.Error to get the Code and\n\t\t\t// Message from an error.\n\t\t\tfmt.Println(err.Error())\n\t\t}\n\t\treturn\n\t}\n\n\tfmt.Println(result)\n}", "func (ar AccountRef) Address() sdk.AccAddress {\n\treturn (sdk.AccAddress)(ar)\n}", "func (n *Node) CreateAddress() *Node {\n\tkeystore := n.client.KeystoreAPI()\n\tif _, err := keystore.CreateUser(n.UserPass); err != nil {\n\t\tpanic(stacktrace.Propagate(err, \"Could not create user for node.\"))\n\t}\n\n\txAddress, err := n.client.XChainAPI().CreateAddress(n.UserPass)\n\tif err != nil {\n\t\tpanic(stacktrace.Propagate(err, \"Could not create user address in the XChainAPI.\"))\n\t}\n\tn.XAddress = xAddress\n\n\tpAddress, err := n.client.PChainAPI().CreateAddress(n.UserPass)\n\tif err != nil {\n\t\tpanic(stacktrace.Propagate(err, \"Could not create user address in the PChainAPI.\"))\n\t}\n\tn.PAddress = pAddress\n\treturn n\n}", "func (addressManager *AddressManager) Address(addressIndex uint64) address.Address {\n\t// update lastUnspentAddressIndex if necessary\n\taddressManager.spentAddressIndexes(addressIndex)\n\n\treturn addressManager.seed.Address(addressIndex)\n}", "func CreateAddressPool(ctx iris.Context) {\n\turi := ctx.Request().RequestURI\n\tfabricID := ctx.Params().Get(\"id\")\n\tif _, err := capmodel.GetFabric(fabricID); err != nil {\n\t\terrMsg := fmt.Sprintf(\"failed to fetch fabric data for uri %s: %s\", uri, err.Error())\n\t\tcreateDbErrResp(ctx, err, errMsg, []interface{}{\"Fabric\", fabricID})\n\t\treturn\n\t}\n\tvar addresspoolData model.AddressPool\n\terr := ctx.ReadJSON(&addresspoolData)\n\tif err != nil {\n\t\terrorMessage := \"error while trying to get JSON body from the request: \" + err.Error()\n\t\tlog.Error(errorMessage)\n\t\tresp := updateErrorResponse(response.MalformedJSON, errorMessage, nil)\n\t\tctx.StatusCode(http.StatusBadRequest)\n\t\tctx.JSON(resp)\n\t\treturn\n\t}\n\t// Todo :Add required validation for the request params\n\tmissingAttribute, err := validateAddressPoolRequest(addresspoolData)\n\tif err != nil {\n\t\tlog.Error(err.Error())\n\t\tresp := updateErrorResponse(response.PropertyMissing, err.Error(), []interface{}{missingAttribute})\n\t\tctx.StatusCode(http.StatusBadRequest)\n\t\tctx.JSON(resp)\n\t\treturn\n\t}\n\tif addresspoolData.Ethernet.IPv4.GatewayIPAddress != \"\" {\n\t\tif _, _, err := net.ParseCIDR(addresspoolData.Ethernet.IPv4.GatewayIPAddress); err != nil {\n\t\t\terrorMessage := \"Invalid value for GatewayIPAddress:\" + err.Error()\n\t\t\tlog.Errorf(errorMessage)\n\t\t\tresp := updateErrorResponse(response.PropertyValueFormatError, errorMessage, []interface{}{addresspoolData.Ethernet.IPv4.GatewayIPAddress, \"GatewayIPAddress\"})\n\t\t\tctx.StatusCode(http.StatusBadRequest)\n\t\t\tctx.JSON(resp)\n\t\t\treturn\n\n\t\t}\n\t\tif addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Lower != addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Upper {\n\t\t\terrorMessage := fmt.Sprintf(\"Requested VLANIdentifierAddressRange Lower %d is not equal to Upper %d\", addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Lower, addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Upper)\n\t\t\tlog.Error(errorMessage)\n\t\t\tresp := updateErrorResponse(response.PropertyUnknown, errorMessage, []interface{}{\"VLANIdentifierAddressRange\"})\n\t\t\tctx.StatusCode(http.StatusBadRequest)\n\t\t\tctx.JSON(resp)\n\t\t\treturn\n\t\t}\n\t\taddressPools, err := capmodel.GetAllAddressPools(fabricID)\n\t\tif err != nil {\n\t\t\terrMsg := fmt.Sprintf(\"failed to fetch AddressPool data for uri %s: %s\", uri, err.Error())\n\t\t\tcreateDbErrResp(ctx, err, errMsg, []interface{}{\"Fabric\", fabricID})\n\t\t\treturn\n\t\t}\n\t\tfor _, data := range addressPools {\n\t\t\tif data.Ethernet.IPv4.GatewayIPAddress == addresspoolData.Ethernet.IPv4.GatewayIPAddress {\n\t\t\t\terrorMessage := \"Requested GatewayIPAddress is already present in the addresspool \" + data.ODataID\n\t\t\t\tlog.Error(errorMessage)\n\t\t\t\tresp := updateErrorResponse(response.ResourceAlreadyExists, errorMessage, []interface{}{\"AddressPool\", \"GatewayIPAddress\", addresspoolData.Ethernet.IPv4.GatewayIPAddress})\n\t\t\t\tctx.StatusCode(http.StatusConflict)\n\t\t\t\tctx.JSON(resp)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tif addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Lower > addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Upper {\n\t\terrorMessage := fmt.Sprintf(\"Requested VLANIdentifierAddressRange Lower %d is greater than Upper %d\", addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Lower, addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Upper)\n\t\tlog.Error(errorMessage)\n\t\tresp := updateErrorResponse(response.PropertyUnknown, errorMessage, []interface{}{\"VLANIdentifierAddressRange\"})\n\t\tctx.StatusCode(http.StatusBadRequest)\n\t\tctx.JSON(resp)\n\t\treturn\n\t}\n\t// validate the VLANIdentifierAddressRange lower value\n\tresp, statusCode := validateVLANIdentifierAddressRange(addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Lower, addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Upper)\n\tif statusCode != http.StatusOK {\n\t\tctx.StatusCode(statusCode)\n\t\tctx.JSON(resp)\n\t\treturn\n\t}\n\n\taddressPoolID := uuid.NewV4().String()\n\taddresspoolData.ODataContext = \"/ODIM/v1/$metadata#AddressPool.AddressPool\"\n\taddresspoolData.ODataType = \"#AddressPool.v1_1_0.AddressPool\"\n\taddresspoolData.ODataID = fmt.Sprintf(\"%s/%s\", uri, addressPoolID)\n\taddresspoolData.ID = addressPoolID\n\n\tif err = capmodel.SaveAddressPool(fabricID, addresspoolData.ODataID, &addresspoolData); err != nil {\n\t\terrMsg := fmt.Sprintf(\"failed to save AddressPool data for uri %s: %s\", uri, err.Error())\n\t\tcreateDbErrResp(ctx, err, errMsg, []interface{}{\"Fabric\", fabricID})\n\t\treturn\n\t}\n\n\tcommon.SetResponseHeader(ctx, map[string]string{\n\t\t\"Location\": addresspoolData.ODataID,\n\t})\n\n\tctx.StatusCode(http.StatusCreated)\n\tctx.JSON(addresspoolData)\n}", "func (s *SkyСoinService) GenerateAddr(pubStr string) (maddr *AddressResponse, err error) {\n\tmaddr = &AddressResponse{}\n\n\tpubKey, err := cipher.PubKeyFromHex(pubStr)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\taddress := cipher.AddressFromPubKey(pubKey)\n\n\tmaddr.Address = address.String()\n\treturn maddr, nil\n}", "func (mr *Repo) AddAddress(addr models.Address) (models.Address, error) {\n\tcollection := mr.client.Database(mr.dbInfo.DBName).Collection(mr.dbInfo.CollectionName)\n\tdbAddr := &dbAddress{}\n\tdbAddr.fromServiceAddress(addr)\n\tr, err := collection.InsertOne(mr.ctx, dbAddr)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn addr, err\n\t}\n\n\tid := r.InsertedID.(primitive.ObjectID).Hex()\n\taddr.ID = id\n\treturn addr, nil\n}", "func Address(attrs []htmlgo.Attribute, children ...HTML) HTML {\n\treturn &htmlgo.Tree{Tag: \"address\", Attributes: attrs, Children: children}\n}", "func NewFromCashAddress(addr *cashaddress.Address) (*Address, error) {\n\tvar network = MainNet\n\tvar addrtype = P2SH\n\n\tswitch addr.Prefix {\n\tcase cashaddress.MainNet:\n\t\tnetwork = MainNet\n\tcase cashaddress.TestNet:\n\t\tnetwork = TestNet\n\tcase cashaddress.RegTest:\n\t\tnetwork = RegTest\n\tdefault:\n\t\treturn nil, errors.New(\"invalid address network\")\n\t}\n\n\tswitch addr.Version {\n\tcase cashaddress.P2KH:\n\t\taddrtype = P2KH\n\tcase cashaddress.P2SH:\n\t\taddrtype = P2SH\n\tdefault:\n\t\treturn nil, errors.New(\"invalid address type\")\n\t}\n\n\treturn &Address{\n\t\tNetwork: network,\n\t\tVersion: addrtype,\n\t\tPayload: addr.Payload,\n\t}, nil\n}", "func ImportAddress(c echo.Context) error {\n\tc.Logger().Print(\"executing ImportAddress handler\")\n\n\tvar req importAddressReq\n\tif err := json.NewDecoder(c.Request().Body).Decode(&req); err != nil {\n\t\treturn c.JSON(http.StatusBadRequest, genericResponse{\n\t\t\tError: \"missing addr field in request\",\n\t\t\tCode: ErrorInvalidRequest,\n\t\t})\n\t}\n\n\tclient, ok := c.Get(\"coin_client\").(transport.AddressImporter)\n\tif !ok {\n\t\treturn c.JSON(http.StatusBadRequest, genericResponse{\n\t\t\tError: fmt.Sprintf(\"client: %s does not have import address functionality\", c.Param(\"asset_id\")),\n\t\t\tCode: ErrorCodeCannotImport,\n\t\t})\n\t}\n\n\terr := client.ImportAddress(req.Addr)\n\tif err != nil {\n\t\tc.Logger().Errorf(\"error getting importing address: %s for coin: %s, err: %v\", req.Addr, c.Param(\"assetId\"), err)\n\t\treturn c.JSON(http.StatusBadRequest, genericResponse{\n\t\t\tError: \"could not import address\",\n\t\t\tCode: ErrorCodeCannotImport,\n\t\t})\n\t}\n\n\treturn c.JSON(http.StatusOK, successResponse)\n}", "func AddressGenerator(t *rapid.T) *rapid.Generator[sdk.AccAddress] {\n\treturn rapid.Custom(func(t *rapid.T) sdk.AccAddress {\n\t\tpkBz := rapid.SliceOfN(rapid.Byte(), 20, 20).Draw(t, \"hex\")\n\t\treturn sdk.AccAddress(pkBz)\n\t})\n}", "func (a *Account) NewAddress() (btcutil.Address, error) {\n\t// Get current block's height and hash.\n\trpcc, err := accessClient()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbs, err := rpcc.BlockStamp()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Get next address from wallet.\n\taddr, err := a.KeyStore.NextChainedAddress(&bs, cfg.KeypoolSize)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Immediately write updated wallet to disk.\n\tAcctMgr.ds.ScheduleWalletWrite(a)\n\tif err := AcctMgr.ds.FlushAccount(a); err != nil {\n\t\treturn nil, fmt.Errorf(\"account write failed: %v\", err)\n\t}\n\n\t// Mark this new address as belonging to this account.\n\tAcctMgr.MarkAddressForAccount(addr, a)\n\n\t// Request updates from btcd for new transactions sent to this address.\n\tif err := rpcc.NotifyReceived([]btcutil.Address{addr}); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn addr, nil\n}", "func (address *Address) CreateAddress(db *gorm.DB) (*Address, error) {\n\n\terr := db.Debug().Create(&address).Error\n\tif err != nil {\n\t\treturn &Address{}, err\n\t}\n\n\treturn address, nil\n}", "func (mt *EasypostAddress) Validate() (err error) {\n\tif mt.ID == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"id\"))\n\t}\n\tif mt.Object == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"object\"))\n\t}\n\n\tif ok := goa.ValidatePattern(`^adr_`, mt.ID); !ok {\n\t\terr = goa.MergeErrors(err, goa.InvalidPatternError(`response.id`, mt.ID, `^adr_`))\n\t}\n\tif !(mt.Mode == \"test\" || mt.Mode == \"production\") {\n\t\terr = goa.MergeErrors(err, goa.InvalidEnumValueError(`response.mode`, mt.Mode, []interface{}{\"test\", \"production\"}))\n\t}\n\tif ok := goa.ValidatePattern(`^Address$`, mt.Object); !ok {\n\t\terr = goa.MergeErrors(err, goa.InvalidPatternError(`response.object`, mt.Object, `^Address$`))\n\t}\n\treturn\n}", "func NewAddress(i, ii int) *Address {\n\tn := strconv.Itoa(i)\n\treturn &Address{\n\t\tId: time.Now().UnixNano(),\n\t\tStreet: \"10\" + n + \" Somewhere Lane\",\n\t\tCity: \"Awesome City \" + n,\n\t\tState: func() string {\n\t\t\tif i%2 == 0 {\n\t\t\t\treturn \"PA\"\n\t\t\t}\n\t\t\treturn \"CA\"\n\t\t}(),\n\t\tZip: ii,\n\t}\n}", "func (cc *CustomerCreate) AddAddress(c ...*CustomerAddress) *CustomerCreate {\n\tids := make([]int, len(c))\n\tfor i := range c {\n\t\tids[i] = c[i].ID\n\t}\n\treturn cc.AddAddresIDs(ids...)\n}", "func (b *Backend) NewAddress() wallet.Address {\n\taddr := Address{}\n\treturn &addr\n}", "func addAddresses(authRequest *sleet.AuthorizationRequest, request *checkout.PaymentRequest) {\n\tif authRequest.BillingAddress != nil && authRequest.Options[sleet.GooglePayTokenOption] == nil {\n\t\tbillingStreetNumber, billingStreetName := extractAdyenStreetFormat(common.SafeStr(authRequest.BillingAddress.StreetAddress1))\n\t\trequest.BillingAddress = &checkout.Address{\n\t\t\tCity: common.SafeStr(authRequest.BillingAddress.Locality),\n\t\t\tCountry: common.SafeStr(authRequest.BillingAddress.CountryCode),\n\t\t\tHouseNumberOrName: billingStreetNumber,\n\t\t\tPostalCode: common.SafeStr(authRequest.BillingAddress.PostalCode),\n\t\t\tStateOrProvince: common.SafeStr(authRequest.BillingAddress.RegionCode),\n\t\t\tStreet: billingStreetName,\n\t\t}\n\t}\n\tif authRequest.ShippingAddress != nil {\n\t\tshippingStreetNumber, shippingStreetName := extractAdyenStreetFormat(common.SafeStr(authRequest.ShippingAddress.StreetAddress1))\n\t\trequest.DeliveryAddress = &checkout.Address{\n\t\t\tCity: common.SafeStr(authRequest.ShippingAddress.Locality),\n\t\t\tCountry: common.SafeStr(authRequest.ShippingAddress.CountryCode),\n\t\t\tHouseNumberOrName: shippingStreetNumber,\n\t\t\tPostalCode: common.SafeStr(authRequest.ShippingAddress.PostalCode),\n\t\t\tStateOrProvince: common.SafeStr(authRequest.ShippingAddress.RegionCode),\n\t\t\tStreet: shippingStreetName,\n\t\t}\n\t}\n}", "func (c *Constructor) newAddress(ctx context.Context) (string, error) {\n\tkp, err := keys.GenerateKeypair(c.curveType)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w unable to generate keypair\", err)\n\t}\n\n\taddress, _, err := c.helper.Derive(\n\t\tctx,\n\t\tc.network,\n\t\tkp.PublicKey,\n\t\tnil,\n\t)\n\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w: unable to derive address\", err)\n\t}\n\n\terr = c.helper.StoreKey(ctx, address, kp)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w: unable to store address\", err)\n\t}\n\n\tif err := c.handler.AddressCreated(ctx, address); err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w: could not handle address creation\", err)\n\t}\n\n\treturn address, nil\n}", "func AddAddress(c router.Context) (interface{}, error) {\n\t// get the data from the request and parse it as structure\n\tdata := c.Param(`data`).(Address)\n\n\t// Validate the inputed data\n\terr := data.Validate()\n\tif err != nil {\n\t\tif _, ok := err.(validation.InternalError); ok {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn nil, status.ErrStatusUnprocessableEntity.WithValidationError(err.(validation.Errors))\n\t}\n\n\t// check if address already exists or not\n\tqueryString := fmt.Sprintf(\"{\\\"selector\\\": {\\\"user_addresses\\\": {\\\"$elemMatch\\\": {\\\"value\\\": \\\"%s\\\"}},\\\"doc_type\\\":\\\"%s\\\"}}\", data.Value, utils.DocTypeUser)\n\tuserResult, _, err := utils.Get(c, queryString, fmt.Sprintf(\"User already exists with the given address %s!\", data.Value))\n\n\tif userResult != nil {\n\t\treturn nil, status.ErrBadRequest.WithMessage(fmt.Sprintf(\"This address %s already exists in the system!\", data.Value))\n\t}\n\n\t// check if address already exists or not\n\tlabelQueryString := fmt.Sprintf(\"{\\\"selector\\\": {\\\"user_addresses\\\": {\\\"$elemMatch\\\": {\\\"label\\\": \\\"%s\\\"}},\\\"_id\\\":{\\\"$ne\\\":\\\"%s\\\"},\\\"doc_type\\\":\\\"%s\\\"}}\", data.Label, data.UserID, utils.DocTypeUser)\n\tlabelResult, _, err := utils.Get(c, labelQueryString, fmt.Sprintf(\"User already exists with the given label %s!\", data.Label))\n\n\tif labelResult != nil {\n\t\treturn nil, status.ErrBadRequest.WithMessage(fmt.Sprintf(\"This label %s has already been taken!\", data.Label))\n\t}\n\n\taddress1 := Address{UserID: data.UserID, Label: data.Label, Value: data.Value}\n\tstub := c.Stub()\n\tuserAsBytes, _ := stub.GetState(data.UserID)\n\tuser := User{}\n\n\terr = json.Unmarshal(userAsBytes, &user)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tuser.UserAddresses = append(user.UserAddresses, address1)\n\t// prepare the response body\n\tresponseBody := UserResponse{ID: data.UserID, Address: user.Address, WalletBalance: user.WalletBalance, Symbol: user.Symbol, CreatedAt: user.CreatedAt, UserAddresses: user.UserAddresses, Identity: user.Identity}\n\t// Save the data and return the response\n\treturn responseBody, c.State().Put(data.UserID, user)\n}", "func CreateQueryCustomerAddressListRequest() (request *QueryCustomerAddressListRequest) {\nrequest = &QueryCustomerAddressListRequest{\nRpcRequest: &requests.RpcRequest{},\n}\nrequest.InitWithApiInfo(\"BssOpenApi\", \"2017-12-14\", \"QueryCustomerAddressList\", \"\", \"\")\nreturn\n}", "func ExampleAddressClient_Validate() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclient, err := armbilling.NewAddressClient(cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := client.Validate(ctx,\n\t\tarmbilling.AddressDetails{\n\t\t\tAddressLine1: to.Ptr(\"1 Test\"),\n\t\t\tCity: to.Ptr(\"bellevue\"),\n\t\t\tCountry: to.Ptr(\"us\"),\n\t\t\tPostalCode: to.Ptr(\"12345\"),\n\t\t\tRegion: to.Ptr(\"wa\"),\n\t\t},\n\t\tnil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// TODO: use response item\n\t_ = res\n}", "func (h *HitBTC) GenerateNewAddress(ctx context.Context, currency string) (DepositCryptoAddresses, error) {\n\tresp := DepositCryptoAddresses{}\n\terr := h.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost,\n\t\tapiV2CryptoAddress+\"/\"+currency,\n\t\turl.Values{},\n\t\totherRequests,\n\t\t&resp)\n\n\treturn resp, err\n}", "func ServiceAddress(chain ChainID) Address {\n\treturn generateAddress(chain, serviceAddressState)\n}", "func (c *Contract) Address() sdk.AccAddress {\n\treturn c.self.Address()\n}", "func NewAddress(street string) *Address {\n // Just return a dummy for STUB\n return &Address{}\n}", "func NewAddress(pk ctypes.PubKey) *Address {\n\ta := Address{pk}\n\treturn &a\n}", "func (*CreateAddressRequest) Descriptor() ([]byte, []int) {\n\treturn file_yandex_cloud_vpc_v1_address_service_proto_rawDescGZIP(), []int{4}\n}", "func (mc *MoacChain) addContractAddress(contractAddr string) (err error) {\n\n\terr = mc.getContractInfo(contractAddr)\n\tif err == nil {\n\t\tvar cm database.CurrencyManagement\n\t\tflag2, err2 := database.Engine.Where(\"currency_contract_address = ?\", contractAddr).Get(&cm)\n\t\tif err2 == nil {\n\t\t\tif flag2 {\n\t\t\t\tvar countId int64 = 1\n\t\t\t\tvar counter int = 0\n\t\t\t\tfor {\n\t\t\t\t\tflag, err1 := database.Engine.Where(\"id = ?\", countId).Exist(&database.UserInfo{})\n\t\t\t\t\tif err1 == nil {\n\t\t\t\t\t\tif flag {\n\t\t\t\t\t\t\tcounter = 0\n\n\t\t\t\t\t\t\tvar ua database.UserAssets\n\t\t\t\t\t\t\tua.UserId = countId\n\t\t\t\t\t\t\tua.CurrencyNumber = 0\n\t\t\t\t\t\t\tua.CurrencyId = cm.CurrencyId\n\t\t\t\t\t\t\terr = database.SessionSubmit(func(session *xorm.Session) (err1 error) {\n\t\t\t\t\t\t\t\t_, err1 = session.Insert(ua)\n\t\t\t\t\t\t\t\treturn err1\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcounter++\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif counter == 11 {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcountId++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn err\n}", "func TestGenerateAddress(t *testing.T) {\n\tif _, err := GenerateAddress(); err != nil {\n\t\tt.Fatalf(\"Failed to generate new address: %v\", err)\n\t}\n}", "func (t *SimpleChaincode) modifyAddress(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tvar dni, address string // Entities\n\tvar err error\n\n\tif len(args) != 2 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 3\")\n\t}\n\n\tdni = args[0]\n\taddress = args[1]\n\n\tvar personObject Person;\n\tpersonStored, err := stub.GetState(dni)\n\tif err != nil {\n\t\treturn shim.Error(\"Failed to get state\")\n\t}\n\terr = json.Unmarshal(personStored, &personObject)\n\t\n\tfmt.Println(\"Modifying person DNI \" + dni + \" with Name \" + personObject.Name)\n\tpersonObject.Address = address\n\n\tdata, err := json.Marshal(personObject)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\terr = stub.PutState(dni, data)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\n\treturn shim.Success(nil)\n}", "func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {\n\tb, err := opts.ToAddressScopeCreateMap()\n\tif err != nil {\n\t\tr.Err = err\n\t\treturn\n\t}\n\tresp, err := client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{\n\t\tOkCodes: []int{201},\n\t})\n\t_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)\n\treturn\n}", "func (*uploadDownloadContractor) Address() modules.NetAddress { return \"\" }", "func bindAddress(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := ParsedABI(K_Address)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil\n}", "func (addressManager *AddressManager) NewAddress() address.Address {\n\treturn addressManager.Address(addressManager.lastAddressIndex + 1)\n}", "func Address(value string) *SimpleElement { return newSEString(\"address\", value) }", "func CreateAddrEntry(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tvar address Address\n\terr := json.NewDecoder(r.Body).Decode(&address)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), 500)\n\t\treturn\n\t}\n\t_, ok := GetEntry(address.FirstName, address.LastName)\n\tif ok {\n\t\thttp.Error(w, fmt.Sprintf(\"Duplicate entry for firstName: %s, lastName: %s\", address.FirstName, address.LastName), 400)\n\t\treturn\n\t}\n\tUpdateEntry(address)\n\tjson.NewEncoder(w).Encode(address)\n}", "func (w Wallet) Address() []byte {\n\tripemd160 := PublicKeyHash(w.PublicKey)\n\n\tversionedRimpemd160 := append([]byte{version}, ripemd160...)\n\tchecksum := CheckSumSlice(versionedRimpemd160)\n\n\tfullHash := append(versionedRimpemd160, checksum...)\n\taddress := Base58Encode(fullHash)\n\n\treturn address\n}", "func (w *Wallet) NewAddress(account uint32,\n\tscope waddrmgr.KeyScope) (btcutil.Address, er.R) {\n\n\tchainClient, err := w.requireChainClient()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar (\n\t\taddr btcutil.Address\n\t\tprops *waddrmgr.AccountProperties\n\t)\n\terr = walletdb.Update(w.db, func(tx walletdb.ReadWriteTx) er.R {\n\t\taddrmgrNs := tx.ReadWriteBucket(waddrmgrNamespaceKey)\n\t\tvar err er.R\n\t\taddr, props, err = w.newAddress(addrmgrNs, account, scope)\n\t\treturn err\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Notify the rpc server about the newly created address.\n\terr = chainClient.NotifyReceived([]btcutil.Address{addr})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tw.NtfnServer.notifyAccountProperties(props)\n\n\treturn addr, nil\n}", "func bindAddress(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := abi.JSON(strings.NewReader(AddressABI))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil\n}", "func bindAddress(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := abi.JSON(strings.NewReader(AddressABI))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil\n}", "func bindAddress(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := abi.JSON(strings.NewReader(AddressABI))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil\n}", "func bindAddress(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {\n\tparsed, err := abi.JSON(strings.NewReader(AddressABI))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil\n}", "func (_BaseContentSpace *BaseContentSpaceCaller) Factory(opts *bind.CallOpts) (common.Address, error) {\n\tvar out []interface{}\n\terr := _BaseContentSpace.contract.Call(opts, &out, \"factory\")\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "func (w *Wallet) NewAddress(s *aklib.DBConfig, pwd []byte, isPublic bool) (*address.Address, error) {\n\tadrmap := w.AddressPublic\n\tvar idx uint32\n\tif !isPublic {\n\t\tadrmap = w.AddressChange\n\t\tidx = 1\n\t}\n\tmaster, err := address.DecryptSeed(w.EncSeed, pwd)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tseed := address.HDseed(master, idx, uint32(len(adrmap)))\n\ta, err := address.New(s.Config, seed)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tadr := &Address{\n\t\tAddress: a,\n\t\tAdrstr: a.Address58(s.Config),\n\t\tNo: len(adrmap),\n\t}\n\tif err := w.PutAddress(s, pwd, adr, true); err != nil {\n\t\treturn nil, err\n\t}\n\tadrmap[a.Address58(s.Config)] = struct{}{}\n\treturn a, w.put(s)\n}", "func (addr *Address) CashAddress() (*cashaddress.Address, error) {\n\tvar network = cashaddress.MainNet\n\tvar addrtype = cashaddress.P2SH\n\n\tswitch addr.Network {\n\tcase MainNet:\n\t\tnetwork = cashaddress.MainNet\n\tcase TestNet:\n\t\tnetwork = cashaddress.TestNet\n\tcase RegTest:\n\t\tnetwork = cashaddress.RegTest\n\tdefault:\n\t\treturn nil, errors.New(\"invalid address network\")\n\t}\n\n\tswitch addr.Version {\n\tcase P2KH:\n\t\taddrtype = cashaddress.P2KH\n\tcase P2SH:\n\t\taddrtype = cashaddress.P2SH\n\tdefault:\n\t\treturn nil, errors.New(\"invalid address type\")\n\t}\n\treturn &cashaddress.Address{\n\t\tVersion: addrtype,\n\t\tPrefix: network,\n\t\tPayload: addr.Payload,\n\t}, nil\n}", "func (as *ASService) InputAddress(req *requests.AddrRequest) {\n\tas.AddrRequest(context.TODO(), req)\n}", "func (p *Poloniex) GenerateNewAddress(ctx context.Context, curr string) (string, error) {\n\ttype Response struct {\n\t\tSuccess int\n\t\tError string\n\t\tResponse string\n\t}\n\tresp := Response{}\n\tvalues := url.Values{}\n\tvalues.Set(\"currency\", curr)\n\n\terr := p.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, poloniexGenerateNewAddress, values, &resp)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif resp.Error != \"\" {\n\t\treturn \"\", errors.New(resp.Error)\n\t}\n\n\treturn resp.Response, nil\n}", "func (a *Account) NewAddress() (btcutil.Address, error) {\n\t// Get current block's height and hash.\n\tbs, err := GetCurBlock()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Get next address from wallet.\n\taddr, err := a.Wallet.NextChainedAddress(&bs, cfg.KeypoolSize)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Immediately write updated wallet to disk.\n\tAcctMgr.ds.ScheduleWalletWrite(a)\n\tif err := AcctMgr.ds.FlushAccount(a); err != nil {\n\t\treturn nil, fmt.Errorf(\"account write failed: %v\", err)\n\t}\n\n\t// Mark this new address as belonging to this account.\n\tAcctMgr.MarkAddressForAccount(addr, a)\n\n\t// Request updates from btcd for new transactions sent to this address.\n\ta.ReqNewTxsForAddress(addr)\n\n\treturn addr, nil\n}", "func Address(a string) Option {\n\treturn func(o *Options) {\n\t\to.Address = a\n\t}\n}", "func (as *ApiService) DepositAddresses(currency string) (*ApiResponse, error) {\n\treq := NewRequest(http.MethodGet, \"/api/v1/deposit-addresses\", map[string]string{\"currency\": currency})\n\treturn as.Call(req)\n}", "func addresses(w http.ResponseWriter, r *http.Request) {\n\n\tuser := getParam(r, USER_ID)\n\tcode := getUserCode(r)\n\n\tresource := \"/users/\" + user + \"/addresses\"\n\tredirectURL := HOST + \"/\" + user + \"/users/addresses\"\n\n\tclient, err := sdk.Meli(CLIENT_ID, code, CLIENT_SECRET, redirectURL)\n\n\tif err != nil {\n\t\tlog.Printf(\"Error: \", err.Error())\n\t\treturn\n\t}\n\n\tvar response *http.Response\n\tif response, err = client.Get(resource); err != nil {\n\t\tlog.Printf(\"Error: \", err.Error())\n\t\treturn\n\t}\n\n\t/*Example\n\t If the API to be called needs authorization/authentication (private api), then the authentication URL needs to be generated.\n\t Once you generate the URL and call it, you will be redirected to a ML login page where your credentials will be asked. Then, after\n\t entering your credentials you will obtain a CODE which will be used to get all the authorization tokens.\n\t*/\n\tif response.StatusCode == http.StatusForbidden {\n\t\turl := sdk.GetAuthURL(CLIENT_ID, sdk.AUTH_URL_MLA, redirectURL)\n\t\tbody, _ := ioutil.ReadAll(response.Body)\n\t\tlog.Printf(\"Returning Authentication URL:%s\\n\", url)\n\t\tlog.Printf(\"Error:%s\", body)\n\t\thttp.Redirect(w, r, url, 301)\n\t}\n\n\tprintOutput(w, response)\n}", "func (f *Factory) WithAddress(address string) *Factory {\n\tf.address = address\n\treturn f\n}", "func NewAddress(path, addr string, net Network, change, addrIndex uint32) *Address {\n\treturn &Address{path: path, addr: addr, net: net, change: change, addrIndex: addrIndex}\n}", "func MakeAddress(accman *wallet.Manager, account string) (wallet.Account, error) {\n\t// If the specified account is a valid address, return it\n\tif helper.IsHexAddress(account) {\n\t\treturn wallet.Account{Address: helper.HexToAddress(account)}, nil\n\t}\n\t// Otherwise try to interpret the account as a keystore index\n\tindex, err := strconv.Atoi(account)\n\tif err != nil {\n\t\treturn wallet.Account{}, fmt.Errorf(\"invalid account address or index %q\", account)\n\t}\n\treturn accman.AccountByIndex(index)\n}", "func DeployAddress(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Address, error) {\n\tparsed, err := ParsedABI(K_Address)\n\tif err != nil {\n\t\treturn common.Address{}, nil, nil, err\n\t}\n\n\tif parsed == nil {\n\t\treturn common.Address{}, nil, nil, errors.New(\"GetABI returned nil\")\n\t}\n\n\taddress, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(AddressBin), backend)\n\tif err != nil {\n\t\treturn common.Address{}, nil, nil, err\n\t}\n\treturn address, tx, &Address{AddressCaller: AddressCaller{contract: contract}, AddressTransactor: AddressTransactor{contract: contract}, AddressFilterer: AddressFilterer{contract: contract}}, nil\n}" ]
[ "0.78183013", "0.7629378", "0.679397", "0.67914236", "0.66517043", "0.6582681", "0.64559764", "0.6390346", "0.6336294", "0.62283635", "0.62227005", "0.62106955", "0.62054926", "0.61936045", "0.6162253", "0.61483634", "0.61028504", "0.60747445", "0.6063984", "0.60360086", "0.6034897", "0.59988743", "0.5972265", "0.5971625", "0.5969762", "0.5963498", "0.59420764", "0.5926836", "0.5921498", "0.5915004", "0.58919835", "0.58894706", "0.5879588", "0.5872201", "0.583039", "0.58209383", "0.58180803", "0.5817585", "0.5817585", "0.5817585", "0.5817585", "0.5817585", "0.578661", "0.57581955", "0.5751077", "0.5750759", "0.5738778", "0.57359755", "0.5731498", "0.57213426", "0.5706656", "0.56942296", "0.5688643", "0.568476", "0.56828344", "0.56823474", "0.56692034", "0.56688535", "0.5654771", "0.56498075", "0.5638252", "0.56363094", "0.5611032", "0.5608034", "0.5602743", "0.5602377", "0.56013685", "0.55996203", "0.5592615", "0.5580301", "0.55709004", "0.55705786", "0.55693954", "0.55660844", "0.55576867", "0.5555394", "0.55448264", "0.55356944", "0.5529067", "0.55260164", "0.5511972", "0.5510217", "0.55089986", "0.5504246", "0.5504246", "0.5504246", "0.5504246", "0.55029464", "0.5497578", "0.549484", "0.54938716", "0.54853654", "0.54798526", "0.547885", "0.54680526", "0.54543644", "0.54409766", "0.54384214", "0.54345256", "0.5433521" ]
0.79032356
0
Create will create a new address for a specific asset and return the newly created address
Create создаст новый адрес для определенного актива и вернет только что созданный адрес
func (as *AddressService) Create(name string) (*Address, error) { if isEmptyStr(as.assetCode) { return nil, errAssetCode } var ( addresses []*Address body struct { Address struct { Name string `json:"name"` } `json:"address"` } ) body.Address.Name = name if err := as.client.Post(buildString("address/deposit/", as.assetCode), &body, &addresses); err != nil { return nil, err } return addresses[0], nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (handler *Handler) CreateAddress(ctx context.Context, in *candyland_grpc.CreateAddressRequest) (*candyland_grpc.CreateAddressReply, error) {\n\terr := handler.CreateAddressUsecase.Create(in.UserId, in.CountryId, in.StateId, in.CityId, in.StreetId, in.Number, in.Complement.String())\n\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\treturn nil, err\n\t}\n\n\tres := &candyland_grpc.CreateAddressReply{\n\t\tWasCreated: true,\n\t}\n\n\treturn res, nil\n}", "func CreateAddress() *addresspb.Address {\n\ta := addresspb.Address{\n\t\tCorrespondanceAddr: &addresspb.Location{\n\t\t\tLocation: \"loc 1\",\n\t\t\tCity: &addresspb.City{\n\t\t\t\tName: \"Mumbai\",\n\t\t\t\tZipCode: \"400005\",\n\t\t\t\tRegion: addresspb.Division_WEST,\n\t\t\t},\n\t\t},\n\n\t\tAdditionalAddr: []*addresspb.Location{\n\t\t\t{\n\t\t\t\tLocation: \"loc 2\",\n\t\t\t\tCity: &addresspb.City{\n\t\t\t\t\tName: \"Srinagar\",\n\t\t\t\t\tZipCode: \"190001\",\n\t\t\t\t\tRegion: addresspb.Division_NORTH,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tLocation: \"loc 3\",\n\t\t\t\tCity: &addresspb.City{\n\t\t\t\t\tName: \"Imphal\",\n\t\t\t\t\tZipCode: \"795001\",\n\t\t\t\t\tRegion: addresspb.Division_EAST,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tLocation: \"loc 4\",\n\t\t\t\tCity: &addresspb.City{\n\t\t\t\t\tName: \"Mysore\",\n\t\t\t\t\tZipCode: \"570001\",\n\t\t\t\t\tRegion: addresspb.Division_SOUTH,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\treturn &a\n}", "func CreateAddress(address models.RequestAddress) (bool, models.ResponseAddress, error) {\n\n\t//Create request\n\trequest := models.Request{}\n\trequest.AddBody(address)\n\trequest.SetUri(\"https://api.easypost.com/v2/addresses\")\n\trequest.SetMethod(\"POST\")\n\n\t//Send request\n\tresponseBody, err := SendRequest(request)\n\n\t//Initialize response address\n\tresponseAddress := models.ResponseAddress{}\n\n\terr = json.Unmarshal(responseBody, &responseAddress)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false, responseAddress, fmt.Errorf(\"Unrecognized response from easypost %s\", err.Error())\n\t}\n\n\treturn responseAddress.Verifications.Delivery.Success, responseAddress, err\n}", "func (as *ApiService) CreateDepositAddress(currency string) (*ApiResponse, error) {\n\treq := NewRequest(http.MethodPost, \"/api/v1/deposit-addresses\", map[string]string{\"currency\": currency})\n\treturn as.Call(req)\n}", "func (id *Public) CreateAddress(version, stream uint64) {\n\tid.Address.Version = version\n\tid.Address.Stream = stream\n\tcopy(id.Address.Ripe[:], id.hash())\n}", "func (as *AddressbookService) CreateAddress(addr models.Address) (models.Address, error) {\n\treturn as.repo.AddAddress(addr)\n}", "func CreateAddress(id ID, owner []byte) (swarm.Address, error) {\n\tsum, err := hash(id, owner)\n\tif err != nil {\n\t\treturn swarm.ZeroAddress, err\n\t}\n\treturn swarm.NewAddress(sum), nil\n}", "func (c *Client) Address(assetCode ...string) *AddressService {\n\tif len(assetCode) == 0 {\n\t\tassetCode[0] = \"\"\n\t}\n\n\treturn &AddressService{service{c}, assetCode[0]}\n}", "func CreateAddress(amount int) (string, []Wallet) {\n\n\twallets := []Wallet{}\n\tfor i := 0; i < amount; i++ {\n\t\twif, _ := network.CreatePrivateKey()\n\t\taddress, _ := network.GetAddress(wif)\n\t\tvar wallet = Wallet{ADDRESS: address.EncodeAddress(), PRIVKEY: wif.String()}\n\t\twallets = append(wallets, wallet)\n\t}\n\n\tjson := ConvertToJSON(&wallets)\n\n\tlog.Println(\"Generated\", amount, \"addresses\")\n\n\treturn json, wallets\n\n}", "func createAddress(creator *Account) Word256 {\n\tnonce := creator.Nonce\n\tcreator.Nonce += 1\n\ttemp := make([]byte, 32+8)\n\tcopy(temp, creator.Address[:])\n\tPutUint64BE(temp[32:], nonce)\n\treturn LeftPadWord256(sha3.Sha3(temp)[:20])\n}", "func CreateAddrEntry(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tvar address Address\n\terr := json.NewDecoder(r.Body).Decode(&address)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), 500)\n\t\treturn\n\t}\n\t_, ok := GetEntry(address.FirstName, address.LastName)\n\tif ok {\n\t\thttp.Error(w, fmt.Sprintf(\"Duplicate entry for firstName: %s, lastName: %s\", address.FirstName, address.LastName), 400)\n\t\treturn\n\t}\n\tUpdateEntry(address)\n\tjson.NewEncoder(w).Encode(address)\n}", "func (service AccountsService) Create(a Account) (*Response, Account, error) {\n\treq, err := service.client.newRequest(\"POST\", \"accounts\", nil, a)\n\tif err != nil {\n\t\treturn nil, Account{}, err\n\t}\n\n\tvar dest Account\n\tres, err := service.client.do(req, &dest)\n\n\tdest.BillingInfo = nil\n\n\treturn res, dest, err\n}", "func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {\n\tb, err := opts.ToAddressScopeCreateMap()\n\tif err != nil {\n\t\tr.Err = err\n\t\treturn\n\t}\n\tresp, err := client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{\n\t\tOkCodes: []int{201},\n\t})\n\t_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)\n\treturn\n}", "func CreateAddress(b types.Address, nonce *big.Int) types.Address {\n\tdata, _ := rlp.EncodeToBytes([]interface{}{b, nonce})\n\treturn types.BytesToAddress(keccak.Keccak256(data)[12:])\n}", "func CreateAddress(a *AddressDAL) (*AddressDAL, error) {\n\tresult := db.DB().Create(a)\n\tif result.Error != nil {\n\t\treturn nil, result.Error\n\t}\n\treturn a, nil\n}", "func (address *Address) CreateAddress(db *gorm.DB) (*Address, error) {\n\n\terr := db.Debug().Create(&address).Error\n\tif err != nil {\n\t\treturn &Address{}, err\n\t}\n\n\treturn address, nil\n}", "func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface, id string, color string, size int, appraisedValue int) error {\n\n\t// Demonstrate the use of Attribute-Based Access Control (ABAC) by checking\n\t// to see if the caller has the \"abac.creator\" attribute with a value of true;\n\t// if not, return an error.\n\n\terr := ctx.GetClientIdentity().AssertAttributeValue(\"abac.creator\", \"true\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"submitting client not authorized to create asset, does not have abac.creator role\")\n\t}\n\n\texists, err := s.AssetExists(ctx, id)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif exists {\n\t\treturn fmt.Errorf(\"the asset %s already exists\", id)\n\t}\n\n\t// Get ID of submitting client identity\n\tclientID, err := s.GetSubmittingClientIdentity(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tasset := Asset{\n\t\tID: id,\n\t\tColor: color,\n\t\tSize: size,\n\t\tOwner: clientID,\n\t\tAppraisedValue: appraisedValue,\n\t}\n\tassetJSON, err := json.Marshal(asset)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn ctx.GetStub().PutState(id, assetJSON)\n}", "func CreateAddress(b common.Address, nonce uint64) common.Address {\n\tdata, _ := rlp.EncodeToBytes([]interface{}{b, nonce})\n\taddr := common.BytesToAddress(Keccak512(data)[:])\n\treturn common.DarmaAddressToContractAddress(addr)\n}", "func (mc *MoacChain) createChainAddress(tradePassword string) (addr string, err error) {\n\n\tdefer func() {\n\t\tif re := recover(); re != nil {\n\t\t\terr = re.(error)\n\t\t}\n\t}()\n\n\terr = rpcClient.Call(&addr, \"personal_newAccount\", tradePassword)\n\n\treturn addr, err\n}", "func (c *Constructor) newAddress(ctx context.Context) (string, error) {\n\tkp, err := keys.GenerateKeypair(c.curveType)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w unable to generate keypair\", err)\n\t}\n\n\taddress, _, err := c.helper.Derive(\n\t\tctx,\n\t\tc.network,\n\t\tkp.PublicKey,\n\t\tnil,\n\t)\n\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w: unable to derive address\", err)\n\t}\n\n\terr = c.helper.StoreKey(ctx, address, kp)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w: unable to store address\", err)\n\t}\n\n\tif err := c.handler.AddressCreated(ctx, address); err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w: could not handle address creation\", err)\n\t}\n\n\treturn address, nil\n}", "func (a *AccountClient) Create(accountParams AccountParams) (*Resource, error) {\n\n\tresp, err := a.client.R().\n\t\tSetResult(&Resource{}).\n\t\tSetBody(map[string]AccountParams{\"data\": accountParams}).\n\t\tPost(\"/v1/organisation/accounts\")\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create account failed: %s\", err)\n\t}\n\n\tif resp.Error() != nil {\n\t\treturn nil, getAPIError(resp)\n\t}\n\n\treturn resp.Result().(*Resource), nil\n}", "func (e *ExternalAssetTypeService) Create(name string, externalAssetType *ExternalAssetType) (*ExternalAssetType, *Response, error) {\n\tif externalAssetType == nil {\n\t\texternalAssetType = &ExternalAssetType{}\n\t}\n\texternalAssetType.Name = name\n\n\tendpoint := \"/assets/external/type\"\n\tresp, err := e.client.postRequestDecode(endpoint, externalAssetType)\n\treturn externalAssetType, resp, err\n}", "func CreateAddress(address string) string {\n\tnumeric := []string{\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"}\n\talpha := []string{\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\"}\n\n\tindexZero := RandomIndex(0, 10)\n\tindexOne := RandomIndex(0, 10)\n\tindexTwo := RandomIndex(0, 10)\n\n\treturn fmt.Sprintf(\"%s %s%s%s\", address, alpha[indexZero], numeric[indexOne], alpha[indexTwo])\n}", "func (lu *litUiClient) NewAddress() (string, error) {\n\n\t// cointype of 0 means default, not mainnet.\n\t// this is ugly but does prevent mainnet use for now.\n\n\tvar cointype, numadrs uint32\n\n\t// if no arguments given, generate 1 new address.\n\t// if no cointype given, assume type 1 (testnet)\n\n\tnumadrs = 1\n\n\treply := new(litrpc.AddressReply)\n\n\targs := new(litrpc.AddressArgs)\n\targs.CoinType = cointype\n\targs.NumToMake = numadrs\n\n\tfmt.Printf(\"adr cointye: %d num:%d\\n\", args.CoinType, args.NumToMake)\n\terr := lu.rpccon.Call(\"LitRPC.Address\", args, reply)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tresponse := reply.WitAddresses[0]\n\t//\tfmt.Fprintf(color.Output, \"new adr(s): %s\\nold: %s\\n\",\n\t//\t\tlnutil.Address(reply.WitAddresses), lnutil.Address(reply.LegacyAddresses))\n\treturn response, nil // reply.WitAddresses[]\n\n}", "func (sc StoreController) Create(c *gin.Context) {\n\tlog.Debug().Caller().Msg(\"stores create\")\n\tp, err := sc.Storeservice.Create(c)\n\n\tif err != nil {\n\t\tif strings.Contains(err.Error(), \"InvalidAddress\") {\n\t\t\tc.AbortWithStatus(http.StatusNotFound)\n\t\t\tlog.Error().Caller().Err(err).Send()\n\t\t} else {\n\t\t\tc.AbortWithStatus(http.StatusBadRequest)\n\t\t\tlog.Error().Caller().Err(err).Send()\n\t\t}\n\t} else {\n\t\tc.JSON(http.StatusCreated, p)\n\t}\n}", "func CreateAddressPool(ctx iris.Context) {\n\turi := ctx.Request().RequestURI\n\tfabricID := ctx.Params().Get(\"id\")\n\tif _, err := capmodel.GetFabric(fabricID); err != nil {\n\t\terrMsg := fmt.Sprintf(\"failed to fetch fabric data for uri %s: %s\", uri, err.Error())\n\t\tcreateDbErrResp(ctx, err, errMsg, []interface{}{\"Fabric\", fabricID})\n\t\treturn\n\t}\n\tvar addresspoolData model.AddressPool\n\terr := ctx.ReadJSON(&addresspoolData)\n\tif err != nil {\n\t\terrorMessage := \"error while trying to get JSON body from the request: \" + err.Error()\n\t\tlog.Error(errorMessage)\n\t\tresp := updateErrorResponse(response.MalformedJSON, errorMessage, nil)\n\t\tctx.StatusCode(http.StatusBadRequest)\n\t\tctx.JSON(resp)\n\t\treturn\n\t}\n\t// Todo :Add required validation for the request params\n\tmissingAttribute, err := validateAddressPoolRequest(addresspoolData)\n\tif err != nil {\n\t\tlog.Error(err.Error())\n\t\tresp := updateErrorResponse(response.PropertyMissing, err.Error(), []interface{}{missingAttribute})\n\t\tctx.StatusCode(http.StatusBadRequest)\n\t\tctx.JSON(resp)\n\t\treturn\n\t}\n\tif addresspoolData.Ethernet.IPv4.GatewayIPAddress != \"\" {\n\t\tif _, _, err := net.ParseCIDR(addresspoolData.Ethernet.IPv4.GatewayIPAddress); err != nil {\n\t\t\terrorMessage := \"Invalid value for GatewayIPAddress:\" + err.Error()\n\t\t\tlog.Errorf(errorMessage)\n\t\t\tresp := updateErrorResponse(response.PropertyValueFormatError, errorMessage, []interface{}{addresspoolData.Ethernet.IPv4.GatewayIPAddress, \"GatewayIPAddress\"})\n\t\t\tctx.StatusCode(http.StatusBadRequest)\n\t\t\tctx.JSON(resp)\n\t\t\treturn\n\n\t\t}\n\t\tif addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Lower != addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Upper {\n\t\t\terrorMessage := fmt.Sprintf(\"Requested VLANIdentifierAddressRange Lower %d is not equal to Upper %d\", addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Lower, addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Upper)\n\t\t\tlog.Error(errorMessage)\n\t\t\tresp := updateErrorResponse(response.PropertyUnknown, errorMessage, []interface{}{\"VLANIdentifierAddressRange\"})\n\t\t\tctx.StatusCode(http.StatusBadRequest)\n\t\t\tctx.JSON(resp)\n\t\t\treturn\n\t\t}\n\t\taddressPools, err := capmodel.GetAllAddressPools(fabricID)\n\t\tif err != nil {\n\t\t\terrMsg := fmt.Sprintf(\"failed to fetch AddressPool data for uri %s: %s\", uri, err.Error())\n\t\t\tcreateDbErrResp(ctx, err, errMsg, []interface{}{\"Fabric\", fabricID})\n\t\t\treturn\n\t\t}\n\t\tfor _, data := range addressPools {\n\t\t\tif data.Ethernet.IPv4.GatewayIPAddress == addresspoolData.Ethernet.IPv4.GatewayIPAddress {\n\t\t\t\terrorMessage := \"Requested GatewayIPAddress is already present in the addresspool \" + data.ODataID\n\t\t\t\tlog.Error(errorMessage)\n\t\t\t\tresp := updateErrorResponse(response.ResourceAlreadyExists, errorMessage, []interface{}{\"AddressPool\", \"GatewayIPAddress\", addresspoolData.Ethernet.IPv4.GatewayIPAddress})\n\t\t\t\tctx.StatusCode(http.StatusConflict)\n\t\t\t\tctx.JSON(resp)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\tif addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Lower > addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Upper {\n\t\terrorMessage := fmt.Sprintf(\"Requested VLANIdentifierAddressRange Lower %d is greater than Upper %d\", addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Lower, addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Upper)\n\t\tlog.Error(errorMessage)\n\t\tresp := updateErrorResponse(response.PropertyUnknown, errorMessage, []interface{}{\"VLANIdentifierAddressRange\"})\n\t\tctx.StatusCode(http.StatusBadRequest)\n\t\tctx.JSON(resp)\n\t\treturn\n\t}\n\t// validate the VLANIdentifierAddressRange lower value\n\tresp, statusCode := validateVLANIdentifierAddressRange(addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Lower, addresspoolData.Ethernet.IPv4.VLANIdentifierAddressRange.Upper)\n\tif statusCode != http.StatusOK {\n\t\tctx.StatusCode(statusCode)\n\t\tctx.JSON(resp)\n\t\treturn\n\t}\n\n\taddressPoolID := uuid.NewV4().String()\n\taddresspoolData.ODataContext = \"/ODIM/v1/$metadata#AddressPool.AddressPool\"\n\taddresspoolData.ODataType = \"#AddressPool.v1_1_0.AddressPool\"\n\taddresspoolData.ODataID = fmt.Sprintf(\"%s/%s\", uri, addressPoolID)\n\taddresspoolData.ID = addressPoolID\n\n\tif err = capmodel.SaveAddressPool(fabricID, addresspoolData.ODataID, &addresspoolData); err != nil {\n\t\terrMsg := fmt.Sprintf(\"failed to save AddressPool data for uri %s: %s\", uri, err.Error())\n\t\tcreateDbErrResp(ctx, err, errMsg, []interface{}{\"Fabric\", fabricID})\n\t\treturn\n\t}\n\n\tcommon.SetResponseHeader(ctx, map[string]string{\n\t\t\"Location\": addresspoolData.ODataID,\n\t})\n\n\tctx.StatusCode(http.StatusCreated)\n\tctx.JSON(addresspoolData)\n}", "func NewAddress(street string) *Address {\n // Just return a dummy for STUB\n return &Address{}\n}", "func makeAddress(keyPair *keypair.KeyPair, testnet bool) *account.Account {\n\n\treturn &account.Account{\n\t\tAccountInterface: &account.ED25519Account{\n\t\t\tTest: testnet,\n\t\t\tPublicKey: keyPair.PublicKey[:],\n\t\t},\n\t}\n}", "func (n *Node) CreateAddress() *Node {\n\tkeystore := n.client.KeystoreAPI()\n\tif _, err := keystore.CreateUser(n.UserPass); err != nil {\n\t\tpanic(stacktrace.Propagate(err, \"Could not create user for node.\"))\n\t}\n\n\txAddress, err := n.client.XChainAPI().CreateAddress(n.UserPass)\n\tif err != nil {\n\t\tpanic(stacktrace.Propagate(err, \"Could not create user address in the XChainAPI.\"))\n\t}\n\tn.XAddress = xAddress\n\n\tpAddress, err := n.client.PChainAPI().CreateAddress(n.UserPass)\n\tif err != nil {\n\t\tpanic(stacktrace.Propagate(err, \"Could not create user address in the PChainAPI.\"))\n\t}\n\tn.PAddress = pAddress\n\treturn n\n}", "func NewAddress(i, ii int) *Address {\n\tn := strconv.Itoa(i)\n\treturn &Address{\n\t\tId: time.Now().UnixNano(),\n\t\tStreet: \"10\" + n + \" Somewhere Lane\",\n\t\tCity: \"Awesome City \" + n,\n\t\tState: func() string {\n\t\t\tif i%2 == 0 {\n\t\t\t\treturn \"PA\"\n\t\t\t}\n\t\t\treturn \"CA\"\n\t\t}(),\n\t\tZip: ii,\n\t}\n}", "func (c *Client) Addresses(ctx context.Context, foreignID, currency string) (Address, error) {\n\treqBody := map[string]string{\n\t\t\"foreign_id\": foreignID,\n\t\t\"currency\": currency,\n\t}\n\n\treqJSON, err := json.Marshal(reqBody)\n\tif err != nil {\n\t\treturn Address{}, fmt.Errorf(\"request body marshaling error: %w\", err)\n\t}\n\n\taddressesURL, err := joinURL(c.api, addressesEndpoint)\n\tif err != nil {\n\t\treturn Address{}, fmt.Errorf(\"request url creating error: %w\", err)\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, addressesURL.String(), bytes.NewBuffer(reqJSON))\n\tif err != nil {\n\t\treturn Address{}, fmt.Errorf(\"request creating error: %w\", err)\n\t}\n\n\tsig, err := createHmac(c.secret, reqJSON)\n\tif err != nil {\n\t\treturn Address{}, fmt.Errorf(\"hmac signature creationg error: %w\", err)\n\t}\n\n\treq.Header.Set(contentTypeHeader, jsonContentType)\n\treq.Header.Set(keyHeader, c.apiKey)\n\treq.Header.Set(signatureHeader, sig)\n\n\tresp, err := c.client.Do(req)\n\tif err != nil {\n\t\treturn Address{}, fmt.Errorf(\"request error: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\terr = ensureSuccessResponse(resp)\n\tif err != nil {\n\t\treturn Address{}, fmt.Errorf(\"request failed: %w\", err)\n\t}\n\n\trespBody := struct {\n\t\tData Address `json:\"data\"`\n\t}{}\n\n\terr = json.NewDecoder(resp.Body).Decode(&respBody)\n\tif err != nil {\n\t\treturn Address{}, fmt.Errorf(\"response unmarshaling error: %w\", err)\n\t}\n\n\treturn respBody.Data, nil\n}", "func (a *APIClient) Create(account AccountData) (created AccountData, err error) {\n\n\trel := &url.URL{Path: \"/v1/organisation/accounts\"}\n\turl := a.BaseURL.ResolveReference(rel)\n\n\tjsonPayload, err := json.Marshal(account)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn AccountData{}, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", url.String(), bytes.NewBuffer(jsonPayload))\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn AccountData{}, err\n\t}\n\n\tresp, err := a.HTTPClient.Do(req)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn AccountData{}, err\n\t}\n\n\tdefer resp.Body.Close()\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn AccountData{}, err\n\t}\n\n\terr = json.Unmarshal(body, &created)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn AccountData{}, err\n\t}\n\n\treturn created, nil\n}", "func (_BaseAccessWalletFactory *BaseAccessWalletFactoryCaller) Creator(opts *bind.CallOpts) (common.Address, error) {\n\tvar out []interface{}\n\terr := _BaseAccessWalletFactory.contract.Call(opts, &out, \"creator\")\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "func (ms MockSOC) Address() boson.Address {\n\taddr, _ := soc.CreateAddress(ms.ID, ms.Owner)\n\treturn addr\n}", "func (as *Service) Create(name, iamRole, externalID string) (*Account, error) {\n\n\tbody := map[string]map[string]string{\n\t\t\"account\": {\"name\": name},\n\t}\n\n\tlog.Printf(\"Making request %v\\n\", body)\n\treq, err := as.httpClient.NewRequest(http.MethodPost, \"/setup/account\", &body)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar v common.Response\n\t_, err = as.httpClient.Do(req, &v)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(v.Response.Items) == 0 {\n\t\treturn nil, errors.New(\"Couldn't create account\")\n\t}\n\tvar account Account\n\n\tfmt.Println(string(v.Response.Items[0]))\n\n\terr = json.Unmarshal(v.Response.Items[0], &account)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttime.Sleep(time.Second * 5)\n\n\terr = as.setupCloudCredentials(account.ID, iamRole, externalID)\n\n\tif err != nil {\n\t\t_ = as.Delete(account.ID)\n\t\treturn nil, err\n\t}\n\n\treturn &account, nil\n}", "func (i *ProjectIPServiceOp) Create(projectID string, ipReservationReq *IPReservationCreateRequest) (*IPAddressReservation, *Response, error) {\n\tif validateErr := ValidateUUID(projectID); validateErr != nil {\n\t\treturn nil, nil, validateErr\n\t}\n\tapiPath := path.Join(projectBasePath, projectID, ipBasePath)\n\tipr := new(IPAddressReservation)\n\n\tresp, err := i.client.DoRequest(\"POST\", apiPath, ipReservationReq, ipr)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\treturn ipr, resp, err\n}", "func (c *Client) CreateAsset(asset *Asset) (*Asset, error) {\n\tvar out AssetItem\n\terr := c.WriteObject(\"/api/v2/assets\", \"POST\", asset, &out)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &out.Asset, nil\n}", "func (r *PoolNAPTRResource) Create(item Pool) error {\n\tif err := r.c.ModQuery(\"POST\", BasePath+PoolNAPTREndpoint, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (eth *Eth) NewAddress(set bool) string {\n\tnewpair := crypto.GenerateNewKeyPair()\n\taddr := ethutil.Bytes2Hex(newpair.Address())\n\tring := eth.keyManager.KeyRing()\n\tring.AddKeyPair(newpair)\n\tif set {\n\t\teth.SetAddressN(ring.Len() - 1)\n\t}\n\treturn addr\n}", "func CustomerAddressCreate(ctx context.Context, db *mongo.Database, cAddress CustomerAddress) error {\n\tcol := db.Collection(AddressCollection)\n\t_, err := col.InsertOne(ctx, cAddress)\n\tif err != nil {\n\t\tif merr, ok := err.(mongo.WriteException); ok {\n\t\t\terrCode := merr.WriteErrors[0].Code\n\t\t\tif errCode == 11000 {\n\t\t\t\treturn ErrAddressExists\n\t\t\t}\n\t\t}\n\t\treturn err\n\t}\n\treturn nil\n}", "func (transaction *Transaction) create(srcAccountId, destAccountId string, amount float32) *Transaction {\n\n\tfmt.Println(\"creating transaction\")\n\ttransaction.srcAccountId = srcAccountId\n\ttransaction.destAccountId = destAccountId\n\ttransaction.amount = amount\n\treturn transaction\n}", "func Create(w http.ResponseWriter, r *http.Request) {\n\n\taccountDecoder := json.NewDecoder(r.Body)\n\tvar accData Account\n\terr := accountDecoder.Decode(&accData)\n\tif err != nil {\n\t\tlog.Fatalln(\"error:\", err)\n\t}\n\taccData.CreateAccount()\n\tfmt.Fprintf(w, \"Account added successfully\")\n}", "func ExampleSnowball_CreateAddress_shared00() {\n\tsvc := snowball.New(session.New())\n\tinput := &snowball.CreateAddressInput{\n\t\tAddress: &snowball.Address{\n\t\t\tCity: aws.String(\"Seattle\"),\n\t\t\tCompany: aws.String(\"My Company's Name\"),\n\t\t\tCountry: aws.String(\"USA\"),\n\t\t\tName: aws.String(\"My Name\"),\n\t\t\tPhoneNumber: aws.String(\"425-555-5555\"),\n\t\t\tPostalCode: aws.String(\"98101\"),\n\t\t\tStateOrProvince: aws.String(\"WA\"),\n\t\t\tStreet1: aws.String(\"123 Main Street\"),\n\t\t},\n\t}\n\n\tresult, err := svc.CreateAddress(input)\n\tif err != nil {\n\t\tif aerr, ok := err.(awserr.Error); ok {\n\t\t\tswitch aerr.Code() {\n\t\t\tcase snowball.ErrCodeInvalidAddressException:\n\t\t\t\tfmt.Println(snowball.ErrCodeInvalidAddressException, aerr.Error())\n\t\t\tcase snowball.ErrCodeUnsupportedAddressException:\n\t\t\t\tfmt.Println(snowball.ErrCodeUnsupportedAddressException, aerr.Error())\n\t\t\tdefault:\n\t\t\t\tfmt.Println(aerr.Error())\n\t\t\t}\n\t\t} else {\n\t\t\t// Print the error, cast err to awserr.Error to get the Code and\n\t\t\t// Message from an error.\n\t\t\tfmt.Println(err.Error())\n\t\t}\n\t\treturn\n\t}\n\n\tfmt.Println(result)\n}", "func (act Account) Create(nr Application) (Resource, error) {\n\tvar r Resource\n\tif nr.Validate() != nil {\n\t\treturn r, nr.Validate()\n\t}\n\terr := common.SendPostRequest(fmt.Sprintf(applications.Create, act.AccountSid), nr, act, &r)\n\treturn r, err\n}", "func (_BaseAccessWallet *BaseAccessWalletCaller) Creator(opts *bind.CallOpts) (common.Address, error) {\n\tvar out []interface{}\n\terr := _BaseAccessWallet.contract.Call(opts, &out, \"creator\")\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "func (dcr *ExchangeWallet) NewAddress() (string, error) {\n\treturn dcr.DepositAddress()\n}", "func (c *Client) Create(ctx context.Context, params *razorpay.OrderParams) (*razorpay.Order, error) {\n\torder := &razorpay.Order{}\n\terr := c.Call(ctx, http.MethodPost, \"/orders\", params, order)\n\treturn order, err\n}", "func (c *PartyController) Create(ctx *app.CreatePartyContext) error {\n\t// PartyController_Create: start_implement\n\n\terr := c.P.PinService().CreateParty(&pinbase.PartyCreate{\n\t\tID: pinbase.Hash(ctx.Payload.Hash),\n\t\tDescription: ctx.Payload.Description,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// PartyController_Create: end_implement\n\tctx.ResponseData.Header().Set(\"Location\", app.PartyHref(ctx.Payload.Hash))\n\treturn ctx.Created()\n}", "func (e Endpoints) PostAddress(ctx context.Context, profileID string, a Address) error {\n\n\t// TODO: Create detailed ref spec\n\trequest := postAddressRequest{ProfileID: profileID, Address: a}\n\n\tresponse, err := e.PostAddressEndpoint(ctx, request)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresp := response.(postAddressResponse)\n\n\treturn resp.Err\n}", "func (a *Account) NewAddress() (btcutil.Address, error) {\n\t// Get current block's height and hash.\n\trpcc, err := accessClient()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbs, err := rpcc.BlockStamp()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Get next address from wallet.\n\taddr, err := a.KeyStore.NextChainedAddress(&bs, cfg.KeypoolSize)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Immediately write updated wallet to disk.\n\tAcctMgr.ds.ScheduleWalletWrite(a)\n\tif err := AcctMgr.ds.FlushAccount(a); err != nil {\n\t\treturn nil, fmt.Errorf(\"account write failed: %v\", err)\n\t}\n\n\t// Mark this new address as belonging to this account.\n\tAcctMgr.MarkAddressForAccount(addr, a)\n\n\t// Request updates from btcd for new transactions sent to this address.\n\tif err := rpcc.NotifyReceived([]btcutil.Address{addr}); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn addr, nil\n}", "func NewAddresser(assetID uint32, acctXPub string, keyIndexer KeyIndexer, network dex.Network) (Addresser, uint32, error) {\n\tdrv, ok := drivers[assetID]\n\tif !ok {\n\t\treturn nil, 0, fmt.Errorf(\"unknown asset driver %d\", assetID)\n\t}\n\taf, ok := drv.(AddresserFactory)\n\tif !ok {\n\t\treturn nil, 0, fmt.Errorf(\"asset does not support NewAddresser\")\n\t}\n\treturn af.NewAddresser(acctXPub, keyIndexer, network)\n}", "func Create(account *Account) (Data, error) {\n\tpayload, err := json.Marshal(Data{Account: *account})\n\tif err != nil {\n\t\treturn Data{}, err\n\t}\n\n\tresponseStatus, responsePayload, err := doRequest(&request{\n\t\tmethod: \"POST\",\n\t\tresource: \"v1/organisation/accounts/\",\n\t\tpayload: payload,\n\t})\n\n\tif err != nil {\n\t\treturn Data{}, err\n\t}\n\n\treturn handleResponseData(responsePayload, http.StatusCreated, responseStatus)\n}", "func MakeAddress(accman *wallet.Manager, account string) (wallet.Account, error) {\n\t// If the specified account is a valid address, return it\n\tif helper.IsHexAddress(account) {\n\t\treturn wallet.Account{Address: helper.HexToAddress(account)}, nil\n\t}\n\t// Otherwise try to interpret the account as a keystore index\n\tindex, err := strconv.Atoi(account)\n\tif err != nil {\n\t\treturn wallet.Account{}, fmt.Errorf(\"invalid account address or index %q\", account)\n\t}\n\treturn accman.AccountByIndex(index)\n}", "func NewAddress() platformservices.Address {\n\n\tvar lat = 37.7917146\n\tvar lng = -122.397054\n\n\treturn platformservices.Address{\n\t\tAddressType: platformservices.AddressTypeLegal,\n\t\tStreetAddress: \"100 Main Street\",\n\t\tCity: \"San Francisco\",\n\t\tState: \"CA\",\n\t\tCountry: \"US\",\n\t\tPostalCode: \"94100\",\n\t\tLatitude: &lat,\n\t\tLongitude: &lng,\n\t}\n}", "func (agr *apiGatewayResource) Create(request *http.Request) (string, restful.Attributes, error) {\n\tctx := request.Context()\n\tapiGatewayInfo, err := agr.getAPIGatewayInfoFromRequest(request)\n\tif err != nil {\n\t\tagr.Logger.WarnWithCtx(ctx, \"Failed to get api gateway config and status from body\", \"err\", err)\n\t\treturn \"\", nil, err\n\t}\n\n\treturn agr.createAPIGateway(request, apiGatewayInfo)\n}", "func (idx *ExistsAddrIndex) Create(dbTx database.Tx) error {\n\t_, err := dbTx.Metadata().CreateBucket(existsAddrIndexKey)\n\treturn err\n}", "func (p *Poloniex) GenerateNewAddress(ctx context.Context, curr string) (string, error) {\n\ttype Response struct {\n\t\tSuccess int\n\t\tError string\n\t\tResponse string\n\t}\n\tresp := Response{}\n\tvalues := url.Values{}\n\tvalues.Set(\"currency\", curr)\n\n\terr := p.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, poloniexGenerateNewAddress, values, &resp)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif resp.Error != \"\" {\n\t\treturn \"\", errors.New(resp.Error)\n\t}\n\n\treturn resp.Response, nil\n}", "func (a *Account) NewAddress() (btcutil.Address, error) {\n\t// Get current block's height and hash.\n\tbs, err := GetCurBlock()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Get next address from wallet.\n\taddr, err := a.Wallet.NextChainedAddress(&bs, cfg.KeypoolSize)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Immediately write updated wallet to disk.\n\tAcctMgr.ds.ScheduleWalletWrite(a)\n\tif err := AcctMgr.ds.FlushAccount(a); err != nil {\n\t\treturn nil, fmt.Errorf(\"account write failed: %v\", err)\n\t}\n\n\t// Mark this new address as belonging to this account.\n\tAcctMgr.MarkAddressForAccount(addr, a)\n\n\t// Request updates from btcd for new transactions sent to this address.\n\ta.ReqNewTxsForAddress(addr)\n\n\treturn addr, nil\n}", "func CreateAsset(\n\ttrx storage.Transaction,\n\tissueTxId merkle.Digest,\n\tissueBlockNumber uint64,\n\tassetId transactionrecord.AssetIdentifier,\n\tnewOwner *account.Account,\n) {\n\t// ensure single threaded\n\ttoLock.Lock()\n\tdefer toLock.Unlock()\n\n\tnewData := &AssetOwnerData{\n\t\ttransferBlockNumber: issueBlockNumber,\n\t\tissueTxId: issueTxId,\n\t\tissueBlockNumber: issueBlockNumber,\n\t\tassetId: assetId,\n\t}\n\n\t// store to database\n\tcreate(trx, issueTxId, newData, newOwner)\n}", "func (_BaseFactory *BaseFactoryCaller) Creator(opts *bind.CallOpts) (common.Address, error) {\n\tvar out []interface{}\n\terr := _BaseFactory.contract.Call(opts, &out, \"creator\")\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "func (h *HitBTC) GenerateNewAddress(ctx context.Context, currency string) (DepositCryptoAddresses, error) {\n\tresp := DepositCryptoAddresses{}\n\terr := h.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost,\n\t\tapiV2CryptoAddress+\"/\"+currency,\n\t\turl.Values{},\n\t\totherRequests,\n\t\t&resp)\n\n\treturn resp, err\n}", "func (a *ApiDB) CreateContract(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tp := MODELS.CREATE_UPDATE_CONTRACT_REQUEST{}\n\terr := json.NewDecoder(r.Body).Decode(&p)\n\tif err != nil {\n\t\tio.WriteString(w, `{\"message\": \"wrong format!\"}`)\n\t\treturn\n\t}\n\n\tresult := BUSINESS.CreateContract(a.Db, p)\n\tif result {\n\t\tio.WriteString(w, ` { \"status\": 200,\n \"message\": \"Create contract success\",\n \"data\": {\n \"status\": 1\n }\n}\n`)\n\t} else {\n\t\tio.WriteString(w, `{ \"message\": \"Can’t create contract\"}`)\n\t}\n}", "func (addressManager *AddressManager) NewAddress() address.Address {\n\treturn addressManager.Address(addressManager.lastAddressIndex + 1)\n}", "func (w *WalletChaincode) create(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tif len(args) < 6 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting at least 2\")\n\t}\n\taddress := args[2]\n\taccountKey := buildAccountKey(address)\n\tif err := stub.PutState(accountKey, []byte(address)); err != nil {\n\t\treturn shim.Error(fmt.Sprintf(\"Error putting data for key [%s]: %s\", accountKey, err))\n\t}\n\tfmt.Println(\"create an account: \", accountKey)\n\n\twalletKey := buildWalletKey(args[0], args[1], address)\n\tif err := stub.PutState(walletKey, []byte(args[5])); err != nil {\n\t\treturn shim.Error(fmt.Sprintf(\"Error putting data for key [%s]: %s\", walletKey, err))\n\t}\n\tfmt.Println(\"create a wallet: \", walletKey)\n\n\t// seqBytes, err := stub.GetState(SEQUENCE)\n\t// if err != nil {\n\t// \treturn shim.Error(\"Failed to get state\")\n\t// }\n\t// if seqBytes == nil {\n\t// \treturn shim.Error(\"Entity not found\")\n\t// }\n\t// seq, _ := strconv.ParseInt(string(seqBytes), 10, 64)\n\tseq := atomic.AddUint64(&w.Sequence, 1)\n\tsequenceKey := buildSequenceKey(seq)\n\tjsonTx := \"{\\\"sequence\\\":\\\"\" + strconv.FormatUint(seq, 10) + \"\\\",\\\"txid\\\":\\\"\" + string(stub.GetTxID()) + \"\\\"}\"\n\tif err := stub.PutState(sequenceKey, []byte(jsonTx)); err != nil {\n\t\treturn shim.Error(fmt.Sprintf(\"Error putting data for key [%s]: %s\", walletKey, err))\n\t}\n\n\tfmt.Println(\"create success: \", stub.GetTxID())\n\treturn shim.Success([]byte(fmt.Sprintf(\"{\\\"wallet\\\":\\\"%s\\\", \\\"txid\\\":\\\"%s\\\"}\", walletKey, stub.GetTxID())))\n}", "func (_Editable *EditableCaller) Creator(opts *bind.CallOpts) (common.Address, error) {\n\tvar out []interface{}\n\terr := _Editable.contract.Call(opts, &out, \"creator\")\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "func (_BaseLibraryFactory *BaseLibraryFactoryCaller) Creator(opts *bind.CallOpts) (common.Address, error) {\n\tvar out []interface{}\n\terr := _BaseLibraryFactory.contract.Call(opts, &out, \"creator\")\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "func (f *Factory) Address() string { return f.address }", "func (pl *PaymentLink) Create(data map[string]interface{}, extraHeaders map[string]string) (map[string]interface{}, error) {\n\turl := fmt.Sprintf(\"/%s%s\", constants.VERSION_V1, constants.PaymentLink_URL)\n\treturn pl.Request.Post(url, data, extraHeaders)\n}", "func (s *Server) CreateContract(w http.ResponseWriter, r *http.Request) {\n\tvar reqData CreateContractRequest\n\tif err := json.NewDecoder(r.Body).Decode(&reqData); err != nil {\n\t\tweb.RespondError(w, r, s.logger, http.StatusInternalServerError, fmt.Errorf(\"decode request body: %w\", err))\n\t\treturn\n\t}\n\n\tif err := contract.CreateContract(r.Context(), s.dbc, reqData.NodePublicKey, reqData.EntityID); err != nil {\n\t\tweb.RespondError(w, r, s.logger, http.StatusInternalServerError, fmt.Errorf(\"create entity: %w\", err))\n\t\treturn\n\t}\n\n\tweb.Respond(w, r, s.logger, http.StatusCreated, nil)\n}", "func (_BaseLibrary *BaseLibraryCaller) Creator(opts *bind.CallOpts) (common.Address, error) {\n\tvar out []interface{}\n\terr := _BaseLibrary.contract.Call(opts, &out, \"creator\")\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "func CreateAsset(met metadata.MetaData, creator *Holder, sym string, name string, desc string) *Asset {\n\tout := Asset{\n\t\tMet: met.(*concrete_metadata.MetaData),\n\t\tCreator: creator,\n\t\tSym: sym,\n\t\tName: name,\n\t\tDesc: desc,\n\t}\n\n\treturn &out\n}", "func CreateAddress2(b types.Address, salt [32]byte, code []byte) types.Address {\n\treturn types.BytesToAddress(keccak.Keccak256([]byte{0xff}, b.Bytes(), salt[:], keccak.Keccak256(code))[12:])\n}", "func NewAccountAddress(\n\taccountConfiguration *signing.Configuration,\n\tkeyPath signing.RelativeKeypath,\n\tnet *chaincfg.Params,\n\tlog *logrus.Entry,\n) *AccountAddress {\n\n\tvar address btcutil.Address\n\tvar redeemScript []byte\n\tconfiguration, err := accountConfiguration.Derive(keyPath)\n\tif err != nil {\n\t\tlog.WithError(err).Panic(\"Failed to derive the configuration.\")\n\t}\n\tlog = log.WithFields(logrus.Fields{\n\t\t\"key-path\": configuration.AbsoluteKeypath().Encode(),\n\t\t\"configuration\": configuration.String(),\n\t})\n\tlog.Debug(\"Creating new account address\")\n\n\tpublicKeyHash := btcutil.Hash160(configuration.PublicKey().SerializeCompressed())\n\tswitch configuration.ScriptType() {\n\tcase signing.ScriptTypeP2PKH:\n\t\taddress, err = btcutil.NewAddressPubKeyHash(publicKeyHash, net)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Panic(\"Failed to get P2PKH addr. from public key hash.\")\n\t\t}\n\tcase signing.ScriptTypeP2WPKHP2SH:\n\t\tvar segwitAddress *btcutil.AddressWitnessPubKeyHash\n\t\tsegwitAddress, err = btcutil.NewAddressWitnessPubKeyHash(publicKeyHash, net)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Panic(\"Failed to get p2wpkh-p2sh addr. from publ. key hash.\")\n\t\t}\n\t\tredeemScript, err = txscript.PayToAddrScript(segwitAddress)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Panic(\"Failed to get redeem script for segwit address.\")\n\t\t}\n\t\taddress, err = btcutil.NewAddressScriptHash(redeemScript, net)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Panic(\"Failed to get a P2SH address for segwit.\")\n\t\t}\n\tcase signing.ScriptTypeP2WPKH:\n\t\taddress, err = btcutil.NewAddressWitnessPubKeyHash(publicKeyHash, net)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Panic(\"Failed to get p2wpkh addr. from publ. key hash.\")\n\t\t}\n\tcase signing.ScriptTypeP2TR:\n\t\toutputKey := txscript.ComputeTaprootKeyNoScript(configuration.PublicKey())\n\t\taddress, err = btcutil.NewAddressTaproot(schnorr.SerializePubKey(outputKey), net)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Panic(\"Failed to get p2tr addr\")\n\t\t}\n\tdefault:\n\t\tlog.Panic(fmt.Sprintf(\"Unrecognized script type: %s\", configuration.ScriptType()))\n\t}\n\n\treturn &AccountAddress{\n\t\tAddress: address,\n\t\tAccountConfiguration: accountConfiguration,\n\t\tConfiguration: configuration,\n\t\tredeemScript: redeemScript,\n\t\tlog: log,\n\t}\n}", "func (client *PublicIPAddressesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, publicIPAddressName string, parameters PublicIPAddress, options *PublicIPAddressesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif publicIPAddressName == \"\" {\n\t\treturn nil, errors.New(\"parameter publicIPAddressName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{publicIpAddressName}\", url.PathEscape(publicIPAddressName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func NewAddress(pk ctypes.PubKey) *Address {\n\ta := Address{pk}\n\treturn &a\n}", "func (s *SOC) Address() (swarm.Address, error) {\n\tif len(s.owner) != crypto.AddressSize {\n\t\treturn swarm.ZeroAddress, errInvalidAddress\n\t}\n\treturn CreateAddress(s.id, s.owner)\n}", "func (r *CompaniesService) Create(company *Company) *CompaniesCreateCall {\n\tc := &CompaniesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.company = company\n\treturn c\n}", "func CreateContract(rpcURL string, sk string, data []byte, gasPrice uint64, gasLimit uint64) (common.Hash, error) {\n\treturn SendTx(rpcURL, sk, \"\", 0, data, gasPrice, gasLimit)\n}", "func (b *Backend) NewAddress() wallet.Address {\n\taddr := Address{}\n\treturn &addr\n}", "func CreateP2SHAddress(c Currency, script []byte) (string, error) {\n\taddress := base58.CheckEncode(btcutil.Hash160(script), c.Chaincfg.ScriptHashAddrID)\n\treturn address, nil\n}", "func (c *Client) Create(ctx context.Context, p *CreatePayload) (res *Person, err error) {\n\tvar ires interface{}\n\tires, err = c.CreateEndpoint(ctx, p)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn ires.(*Person), nil\n}", "func NewAddress(city, state string) *Address {\n\treturn &Address{\n\t\tCity: city,\n\t\tState: state,\n\t}\n}", "func (s *Service) Create(newAccountDefinition *model.NewAccountDefinition) *CreateOp {\n\treturn &CreateOp{\n\t\tCredential: s.credential,\n\t\tMethod: \"POST\",\n\t\tPath: \"/v2/accounts\",\n\t\tPayload: newAccountDefinition,\n\t\tQueryOpts: make(url.Values),\n\t\tVersion: esign.APIv2,\n\t}\n}", "func (Interface *LineInterface) CreateWallet() {\n\twallets, _ := wallet.CreateWallets()\n\taddress := wallets.AddWallet()\n\twallets.SaveFile()\n\tfmt.Printf(\"NEW ADDRESS: %s\\n\", address)\n}", "func (planetDeliveryRest *PlanetDeliveryRest) Create(w http.ResponseWriter, r *http.Request) {\n\tvar planet entity.Planet\n\n\terr := json.NewDecoder(r.Body).Decode(&planet)\n\tif err != nil {\n\t\tError(w, \"Failed to decode JSON\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tplanetToInsert := *entity.NewPlanet(planet.Name, planet.Climate, planet.Terrain)\n\n\tnewPlanet, err := planetDeliveryRest.planetUsecase.Create(r.Context(), planetToInsert)\n\tif err != nil {\n\t\tError(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tJSON(w, newPlanet, http.StatusCreated)\n}", "func (s *serviceOutlite) EntityCreate(input *schemas.SchemaOutlet) (*models.ModelOutlet, schemas.SchemaDatabaseError) {\n\tvar outlet schemas.SchemaOutlet\n\toutlet.Name = input.Name\n\toutlet.Phone = input.Phone\n\toutlet.Address = input.Address\n\toutlet.MerchatID = input.MerchatID\n\n\tres, err := s.outlet.EntityCreate(&outlet)\n\treturn res, err\n}", "func (w *Wallet) NewAddress(account uint32,\n\tscope waddrmgr.KeyScope) (btcutil.Address, er.R) {\n\n\tchainClient, err := w.requireChainClient()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar (\n\t\taddr btcutil.Address\n\t\tprops *waddrmgr.AccountProperties\n\t)\n\terr = walletdb.Update(w.db, func(tx walletdb.ReadWriteTx) er.R {\n\t\taddrmgrNs := tx.ReadWriteBucket(waddrmgrNamespaceKey)\n\t\tvar err er.R\n\t\taddr, props, err = w.newAddress(addrmgrNs, account, scope)\n\t\treturn err\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Notify the rpc server about the newly created address.\n\terr = chainClient.NotifyReceived([]btcutil.Address{addr})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tw.NtfnServer.notifyAccountProperties(props)\n\n\treturn addr, nil\n}", "func CreateAddressScope(t *testing.T, client *gophercloud.ServiceClient) (*addressscopes.AddressScope, error) {\n\taddressScopeName := tools.RandomString(\"TESTACC-\", 8)\n\tcreateOpts := addressscopes.CreateOpts{\n\t\tName: addressScopeName,\n\t\tIPVersion: 4,\n\t}\n\n\tt.Logf(\"Attempting to create an address-scope: %s\", addressScopeName)\n\n\taddressScope, err := addressscopes.Create(client, createOpts).Extract()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tt.Logf(\"Successfully created the addressscopes.\")\n\n\tth.AssertEquals(t, addressScope.Name, addressScopeName)\n\tth.AssertEquals(t, addressScope.IPVersion, int(gophercloud.IPv4))\n\n\treturn addressScope, nil\n}", "func (lu *litUiClient) Address() (string, error) {\n\n\t// cointype of 0 means default, not mainnet.\n\t// this is ugly but does prevent mainnet use for now.\n\n\tvar cointype, numadrs uint32\n\n\t// if no arguments given, generate 1 new address.\n\t// if no cointype given, assume type 1 (testnet)\n\n\tnumadrs = 0\n\n\treply := new(litrpc.AddressReply)\n\n\targs := new(litrpc.AddressArgs)\n\targs.CoinType = cointype\n\targs.NumToMake = numadrs\n\n\tfmt.Printf(\"adr cointye: %d num:%d\\n\", args.CoinType, args.NumToMake)\n\terr := lu.rpccon.Call(\"LitRPC.Address\", args, reply)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tresponse := reply.WitAddresses[len(reply.WitAddresses)-1]\n\treturn response, nil\n}", "func (c *MyAssetContract) CreateMyAsset(ctx contractapi.TransactionContextInterface, myAssetID string, value string) error {\n\texists, err := c.MyAssetExists(ctx, myAssetID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Could not read from world state. %s\", err)\n\t} else if exists {\n\t\treturn fmt.Errorf(\"The asset %s already exists\", myAssetID)\n\t}\n\n\tmyAsset := new(MyAsset)\n\tmyAsset.Value = value\n\n\tbytes, _ := json.Marshal(myAsset)\n\n\treturn ctx.GetStub().PutState(myAssetID, bytes)\n}", "func (n *NetworkServiceHandler) Create(ctx context.Context, regionID, description, cidrBlock string) (*Network, error) {\n\n\turi := \"/v1/network/create\"\n\n\tvalues := url.Values{\n\t\t\"DCID\": {regionID},\n\t}\n\n\t// Optional\n\tif cidrBlock != \"\" {\n\t\t_, ipNet, err := net.ParseCIDR(cidrBlock)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif v4Subnet := ipNet.IP.To4(); v4Subnet != nil {\n\t\t\tvalues.Add(\"v4_subnet\", v4Subnet.String())\n\t\t}\n\t\tmask, _ := ipNet.Mask.Size()\n\t\tvalues.Add(\"v4_subnet_mask\", strconv.Itoa(mask))\n\t}\n\n\tif description != \"\" {\n\t\tvalues.Add(\"description\", description)\n\t}\n\n\treq, err := n.client.NewRequest(ctx, http.MethodPost, uri, values)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tnetwork := new(Network)\n\terr = n.client.DoWithContext(ctx, req, network)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn network, nil\n}", "func (_BaseContentFactory *BaseContentFactoryCaller) Creator(opts *bind.CallOpts) (common.Address, error) {\n\tvar out []interface{}\n\terr := _BaseContentFactory.contract.Call(opts, &out, \"creator\")\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "func (s *CheckoutServiceOp) Create(checkout Checkout) (*Checkout, error) {\n\tpath := fmt.Sprintf(\"%s.json\", checkoutsBasePath)\n\twrappedData := CheckoutResource{Checkout: &checkout}\n\tresource := new(CheckoutResource)\n\terr := s.client.Post(path, wrappedData, resource)\n\treturn resource.Checkout, err\n}", "func (vr *VirtualResource) Create(item VirtualServerConfig) error {\n\tif err := vr.c.ModQuery(\"POST\", BasePath+VirtualEndpoint, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func op_CREATE(pc *uint64, in *interpreter, ctx *callCtx) uint64 {\n\tstack := ctx.stack\n\n\tvalue, offset, size := stack.Pop(), stack.Pop(), stack.Pop()\n\tinput := ctx.memory.GetCopy(offset.Uint64(), size.Uint64())\n\n\tin.evm.create(ctx.contract, input, &value)\n\n\t// returned address from create\n\taddress := in.evm.create_addr.get(in.evm.level + 1)\n\n\taddr := new(uint256.Int).SetBytes(address.Bytes())\n\tstack.Push(addr)\n\n\treturn 0\n}", "func (wallet *Wallet) CreateAsset(asset Asset) (assetColor ledgerstate.Color, err error) {\n\tif asset.Amount == 0 {\n\t\terr = errors.New(\"required to provide the amount when trying to create an asset\")\n\n\t\treturn\n\t}\n\n\tif asset.Name == \"\" {\n\t\terr = errors.New(\"required to provide a name when trying to create an asset\")\n\n\t\treturn\n\t}\n\n\ttx, err := wallet.SendFunds(\n\t\tDestination(wallet.ReceiveAddress(), asset.Amount, ledgerstate.ColorMint),\n\t)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// this only works if there is only one MINT output in the transaction\n\tassetColor = ledgerstate.ColorIOTA\n\tfor _, output := range tx.Essence().Outputs() {\n\t\toutput.Balances().ForEach(func(color ledgerstate.Color, balance uint64) bool {\n\t\t\tif color == ledgerstate.ColorMint {\n\t\t\t\tdigest := blake2b.Sum256(output.ID().Bytes())\n\t\t\t\tassetColor, _, err = ledgerstate.ColorFromBytes(digest[:])\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\t}\n\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif assetColor != ledgerstate.ColorIOTA {\n\t\twallet.assetRegistry.RegisterAsset(assetColor, asset)\n\t}\n\n\treturn\n}", "func CreateReleaseEipSegmentAddressRequest() (request *ReleaseEipSegmentAddressRequest) {\n\trequest = &ReleaseEipSegmentAddressRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Vpc\", \"2016-04-28\", \"ReleaseEipSegmentAddress\", \"vpc\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (r *OrganizationsService) Create(googlecloudapigeev1organization *GoogleCloudApigeeV1Organization) *OrganizationsCreateCall {\n\tc := &OrganizationsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.googlecloudapigeev1organization = googlecloudapigeev1organization\n\treturn c\n}", "func (addressManager *AddressManager) Address(addressIndex uint64) address.Address {\n\t// update lastUnspentAddressIndex if necessary\n\taddressManager.spentAddressIndexes(addressIndex)\n\n\treturn addressManager.seed.Address(addressIndex)\n}", "func (client *Client) CreateSmartContract(contract *ContractConfiguration) (_ *Response, err error) {\n\tpath := \"/contract\"\n\turi := fmt.Sprintf(\"%s%s\", client.apiBaseURL, path)\n\tb, err := json.Marshal(contract)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp, err := client.httpClient.Post(uri, \"content/json\", bytes.NewBuffer(b))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer func() {\n\t\t_ = resp.Body.Close()\n\t}()\n\tvar statusMessage []byte\n\tstatusMessage, err = ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresponse := Response{\n\t\tResponse: statusMessage,\n\t\tStatus: resp.StatusCode,\n\t\tOK: 200 <= resp.StatusCode && 300 > resp.StatusCode,\n\t}\n\treturn &response, err\n}" ]
[ "0.660583", "0.65768284", "0.655611", "0.6459867", "0.6374091", "0.6367556", "0.6301462", "0.62489724", "0.62117654", "0.6106471", "0.60594046", "0.6023272", "0.60168755", "0.60069805", "0.5987559", "0.5911845", "0.5869427", "0.5815969", "0.5815888", "0.57545626", "0.57401866", "0.5701813", "0.56968653", "0.5658971", "0.5631528", "0.56228966", "0.5617451", "0.55719334", "0.5559565", "0.55457634", "0.5519083", "0.5495622", "0.5468455", "0.54226816", "0.54176146", "0.54170996", "0.54032004", "0.53940773", "0.53865725", "0.53764737", "0.5370866", "0.5368728", "0.53640395", "0.5359734", "0.5352188", "0.5339282", "0.5308125", "0.5307646", "0.5305161", "0.53004134", "0.52951604", "0.5278469", "0.52724963", "0.5253072", "0.5232919", "0.5230944", "0.5220084", "0.5212395", "0.5202409", "0.5187587", "0.5180557", "0.5173938", "0.517191", "0.5167127", "0.5162654", "0.5152753", "0.515256", "0.51474184", "0.5136245", "0.5133833", "0.51297957", "0.511852", "0.5117613", "0.51100665", "0.51089656", "0.51070434", "0.51015645", "0.5100754", "0.5087843", "0.50848246", "0.5080746", "0.5080233", "0.50756437", "0.50729704", "0.50721425", "0.50693136", "0.5065623", "0.5064168", "0.50636464", "0.5062529", "0.5057743", "0.5055746", "0.50496346", "0.504041", "0.50402397", "0.5030658", "0.502603", "0.5025736", "0.5023435", "0.5022829" ]
0.81269246
0
GetActive will get all active addresses for an asset
GetActive получит все активные адреса для актива
func (as *AddressService) GetActive() ([]*Address, error) { return as.getAddresses("deposit") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *AccountsListCall) Active(active bool) *AccountsListCall {\n\tc.urlParams_.Set(\"active\", fmt.Sprint(active))\n\treturn c\n}", "func (w *Wallet) activeData(dbtx walletdb.ReadTx) ([]btcutil.Address, []wtxmgr.Credit, er.R) {\n\taddrmgrNs := dbtx.ReadBucket(waddrmgrNamespaceKey)\n\ttxmgrNs := dbtx.ReadBucket(wtxmgrNamespaceKey)\n\n\tvar addrs []btcutil.Address\n\terr := w.Manager.ForEachActiveAddress(addrmgrNs, func(addr btcutil.Address) er.R {\n\t\taddrs = append(addrs, addr)\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tunspent, err := w.TxStore.GetUnspentOutputs(txmgrNs)\n\treturn addrs, unspent, err\n}", "func (c *AdsListCall) Active(active bool) *AdsListCall {\n\tc.urlParams_.Set(\"active\", fmt.Sprint(active))\n\treturn c\n}", "func (c *CreativesListCall) Active(active bool) *CreativesListCall {\n\tc.urlParams_.Set(\"active\", fmt.Sprint(active))\n\treturn c\n}", "func (a *Account) ActivePaymentAddresses() map[string]struct{} {\n\tinfos := a.KeyStore.ActiveAddresses()\n\n\taddrs := make(map[string]struct{}, len(infos))\n\tfor _, info := range infos {\n\t\taddrs[info.Address().EncodeAddress()] = struct{}{}\n\t}\n\n\treturn addrs\n}", "func (a *Account) ActivePaymentAddresses() map[string]struct{} {\n\tinfos := a.ActiveAddresses()\n\n\taddrs := make(map[string]struct{}, len(infos))\n\tfor _, info := range infos {\n\t\taddrs[info.Address().EncodeAddress()] = struct{}{}\n\t}\n\n\treturn addrs\n}", "func ActiveAddresses() map[string]net.Interface {\n\tresult := make(map[string]net.Interface)\n\tif iFaces, err := net.Interfaces(); err == nil {\n\t\tfor _, iFace := range iFaces {\n\t\t\tconst interesting = net.FlagUp | net.FlagBroadcast\n\t\t\tif iFace.Flags&interesting == interesting {\n\t\t\t\tif name := Address(iFace); name != \"\" {\n\t\t\t\t\tresult[name] = iFace\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn result\n}", "func (k Keeper) GetActiveValidatorList(ctx sdk.Context) ([]sdk.AccAddress, error) {\n\tvar result []sdk.AccAddress\n\tstore := ctx.KVStore(k.dataStoreKey)\n\tit := store.Iterator(nil, nil)\n\tdefer it.Close()\n\tfor ; it.Valid(); it.Next() {\n\t\tvar value types.Info\n\t\tif err := proto.Unmarshal(it.Value(), &value); err != nil {\n\t\t\tpanic(errors.Wrap(err, \"cannot unmarshal info\"))\n\t\t}\n\t\tif !value.IsActive() {\n\t\t\tcontinue\n\t\t}\n\t\taddr := sdk.AccAddress(it.Key())\n\t\tresult = append(result, addr)\n\t}\n\n\treturn result, nil\n}", "func (c *RemarketingListsListCall) Active(active bool) *RemarketingListsListCall {\n\tc.urlParams_.Set(\"active\", fmt.Sprint(active))\n\treturn c\n}", "func (eth *Eth) ActiveAddress() string {\n\tkeypair := eth.keyManager.KeyPair()\n\taddr := ethutil.Bytes2Hex(keypair.Address())\n\treturn addr\n}", "func (mod *EthModule) ActiveAddress() string {\n\treturn mod.eth.ActiveAddress()\n}", "func (c *TargetableRemarketingListsListCall) Active(active bool) *TargetableRemarketingListsListCall {\n\tc.urlParams_.Set(\"active\", fmt.Sprint(active))\n\treturn c\n}", "func (am *AccountManager) RescanActiveAddresses() error {\n\tvar job *RescanJob\n\tfor _, a := range am.AllAccounts() {\n\t\tacctJob, err := a.RescanActiveJob()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif job == nil {\n\t\t\tjob = acctJob\n\t\t} else {\n\t\t\tjob.Merge(acctJob)\n\t\t}\n\t}\n\tif job != nil {\n\t\t// Submit merged job and block until rescan completes.\n\t\tjobFinished := am.rm.SubmitJob(job)\n\t\t<-jobFinished\n\t}\n\n\treturn nil\n}", "func (v Account) GetActiveOffers(params AccountGetActiveOffersParams) (*AccountGetActiveOffersResponse, error) {\n\tr, err := v.API.Request(\"account.getActiveOffers\", params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar resp AccountGetActiveOffersResponse\n\terr = json.Unmarshal(r, &resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resp, nil\n}", "func (o *InlineResponse20075StatsBilling) GetActive() string {\n\tif o == nil || o.Active == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Active\n}", "func (cluster *HttpCluster) Active() []string {\n\tcluster.RLock()\n\tdefer cluster.RUnlock()\n\tmember := cluster.active\n\tlist := make([]string, 0)\n\tfor i := 0; i < cluster.size; i++ {\n\t\tif member.status == MEMBER_AVAILABLE {\n\t\t\tlist = append(list, member.hostname)\n\t\t}\n\t}\n\treturn list\n}", "func (_NodeSpace *NodeSpaceCaller) ActiveNodeAddresses(opts *bind.CallOpts, arg0 *big.Int) (common.Address, error) {\n\tvar out []interface{}\n\terr := _NodeSpace.contract.Call(opts, &out, \"activeNodeAddresses\", arg0)\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "func (_BaseContentSpace *BaseContentSpaceCaller) ActiveNodeAddresses(opts *bind.CallOpts, arg0 *big.Int) (common.Address, error) {\n\tvar out []interface{}\n\terr := _BaseContentSpace.contract.Call(opts, &out, \"activeNodeAddresses\", arg0)\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "func (c *DirectorySitesListCall) Active(active bool) *DirectorySitesListCall {\n\tc.urlParams_.Set(\"active\", fmt.Sprint(active))\n\treturn c\n}", "func (a *Account) SortedActivePaymentAddresses() []string {\n\tinfos := a.KeyStore.SortedActiveAddresses()\n\n\taddrs := make([]string, len(infos))\n\tfor i, info := range infos {\n\t\taddrs[i] = info.Address().EncodeAddress()\n\t}\n\n\treturn addrs\n}", "func (r Virtual_Guest) GetActiveTransactions() (resp []datatypes.Provisioning_Version1_Transaction, err error) {\n\terr = r.Session.DoRequest(\"SoftLayer_Virtual_Guest\", \"getActiveTransactions\", nil, &r.Options, &resp)\n\treturn\n}", "func (qs InstantprofileQS) ActiveGe(v bool) InstantprofileQS {\n\treturn qs.filter(`\"active\" >=`, v)\n}", "func (a *Account) SortedActivePaymentAddresses() []string {\n\tinfos := a.Wallet.SortedActiveAddresses()\n\n\taddrs := make([]string, len(infos))\n\tfor i, info := range infos {\n\t\taddrs[i] = info.Address().EncodeAddress()\n\t}\n\n\treturn addrs\n}", "func (o *Swapspace) GetActive(ctx context.Context) (active bool, err error) {\n\terr = o.object.CallWithContext(ctx, \"org.freedesktop.DBus.Properties.Get\", 0, InterfaceSwapspace, \"Active\").Store(&active)\n\treturn\n}", "func (rs *rootResolver) AccountsActive() (hexutil.Uint64, error) {\n\treturn repository.R().AccountsActive()\n}", "func (s *Pool) getActive(key interface{}) (*GroupInstance, bool) {\n\tactive, exists := s.actives.Load(key)\n\tif !exists {\n\t\treturn nil, false\n\t} else {\n\t\tins := active.(*GroupInstance)\n\t\treturn ins, !ins.IsRetired()\n\t}\n}", "func (svc *inmemService) GetAddresses(ctx context.Context, profileID string) ([]Address, error) {\n\n\t// Get a Read Lock on the svc for atomic read access to the datastore\n\tsvc.mtx.RLock()\n\n\t// Immediately set up a lock release to occur when the function finishes\n\tdefer svc.mtx.RUnlock()\n\n\t// Check to make sure there is a profile that corresponds to the passed in profile and save the found profile to a profile variable\n\tprofile, ok := svc.profiles[profileID]\n\n\t// If no profile was found for the passed in ID\n\tif !ok {\n\n\t\t// Return error informing the caller that the profile to which the addresses should have been associated was not found\n\t\treturn nil, ErrNotFound\n\t}\n\n\t// Return all addresses associated with the profile that was passed in and a nil error value\n\treturn profile.Addresses, nil\n}", "func (c Calendars) Active() Calendars {\n\tcals := make(Calendars)\n\tfor k, cal := range c {\n\t\tif cal.active {\n\t\t\tcals[k] = cal\n\t\t}\n\t}\n\treturn cals\n}", "func (s *Identity) AccountsGET(w http.ResponseWriter, r *http.Request) {\n\ts.mu.RLock()\n\tdefer s.mu.RUnlock()\n\twriteResponse(s.addresses, w, r)\n}", "func (a *addrBook) getAddresses() []*addrInfo {\n\ta.mu.Lock()\n\tdefer a.mu.Unlock()\n\n\taddrIndexLen := len(a.addrIndex)\n\tif addrIndexLen == 0 {\n\t\treturn nil\n\t}\n\n\taddrs := make([]*addrInfo, 0, addrIndexLen)\n\tfor _, v := range a.addrIndex {\n\t\taddrs = append(addrs, v.Addr)\n\t}\n\n\treturn addrs\n}", "func (o ServiceEmailsOnPushOutput) Active() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v *ServiceEmailsOnPush) pulumi.BoolOutput { return v.Active }).(pulumi.BoolOutput)\n}", "func (c Client) GetActiveListings() {\n\tc.makeGetRequest(\"listings/active\")\n}", "func (config *Config) GetActive() *CacheConfig {\n\tactive := config.GetActiveProfile()\n\n\tInitDevSpaceConfig(config, active)\n\treturn config.Profiles[active]\n}", "func (t *Tracer) GetActiveConnections(_ string) (*network.Connections, error) {\n\treturn nil, ebpf.ErrNotImplemented\n}", "func (c *AccountUserProfilesListCall) Active(active bool) *AccountUserProfilesListCall {\n\tc.urlParams_.Set(\"active\", fmt.Sprint(active))\n\treturn c\n}", "func (us *UserService) GetAllActive(ctx context.Context) ([]user.User, error) {\n\tctx, cancel := context.WithTimeout(ctx, waitTime*time.Second)\n\tdefer cancel()\n\n\tusers, err := us.repository.GetAllActive(ctx)\n\tif err != nil {\n\t\tus.log.Error(err)\n\t\treturn nil, err\n\t}\n\n\treturn users, nil\n}", "func (r Virtual_Guest) GetActiveTransaction() (resp datatypes.Provisioning_Version1_Transaction, err error) {\n\terr = r.Session.DoRequest(\"SoftLayer_Virtual_Guest\", \"getActiveTransaction\", nil, &r.Options, &resp)\n\treturn\n}", "func (o *CommitteeInfoResponse) GetActive() bool {\n\tif o == nil {\n\t\tvar ret bool\n\t\treturn ret\n\t}\n\n\treturn o.Active\n}", "func (c *Contract) IsActive() bool {\n\treturn c.Status == \"Active\"\n}", "func (c *Controller) ActiveOffers() http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\toffers, err := c.offerService.Active()\n\n\t\tif err != nil {\n\t\t\trespond(w, r, http.StatusInternalServerError, ErrProcessingFailed.Error())\n\t\t\treturn\n\t\t}\n\n\t\trespond(w, r, http.StatusOK, offers)\n\t\treturn\n\t}\n}", "func (o *InlineResponse20075StatsBilling) SetActive(v string) {\n\to.Active = &v\n}", "func (qs InstantprofileQS) ActiveEq(v bool) InstantprofileQS {\n\treturn qs.filter(`\"active\" =`, v)\n}", "func (o *RuleActionStore) GetActive() bool {\n\tif o == nil || o.Active == nil {\n\t\tvar ret bool\n\t\treturn ret\n\t}\n\treturn *o.Active\n}", "func (acn *Account) Active() bool {\n\treturn acn.active\n}", "func (w *Wallet) SortedActivePaymentAddresses() ([]string, er.R) {\n\tvar addrStrs []string\n\terr := walletdb.View(w.db, func(tx walletdb.ReadTx) er.R {\n\t\taddrmgrNs := tx.ReadBucket(waddrmgrNamespaceKey)\n\t\treturn w.Manager.ForEachActiveAddress(addrmgrNs, func(addr btcutil.Address) er.R {\n\t\t\taddrStrs = append(addrStrs, addr.EncodeAddress())\n\t\t\treturn nil\n\t\t})\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tsort.Strings(addrStrs)\n\treturn addrStrs, nil\n}", "func (h *HitBTC) GetActiveorders(ctx context.Context, currency string) ([]Order, error) {\n\tvar resp []Order\n\terr := h.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet,\n\t\torders+\"?symbol=\"+currency,\n\t\turl.Values{},\n\t\ttradingRequests,\n\t\t&resp)\n\n\treturn resp, err\n}", "func (as *AddressService) GetSaved() ([]*Address, error) {\n\treturn as.getAddresses(\"withdraw\")\n}", "func (la *leastActive) Get(ctx context.Context, opts grpc.BalancerGetOptions) (addr grpc.Address, put func(), err error) {\n\n\tvar ch chan struct{}\n\tla.mu.Lock()\n\tif la.done {\n\t\tla.mu.Unlock()\n\t\terr = grpc.ErrClientConnClosing\n\t\treturn\n\t}\n\n\tif len(la.addrs) > 0 {\n\t\tif la.next >= len(la.addrs) {\n\t\t\tla.next = 0\n\t\t}\n\t\tnext := la.next\n\t\tfor {\n\t\t\ta := la.addrs[next]\n\t\t\tnext = la.getNext()\n\t\t\tif a.Connected {\n\t\t\t\taddr = a.Addr\n\t\t\t\tla.next = next\n\t\t\t\ta.AddActive()\n\t\t\t\tput = func() {\n\t\t\t\t\ta.Lock()\n\t\t\t\t\ta.SubActive()\n\t\t\t\t\ta.UnLock()\n\t\t\t\t\tfmt.Println(\"rpc call return\")\n\t\t\t\t}\n\t\t\t\tla.mu.Unlock()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif next == la.next {\n\t\t\t\t// Has iterated all the possible address but none is connected.\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tif !opts.BlockingWait {\n\t\tif len(la.addrs) == 0 {\n\t\t\tla.mu.Unlock()\n\t\t\terr = grpc.Errorf(codes.Unavailable, \"there is no address available\")\n\t\t\treturn\n\t\t}\n\n\t\t// Returns the next addr on la.addrs for failfast RPCs.\n\t\taddr = la.addrs[la.next].Addr\n\t\tla.addrs[la.next].AddActive()\n\t\tput = func() {\n\t\t\tla.addrs[la.next].Lock()\n\t\t\tla.addrs[la.next].SubActive()\n\t\t\tla.addrs[la.next].UnLock()\n\t\t\tfmt.Println(\"rpc call return\")\n\t\t}\n\t\tla.next = la.getNext()\n\t\tla.mu.Unlock()\n\t\tfmt.Println(\"return2:\", addr.Addr)\n\t\treturn\n\t}\n\t// Wait on la.waitCh for non-failfast RPCs.\n\tif la.waitCh == nil {\n\t\tch = make(chan struct{})\n\t\tla.waitCh = ch\n\t} else {\n\t\tch = la.waitCh\n\t}\n\tla.mu.Unlock()\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\terr = ctx.Err()\n\t\t\treturn\n\t\tcase <-ch:\n\t\t\tla.mu.Lock()\n\t\t\tif la.done {\n\t\t\t\tla.mu.Unlock()\n\t\t\t\terr = grpc.ErrClientConnClosing\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif len(la.addrs) > 0 {\n\n\t\t\t\tif la.next >= len(la.addrs) {\n\t\t\t\t\tla.next = 0\n\t\t\t\t}\n\t\t\t\tnext := la.next\n\t\t\t\tfor {\n\t\t\t\t\ta := la.addrs[next]\n\t\t\t\t\tnext = la.getNext()\n\t\t\t\t\tif a.Connected {\n\t\t\t\t\t\taddr = a.Addr\n\t\t\t\t\t\tla.next = next\n\t\t\t\t\t\ta.AddActive()\n\t\t\t\t\t\tput = func() {\n\t\t\t\t\t\t\ta.Lock()\n\t\t\t\t\t\t\ta.SubActive()\n\t\t\t\t\t\t\ta.UnLock()\n\t\t\t\t\t\t\tfmt.Println(\"rpc call return\")\n\t\t\t\t\t\t}\n\t\t\t\t\t\tla.mu.Unlock()\n\t\t\t\t\t\tfmt.Println(\"return3:\", addr.Addr)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tif next == la.next {\n\t\t\t\t\t\t// Has iterated all the possible address but none is connected.\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// The newly added addr got removed by Down() again.\n\t\t\tif la.waitCh == nil {\n\t\t\t\tch = make(chan struct{})\n\t\t\t\tla.waitCh = ch\n\t\t\t} else {\n\t\t\t\tch = la.waitCh\n\t\t\t}\n\t\t\tla.mu.Unlock()\n\t\t}\n\t}\n}", "func ActiveScan(urls,apis string, options OptionsZAP){\n\tRun(urls,apis,AScanAPI, options)\n}", "func (q *Queue) ActiveTools() map[string]common.Tool {\n\tq.RLock()\n\tdefer q.RUnlock()\n\n\t// Cycle through all the attached resources for unique tools\n\tvar tools = make(map[string]common.Tool)\n\tfor _, res := range q.pool {\n\t\t// Check if the tool is active for jobs (AKA running or paused)\n\t\tif res.Status != common.STATUS_QUIT {\n\t\t\t// Resource is paused or running so get the tools it provides\n\t\t\tfor uuid, t := range res.Tools {\n\t\t\t\t// Check if tool already exists in the tools map\n\t\t\t\t_, ok := tools[uuid]\n\t\t\t\tif !ok {\n\t\t\t\t\t// Tool doesn't exit already so add it\n\t\t\t\t\ttools[uuid] = t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn tools\n}", "func GetAll(query map[string]int64) ([]Models.Agent, error) {\n\tvar agents []Models.Agent\n\n\tqueryAgent := `\n\t\tSELECT agent.id, agent.code AS code, agent.name AS name, \n\t\tcontact.city_id AS city_id, contact.country_id AS country_id, \n\t\tcity.name AS city_name, country.name AS country_name\n\t\tFROM companies AS agent\n\t\tLEFT JOIN contacts AS contact ON contact.id = agent.contact_id\n\t\tLEFT JOIN cities AS city ON city.id = contact.city_id\n\t\tLEFT JOIN countries AS country ON country.id = contact.country_id\n\t\tWHERE agent.status = 'ACTIVE' and agent.company_type_id = $1\n\t`\n\trows, err := dbMod.DB.Query(queryAgent, query[\"type\"])\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn nil, err\n\t}\n\tfor rows.Next() {\n\t\tvar agent Models.Agent\n\n\t\tif err = rows.Scan(\n\t\t\t&agent.ID, &agent.Code, &agent.Name, &agent.CityID,\n\t\t\t&agent.CountryID, &agent.CityName, &agent.CountryName,\n\t\t); err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\tagents = append(agents, agent)\n\t}\n\n\treturn agents, nil\n}", "func (a *addrBook) getAddresses() []*node.Info {\n\ta.mtx.Lock()\n\tdefer a.mtx.Unlock()\n\n\taddrIndexLen := len(a.addrIndex)\n\tif addrIndexLen == 0 {\n\t\treturn nil\n\t}\n\n\taddrs := make([]*node.Info, 0, addrIndexLen)\n\tfor _, v := range a.addrIndex {\n\t\taddrs = append(addrs, v.na)\n\t}\n\n\treturn addrs\n}", "func (o JobStatusPtrOutput) Active() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v JobStatus) *int { return v.Active }).(pulumi.IntPtrOutput)\n}", "func GetAllAddresses() []*AddressDAL {\n\taddresses := []*AddressDAL{}\n\tdb.DB().Find(&addresses)\n\treturn addresses\n}", "func (_UsersData *UsersDataFilterer) FilterOnSetActive(opts *bind.FilterOpts) (*UsersDataOnSetActiveIterator, error) {\n\n\tlogs, sub, err := _UsersData.contract.FilterLogs(opts, \"onSetActive\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &UsersDataOnSetActiveIterator{contract: _UsersData.contract, event: \"onSetActive\", logs: logs, sub: sub}, nil\n}", "func (a Accounts) Get(asset string) *Account {\n\tfor i := range a.Datas {\n\t\tif a.Datas[i].Balance.Currency == asset {\n\t\t\treturn &a.Datas[i]\n\t\t}\n\t}\n\treturn nil\n}", "func (c *CoordinatorHelper) AllAddresses(\n\tctx context.Context,\n\tdbTx storage.DatabaseTransaction,\n) ([]string, error) {\n\treturn c.keyStorage.GetAllAddressesTransactional(ctx, dbTx)\n}", "func Active(nomad *NomadServer, job *Job, host *Host) bool {\n\tallocs := Allocs(nomad)\n\tfor _, alloc := range allocs {\n\t\tif alloc.NodeID == host.ID && strings.Contains(alloc.Name, job.Name) {\n\t\t\tif alloc.DesiredStatus != \"stop\" && strings.Contains(alloc.Name, \"worker\") {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}", "func (p *Poloniex) GetActiveLoans(ctx context.Context) (ActiveLoans, error) {\n\tresult := ActiveLoans{}\n\treturn result, p.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, poloniexActiveLoans, url.Values{}, &result)\n}", "func Active() bool {\n\treturn isActive\n}", "func GetActiveAttrib(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *uint8) {\n\tsyscall.Syscall9(gpGetActiveAttrib, 7, uintptr(program), uintptr(index), uintptr(bufSize), uintptr(unsafe.Pointer(length)), uintptr(unsafe.Pointer(size)), uintptr(unsafe.Pointer(xtype)), uintptr(unsafe.Pointer(name)), 0, 0)\n}", "func Activate(options MetadataOptions, context *Context) (*http.Response, error) {\n\tvar (\n\t\tassetMetadata *model.PlanetAssetMetadata\n\t\terr error\n\t)\n\tif assetMetadata, err = GetPlanetAssets(options, context); err != nil {\n\t\treturn nil, err\n\t}\n\treturn planetRequest(planetRequestInput{method: \"POST\", inputURL: assetMetadata.ActivationURL.String()}, context)\n}", "func (w *Wallet) AllAddress() []string {\n\tadrs := make([]string, 0, len(w.AddressChange)+len(w.AddressPublic))\n\tfor adr := range w.AddressChange {\n\t\tadrs = append(adrs, adr)\n\t}\n\tfor adr := range w.AddressPublic {\n\t\tadrs = append(adrs, adr)\n\t}\n\treturn adrs\n}", "func (ids identities) getAddresses() []common.Address {\n\taddresses := make([]common.Address, len(ids))\n\tfor i := 0; i < len(ids); i++ {\n\t\taddresses[i] = ids[i].addr\n\t}\n\treturn addresses\n}", "func (o JobStatusOutput) Active() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v JobStatus) *int { return v.Active }).(pulumi.IntPtrOutput)\n}", "func GetActiveReports() []Report {\n\treturn reports\n}", "func (s *SmartContract) GetAllAssets(ctx contractapi.TransactionContextInterface) ([]*Asset, error) {\n\t// range query with empty string for startKey and endKey does an\n\t// open-ended query of all assets in the chaincode namespace.\n\tresultsIterator, err := ctx.GetStub().GetStateByRange(\"\", \"\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resultsIterator.Close()\n\n\tvar assets []*Asset\n\tfor resultsIterator.HasNext() {\n\t\tqueryResponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvar asset Asset\n\t\terr = json.Unmarshal(queryResponse.Value, &asset)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tassets = append(assets, &asset)\n\t}\n\n\treturn assets, nil\n}", "func (c Calendars) dumpActive() error {\n\tpath, err := c.configPath()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tactive := make([]string, 0, len(c))\n\tfor id, cal := range c {\n\t\tif cal.active {\n\t\t\tactive = append(active, id)\n\t\t}\n\t}\n\n\treturn writeLines(active, path)\n}", "func GetActiveAttrib(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *uint8) {\n\tC.glowGetActiveAttrib(gpGetActiveAttrib, (C.GLuint)(program), (C.GLuint)(index), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLint)(unsafe.Pointer(size)), (*C.GLenum)(unsafe.Pointer(xtype)), (*C.GLchar)(unsafe.Pointer(name)))\n}", "func GetActiveAttrib(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *uint8) {\n\tC.glowGetActiveAttrib(gpGetActiveAttrib, (C.GLuint)(program), (C.GLuint)(index), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLint)(unsafe.Pointer(size)), (*C.GLenum)(unsafe.Pointer(xtype)), (*C.GLchar)(unsafe.Pointer(name)))\n}", "func (e Endpoints) GetAddresses(ctx context.Context, profileID string) ([]Address, error) {\n\n\t// TODO: Create detailed ref spec\n\trequest := getAddressesRequest{ProfileID: profileID}\n\n\tresponse, err := e.GetAddressesEndpoint(ctx, request)\n\n\tif err != nil {\n\t\treturn []Address{}, nil\n\t}\n\n\tresp := response.(getAddressesResponse)\n\n\treturn resp.Addresses, resp.Err\n\n}", "func GetQueryActiveValidators(route string, cdc *codec.Codec) *cobra.Command {\n\treturn &cobra.Command{\n\t\tUse: \"active-validators\",\n\t\tArgs: cobra.NoArgs,\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tcliCtx := context.NewCLIContext().WithCodec(cdc)\n\t\t\tbz, _, err := cliCtx.Query(fmt.Sprintf(\"custom/%s/%s\", route, types.QueryActiveValidators))\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn printOutput(cliCtx, cdc, bz, &[]types.QueryActiveValidatorResult{})\n\t\t},\n\t}\n}", "func (program Program) GetActiveAttributes() int32 {\n\tvar params int32\n\tgl.GetProgramiv(uint32(program), gl.ACTIVE_ATTRIBUTES, &params)\n\treturn params\n}", "func GetCmdQueryActive(queryRoute string, cdc *codec.Codec) *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: oracle.QueryActive,\n\t\tArgs: cobra.NoArgs,\n\t\tShort: \"Query the active list of Terra assets recognized by the oracle\",\n\t\tLong: strings.TrimSpace(`\nQuery the active list of Terra assets recognized by the oracle.\n\n$ terracli query oracle active\n`),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tcliCtx := context.NewCLIContext().WithCodec(cdc)\n\n\t\t\tres, err := cliCtx.QueryWithData(fmt.Sprintf(\"custom/%s/%s\", queryRoute, oracle.QueryActive), nil)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tvar actives oracle.QueryActiveResponse\n\t\t\tcdc.MustUnmarshalJSON(res, &actives)\n\t\t\treturn cliCtx.PrintOutput(actives)\n\t\t},\n\t}\n\n\treturn cmd\n}", "func (o *CommitteeInfoResponse) SetActive(v bool) {\n\to.Active = v\n}", "func (c *Client) SiteActiveClients(site string, filterMac string) (*SiteActiveClientsResponse, error) {\n\textPath := \"stat/sta\"\n\tif filterMac != \"\" {\n\t\textPath = extPath + \"/\" + strings.ToLower(filterMac)\n\t}\n\n\tvar resp SiteActiveClientsResponse\n\terr := c.doSiteRequest(http.MethodGet, site, extPath, nil, &resp)\n\treturn &resp, err\n}", "func (pg *PGStorage) GetAddresses(sql string, args ...interface{}) ([]*Address, error) {\n\tsql = \"SELECT id, updated_at, hash, income, outcome, ballance FROM address \" + sql\n\n\trows, err := pg.con.Query(sql, args)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\taddresses := make([]*Address, 0)\n\n\tfor rows.Next() {\n\t\ta := &Address{}\n\t\tif err := rows.Scan(\n\t\t\t&a.ID,\n\t\t\t&a.UpdatedAt,\n\t\t\t&a.Hash,\n\t\t\t&a.Income,\n\t\t\t&a.Outcome,\n\t\t\t&a.Ballance,\n\t\t); err != nil {\n\t\t\treturn addresses, err\n\t\t}\n\t\taddresses = append(addresses, a)\n\t}\n\treturn addresses, err\n}", "func (_Posminer *PosminerCaller) ActiveUsers(opts *bind.CallOpts) (struct {\n\tLastTime *big.Int\n\tActiveNum *big.Int\n}, error) {\n\tret := new(struct {\n\t\tLastTime *big.Int\n\t\tActiveNum *big.Int\n\t})\n\tout := ret\n\terr := _Posminer.contract.Call(opts, out, \"ActiveUsers\")\n\treturn *ret, err\n}", "func GetActiveAttrib(program Uint, index Uint, bufSize Sizei, length *Sizei, size *Int, kind *Enum, name []byte) {\n\tcprogram, _ := (C.GLuint)(program), cgoAllocsUnknown\n\tcindex, _ := (C.GLuint)(index), cgoAllocsUnknown\n\tcbufSize, _ := (C.GLsizei)(bufSize), cgoAllocsUnknown\n\tclength, _ := (*C.GLsizei)(unsafe.Pointer(length)), cgoAllocsUnknown\n\tcsize, _ := (*C.GLint)(unsafe.Pointer(size)), cgoAllocsUnknown\n\tckind, _ := (*C.GLenum)(unsafe.Pointer(kind)), cgoAllocsUnknown\n\tcname, _ := (*C.GLchar)(unsafe.Pointer((*sliceHeader)(unsafe.Pointer(&name)).Data)), cgoAllocsUnknown\n\tC.glGetActiveAttrib(cprogram, cindex, cbufSize, clength, csize, ckind, cname)\n}", "func (c *Component) GetActive() bool {\n\treturn c.active\n}", "func Active() bool {\n\treturn DefaultTracer.Active()\n}", "func (o GoogleCloudRetailV2alphaConditionOutput) ActiveTimeRange() GoogleCloudRetailV2alphaConditionTimeRangeArrayOutput {\n\treturn o.ApplyT(func(v GoogleCloudRetailV2alphaCondition) []GoogleCloudRetailV2alphaConditionTimeRange {\n\t\treturn v.ActiveTimeRange\n\t}).(GoogleCloudRetailV2alphaConditionTimeRangeArrayOutput)\n}", "func (o GoogleCloudRetailV2alphaConditionPtrOutput) ActiveTimeRange() GoogleCloudRetailV2alphaConditionTimeRangeArrayOutput {\n\treturn o.ApplyT(func(v *GoogleCloudRetailV2alphaCondition) []GoogleCloudRetailV2alphaConditionTimeRange {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.ActiveTimeRange\n\t}).(GoogleCloudRetailV2alphaConditionTimeRangeArrayOutput)\n}", "func GetActiveAttrib(p Program, index uint32) (name string, size int, ty Enum) {\n\tvar length, si int32\n\tvar typ uint32\n\tname = strings.Repeat(\"\\x00\", 256)\n\tcname := gl.Str(name)\n\tgl.GetActiveAttrib(p.Value, uint32(index), int32(len(name)-1), &length, &si, &typ, cname)\n\tname = name[:strings.IndexRune(name, 0)]\n\treturn name, int(si), Enum(typ)\n}", "func (cli *CLI) listAddresses() {\n\twallets, _ := wallet.CreateWallets()\n\tfor address := range wallets {\n\t\tfmt.Println(address)\n\t}\n}", "func (o *AllocationList) GetCashActive() float64 {\n\tif o == nil {\n\t\tvar ret float64\n\t\treturn ret\n\t}\n\n\treturn o.CashActive\n}", "func (as *AddressbookService) GetUserAddresses(id string) ([]models.Address, error) {\n\treturn as.repo.GetUserAddresses(id)\n}", "func (ws *Wallets) GetAddresses() []string {\n\tvar addresses []string\n\n\tfor address := range ws.Wallets {\n\t\taddresses = append(addresses, address)\n\t}\n\n\treturn addresses\n}", "func (o *InlineResponse20075StatsBilling) HasActive() bool {\n\tif o != nil && o.Active != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (log *inMemorySagaLog) GetActiveSagas() ([]string, error) {\n\tlog.mutex.RLock()\n\tdefer log.mutex.RUnlock()\n\n\tkeys := make([]string, 0, len(log.sagas))\n\n\tfor key, _ := range log.sagas {\n\t\tkeys = append(keys, key)\n\t}\n\n\treturn keys, nil\n}", "func (s UserSet) Active() bool {\n\tres, _ := s.RecordCollection.Get(models.NewFieldName(\"Active\", \"active\")).(bool)\n\treturn res\n}", "func (o IntegrationEmailsOnPushOutput) Active() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v *IntegrationEmailsOnPush) pulumi.BoolOutput { return v.Active }).(pulumi.BoolOutput)\n}", "func (sc *TraceScope) Active() bool {\n\treturn sc.trc.Active()\n}", "func (c *Client) GetAddressesAdv(crypto string, addresses []string, options map[string]string) (resp *DataAddresses, e error) {\n\tif e = c.ValidateCrypto(crypto); e != nil {\n\t\treturn\n\t}\n\n\tresp = &DataAddresses{}\n\tvar path = crypto + \"/dashboards/addresses/\" + strings.Join(addresses, \",\")\n\treturn resp, c.LoadResponse(path, resp, options)\n}", "func CommandShowActive(conf Config, ctx, query Query) error {\n\tts, err := LoadTaskSet(conf.Repo, conf.IDsFile, false)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tquery = query.Merge(ctx)\n\tts.Filter(query)\n\tts.FilterByStatus(STATUS_ACTIVE)\n\tts.DisplayByNext(ctx, true)\n\n\treturn nil\n}", "func (d *Database) GetActiveAlerts() []interface{} {\n\tAlerts := make([]interface{}, 0)\n\n\trows, err := d.db.Query(\n\t\t`SELECT id, name, type, content, active, allow_dismiss, registered_only FROM alert WHERE active IS TRUE;`,\n\t)\n\n\tif err == nil {\n\t\tdefer rows.Close()\n\t\tfor rows.Next() {\n\t\t\tvar a Alert\n\n\t\t\tif err := rows.Scan(\n\t\t\t\t&a.AlertID,\n\t\t\t\t&a.Name,\n\t\t\t\t&a.Type,\n\t\t\t\t&a.Content,\n\t\t\t\t&a.Active,\n\t\t\t\t&a.AllowDismiss,\n\t\t\t\t&a.RegisteredOnly,\n\t\t\t); err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t} else {\n\t\t\t\tAlerts = append(Alerts, &a)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn Alerts\n}", "func (a *Account) RescanActiveJob() (*RescanJob, error) {\n\t// Determine the block necesary to start the rescan for all active\n\t// addresses.\n\theight := a.KeyStore.SyncHeight()\n\n\tactives := a.KeyStore.SortedActiveAddresses()\n\taddrs := make([]btcutil.Address, 0, len(actives))\n\tfor i := range actives {\n\t\taddrs = append(addrs, actives[i].Address())\n\t}\n\n\tunspents, err := a.TxStore.UnspentOutputs()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\toutpoints := make([]*btcwire.OutPoint, 0, len(unspents))\n\tfor _, c := range unspents {\n\t\toutpoints = append(outpoints, c.OutPoint())\n\t}\n\n\tjob := &RescanJob{\n\t\tAddresses: map[*Account][]btcutil.Address{a: addrs},\n\t\tOutPoints: outpoints,\n\t\tStartHeight: height,\n\t}\n\treturn job, nil\n}", "func GetAllAddress(s *aklib.DBConfig) (map[string]*Address, error) {\n\tadrs := make(map[string]*Address)\n\terr := s.DB.View(func(txn *badger.Txn) error {\n\t\tit := txn.NewIterator(badger.DefaultIteratorOptions)\n\t\tdefer it.Close()\n\t\tprefix := []byte{byte(db.HeaderWalletAddress)}\n\t\tfor it.Seek(prefix); it.ValidForPrefix(prefix); it.Next() {\n\t\t\titem := it.Item()\n\t\t\tv, err := item.ValueCopy(nil)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tvar adr Address\n\t\t\tif err := arypack.Unmarshal(v, &adr); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tadrs[string(item.Key()[1:])] = &adr\n\t\t}\n\t\treturn nil\n\t})\n\treturn adrs, err\n}", "func (k Keeper) GetActiveValidators(ctx sdk.Context) ([]types.Validator, error) {\n\tvar result []types.Validator\n\tstore := ctx.KVStore(k.dataStoreKey)\n\tproposed := k.GetBlocksProposedByAll(ctx)\n\n\tit := store.Iterator(nil, nil)\n\tdefer it.Close()\n\tfor ; it.Valid(); it.Next() {\n\t\tvar value types.Info\n\t\tif err := proto.Unmarshal(it.Value(), &value); err != nil {\n\t\t\tpanic(errors.Wrap(err, \"cannot unmarshal info\"))\n\t\t}\n\t\tif !value.IsActive() {\n\t\t\tcontinue\n\t\t}\n\t\taddr := sdk.AccAddress(it.Key())\n\t\tresult = append(result, types.GenesisValidatorFromD(addr, value, proposed[addr.String()]))\n\t}\n\n\treturn result, nil\n}", "func (cp *Pool) Active() int64 {\n\tp := cp.pool()\n\tif p == nil {\n\t\treturn 0\n\t}\n\treturn p.Active()\n}" ]
[ "0.595874", "0.5908878", "0.5823863", "0.57964134", "0.57462436", "0.56345075", "0.5600323", "0.54584813", "0.5417571", "0.5400139", "0.5300115", "0.5276993", "0.52485746", "0.5168865", "0.51660424", "0.5158932", "0.513461", "0.51050174", "0.510044", "0.50979775", "0.5083802", "0.50743717", "0.50718147", "0.50339484", "0.5015984", "0.50102144", "0.49731946", "0.49728903", "0.4953585", "0.494153", "0.49409685", "0.49168965", "0.49122596", "0.4873417", "0.48632032", "0.48534423", "0.48363534", "0.48313692", "0.48164368", "0.47893137", "0.47804013", "0.47796163", "0.47794685", "0.47572595", "0.47550905", "0.47473383", "0.47460762", "0.47421563", "0.47122967", "0.47016904", "0.4699449", "0.46926662", "0.46820837", "0.46813592", "0.467019", "0.46675697", "0.4664755", "0.46585095", "0.46543655", "0.46541473", "0.4649693", "0.46442407", "0.46397185", "0.46186763", "0.46138364", "0.46125892", "0.46124482", "0.45967773", "0.4596502", "0.4596502", "0.4592222", "0.45911655", "0.4589562", "0.4588202", "0.4580803", "0.4572748", "0.4562038", "0.4553841", "0.4553514", "0.45425364", "0.45322478", "0.452852", "0.45211962", "0.45176795", "0.4507924", "0.45066744", "0.45057034", "0.45025882", "0.4500148", "0.4490988", "0.44887844", "0.44865918", "0.44818497", "0.4468172", "0.446273", "0.4462003", "0.44607437", "0.44570866", "0.44552597", "0.4450716" ]
0.7209901
0
GetSaved will get all saved addresses for an asset
GetSaved получит все сохраненные адреса для актива
func (as *AddressService) GetSaved() ([]*Address, error) { return as.getAddresses("withdraw") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func GetSavedSitemaps() []string {\n\treturn savedSitemaps\n}", "func (ws *Wallets) GetAddresses() []string {\n\tvar addresses []string\n\n\tfor address := range ws.Wallets {\n\t\taddresses = append(addresses, address)\n\t}\n\n\treturn addresses\n}", "func (svc *inmemService) GetAddresses(ctx context.Context, profileID string) ([]Address, error) {\n\n\t// Get a Read Lock on the svc for atomic read access to the datastore\n\tsvc.mtx.RLock()\n\n\t// Immediately set up a lock release to occur when the function finishes\n\tdefer svc.mtx.RUnlock()\n\n\t// Check to make sure there is a profile that corresponds to the passed in profile and save the found profile to a profile variable\n\tprofile, ok := svc.profiles[profileID]\n\n\t// If no profile was found for the passed in ID\n\tif !ok {\n\n\t\t// Return error informing the caller that the profile to which the addresses should have been associated was not found\n\t\treturn nil, ErrNotFound\n\t}\n\n\t// Return all addresses associated with the profile that was passed in and a nil error value\n\treturn profile.Addresses, nil\n}", "func (w *XPubWallet) GetAddresses() []cipher.Addresser {\n\treturn w.Entries.getAddresses()\n}", "func (c *ChunkRef) Save() ([]datastore.Property, error) {\n\treturn datastore.SaveStruct(c)\n}", "func (as *AddressService) GetActive() ([]*Address, error) {\n\treturn as.getAddresses(\"deposit\")\n}", "func (mock *StoreServiceMock) SaveCalls() []struct {\n\tEntry ytfeed.Entry\n} {\n\tvar calls []struct {\n\t\tEntry ytfeed.Entry\n\t}\n\tmock.lockSave.RLock()\n\tcalls = mock.calls.Save\n\tmock.lockSave.RUnlock()\n\treturn calls\n}", "func (account *Account) Saved() *SavedMedia {\r\n\treturn &SavedMedia{\r\n\t\tinst: account.inst,\r\n\t\tendpoint: urlFeedSaved,\r\n\t\terr: nil,\r\n\t}\r\n}", "func (s *Store) GetBulk(suffixes []string) ([]string, error) {\n\tanchorBytes, err := s.store.GetBulk(suffixes...)\n\tif err != nil {\n\t\treturn nil, orberrors.NewTransient(fmt.Errorf(\"failed to get did anchor reference: %w\", err))\n\t}\n\n\tanchors := make([]string, len(suffixes))\n\n\tfor i, a := range anchorBytes {\n\t\tif a == nil {\n\t\t\tanchors[i] = \"\"\n\t\t} else {\n\t\t\tanchors[i] = string(a)\n\t\t}\n\t}\n\n\tlogger.Debugf(\"retrieved latest anchors%s for suffixes%s\", anchors, suffixes)\n\n\treturn anchors, nil\n}", "func (pg *PGStorage) GetAddresses(sql string, args ...interface{}) ([]*Address, error) {\n\tsql = \"SELECT id, updated_at, hash, income, outcome, ballance FROM address \" + sql\n\n\trows, err := pg.con.Query(sql, args)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\taddresses := make([]*Address, 0)\n\n\tfor rows.Next() {\n\t\ta := &Address{}\n\t\tif err := rows.Scan(\n\t\t\t&a.ID,\n\t\t\t&a.UpdatedAt,\n\t\t\t&a.Hash,\n\t\t\t&a.Income,\n\t\t\t&a.Outcome,\n\t\t\t&a.Ballance,\n\t\t); err != nil {\n\t\t\treturn addresses, err\n\t\t}\n\t\taddresses = append(addresses, a)\n\t}\n\treturn addresses, err\n}", "func (s *Service) GetAddresses(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tsizeStr := r.FormValue(\"size\")\n\tprefix := r.FormValue(\"prefix\")\n\tif sizeStr == \"\" {\n\t\tsizeStr = defaultPageSize\n\t}\n\tdata := &Data{}\n\tdefer func() {\n\t\tif err := json.NewEncoder(w).Encode(data.Addresses); err != nil {\n\t\t\tutils.Logger().Warn().Err(err).Msg(\"cannot JSON-encode addresses\")\n\t\t}\n\t}()\n\n\tsize, err := strconv.Atoi(sizeStr)\n\tif err != nil || size > maxAddresses {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\tdata.Addresses, err = s.Storage.GetAddresses(size, prefix)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tutils.Logger().Warn().Err(err).Msg(\"wasn't able to fetch addresses from storage\")\n\t\treturn\n\t}\n}", "func (l *localLinker) Save(ctx context.Context, req *pbd.SaveRequest) (*pbd.Empty, error) {\n\tl.store[req.Key] = req.Value\n\treturn &pbd.Empty{}, nil\n}", "func (u *Unmarshal) AssetsExportGet(uuid string, chunk string) ([]byte, error) {\n\ts := u.NewService()\n\traw, err := s.AssetsExportGet(uuid, chunk)\n\treturn raw, err\n}", "func (mp *Map) Save() ([]datastore.Property, error) {\n\tvar d []datastore.Property\n\tfor k, v := range *mp {\n\t\td = append(d, datastore.Property{\n\t\t\tName: k,\n\t\t\tValue: v,\n\t\t\t// Force property to not be indexed. This allows more freedom of the\n\t\t\t// property name, i.e. may contain \".\".\n\t\t\tNoIndex: true,\n\t\t})\n\t}\n\treturn d, nil\n}", "func (m *Drive) GetBundles()([]DriveItemable) {\n return m.bundles\n}", "func (fs *FileAddrStorage) GetAddresses() ([]NetAddr, error) {\n\tbytes, err := ioutil.ReadFile(fs.filePath)\n\tif err != nil {\n\t\treturn nil, trace.ConvertSystemError(err)\n\t}\n\tvar addrs []NetAddr\n\tif len(bytes) > 0 {\n\t\terr = json.Unmarshal(bytes, &addrs)\n\t\tif err != nil {\n\t\t\treturn nil, trace.Wrap(err)\n\t\t}\n\t}\n\treturn addrs, nil\n}", "func FindSavedDesks(ctx context.Context, ac *uiauto.Context) ([]uiauto.NodeInfo, error) {\n\tsavedDeskItemView := nodewith.ClassName(\"SavedDeskItemView\")\n\tsavedDeskItemViewInfo, err := ac.NodesInfo(ctx, savedDeskItemView)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to find SavedDeskItemView\")\n\t}\n\treturn savedDeskItemViewInfo, nil\n}", "func (ws *WalletStore) Save() {\n\tvar buffer bytes.Buffer\n\tgob.Register(elliptic.P256())\n\tencoder := gob.NewEncoder(&buffer)\n\terr := encoder.Encode(ws.Wallets)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfile := ws.Config.GetWalletStoreFile(ws.NodeID)\n\terr = ioutil.WriteFile(file, buffer.Bytes(), 0644)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "func (serv *TransactionService) SaveAll(dirPath string, trs []trs.Transaction) ([]stored_transactions.Transaction, error) {\n\tout := []stored_transactions.Transaction{}\n\tfor _, oneTrs := range trs {\n\t\toneObjDirPath := filepath.Join(dirPath, oneTrs.GetMetaData().GetID().String())\n\t\toneObj, oneObjErr := serv.Save(oneObjDirPath, oneTrs)\n\t\tif oneObjErr != nil {\n\t\t\treturn nil, oneObjErr\n\t\t}\n\n\t\tout = append(out, oneObj)\n\t}\n\n\treturn out, nil\n}", "func (cli *OpsGenieAlertV2Client) ListSavedSearches(req alertsv2.LisSavedSearchRequest) (*savedsearches.ListSavedSearchResponse, error) {\n\tvar response savedsearches.ListSavedSearchResponse\n\terr := cli.sendGetRequest(&req, &response)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &response, nil\n}", "func (m *MemoryRewardStorage) GetAll() []rewards.Reward {\n\treturn m.rewards\n}", "func (wlt *Wallet) GetAddresses() []cipher.Address {\n\taddrs := make([]cipher.Address, len(wlt.Entries))\n\tfor i, e := range wlt.Entries {\n\t\taddrs[i] = e.Address\n\t}\n\treturn addrs\n}", "func (r *Reserve) Save(s *Store) error {\n\tdata, _ := json.Marshal(s)\n\tif err := ioutil.WriteFile(r.path, data, 0644); err != nil {\n\t\treturn fmt.Errorf(\"Failed to set %s: %s\", r.name, err)\n\t}\n\treturn nil\n}", "func (mapping *ApplicationAccountStoreMapping) Save() error {\n\turl := buildRelativeURL(\"accountStoreMappings\")\n\tif mapping.Href != \"\" {\n\t\turl = mapping.Href\n\t}\n\n\treturn client.post(url, mapping, mapping)\n}", "func (fcb *FileCacheBackend) Save(ob types.OutgoingBatch) error {\n\tfilename := fcb.getFilename(fcb.getCacheFilename(ob))\n\tlog.Printf(\"Saving to %s\", filename)\n\tfile, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_EXCL, 0600)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Unable to save to %s - %s\", filename, err)\n\t}\n\tdefer file.Close()\n\tfor _, item := range ob.Values {\n\t\tfile.WriteString(item + \"\\n\")\n\t}\n\treturn nil\n}", "func (a *addrBook) getAddresses() []*addrInfo {\n\ta.mu.Lock()\n\tdefer a.mu.Unlock()\n\n\taddrIndexLen := len(a.addrIndex)\n\tif addrIndexLen == 0 {\n\t\treturn nil\n\t}\n\n\taddrs := make([]*addrInfo, 0, addrIndexLen)\n\tfor _, v := range a.addrIndex {\n\t\taddrs = append(addrs, v.Addr)\n\t}\n\n\treturn addrs\n}", "func GetAllAddresses() []*AddressDAL {\n\taddresses := []*AddressDAL{}\n\tdb.DB().Find(&addresses)\n\treturn addresses\n}", "func (b *Backend) Save(root internal.Root) ([]internal.Game, error) {\n\tvar gameJSON []byte\n\tvar games []internal.Game\n\terr := b.DB.Update(func(txn *badger.Txn) error {\n\t\tvar err error\n\t\tfor _, date := range root.Dates {\n\t\t\tdateString := date.DateString\n\t\t\tfor _, game := range date.Games {\n\t\t\t\tkey := fmt.Sprintf(\"%s:%d:%d\", dateString, game.Teams[\"away\"].Team.ID, game.Teams[\"home\"].Team.ID)\n\t\t\t\tgameJSON, err = json.Marshal(game)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\ttxn.Set([]byte(key), gameJSON)\n\t\t\t\tgames = append(games, game)\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t})\n\n\treturn games, err\n}", "func (m *Printer) GetShares()([]PrinterShareable) {\n val, err := m.GetBackingStore().Get(\"shares\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.([]PrinterShareable)\n }\n return nil\n}", "func (o *Service) GetAddresses() []string {\n\tif o == nil || o.Addresses == nil {\n\t\tvar ret []string\n\t\treturn ret\n\t}\n\treturn *o.Addresses\n}", "func GetAddressList() []common.Address {\n\treturn allSkrAddress\n}", "func (d *DiskStorage) GetAll() (map[string]Entry, error) {\n\treturn d.memStorage.GetAll()\n}", "func All(w http.ResponseWriter, r *http.Request) {\n\tvar result []Location\n\terr := store.Find(&result, bolthold.Where(\"Serial\").Eq(\"ce011711bd1668d80c\").Index(\"Serial\"))\n\tif err != nil {\n\t\tfmt.Println(\"Err\")\n\t\tfmt.Println(err)\n\t}\n\n\tjson.NewEncoder(w).Encode(result)\n\n}", "func (e Endpoints) GetAddresses(ctx context.Context, profileID string) ([]Address, error) {\n\n\t// TODO: Create detailed ref spec\n\trequest := getAddressesRequest{ProfileID: profileID}\n\n\tresponse, err := e.GetAddressesEndpoint(ctx, request)\n\n\tif err != nil {\n\t\treturn []Address{}, nil\n\t}\n\n\tresp := response.(getAddressesResponse)\n\n\treturn resp.Addresses, resp.Err\n\n}", "func (w *Wallet) AllAddress() []string {\n\tadrs := make([]string, 0, len(w.AddressChange)+len(w.AddressPublic))\n\tfor adr := range w.AddressChange {\n\t\tadrs = append(adrs, adr)\n\t}\n\tfor adr := range w.AddressPublic {\n\t\tadrs = append(adrs, adr)\n\t}\n\treturn adrs\n}", "func Save(data []*JSON) error {\n\treturn save(data, \"./extracted_jsons.json\")\n}", "func (epcb *EntryPointCreateBulk) SaveX(ctx context.Context) []*EntryPoint {\n\tv, err := epcb.Save(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (s *Storage) GetAll() (uuids [][]byte, entries []Entry, err error) {\n\treturn s.innerGet(time.Now(), true)\n}", "func (sq *allSavedQueriesCached) get() map[string]api.SavedQuerySpecAndConfig {\n\tsq.mu.Lock()\n\tdefer sq.mu.Unlock()\n\n\tcpy := make(map[string]api.SavedQuerySpecAndConfig, len(sq.allSavedQueries))\n\tfor k, v := range sq.allSavedQueries {\n\t\tcpy[k] = v\n\t}\n\treturn cpy\n}", "func (a *Aliases) Save() error {\n\tlog.Debug().Msg(\"[Config] Saving Aliases...\")\n\treturn a.SaveAliases(K9sAlias)\n}", "func (m *IGApiManager) GetSavedPosts() (items []IGItem, err error) {\n\tb, err := getHTTPResponse(urlSaved, m.dsUserId, m.sessionid, m.csrftoken)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tspp := savedPostsResp{}\n\terr = json.Unmarshal(b, &spp)\n\tif err != nil {\n\t\treturn\n\t}\n\tfor _, item := range spp.Items {\n\t\titems = append(items, item.Item)\n\t}\n\n\tfor spp.MoreAvailable {\n\t\turl := urlSaved + \"?max_id=\" + spp.NextMaxId\n\t\tb, err = getHTTPResponse(url, m.dsUserId, m.sessionid, m.csrftoken)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tspp = savedPostsResp{}\n\t\terr = json.Unmarshal(b, &spp)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tfor _, item := range spp.Items {\n\t\t\titems = append(items, item.Item)\n\t\t}\n\t\tlog.Println(\"fetched\", len(items), \"items\")\n\t\t// sleep 500ms to prevent http 429\n\t\ttime.Sleep(500 * time.Millisecond)\n\t}\n\n\treturn\n}", "func (r *Repository) Save(url string, toAddr, ccAddr []string, content string, status int) error {\n\treturn nil\n}", "func GetAllAddress(s *aklib.DBConfig) (map[string]*Address, error) {\n\tadrs := make(map[string]*Address)\n\terr := s.DB.View(func(txn *badger.Txn) error {\n\t\tit := txn.NewIterator(badger.DefaultIteratorOptions)\n\t\tdefer it.Close()\n\t\tprefix := []byte{byte(db.HeaderWalletAddress)}\n\t\tfor it.Seek(prefix); it.ValidForPrefix(prefix); it.Next() {\n\t\t\titem := it.Item()\n\t\t\tv, err := item.ValueCopy(nil)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tvar adr Address\n\t\t\tif err := arypack.Unmarshal(v, &adr); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tadrs[string(item.Key()[1:])] = &adr\n\t\t}\n\t\treturn nil\n\t})\n\treturn adrs, err\n}", "func (a Accounts) Get(asset string) *Account {\n\tfor i := range a.Datas {\n\t\tif a.Datas[i].Balance.Currency == asset {\n\t\t\treturn &a.Datas[i]\n\t\t}\n\t}\n\treturn nil\n}", "func (_obj *Apipayments) Payments_getSavedInfo(params *TLpayments_getSavedInfo, _opt ...map[string]string) (ret Payments_SavedInfo, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\ttarsCtx := context.Background()\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"payments_getSavedInfo\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (s *Client) GetUserSavedTracks(ctx context.Context, token *oauth2.Token, q *QParams) (*models.UserSavedTracks, error) {\n\tvar endpoint *url.URL = s.API.UserSavedTracksURL\n\t//in go structs containing primitive types are copied by value\n\t//https://stackoverflow.com/questions/51635766/how-do-i-copy-a-struct-in-golang\n\tlog.Println(\"SAME ADDRESS ?????\")\n\tlog.Println(&endpoint == &s.API.UserSavedTracksURL)\n\tif q != nil {\n\t\tparams := url.Values{}\n\t\tif q.Limit != nil {\n\t\t\tvar l int = *(q).Limit\n\t\t\tvalid := (l >= 1) && (l <= 50)\n\t\t\tif valid {\n\t\t\t\tparams.Set(\"limit\", strconv.Itoa(l))\n\t\t\t}\n\t\t}\n\t\tif q.Offset != nil {\n\t\t\tvar offset int = *(q).Offset\n\t\t\tif offset > 0 {\n\t\t\t\tparams.Set(\"offset\", strconv.Itoa(offset))\n\t\t\t}\n\t\t}\n\t\tif q.Market != nil {\n\t\t\tvar m string = *(q).Market\n\t\t\tif validMarketOpt(m) {\n\t\t\t\tparams.Set(\"market\", *(q).Market)\n\t\t\t}\n\t\t}\n\n\t\tendpoint.RawQuery = params.Encode()\n\t}\n\turl := endpoint.String()\n\tlog.Println(url)\n\tlog.Printf(\"User saved tracks url: %v\\n\", url)\n\n\ttracks := &models.UserSavedTracks{}\n\n\thttpClient := s.Config.Client(ctx, token)\n\tresp, err := httpClient.Get(url)\n\tif resp.StatusCode >= http.StatusBadRequest {\n\t\tlog.Println(\"status code todo:return err\")\n\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tif err := json.NewDecoder(resp.Body).Decode(tracks); err != nil {\n\t\tlog.Printf(\"Could not decode body: %v\\n\", err)\n\t\treturn nil, err\n\t}\n\n\treturn tracks, nil\n\n}", "func (g *Group) Save() [][]string {\n\tres := make([][]string, len(g.PriorityStudents)+len(g.Students))\n\tvar i int\n\tsaveStudents(g.PriorityStudents, res, &i)\n\tsaveStudents(g.Students, res, &i)\n\treturn res\n}", "func (app *service) Save(state State) error {\n\tjs, err := app.adapter.ToJSON(state)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tchainHash := state.Chain()\n\tindex := state.Height()\n\tpath := filePath(chainHash, index)\n\treturn app.fileService.Save(path, js)\n}", "func (c *CoordinatorHelper) AllAddresses(\n\tctx context.Context,\n\tdbTx storage.DatabaseTransaction,\n) ([]string, error) {\n\treturn c.keyStorage.GetAllAddressesTransactional(ctx, dbTx)\n}", "func (db *STXOsDB) GetAddrAll(hash *Uint168) ([]*STXO, error) {\n\tdb.RLock()\n\tdefer db.RUnlock()\n\n\tsql := \"SELECT OutPoint, Value, LockTime, AtHeight, SpendHash, SpendHeight FROM STXOs WHERE ScriptHash=?\"\n\trows, err := db.Query(sql, hash.Bytes())\n\tif err != nil {\n\t\treturn []*STXO{}, err\n\t}\n\tdefer rows.Close()\n\n\treturn db.getSTXOs(rows)\n}", "func (ipset *IPSet) Save() error {\n\tstdout, err := ipset.run(\"save\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tipset.Sets = parseIPSetSave(ipset, stdout)\n\treturn nil\n}", "func (m *User) GetImAddresses()([]string) {\n return m.imAddresses\n}", "func (mock *CacheRepositoryMock) SaveCalls() []struct {\n\tKey string\n\tValue interface{}\n} {\n\tvar calls []struct {\n\t\tKey string\n\t\tValue interface{}\n\t}\n\tmock.lockSave.RLock()\n\tcalls = mock.calls.Save\n\tmock.lockSave.RUnlock()\n\treturn calls\n}", "func (s *IdeaStorage) GetAll() ([]*models.Idea, error) {\n\treturn s.ideas, nil\n}", "func (m *MemoryStorage) GetAll() (map[string]Entry, error) {\n\treturn m.entries, nil\n}", "func (mock *RepositoryMock) SaveCalls() []struct {\n\tCtx context.Context\n\tID string\n\tURL string\n} {\n\tvar calls []struct {\n\t\tCtx context.Context\n\t\tID string\n\t\tURL string\n\t}\n\tmock.lockSave.RLock()\n\tcalls = mock.calls.Save\n\tmock.lockSave.RUnlock()\n\treturn calls\n}", "func getAllCompanySymbols() ([]string){\r\n return []string{}\r\n}", "func (wcb *WalletCreateBulk) SaveX(ctx context.Context) []*Wallet {\n\tv, err := wcb.Save(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (p *ProviderParams) Save() ([]datastore.Property, error) {\n\tvar result []datastore.Property\n\tfor k, v := range *p {\n\t\tresult = append(result, datastore.Property{\n\t\t\tName: k,\n\t\t\tValue: v,\n\t\t})\n\t}\n\treturn result, nil\n}", "func (m *BookingBusiness) GetAddress()(PhysicalAddressable) {\n val, err := m.GetBackingStore().Get(\"address\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(PhysicalAddressable)\n }\n return nil\n}", "func (app *service) Save(genesis Genesis) error {\n\t_, err := app.repository.Retrieve()\n\tif err == nil {\n\t\treturn errors.New(\"there is already a Genesis instance\")\n\t}\n\n\tbill := genesis.Bill()\n\terr = app.billService.Save(bill)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttrGenesis, err := app.adapter.ToTransfer(genesis)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn app.trService.Save(trGenesis)\n}", "func (file *File) SnapshotSaved() {\n\tif file.buffHist != nil {\n\t\tfile.buffHist.SnapshotSaved()\n\t}\n}", "func (b Banai) Save(fileName string) (string, error) {\n\tabs, e := filepath.Abs(fileName)\n\tif e != nil {\n\t\treturn \"\", e\n\t}\n\tstashID := uuid.NewString()\n\n\te = fsutils.CopyfsItem(abs, stashID)\n\tif e != nil {\n\t\treturn \"\", e\n\t}\n\treturn stashID, nil\n}", "func (msg MsgSellAsset) GetSigners() []sdk.AccAddress {\n\taddr, err := sdk.AccAddressFromBech32(msg.Seller)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn []sdk.AccAddress{addr}\n}", "func (model *GrogModel) AllAssets() ([]*Asset, error) {\n\tvar foundAssets []*Asset\n\n\trows, rowsErr := model.db.DB.Query(`select name, mimeType, content, serve_external, rendered,\n\t\tadded, modified from Assets`)\n\tif rowsErr != nil {\n\t\treturn nil, fmt.Errorf(\"error loading all assets: %v\", rowsErr)\n\t}\n\n\tdefer rows.Close()\n\n\tvar (\n\t\tname string\n\t\tmimeType string\n\t\tcontent = make([]byte, 0)\n\t\tserveExternal int64\n\t\trendered int64\n\t\tadded int64\n\t\tmodified int64\n\t)\n\n\tfor rows.Next() {\n\t\tif rows.Scan(&name, &mimeType, &content, &serveExternal, &rendered, &added, &modified) != sql.ErrNoRows {\n\t\t\tfoundAsset := model.NewAsset(name, mimeType)\n\t\t\tfoundAsset.Content = content\n\t\t\tif serveExternal == 1 {\n\t\t\t\tfoundAsset.ServeExternal = true\n\t\t\t} else {\n\t\t\t\tfoundAsset.ServeExternal = false\n\t\t\t}\n\n\t\t\tif rendered == 1 {\n\t\t\t\tfoundAsset.Rendered = true\n\t\t\t} else {\n\t\t\t\tfoundAsset.Rendered = false\n\t\t\t}\n\n\t\t\tfoundAsset.Added.Set(time.Unix(added, 0))\n\t\t\tfoundAsset.Modified.Set(time.Unix(modified, 0))\n\n\t\t\tif foundAssets == nil {\n\t\t\t\tfoundAssets = make([]*Asset, 0)\n\t\t\t}\n\t\t\tfoundAssets = append(foundAssets, foundAsset)\n\t\t}\n\t}\n\n\treturn foundAssets, nil\n}", "func (ref *DidAnchor) GetBulk(suffixes []string) ([]string, error) {\n\tref.RLock()\n\tdefer ref.RUnlock()\n\n\tanchors := make([]string, len(suffixes))\n\n\tfor i, suffix := range suffixes {\n\t\tanchor, ok := ref.m[suffix]\n\t\tif !ok {\n\t\t\tanchors[i] = \"\"\n\t\t} else {\n\t\t\tanchors[i] = anchor\n\t\t}\n\t}\n\n\treturn anchors, nil\n}", "func (kvStore *KVStore) DumpStore() []KVPair {\n els := make([]KVPair, len(kvStore.mapping))\n\n i := 0\n for k, v := range kvStore.mapping {\n els[i] = KVPair{k, *v}\n i++\n }\n\n return els\n}", "func (s Storage) GetAll() Storage {\n\treturn s\n}", "func (m *BookingBusiness) GetServices()([]BookingServiceable) {\n val, err := m.GetBackingStore().Get(\"services\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.([]BookingServiceable)\n }\n return nil\n}", "func (m *VirtualEndpoint) GetSnapshots()([]CloudPcSnapshotable) {\n val, err := m.GetBackingStore().Get(\"snapshots\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.([]CloudPcSnapshotable)\n }\n return nil\n}", "func (t *Table) Save(key string, s string) ([]byte, error) {\n\tp := fmt.Sprintf(\"&object=%s&key=%s&%s\", t.Name, key, s)\n\treturn t.SaveBulk(p)\n}", "func (s *Store) GetAll() Dict {\n\treturn *s.data\n}", "func (b *Bookmarks) Save() error {\n\treturn b.WriteToFile(b.Filename)\n}", "func (wallet *Wallet) ExportState() []byte {\n\tmarshalUtil := marshalutil.New()\n\tmarshalUtil.WriteBytes(wallet.Seed().Bytes())\n\tmarshalUtil.WriteUint64(wallet.AddressManager().lastAddressIndex)\n\tmarshalUtil.WriteBytes(wallet.assetRegistry.Bytes())\n\tmarshalUtil.WriteBytes(*(*[]byte)(unsafe.Pointer(&wallet.addressManager.spentAddresses)))\n\n\treturn marshalUtil.Bytes()\n}", "func (posts Posts) Save() (err error) {\n\tpaths := pathsInLocal()\n\tfor _, post := range posts {\n\t\terr = post.Save(paths)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "func (m *CountryNamedLocation) GetCountriesAndRegions()([]string) {\n val, err := m.GetBackingStore().Get(\"countriesAndRegions\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.([]string)\n }\n return nil\n}", "func (i *Item) Save() (map[string]bigquery.Value, string, error) {\n\treturn map[string]bigquery.Value{\n\t\t\"value\": i.value,\n\t\t\"metricname\": i.metricname,\n\t\t\"timestamp\": i.timestamp,\n\t\t\"tags\": i.tags,\n\t}, \"\", nil\n}", "func GetKnownAddresses() (data []network.NetAddress, err error) {\n\terr = db.View(func(tx *bolt.Tx) error {\n\t\tb := tx.Bucket(knownAddresses)\n\t\tc := b.Cursor()\n\t\tfor k, v := c.First(); k != nil; k, v = c.Next() {\n\t\t\taddr := network.NetAddress{}\n\t\t\tterr := json.Unmarshal(v, &addr.Lastseen)\n\t\t\tif terr != nil {\n\t\t\t\treturn fmt.Errorf(\"get known adrresses unmarshal: %s\", terr)\n\t\t\t}\n\t\t\ts := strings.Split(string(k[:]), \":\")\n\t\t\taddr.Ip = s[0]\n\t\t\taddr.Port = s[1]\n\t\t\tdata = append(data, addr)\n\t\t}\n\t\treturn nil\n\t})\n\treturn\n}", "func Save() {\n\tdata := Savedata{\n\t\tName: GS.current.name,\n\t\tGamestate: GS.current,\n\t}\n\n\tf, err := json.MarshalIndent(data, \"\", \" \")\n\tcheck(err)\n\tioutil.WriteFile(\"data/savegame.json\", f, 0644)\n}", "func (s store) Save() {\n\ts.writeToDisk()\n}", "func (tx *ReleaseFromEndowment) GetAccountAddresses(app *App) ([]string, error) {\n\trfea, err := tx.GetSource(app)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"getting RFE SV\")\n\t}\n\treturn []string{rfea.String(), tx.Destination.String()}, nil\n}", "func (s *Service) GetAll(ctx context.Context) ([]types.Visit, error) {\n\treturn s.repo.FindAll(ctx)\n}", "func (m *PasswordResetModel) SaveAll(ctx context.Context, passwordResets []PasswordResetN) ([]int64, error) {\n\tids := make([]int64, 0)\n\tfor _, passwordReset := range passwordResets {\n\t\tid, err := m.Save(ctx, passwordReset)\n\t\tif err != nil {\n\t\t\treturn ids, err\n\t\t}\n\n\t\tids = append(ids, id)\n\t}\n\n\treturn ids, nil\n}", "func (s *Identity) AccountsGET(w http.ResponseWriter, r *http.Request) {\n\ts.mu.RLock()\n\tdefer s.mu.RUnlock()\n\twriteResponse(s.addresses, w, r)\n}", "func (t *Table) SaveBulk(s string) ([]byte, error) {\n\tu := \"https://%s/save\"\n\tx := fmt.Sprintf(u, t.Host)\n\n\tw := bytes.NewBufferString(\"?json\")\n\t_, _ = w.WriteString(s)\n\tb := bytes.NewReader(w.Bytes())\n\t//log.Printf(\"SaveBulk: writing %s\\n\", w.String())\n\treq, err := http.NewRequest(\"POST\", x, b)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// Salsa's API needs these cookies to verify authentication.\n\tfor _, c := range t.Cookies {\n\t\treq.AddCookie(c)\n\t}\n\t// TODO: figure out what to do with the an error response from /save.\n\tif t.API.Verbose {\n\t\tfmt.Printf(\"SaveBulk: %v%v\\n\", x, w.String())\n\t}\n\tresp, err := t.Client.Do(req)\n\tvar body []byte\n\tif err == nil {\n\t\tdefer resp.Body.Close()\n\t\tbody, err = ioutil.ReadAll(resp.Body)\n\t}\n\n\treturn body, err\n}", "func (ids identities) getAddresses() []common.Address {\n\taddresses := make([]common.Address, len(ids))\n\tfor i := 0; i < len(ids); i++ {\n\t\taddresses[i] = ids[i].addr\n\t}\n\treturn addresses\n}", "func (acb *AreahistoryCreateBulk) SaveX(ctx context.Context) []*Areahistory {\n\tv, err := acb.Save(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (s *Store) GetAddress() string {\n\tgeoAddresses := []string{}\n\tif s.Address.Valid {\n\t\tgeoAddresses = append(geoAddresses, s.Address.String)\n\t}\n\tif s.City.Valid {\n\t\tgeoAddresses = append(geoAddresses, s.City.String)\n\t}\n\tif s.State.Valid {\n\t\tgeoAddresses = append(geoAddresses, s.State.String)\n\t}\n\tgeoAddress := strings.Join(geoAddresses, \", \")\n\treturn geoAddress\n}", "func (hs *HistoryService) All(actionType string) ([]*TransactionHistory, error) {\n\tvar transHist []*TransactionHistory\n\tif err := hs.client.Get(buildString(\"history/\", actionType, \"/\", strconv.Itoa(hs.assetId)),\n\t\t&transHist); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn transHist, nil\n}", "func (e *Entity) Export() map[string]interface{} {\n\ta := make(map[string]interface{})\n\te.lock.Lock()\n\tdefer e.lock.Unlock()\n\n\tfor label, attribute := range e.Attributes {\n\t\ta[label] = attribute.Get()\n\t}\n\n\treturn a\n}", "func SaveAll(args ...interface{}) error {\n\treturn doAll(Save, args...)\n}", "func (ws *WebServer) LoadSavedAcct(dbPath, network string) (string, error) {\n\tseed, err := ws.GetSeedFromDB(network)\n\tif err != nil {\n\t\tws.log.Errorf(\"LoadSavedAcct:%s\", ErrCombind(ErrorBoltDBGetSeed, err))\n\t\treturn \"\", ErrCombind(ErrorBoltDBGetSeed, err)\n\t}\n\tif seed == \"\" {\n\t\tws.log.Errorf(\"LoadSavedAcct:%s\", ErrorGetEmptySeed)\n\t\treturn \"\", ErrorGetEmptySeed\n\t}\n\ta, err := sdk.AccountFromSeed(seed)\n\tif err != nil {\n\t\tws.log.Errorf(\"LoadSavedAcct:%s\", ErrCombind(ErrorGetAccountFromSeed, err))\n\t\treturn \"\", ErrorGetAccountFromSeed\n\t}\n\terr = ws.SetAccount(a.AccountNumber(), seed, network)\n\n\tif err != nil {\n\t\tws.log.Errorf(\"LoadSavedAcct:%s\", ErrorSetAccount)\n\t\treturn \"\", ErrorSetAccount\n\t}\n\n\t//Save to file and load to memory\n\tseedFile := filepath.Join(ws.rootPath, \"bitmarkd\", network, \"proof.sign\")\n\tf, err := os.OpenFile(seedFile, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0600)\n\tdefer f.Close()\n\tif err != nil {\n\t\tws.log.Errorf(\"LoadSavedAcct:%s\", ErrCombind(ErrorOpenSeedFile, err))\n\t\treturn \"\", ErrCombind(ErrorOpenSeedFile, err)\n\t}\n\t_, err = f.WriteString(fmt.Sprintf(\"SEED:%s\", seed))\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn a.AccountNumber(), nil\n}", "func (e *Account) Save() error { return ent.SaveEnt(e) }", "func (e *Account) Save() error { return ent.SaveEnt(e) }", "func (x SyntheticMonitorEntity) GetAssets() []SyntheticsSyntheticMonitorAsset {\n\treturn x.Assets\n}", "func (m *Group) GetSites()([]Siteable) {\n return m.sites\n}", "func (app *application) getAssets(w http.ResponseWriter, r *http.Request) {\n\tdata, err := app.assets.GetAssets()\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\n\tj, err := json.Marshal(data)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write(j)\n}", "func (b *Bucket) Save(key string, data []byte) (*brazier.Item, error) {\n\terr := b.node.Set(\"items\", key, data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &brazier.Item{\n\t\tKey: key,\n\t\tData: data,\n\t}, nil\n}", "func (f *fetcher) Save(data []byte) {\n\t// Implementation can be application dependent\n\t// eg. you may implement connect to a redis server here\n\tfmt.Println(string(data))\n}", "func (s *SmartContract) GetAllAssets(ctx contractapi.TransactionContextInterface) ([]*Asset, error) {\n\t// range query with empty string for startKey and endKey does an\n\t// open-ended query of all assets in the chaincode namespace.\n\tresultsIterator, err := ctx.GetStub().GetStateByRange(\"\", \"\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resultsIterator.Close()\n\n\tvar assets []*Asset\n\tfor resultsIterator.HasNext() {\n\t\tqueryResponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvar asset Asset\n\t\terr = json.Unmarshal(queryResponse.Value, &asset)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tassets = append(assets, &asset)\n\t}\n\n\treturn assets, nil\n}" ]
[ "0.58940905", "0.5235095", "0.5105615", "0.5036253", "0.49775848", "0.49759227", "0.49557313", "0.4901856", "0.486662", "0.4844012", "0.4823038", "0.48178643", "0.4812065", "0.48031896", "0.4785494", "0.4763713", "0.47625273", "0.4760581", "0.47561753", "0.47330952", "0.469473", "0.46820766", "0.4680319", "0.46653792", "0.4661126", "0.46358964", "0.4624875", "0.46125457", "0.4601281", "0.4592749", "0.45822728", "0.45730448", "0.4572989", "0.4559922", "0.45395473", "0.45362678", "0.45261464", "0.45226303", "0.4514699", "0.451352", "0.45085317", "0.45025754", "0.44843957", "0.44665658", "0.44637108", "0.4463597", "0.44613796", "0.44544", "0.44433022", "0.44391564", "0.4438538", "0.44370687", "0.44354263", "0.44265434", "0.44195443", "0.4415129", "0.44106522", "0.4403775", "0.43972513", "0.4395367", "0.43935835", "0.43915075", "0.4389519", "0.43685636", "0.43655357", "0.43645906", "0.43586996", "0.4354265", "0.4343437", "0.4342848", "0.43427768", "0.43382692", "0.4327075", "0.43202302", "0.4318073", "0.4318044", "0.43159783", "0.431219", "0.43107656", "0.4308178", "0.43056905", "0.43051666", "0.42932996", "0.42903912", "0.42864853", "0.4285549", "0.4282645", "0.42807963", "0.42783225", "0.42767692", "0.4276436", "0.42760253", "0.4274359", "0.4274359", "0.42704517", "0.42698768", "0.42671508", "0.42669052", "0.42666888", "0.42648873" ]
0.7589577
0
Remove will remove a withdrawal adddress given the id of the address
Remove удалит адрес вывода по заданному идентификатору адреса
func (as *AddressService) Remove(addressID int) error { if err := as.client.Delete(buildString("address/withdraw/", strconv.Itoa(addressID))); err != nil { return err } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *wsClientFilter) removeAddress(a btcutil.Address) {\n\tswitch a := a.(type) {\n\tcase *btcutil.AddressPubKeyHash:\n\t\tdelete(f.pubKeyHashes, *a.Hash160())\n\t\treturn\n\tcase *btcutil.AddressScriptHash:\n\t\tdelete(f.scriptHashes, *a.Hash160())\n\t\treturn\n\tcase *btcutil.AddressPubKey:\n\t\tserializedPubKey := a.ScriptAddress()\n\t\tswitch len(serializedPubKey) {\n\t\tcase 33: // compressed\n\t\t\tvar compressedPubKey [33]byte\n\t\t\tcopy(compressedPubKey[:], serializedPubKey)\n\t\t\tdelete(f.compressedPubKeys, compressedPubKey)\n\t\t\treturn\n\t\tcase 65: // uncompressed\n\t\t\tvar uncompressedPubKey [65]byte\n\t\t\tcopy(uncompressedPubKey[:], serializedPubKey)\n\t\t\tdelete(f.uncompressedPubKeys, uncompressedPubKey)\n\t\t\treturn\n\t\t}\n\t}\n\n\tdelete(f.otherAddresses, a.EncodeAddress())\n}", "func DeleteAddressByID(ID int)error{\n\tsql := \"delete from address where id = ?\"\n\t_,err := utils.Db.Exec(sql,ID)\n\tif err != nil{\n\t\treturn err\n\t}\n\treturn nil\n}", "func (ua *UserAddress) Delete(ctx context.Context, key ...interface{}) error {\n\tvar err error\n\tvar dbConn *sql.DB\n\n\t// if deleted, bail\n\tif ua._deleted {\n\t\treturn nil\n\t}\n\n\ttx, err := components.M.GetConnFromCtx(ctx)\n\tif err != nil {\n\t\tdbConn, err = components.M.GetMasterConn()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\ttableName, err := GetUserAddressTableName(key...)\n\tif err != nil {\n\t\treturn err\n\t}\n\t//1\n\n\t// sql query with composite primary key\n\tsqlstr := `UPDATE ` + tableName + ` SET is_del = 1 WHERE uaid = ?`\n\n\t// run query\n\tutils.GetTraceLog(ctx).Debug(\"DB\", zap.String(\"SQL\", fmt.Sprint(sqlstr, ua.Uaid)))\n\tif tx != nil {\n\t\t_, err = tx.Exec(sqlstr, ua.Uaid)\n\t} else {\n\t\t_, err = dbConn.Exec(sqlstr, ua.Uaid)\n\t}\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// set deleted\n\tua._deleted = true\n\n\treturn nil\n}", "func DeleteDesainByID(e echo.Context) error {\n\tvar desain db.Desains\n\tid, _ := strconv.Atoi(e.Param(\"id\"))\n\tconfig.DB.Where(\"id = ?\", id).Delete(&desain)\n\treturn e.JSON(http.StatusOK, map[string]interface{}{\n\t\t\"desain\": desain,\n\t\t\"message\": \"Data Berhasil Dihapus\",\n\t})\n}", "func (f *wsClientFilter) removeAddressStr(s string, params *chaincfg.Params) {\n\ta, err := btcutil.DecodeAddress(s, params)\n\tif err == nil {\n\t\tf.removeAddress(a)\n\t} else {\n\t\tdelete(f.otherAddresses, s)\n\t}\n}", "func (twd *TCPWaveDriver) ReleaseAddress(conf NetConfig, ip string, mac string) (string,error){\n glog.Infof(\"Ip delete request with ip = %s\", ip)\n err := twd.ObjMgr.DeleteIPAddress(ip, \"\", conf.IPAM.Org)\n if err!=nil{\n glog.Error(err)\n return \"\", err\n }\n return ip,nil\n}", "func (s *svcBook) DelByID(pId *uint) (uint, error) {\n\treturn (*s.pRepo).DelByID(pId)\n}", "func DeleteAddress(id int32) error {\n\ta, err := GetAddress(id)\n\tif err != nil {\n\t\treturn err\n\t}\n\tresult := db.DB().Delete(a)\n\treturn result.Error\n}", "func (o *Address) Delete(exec boil.Executor) error {\n\tif o == nil {\n\t\treturn errors.New(\"sqlboiler: no Address provided for delete\")\n\t}\n\n\tif err := o.doBeforeDeleteHooks(exec); err != nil {\n\t\treturn err\n\t}\n\n\targs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), addressPrimaryKeyMapping)\n\tsql := \"DELETE FROM `address` WHERE `address_id`=?\"\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintln(boil.DebugWriter, sql)\n\t\tfmt.Fprintln(boil.DebugWriter, args...)\n\t}\n\n\t_, err := exec.Exec(sql, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"sqlboiler: unable to delete from address\")\n\t}\n\n\tif err := o.doAfterDeleteHooks(exec); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (t *ToDoList) Remove(id string) {\n\tidx := findDealIndex(t.Deals, id)\n\tif idx == -1 {\n\t\tpanic(\"Deal is not found\")\n\t}\n\tt.Deals[idx] = t.Deals[len(t.Deals)-1]\n\tt.Deals[len(t.Deals)-1] = nil\n\tt.Deals = t.Deals[:len(t.Deals)-1]\n}", "func (t *Transaction) remove(db meddler.DB) error {\n lender, err := GetUserById(db, t.LenderId)\n if err != nil {\n return err\n }\n debtor, err := GetUserById(db, t.DebtorId)\n if err != nil {\n return err\n }\n\n // reverse the balance updates due to this transaction\n lender.UpdateBalance(db, -(t.Amount))\n debtor.UpdateBalance(db, t.Amount)\n\n // remove the transaction from the db\n _, err = db.Exec(\"DELETE FROM transactions WHERE id = ?\", t.Id)\n if err != nil {\n return err\n }\n t = nil\n\n return nil\n}", "func RemoveByID(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tfmt.Fprint(w, \"Welcome!\\n\")\n}", "func (oiuo *OrderInfoUpdateOne) RemoveOrderAddress(o ...*OrderAddress) *OrderInfoUpdateOne {\n\tids := make([]int, len(o))\n\tfor i := range o {\n\t\tids[i] = o[i].ID\n\t}\n\treturn oiuo.RemoveOrderAddresIDs(ids...)\n}", "func (t *Tenants) Del(id string) error {\n\treturn t.store.Del(id)\n}", "func (oiu *OrderInfoUpdate) RemoveOrderAddress(o ...*OrderAddress) *OrderInfoUpdate {\n\tids := make([]int, len(o))\n\tfor i := range o {\n\t\tids[i] = o[i].ID\n\t}\n\treturn oiu.RemoveOrderAddresIDs(ids...)\n}", "func RemoveAddress(addrs []Address, a Address) []Address {\n\ti := IndexOfAddress(addrs, a)\n\tif i == -1 {\n\t\treturn addrs\n\t}\n\n\treturn append(addrs[:i], addrs[i+1:]...)\n}", "func (uuo *UserUpdateOne) RemoveUserid(c ...*Carservice) *UserUpdateOne {\n\tids := make([]int, len(c))\n\tfor i := range c {\n\t\tids[i] = c[i].ID\n\t}\n\treturn uuo.RemoveUseridIDs(ids...)\n}", "func (s *service) RemoveByID(ctx context.Context, id string) error {\n\tlogger := log.With(s.logger, \"method\", \"RemovebyID\")\n\tif Orders.IsEmpty() {\n\t\tlevel.Error(logger).Log(\"err\", ErrOrderBookIsEmpty)\n\t\treturn ErrOrderBookIsEmpty\n\t}\n\n\tif _, ok := Orders.Get(id); ok {\n\t\tif !ok {\n\t\t\tlevel.Error(logger).Log(\"err\", ok)\n\t\t\treturn ErrOrderNotFound\n\t\t}\n\t}\n\tOrders.Remove(id)\n\tspread.setPrices()\n\treturn nil\n}", "func (*SeatDataAccessObject) DeleteBySeatID(seatID int) {\n\tvar seat Seat\n\t_, err := orm.Table(seat).ID(seatID).Delete(&seat)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "func (d *DogNZB) Remove(t Type, id string) (*AddRemoveQuery, error) {\n\tb, err := d.get(d.buildURL(\"remove\", t, id))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar q AddRemoveQuery\n\tif err := xml.Unmarshal(b, &q); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// if dognzb sent an error back, we should also error\n\tif q.ErrorCode != \"\" {\n\t\treturn nil, fmt.Errorf(\"%v\", q.ErrorDesc)\n\t}\n\treturn &q, nil\n}", "func (b *BlockQueue) delAddress(address string, balance int64, tx *Tx) {\n\n\t// Remove tx from address index\n\tq := b.addrTx[address]\n\tq.PopFront()\n\t\n\tif q.Len() == 0 {\n\t\tdelete(b.addrTx, address)\n\t}\n\n\t// Update accumulated address balance\n\tnew_balance := b.addrBalance[address] - balance\n\tif new_balance == 0 {\n\t\tdelete(b.addrBalance, address)\n\t} else {\n\t\tb.addrBalance[address] = new_balance\n\t}\n}", "func (uu *UserUpdate) RemoveUserid(c ...*Carservice) *UserUpdate {\n\tids := make([]int, len(c))\n\tfor i := range c {\n\t\tids[i] = c[i].ID\n\t}\n\treturn uu.RemoveUseridIDs(ids...)\n}", "func Del(id string) error {\n\treturn getC().Del(id)\n}", "func Del(id string) error {\n\treturn getC().Del(id)\n}", "func Del(id string) error {\n\treturn getC().Del(id)\n}", "func DeleteAddressPoolInfo(ctx iris.Context) {\n\turi := ctx.Request().RequestURI\n\tfabricID := ctx.Params().Get(\"id\")\n\n\tif _, err := capmodel.GetFabric(fabricID); err != nil {\n\t\terrMsg := fmt.Sprintf(\"failed to fetch fabric data for uri %s: %s\", uri, err.Error())\n\t\tcreateDbErrResp(ctx, err, errMsg, []interface{}{\"Fabric\", fabricID})\n\t\treturn\n\t}\n\n\taddresspoolData, err := capmodel.GetAddressPool(fabricID, uri)\n\tif err != nil {\n\t\terrMsg := fmt.Sprintf(\"failed to fetch AddressPool data for uri %s: %s\", uri, err.Error())\n\t\tcreateDbErrResp(ctx, err, errMsg, []interface{}{\"AddressPool\", fabricID})\n\t\treturn\n\t}\n\tif addresspoolData.Links != nil && len(addresspoolData.Links.Zones) > 0 {\n\t\terrMsg := fmt.Sprintf(\"AddressPool cannot be deleted as there are dependent Zone still tied to it\")\n\t\tlog.Error(errMsg)\n\t\tresp := updateErrorResponse(response.ResourceCannotBeDeleted, errMsg, []interface{}{uri, \"AddressPool\"})\n\t\tctx.StatusCode(http.StatusNotAcceptable)\n\t\tctx.JSON(resp)\n\t\treturn\n\t}\n\t// Todo:Add the validation to verify the links\n\tif err = capmodel.DeleteAddressPool(fabricID, uri); err != nil {\n\t\terrMsg := fmt.Sprintf(\"failed to delete fabric data in DB for uri %s: %s\", uri, err.Error())\n\t\tcreateDbErrResp(ctx, err, errMsg, []interface{}{\"Fabric\", fabricID})\n\t\treturn\n\t}\n\tctx.StatusCode(http.StatusNoContent)\n}", "func (r *LBServiceReconciler) withdrawService(ctx context.Context, sc *ServerWithConfig, key resource.Key) error {\n\tadvertisements := sc.ServiceAnnouncements[key]\n\t// Loop in reverse order so we can delete without effect to the iteration.\n\tfor i := len(advertisements) - 1; i >= 0; i-- {\n\t\tadvertisement := advertisements[i]\n\t\tif err := sc.Server.WithdrawPath(ctx, types.PathRequest{Path: advertisement}); err != nil {\n\t\t\t// Persist remaining advertisements\n\t\t\tsc.ServiceAnnouncements[key] = advertisements\n\t\t\treturn fmt.Errorf(\"failed to withdraw deleted service route: %v: %w\", advertisement.NLRI, err)\n\t\t}\n\n\t\t// Delete the advertisement after each withdraw in case we error half way through\n\t\tadvertisements = slices.Delete(advertisements, i, i+1)\n\t}\n\n\t// If all were withdrawn without error, we can delete the whole svc from the map\n\tdelete(sc.ServiceAnnouncements, key)\n\n\treturn nil\n}", "func DelDPSDetailById(id int64) (err error) {\n\to := orm.NewOrm()\n\tv := DPSDetail{Id: id}\n\t// ascertain id exists in the database\n\tif err = o.Read(&v); err == nil {\n\t\tvar num int64\n\t\tif num, err = o.Delete(&DPSDetail{Id: id}); err == nil {\n\t\t\tfmt.Println(\"Number of records deleted in database:\", num)\n\t\t}\n\t}\n\treturn\n}", "func deleteById(l []ClientType, id string) (list []ClientType) {\n\t/*\n\t * Delete an element of the list by its Id given by 'id'\n\t */\n\t\n\tlist = l\n\tfor index, value := range l {\n\t\tif (value.client_id == id) {\n\t\t\tlist = removeIndex(l, index)\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn list\n}", "func (p *Store) Del(ctx context.Context, round uint64) error {\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tdefault:\n\t}\n\n\tconst query = `\n\tDELETE FROM\n\t\tbeacon_details\n\tWHERE\n\t\tbeacon_id = :id AND\n\t\tround = :round`\n\n\tdata := struct {\n\t\tID int `db:\"id\"`\n\t\tRound uint64 `db:\"round\"`\n\t}{\n\t\tID: p.beaconID,\n\t\tRound: round,\n\t}\n\n\t_, err := p.db.NamedExecContext(ctx, query, data)\n\treturn err\n}", "func (m *MemberService) DeleteAddress(ctx context.Context, addressID string) error {\n\tdata, err := m.DELETE(\"/address/\" + addressID).\n\t\tAuth(m.Presign(time.Minute)).\n\t\tDo(ctx).Bytes()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar resp Err\n\tif err := jsoniter.Unmarshal(data, &resp); err != nil {\n\t\treturn err\n\t}\n\n\tif resp.Code > 0 {\n\t\treturn resp\n\t}\n\n\treturn nil\n}", "func (t *Tkeyid) DelFromId(id uint) (key string, ok bool) {\n\tkey, ok = t.idtokey[id]\n\tif ok {\n\t\tdelete(t.idtokey, id)\n\t\tdelete(t.keytoid, key)\n\t}\n\treturn\n}", "func (as *Service) Delete(id string) error {\n\treq, err := as.httpClient.NewRequest(http.MethodDelete, fmt.Sprintf(\"/setup/account/%s\", id), nil)\n\tv := make(map[string]interface{})\n\t_, err = as.httpClient.Do(req, &v)\n\treturn err\n}", "func (dao *DAO) RemoveExpenseByID(id string) error {\r\n\terr := db.C(dao.ExpenseCollection).RemoveId(bson.ObjectIdHex(id))\r\n\r\n\treturn err\r\n}", "func DeleteByID() {\n\n}", "func (gt GtwyMgr) Delete(ctx context.Context, appcontext, remoteAddress string) error {\n\tif EnvDebugOn {\n\t\tlblog.LogEvent(\"GtwyMgr\", \"Delete\", \"info\", \"start\")\n\t}\n\n\t//check the approval list\n\tq := datastore.NewQuery(gt.bc.GetConfigValue(ctx, \"EnvGtwayDsKind\")).\n\t\tNamespace(gt.bc.GetConfigValue(ctx, \"EnvGtwayDsNamespace\")).\n\t\tFilter(\"appcontext =\", appcontext).\n\t\tFilter(\"remoteaddress =\", remoteAddress).\n\t\tKeysOnly()\n\n\tvar arr []Gateway\n\tkeys, err := gt.ds.GetAll(ctx, q, &arr)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttx, err := gt.ds.NewTransaction(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := tx.DeleteMulti(keys); err != nil {\n\t\ttx.Rollback()\n\t\treturn err\n\t}\n\n\tif _, err = tx.Commit(); err != nil {\n\t\treturn err\n\t}\n\n\tif EnvDebugOn {\n\t\tlblog.LogEvent(\"GtwyMgr\", \"Delete\", \"info\", \"end\")\n\t}\n\treturn nil\n}", "func (data *DNSData) Remove(name string) error {\n\tfqdn := dns.Fqdn(name)\n\n\taRecord, ok := data.v4Addresses[fqdn]\n\tif ok {\n\t\tarpa, err := dns.ReverseAddr(aRecord.A.String())\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tdelete(data.reverseLookups, arpa)\n\t}\n\tdelete(data.v4Addresses, fqdn)\n\n\taaaaRecord, ok := data.v6Addresses[fqdn]\n\tif ok {\n\t\tarpa, err := dns.ReverseAddr(aaaaRecord.AAAA.String())\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tdelete(data.reverseLookups, arpa)\n\t}\n\tdelete(data.v6Addresses, fqdn)\n\n\treturn nil\n}", "func (al *AddrList) RemoveAddress(address string) {\n\n\tal.slice = removeStringFromSlice(address, al.slice)\n\n\t//re-build the comma-seperated string of addresses\n\tal.csv = toAddrString(al.slice)\n\t\n}", "func (k Keeper) RemoveDeposit(ctx sdk.Context, id uint64) {\n\tstore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DepositKey))\n\tstore.Delete(GetDepositIDBytes(id))\n}", "func (*wsNotificationManager) removeAddrRequest(addrs map[string]map[chan struct{}]*wsClient,\n\twsc *wsClient, addr string) {\n\n\t// Remove the request tracking from the client.\n\tdelete(wsc.addrRequests, addr)\n\n\t// Remove the client from the list to notify.\n\tcmap, ok := addrs[addr]\n\tif !ok {\n\t\trpcsLog.Warnf(\"Attempt to remove nonexistent addr request \"+\n\t\t\t\"<%s> for websocket client %s\", addr, wsc.addr)\n\t\treturn\n\t}\n\tdelete(cmap, wsc.quit)\n\n\t// Remove the map entry altogether if there are no more clients\n\t// interested in it.\n\tif len(cmap) == 0 {\n\t\tdelete(addrs, addr)\n\t}\n}", "func (i *ImmediateCron) Remove(id cron.EntryID) {}", "func removeBobba(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tid, err := getRequestID(vars, \"id\")\n\n\t// Set JSON header\n\tw.Header().Set(\"Content-type\", \"application/json\")\n\tif err != nil {\n\t\terrPayload := buildErrorPayload(idEmptyRemove, 200)\n\n\t\tw.Write(errPayload)\n\t\treturn\n\t}\n\n\terr = runRemoveRoutine(id)\n\tif err != nil {\n\t\terrPayload := buildErrorPayload(err.Error(), 200)\n\t\tw.Write(errPayload)\n\t}\n\n\tpayload := buildSuccessPayload(\"success\", 200)\n\tw.Write(payload)\n}", "func RemoveWalletFederationAddress(uc *mw.IcopContext, c *gin.Context) {\n\tvar l RemoveWalletFederationAddressRequest\n\tif err := c.Bind(&l); err != nil {\n\t\tc.JSON(http.StatusBadRequest, cerr.LogAndReturnError(uc.Log, err, cerr.ValidBadInputData, cerr.BindError))\n\t\treturn\n\t}\n\n\tif valid, validErrors := cerr.ValidateStruct(uc.Log, l); !valid {\n\t\tc.JSON(http.StatusBadRequest, validErrors)\n\t\treturn\n\t}\n\n\tuserID := mw.GetAuthUser(c).UserID\n\n\t//remove the wallet\n\treq := &pb.WalletChangeFederationAddressRequest{\n\t\tBase: NewBaseRequest(uc),\n\t\tId: l.ID,\n\t\tUserId: userID,\n\t\tFriendlyId: \"\",\n\t\tDomain: \"\",\n\t}\n\t_, err := dbClient.WalletChangeFederationAddress(c, req)\n\tif err != nil {\n\t\tc.JSON(http.StatusInternalServerError, cerr.LogAndReturnError(uc.Log, err, \"Error removing wallet federation address\", cerr.GeneralError))\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, \"{}\")\n}", "func (tr *TestRunner) Del(addr *net.UDPAddr) {\n\ttr.mutex.Lock()\n\tdefer tr.mutex.Unlock()\n\t// Find the element\n\tfor i, v := range tr.targets {\n\t\tif v == addr {\n\t\t\t// Delete the element\n\t\t\t// This doesn't preserve order because it shouldn't matter.\n\t\t\t// Also it's WAY more efficient, especially at scale.\n\t\t\ttr.targets[i] = tr.targets[len(tr.targets)-1]\n\t\t\ttr.targets[len(tr.targets)-1] = nil\n\t\t\ttr.targets = tr.targets[:len(tr.targets)-1]\n\t\t}\n\t}\n}", "func deleteBook(id int) {\n\tfmt.Println(\"func: getBook\")\n\tfor index, book := range books {\n\t\tif book.ID == id {\n\t\t\tbooks = append(books[:index], books[index + 1:]...)\n\t\t\treturn\n\t\t}\n\t}\n}", "func UPSDelete(id string) error {\n\tfor index, item := range ups {\n\t\tif item.ID == id {\n\t\t\tups = append(ups[:index], ups[index+1:]...)\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn fmt.Errorf(\"UPS %s Not Found\", id)\n}", "func deleteItem(id string) error {\n\tdeathrow := findItem(id)\n\tfor i, _ := range items {\n\t\tfound := getXidString(deathrow)\n\t\tif id == found {\n\t\t\titems = append(items[:i], items[i+1:]...)\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn fmt.Errorf(\"Could not find item with id of %v to delete\", id)\n}", "func addIDToDeleteRequest(r *resource,\n\tinput *svcsdk.DeleteVpcEndpointsInput) error {\n\tif r.ko.Status.VPCEndpointID == nil {\n\t\treturn errors.New(\"unable to extract VPCEndpointID from resource\")\n\t}\n\tinput.VpcEndpointIds = []*string{r.ko.Status.VPCEndpointID}\n\treturn nil\n}", "func (r *PoolNAPTRResource) Delete(id string) error {\n\tif err := r.c.ModQuery(\"DELETE\", BasePath+PoolNAPTREndpoint+\"/\"+id, nil); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func DeletePoint(db *gorm.DB, id string) error {\n\tpoint := new(model.Point)\n\tif err := db.Where(\"id = ? \", id).Delete(&point).Error; err != nil {\n\t\tlog.Println(err)\n\t\treturn err\n\t}\n\n\t//tag := new(model.Tag)\n\t//if err := db.Where(\"post_id = ? \", id).Delete(&tag).Error; err != nil {\n\t//\tlog.Println(err)\n\t//}\n\n\treturn nil\n}", "func (r *BillingRepository) DeleteBillingById(id string) error {\n\terr := r.C.Remove(bson.M{\"_id\": bson.ObjectIdHex(id)})\n\treturn err\n}", "func (m *UserMutation) RemoveAddresIDs(ids ...int64) {\n\tif m.removedaddress == nil {\n\t\tm.removedaddress = make(map[int64]struct{})\n\t}\n\tfor i := range ids {\n\t\tm.removedaddress[ids[i]] = struct{}{}\n\t}\n}", "func (s ids) remove(id int) ids {\n\tindex := sort.SearchInts([]int(s), id)\n\tif index < len(s) && s[index] == id {\n\t\ts = append(s[:index], s[index+1:]...)\n\t}\n\treturn s\n}", "func (e Endpoints) DeleteAddress(ctx context.Context, profileID string, addressID string) error {\n\trequest := deleteAddressRequest{ProfileID: profileID, AddressID: addressID}\n\n\tresponse, err := e.DeleteAddressEndpoint(ctx, request)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresp := response.(deleteAddressResponse)\n\n\treturn resp.Err\n}", "func (s *SweepPruneSet[T]) Remove(id SweepPruneItemID) {\n\titemIndex := uint32(id)\n\titem := &s.items[itemIndex]\n\titem.Position = dprec.Vec3{\n\t\tX: math.Inf(+1),\n\t\tY: math.Inf(+1),\n\t\tZ: math.Inf(+1),\n\t}\n\titem.Radius = 1.0\n\tvar zeroV T\n\titem.Value = zeroV\n\ts.dirtyItemIDs[itemIndex] = struct{}{}\n\ts.freeItemIDs.Push(itemIndex)\n}", "func Remove(w http.ResponseWriter, r *http.Request) {\n\tparams := mux.Vars(r)\n\n\tid := params[\"id\"]\n\n\tif id == \"\" {\n\t\tutils.HTTPResponse(w, http.StatusInternalServerError, \"Bad Request, id is missing.\", false)\n\t\treturn\n\t}\n\n\tresult, err := db.Connection.Exec(utils.BuildString(\"DELETE FROM moedas WHERE id = \", id))\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\tutils.HTTPResponse(w, http.StatusInternalServerError, \"Error ocurred while removing data, please try again.\", false)\n\t\treturn\n\t}\n\n\tif rows, _ := result.RowsAffected(); rows == 0 {\n\t\tlog.Println(err.Error())\n\t\tutils.HTTPResponse(w, http.StatusInternalServerError, \"Error ocurred while removing data, please try again.\", false)\n\t\treturn\n\t}\n\n\tutils.HTTPResponse(w, http.StatusOK, \"Currency removed successfully!\", false)\n}", "func (m MariaDB) Remove(ctx context.Context, id string) (int64, error) {\n\tsqlQuery := \"DELETE FROM person WHERE id = ?\"\n\trslt, err := m.Person.ExecContext(ctx, sqlQuery, id)\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"could not remove data\")\n\t}\n\tcount, err := rslt.RowsAffected()\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"rows are not affected\")\n\t}\n\treturn count, nil\n}", "func Remove(name string) error", "func (db *Tool) Delete(id int) error {\n\ttools, err := db.fetchTools()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor i, v := range tools {\n\t\tif id == v.ID {\n\t\t\ttools = append(tools[:i], tools[i+1:]...)\n\t\t}\n\t}\n\n\tif err = Save(toolData, tools); err != nil {\n\t\treturn errors.New(\"problem making updates, please try again\")\n\t}\n\n\t// if tool has an associated rental, delete rental\n\tr := Rental{}\n\tif err = r.cascade(id, 0); err != nil {\n\t\treturn errors.New(\"rental not found\")\n\t}\n\n\treturn nil\n}", "func deletePerson(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tpersonID := ps.ByName(\"id\")\n\tfor index, item := range people {\n\t\tif item.ID == personID {\n\t\t\tpeople = append(people[:index], people[index+1:]...)\n\t\t\tbreak\n\t\t}\n\t}\n\tjson.NewEncoder(w).Encode(people)\n}", "func DeleteWorkoutByRoutineID(id string, db *sql.DB) {\n\tquery := fmt.Sprintf(`DELETE FROM Workouts WHERE routine_id = \"%s\"`, id)\n\tdb.Exec(query)\n}", "func (b *Bus) Remove(p Passenger) {\n\tdelete(b.passengers, p.SSN)\n\tfmt.Printf(\"%s: unboarded passenger with SSN %q\\n\", b.name, p.SSN)\n}", "func DeleteRequest(w http.ResponseWriter, r *http.Request, p httprouter.Params) {\n\t a:= p.ByName(\"id\")\n\t ac,_ := strconv.Atoi(a)\n\t sess:=getSession();\n er := sess.DB(\"trip-planner\").C(\"locations\").Remove(bson.M{\"id\": ac})\n if er!=nil {\n \tpanic(er)\n }\n\tw.WriteHeader(200)\n}", "func (p *pool) deleteFromID(id int) error {\n\tconn := p.Get()\n\tdefer conn.Close()\n\n\text, err := redis.String(conn.Do(\"HGET\", key(\"entry\", strconv.Itoa(id)), \"fileext\"))\n\tif err != nil {\n\t\treturn xerrors.Errorf(\"can not get image extension %d: %w\", id, err)\n\t}\n\n\t// Delete from list\n\tif _, err := conn.Do(\"SREM\", key(\"entries\"), id); err != nil {\n\t\treturn xerrors.Errorf(\"can not delete entry id: %w\", err)\n\t}\n\n\t// Delete from redis\n\tif _, err := conn.Do(\"DEL\", key(\"entry\", strconv.Itoa(id))); err != nil {\n\t\treturn xerrors.Errorf(\"can not delete entry: %w\", err)\n\t}\n\n\t// Delete image from disk\n\tfilePath := path.Join(mailimagePath(), \"images\", fmt.Sprintf(\"%d%s\", id, ext))\n\tif err := os.Remove(filePath); err != nil {\n\t\treturn xerrors.Errorf(\"can not delete image from disk: %w\", err)\n\t}\n\n\t// Delete mail fom disk\n\tfilePath = path.Join(mailimagePath(), \"success\", strconv.Itoa(id))\n\tif err := os.Remove(filePath); err != nil {\n\t\treturn xerrors.Errorf(\"can not delete file from disk: %w\", err)\n\t}\n\treturn nil\n}", "func (cs *ClientStore) RemoveByID(id string) (err error) {\n\tcs.cHandler(cs.ccfg.ClientsCName, func(c *mongo.Collection) {\n\t\tif _, cerr := c.DeleteOne(context.TODO(), db.Map{\"id\": id}); cerr != nil {\n\t\t\terr = cerr\n\t\t\treturn\n\t\t}\n\t})\n\n\treturn\n}", "func (b *RaftBalloon) remove(id string) error {\n\tif b.raft.api.State() != raft.Leader {\n\t\treturn ErrNotLeader\n\t}\n\n\tf := b.raft.api.RemoveServer(raft.ServerID(id), 0, 0)\n\tif f.Error() != nil {\n\t\tif f.Error() == raft.ErrNotLeader {\n\t\t\treturn ErrNotLeader\n\t\t}\n\t\treturn f.Error()\n\t}\n\n\tcmd := &commands.MetadataDeleteCommand{Id: id}\n\t_, err := b.raftApply(commands.MetadataDeleteCommandType, cmd)\n\n\treturn err\n}", "func (n *NIC) RemoveAddress(addr tcpip.Address) error {\n\tn.mu.Lock()\n\tr := n.endpoints[NetworkEndpointID{addr}]\n\tif r == nil || !r.holdsInsertRef {\n\t\tn.mu.Unlock()\n\t\treturn tcpip.ErrBadLocalAddress\n\t}\n\n\tr.holdsInsertRef = false\n\tn.mu.Unlock()\n\n\tr.decRef()\n\n\treturn nil\n}", "func (uuo *UserUpdateOne) RemoveUserof(a ...*Ambulance) *UserUpdateOne {\n\tids := make([]int, len(a))\n\tfor i := range a {\n\t\tids[i] = a[i].ID\n\t}\n\treturn uuo.RemoveUserofIDs(ids...)\n}", "func (p *UserStoreClient) RemoveFromBusiness(ctx context.Context, authenticationToken string, emailAddress string) (err error) {\n var _args21 UserStoreRemoveFromBusinessArgs\n _args21.AuthenticationToken = authenticationToken\n _args21.EmailAddress = emailAddress\n var _result22 UserStoreRemoveFromBusinessResult\n if err = p.Client_().Call(ctx, \"removeFromBusiness\", &_args21, &_result22); err != nil {\n return\n }\n switch {\n case _result22.UserException!= nil:\n return _result22.UserException\n case _result22.SystemException!= nil:\n return _result22.SystemException\n case _result22.NotFoundException!= nil:\n return _result22.NotFoundException\n }\n\n return nil\n}", "func (d *DirectAddress) Delete(key int) {\n\tif err := d.validateKey(key); err != nil {\n\t\treturn\n\t}\n\td.array[key-d.uMin] = nil\n}", "func RemovePayee(id bson.ObjectId, payeeID bson.ObjectId) User {\n\tsession, _ := mgo.Dial(\"127.0.0.1\")\n\tdefer session.Close()\n\tsession.SetMode(mgo.Monotonic, true)\n\tdb := session.DB(\"reimburse-me\").C(\"user\")\n\tuserID := bson.M{\"_id\": id}\n\tchange := bson.M{\"$pull\": bson.M{\n\t\t\"payees\": payeeID,\n\t}}\n\tdb.Update(userID, change)\n\tvar user User\n\tdb.Find(bson.M{\"_id\": id}).One(&user)\n\treturn user\n}", "func removeBook(id uint64){\n\t_onlyCurator()\n\tstate.WriteUint64(REMOVED_KEY, _getRemoved() + 1)\n\tstate.Clear(_bookId(id))\n}", "func (r MockRateRepository) RemoveByPairID(id int64) error {\n\tif id == 2 {\n\t\treturn errors.New(\"id not found\")\n\t}\n\treturn nil\n}", "func RemoveFromArea(key, set string) error {\n\tconn := db.Pool.Get()\n\tdefer conn.Close()\n\n\treturn db.Srem(conn, set, key)\n}", "func DeleteAddrEntry(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\t// get query parameters\n\tqueryValues := r.URL.Query()\n\tlastName := queryValues.Get(\"lastName\")\n\tfirstName := queryValues.Get(\"firstName\")\n\taddress, ok := GetEntry(firstName, lastName)\n\tif !ok {\n\t\thttp.Error(w, fmt.Sprintf(\"Entry not found for firstName: %s, lastName: %s\", firstName, lastName), 404)\n\t\treturn\n\t}\n\tDeleteEntry(address)\n\n}", "func (h *Handler) DeleteSavingByUserID(w http.ResponseWriter, r *http.Request, param httprouter.Params) {\n\tuserID, err := strconv.ParseInt(param.ByName(\"userID\"), 10, 64)\n\tif err != nil {\n\t\tlog.Printf(\"[internal][GetUserByID] invalid user_id :%+v\\n\", err)\n\t\treturn\n\t}\n\n\tquery := fmt.Sprintf(\"DELETE FROM savings WHERE user_id = %d\", userID)\n\t_, err = h.DB.Exec(query)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n\n\trenderJSON(w, []byte(`\n\t{\n\t\tstatus: \"success\",\n\t\tmessage: \"Delete book success!\"\n\t}\n\t`), http.StatusOK)\n}", "func (uu *UserUpdate) RemoveUserof(a ...*Ambulance) *UserUpdate {\n\tids := make([]int, len(a))\n\tfor i := range a {\n\t\tids[i] = a[i].ID\n\t}\n\treturn uu.RemoveUserofIDs(ids...)\n}", "func (db DB) RemoveSpend(ctx context.Context, id uint) error {\n\tif !db.checkSpend(ctx, id) {\n\t\treturn common.ErrSpendNotExist\n\t}\n\n\treturn db.db.RunInTransaction(ctx, func(tx *pg.Tx) error {\n\t\tdayID, err := db.selectSpendDayID(ctx, tx, id)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t_, err = tx.ModelContext(ctx, (*Spend)(nil)).Where(\"id = ?\", id).Delete()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tmonthID, err := db.selectMonthIDByDayID(ctx, tx, dayID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn db.recomputeAndUpdateMonth(tx, monthID)\n\t})\n}", "func (d *Driver) Remove(id string) error {\n\tlogrus.Debugf(\"Remove - id %s\", id)\n\tif strings.HasSuffix(id, \"-init\") {\n\t\treturn nil\n\t}\n\treturn d.ioctl(LayerRemove, \"\", id)\n}", "func (b *Bookmarks) RemoveAt(idx int) {\n\tif idx < 0 || idx >= len(b.Bookmark) {\n\t\treturn\n\t}\n\tb.Bookmark = append(b.Bookmark[:idx], b.Bookmark[idx+1:]...)\n}", "func (oauthClient *OauthClient) Delete(db *gorm.DB, id uuid.UUID) error {\n\tif err := db.Where(\"id = ?\", id).Delete(&oauthClient).Error; err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (bl *blackList) delete(ip string, port int) {\n\tbl.list.Delete(bl.genKey(ip, port))\n}", "func (c *Client) Remove(ctx context.Context, id uint64) error {\n\trequest := protocol.Message{}\n\trequest.Init(4096)\n\tresponse := protocol.Message{}\n\tresponse.Init(4096)\n\n\tprotocol.EncodeRemove(&request, id)\n\n\tif err := c.protocol.Call(ctx, &request, &response); err != nil {\n\t\treturn err\n\t}\n\n\tif err := protocol.DecodeEmpty(&response); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (b *books) Remove(id string) bool {\n\n\tif !b.isOpen() {\n\t\tlog.Panic(\"Repositorio não aberto\")\n\t}\n\n\t_, err := b.db.Exec(\"DELETE FROM CAD_BOOKS WHERE COD_BOOK = ?\", id)\n\n\treturn err == nil\n}", "func (s *PSlice) Remove(addr swarm.Address, po uint8) {\n\ts.Lock()\n\tdefer s.Unlock()\n\n\te, i := s.exists(addr)\n\tif !e {\n\t\treturn\n\t}\n\n\ts.peers = append(s.peers[:i], s.peers[i+1:]...)\n\ts.decDeeper(po)\n}", "func (s *AdoptersService) DeleteAdopterByID(ctx context.Context, adopterID int64) (*Response, error) {\n\tu := fmt.Sprintf(\"/adopter/%v\", adopterID)\n\treq, err := s.client.NewRequest(\"DELETE\", u, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn s.client.Do(ctx, req, nil)\n}", "func (store *ProviderBackedStore) Del(id Identifier) {\n\tkey := id.Value()\n\tif _, existing := store.retriever[key]; existing {\n\t\tdelete(store.retriever, key)\n\t\tnewIDs := make([]Identifier, 0, len(store.ids)-1)\n\t\tfor _, oldID := range store.ids {\n\t\t\tif oldID.Value() != key {\n\t\t\t\tnewIDs = append(newIDs, oldID)\n\t\t\t}\n\t\t}\n\t\tstore.ids = newIDs\n\t}\n}", "func (m *MemberService) UpsertAddress(ctx context.Context, op *WithdrawAddressView) (*WithdrawAddressView, error) {\n\tdata, err := m.POST(\"/address\").\n\t\tBody(op).\n\t\tAuth(m.Presign(time.Minute)).\n\t\tDo(ctx).Bytes()\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar resp struct {\n\t\tErr\n\t\tAddress *WithdrawAddressView `json:\"address\"`\n\t}\n\n\tif err := jsoniter.Unmarshal(data, &resp); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif resp.Code > 0 {\n\t\treturn nil, resp.Err\n\t}\n\n\treturn resp.Address, nil\n}", "func (oauthClient *OauthClient) UnscoppedGetByID(db *gorm.DB, id uuid.UUID) error {\n\tif err := db.Unscoped().Where(\"id = ?\", id).Find(&oauthClient).Error; err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func DeletePerson(w http.ResponseWriter, req *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tparams := mux.Vars(req)\n\tid, _ := strconv.Atoi(params[\"id\"])\n\tfor index, person := range models.People {\n\t\tif person.ID == id {\n\t\t\tmodels.People = append(models.People[:index], models.People[index+1:]...)\n\t\t}\n\t}\n}", "func (self PostgresDatabase) UnbanAddr(addr string) (err error) {\n _, err = self.conn.Exec(\"DELETE FROM IPBans WHERE addr >>= $1\", addr)\n return\n}", "func (u *Util) RemoveAndRefund(username, hash string) error {\n\tif hash == \"\" {\n\t\treturn nil\n\t}\n\treturn u.UP.RemovePin(username, hash, \"public\")\n}", "func deletePeople(id int) {\n\tsqlStatement := `\nDELETE FROM people\nWHERE id = $1;`\n\t_, err := Db.Exec(sqlStatement, 1)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(\"People Deleted\", id)\n\n}", "func (as *AllState) DeleteBreakByID(id int) bool {\n\tfor i, br := range as.Breaks {\n\t\tif br.ID == id {\n\t\t\tas.Breaks = append(as.Breaks[:i], as.Breaks[i+1:]...)\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (b *BizDAO) DeleteUserByID(id string) error {\n\tquery := bson.M{\"_id\": bson.ObjectIdHex(id)}\n\terr := db.C(UCOLLECTION).Remove(query)\n\treturn err\n}", "func removeFromSorted(l *list.List, id ID) {\n\tfor e := l.Front(); e != nil; e = e.Next() {\n\t\tc := e.Value.(Contact)\n\t\tif c.NodeID.Equals(id) {\n\t\t\tl.Remove(e)\n\t\t\treturn\n\t\t}\n\t}\n}", "func RemoveUser(userID string) (err error) {\n\n err = checkInit()\n if err != nil {\n return\n }\n\n err = createError(032)\n\n if _, ok := data[\"users\"].(map[string]interface{})[userID]; ok {\n\n delete(data[\"users\"].(map[string]interface{}), userID)\n err = saveDatabase(data)\n\n return\n }\n\n return\n}", "func (a *Client) PostReturnAddressesByReturnAddressIDDelete(params *PostReturnAddressesByReturnAddressIDDeleteParams, authInfo runtime.ClientAuthInfoWriter) (*PostReturnAddressesByReturnAddressIDDeleteOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewPostReturnAddressesByReturnAddressIDDeleteParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"PostReturnAddressesByReturnAddressIdDelete\",\n\t\tMethod: \"DELETE\",\n\t\tPathPattern: \"/post/return-addresses/{return_address_id}\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &PostReturnAddressesByReturnAddressIDDeleteReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*PostReturnAddressesByReturnAddressIDDeleteOK), nil\n\n}", "func (i *ProjectIPServiceOp) Remove(ipReservationID string) (*Response, error) {\n\treturn i.Delete(ipReservationID)\n}", "func RemoveIPReservation(id string) error {\n\tclient, err := NewExtPacketClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, e := client.IPReservations.Remove(id)\n\treturn e\n}" ]
[ "0.55589956", "0.5514438", "0.54790044", "0.54399794", "0.5416836", "0.5332153", "0.5321886", "0.53084344", "0.5301175", "0.52927023", "0.52401966", "0.52376306", "0.52170765", "0.5206461", "0.5174361", "0.5145053", "0.5140159", "0.51046467", "0.50969785", "0.5090812", "0.50850946", "0.50722307", "0.505586", "0.505586", "0.505586", "0.502539", "0.5018256", "0.50030375", "0.4993085", "0.4985592", "0.4978683", "0.49722743", "0.49658704", "0.49619463", "0.4945906", "0.4940191", "0.49373347", "0.49347705", "0.49346188", "0.49238172", "0.49147022", "0.49103484", "0.49024457", "0.48505592", "0.4836375", "0.48356935", "0.48217854", "0.4816126", "0.48148903", "0.48118392", "0.48068374", "0.4797477", "0.4782661", "0.47767282", "0.4776184", "0.47715375", "0.47634056", "0.47628054", "0.47620758", "0.47592083", "0.4751241", "0.47509086", "0.4747385", "0.47379392", "0.4737361", "0.47326583", "0.47323605", "0.47231296", "0.47182882", "0.4716061", "0.4709825", "0.47064674", "0.47013164", "0.46998435", "0.46924448", "0.46803713", "0.46778017", "0.4668058", "0.46652818", "0.46628913", "0.4662191", "0.46503863", "0.46426597", "0.464233", "0.4642163", "0.46413487", "0.46344665", "0.46225837", "0.46142694", "0.4612585", "0.4605176", "0.46049637", "0.46024123", "0.4596137", "0.45915803", "0.45910862", "0.45822528", "0.4574587", "0.45691624", "0.45683935" ]
0.7032371
0
VerifyWithdrawal will verify a withdrawal given the verification token
VerifyWithdrawal проверит вывод, используя предоставленный токен проверки
func (as *AddressService) VerifyWithdrawal(token string) error { if err := as.client.Get(buildString("address/withdraw/verify/", token), nil); err != nil { return err } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (_Token *TokenSession) ExecuteWithdrawal() (*types.Transaction, error) {\n\treturn _Token.Contract.ExecuteWithdrawal(&_Token.TransactOpts)\n}", "func (_Token *TokenTransactorSession) ExecuteWithdrawal() (*types.Transaction, error) {\n\treturn _Token.Contract.ExecuteWithdrawal(&_Token.TransactOpts)\n}", "func (_Token *TokenTransactor) ExecuteWithdrawal(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _Token.contract.Transact(opts, \"executeWithdrawal\")\n}", "func (broadcast *Broadcast) ValidatorWithdraw(ctx context.Context, username, amount,\n\tprivKeyHex string, seq int64) (*model.BroadcastResponse, error) {\n\tmsg := model.ValidatorWithdrawMsg{\n\t\tUsername: username,\n\t\tAmount: amount,\n\t}\n\treturn broadcast.broadcastTransaction(ctx, msg, privKeyHex, seq, \"\", false)\n}", "func (_Lmc *LmcTransactor) Withdraw(opts *bind.TransactOpts, _tokenAmount *big.Int) (*types.Transaction, error) {\n\treturn _Lmc.contract.Transact(opts, \"withdraw\", _tokenAmount)\n}", "func VerifyTransaction(contract BasicFluenceContract, tx Transaction, minDeposit int64) {\n // checking that the client actually exists in the contract\n var deposit, ok = contract.ClientDeposits[tx.Seal.PublicKey]\n assertTrue(ok)\n\n // checking that the client has enough funds\n assertTrue(deposit >= minDeposit)\n\n // checking that the transaction was signed by this client\n assertTrue(Verify(tx.Seal, Hash(tx.Invoke)))\n}", "func withdraw(ctx iscp.Sandbox) (dict.Dict, error) {\n\tstate := ctx.State()\n\tmustCheckLedger(state, \"accounts.withdraw.begin\")\n\n\tif ctx.Caller().Address().Equals(ctx.ChainID().AsAddress()) {\n\t\t// if the caller is on the same chain, do nothing\n\t\treturn nil, nil\n\t}\n\ttokensToWithdraw, ok := GetAccountBalances(state, ctx.Caller())\n\tif !ok {\n\t\t// empty balance, nothing to withdraw\n\t\treturn nil, nil\n\t}\n\t// will be sending back to default entry point\n\ta := assert.NewAssert(ctx.Log())\n\t// bring balances to the current account (owner's account). It is needed for subsequent Send call\n\ta.Require(MoveBetweenAccounts(state, ctx.Caller(), commonaccount.Get(ctx.ChainID()), tokensToWithdraw),\n\t\t\"accounts.withdraw.inconsistency. failed to move tokens to owner's account\")\n\n\t// add incoming tokens (after fees) to the balances to be withdrawn. Otherwise they would end up in the common account\n\ttokensToWithdraw.AddAll(ctx.IncomingTransfer())\n\t// Send call assumes tokens are in the current account\n\ta.Require(ctx.Send(ctx.Caller().Address(), tokensToWithdraw, &iscp.SendMetadata{\n\t\tTargetContract: ctx.Caller().Hname(),\n\t}), \"accounts.withdraw.inconsistency: failed sending tokens \")\n\n\tctx.Log().Debugf(\"accounts.withdraw.success. Sent to address %s\", tokensToWithdraw.String())\n\n\tmustCheckLedger(state, \"accounts.withdraw.exit\")\n\treturn nil, nil\n}", "func (_WELV9 *WELV9Transactor) Withdraw(opts *bind.TransactOpts, wad *big.Int) (*types.Transaction, error) {\n\treturn _WELV9.contract.Transact(opts, \"withdraw\", wad)\n}", "func TstCheckWithdrawalStatusMatches(t *testing.T, s1, s2 WithdrawalStatus) {\n\tif s1.Fees() != s2.Fees() {\n\t\tt.Fatalf(\"Wrong amount of network fees; want %d, got %d\", s1.Fees(), s2.Fees())\n\t}\n\n\tif !reflect.DeepEqual(s1.Sigs(), s2.Sigs()) {\n\t\tt.Fatalf(\"Wrong tx signatures; got %x, want %x\", s1.Sigs(), s2.Sigs())\n\t}\n\n\tif !reflect.DeepEqual(s1.NextInputAddr(), s2.NextInputAddr()) {\n\t\tt.Fatalf(\"Wrong NextInputAddr; got %v, want %v\", s1.NextInputAddr(), s2.NextInputAddr())\n\t}\n\n\tif !reflect.DeepEqual(s1.NextChangeAddr(), s2.NextChangeAddr()) {\n\t\tt.Fatalf(\"Wrong NextChangeAddr; got %v, want %v\", s1.NextChangeAddr(), s2.NextChangeAddr())\n\t}\n\n\tif !reflect.DeepEqual(s1.Outputs(), s2.Outputs()) {\n\t\tt.Fatalf(\"Wrong WithdrawalOutputs; got %v, want %v\", s1.Outputs(), s2.Outputs())\n\t}\n\n\tif !reflect.DeepEqual(s1.transactions, s2.transactions) {\n\t\tt.Fatalf(\"Wrong transactions; got %v, want %v\", s1.transactions, s2.transactions)\n\t}\n\n\t// The above checks could be replaced by this one, but when they fail the\n\t// failure msg wouldn't give us much clue as to what is not equal, so we do\n\t// the individual checks above and use this one as a catch-all check in case\n\t// we forget to check any of the individual fields.\n\tif !reflect.DeepEqual(s1, s2) {\n\t\tt.Fatalf(\"Wrong WithdrawalStatus; got %v, want %v\", s1, s2)\n\t}\n}", "func (_WandappETH *WandappETHSession) Withdraw(proof []byte) (*types.Transaction, error) {\n\treturn _WandappETH.Contract.Withdraw(&_WandappETH.TransactOpts, proof)\n}", "func (_Lmc *LmcSession) Withdraw(_tokenAmount *big.Int) (*types.Transaction, error) {\n\treturn _Lmc.Contract.Withdraw(&_Lmc.TransactOpts, _tokenAmount)\n}", "func (_WandappETH *WandappETHTransactor) Withdraw(opts *bind.TransactOpts, proof []byte) (*types.Transaction, error) {\n\treturn _WandappETH.contract.Transact(opts, \"withdraw\", proof)\n}", "func (_Lmc *LmcTransactorSession) Withdraw(_tokenAmount *big.Int) (*types.Transaction, error) {\n\treturn _Lmc.Contract.Withdraw(&_Lmc.TransactOpts, _tokenAmount)\n}", "func (_WandappETH *WandappETHTransactorSession) Withdraw(proof []byte) (*types.Transaction, error) {\n\treturn _WandappETH.Contract.Withdraw(&_WandappETH.TransactOpts, proof)\n}", "func (_TokenStakingEscrow *TokenStakingEscrowTransactor) WithdrawRevoked(opts *bind.TransactOpts, operator common.Address) (*types.Transaction, error) {\n\treturn _TokenStakingEscrow.contract.Transact(opts, \"withdrawRevoked\", operator)\n}", "func (_IWETH *IWETHSession) Withdraw(arg0 *big.Int) (*types.Transaction, error) {\r\n\treturn _IWETH.Contract.Withdraw(&_IWETH.TransactOpts, arg0)\r\n}", "func (_EtherDelta *EtherDeltaTransactor) WithdrawToken(opts *bind.TransactOpts, token common.Address, amount *big.Int) (*types.Transaction, error) {\n\treturn _EtherDelta.contract.Transact(opts, \"withdrawToken\", token, amount)\n}", "func (_IWETH *IWETHTransactorSession) Withdraw(arg0 *big.Int) (*types.Transaction, error) {\r\n\treturn _IWETH.Contract.Withdraw(&_IWETH.TransactOpts, arg0)\r\n}", "func (_BondedECDSAKeep *BondedECDSAKeepTransactor) Withdraw(opts *bind.TransactOpts, _member common.Address) (*types.Transaction, error) {\n\treturn _BondedECDSAKeep.contract.Transact(opts, \"withdraw\", _member)\n}", "func (_Smartchef *SmartchefTransactor) Withdraw(opts *bind.TransactOpts, _amount *big.Int) (*types.Transaction, error) {\n\treturn _Smartchef.contract.Transact(opts, \"withdraw\", _amount)\n}", "func (_ElvTradable *ElvTradableTransactor) Withdraw(opts *bind.TransactOpts, _amount *big.Int) (*types.Transaction, error) {\n\treturn _ElvTradable.contract.Transact(opts, \"withdraw\", _amount)\n}", "func (sc stakingClient) Withdraw(fromInfo keys.Info, passWd, coinsStr, memo string, accNum, seqNum uint64) (\n\tresp sdk.TxResponse, err error) {\n\tif err = params.CheckKeyParams(fromInfo, passWd); err != nil {\n\t\treturn\n\t}\n\n\tcoin, err := sdk.ParseDecCoin(coinsStr)\n\tif err != nil {\n\t\treturn resp, fmt.Errorf(\"failed : parse Coins [%s] error: %s\", coinsStr, err)\n\t}\n\n\tmsg := types.NewMsgWithdraw(fromInfo.GetAddress(), coin)\n\n\treturn sc.BuildAndBroadcast(fromInfo.GetName(), passWd, memo, []sdk.Msg{msg}, accNum, seqNum)\n\n}", "func (s *Service) WithdrawSuccess(c context.Context, orderNo int64, tradeStatus int) (err error) {\n\tupWithdraw, err := s.dao.QueryUpWithdrawByID(c, orderNo)\n\tif err != nil {\n\t\tlog.Error(\"s.dao.QueryUpWithdrawByID error(%v)\", err)\n\t\treturn\n\t}\n\n\tif tradeStatus != _withdrawSuccess {\n\t\tlog.Info(\"param tradeStatus(%d) != withdraw success(2)\", tradeStatus)\n\t\treturn\n\t}\n\n\tif upWithdraw.State == _withdrawSuccess {\n\t\tlog.Info(\"withdraw has successed already\")\n\t\treturn\n\t}\n\n\ttx, err := s.dao.BeginTran(c)\n\tif err != nil {\n\t\tlog.Error(\"s.dao.BeginTran error(%v)\", err)\n\t\treturn\n\t}\n\n\t// update up_income_withdraw state\n\trows, err := s.dao.TxUpdateUpWithdrawState(tx, orderNo, _withdrawSuccess)\n\tif err != nil {\n\t\ttx.Rollback()\n\t\tlog.Error(\"s.dao.UpdateUpWithdrawState error(%v)\", err)\n\t\treturn\n\t}\n\tif rows != 1 {\n\t\ttx.Rollback()\n\t\tlog.Error(\"s.dao.UpdateUpWithdrawState Update withdraw record error id(%d)\", orderNo)\n\t\treturn\n\t}\n\n\t// update up_account withdraw\n\trows, err = s.dao.TxUpdateUpAccountWithdraw(tx, upWithdraw.MID, upWithdraw.WithdrawIncome)\n\tif err != nil {\n\t\ttx.Rollback()\n\t\tlog.Error(\"s.dao.UpdateUpAccountWithdraw error(%v)\", err)\n\t\treturn\n\t}\n\tif rows != 1 {\n\t\ttx.Rollback()\n\t\tlog.Error(\"s.dao.UpdateUpAccountWithdraw Update up account record error id(%d)\", orderNo)\n\t\treturn\n\t}\n\n\tmaxUpWithdrawDateVersion, err := s.dao.TxQueryMaxUpWithdrawDateVersion(tx, upWithdraw.MID)\n\tif err != nil {\n\t\ttx.Rollback()\n\t\tlog.Error(\"s.dao.QueryMaxUpWithdrawDateVersion error(%v)\", err)\n\t\treturn\n\t}\n\n\ttime := 0\n\tvar version int64\n\tfor {\n\t\tversion, err = s.dao.TxQueryUpAccountVersion(tx, upWithdraw.MID)\n\t\tif err != nil {\n\t\t\ttx.Rollback()\n\t\t\tlog.Error(\"s.dao.QueryUpAccountVersion error(%v)\", err)\n\t\t\treturn\n\t\t}\n\t\tif maxUpWithdrawDateVersion == \"\" {\n\t\t\tmaxUpWithdrawDateVersion = upWithdraw.DateVersion\n\t\t}\n\n\t\trows, err = s.dao.TxUpdateUpAccountUnwithdrawIncome(tx, upWithdraw.MID, maxUpWithdrawDateVersion, version)\n\t\tif err != nil {\n\t\t\ttx.Rollback()\n\t\t\tlog.Error(\"s.dao.UpdateUpAccountUnwithdrawIncome error(%v)\", err)\n\t\t\treturn\n\t\t}\n\t\tif rows == 1 {\n\t\t\tif err = tx.Commit(); err != nil {\n\t\t\t\tlog.Error(\"tx.Commit error\")\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\ttime++\n\t\tif time >= 10 {\n\t\t\ttx.Rollback()\n\t\t\tlog.Info(\"try to synchronize unwithdraw income 10 times error mid(%d)\", upWithdraw.MID)\n\t\t\terr = fmt.Errorf(\"try to synchronize unwithdraw income 10 times error mid(%d)\", upWithdraw.MID)\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn\n}", "func (_BREMICO *BREMICOTransactor) ConfirmWithdraw(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _BREMICO.contract.Transact(opts, \"confirmWithdraw\")\n}", "func (_TokenStakingEscrow *TokenStakingEscrowTransactor) Withdraw(opts *bind.TransactOpts, operator common.Address) (*types.Transaction, error) {\n\treturn _TokenStakingEscrow.contract.Transact(opts, \"withdraw\", operator)\n}", "func (_BREMICO *BREMICOSession) ConfirmWithdraw() (*types.Transaction, error) {\n\treturn _BREMICO.Contract.ConfirmWithdraw(&_BREMICO.TransactOpts)\n}", "func (_IWETH *IWETHTransactor) Withdraw(opts *bind.TransactOpts, arg0 *big.Int) (*types.Transaction, error) {\r\n\treturn _IWETH.contract.Transact(opts, \"withdraw\", arg0)\r\n}", "func (_Wmatic *WmaticTransactor) Withdraw(opts *bind.TransactOpts, wad *big.Int) (*types.Transaction, error) {\n\treturn _Wmatic.contract.Transact(opts, \"withdraw\", wad)\n}", "func (_BondedECDSAKeep *BondedECDSAKeepTransactorSession) Withdraw(_member common.Address) (*types.Transaction, error) {\n\treturn _BondedECDSAKeep.Contract.Withdraw(&_BondedECDSAKeep.TransactOpts, _member)\n}", "func (s *StorageECR721Fixed) Withdraw() error {\n\tevmTr, err := s.session.Withdraw()\n\tif err != nil {\n\t\terr = errors.Wrapf(err, \"failed to execute %s\", Withdraw)\n\t\tLogger.Error(err)\n\t\treturn err\n\t}\n\n\tLogger.Info(\"Executed \", Withdraw, \" hash: \", evmTr.Hash())\n\n\treturn nil\n}", "func (_BondedECDSAKeep *BondedECDSAKeepSession) Withdraw(_member common.Address) (*types.Transaction, error) {\n\treturn _BondedECDSAKeep.Contract.Withdraw(&_BondedECDSAKeep.TransactOpts, _member)\n}", "func (orc *Oracle) verifyTotalDailyWithdrawal(ts time.Time, state *OracleState, amount *big.Int) bool {\n\tcurrentAmount := state.TotalWithdrawalAmount.Value.Int\n\n\t// state timestamp always maintains 00:00:00 UTC timestamp\n\tdayStart := time.Unix(state.Timestamp, 0)\n\t// If current timestamp is after state timestamp for a day, assumed that we the total amount\n\t// should be reset first.\n\tif ts.Sub(dayStart).Hours() > 24 {\n\t\tcurrentAmount = big.NewInt(0)\n\t}\n\n\tnextAmount := big.NewInt(0).Add(currentAmount, amount)\n\treturn nextAmount.Cmp(orc.maxTotalDailyWithdrawalAmount.Int) > 0\n}", "func (_Wmatic *WmaticSession) Withdraw(wad *big.Int) (*types.Transaction, error) {\n\treturn _Wmatic.Contract.Withdraw(&_Wmatic.TransactOpts, wad)\n}", "func (_Wmatic *WmaticTransactorSession) Withdraw(wad *big.Int) (*types.Transaction, error) {\n\treturn _Wmatic.Contract.Withdraw(&_Wmatic.TransactOpts, wad)\n}", "func (_Token *TokenSession) InitiateWithdrawal() (*types.Transaction, error) {\n\treturn _Token.Contract.InitiateWithdrawal(&_Token.TransactOpts)\n}", "func (p *TDepositWithdrawServiceClient) AuditDepositWithdraw(ctx context.Context, traceId string, status string, mark string, withdrawId int32) (r bool, err error) {\n var _args5 TDepositWithdrawServiceAuditDepositWithdrawArgs\n _args5.TraceId = traceId\n _args5.Status = status\n _args5.Mark = mark\n _args5.WithdrawId = withdrawId\n var _result6 TDepositWithdrawServiceAuditDepositWithdrawResult\n if err = p.c.Call(ctx, \"auditDepositWithdraw\", &_args5, &_result6); err != nil {\n return\n }\n return _result6.GetSuccess(), nil\n}", "func (orc *Oracle) verifyAccountDailyWithdrawal(ts time.Time, account *Account, amount *big.Int) bool {\n\tcurrentAmount := big.NewInt(0)\n\tif account.TotalWithdrawalAmount != nil {\n\t\tcurrentAmount = account.TotalWithdrawalAmount.Value.Int\n\t}\n\n\t// each daily withdrawal period starts at 00:00:00 UTC\n\tdayStart := time.Unix(account.Timestamp, 0)\n\t// daily limit is reset every 24 hours\n\tif ts.Sub(dayStart).Hours() > 24 {\n\t\tcurrentAmount = big.NewInt(0)\n\t}\n\n\tnextAmount := big.NewInt(0).Add(currentAmount, amount)\n\treturn nextAmount.Cmp(orc.maxPerAccountDailyWithdrawalAmount.Int) > 0\n}", "func (f *Fortune) Withdrawal(amount decimal.Decimal) {\n\tf.active = f.active.Sub(amount)\n}", "func (_DelegateProfile *DelegateProfileTransactorSession) Withdraw() (*types.Transaction, error) {\n\treturn _DelegateProfile.Contract.Withdraw(&_DelegateProfile.TransactOpts)\n}", "func (_DelegateProfile *DelegateProfileTransactor) Withdraw(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _DelegateProfile.contract.Transact(opts, \"withdraw\")\n}", "func (_EtherDelta *EtherDeltaSession) WithdrawToken(token common.Address, amount *big.Int) (*types.Transaction, error) {\n\treturn _EtherDelta.Contract.WithdrawToken(&_EtherDelta.TransactOpts, token, amount)\n}", "func (_BREMICO *BREMICOTransactorSession) ConfirmWithdraw() (*types.Transaction, error) {\n\treturn _BREMICO.Contract.ConfirmWithdraw(&_BREMICO.TransactOpts)\n}", "func (_EtherDelta *EtherDeltaTransactorSession) WithdrawToken(token common.Address, amount *big.Int) (*types.Transaction, error) {\n\treturn _EtherDelta.Contract.WithdrawToken(&_EtherDelta.TransactOpts, token, amount)\n}", "func (_DelegateProfile *DelegateProfileSession) Withdraw() (*types.Transaction, error) {\n\treturn _DelegateProfile.Contract.Withdraw(&_DelegateProfile.TransactOpts)\n}", "func (user User) Withdraw(ctx context.Context, input *TransferInput, pin string) (*Snapshot, error) {\n\tif len(input.TraceID) == 0 {\n\t\tinput.TraceID = uuid.Must(uuid.NewV4()).String()\n\t}\n\tparas := utils.UnselectFields(input)\n\tdata, err := user.RequestWithPIN(ctx, \"POST\", \"/withdrawals\", paras, pin)\n\tif err != nil {\n\t\treturn nil, requestError(err)\n\t}\n\n\tvar resp struct {\n\t\tSnapshot *struct {\n\t\t\t*Snapshot\n\t\t\tMemo string `json:\"memo,omitempty\"`\n\t\t} `json:\"data,omitempty\"`\n\t\tError *Error `json:\"error,omitempty\"`\n\t}\n\tif err = json.Unmarshal(data, &resp); err != nil {\n\t\treturn nil, requestError(err)\n\t} else if resp.Error != nil {\n\t\treturn nil, resp.Error\n\t}\n\n\tresp.Snapshot.Data = resp.Snapshot.Memo\n\tif !input.verify(*resp.Snapshot.Snapshot) {\n\t\treturn nil, traceError()\n\t}\n\n\treturn resp.Snapshot.Snapshot, nil\n}", "func (_ElvTradableLocal *ElvTradableLocalTransactor) Withdraw(opts *bind.TransactOpts, _amount *big.Int) (*types.Transaction, error) {\n\treturn _ElvTradableLocal.contract.Transact(opts, \"withdraw\", _amount)\n}", "func (_Token *TokenTransactorSession) InitiateWithdrawal() (*types.Transaction, error) {\n\treturn _Token.Contract.InitiateWithdrawal(&_Token.TransactOpts)\n}", "func (_Smartchef *SmartchefSession) Withdraw(_amount *big.Int) (*types.Transaction, error) {\n\treturn _Smartchef.Contract.Withdraw(&_Smartchef.TransactOpts, _amount)\n}", "func (_Token *TokenTransactor) InitiateWithdrawal(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _Token.contract.Transact(opts, \"initiateWithdrawal\")\n}", "func (_XStaking *XStakingTransactor) Withdraw(opts *bind.TransactOpts, amount *big.Int) (*types.Transaction, error) {\n\treturn _XStaking.contract.Transact(opts, \"withdraw\", amount)\n}", "func (tc *Client) VerifyToken(ctx context.Context, token string,\n\tclient apiclient.HttpRunner) error {\n\n\tl := log.FromContext(ctx)\n\n\t// TODO sanitize token\n\n\turl := utils.JoinURL(tc.conf.TenantAdmAddr, TenantVerifyUri)\n\n\treq, err := http.NewRequest(http.MethodPost, url, nil)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to create request to tenant administrator\")\n\t}\n\n\t// tenant token is passed in Authorization header\n\treq.Header.Add(\"Authorization\", \"Bearer \"+token)\n\n\tctx, cancel := context.WithTimeout(ctx, tc.conf.Timeout)\n\tdefer cancel()\n\n\trsp, err := client.Do(req.WithContext(ctx))\n\tif err != nil {\n\t\tl.Errorf(\"tenantadm request failed: %v\", err)\n\t\treturn errors.Wrap(err, \"request to verify token failed\")\n\t}\n\tdefer rsp.Body.Close()\n\n\tswitch rsp.StatusCode {\n\n\tcase http.StatusUnauthorized: // 401, verification result negative\n\t\tapiErr := rest_utils.ParseApiError(rsp.Body)\n\t\tif !rest_utils.IsApiError(apiErr) {\n\t\t\treturn errors.Errorf(\"failed to parse tenantadm api error response\")\n\t\t}\n\n\t\treturn MakeErrTokenVerificationFailed(apiErr)\n\n\tcase http.StatusOK: // 200, token verified\n\t\treturn nil\n\tdefault:\n\t\treturn errors.Errorf(\"token verification request returned unexpected status %v\",\n\t\t\trsp.StatusCode)\n\t}\n}", "func (_Smartchef *SmartchefTransactorSession) Withdraw(_amount *big.Int) (*types.Transaction, error) {\n\treturn _Smartchef.Contract.Withdraw(&_Smartchef.TransactOpts, _amount)\n}", "func (_Contract *ContractTransactor) Withdraw(opts *bind.TransactOpts, value *big.Int) (*types.Transaction, error) {\n\treturn _Contract.contract.Transact(opts, \"withdraw\", value)\n}", "func Withdraw(interactor account.Interactor) fiber.Handler {\n\n\treturn func(ctx *fiber.Ctx) error {\n\t\tvar userDetails = ctx.Locals(\"userDetails\").(map[string]string)\n\t\tuserId := userDetails[\"userId\"]\n\n\t\tvar p param\n\t\t_ = ctx.BodyParser(&p)\n\n\t\tbalance, err := interactor.Withdraw(uuid.FromStringOrNil(userId), p.Amount)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn ctx.JSON(map[string]interface{}{\n\t\t\t\"message\": fmt.Sprintf(\"Amount successfully withdrawn. New balance %v\", balance),\n\t\t\t\"balance\": balance,\n\t\t\t\"userId\": userId,\n\t\t})\n\t}\n}", "func (c *Client) Withdraw(ctx context.Context, foreignID string, amount float64, currency, address string) (Withdrawal, error) {\n\treqBody := map[string]interface{}{\n\t\t\"foreign_id\": foreignID,\n\t\t\"amount\": amount,\n\t\t\"currency\": currency,\n\t\t\"address\": address,\n\t}\n\n\treqJSON, err := json.Marshal(reqBody)\n\tif err != nil {\n\t\treturn Withdrawal{}, fmt.Errorf(\"request body marshaling error: %w\", err)\n\t}\n\n\twithdrawalURL, err := joinURL(c.api, withdrawalEndpoint)\n\tif err != nil {\n\t\treturn Withdrawal{}, fmt.Errorf(\"request url creating error: %w\", err)\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, withdrawalURL.String(), bytes.NewBuffer(reqJSON))\n\tif err != nil {\n\t\treturn Withdrawal{}, fmt.Errorf(\"request creating error: %w\", err)\n\t}\n\n\tsig, err := createHmac(c.secret, reqJSON)\n\tif err != nil {\n\t\treturn Withdrawal{}, fmt.Errorf(\"hmac signature creationg error: %w\", err)\n\t}\n\n\treq.Header.Set(contentTypeHeader, jsonContentType)\n\treq.Header.Set(keyHeader, c.apiKey)\n\treq.Header.Set(signatureHeader, sig)\n\n\tresp, err := c.client.Do(req)\n\tif err != nil {\n\t\treturn Withdrawal{}, fmt.Errorf(\"request error: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\terr = ensureSuccessResponse(resp)\n\tif err != nil {\n\t\treturn Withdrawal{}, fmt.Errorf(\"request failed: %w\", err)\n\t}\n\n\trespBody := struct {\n\t\tData Withdrawal `json:\"data\"`\n\t}{}\n\n\terr = json.NewDecoder(resp.Body).Decode(&respBody)\n\tif err != nil {\n\t\treturn Withdrawal{}, fmt.Errorf(\"response unmarshaling error: %w\", err)\n\t}\n\n\treturn respBody.Data, nil\n}", "func (_TokenStakingEscrow *TokenStakingEscrowSession) WithdrawRevoked(operator common.Address) (*types.Transaction, error) {\n\treturn _TokenStakingEscrow.Contract.WithdrawRevoked(&_TokenStakingEscrow.TransactOpts, operator)\n}", "func (c *Client) Withdraw(ctx context.Context, p *WithdrawRequestBody) (err error) {\n\t_, err = c.WithdrawEndpoint(ctx, p)\n\treturn\n}", "func (_BREMICO *BREMICOTransactor) Withdraw(opts *bind.TransactOpts, _value *big.Int) (*types.Transaction, error) {\n\treturn _BREMICO.contract.Transact(opts, \"withdraw\", _value)\n}", "func (w *Wallet) Withdraw(amount Bitcoin) error {\n\n\tif amount > w.balance {\n\t\treturn errors.New(\"cannot withdraw, insufficient funds\")\n\t}\n\tw.balance -= amount\n\treturn nil\n}", "func (_XStaking *XStakingSession) Withdraw(amount *big.Int) (*types.Transaction, error) {\n\treturn _XStaking.Contract.Withdraw(&_XStaking.TransactOpts, amount)\n}", "func (_Contract *ContractTransactorSession) Withdraw(value *big.Int) (*types.Transaction, error) {\n\treturn _Contract.Contract.Withdraw(&_Contract.TransactOpts, value)\n}", "func (_XStaking *XStakingTransactorSession) Withdraw(amount *big.Int) (*types.Transaction, error) {\n\treturn _XStaking.Contract.Withdraw(&_XStaking.TransactOpts, amount)\n}", "func (_Cakevault *CakevaultTransactor) EmergencyWithdraw(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _Cakevault.contract.Transact(opts, \"emergencyWithdraw\")\n}", "func (c *Controller) FullWithdrawal(ctx context.Context) {\n\t_ = c.BGPMgr.ConfigurePeers(ctx, nil, nil) // cannot fail, no need for error handling\n}", "func (c *Controller) FullWithdrawal(ctx context.Context) {\n\t_ = c.BGPMgr.ConfigurePeers(ctx, nil, nil) // cannot fail, no need for error handling\n}", "func (u Usecase) Withdraw(ctx context.Context, accID vos.AccountID, amount vos.Money) error {\n\tconst operation = \"accounts.Usecase.Withdraw\"\n\n\tlog := logger.FromCtx(ctx).WithFields(logrus.Fields{\n\t\t\"accID\": accID,\n\t\t\"amount\": amount.Int(),\n\t})\n\n\tlog.Infoln(\"processing a withdrawal\")\n\n\tif amount <= 0 {\n\t\treturn ErrInvalidAmount\n\t}\n\n\tacc, err := u.GetAccountByID(ctx, accID)\n\tif err != nil {\n\t\treturn domain.Error(operation, err)\n\t}\n\n\tif acc.Balance < amount {\n\t\treturn ErrInsufficientBalance\n\t}\n\n\terr = u.accRepo.Withdraw(ctx, accID, amount)\n\n\tif err != nil {\n\t\treturn domain.Error(operation, err)\n\t}\n\n\tlog.Infoln(\"withdrawal successfully processed\")\n\n\treturn nil\n}", "func ExampleVerifyingToken() {\n\ttoken := \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0OTc4OTc1NjYsIm5hbWUiOiJ0cnVlIiwidXNlciI6InRydWUifQ.OE3v4g-_Grx18htmaQAOt2y7udW_RUuvv1nELK4Z-Sk\"\n\tValidateToken(token)\n}", "func (_TokenStakingEscrow *TokenStakingEscrowSession) Withdraw(operator common.Address) (*types.Transaction, error) {\n\treturn _TokenStakingEscrow.Contract.Withdraw(&_TokenStakingEscrow.TransactOpts, operator)\n}", "func (_Contract *ContractSession) Withdraw(value *big.Int) (*types.Transaction, error) {\n\treturn _Contract.Contract.Withdraw(&_Contract.TransactOpts, value)\n}", "func (_Cakevault *CakevaultTransactor) Withdraw(opts *bind.TransactOpts, _shares *big.Int) (*types.Transaction, error) {\n\treturn _Cakevault.contract.Transact(opts, \"withdraw\", _shares)\n}", "func (server *OpencxServer) withdrawFromLightning(params *coinparam.Params) (withdrawFunction func(*koblitz.PublicKey, int64) (string, error), err error) {\n\n\twithdrawFunction = func(pubkey *koblitz.PublicKey, amount int64) (txid string, err error) {\n\n\t\tif amount <= 0 {\n\t\t\terr = fmt.Errorf(\"Can't withdraw <= 0\")\n\t\t\treturn\n\t\t}\n\n\t\t// calculate fee, do this using subwallet because the funding will all be done through lit\n\t\t// TODO: figure out if there is redundancy with server.WalletMap and server.ExchangeNode.SubWallet and\n\t\t// if that redundancy is necessary. It might be\n\t\tfee := server.ExchangeNode.SubWallet[params.HDCoinType].Fee() * 1000\n\t\tif amount < consts.MinOutput+fee {\n\t\t\terr = fmt.Errorf(\"You can't withdraw any less than %d %s\", consts.MinOutput+fee, params.Name)\n\t\t\treturn\n\t\t}\n\n\t\tvar peerIdx uint32\n\t\tif peerIdx, err = server.GetPeerFromPubkey(pubkey); err != nil {\n\t\t\terr = fmt.Errorf(\"You may not have ever connected with the exchange, or you're using a different identity. The exchange can only authenticate for channel creating if you are the node: \\n%s\", err)\n\t\t\treturn\n\t\t}\n\n\t\tlogging.Infof(\"Checking if connected to peer\")\n\n\t\t// if we already have a channel and we can, we should push\n\t\tif !server.ExchangeNode.ConnectedToPeer(peerIdx) {\n\t\t\terr = fmt.Errorf(\"Not connected to peer! Please connect to the exchange. We don't know how to connect to you\")\n\t\t\treturn\n\t\t}\n\n\t\t// calculate capacity as a function of the amount to be sent\n\t\tvar ccap int64\n\t\tif amount < consts.MinChanCapacity {\n\t\t\tccap = consts.MinChanCapacity\n\t\t} else {\n\t\t\tccap = amount + consts.MinOutput + fee\n\t\t}\n\n\t\t// TODO: this should only happen when we get a proof that the other person actually took the withdraw / updated the state. We don't have a guarantee that they will always accept\n\n\t\t// clearing settlement layer\n\t\tif err = server.CreditUser(pubkey, uint64(amount), params); err != nil {\n\t\t\terr = fmt.Errorf(\"Error while crediting user for CreateChannel: %s\\n\", err)\n\t\t\treturn\n\t\t}\n\n\t\t// check if any of the channels are of the correct param and have enough capacity (-[min+fee])\n\n\t\t// make data but we don't really want any\n\t\tnoData := new([32]byte)\n\n\t\tlogging.Infof(\"Trying to fund channel\")\n\t\t// retrieve chanIdx because we need it for qchan for outpoint hash, if that's not useful anymore just make this chanIdx => _\n\t\tvar chanIdx uint32\n\t\tif chanIdx, err = server.ExchangeNode.FundChannel(peerIdx, params.HDCoinType, ccap, amount, *noData); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tlogging.Infof(\"Getting qchanidx\")\n\t\t// get qchan so we can get the outpoint hash\n\t\tvar qchan *qln.Qchan\n\t\tif qchan, err = server.ExchangeNode.GetQchanByIdx(chanIdx); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tlogging.Infof(\"We're pretty much done with this withdraw\")\n\t\t// get outpoint hash because that's useful information to return\n\t\ttxid = qchan.Op.Hash.String()\n\n\t\treturn\n\t}\n\treturn\n}", "func verifyFlow(secret map[string]interface{}, scope string, code string) (*Token, error) {\n\t// Construct a POST request to fetch OAuth token with the verificaton code.\n\tparams := url.Values{\n\t\t\"client_id\": []string{toString(secret[\"client_id\"])},\n\t\t\"code\": []string{code},\n\t\t\"scope\": []string{scope},\n\t\t\"grant_type\": []string{\"authorization_code\"},\n\t\t\"redirect_uri\": []string{oobCallbackUrn},\n\t}\n\tif clientSecret, ok := secret[\"client_secret\"]; ok {\n\t\tparams.Set(\"client_secret\", toString(clientSecret))\n\t}\n\n\t// Send the POST request and return token.\n\treturn retrieveAccessToken(toString(secret[\"token_uri\"]), params)\n}", "func (_TokenStakingEscrow *TokenStakingEscrowTransactorSession) WithdrawRevoked(operator common.Address) (*types.Transaction, error) {\n\treturn _TokenStakingEscrow.Contract.WithdrawRevoked(&_TokenStakingEscrow.TransactOpts, operator)\n}", "func AliceWithdrawFromTxAPIHandler(w http.ResponseWriter, r *http.Request) {\n\tLog := Logger.NewSessionLogger()\n\n\tvar plog PodLog\n\tplog.Result = LOG_RESULT_FAILED\n\tplog.Operation = LOG_OPERATION_TYPE_ALICE_WITHDRAW_FROM_TX\n\n\tdefer func() {\n\t\terr := insertLogToDB(plog)\n\t\tif err != nil {\n\t\t\tLog.Warnf(\"insert log error! %v\", err)\n\t\t\treturn\n\t\t}\n\t\tnodeRecovery(w, Log)\n\t}()\n\n\tsessionID := r.FormValue(\"session_id\")\n\tLog.Infof(\"start withdraw eth from transaction in contract...sessionID=%v\", sessionID)\n\tplog.Detail = fmt.Sprintf(\"sessionID=%v\", sessionID)\n\n\tif sessionID == \"\" {\n\t\tLog.Warnf(\"invalid sessionID. sessionID=%v\", sessionID)\n\t\tfmt.Fprintf(w, RESPONSE_INCOMPLETE_PARAM)\n\t\treturn\n\t}\n\ttx, rs, err := loadAliceFromDB(sessionID)\n\tif err != nil {\n\t\tLog.Warnf(\"failed to load transaction info from db. sessionID=%v, err=%v\", sessionID, err)\n\t\tfmt.Fprintf(w, RESPONSE_READ_DATABASE_FAILED)\n\t\treturn\n\t}\n\tif !rs {\n\t\tLog.Warnf(\"no transaction info loaded. sessionID=%v,\", sessionID)\n\t\tfmt.Fprintf(w, RESPONSE_NO_NEED_TO_WITHDRAW)\n\t\treturn\n\t}\n\tif tx.SubMode != TRANSACTION_SUB_MODE_COMPLAINT {\n\t\tLog.Warnf(\"the mode does not need withdraw eth.\")\n\t\tfmt.Fprintf(w, RESPONSE_NO_NEED_TO_WITHDRAW)\n\t\treturn\n\t}\n\tLog.Debugf(\"start send transaction to withdraw eth...sessionID=%v\", sessionID)\n\tt := time.Now()\n\ttxid, err := settleDealForComplaint(sessionID, tx.AliceAddr, tx.BobAddr)\n\tif err != nil {\n\t\tLog.Warnf(\"failed to withdraw eth for Alice from contract. err=%v\", err)\n\t\tfmt.Fprintf(w, RESPONSE_READ_CONTRACT_FAILED)\n\t\treturn\n\t}\n\tLog.Debugf(\"success to send transaction to withdraw eth...txid=%v, sessionID=%v, time cost=%v\", txid, sessionID, time.Since(t))\n\n\tplog.Result = LOG_RESULT_SUCCESS\n\tfmt.Fprintf(w, fmt.Sprintf(RESPONSE_SUCCESS, \"send transaction for withdrawing from contract...\"))\n\treturn\n}", "func (a *Account) Withdraw (amount int) error {\n\tif a.balance < amount {\n\t\treturn errNomoney\n\t}\n\ta.balance -= amount\n\treturn nil\n}", "func (_Vault *VaultSession) Withdraw(inst []byte, heights *big.Int, instPaths [][32]byte, instPathIsLefts []bool, instRoots [32]byte, blkData [32]byte, sigIdxs []*big.Int, sigVs []uint8, sigRs [][32]byte, sigSs [][32]byte) (*types.Transaction, error) {\n\treturn _Vault.Contract.Withdraw(&_Vault.TransactOpts, inst, heights, instPaths, instPathIsLefts, instRoots, blkData, sigIdxs, sigVs, sigRs, sigSs)\n}", "func (dcr *ExchangeWallet) withdraw(addr stdaddr.Address, val, feeRate uint64) (*wire.MsgTx, uint64, error) {\n\tif val == 0 {\n\t\treturn nil, 0, fmt.Errorf(\"cannot withdraw value = 0\")\n\t}\n\tenough := func(sum uint64, size uint32, unspent *compositeUTXO) bool {\n\t\treturn sum+toAtoms(unspent.rpc.Amount) >= val\n\t}\n\tcoins, _, _, _, err := dcr.fund(enough)\n\tif err != nil {\n\t\treturn nil, 0, fmt.Errorf(\"unable to withdraw %s DCR to address %s with feeRate %d atoms/byte: %w\",\n\t\t\tamount(val), addr, feeRate, err)\n\t}\n\n\tmsgTx, sentVal, err := dcr.sendCoins(addr, coins, val, feeRate, true)\n\tif err != nil {\n\t\tif _, retErr := dcr.returnCoins(coins); retErr != nil {\n\t\t\tdcr.log.Errorf(\"Failed to unlock coins: %v\", retErr)\n\t\t}\n\t\treturn nil, 0, err\n\t}\n\treturn msgTx, sentVal, nil\n}", "func (_SingleAuto *SingleAutoTransactor) Withdraw(opts *bind.TransactOpts, _pid *big.Int, _wantAmt *big.Int) (*types.Transaction, error) {\n\treturn _SingleAuto.contract.Transact(opts, \"withdraw\", _pid, _wantAmt)\n}", "func (_Vault *VaultTransactorSession) Withdraw(inst []byte, heights *big.Int, instPaths [][32]byte, instPathIsLefts []bool, instRoots [32]byte, blkData [32]byte, sigIdxs []*big.Int, sigVs []uint8, sigRs [][32]byte, sigSs [][32]byte) (*types.Transaction, error) {\n\treturn _Vault.Contract.Withdraw(&_Vault.TransactOpts, inst, heights, instPaths, instPathIsLefts, instRoots, blkData, sigIdxs, sigVs, sigRs, sigSs)\n}", "func (cust *custInfo) doWithdrawal(amt uint64){\n cAddr, err3 := net.ResolveUDPAddr(\"udp\",\":0\")\n sAddr, err4 := net.ResolveUDPAddr(\"udp\", headAddress)\n connHead, errHead := net.DialUDP(\"udp\",cAddr,sAddr)\n logMessage(\"Status\",\"Connecting to Head for Withdrawal\")\n if(errHead != nil){\n fmt.Println(\"Err\",errHead)\n }\n if(err3!=nil || err4!=nil){\n log.Fatal(\"Connection error\",err4)\n }\n notifyMe(connHead)\n param := ParamsUpdate{cust.reqId,cust.accountNumber,\"withDrawal\",amt}\n b,err1 := json.Marshal(param)\n if(err1 != nil){\n fmt.Println(\"Error\")\n }\n connHead.Write(b)\n logMessage(\"Send\",param)\n fmt.Println(\"Withdrawal Request Sent\\n\")\n go receiveMsgFromTail(connTail,\"Withdrawal\")\n defer connHead.Close()\n}", "func (m *WithdrawManager) SubmitWithdrawal(ctx context.Context, req *withdraw.Request) (*withdraw.Response, error) {\n\tif m == nil {\n\t\treturn nil, ErrNilSubsystem\n\t}\n\tif req == nil {\n\t\treturn nil, withdraw.ErrRequestCannotBeNil\n\t}\n\n\texch, err := m.exchangeManager.GetExchangeByName(req.Exchange)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp := &withdraw.Response{\n\t\tExchange: withdraw.ExchangeResponse{\n\t\t\tName: req.Exchange,\n\t\t},\n\t\tRequestDetails: *req,\n\t}\n\n\t// Determines if the currency can be withdrawn from the exchange\n\terrF := exch.CanWithdraw(req.Currency, asset.Spot)\n\tif errF != nil && !errors.Is(errF, currencystate.ErrCurrencyStateNotFound) { // Suppress not found error\n\t\treturn nil, errF\n\t}\n\n\tif m.isDryRun {\n\t\tlog.Warnln(log.Global, \"Dry run enabled, no withdrawal request will be submitted or have an event created\")\n\t\tresp.ID = withdraw.DryRunID\n\t\tresp.Exchange.Status = \"dryrun\"\n\t\tresp.Exchange.ID = withdraw.DryRunID.String()\n\t} else {\n\t\tvar ret *withdraw.ExchangeResponse\n\t\tif req.Type == withdraw.Crypto {\n\t\t\tif !m.portfolioManager.IsWhiteListed(req.Crypto.Address) {\n\t\t\t\treturn nil, withdraw.ErrStrAddressNotWhiteListed\n\t\t\t}\n\t\t\tif !m.portfolioManager.IsExchangeSupported(req.Exchange, req.Crypto.Address) {\n\t\t\t\treturn nil, withdraw.ErrStrExchangeNotSupportedByAddress\n\t\t\t}\n\t\t}\n\t\tif req.Type == withdraw.Fiat {\n\t\t\tret, err = exch.WithdrawFiatFunds(ctx, req)\n\t\t\tif err != nil {\n\t\t\t\tresp.Exchange.Status = err.Error()\n\t\t\t} else {\n\t\t\t\tresp.Exchange.Status = ret.Status\n\t\t\t\tresp.Exchange.ID = ret.ID\n\t\t\t}\n\t\t} else if req.Type == withdraw.Crypto {\n\t\t\tret, err = exch.WithdrawCryptocurrencyFunds(ctx, req)\n\t\t\tif err != nil {\n\t\t\t\tresp.Exchange.Status = err.Error()\n\t\t\t} else {\n\t\t\t\tresp.Exchange.Status = ret.Status\n\t\t\t\tresp.Exchange.ID = ret.ID\n\t\t\t}\n\t\t}\n\t}\n\tdbwithdraw.Event(resp)\n\tif err == nil {\n\t\twithdraw.Cache.Add(resp.ID, resp)\n\t}\n\treturn resp, err\n}", "func testWithdrawZeroBalance(t *testing.T, n int) {\n\trng := pkgtest.Prng(t)\n\ts := test.NewSetup(t, rng, n)\n\t// create valid state and params\n\tparams, state := channeltest.NewRandomParamsAndState(rng, channeltest.WithParts(s.Parts...), channeltest.WithAssets((*ethchannel.Asset)(&s.Asset)), channeltest.WithIsFinal(true))\n\tagreement := state.Balances.Clone()\n\n\tfor i := range params.Parts {\n\t\tif i%2 == 0 {\n\t\t\tstate.Balances[0][i].SetInt64(0)\n\t\t\tagreement[0][i].SetInt64(0)\n\t\t} // is != 0 otherwise\n\t\tt.Logf(\"Part: %d ShouldFund: %t Bal: %v\", i, i%2 == 1, state.Balances[0][i])\n\t}\n\n\t// fund\n\tct := pkgtest.NewConcurrent(t)\n\tfor i, funder := range s.Funders {\n\t\ti, funder := i, funder\n\t\tgo ct.StageN(\"funding loop\", n, func(rt pkgtest.ConcT) {\n\t\t\treq := channel.NewFundingReq(params, state, channel.Index(i), agreement)\n\t\t\trequire.NoError(rt, funder.Fund(context.Background(), *req), \"funding should succeed\")\n\t\t})\n\t}\n\tct.Wait(\"funding loop\")\n\n\t// register\n\treq := channel.AdjudicatorReq{\n\t\tParams: params,\n\t\tAcc: s.Accs[0],\n\t\tTx: testSignState(t, s.Accs, params, state),\n\t\tIdx: 0,\n\t}\n\trequire.NoError(t, s.Adjs[0].Register(context.Background(), req))\n\t// we don't need to wait for a timeout since we registered a final state\n\n\t// withdraw\n\tfor i, _adj := range s.Adjs {\n\t\tadj := _adj\n\t\treq.Acc = s.Accs[i]\n\t\treq.Idx = channel.Index(i)\n\t\t// check that the nonce stays the same for zero balance withdrawals\n\t\tdiff, err := test.NonceDiff(s.Accs[i].Address(), adj, func() error {\n\t\t\treturn adj.Withdraw(context.Background(), req, nil)\n\t\t})\n\t\trequire.NoError(t, err)\n\t\tif i%2 == 0 {\n\t\t\tassert.Zero(t, diff, \"Nonce should stay the same\")\n\t\t} else {\n\t\t\tassert.Equal(t, 1, diff, \"Nonce should increase by 1\")\n\t\t}\n\t}\n\tassertHoldingsZero(context.Background(), t, s.CB, params, state.Assets)\n}", "func (_TokenStakingEscrow *TokenStakingEscrowTransactorSession) Withdraw(operator common.Address) (*types.Transaction, error) {\n\treturn _TokenStakingEscrow.Contract.Withdraw(&_TokenStakingEscrow.TransactOpts, operator)\n}", "func (_TokenStakingEscrow *TokenStakingEscrowCaller) DepositWithdrawnAmount(opts *bind.CallOpts, operator common.Address) (*big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t)\n\tout := ret0\n\terr := _TokenStakingEscrow.contract.Call(opts, out, \"depositWithdrawnAmount\", operator)\n\treturn *ret0, err\n}", "func (_SingleAuto *SingleAutoTransactorSession) Withdraw(_pid *big.Int, _wantAmt *big.Int) (*types.Transaction, error) {\n\treturn _SingleAuto.Contract.Withdraw(&_SingleAuto.TransactOpts, _pid, _wantAmt)\n}", "func (_Cakevault *CakevaultSession) EmergencyWithdraw() (*types.Transaction, error) {\n\treturn _Cakevault.Contract.EmergencyWithdraw(&_Cakevault.TransactOpts)\n}", "func (_Vault *VaultCallerSession) Withdrawed(arg0 [32]byte) (bool, error) {\n\treturn _Vault.Contract.Withdrawed(&_Vault.CallOpts, arg0)\n}", "func (_Vault *VaultTransactor) RequestWithdraw(opts *bind.TransactOpts, incognitoAddress string, token common.Address, amount *big.Int, signData []byte, timestamp []byte) (*types.Transaction, error) {\n\treturn _Vault.contract.Transact(opts, \"requestWithdraw\", incognitoAddress, token, amount, signData, timestamp)\n}", "func (_TokenStakingEscrow *TokenStakingEscrowSession) DepositWithdrawnAmount(operator common.Address) (*big.Int, error) {\n\treturn _TokenStakingEscrow.Contract.DepositWithdrawnAmount(&_TokenStakingEscrow.CallOpts, operator)\n}", "func (_IStakingRewards *IStakingRewardsTransactor) Withdraw(opts *bind.TransactOpts, amount *big.Int) (*types.Transaction, error) {\n\treturn _IStakingRewards.contract.Transact(opts, \"withdraw\", amount)\n}", "func (_IStakingRewards *IStakingRewardsSession) Withdraw(amount *big.Int) (*types.Transaction, error) {\n\treturn _IStakingRewards.Contract.Withdraw(&_IStakingRewards.TransactOpts, amount)\n}", "func (w *xcWallet) UnapproveToken(assetVersion uint32, onConfirm func()) (string, error) {\n\tapprover, ok := w.Wallet.(asset.TokenApprover)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"%s wallet is not a TokenApprover\", unbip(w.AssetID))\n\t}\n\treturn approver.UnapproveToken(assetVersion, onConfirm)\n}", "func (_TokenStakingEscrow *TokenStakingEscrowFilterer) FilterRevokedDepositWithdrawn(opts *bind.FilterOpts, operator []common.Address, grantManager []common.Address) (*TokenStakingEscrowRevokedDepositWithdrawnIterator, error) {\n\n\tvar operatorRule []interface{}\n\tfor _, operatorItem := range operator {\n\t\toperatorRule = append(operatorRule, operatorItem)\n\t}\n\tvar grantManagerRule []interface{}\n\tfor _, grantManagerItem := range grantManager {\n\t\tgrantManagerRule = append(grantManagerRule, grantManagerItem)\n\t}\n\n\tlogs, sub, err := _TokenStakingEscrow.contract.FilterLogs(opts, \"RevokedDepositWithdrawn\", operatorRule, grantManagerRule)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &TokenStakingEscrowRevokedDepositWithdrawnIterator{contract: _TokenStakingEscrow.contract, event: \"RevokedDepositWithdrawn\", logs: logs, sub: sub}, nil\n}", "func withdraw(res http.ResponseWriter, req *http.Request){\n\tvar result Account\n\n\tcollection := client.Database(Database).Collection(Collection)\n\tparams := url_parser(req.URL.String())\n\tfilter := bson.D{{\"identifier\", clean_string(params[\"account\"])}}\n\terr := collection.FindOne(context.TODO(), filter).Decode(&result)\n\t\n\tchange, err := strconv.ParseFloat(clean_string(params[\"withdrawl\"]), 64)\n\t\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\tinitial, err := strconv.ParseFloat(result.Balance, 64)\n\tupdated := strconv.FormatFloat((initial - change), 'f', -1, 64)\n\tresult.Balance = updated\n\n\tif err != nil{\n\t\tfmt.Println(err)\n\t}\n\tentry, err := bson.Marshal(result)\n\t_ , err = collection.ReplaceOne(context.TODO(), filter, entry)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tgenerate_record(clean_string(params[\"account\"]), updated, \"-\"+clean_string(params[\"withdrawl\"]), \"withdrawl\")\n}", "func (a *Account) Withdraw(amount int) error {\n\tif a.balance < amount {\n\t\treturn errorWithdraw\n\t}\n\ta.balance -= amount\n\treturn nil\n}", "func (s *FundServer) Withdraw(amount int) {\n\ts.Transact(func(f *Fund) {\n\t\tf.Withdraw(amount)\n\t})\n}", "func (_Vault *VaultSession) Withdrawed(arg0 [32]byte) (bool, error) {\n\treturn _Vault.Contract.Withdrawed(&_Vault.CallOpts, arg0)\n}", "func (_TokenStakingEscrow *TokenStakingEscrowFilterer) WatchDepositWithdrawn(opts *bind.WatchOpts, sink chan<- *TokenStakingEscrowDepositWithdrawn, operator []common.Address, grantee []common.Address) (event.Subscription, error) {\n\n\tvar operatorRule []interface{}\n\tfor _, operatorItem := range operator {\n\t\toperatorRule = append(operatorRule, operatorItem)\n\t}\n\tvar granteeRule []interface{}\n\tfor _, granteeItem := range grantee {\n\t\tgranteeRule = append(granteeRule, granteeItem)\n\t}\n\n\tlogs, sub, err := _TokenStakingEscrow.contract.WatchLogs(opts, \"DepositWithdrawn\", operatorRule, granteeRule)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn event.NewSubscription(func(quit <-chan struct{}) error {\n\t\tdefer sub.Unsubscribe()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase log := <-logs:\n\t\t\t\t// New log arrived, parse the event and forward to the user\n\t\t\t\tevent := new(TokenStakingEscrowDepositWithdrawn)\n\t\t\t\tif err := _TokenStakingEscrow.contract.UnpackLog(event, \"DepositWithdrawn\", log); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tevent.Raw = log\n\n\t\t\t\tselect {\n\t\t\t\tcase sink <- event:\n\t\t\t\tcase err := <-sub.Err():\n\t\t\t\t\treturn err\n\t\t\t\tcase <-quit:\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\tcase err := <-sub.Err():\n\t\t\t\treturn err\n\t\t\tcase <-quit:\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}), nil\n}", "func (a *Account) Withdraw(amount int) error {\n\tif amount > a.Balance {\n\t\treturn fmt.Errorf(\"account: not enough funds\")\n\t}\n\n\ta.Balance -= amount\n\n\treturn nil\n}", "func (w *Wallet) Withdraw(amount Shivcoin) error {\n\tif amount < w.balance {\n\t\tw.balance -= amount\n\t\treturn nil\n\t} else {\n\t\treturn ErrInsufficientFunds\n\t}\n}" ]
[ "0.6124915", "0.60527366", "0.59476393", "0.5926781", "0.5890346", "0.5857869", "0.58281296", "0.57886124", "0.578397", "0.57604176", "0.5714432", "0.5687001", "0.56778246", "0.56577224", "0.5635493", "0.56080854", "0.559661", "0.55527294", "0.5551587", "0.5543905", "0.5539392", "0.55374396", "0.55363804", "0.5533404", "0.55154246", "0.5508218", "0.5497701", "0.5487953", "0.54799235", "0.54728186", "0.5467871", "0.54674006", "0.54667133", "0.5464994", "0.54539114", "0.54503506", "0.5436821", "0.54330456", "0.5428306", "0.542579", "0.5420984", "0.54146737", "0.5411993", "0.53700924", "0.53515595", "0.5348653", "0.53340477", "0.533228", "0.5323173", "0.53192323", "0.53191894", "0.5305408", "0.5304224", "0.530391", "0.52643543", "0.5259291", "0.5241931", "0.5236473", "0.52205503", "0.5217555", "0.5215931", "0.5205591", "0.51945347", "0.5185779", "0.5185779", "0.5184571", "0.5182847", "0.51784223", "0.51780194", "0.5176221", "0.5175564", "0.51590073", "0.51519847", "0.51404256", "0.513949", "0.5138581", "0.51213443", "0.5115558", "0.51021975", "0.5102178", "0.50989443", "0.50784", "0.5074792", "0.50671244", "0.506666", "0.50630444", "0.50589705", "0.50484467", "0.50454444", "0.5044557", "0.5044076", "0.5036666", "0.5035343", "0.50346327", "0.50328296", "0.5030264", "0.50237995", "0.5011292", "0.50091666", "0.50075215" ]
0.7984501
0
VerifyBSB will verify a BSB number and send back the current status of that BSB
VerifyBSB проверит номер BSB и вернет текущий статус этого BSB
func (as *AddressService) VerifyBSB(bsb string) (*BSBStatus, error) { var bsbStatus BSBStatus if err := as.client.Get(buildString("address/withdraw/bsb-verify/", bsb), &bsbStatus); err != nil { return nil, err } return &bsbStatus, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (api *API) fBVerificationExists(token string) (fbid uint64, err error) {\n\ts, err := api.sc.Prepare(\"SELECT fb_id FROM facebook_verification WHERE token = ?\")\n\tif err != nil {\n\t\treturn\n\t}\n\terr = s.QueryRow(token).Scan(&fbid)\n\tif err == sql.ErrNoRows {\n\t\terr = NoSuchVerificationToken\n\t}\n\treturn\n}", "func verify(srvChan chan string, channel, nick, hostname string, args []string) {\n\tmessage := \"NOTICE \" + channel + \" :\"\n\tif len(args) != 2 {\n\t\tmessage = \"NOTICE \" + channel + \" :ERROR: Invalid number of arguments\"\n\t} else {\n\t\tuname := args[0]\n\t\tpin := args[1]\n\t\treply := cmdDb.Cmd(\"get\", uname+\"Pin\")\n\t\tpinDb, err := (reply.Bytes())\n\t\tif err != nil {\n\t\t\tlog.Println(err.Error())\n\t\t\treturn\n\t\t}\n\t\tif string(pinDb) == pin {\n\t\t\tmessage += \"You are now verified as \" + uname\n\t\t\tcmdDb.Cmd(\"set\", uname+\"Host\", hostname)\n\t\t\tcmdDb.Cmd(\"set\", uname+\"Pin\", fmt.Sprintf(\"%06d\", rand.Intn(1000000)))\n\t\t} else {\n\t\t\tmessage += \"PIN does not match that of \" + uname\n\t\t}\n\t}\n\tlog.Println(message)\n\tsrvChan <- message\n}", "func BebGetSuccess(w http.ResponseWriter, name string) {\n\tw.WriteHeader(http.StatusOK)\n\ts := bebtypes.Subscription{\n\t\tName: name,\n\t\tSubscriptionStatus: bebtypes.SubscriptionStatusActive,\n\t}\n\terr := json.NewEncoder(w).Encode(s)\n\tExpect(err).ShouldNot(HaveOccurred())\n}", "func (s *BaseEvent) BSuccess() bool {\n if !s.sysParamsExtracted { panic(\"!s.sysParamsExtracted\"); }\n return (s.sysParams.BSuccess == 1)\n}", "func TestBirdShowStatus(t *testing.T) {\n\tout := \"1000-BIRD 1.6.4\\n\" +\n\t\t\"1011-Router ID is 192.168.1.9\\n\" +\n\t\t\" Current server time is 2018-12-27 12:15:01\\n\" +\n\t\t\" Last reboot on 2018-12-21 12:35:11\\n\" +\n\t\t\" Last reconfiguration on 2018-12-21 12:35:11\\n\" +\n\t\t\"0013 Daemon is up and running\\n\"\n\tcompleted := containsActionCompletedCode([]byte(out))\n\n\tassert.True(\"'show status' successfully completed\", completed, t)\n}", "func (bbs *BBSG2Pub) Verify(messages [][]byte, sigBytes, pubKeyBytes []byte) error {\n\tsignature, err := ParseSignature(sigBytes)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parse signature: %w\", err)\n\t}\n\n\tpublicKey, err := UnmarshalPublicKey(pubKeyBytes)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parse public key: %w\", err)\n\t}\n\n\tmessagesFr := make([]*SignatureMessage, len(messages))\n\tfor i := range messages {\n\t\tmessagesFr[i], err = ParseSignatureMessage(messages[i])\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"parse signature message %d: %w\", i+1, err)\n\t\t}\n\t}\n\n\tp1 := signature.GetPoint().ToAffine()\n\tq1 := bls.G2ProjectiveOne.\n\t\tMulFR(signature.E.ToRepr()).\n\t\tAdd(publicKey.GetPoint())\n\n\tp2, err := getB(signature.S, messagesFr, publicKey)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get B point: %w\", err)\n\t}\n\n\tif compareTwoPairings(p1.ToProjective(), q1, p2.ToProjective(), bls.G2ProjectiveOne) {\n\t\treturn nil\n\t}\n\n\treturn errors.New(\"BLS12-381: invalid signature\")\n}", "func (b *backend) Verify(addr wallet.Address, _params *channel.Params, state *channel.State, sig []byte) (bool, error) {\n\tif err := state.Valid(); err != nil {\n\t\treturn false, errors.Wrap(err, \"verifying invalid state\")\n\t}\n\tlog.WithFields(log.Fields{\"channel\": state.ID, \"version\": state.Version}).Tracef(\"Verifying state\")\n\n\tbuff := new(bytes.Buffer)\n\tif err := state.Encode(buff); err != nil {\n\t\treturn false, errors.WithMessage(err, \"pack state\")\n\t}\n\treturn wallet.VerifySignature(buff.Bytes(), sig, addr)\n}", "func wbbVerify(curve *math.Curve, pk *math.G2, sig *math.G1, m *math.Zr) error {\n\tif pk == nil || sig == nil || m == nil {\n\t\treturn errors.Errorf(\"Weak-BB signature invalid: received nil input\")\n\t}\n\t// Set P = pk * g2^m\n\tP := curve.NewG2()\n\tP.Clone(pk)\n\tP.Add(curve.GenG2.Mul(m))\n\tP.Affine()\n\t// check that e(sig, pk * g2^m) = e(g1, g2)\n\tif !curve.FExp(curve.Pairing(P, sig)).Equals(curve.GenGt) {\n\t\treturn errors.Errorf(\"Weak-BB signature is invalid\")\n\t}\n\treturn nil\n}", "func (cgs *CmdGetSlotNumWithRegNum) Verify() error {\n\tif perror.Empty == cgs.RegistrationNumber {\n\t\treturn perror.ErrInvalidParams\n\t}\n\treturn nil\n}", "func (mb *tcpPackager) Verify(aduRequest []byte, aduResponse []byte) error {\n\treturn verify(aduRequest, aduResponse)\n}", "func (api *Staytus) VerifySubscriber(email string) (bool, error) {\n\trequest := &request{\n\t\tSubscriberEmail: email,\n\t}\n\tbody, err := json.Marshal(request)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdata, err := api.post(\"api/v1/subscribers/verify\", body)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tvar result bool\n\tif err := json.Unmarshal(data, &result); err != nil {\n\t\treturn false, err\n\t}\n\treturn result, nil\n}", "func (s BlockchainStatus) Verify() error {\n\tswitch s {\n\tcase UnknownChain, Created, Preferred, Validating, Syncing:\n\t\treturn nil\n\tdefault:\n\t\treturn errUnknownBlockchainStatus\n\t}\n}", "func (_Ethdkg *EthdkgCaller) Verify(opts *bind.CallOpts, message []byte, sig [2]*big.Int, pubK [4]*big.Int) (bool, error) {\n\tvar (\n\t\tret0 = new(bool)\n\t)\n\tout := ret0\n\terr := _Ethdkg.contract.Call(opts, out, \"Verify\", message, sig, pubK)\n\treturn *ret0, err\n}", "func (c *Client) VerifyRoutingNumber(data string) (map[string]interface{}, error) {\n\tlog.info(\"========== VERIFY ROUTING NUMBER ==========\")\n\turl := buildURL(\"routing-number-verification\")\n\n\treturn c.do(\"POST\", url, data, nil)\n}", "func (client *Client) VerifyBankElement(request *VerifyBankElementRequest) (response *VerifyBankElementResponse, err error) {\n\tresponse = CreateVerifyBankElementResponse()\n\terr = client.DoAction(request, response)\n\treturn\n}", "func (mb *rtuPackager) Verify(aduRequest []byte, aduResponse []byte) (err error) {\n\tlength := len(aduResponse)\n\t// Minimum size (including address, function and CRC)\n\tif length < rtuMinSize {\n\t\terr = fmt.Errorf(\"modbus: response length '%v' does not meet minimum '%v'\", length, rtuMinSize)\n\t\treturn\n\t}\n\t// Slave address must match\n\tif aduResponse[0] != aduRequest[0] {\n\t\terr = fmt.Errorf(\"modbus: response slave id '%v' does not match request '%v'\", aduResponse[0], aduRequest[0])\n\t\treturn\n\t}\n\treturn\n}", "func (s *SCIONBoxController) checkHBStatus(isd addr.ISD, As addr.AS) {\n\ttime.Sleep(HeartBeatPeriod * time.Second)\n\tfor true {\n\t\tslas, err := models.FindSCIONLabASByIAInt(isd, As)\n\t\tif err != nil {\n\t\t\tif err == orm.ErrNoRows {\n\t\t\t\treturn\n\t\t\t} else {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tif slas.Status == models.Removed {\n\t\t\treturn\n\t\t}\n\t\tdelta := time.Now().Sub(slas.Updated)\n\t\tif delta.Seconds() > float64(HeartBeatLimit*HeartBeatPeriod) {\n\t\t\tif slas.Status != models.Inactive {\n\t\t\t\tlog.Printf(\"AS Status set to inactive, AS: %v, Time since last HB: %v\", slas, delta)\n\t\t\t\tslas.Status = models.Inactive\n\t\t\t\tslas.Update()\n\t\t\t}\n\t\t}\n\t\ttime.Sleep(HeartBeatPeriod * time.Second)\n\t}\n}", "func Verify(raw []byte, hmacSecret *[32]byte) (*refs.MessageRef, *DeserializedMessage, error) {\n\tenc, err := EncodePreserveOrder(raw)\n\tif err != nil {\n\t\tif len(raw) > 15 {\n\t\t\traw = raw[:15]\n\t\t}\n\t\treturn nil, nil, fmt.Errorf(\"ssb Verify: could not encode message (%q): %w\", raw, err)\n\t}\n\n\t// destroys it for the network layer but makes it easier to access its values\n\tvar dmsg DeserializedMessage\n\tif err := json.Unmarshal(raw, &dmsg); err != nil {\n\t\tif len(raw) > 15 {\n\t\t\traw = raw[:15]\n\t\t}\n\t\treturn nil, nil, fmt.Errorf(\"ssb Verify: could not json.Unmarshal message (%q): %w\", raw, err)\n\t}\n\n\twoSig, sig, err := ExtractSignature(enc)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"ssb Verify(%s:%d): could not extract signature: %w\", dmsg.Author.Ref(), dmsg.Sequence, err)\n\t}\n\n\tif hmacSecret != nil {\n\t\tmac := auth.Sum(woSig, hmacSecret)\n\t\twoSig = mac[:]\n\t}\n\n\tif err := sig.Verify(woSig, &dmsg.Author); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"ssb Verify(%s:%d): could not verify message: %w\", dmsg.Author.Ref(), dmsg.Sequence, err)\n\t}\n\n\t// hash the message - it's sadly the internal string rep of v8 that get's hashed, not the json string\n\tv8warp, err := InternalV8Binary(enc)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"ssb Verify(%s:%d): could hash convert message: %w\", dmsg.Author.Ref(), dmsg.Sequence, err)\n\t}\n\th := sha256.New()\n\tio.Copy(h, bytes.NewReader(v8warp))\n\n\tmr := refs.MessageRef{\n\t\tHash: h.Sum(nil),\n\t\tAlgo: refs.RefAlgoMessageSSB1,\n\t}\n\treturn &mr, &dmsg, nil\n}", "func inspectSBRStatus(\n\tctx context.Context,\n\tt *testing.T,\n\tf *framework.Framework,\n\tnamespacedName types.NamespacedName,\n) {\n\terr := retry(10, 5*time.Second, func() error {\n\t\tt.Logf(\"Inspecting SBR: '%s'\", namespacedName)\n\t\terr := assertSBRStatus(ctx, f, namespacedName)\n\t\tif err != nil {\n\t\t\tt.Logf(\"Error on inspecting SBR: '%#v'\", err)\n\t\t}\n\t\treturn err\n\t})\n\tt.Logf(\"SBR-Status: Result after attempts, error: '%#v'\", err)\n\trequire.NoError(t, err)\n}", "func SendVerificationSMS(phone string) bool {\n\n\t//generate/save to vc table\n\tvc, result := services.CreateVcRecord(phone, session)\n\tif result == false {\n\t\tlog.Println(\"sending verification failed cause of VC service failur\")\n\t\treturn false\n\t}\n\n\t//send\n\torigin := structs.SmsOrigin{From: \"10001398\", ApiKey: \"ED09D0D7-5FBA-43A2-8B9D-F0AE79666B52\"}\n\tSmsErr := services.SendSms(vc, phone, origin)\n\tif SmsErr != true {\n\t\tlog.Println(\"User Submition Failed Cause Of SMS service Error:008\")\n\t\tlog.Println(SmsErr)\n\t\tlog.Println(\"End <=008\")\n\t\treturn false\n\t}\n\n\treturn true\n\n}", "func CheckPaymentToBeta() {\n\tbrokerTxs, _ := models.GetTransactionsBySessionTypesAndPaymentStatuses([]int{},\n\t\t[]models.PaymentStatus{models.BrokerTxBetaPaymentPending})\n\n\tfor _, brokerTx := range brokerTxs {\n\t\tbalance := EthWrapper.CheckPRLBalance(eth_gateway.StringToAddress(brokerTx.ETHAddrBeta))\n\t\texpectedBalance := new(big.Int).Quo(brokerTx.GetTotalCostInWei(), big.NewInt(int64(2)))\n\t\tif balance.Int64() > 0 && balance.Int64() >= expectedBalance.Int64() {\n\t\t\tpreviousBetaPaymentStatus := brokerTx.PaymentStatus\n\t\t\tbrokerTx.PaymentStatus = models.BrokerTxBetaPaymentConfirmed\n\t\t\terr := models.DB.Save(&brokerTx)\n\t\t\tif err != nil {\n\t\t\t\toyster_utils.LogIfError(err, nil)\n\t\t\t\tbrokerTx.PaymentStatus = previousBetaPaymentStatus\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif brokerTx.Type == models.SessionTypeBeta {\n\t\t\t\tReportGoodAlphaToDRS(brokerTx)\n\t\t\t}\n\t\t\toyster_utils.LogToSegment(\"check_beta_payments: CheckPaymentToBeta - beta_confirmed\",\n\t\t\t\tanalytics.NewProperties().\n\t\t\t\t\tSet(\"beta_address\", brokerTx.ETHAddrBeta).\n\t\t\t\t\tSet(\"alpha_address\", brokerTx.ETHAddrAlpha))\n\t\t}\n\t}\n}", "func (c *Client) BPI(bpi int) error {\n\tvar args []byte\n\n\targs = combine(args, \"BPI \")\n\targs = combine(args, strconv.Itoa(bpi))\n\n\treturn c.Send(MESSAGE_CLIENT_SET_CHANNEL_INFO, args)\n}", "func (byb *TokenByb) checkBybToken() (smcError smc.Error) {\n\tsmcError.ErrorCode = bcerrors.ErrCodeOK\n\n\t// get token address by name and symbol\n\taddr1, bcerr1 := byb.getTokenAddrByName(BybName)\n\taddr2, bcerr2 := byb.getTokenAddrBySymbol(bybSymbol)\n\tif bcerr1.ErrorCode != bcerrors.ErrCodeOK {\n\t\treturn bcerr1\n\t}\n\tif bcerr2.ErrorCode != bcerrors.ErrCodeOK {\n\t\treturn bcerr2\n\t}\n\n\tif addr1 == \"\" && addr2 == \"\" {\n\t\tsmcError.ErrorCode = bcerrors.ErrCodeOK\n\t\treturn\n\t}\n\n\t// the address must be equal both addr1 and addr2\n\tif addr1 != addr2 {\n\t\tsmcError.ErrorCode = bcerrors.ErrCodeInterContractsBybInitialized\n\t\treturn\n\t}\n\n\t// get token by address\n\tiToken, err := byb.State.GetToken(addr1)\n\tif err != nil {\n\t\tsmcError.ErrorCode = bcerrors.ErrCodeLowLevelError\n\t\tsmcError.ErrorDesc = err.Error()\n\t\treturn\n\t}\n\tif iToken.Owner != byb.Sender.Addr {\n\t\tsmcError.ErrorCode = bcerrors.ErrCodeInterContractsBybInitialized\n\t\treturn\n\t}\n\n\tif Compare(iToken.TotalSupply, Zero()) != 0 {\n\t\tsmcError.ErrorCode = bcerrors.ErrCodeInterContractsBybInitialized\n\t\treturn\n\t}\n\n\t// get token contract with contract address\n\ttContract, err := byb.State.StateDB.GetContract(iToken.Address)\n\tif err != nil {\n\t\tsmcError.ErrorCode = bcerrors.ErrCodeLowLevelError\n\t\tsmcError.ErrorDesc = err.Error()\n\t\treturn\n\t}\n\n\t// can't set byb contract lose height\n\tif tContract.Address == byb.State.ContractAddress {\n\t\tsmcError.ErrorCode = bcerrors.ErrCodeInterContractsBybInitialized\n\t\treturn\n\t}\n\n\t// get world app state for block height\n\tworldAppState, err := byb.State.StateDB.GetWorldAppState()\n\tif err != nil {\n\t\tsmcError.ErrorCode = bcerrors.ErrCodeLowLevelError\n\t\tsmcError.ErrorDesc = err.Error()\n\t\treturn\n\t}\n\n\t// set byb token contract's lose height with block height\n\ttContract.LoseHeight = uint64(worldAppState.BlockHeight + 1)\n\n\t// update byb token contract\n\terr = byb.State.SetTokenContract(tContract)\n\tif err != nil {\n\t\tsmcError.ErrorCode = bcerrors.ErrCodeLowLevelError\n\t\tsmcError.ErrorDesc = smcError.Error()\n\t\treturn\n\t}\n\n\treturn\n}", "func (cb *callBack) OnVerifyComplete(zcnTxn *zcncore.Transaction, status int) {\n\tcb.sendVerifyCall()\n\n\terr := zcnTxn.GetVerifyError()\n\tif err == \"\" {\n\t\terr = \"no error\"\n\t}\n\n\tlog.Logger.Debug(\"Transaction verified\",\n\t\tzap.String(\"status\", TxnStatus(status).String()),\n\t\tzap.Any(\"txn_hash\", zcnTxn.GetTransactionHash()),\n\t\tzap.String(\"error\", err),\n\t)\n}", "func (_Ethdkg *EthdkgSession) Verify(message []byte, sig [2]*big.Int, pubK [4]*big.Int) (bool, error) {\n\treturn _Ethdkg.Contract.Verify(&_Ethdkg.CallOpts, message, sig, pubK)\n}", "func (dstv Dstv) Status(serialNumber string) (*StatusResponse, error) {\n\tdstv.AddQueryData(paymenex.PActId, \"STATUS\")\n\tdstv.AddQueryData(paymenex.PSerialNumber, serialNumber)\n\txml, err := dstv.MakeRequest()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// writeFile(\"status.xml\", xml) // DEBUG\n\tresponse := new(StatusResponse)\n\tok := dstv.ParseAndVerifyResponse(xml, response)\n\tif !ok {\n\t\treturn response, errors.New(errVerifyMsg)\n\t}\n\treturn response, nil\n}", "func (bft *ProtocolBFTCoSi) waitResponseVerification() (*Response, bool) {\n\tlog.Lvl3(bft.Name(), \"Waiting for response verification:\")\n\t// wait the verification\n\tverified := <-bft.verifyChan\n\n\t// sanity check\n\tif bft.IsLeaf() && len(bft.tempPrepareResponse) != 0 {\n\t\tpanic(\"bft.tempPrepareResponse is not 0 on leaf node\")\n\t}\n\n\tresp, err := bft.prepare.Response(bft.tempPrepareResponse)\n\tif err != nil {\n\t\treturn nil, false\n\t}\n\n\tif !verified {\n\t\t// Add our exception\n\t\tbft.tempExceptions = append(bft.tempExceptions, Exception{\n\t\t\tIndex: bft.index,\n\t\t\tCommitment: bft.prepare.GetCommitment(),\n\t\t})\n\t\t// Don't include our response!\n\t\tresp = bft.Suite().Scalar().Set(resp).Sub(resp, bft.prepare.GetResponse())\n\t\tlog.Lvl3(bft.Name(), \"Response verification: failed\")\n\t}\n\n\t// if we didn't get all the responses, add them to the exception\n\t// 1, find children that are not in tempPrepareResponsePublics\n\t// 2, for the missing ones, find the global index and then add it to the exception\n\tpublicsMap := make(map[kyber.Point]bool)\n\tfor _, p := range bft.tempPrepareResponsePublics {\n\t\tpublicsMap[p] = true\n\t}\n\tfor _, tn := range bft.Children() {\n\t\tif !publicsMap[tn.ServerIdentity.Public] {\n\t\t\t// We assume the server was also not available for the commitment\n\t\t\t// so no need to subtract the commitment.\n\t\t\t// Conversely, we cannot handle nodes which fail right\n\t\t\t// after making a commitment at the moment.\n\t\t\tbft.tempExceptions = append(bft.tempExceptions, Exception{\n\t\t\t\tIndex: tn.RosterIndex,\n\t\t\t\tCommitment: bft.Suite().Point().Null(),\n\t\t\t})\n\t\t}\n\t}\n\n\tr := &Response{\n\t\tTYPE: RoundPrepare,\n\t\tExceptions: bft.tempExceptions,\n\t\tResponse: resp,\n\t}\n\n\tlog.Lvl3(bft.Name(), \"Response verification:\", verified)\n\treturn r, verified\n}", "func test_checkBuriedState(t *testing.T) {\n\n\taddr, _, _ := eth_gateway.EthWrapper.GenerateEthAddr()\n\n\tburied, err := eth_gateway.EthWrapper.CheckBuriedState(addr)\n\n\tif err != nil {\n\t\tt.Fatal(\"Failed to check the bury state of the given address.\")\n\t} else {\n\t\tresult := \"false\"\n\t\tif buried {\n\t\t\tresult = \"true\"\n\t\t}\n\t\tt.Log(\"Successfully checked bury state: \" + result)\n\t}\n}", "func (c Channel) Verify(r *http.Request) error {\n\ttemp := verifyPassword{}\n\te := c.bodyStruct(r, &temp)\n\n\tif e != nil {\n\t\treturn e\n\t}\n\n\t// create a channel out of the validation object\n\tchannel := are_hub.NewChannel(\"\", temp.Password)\n\n\t// insert the channel into r's context\n\t*r = *r.WithContext(channel.ToCtx(r.Context()))\n\n\treturn nil\n}", "func (_Ethdkg *EthdkgCallerSession) Verify(message []byte, sig [2]*big.Int, pubK [4]*big.Int) (bool, error) {\n\treturn _Ethdkg.Contract.Verify(&_Ethdkg.CallOpts, message, sig, pubK)\n}", "func BebListSuccess(w http.ResponseWriter) {\n\tw.WriteHeader(http.StatusAccepted)\n\tresponse := bebtypes.Response{\n\t\tStatusCode: http.StatusOK,\n\t\tMessage: \"\",\n\t}\n\terr := json.NewEncoder(w).Encode(response)\n\tExpect(err).ShouldNot(HaveOccurred())\n}", "func TestOAuthVerifyState(t *testing.T) {\n\tservice := NewOAuth2Service(testClientID, testClientSecret, testScopes, testTokenURL, testAuthURL)\n\tservice.ExchangeAuthCodeForToken(testCode)\n}", "func (_Flytrap *FlytrapCaller) VerifySub(opts *bind.CallOpts, person common.Address, topic string) (bool, [2]byte, bool, error) {\n\tvar (\n\t\tret0 = new(bool)\n\t\tret1 = new([2]byte)\n\t\tret2 = new(bool)\n\t)\n\tout := &[]interface{}{\n\t\tret0,\n\t\tret1,\n\t\tret2,\n\t}\n\terr := _Flytrap.contract.Call(opts, out, \"verifySub\", person, topic)\n\treturn *ret0, *ret1, *ret2, err\n}", "func STATUSBABYNAME(v string) predicate.Babystatus {\n\treturn predicate.Babystatus(func(s *sql.Selector) {\n\t\ts.Where(sql.EQ(s.C(FieldSTATUSBABYNAME), v))\n\t})\n}", "func (api *API) FBissueVerification(fbid uint64) (err error) {\n\temail, err := api.fBGetEmail(fbid)\n\tif err != nil {\n\t\treturn\n\t}\n\trandom, err := randomString()\n\tif err != nil {\n\t\treturn\n\t}\n\terr = api.createFBVerification(fbid, random)\n\tif err != nil {\n\t\treturn\n\t}\n\tfbtoken, err := api.fbToken(fbid)\n\tif err != nil {\n\t\treturn\n\t}\n\tfirstName, _, _, err := fBName(fbid, fbtoken)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = api.issueVerificationEmail(email, firstName, random)\n\treturn\n}", "func TestIncompleteBirdShowStatus(t *testing.T) {\n\tout := \"1011-Router ID is 192.168.1.9\\n\" +\n\t\t\" Current server time is 2018-12-27 12:15:01\\n\" +\n\t\t\" Last reboot on 2018-12-21 12:35:11\\n\"\n\tcompleted := containsActionCompletedCode([]byte(out))\n\n\tassert.False(\"'show status' successfully completed\", completed, t)\n}", "func (c *CPU6502) bvs() uint8 {\n\tif c.getFlag(flagV) == 1 {\n\t\tc.branch()\n\t}\n\treturn 0\n}", "func (api *API) fBSetVerified(email string, fbuser uint64) (id gp.UserID, err error) {\n\tid, err = api.userWithEmail(email)\n\tif err != nil {\n\t\tlog.Println(\"There isn't a user with this facebook email\")\n\t\tid, err = api.createUserFromFB(fbuser, email)\n\t\treturn\n\t}\n\terr = api.userSetFB(id, fbuser)\n\tif err == nil {\n\t\terr = api.verify(id)\n\t\tif err == nil {\n\t\t\tlog.Println(\"Verifying worked. Now setting networks from invites...\")\n\t\t\terr = api.acceptAllInvites(id, email)\n\t\t}\n\t}\n\treturn\n}", "func (cpu *Mos6502) bvc() uint8 {\n\tif cpu.GetStatusFlag(V) == 0 {\n\t\tcpu.branch()\n\t}\n\treturn 0\n}", "func (ckmgr *CheckpointManager) getVBTimestampForVB(vbno uint16, ckptDoc *metadata.CheckpointsDoc, max_seqno uint64) (*base.VBTimestamp, error) {\n\tvar agreeedIndex int = -1\n\n\t//do checkpointing only when the remote bucket supports xdcrcheckpointing\n\t//get the existing checkpoint records if they exist, otherwise return an empty ckpt record\n\tckpt_list := ckmgr.ckptRecords(ckptDoc, vbno)\n\tfor index, ckpt_record := range ckpt_list {\n\t\tif ckpt_record != nil && ckpt_record.Seqno <= max_seqno {\n\t\t\tremote_vb_status := &service_def.RemoteVBReplicationStatus{VBOpaque: ckpt_record.Target_vb_opaque,\n\t\t\t\tVBSeqno: ckpt_record.Target_Seqno,\n\t\t\t\tVBNo: vbno}\n\n\t\t\tbMatch := false\n\t\t\tbMatch, current_remoteVBOpaque, err := ckmgr.capi_svc.PreReplicate(ckmgr.remote_bucket, remote_vb_status, ckmgr.support_ckpt)\n\t\t\t//remote vb topology changed\n\t\t\t//udpate the vb_uuid and try again\n\t\t\tif err == nil {\n\t\t\t\tckmgr.updateCurrentVBOpaque(vbno, current_remoteVBOpaque)\n\t\t\t\tckmgr.logger.Debugf(\"%v Remote vbucket %v has a new opaque %v, update\\n\", ckmgr.pipeline.Topic(), current_remoteVBOpaque, vbno)\n\t\t\t\tckmgr.logger.Debugf(\"%v Done with _pre_prelicate call for %v for vbno=%v, bMatch=%v\", ckmgr.pipeline.Topic(), remote_vb_status, vbno, bMatch)\n\t\t\t}\n\n\t\t\tif err != nil || bMatch {\n\t\t\t\tif bMatch {\n\t\t\t\t\tckmgr.logger.Debugf(\"%v Remote bucket %v vbno %v agreed on the checkpoint %v\\n\", ckmgr.pipeline.Topic(), ckmgr.remote_bucket, vbno, ckpt_record)\n\t\t\t\t\tif ckptDoc != nil {\n\t\t\t\t\t\tagreeedIndex = index\n\t\t\t\t\t}\n\n\t\t\t\t} else if err == service_def.NoSupportForXDCRCheckpointingError {\n\t\t\t\t\tckmgr.updateCurrentVBOpaque(vbno, nil)\n\t\t\t\t\tckmgr.logger.Infof(\"%v Remote vbucket %v is on a old node which doesn't support checkpointing, update target_vb_uuid=0\\n\", ckmgr.pipeline.Topic(), vbno)\n\n\t\t\t\t} else {\n\t\t\t\t\tckmgr.logger.Errorf(\"%v Pre_replicate failed for %v. err=%v\\n\", ckmgr.pipeline.Topic(), vbno, err)\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tgoto POPULATE\n\t\t\t}\n\t\t}\n\t}\nPOPULATE:\n\treturn ckmgr.populateVBTimestamp(ckptDoc, agreeedIndex, vbno), nil\n}", "func TestSuccessful(t *testing.T) {\n\tcontroller := newTestController(t)\n\n\t// First try creating an invoice\n\tinv := load_scaffold_invoice(t, \"valid_v1\")\n\t_, err := controller.Client.CreateInvoice(inv)\n\tif err != nil {\n\t\tt.Fatalf(\"Unable to create invoice: %s\", err)\n\t}\n\n\t// Now create the parcel associated with that invoice\n\tdata := load_scaffold_parcel_data(t, \"valid_v1\", \"parcel\")\n\tif err := controller.Client.CreateParcel(inv.Name(), inv.Parcel[0].Label.SHA256, data); err != nil {\n\t\tt.Fatalf(\"Unable to create parcel: %s\", err)\n\t}\n\n\t// Now see if we get the parcel back from the server\n\tserverData, err := controller.Client.GetParcel(inv.Name(), inv.Parcel[0].Label.SHA256)\n\tif err != nil {\n\t\tt.Fatalf(\"Unable to fetch parcel from server: %s\", err)\n\t}\n\n\tif !reflect.DeepEqual(data, serverData) {\n\t\tt.Fatalf(\"Did not get back valid data from the server\\nExpected: %s\\nGot: %s\", data, serverData)\n\t}\n\n\t// Now try yanking the parcel and fetching it to make sure it gives us an error\n\tif err := controller.Client.YankInvoice(inv.Name()); err != nil {\n\t\tt.Fatalf(\"Unable to yank invoice: %s\", err)\n\t}\n\n\t_, err = controller.Client.GetInvoice(inv.Name())\n\tif err == nil {\n\t\tt.Fatal(\"Shouldn't be able to get a yanked invoice\")\n\t}\n\n\t// Get the yanked invoice and make sure it works\n\t_, err = controller.Client.GetYankedInvoice(inv.Name())\n\tif err != nil {\n\t\tt.Fatalf(\"Should be able to get a yanked invoice: %s\", err)\n\t}\n}", "func validateBIDS(valroot, resdir string) error {\n\tsrvcfg := config.Read()\n\tvar validateNifti bool\n\n\t// Use validation config file if available\n\tcfgpath := filepath.Join(valroot, srvcfg.Label.ValidationConfigFile)\n\tlog.ShowWrite(\"[Info] looking for config file at %q\", cfgpath)\n\tif fi, err := os.Stat(cfgpath); err == nil && !fi.IsDir() {\n\t\tvalcfg, err := handleValidationConfig(cfgpath)\n\t\tif err == nil {\n\t\t\tcheckdir := filepath.Join(valroot, valcfg.Bidscfg.BidsRoot)\n\t\t\tif fi, err = os.Stat(checkdir); err == nil && fi.IsDir() {\n\t\t\t\tvalroot = checkdir\n\t\t\t\tlog.ShowWrite(\"[Info] using validation root directory: %s; %s\", valroot, checkdir)\n\t\t\t} else {\n\t\t\t\tlog.ShowWrite(\"[Error] reading validation root directory: %s\", err.Error())\n\t\t\t}\n\t\t\tvalidateNifti = valcfg.Bidscfg.ValidateNifti\n\t\t} else {\n\t\t\tlog.ShowWrite(\"[Error] unmarshalling validation config file: %s\", err.Error())\n\t\t}\n\t} else {\n\t\tlog.ShowWrite(\"[Info] no validation config file found or processed, running from repo root: %s\", err.Error())\n\t}\n\n\t// Ignoring NiftiHeaders for now, since it seems to be a common error\n\toutBadge := filepath.Join(resdir, srvcfg.Label.ResultsBadge)\n\tlog.ShowWrite(\"[Info] running bids validation: '%s %t --json %s'\", srvcfg.Exec.BIDS, validateNifti, valroot)\n\n\t// Make sure the validator arguments are in the right order\n\tvar args []string\n\tif !validateNifti {\n\t\targs = append(args, \"--ignoreNiftiHeaders\")\n\t}\n\targs = append(args, \"--json\")\n\targs = append(args, valroot)\n\n\tvar out, serr bytes.Buffer\n\tcmd := exec.Command(srvcfg.Exec.BIDS, args...)\n\tout.Reset()\n\tserr.Reset()\n\tcmd.Stdout = &out\n\tcmd.Stderr = &serr\n\terr := cmd.Run()\n\t// Only return if the error is not related to the bids validation; if the out string contains information\n\t// we can continue\n\tif err != nil && !strings.Contains(out.String(), \"QUICK_VALIDATION_FAILED\") {\n\t\treturn fmt.Errorf(\"[Error] running bids validation (%s): %q, %q, %q\", valroot, err.Error(), serr.String(), out.String())\n\t}\n\n\t// We need this for both the writing of the result and the badge\n\toutput := out.Bytes()\n\n\t// CHECK: can this lead to a race condition, if a job for the same user/repo combination is started twice in short succession?\n\toutFile := filepath.Join(resdir, srvcfg.Label.ResultsFile)\n\terr = ioutil.WriteFile(outFile, []byte(output), os.ModePerm)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"[Error] writing results file for %q\", valroot)\n\t}\n\n\t// Write proper badge according to result\n\tcontent := resources.SuccessBadge\n\tvar parseBIDS BidsRoot\n\terr = json.Unmarshal(output, &parseBIDS)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"[Error] unmarshalling results json: %s\", err.Error())\n\t}\n\n\tif len(parseBIDS.Issues.Errors) > 0 {\n\t\tcontent = resources.ErrorBadge\n\t} else if len(parseBIDS.Issues.Warnings) > 0 {\n\t\tcontent = resources.WarningBadge\n\t}\n\n\terr = ioutil.WriteFile(outBadge, []byte(content), os.ModePerm)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"[Error] writing results badge for %q\", valroot)\n\t}\n\n\tlog.ShowWrite(\"[Info] finished validating repo at %q\", valroot)\n\treturn nil\n}", "func (l *LNCChallenger) VerifyInvoiceStatus(hash lntypes.Hash,\n\tstate lnrpc.Invoice_InvoiceState, timeout time.Duration) error {\n\n\treturn l.lndChallenger.VerifyInvoiceStatus(hash, state, timeout)\n}", "func GetMbVerificationCode(c *fiber.Ctx) error {\n\t// id := middleware.GetIdFromCookie(c)\n\tid := c.Params(\"id\")\n\tvar request dto.NewMobileVerificationRequest\n\tif err := c.BodyParser(&request); err != nil {\n\t\treturn err\n\t} else {\n\t\tappErr := service.GetMobileVerificationCode(request, id)\n\t\tif appErr.Status != true {\n\t\t\tgetStatus(c, 500, appErr)\n\t\t} else {\n\t\t\tgetStatus(c, 200, appErr)\n\t\t}\n\t}\n\treturn nil\n}", "func Verify(suite suites.Suite, X kyber.Point, msg, sig []byte) error {\n\tHM := hashToPoint(suite, msg)\n\ts := suite.G1().Point()\n\tif err := s.UnmarshalBinary(sig); err != nil {\n\t\treturn err\n\t}\n\ts.Neg(s)\n\tif !suite.PairingCheck([]kyber.Point{s, HM}, []kyber.Point{suite.G2().Point().Base(), X}) {\n\t\treturn errors.New(\"bls: invalid signature\")\n\t}\n\treturn nil\n}", "func (c *client) VerifyStatus() error {\n\t//ensure k3d is in PATH\n\tif _, err := c.pathLooker.Look(binaryName); err != nil {\n\t\tif c.verbose {\n\t\t\tfmt.Printf(\"Command '%s' not found in PATH\", binaryName)\n\t\t}\n\t\treturn fmt.Errorf(\"Command '%s' not found. Please install %s (see https://github.com/rancher/k3d#get)\", binaryName, binaryName)\n\t}\n\n\tif err := c.checkVersion(); err != nil {\n\t\treturn err\n\t}\n\n\t// execute a command and return the error\n\t_, err := c.runCmd(\"cluster\", \"list\")\n\treturn err\n}", "func (s *TXPoolServer) verifyBlock(req *tc.VerifyBlockReq, sender *actor.PID) {\n\tif req == nil || len(req.Txs) == 0 {\n\t\treturn\n\t}\n\n\ts.setHeight(req.Height)\n\ts.pendingBlock.mu.Lock()\n\tdefer s.pendingBlock.mu.Unlock()\n\n\ts.pendingBlock.sender = sender\n\ts.pendingBlock.height = req.Height\n\ts.pendingBlock.processedTxs = make(map[common.Uint256]*tc.VerifyTxResult, len(req.Txs))\n\ts.pendingBlock.unProcessedTxs = make(map[common.Uint256]*tx.Transaction, 0)\n\n\ttxs := make(map[common.Uint256]bool, len(req.Txs))\n\n\t// Check whether a tx's gas price is lower than the required, if yes,\n\t// just return error\n\tfor _, t := range req.Txs {\n\t\tif t.GasPrice < s.gasPrice {\n\t\t\tentry := &tc.VerifyTxResult{\n\t\t\t\tHeight: s.pendingBlock.height,\n\t\t\t\tTx: t,\n\t\t\t\tErrCode: errors.ErrGasPrice,\n\t\t\t}\n\t\t\ts.pendingBlock.processedTxs[t.Hash()] = entry\n\t\t\ts.sendBlkResult2Consensus()\n\t\t\treturn\n\t\t}\n\t\t// Check whether double spent\n\t\tif _, ok := txs[t.Hash()]; ok {\n\t\t\tentry := &tc.VerifyTxResult{\n\t\t\t\tHeight: s.pendingBlock.height,\n\t\t\t\tTx: t,\n\t\t\t\tErrCode: errors.ErrDoubleSpend,\n\t\t\t}\n\t\t\ts.pendingBlock.processedTxs[t.Hash()] = entry\n\t\t\ts.sendBlkResult2Consensus()\n\t\t\treturn\n\t\t}\n\t\ttxs[t.Hash()] = true\n\t}\n\n\tcheckBlkResult := s.txPool.GetUnverifiedTxs(req.Txs, req.Height)\n\n\tfor _, t := range checkBlkResult.UnverifiedTxs {\n\t\ts.assignTxToWorker(t, tc.NilSender, nil)\n\t\ts.pendingBlock.unProcessedTxs[t.Hash()] = t\n\t}\n\n\tfor _, t := range checkBlkResult.OldTxs {\n\t\ts.reVerifyStateful(t, tc.NilSender)\n\t\ts.pendingBlock.unProcessedTxs[t.Hash()] = t\n\t}\n\n\tfor _, t := range checkBlkResult.VerifiedTxs {\n\t\ts.pendingBlock.processedTxs[t.Tx.Hash()] = t\n\t}\n\n\t/* If all the txs in the blocks are verified, send response\n\t * to the consensus directly\n\t */\n\tif len(s.pendingBlock.unProcessedTxs) == 0 {\n\t\ts.sendBlkResult2Consensus()\n\t}\n}", "func VerificationHandler(w http.ResponseWriter, r *http.Request) {\n\tkey := r.URL.Query().Get(\"key\")\n\t// If we have something in the ?key= query field...\n\tif key != \"\" {\n\t\tsess, err := db.GetDbSession()\n\t\tif err != nil {\n\t\t\tpanic(\"test\")\n\t\t}\n\n\t\tuser := &models.User{}\n\t\tc := sess.Database(\"releasetrackr\").Collection(\"users\")\n\n\t\t// Find the user that the verification field corresponds to\n\t\tuserErr := c.FindOne(\n\t\t\tcontext.Background(),\n\t\t\tbson.M{\n\t\t\t\t\"verificationcode\": key,\n\t\t\t\t\"verified\": false,\n\t\t\t}).Decode(&user)\n\n\t\t// If it's invalid, display an error back to the user\n\t\tif userErr != nil {\n\t\t\tjson, _ := json.Marshal(&responses.ErrorResponse{\n\t\t\t\tCode: 400,\n\t\t\t\tError: \"The token you want to verify is invalid\",\n\t\t\t})\n\t\t\tw.WriteHeader(400)\n\t\t\tw.Write(json)\n\t\t\tlog.Printf(\"[Handler][VerificationHandler] Verification token fail: %s\", r.RemoteAddr)\n\t\t\treturn\n\t\t}\n\n\t\t// If not, we'll set the verified field to true\n\t\tchange := bson.M{\n\t\t\t\"$set\": bson.M{\n\t\t\t\t\"verified\": true,\n\t\t\t},\n\t\t}\n\t\tc.FindOneAndUpdate(\n\t\t\tcontext.Background(),\n\t\t\tuser,\n\t\t\tchange,\n\t\t)\n\n\t\tlog.Printf(\"[Handler][VerificationHandler] Verification token pass: %s - %s\", key, r.RemoteAddr)\n\n\t\t// Display a success message to the user.\n\t\tjson, _ := json.Marshal(&responses.SuccessResponse{\n\t\t\tCode: 200,\n\t\t\tMessage: \"Verification passed.\",\n\t\t})\n\n\t\tw.WriteHeader(200)\n\t\tw.Write(json)\n\t\treturn\n\t}\n}", "func (c *Client) PiSetBillingStatus(sbs piv1.SetBillingStatus) (*piv1.SetBillingStatusReply, error) {\n\tresBody, err := c.makeReq(http.MethodPost,\n\t\tpiv1.APIRoute, piv1.RouteSetBillingStatus, sbs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar sbsr piv1.SetBillingStatusReply\n\terr = json.Unmarshal(resBody, &sbsr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &sbsr, nil\n}", "func (client *Client) VerifyCen(request *VerifyCenRequest) (response *VerifyCenResponse, err error) {\n\tresponse = CreateVerifyCenResponse()\n\terr = client.DoAction(request, response)\n\treturn\n}", "func checkBinaryVersion(fsm *fsm.FSM) error {\n\tourVersion, err := semver.NewVersion(version.Get().Version)\n\tif err != nil {\n\t\treturn trace.Wrap(err, \"failed to parse this binary version: %v\",\n\t\t\tversion.Get().Version)\n\t}\n\n\tplan, err := fsm.GetPlan()\n\tif err != nil {\n\t\treturn trace.Wrap(err, \"failed to obtain operation plan\")\n\t}\n\n\trequiredVersion, err := plan.GravityPackage.SemVer()\n\tif err != nil {\n\t\treturn trace.Wrap(err, \"failed to parse required binary version: %v\",\n\t\t\tplan.GravityPackage)\n\t}\n\n\tif !ourVersion.Equal(*requiredVersion) {\n\t\treturn trace.BadParameter(\n\t\t\t`Current operation plan should be executed with the gravity binary of version %q while this binary is of version %q.\n\nPlease use the gravity binary from the upgrade installer tarball to execute the plan, or download appropriate version from the Ops Center (curl https://get.gravitational.io/telekube/install/%v | bash).\n`, requiredVersion, ourVersion, plan.GravityPackage.Version)\n\t}\n\n\treturn nil\n}", "func (b *Handler) VerifySignature(scr message.NewBlock) error {\n\tpacket := new(bytes.Buffer)\n\n\thdr := scr.State()\n\tif err := header.MarshalSignableVote(packet, hdr); err != nil {\n\t\treturn err\n\t}\n\n\treturn msg.VerifyBLSSignature(hdr.PubKeyBLS, scr.SignedHash, packet.Bytes())\n}", "func (m *Mpesa) B2BRequest(b2b B2BRequestBody) (*MpesaResult, error) {\n\n\treturn m.sendAndProcessMpesaRequest(m.getB2BUrl(), b2b, nil)\n\n}", "func (task *ParseTask) Verify(content []byte) error {\n\n\ttask.addContent(\"verify\")\n\terr := task.remote.IsValidResponse(content)\n\ttask.finishRequest(err, \"The content is valid\")\n\n\treturn err\n}", "func (h *handle) mpsseVerify() error {\n\tvar b [2]byte\n\tfor _, v := range []byte{0xAA, 0xAB} {\n\t\t// Write a bad command and ensure it returned correctly.\n\t\t// Unlike what the application note proposes, include a flush op right\n\t\t// after. Without the flush, the device will only flush after the delay\n\t\t// specified to SetLatencyTimer. The flush removes this unneeded wait,\n\t\t// which enables increasing the delay specified to SetLatencyTimer.\n\t\tb[0] = v\n\t\tb[1] = flush\n\t\tif _, err := h.Write(b[:]); err != nil {\n\t\t\treturn fmt.Errorf(\"ftdi: MPSSE verification failed: %w\", err)\n\t\t}\n\t\tp, e := h.h.GetQueueStatus()\n\t\tif e != 0 {\n\t\t\treturn toErr(\"Read/GetQueueStatus\", e)\n\t\t}\n\t\tif p != 2 {\n\t\t\treturn fmt.Errorf(\"ftdi: MPSSE verification failed: expected 2 bytes reply, got %d bytes\", p)\n\t\t}\n\t\tctx, cancel := context200ms()\n\t\tdefer cancel()\n\t\tif _, err := h.ReadAll(ctx, b[:]); err != nil {\n\t\t\treturn fmt.Errorf(\"ftdi: MPSSE verification failed: %w\", err)\n\t\t}\n\t\t// 0xFA means invalid command, 0xAA is the command echoed back.\n\t\tif b[0] != 0xFA || b[1] != v {\n\t\t\treturn fmt.Errorf(\"ftdi: MPSSE verification failed test for byte %#x: %#x\", v, b)\n\t\t}\n\t}\n\treturn nil\n}", "func (t *testerV10x) verifyResult(result types.Result, name string) string {\n\tr, err := types100.GetResult(result)\n\tExpect(err).NotTo(HaveOccurred())\n\n\tExpect(r.Interfaces).To(HaveLen(1))\n\tExpect(r.Interfaces[0].Name).To(Equal(name))\n\tExpect(r.IPs).To(HaveLen(1))\n\n\treturn r.Interfaces[0].Mac\n}", "func (client *Client) VerifyBankElementWithCallback(request *VerifyBankElementRequest, callback func(response *VerifyBankElementResponse, err error)) <-chan int {\n\tresult := make(chan int, 1)\n\terr := client.AddAsyncTask(func() {\n\t\tvar response *VerifyBankElementResponse\n\t\tvar err error\n\t\tdefer close(result)\n\t\tresponse, err = client.VerifyBankElement(request)\n\t\tcallback(response, err)\n\t\tresult <- 1\n\t})\n\tif err != nil {\n\t\tdefer close(result)\n\t\tcallback(nil, err)\n\t\tresult <- 0\n\t}\n\treturn result\n}", "func Verify (w http.ResponseWriter, r *http.Request) {\n\ttoken := helpers.ExtractToken(r)\n\tsuccess, err := helpers.VerifyToken(token)\n\n\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\tfmt.Fprintf(w, err.Error());\n\t\treturn;\n\t}\n\n\tw.WriteHeader(http.StatusOK)\n\tfmt.Fprint(w, success)\n}", "func (p *piPlugin) cmdSetBillingStatus(token []byte, payload string) (string, error) {\n\t// Decode payload\n\tvar sbs pi.SetBillingStatus\n\terr := json.Unmarshal([]byte(payload), &sbs)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Verify token\n\terr = tokenMatches(token, sbs.Token)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Verify billing status\n\tswitch sbs.Status {\n\tcase pi.BillingStatusClosed, pi.BillingStatusCompleted:\n\t\t// These are allowed; continue\n\n\tcase pi.BillingStatusActive:\n\t\t// We don't currently allow the status to be manually set to\n\t\t// active.\n\t\treturn \"\", backend.PluginError{\n\t\t\tPluginID: pi.PluginID,\n\t\t\tErrorCode: uint32(pi.ErrorCodeBillingStatusChangeNotAllowed),\n\t\t\tErrorContext: \"cannot set to active\",\n\t\t}\n\n\tdefault:\n\t\t// Billing status is invalid\n\t\treturn \"\", backend.PluginError{\n\t\t\tPluginID: pi.PluginID,\n\t\t\tErrorCode: uint32(pi.ErrorCodeBillingStatusInvalid),\n\t\t\tErrorContext: \"invalid billing status\",\n\t\t}\n\t}\n\n\t// Verify signature\n\tmsg := sbs.Token + strconv.FormatUint(uint64(sbs.Status), 10) + sbs.Reason\n\terr = util.VerifySignature(sbs.Signature, sbs.PublicKey, msg)\n\tif err != nil {\n\t\treturn \"\", convertSignatureError(err)\n\t}\n\n\t// Ensure reason is provided when status is set to closed.\n\tif sbs.Status == pi.BillingStatusClosed && sbs.Reason == \"\" {\n\t\treturn \"\", backend.PluginError{\n\t\t\tPluginID: pi.PluginID,\n\t\t\tErrorCode: uint32(pi.ErrorCodeBillingStatusChangeNotAllowed),\n\t\t\tErrorContext: \"must provide a reason when setting \" +\n\t\t\t\t\"billing status to closed\",\n\t\t}\n\t}\n\n\t// Ensure no billing status already exists\n\tstatuses, err := p.billingStatuses(token)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif len(statuses) > 0 {\n\t\treturn \"\", backend.PluginError{\n\t\t\tPluginID: pi.PluginID,\n\t\t\tErrorCode: uint32(pi.ErrorCodeBillingStatusChangeNotAllowed),\n\t\t\tErrorContext: \"can not set billing status more than once\",\n\t\t}\n\t}\n\n\t// Ensure record's vote ended and it was approved\n\tvsr, err := p.voteSummary(token)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif vsr.Status != ticketvote.VoteStatusApproved {\n\t\treturn \"\", backend.PluginError{\n\t\t\tPluginID: pi.PluginID,\n\t\t\tErrorCode: uint32(pi.ErrorCodeBillingStatusChangeNotAllowed),\n\t\t\tErrorContext: \"setting billing status is allowed only if \" +\n\t\t\t\t\"proposal vote was approved\",\n\t\t}\n\t}\n\n\t// Save billing status change\n\treceipt := p.identity.SignMessage([]byte(sbs.Signature))\n\tbsc := pi.BillingStatusChange{\n\t\tToken: sbs.Token,\n\t\tStatus: sbs.Status,\n\t\tReason: sbs.Reason,\n\t\tPublicKey: sbs.PublicKey,\n\t\tSignature: sbs.Signature,\n\t\tTimestamp: time.Now().Unix(),\n\t\tReceipt: hex.EncodeToString(receipt[:]),\n\t}\n\terr = p.billingStatusSave(token, bsc)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Prepare reply\n\tsbsr := pi.SetBillingStatusReply{\n\t\tTimestamp: bsc.Timestamp,\n\t\tReceipt: bsc.Receipt,\n\t}\n\treply, err := json.Marshal(sbsr)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(reply), nil\n}", "func ParseBvbin(s string) TermT {\n\tcs := C.CString(s)\n\tdefer C.free(unsafe.Pointer(cs))\n\treturn TermT(C.yices_parse_bvbin(cs))\n}", "func (r *SubscriptionReconciler) syncBEBSubscription(subscription *eventingv1alpha1.Subscription,\n\tresult *ctrl.Result, ctx context.Context, logger logr.Logger) (bool, error) {\n\tlogger.Info(\"Syncing subscription with BEB\")\n\n\tr.bebClient.Initialize()\n\n\t// if object is marked for deletion, we need to delete the BEB subscription\n\tif r.isInDeletion(subscription) {\n\t\treturn false, r.deleteBEBSubscription(subscription, logger, ctx)\n\t}\n\n\tvar statusChanged bool\n\tvar err error\n\tif statusChanged, err = r.bebClient.SyncBebSubscription(subscription); err != nil {\n\t\tlogger.Error(err, \"Update BEB subscription failed\")\n\t\tcondition := eventingv1alpha1.MakeCondition(eventingv1alpha1.ConditionSubscribed, eventingv1alpha1.ConditionReasonSubscriptionCreationFailed, corev1.ConditionFalse)\n\t\tif err := r.updateCondition(subscription, condition, ctx); err != nil {\n\t\t\treturn statusChanged, err\n\t\t}\n\t\treturn false, err\n\t}\n\n\tif !subscription.Status.IsConditionSubscribed() {\n\t\tcondition := eventingv1alpha1.MakeCondition(eventingv1alpha1.ConditionSubscribed, eventingv1alpha1.ConditionReasonSubscriptionCreated, corev1.ConditionTrue)\n\t\tif err := r.updateCondition(subscription, condition, ctx); err != nil {\n\t\t\treturn statusChanged, err\n\t\t}\n\t\tstatusChanged = true\n\t}\n\n\tstatusChangedAtCheck, retry, errTimeout := r.checkStatusActive(subscription)\n\tstatusChanged = statusChanged || statusChangedAtCheck\n\tif errTimeout != nil {\n\t\tlogger.Error(errTimeout, \"Timeout at retry\")\n\t\tresult.Requeue = false\n\t\treturn statusChanged, errTimeout\n\t}\n\tif retry {\n\t\tlogger.Info(\"Wait for subscription to be active\", \"name:\", subscription.Name, \"status:\", subscription.Status.EmsSubscriptionStatus.SubscriptionStatus)\n\t\tcondition := eventingv1alpha1.MakeCondition(eventingv1alpha1.ConditionSubscriptionActive, eventingv1alpha1.ConditionReasonSubscriptionNotActive, corev1.ConditionFalse)\n\t\tif err := r.updateCondition(subscription, condition, ctx); err != nil {\n\t\t\treturn statusChanged, err\n\t\t}\n\t\tresult.RequeueAfter = time.Second * 1\n\t} else if statusChanged {\n\t\tcondition := eventingv1alpha1.MakeCondition(eventingv1alpha1.ConditionSubscriptionActive, eventingv1alpha1.ConditionReasonSubscriptionActive, corev1.ConditionTrue)\n\t\tif err := r.updateCondition(subscription, condition, ctx); err != nil {\n\t\t\treturn statusChanged, err\n\t\t}\n\t}\n\t// OK\n\treturn statusChanged, nil\n}", "func (r Service) Verify(captchaResponse string) (requester.VerifyResponse, error) {\n\theaders := map[string]string{\n\t\t\"Content-Type\": \"application/x-www-form-urlencoded\",\n\t}\n\tbody := url.Values{}\n\tbody.Set(\"secret\", r.secret)\n\tbody.Set(\"response\", captchaResponse)\n\tapiRes := requester.VerifyResponse{}\n\terr := r.http.JSON(http.MethodPost, verifyAPI, headers, body.Encode(), &apiRes)\n\tif err != nil {\n\t\treturn requester.VerifyResponse{}, errors.New(\"failed to retrieve reCaptcha API response\")\n\t}\n\treturn apiRes, nil\n}", "func (service *Stainless) Verify(\n\treq *proto.VerificationRequest) (network.Message, error) {\n\tconsole, report, err := verify(req.SourceFiles)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlog.Lvl4(\"Returning\", console, report)\n\n\treturn &proto.VerificationResponse{\n\t\tConsole: console,\n\t\tReport: report,\n\t}, nil\n}", "func (cpu *Mos6502) bcs() uint8 {\n\tif cpu.GetStatusFlag(C) == 1 {\n\t\tcpu.branch()\n\t}\n\treturn 0\n}", "func (bbsbr BlockBlobsStageBlockResponse) Status() string {\n\treturn bbsbr.rawResponse.Status\n}", "func Verification(pub ecdsa.PublicKey, hash []byte, r, s *big.Int) bool {\n\tverifystatus := ecdsa.Verify(&pub, hash, r, s)\n\treturn verifystatus\n}", "func (t *testerV01xOr02x) verifyResult(result types.Result, _ string) string {\n\tr, err := types020.GetResult(result)\n\tExpect(err).NotTo(HaveOccurred())\n\n\tExpect(r.IP4.IP.IP).NotTo(BeNil())\n\tExpect(r.IP6).To(BeNil())\n\n\t// 0.2 and earlier don't return MAC address\n\treturn \"\"\n}", "func (u *walletIdentity) Verify(msg []byte, sig []byte) error {\n\treturn errors.New(\"not implemented\")\n}", "func CheckIBAN(number string) (*IBANBICInfo, error) {\n\n\tif len(number) == 0 {\n\t\treturn nil, ErrIBANBICInvalidInput\n\t}\n\n\tresult := &IBANBICInfo{\n\t\tBBAN: number,\n\t}\n\n\tbankName, err := performIBANBICRequest(\"BBANtoBANKNAME\", number)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresult.BankName = bankName\n\n\tibanAndBic, err := performIBANBICRequest(\"BBANtoIBANandBIC\", number)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tibanBicParts := strings.SplitN(ibanAndBic, \"#\", 2)\n\tif len(ibanBicParts) < 2 {\n\t\treturn nil, errors.New(ErrIBANBICServiceError + \"Failed to get BIC and IBAN code\")\n\t}\n\n\tresult.IBAN = ibanBicParts[0]\n\tresult.BIC = ibanBicParts[1]\n\n\treturn result, nil\n\n}", "func Verify() {\n\tlist, _ := proxyServiceInstance.GetUnVerified()\n\tfor _, p := range list {\n\t\tverifyJob <- p\n\t}\n}", "func (fm *FinalModelStructBytes) Verify() int {\n fm.buffer.Shift(fm.FBEOffset())\n fbeResult := fm.VerifyFields()\n fm.buffer.Unshift(fm.FBEOffset())\n return fbeResult\n}", "func (pbusnr PageBlobsUpdateSequenceNumberResponse) Status() string {\n\treturn pbusnr.rawResponse.Status\n}", "func assertSBRStatus(\n\tctx context.Context,\n\tf *framework.Framework,\n\tnamespacedName types.NamespacedName,\n) error {\n\tsbr := &v1alpha1.ServiceBindingRequest{}\n\tif err := f.Client.Get(ctx, namespacedName, sbr); err != nil {\n\t\treturn err\n\t}\n\n\tfor i, condition := range sbr.Status.Conditions {\n\t\tif condition.Type != servicebindingrequest.BindingReady && condition.Status != corev1.ConditionTrue {\n\t\t\treturn fmt.Errorf(\n\t\t\t\t\"Condition.Type and Condition.Status is '%s' and '%s' instead of '%s' and '%s'\",\n\t\t\t\tsbr.Status.Conditions[i].Type,\n\t\t\t\tsbr.Status.Conditions[i].Status,\n\t\t\t\tservicebindingrequest.BindingReady,\n\t\t\t\tcorev1.ConditionTrue)\n\t\t}\n\t}\n\treturn nil\n}", "func (_Flytrap *FlytrapSession) VerifySub(person common.Address, topic string) (bool, [2]byte, bool, error) {\n\treturn _Flytrap.Contract.VerifySub(&_Flytrap.CallOpts, person, topic)\n}", "func (m *Module) Verify(state, token string) (bool, error) {\n\tobj, err := jose.ParseEncrypted(token)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err)\n\t}\n\tb, err := obj.Decrypt(m.decryptionKey)\n\tcsrfPayload := &csrfPayload{}\n\tif err = json.Unmarshal(b, csrfPayload); err != nil {\n\t\treturn false, errors.Wrap(err)\n\t}\n\tif state != csrfPayload.State {\n\t\treturn false, nil\n\t}\n\tif time.Now().After(csrfPayload.ExpireAfter) {\n\t\treturn false, nil\n\t}\n\treturn true, nil\n}", "func (s *service) Verify(w http.ResponseWriter, r *http.Request) (interface{}, error) {\n\tctx := r.Context()\n\tuserID := httpapi.GetUserID(r)\n\ttoken := httpapi.GetToken(r)\n\n\treq, err := decodeSignupVerifyRequest(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tuser, err := s.repoMngr.User().ByIdentity(ctx, \"ID\", userID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err = s.otp.ValidateOTP(req.Code, token.CodeHash); err != nil {\n\t\treturn nil, err\n\t}\n\n\tjwtToken, err := s.token.Create(ctx, user, auth.JWTAuthorized)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err = s.markUserVerified(ctx, user); err != nil {\n\t\treturn nil, err\n\t}\n\n\tloginHistory := &auth.LoginHistory{\n\t\tUserID: userID,\n\t\tTokenID: jwtToken.Id,\n\t\tIPAddress: sql.NullString{\n\t\t\tString: httpapi.GetIP(r),\n\t\t\tValid: true,\n\t\t},\n\t\tExpiresAt: s.token.RefreshableTill(ctx, jwtToken, jwtToken.RefreshToken),\n\t}\n\tif err = s.repoMngr.LoginHistory().Create(ctx, loginHistory); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn s.respond(ctx, w, user, jwtToken)\n}", "func (_Flytrap *FlytrapCallerSession) VerifySub(person common.Address, topic string) (bool, [2]byte, bool, error) {\n\treturn _Flytrap.Contract.VerifySub(&_Flytrap.CallOpts, person, topic)\n}", "func (api *Api) verify() error {\n\treturn nil\n}", "func GetStatusSniffer(uuid string) (running bool, status bool) {\n owlh, err := ndb.GetStapServerInformation(uuid)\n if err != nil {\n logs.Error(\"Error retrieving stap server information\")\n }\n logs.Info(\"Checking Sniffer status for uuid: \" + uuid)\n\n running, pid, cpu, mem := GetStatusSnifferSSH(uuid)\n cpuStatus := GetStatusCPU(owlh, cpu, uuid)\n memStatus := GetStatusMEM(owlh, mem, uuid)\n storageStatus := GetStatusStorage(owlh, uuid)\n\n logs.Alert(\"Checking \" + owlh[\"name\"] + \" - \" + owlh[\"ip\"] + \" - PID:\" + pid + \" CPU: \" + strconv.FormatBool(cpuStatus) + \" MEM: \" + strconv.FormatBool(memStatus) + \" STORAGE: \" + strconv.FormatBool(storageStatus))\n if cpuStatus && memStatus && storageStatus {\n return running, true\n }\n return running, false\n}", "func VFNMSUB132PD_BCST(ops ...operand.Op) { ctx.VFNMSUB132PD_BCST(ops...) }", "func verify(publicKey *rsa.PublicKey, message []byte, sig []byte) error {\n\th := sha256.New()\n\th.Write(message)\n\td := h.Sum(nil)\n\treturn rsa.VerifyPKCS1v15(publicKey, crypto.SHA256, d, sig)\n}", "func HandleLoadbalancerGetSuccessfully(t *testing.T) {\n\tth.Mux.HandleFunc(\"/v2.0/lbaas/loadbalancers/36e08a3e-a78f-4b40-a229-1e7e23eee1ab\", func(w http.ResponseWriter, r *http.Request) {\n\t\tth.TestMethod(t, r, \"GET\")\n\t\tth.TestHeader(t, r, \"X-Auth-Token\", client.TokenID)\n\t\tth.TestHeader(t, r, \"Accept\", \"application/json\")\n\n\t\tfmt.Fprintf(w, SingleLoadbalancerBody)\n\t})\n}", "func (u *UserController) VerifyLink(c *gin.Context) {\n\tvar data forms.ResendCommand\n\n\tif (c.BindJSON(&data)) != nil {\n\t\tc.JSON(400, gin.H{\"message\": \"Provided all fields\"})\n\t\tc.Abort()\n\t\treturn\n\t}\n\n\tresult, err := userModel.GetUserByEmail(data.Email)\n\n\tif result.Email == \"\" {\n\t\tc.JSON(404, gin.H{\"message\": \"User account was not found\"})\n\t\tc.Abort()\n\t\treturn\n\t}\n\n\tif err != nil {\n\t\tc.JSON(500, gin.H{\"message\": \"Something wrong happened, try again later\"})\n\t\tc.Abort()\n\t\treturn\n\t}\n\n\tresetToken, _ := services.GenerateNonAuthToken(result.Email)\n\n\tlink := \"http://localhost:5000/api/v1/verify-account?verify_token=\" + resetToken\n\tbody := \"Here is your reset <a href='\" + link + \"'>link</a>\"\n\thtml := \"<strong>\" + body + \"</strong>\"\n\n\temail := services.SendMail(\"Verify Account\", body, result.Email, html, result.Name)\n\n\tif email == true {\n\t\tc.JSON(200, gin.H{\"messsage\": \"Check mail\"})\n\t\tc.Abort()\n\t\treturn\n\t} else {\n\t\tc.JSON(500, gin.H{\"message\": \"An issue occured sending you an email\"})\n\t\tc.Abort()\n\t\treturn\n\t}\n}", "func (cpu *Mos6502) sbc() uint8 {\n\tcpu.fetch()\n\n\tvalue := word(cpu.fetchedData) ^ 0x00ff\n\tcpu.temp = word(cpu.a) + value + word(cpu.GetStatusFlag(C))\n\n\tcpu.setStatusFlag(C, (cpu.temp&0xff00)>>7 == 1)\n\tcpu.setStatusFlag(Z, (cpu.temp&0x00ff) == 0)\n\tcpu.setStatusFlag(V, (cpu.temp^word(cpu.a))&(cpu.temp^value)&0x0080 > 0)\n\tcpu.setStatusFlag(N, (cpu.temp&0x0080) > 0)\n\n\tcpu.a = byte(cpu.temp & 0x00ff)\n\treturn 1\n}", "func (u *User) VerifyPIN(pin string) (map[string]interface{}, error) {\n\tlog.info(\"========== VERIFY PIN ==========\")\n\turl := buildURL(path[\"auth\"], u.UserID)\n\n\tdata := `{ \"refresh_token\": \"` + u.RefreshToken + `\", \"validation_pin\": \"` + pin + `\" }`\n\n\tres, err := u.do(\"POST\", url, data, nil)\n\n\treturn res, err\n}", "func (t *SimpleChaincode) verifyFile(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) {\r\n\tvar key, value,vstring string\r\n\tvar err error\r\n\t\r\n\r\n\tfmt.Println(\"running verifyFile()\")\r\n\r\n\tif len(args) != 2 {\r\n\t\treturn nil, errors.New(\"Incorrect number of arguments. Expecting 2. name of the key and value to set\")\r\n\t}\r\n\r\n\tkey = args[0] //rename for funsies\r\n\tvalue = args[1]\r\n\t\r\n\tv,err := stub.GetState(key)\r\n\tif err != nil {\r\n\t\treturn nil, errors.New(\"Failed to get state\")\r\n\t}\r\n\tif v==nil {\r\n\t\treturn nil, errors.New(\"NIF doesn't exist\")\r\n\t} else {\r\n\t\t\r\n\t\tvstring = string(v)\r\n\t\tif vstring==value {\r\n\t\t\treturn nil,nil\r\n\t\t} else { \r\n\t\t\t\r\n\t\t\treturn nil, errors.New(\"No Match\")\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t}\r\n\treturn nil, nil\r\n}", "func Verify() bool {\n\treturn true\n}", "func (c OffChainCrossNodeSimplePaymentReconciliationBill) VerifySignature() error {\n\n\treturn c.ChannelChainTransferData.CheckMustAddressAndSigns()\n}", "func signVCWithBBS(r *require.Assertions, vc *verifiableapi.Credential) string {\n\tpubKey, privKey, err := bbs12381g2pub.GenerateKeyPair(sha256.New, nil)\n\tr.NoError(err)\n\tr.NotEmpty(privKey)\n\n\tpubKeyBytes, err := pubKey.Marshal()\n\tr.NoError(err)\n\n\tdidKey, keyID := fingerprint.CreateDIDKeyByCode(fingerprint.BLS12381g2PubKeyMultiCodec, pubKeyBytes)\n\n\tbbsSigner, err := newBBSSigner(privKey)\n\tr.NoError(err)\n\n\tsigSuite := bbsblssignature2020.New(\n\t\tsuite.WithSigner(bbsSigner),\n\t\tsuite.WithVerifier(bbsblssignature2020.NewG2PublicKeyVerifier()))\n\n\tldpContext := &verifiableapi.LinkedDataProofContext{\n\t\tSignatureType: \"BbsBlsSignature2020\",\n\t\tSignatureRepresentation: verifiableapi.SignatureProofValue,\n\t\tSuite: sigSuite,\n\t\tVerificationMethod: keyID,\n\t}\n\n\tloader, err := jsonldtest.DocumentLoader()\n\tr.NoError(err)\n\n\terr = vc.AddLinkedDataProof(ldpContext, jsonld.WithDocumentLoader(loader))\n\tr.NoError(err)\n\n\tvcSignedBytes, err := json.Marshal(vc)\n\tr.NoError(err)\n\tr.NotEmpty(vcSignedBytes)\n\n\tvcVerified, err := verifiableapi.ParseCredential(vcSignedBytes,\n\t\tverifiableapi.WithEmbeddedSignatureSuites(sigSuite),\n\t\tverifiableapi.WithPublicKeyFetcher(verifiableapi.SingleKey(pubKeyBytes, \"Bls12381G2Key2020\")),\n\t\tverifiableapi.WithJSONLDDocumentLoader(loader),\n\t)\n\tr.NoError(err)\n\tr.NotNil(vcVerified)\n\n\treturn didKey\n}", "func (s *Server) verifyTransaction(tx *Transaction) bool {\n\ttime.Sleep(txDelay)\n\treturn true\n}", "func (a *Client) BurnToken(params *BurnTokenParams) (*BurnTokenOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewBurnTokenParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"burnToken\",\n\t\tMethod: \"POST\",\n\t\tPathPattern: \"/asset/tokens/{symbol}/burns\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"http\", \"https\"},\n\t\tParams: params,\n\t\tReader: &BurnTokenReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*BurnTokenOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for burnToken: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "func verifyCircleCIJobSuccess(orgRepo, gitHash, circleCIDeployJobName, circleCIAPIToken string) (err error) {\n\tclient := &circleci.Client{Token: circleCIAPIToken}\n\tsplitOrgRepo := strings.Split(orgRepo, \"/\")\n\torg := splitOrgRepo[0]\n\trepo := splitOrgRepo[1]\n\tvar targetBuildNum int\n\tif targetBuildNum, err = obtainBuildNum(org, repo, gitHash, circleCIDeployJobName,\n\t\tclient); err != nil {\n\t\treturn\n\t}\n\treturn checkForJobSuccess(org, repo, targetBuildNum, client)\n}", "func Test_VerifySigFromTass(t *testing.T) {\n\trequire := require.New(t)\n\n\t//c := &sm2.Driver{}\n\n\txBytes := common.FromHex(\"0000000000000000000000000000000000000000000000000000000000000000FD4241057FEC6CBEEC501F7E1763751B8F6DFCFB910FB634FBB76A16639EF172\")\n\tyBytes := common.FromHex(\"00000000000000000000000000000000000000000000000000000000000000001C6DA89F9C1A5EE9B6108E5A2A5FE336962630A34DBA1AF428451E1CE63BB3CF\")\n\tx := new(big.Int).SetBytes(xBytes)\n\ty := new(big.Int).SetBytes(yBytes)\n\n\tpublicKey := &gmsm_sm2.PublicKey{\n\t\tX: x,\n\t\tY: y,\n\t}\n\tvar pubSM2 sm2.PubKeySM2\n\tcopy(pubSM2[:], gmsm_sm2.Compress(publicKey))\n\n\trBytes := common.FromHex(\"00000000000000000000000000000000000000000000000000000000000000003AA29337E7149047FB8AE83F30AA00125E23173C88F284ADDED2E5B59ACAA5B9\")\n\tsBytes := common.FromHex(\"0000000000000000000000000000000000000000000000000000000000000000E2E9338109D74269578216039FD4D1C764E7F6F142CBB2E3035E7E49D375D330\")\n\tr := new(big.Int).SetBytes(rBytes)\n\ts := new(big.Int).SetBytes(sBytes)\n\n\tsignature := sm2.SignatureSM2(sm2.Serialize(r, s))\n\n\tmsg := []byte(\"112233445566112233445566112233445566112233445566\")\n\tok := pubSM2.VerifyBytes(msg, signature)\n\trequire.Equal(true, ok)\n}", "func (cpu *Mos6502) bcc() uint8 {\n\tif cpu.GetStatusFlag(C) == 0 {\n\t\tcpu.branch()\n\t}\n\treturn 0\n}", "func Verify(res http.ResponseWriter, req *http.Request) {\n\tvar (\n\t\tuserModel models.User\n\t\terrorResponse response.Error\n\t\tsuccessResponse response.Success\n\t\tverfiy userRequest.Verify\n\t\terror error\n\t)\n\terror = json.NewDecoder(req.Body).Decode(&verfiy)\n\tif error != nil {\n\t\terrorResponse.Code = http.StatusBadRequest\n\t\terrorResponse.Error = config.InvalidRequest\n\t\thelpers.SetResponse(res, http.StatusBadRequest, errorResponse)\n\t\treturn\n\t}\n\terror = verfiy.Validate()\n\tif error != nil {\n\t\terrorResponse.Code = http.StatusBadRequest\n\t\terrorResponse.Error = helpers.FormatError(error.Error())\n\t\thelpers.SetResponse(res, http.StatusBadRequest, errorResponse)\n\t\treturn\n\t}\n\tuser := userModel.Check(req.Context().Value(\"identity\"))\n\t//log.Println(user)\n\totp, _ := strconv.ParseInt(verfiy.Otp, 10, 64)\n\tif user.ID < 0 || user.OTP != otp || !helpers.InArray(user.OtpType, []string{\"authorizeEmail\", \"authorizePhone\", \"verifyEmail\", \"verifyPhone\"}) {\n\t\terrorResponse.Code = http.StatusBadRequest\n\t\terrorResponse.Error = config.InvalidToken\n\t\thelpers.SetResponse(res, http.StatusBadRequest, errorResponse)\n\t\treturn\n\t}\n\tswitch user.OtpType {\n\tcase \"authorizeEmail\":\n\t\tuser.EmailVerify = 1\n\t\tuser.LastLogedIn = time.Now()\n\t\tsuccessResponse.Msg = config.LoggedInMsg\n\tcase \"authorizePhone\":\n\t\tuser.PhoneVerify = 1\n\t\tuser.LastLogedIn = time.Now()\n\t\tsuccessResponse.Msg = config.LoggedInMsg\n\tcase \"verifyEmail\":\n\t\tuser.EmailVerify = 1\n\t\tsuccessResponse.Msg = config.EmailVerifyMsg\n\tcase \"verifyPhone\":\n\t\tuser.PhoneVerify = 1\n\t\tsuccessResponse.Msg = config.PhoneVerifyMsg\n\t}\n\tuser.OTP, user.OtpType, user.OtpValidity = 0, \"\", 0\n\terror = userModel.UpdateDetail()\n\tif error != nil {\n\t\terrorResponse.Code = http.StatusServiceUnavailable\n\t\terrorResponse.Error = config.ServiceUnavailable\n\t\thelpers.SetResponse(res, http.StatusServiceUnavailable, errorResponse)\n\t\treturn\n\t}\n\tsuccessResponse.Code = http.StatusOK\n\thelpers.SetResponse(res, http.StatusOK, successResponse)\n}", "func GetB() bool {\n\treturn machine.BUTTONB.Get()\n}", "func VerifyPassword(userName, password string) bool {\n\tlocalShare, err := LocalShareForPwdVerification()\n\n\tif err != nil {\n\t\treturn false\n\t}\n\n\tcmd := exec.Command(\"smbclient\", \"//localhost/\"+localShare, \"-U\", userName, \"-c\", \"exit\")\n\n\tvar outbuf bytes.Buffer\n\tcmd.Stdout = &outbuf\n\n\tstdin, _ := cmd.StdinPipe()\n\n\tcmd.Start()\n\n\tstdin.Write([]byte(password))\n\tstdin.Close()\n\n\terr = cmd.Wait()\n\n\toutput := outbuf.String()\n\n\tlog.Printf(\"Output of password verification: %s\\n.\", output)\n\n\treturn err == nil\n}", "func vbm(args ...string) error {\n\treturn cmd(B2D.Vbm, args...)\n}", "func tearDown(url string) {\n\tvar errTransactions int64\n\terrTransactions = 0\n\tfmt.Println(\"....... State transfer is happening, Lets take a nap for 2 mins ......\")\n\tsleep(120)\n\tval1, val2 := queryChaincode(counter)\n\tfmt.Println(\"========= After Query Vals A = \",val1,\" \\n B = \", val2,\"\\n\")\n\n/*\theight := getChainHeight(url) //Remove hardcoding ??\n\tfmt.Println(\"========= Total Blocks #\", height)\n\tfor i := 1; i < height; i++ {\n\t\t//TODO: Don't hard code IP , can we take this as argument ?\n\t\tnonHashData := chaincode.ChaincodeBlockTrxInfo(url, i)\n\t\tlength := len(nonHashData.TransactionResult)\n\t\tfor j := 0; j < length; j++ {\n\t\t\tif nonHashData.TransactionResult[j].ErrorCode > 0 {\n\t\t\t\tfmt.Printf(\"\\n========= Block[%d] Trx#[%s] UUID [%d] ErrorCode [%d] Error: %s\\n\", i, counter, nonHashData.TransactionResult[j].Uuid, nonHashData.TransactionResult[j].ErrorCode, nonHashData.TransactionResult[j].Error)\n\t\t\t\terrTransactions++\n\t\t\t}\n\t\t}\n\t}\n\tif errTransactions > 0 {\n\t\tfmt.Println(\"========= Failed transactions #\", errTransactions)\n\t}\n\tfmt.Println(\"========= Successful transactions #\", counter-errTransactions)\n\n\tnewVal,err := strconv.ParseInt(val2, 10, 64);\n\n\tif err != nil {\n\t\t\tfmt.Println(\"Failed to convert \",val2,\" to int64\\n Error: \", err)\n\t}*/\n\n\t//TODO: Block size again depends on the Block configuration in pbft config file\n\t//Test passes when 2 * block height match with total transactions, else fails\n\tif (newVal == counter) {\n\t\tfmt.Println(\"######### TEST PASSED #########\")\n\t} else {\n\t\tfmt.Println(\"######### TEST FAILED #########\")\n\t}\n\n}", "func signVCWithBBS(r *require.Assertions, vc *verifiable.Credential) string {\n\tpubKey, privKey, err := bbs12381g2pub.GenerateKeyPair(sha256.New, nil)\n\tr.NoError(err)\n\tr.NotEmpty(privKey)\n\n\tpubKeyBytes, err := pubKey.Marshal()\n\tr.NoError(err)\n\n\tdidKey, keyID := fingerprint.CreateDIDKeyByCode(fingerprint.BLS12381g2PubKeyMultiCodec, pubKeyBytes)\n\n\tbbsSigner, err := newBBSSigner(privKey)\n\tr.NoError(err)\n\n\tsigSuite := bbsblssignature2020.New(\n\t\tsuite.WithSigner(bbsSigner),\n\t\tsuite.WithVerifier(bbsblssignature2020.NewG2PublicKeyVerifier()))\n\n\tldpContext := &verifiable.LinkedDataProofContext{\n\t\tSignatureType: \"BbsBlsSignature2020\",\n\t\tSignatureRepresentation: verifiable.SignatureProofValue,\n\t\tSuite: sigSuite,\n\t\tVerificationMethod: keyID,\n\t}\n\n\tloader, err := jsonldtest.DocumentLoader()\n\tr.NoError(err)\n\n\terr = vc.AddLinkedDataProof(ldpContext, jsonld.WithDocumentLoader(loader))\n\tr.NoError(err)\n\n\tvcSignedBytes, err := json.Marshal(vc)\n\tr.NoError(err)\n\tr.NotEmpty(vcSignedBytes)\n\n\tvcVerified, err := verifiable.ParseCredential(vcSignedBytes,\n\t\tverifiable.WithEmbeddedSignatureSuites(sigSuite),\n\t\tverifiable.WithPublicKeyFetcher(verifiable.SingleKey(pubKeyBytes, \"Bls12381G2Key2020\")),\n\t\tverifiable.WithJSONLDDocumentLoader(loader),\n\t)\n\tr.NoError(err)\n\tr.NotNil(vcVerified)\n\n\treturn didKey\n}" ]
[ "0.54125434", "0.54113877", "0.535207", "0.532243", "0.52799875", "0.52168584", "0.52088404", "0.5178279", "0.5171409", "0.5150322", "0.5136394", "0.51195115", "0.5100915", "0.5069178", "0.5030368", "0.50266194", "0.50152457", "0.50060326", "0.49994752", "0.49660742", "0.49428263", "0.49365884", "0.4928855", "0.4923025", "0.4856724", "0.48519108", "0.48517528", "0.4843189", "0.48377275", "0.4820545", "0.48023626", "0.4800466", "0.47908953", "0.47854102", "0.4780447", "0.47792235", "0.47754645", "0.47679043", "0.47643974", "0.47539324", "0.475349", "0.4749074", "0.4745571", "0.47432226", "0.47376123", "0.4729231", "0.471802", "0.47109535", "0.4709872", "0.47017545", "0.46967703", "0.46959636", "0.46954465", "0.46781793", "0.46720552", "0.46669397", "0.46651903", "0.46622956", "0.46616846", "0.46568683", "0.46549767", "0.46524227", "0.4646072", "0.46405277", "0.46229598", "0.4621771", "0.46216354", "0.46037722", "0.46005103", "0.45943594", "0.45938602", "0.45922554", "0.45918822", "0.4589522", "0.4577476", "0.4576335", "0.45630547", "0.45628038", "0.45580724", "0.45547152", "0.45496875", "0.45420006", "0.4539046", "0.45363435", "0.45306793", "0.4525411", "0.45241714", "0.45221856", "0.45123208", "0.45111996", "0.4509895", "0.4508298", "0.44991872", "0.4494003", "0.44914994", "0.44819832", "0.4479452", "0.44767103", "0.4475146", "0.447173" ]
0.73651963
0
CheckDeposit check a deposit for an address given the address id
Проверить депозит по адресу, используя идентификатор адреса
func (as *AddressService) CheckDeposit(addressID int) error { if isEmptyStr(as.assetCode) { return errAssetCode } if err := as.client.Get(buildString("address/check/", as.assetCode, "/", strconv.Itoa(addressID)), nil); err != nil { return err } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (k *Keeper) GetDeposit(ctx sdk.Context, address sdk.AccAddress) (deposit types.Deposit, found bool) {\n\tstore := k.Store(ctx)\n\n\tkey := types.DepositKey(address)\n\tvalue := store.Get(key)\n\tif value == nil {\n\t\treturn deposit, false\n\t}\n\n\tk.cdc.MustUnmarshalBinaryBare(value, &deposit)\n\treturn deposit, true\n}", "func (p *PrivKey) checkImportedAddress(walletAddress, p2shSegwitAddress, fullPublicKey string) {\n\t// Note,\n\t// GetAccount() calls GetAddressInfo() internally\n\n\tvar (\n\t\ttargetAddr string\n\t\taddrType address.AddrType\n\t)\n\n\tswitch p.btc.CoinTypeCode() {\n\tcase coin.BTC:\n\t\ttargetAddr = p2shSegwitAddress\n\t\taddrType = address.AddrTypeP2shSegwit\n\tcase coin.BCH:\n\t\ttargetAddr = walletAddress\n\t\taddrType = address.AddrTypeBCHCashAddr\n\tdefault:\n\t\tp.logger.Warn(\"this coin type is not implemented in checkImportedAddress()\",\n\t\t\tzap.String(\"coin_type_code\", p.btc.CoinTypeCode().String()))\n\t\treturn\n\t}\n\n\t// 1.call `getaccount` by target_address\n\tacnt, err := p.btc.GetAccount(targetAddr)\n\tif err != nil {\n\t\tp.logger.Warn(\n\t\t\t\"fail to call btc.GetAccount()\",\n\t\t\tzap.String(addrType.String(), targetAddr),\n\t\t\tzap.Error(err))\n\t\treturn\n\t}\n\tp.logger.Debug(\n\t\t\"account is found\",\n\t\tzap.String(\"account\", acnt),\n\t\tzap.String(addrType.String(), targetAddr))\n\n\t// 2.call `getaddressinfo` by target_address\n\taddrInfo, err := p.btc.GetAddressInfo(targetAddr)\n\tif err != nil {\n\t\tp.logger.Warn(\n\t\t\t\"fail to call btc.GetAddressInfo()\",\n\t\t\tzap.String(addrType.String(), targetAddr),\n\t\t\tzap.Error(err))\n\t} else {\n\t\tif addrInfo.Pubkey != fullPublicKey {\n\t\t\tp.logger.Warn(\n\t\t\t\t\"pubkey is not matched\",\n\t\t\t\tzap.String(\"in_bitcoin_core\", addrInfo.Pubkey),\n\t\t\t\tzap.String(\"in_database\", fullPublicKey))\n\t\t}\n\t}\n}", "func (u Usecase) Deposit(ctx context.Context, accID vos.AccountID, amount vos.Money) error {\n\tconst operation = \"accounts.Usecase.Deposit\"\n\n\tlog := logger.FromCtx(ctx).WithFields(logrus.Fields{\n\t\t\"accID\": accID,\n\t\t\"amount\": amount.Int(),\n\t})\n\n\tlog.Infoln(\"processing a deposit\")\n\n\tif amount <= 0 {\n\t\treturn ErrInvalidAmount\n\t}\n\n\terr := u.accRepo.Deposit(ctx, accID, amount)\n\n\tif err != nil {\n\t\treturn domain.Error(operation, err)\n\t}\n\n\tlog.Infoln(\"deposit successfully processed\")\n\n\treturn nil\n}", "func (e Exchange) DepositAddress(exch string, currencyCode currency.Code) (out string, err error) {\n\tif currencyCode.IsEmpty() {\n\t\terr = errors.New(\"currency code is empty\")\n\t\treturn\n\t}\n\treturn engine.Bot.DepositAddressManager.GetDepositAddressByExchange(exch, currencyCode)\n}", "func (mapper GovMapper) GetDeposit(proposalID uint64, depositorAddr btypes.Address) (deposit gtypes.Deposit, exists bool) {\n\texists = mapper.Get(KeyDeposit(proposalID, depositorAddr), &deposit)\n\tif !exists {\n\t\treturn gtypes.Deposit{}, false\n\t}\n\n\treturn deposit, true\n}", "func (h *HUOBI) QueryDepositAddress(ctx context.Context, cryptocurrency currency.Code) ([]DepositAddress, error) {\n\tresp := struct {\n\t\tDepositAddress []DepositAddress `json:\"data\"`\n\t}{}\n\n\tvals := url.Values{}\n\tvals.Set(\"currency\", cryptocurrency.Lower().String())\n\n\terr := h.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, huobiAccountDepositAddress, vals, nil, &resp, true)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(resp.DepositAddress) == 0 {\n\t\treturn nil, errors.New(\"deposit address data isn't populated\")\n\t}\n\treturn resp.DepositAddress, nil\n}", "func (_PlasmaFramework *PlasmaFrameworkCaller) IsDeposit(opts *bind.CallOpts, blockNum *big.Int) (bool, error) {\n\tvar (\n\t\tret0 = new(bool)\n\t)\n\tout := ret0\n\terr := _PlasmaFramework.contract.Call(opts, out, \"isDeposit\", blockNum)\n\treturn *ret0, err\n}", "func deposit(ctx iscp.Sandbox) (dict.Dict, error) {\n\tctx.Log().Debugf(\"accounts.deposit.begin -- %s\", ctx.IncomingTransfer())\n\n\tmustCheckLedger(ctx.State(), \"accounts.deposit.begin\")\n\n\tcaller := ctx.Caller()\n\tparams := kvdecoder.New(ctx.Params(), ctx.Log())\n\ttargetAccount := params.MustGetAgentID(ParamAgentID, caller)\n\ttargetAccount = commonaccount.AdjustIfNeeded(targetAccount, ctx.ChainID())\n\n\t// funds currently are in the common account (because call is to 'accounts'), they must be moved to the target\n\tsucc := MoveBetweenAccounts(ctx.State(), commonaccount.Get(ctx.ChainID()), targetAccount, ctx.IncomingTransfer())\n\tassert.NewAssert(ctx.Log()).Require(succ, \"internal error: failed to deposit to %s\", targetAccount.String())\n\n\tctx.Log().Debugf(\"accounts.deposit.success: target: %s\\n%s\",\n\t\ttargetAccount, ctx.IncomingTransfer().String())\n\n\tmustCheckLedger(ctx.State(), \"accounts.deposit.exit\")\n\treturn nil, nil\n}", "func ProcessDeposit(state *beacon.BeaconState, dep *beacon.Deposit) error {\n\t// Deposits must be processed in order\n\tif dep.Index != state.DepositIndex {\n\t\treturn errors.New(fmt.Sprintf(\"deposit has index %d that does not match with state index %d\", dep.Index, state.DepositIndex))\n\t}\n\n\tserializedDepositData := dep.Data.Serialized()\n\n\t// Verify the Merkle branch\n\tif !merkle.VerifyMerkleBranch(\n\t\thash.Hash(serializedDepositData),\n\t\tdep.Proof[:],\n\t\tbeacon.DEPOSIT_CONTRACT_TREE_DEPTH,\n\t\tuint64(dep.Index),\n\t\tstate.LatestEth1Data.DepositRoot) {\n\t\treturn errors.New(fmt.Sprintf(\"deposit %d has merkle proof that failed to be verified\", dep.Index))\n\t}\n\n\t// Increment the next deposit index we are expecting. Note that this\n\t// needs to be done here because while the deposit contract will never\n\t// create an invalid Merkle branch, it may admit an invalid deposit\n\t// object, and we need to be able to skip over it\n\tstate.DepositIndex += 1\n\n\tvalIndex := beacon.ValidatorIndexMarker\n\tfor i, v := range state.ValidatorRegistry {\n\t\tif v.Pubkey == dep.Data.Pubkey {\n\t\t\tvalIndex = beacon.ValidatorIndex(i)\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Check if it is a known validator that is depositing (\"if pubkey not in validator_pubkeys\")\n\tif valIndex == beacon.ValidatorIndexMarker {\n\t\t// only unknown pubkeys need to be verified, others are already trusted\n\t\tif !bls.BlsVerify(\n\t\t\tdep.Data.Pubkey,\n\t\t\tssz.SignedRoot(dep.Data),\n\t\t\tdep.Data.ProofOfPossession,\n\t\t\tbeacon.GetDomain(state.Fork, state.Epoch(), beacon.DOMAIN_DEPOSIT)) {\n\t\t\t// simply don't handle the deposit.\n\t\t\treturn nil\n\t\t}\n\n\t\t// Not a known pubkey, add new validator\n\t\tvalidator := beacon.Validator{\n\t\t\tPubkey: dep.Data.Pubkey,\n\t\t\tWithdrawalCredentials: dep.Data.WithdrawalCredentials,\n\t\t\tActivationEpoch: beacon.FAR_FUTURE_EPOCH,\n\t\t\tExitEpoch: beacon.FAR_FUTURE_EPOCH,\n\t\t\tWithdrawableEpoch: beacon.FAR_FUTURE_EPOCH,\n\t\t\tInitiatedExit: false,\n\t\t\tSlashed: false,\n\t\t\tHighBalance: 0,\n\t\t}\n\t\t// Note: In phase 2 registry indices that have been withdrawn for a long time will be recycled.\n\t\tstate.ValidatorRegistry = append(state.ValidatorRegistry, validator)\n\t\tstate.Balances = append(state.Balances, 0)\n\t\tvalIndex = beacon.ValidatorIndex(len(state.ValidatorRegistry) - 1)\n\t\tstate.SetBalance(valIndex, dep.Data.Amount)\n\t} else {\n\t\t// Increase balance by deposit amount\n\t\tstate.IncreaseBalance(valIndex, dep.Data.Amount)\n\t}\n\treturn nil\n}", "func (_SingleAuto *SingleAutoFilterer) FilterDeposit(opts *bind.FilterOpts, user []common.Address, pid []*big.Int) (*SingleAutoDepositIterator, error) {\n\n\tvar userRule []interface{}\n\tfor _, userItem := range user {\n\t\tuserRule = append(userRule, userItem)\n\t}\n\tvar pidRule []interface{}\n\tfor _, pidItem := range pid {\n\t\tpidRule = append(pidRule, pidItem)\n\t}\n\n\tlogs, sub, err := _SingleAuto.contract.FilterLogs(opts, \"Deposit\", userRule, pidRule)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &SingleAutoDepositIterator{contract: _SingleAuto.contract, event: \"Deposit\", logs: logs, sub: sub}, nil\n}", "func (_Depositmanager *DepositmanagerSession) DepositFor(_destination common.Address, _amount *big.Int, _tokenType *big.Int, _pubkey []byte) (*types.Transaction, error) {\n\treturn _Depositmanager.Contract.DepositFor(&_Depositmanager.TransactOpts, _destination, _amount, _tokenType, _pubkey)\n}", "func (_Depositmanager *DepositmanagerTransactorSession) DepositFor(_destination common.Address, _amount *big.Int, _tokenType *big.Int, _pubkey []byte) (*types.Transaction, error) {\n\treturn _Depositmanager.Contract.DepositFor(&_Depositmanager.TransactOpts, _destination, _amount, _tokenType, _pubkey)\n}", "func (dcr *ExchangeWallet) DepositAddress() (string, error) {\n\taddr, err := dcr.wallet.ExternalAddress(dcr.ctx, dcr.depositAccount())\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn addr.String(), nil\n}", "func deposit(scid string, amount int64) {\n\t\n\twalletURL:= \"http://127.0.0.1:30309/json_rpc\"\n\t\n\tdata:= PayloadDeposit{\n\t\tJsonrpc: \"2.0\", \n\t\tID: \"0\",\n\t\tMethod: \"transfer_split\",\n\t\tParams: Params{\n\t\t\tMixin: 5,\n\t\t\tGetTxKey: true,\n\t\t\tScTx: ScTx{\n\t\t\t\tEntrypoint: \"Deposit\", \n\t\t\t\tScid: scid,\n\t\t\t\tValue: amount,\n\t\t\t}, \n\t\t},\n\t}\n\n\t\n\tpayloadBytes, err := json.Marshal(data)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tbody := bytes.NewReader(payloadBytes)\n\t\n\t_, err=rpcPost(body, walletURL)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\t\n\t//println(result)\t\n\tfmt.Println(\"Deposit sent to wallet!\")\n\t\n}", "func (deposit *Deposit) ValidateDeposit() (map[string]interface{}, bool) {\n\n\tif deposit.Amount <= 0 {\n\t\treturn u.Message(false, \"Amount is required\"), false\n\t}\n\n\tif deposit.FormaPago == \"\" {\n\t\treturn u.Message(false, \"FormaPago is required\"), false\n\t}\n\n\t//check client in DB\n\t_, err := ExistClientIdentificationDB(deposit.Clientidentificationcard)\n\tif err == gorm.ErrRecordNotFound {\n\t\treturn u.Message(false, \"Client exist no in DB\"), false\n\t}\n\n\treturn u.Message(false, \"Requirement passed\"), true\n}", "func (_TTFT20 *TTFT20Caller) IsWithdrawalAddress(opts *bind.CallOpts, _addr common.Address) (bool, error) {\n\tvar (\n\t\tret0 = new(bool)\n\t)\n\tout := ret0\n\terr := _TTFT20.contract.Call(opts, out, \"isWithdrawalAddress\", _addr)\n\treturn *ret0, err\n}", "func (as *ApiService) CreateDepositAddress(currency string) (*ApiResponse, error) {\n\treq := NewRequest(http.MethodPost, \"/api/v1/deposit-addresses\", map[string]string{\"currency\": currency})\n\treturn as.Call(req)\n}", "func (_TokenStakingEscrow *TokenStakingEscrowCaller) HasDeposit(opts *bind.CallOpts, operator common.Address) (bool, error) {\n\tvar (\n\t\tret0 = new(bool)\n\t)\n\tout := ret0\n\terr := _TokenStakingEscrow.contract.Call(opts, out, \"hasDeposit\", operator)\n\treturn *ret0, err\n}", "func (q queryServer) Deposit(ctx context.Context, req *v1.QueryDepositRequest) (*v1.QueryDepositResponse, error) {\n\tif req == nil {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"invalid request\")\n\t}\n\n\tif req.ProposalId == 0 {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"proposal id can not be 0\")\n\t}\n\n\tif req.Depositor == \"\" {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"empty depositor address\")\n\t}\n\n\tdepositor, err := q.k.authKeeper.AddressCodec().StringToBytes(req.Depositor)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdeposit, err := q.k.Deposits.Get(ctx, collections.Join(req.ProposalId, sdk.AccAddress(depositor)))\n\tif err != nil {\n\t\treturn nil, status.Error(codes.NotFound, err.Error())\n\t}\n\n\treturn &v1.QueryDepositResponse{Deposit: &deposit}, nil\n}", "func (_Depositmanager *DepositmanagerTransactor) Deposit(opts *bind.TransactOpts, _amount *big.Int, _tokenType *big.Int, _pubkey []byte) (*types.Transaction, error) {\n\treturn _Depositmanager.contract.Transact(opts, \"deposit\", _amount, _tokenType, _pubkey)\n}", "func (_SingleAuto *SingleAutoTransactor) Deposit(opts *bind.TransactOpts, _pid *big.Int, _wantAmt *big.Int) (*types.Transaction, error) {\n\treturn _SingleAuto.contract.Transact(opts, \"deposit\", _pid, _wantAmt)\n}", "func (sc stakingClient) Deposit(fromInfo keys.Info, passWd, coinsStr, memo string, accNum, seqNum uint64) (\n\tresp sdk.TxResponse, err error) {\n\tif err = params.CheckKeyParams(fromInfo, passWd); err != nil {\n\t\treturn\n\t}\n\n\tcoin, err := sdk.ParseDecCoin(coinsStr)\n\tif err != nil {\n\t\treturn resp, fmt.Errorf(\"failed : parse Coins [%s] error: %s\", coinsStr, err)\n\t}\n\n\tmsg := types.NewMsgDeposit(fromInfo.GetAddress(), coin)\n\n\treturn sc.BuildAndBroadcast(fromInfo.GetName(), passWd, memo, []sdk.Msg{msg}, accNum, seqNum)\n}", "func TestGetBTCDeposAddress(t *testing.T) {\n\n\ta := InitApp(\"https://mbank.dl-dev.ru/api/\")\n\n\taddr, err := a.GetBTCDeposAddress(MinterAddress, \"BIP\", \"xxx@yyy.ru\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif addr == \"\" {\n\t\tt.Errorf(\"Empty address %s\", addr)\n\t}\n\n}", "func (mapper GovMapper) AddDeposit(ctx context.Context, proposalID uint64, depositorAddr btypes.Address, depositAmount uint64) (btypes.Error, bool) {\n\tproposal, ok := mapper.GetProposal(proposalID)\n\tif !ok {\n\t\treturn ErrUnknownProposal(proposalID), false\n\t}\n\n\taccountMapper := ctx.Mapper(account.AccountMapperName).(*account.AccountMapper)\n\taccount := accountMapper.GetAccount(depositorAddr).(*types.QOSAccount)\n\taccount.MustMinusQOS(btypes.NewInt(int64(depositAmount)))\n\taccountMapper.SetAccount(account)\n\n\t// Update proposal\n\tproposal.TotalDeposit = proposal.TotalDeposit + depositAmount\n\tmapper.SetProposal(proposal)\n\n\t// Check if deposit has provided sufficient total funds to transition the proposal into the voting period\n\tactivatedVotingPeriod := false\n\tif proposal.Status == gtypes.StatusDepositPeriod && proposal.TotalDeposit >= mapper.GetParams(ctx).MinDeposit {\n\t\tmapper.activateVotingPeriod(ctx, proposal)\n\t\tactivatedVotingPeriod = true\n\t}\n\n\t// Add or update deposit object\n\tcurrDeposit, found := mapper.GetDeposit(proposalID, depositorAddr)\n\tif !found {\n\t\tnewDeposit := gtypes.Deposit{depositorAddr, proposalID, depositAmount}\n\t\tmapper.setDeposit(proposalID, depositorAddr, newDeposit)\n\t} else {\n\t\tcurrDeposit.Amount = currDeposit.Amount + depositAmount\n\t\tmapper.setDeposit(proposalID, depositorAddr, currDeposit)\n\t}\n\n\treturn nil, activatedVotingPeriod\n}", "func (_Vault *VaultTransactor) Deposit(opts *bind.TransactOpts, incognitoAddress string) (*types.Transaction, error) {\n\treturn _Vault.contract.Transact(opts, \"deposit\", incognitoAddress)\n}", "func (_Depositmanager *DepositmanagerTransactor) DepositFor(opts *bind.TransactOpts, _destination common.Address, _amount *big.Int, _tokenType *big.Int, _pubkey []byte) (*types.Transaction, error) {\n\treturn _Depositmanager.contract.Transact(opts, \"depositFor\", _destination, _amount, _tokenType, _pubkey)\n}", "func (dcr *DCRBackend) CheckAddress(addr string) bool {\n\t_, err := dcrutil.DecodeAddress(addr, chainParams)\n\treturn err == nil\n}", "func (h *Handle) Deposit() {\n\tvar result types.HexNumber\n\tvalue, _ := new(big.Int).SetString(\"20123456789000000000000000000\", 0)\n\taccount := types.Str2Address(\"0x1b978a1d302335a6f2ebe4b8823b5e17c3c84135\")\n\terr := tokenA.Deposit.SendTransaction(&result, account, value)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tlog.Println(result)\n}", "func (as *ApiService) DepositAddresses(currency string) (*ApiResponse, error) {\n\treq := NewRequest(http.MethodGet, \"/api/v1/deposit-addresses\", map[string]string{\"currency\": currency})\n\treturn as.Call(req)\n}", "func (_SingleAuto *SingleAutoTransactorSession) Deposit(_pid *big.Int, _wantAmt *big.Int) (*types.Transaction, error) {\n\treturn _SingleAuto.Contract.Deposit(&_SingleAuto.TransactOpts, _pid, _wantAmt)\n}", "func (a *Client) UserGetDepositAddress(params *UserGetDepositAddressParams) (*UserGetDepositAddressOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewUserGetDepositAddressParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"User.getDepositAddress\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/user/depositAddress\",\n\t\tProducesMediaTypes: []string{\"application/javascript\", \"application/xml\", \"text/javascript\", \"text/xml\"},\n\t\tConsumesMediaTypes: []string{\"application/x-www-form-urlencoded\"},\n\t\tSchemes: []string{\"http\"},\n\t\tParams: params,\n\t\tReader: &UserGetDepositAddressReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*UserGetDepositAddressOK), nil\n\n}", "func (w *Wallet) FindAddress(adrstr ...string) bool {\n\tfor _, adr := range adrstr {\n\t\t_, pub := w.AddressPublic[adr]\n\t\t_, priv := w.AddressChange[adr]\n\t\tif pub || priv {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (c *ClientWithResponses) GetDepositAddressWithResponse(ctx context.Context, currency CurrencyParam, reqEditors ...RequestEditorFn) (*GetDepositAddressResponse, error) {\n\trsp, err := c.GetDepositAddress(ctx, currency, reqEditors...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ParseGetDepositAddressResponse(rsp)\n}", "func Deposit(accID string, amount int64) error {\n\tif amount <= 0 {\n\t\treturn fmt.Errorf(\"invalid amount; %d\", amount)\n\t}\n\n\tvar accs []*share.Account\n\terr := client.GetByNames(ctx, share.KindAccount, []string{accID, \"Cash\"}, &accs)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get accounts error; %v\", err)\n\t}\n\taccs[0].Balance += amount\n\taccs[1].Balance -= amount\n\ttrans := []*share.Transaction{\n\t\t{Type: share.TransactionTypeDeposit, AccountID: accID, Amount: amount},\n\t\t{Type: share.TransactionTypeWithdraw, AccountID: \"Cash\", Amount: -amount},\n\t}\n\tfor _, tran := range trans {\n\t\ttran.NewKey(share.KindTransaction)\n\t}\n\terr = client.SaveModels(ctx, \"\", []interface{}{accs[0], accs[1], trans[0], trans[1]})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"save models error; %v\", err)\n\t}\n\treturn nil\n}", "func (c *Client) BalanceForAddress(address string) (int, error) {\n\turl := fmt.Sprintf(\"%s/addr/%s/balance?token=%s\", c.URL, address, c.Token)\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tresp, err := c.HC.Do(req)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tbodyBytes, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tresponseString := string(bodyBytes)\n\tduffs, err := strconv.ParseInt(responseString, 10, 64)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn int(duffs), nil\n}", "func (a *Account) Deposit(amount int64) (newBalance int64, ok bool) {\n\ta.mutex.Lock() // Aquire the lock on the shared resource the balance\n\tdefer a.mutex.Unlock() // Release lock when surrouding function has executed\n\tif !a.open || a.balance+amount < 0 {\n\t\treturn 0, false // If the bank account is not open or even with the deposit the balance is still negativr\n\t}\n\ta.balance += amount\n\treturn a.balance, true\n}", "func (broadcast *Broadcast) ValidatorDeposit(ctx context.Context, username, deposit,\n\tvalidatorPubKey, link, privKeyHex string, seq int64) (*model.BroadcastResponse, error) {\n\tvalPubKey, err := transport.GetPubKeyFromHex(validatorPubKey)\n\tif err != nil {\n\t\treturn nil, errors.FailedToGetPubKeyFromHexf(\"ValidatorDeposit: failed to get Val pub key\").AddCause(err)\n\t}\n\tmsg := model.ValidatorDepositMsg{\n\t\tUsername: username,\n\t\tDeposit: deposit,\n\t\tValPubKey: valPubKey,\n\t\tLink: link,\n\t}\n\treturn broadcast.broadcastTransaction(ctx, msg, privKeyHex, seq, \"\", false)\n}", "func (w *Wallet) Deposit(amount Bitcoin) {\n\tfmt.Printf(\"address of balance in wallet is %v \\n\", &w.balance) // get the pointer\n\tw.balance += amount\n}", "func TestGetBTCDepositStatus(t *testing.T) {\n\n\ta := InitApp(\"https://mbank.dl-dev.ru/api/\")\n\n\tstat, err := a.GetBTCDepositStatus(\"tb1qtfnwald5a667730yqrvdt67aslmgn3k7qykq5a\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif stat == nil {\n\t\tt.Errorf(\"Empty stat\")\n\t}\n\n\tstat, err = a.GetBTCDepositStatus(\"saawdadadw\")\n\tif err.Error() != \"Address not found\" {\n\t\tt.Fatal(err)\n\t\tt.Errorf(\"Cannot found err\")\n\t}\n\n}", "func (_SingleAuto *SingleAutoSession) Deposit(_pid *big.Int, _wantAmt *big.Int) (*types.Transaction, error) {\n\treturn _SingleAuto.Contract.Deposit(&_SingleAuto.TransactOpts, _pid, _wantAmt)\n}", "func (vmctx *VMContext) TransferToAddress(targetAddr address.Address, transfer coretypes.ColoredBalances) bool {\n\tprivileged := vmctx.CurrentContractHname() == accounts.Interface.Hname()\n\tfmt.Printf(\"TransferToAddress: %s privileged = %v\\n\", targetAddr.String(), privileged)\n\tif !privileged {\n\t\t// if caller is accounts, it must debit from account by itself\n\t\tagentID := vmctx.MyAgentID()\n\t\tvmctx.pushCallContext(accounts.Interface.Hname(), nil, nil) // create local context for the state\n\t\tdefer vmctx.popCallContext()\n\n\t\tif !accounts.DebitFromAccount(vmctx.State(), agentID, transfer) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn vmctx.txBuilder.TransferToAddress(targetAddr, transfer) == nil\n}", "func (s *SkyСoinService) CheckBalance(addr string) (*BalanceResponse, error) {\n\taddressesToGetBalance := make([]string, 0, 1)\n\taddressesToGetBalance = append(addressesToGetBalance, addr)\n\tbalanceResult, err := s.checkBalance(s.client, addressesToGetBalance)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &BalanceResponse{\n\t\tAddress: addr,\n\t\tHours: balanceResult.Confirmed.Hours,\n\t\tBalance: balanceResult.Confirmed.Coins,\n\t}, nil\n}", "func (p *TDepositWithdrawServiceClient) AuditDepositWithdraw(ctx context.Context, traceId string, status string, mark string, withdrawId int32) (r bool, err error) {\n var _args5 TDepositWithdrawServiceAuditDepositWithdrawArgs\n _args5.TraceId = traceId\n _args5.Status = status\n _args5.Mark = mark\n _args5.WithdrawId = withdrawId\n var _result6 TDepositWithdrawServiceAuditDepositWithdrawResult\n if err = p.c.Call(ctx, \"auditDepositWithdraw\", &_args5, &_result6); err != nil {\n return\n }\n return _result6.GetSuccess(), nil\n}", "func (*DepositServer) Deposit(ctx context.Context, req *DepositRequest) (*DepositResponse, error) {\n\tif req.GetAmount() < 0 {\n\t\treturn nil, status.Errorf(codes.InvalidArgument, \"cannot deposit %v\", req.GetAmount())\n\t}\n\n\ttime.Sleep(time.Duration(req.GetAmount()) * time.Millisecond)\n\treturn &DepositResponse{Ok: true}, nil\n}", "func (acc *Account) Deposit(amount int64) (newBalance int64, ok bool) {\n\tacc.Lock()\n\tdefer acc.Unlock()\n\n\t//make sure the account is valid AND that we aren't overdrafting\n\tif acc.invalid || amount+acc.balance < 0 {\n\t\treturn\n\t}\n\n\tok = true\n\tnewBalance = amount + acc.balance\n\tacc.balance = newBalance\n\n\treturn\n}", "func checkBalance(t *testing.T, baseApp *baseapp.BaseApp, addr sdk.AccAddress, balances sdk.Coins, keeper bankkeeper.Keeper) {\n\tt.Helper()\n\tctxCheck := baseApp.NewContext(true)\n\tkeeperBalances := keeper.GetAllBalances(ctxCheck, addr)\n\trequire.True(t, balances.Equal(keeperBalances))\n}", "func (_Dospayment *DospaymentCaller) GuardianFundsAddr(opts *bind.CallOpts) (common.Address, error) {\n\tvar (\n\t\tret0 = new(common.Address)\n\t)\n\tout := ret0\n\terr := _Dospayment.contract.Call(opts, out, \"guardianFundsAddr\")\n\treturn *ret0, err\n}", "func (w *Wallet) Deposit(amount Bitcoin) {\n\t/*Deposit takes a pointer to Wallet as the input because\n\totherwise, the amount we add to balance will be to a copy of balance\n\tand not to the one that the test is checking against\n\t*/\n\t(*w).balance += amount\n\t/*using (*w) dereferences the pointer so we can read it\n\thowever it is not necessary to write it like this because golang will\n\tdo it implicitly for you\n\t*/\n\n}", "func (p *PChainHelper) CheckBalance(client *avalanchegoclient.Client, address string, amount uint64) error {\n\n\tpBalance, err := client.PChainAPI().GetBalance(address)\n\tif err != nil {\n\t\treturn stacktrace.Propagate(err, \"Failed to retrieve P Chain balance.\")\n\t}\n\tpActualBalance := uint64(pBalance.Balance)\n\tif pActualBalance != amount {\n\t\treturn stacktrace.NewError(\"Found unexpected P Chain Balance for address: %s. Expected: %v, found: %v\",\n\t\t\taddress, amount, pActualBalance)\n\t}\n\n\treturn nil\n}", "func (as *AddressService) VerifyWithdrawal(token string) error {\n\tif err := as.client.Get(buildString(\"address/withdraw/verify/\", token), nil); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func GetDepositAddress(coin string) (address string, error error) {\n\tjsonData, err := doTauRequest(1, \"GET\", \"data/getdepositaddress?coin=\"+coin, nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"TauDepositAddress-> %v\", err)\n\t}\n\tvar d struct {\n\t\tCoin string `json:\"coin\"`\n\t\tAddress string `json:\"address\"`\n\t}\n\tif err := json.Unmarshal(jsonData, &d); err != nil {\n\t\treturn \"\", fmt.Errorf(\"TauDepositAddress-> %v\", err)\n\t}\n\treturn d.Address, nil\n}", "func CheckBalance(t *testing.T, app *App, addr sdk.AccAddress, exp sdk.Coins) {\n\tctxCheck := app.BaseApp.NewContext(true, abci.Header{})\n\tres := app.AccountKeeper.GetAccount(ctxCheck, addr)\n\n\trequire.Equal(t, exp, res.GetCoins())\n}", "func (_TTFT20 *TTFT20Session) IsWithdrawalAddress(_addr common.Address) (bool, error) {\n\treturn _TTFT20.Contract.IsWithdrawalAddress(&_TTFT20.CallOpts, _addr)\n}", "func AddressExists(exec boil.Executor, addressID uint16) (bool, error) {\n\tvar exists bool\n\tsql := \"select exists(select 1 from `address` where `address_id`=? limit 1)\"\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintln(boil.DebugWriter, sql)\n\t\tfmt.Fprintln(boil.DebugWriter, addressID)\n\t}\n\n\trow := exec.QueryRow(sql, addressID)\n\n\terr := row.Scan(&exists)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"sqlboiler: unable to check if address exists\")\n\t}\n\n\treturn exists, nil\n}", "func (k *Kraken) GetDepositAddress(cryptocurrency currency.Code, _ string) (string, error) {\n\tmethods, err := k.GetDepositMethods(cryptocurrency.String())\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvar method string\n\tfor _, m := range methods {\n\t\tmethod = m.Method\n\t}\n\n\tif method == \"\" {\n\t\treturn \"\", errors.New(\"method not found\")\n\t}\n\n\treturn k.GetCryptoDepositAddress(method, cryptocurrency.String())\n}", "func (acc *Account) Deposit(amount int64) (newBalance int64, ok bool) {\n\tacc.mu.Lock()\n\tdefer acc.mu.Unlock()\n\tif acc.closed {\n\t\treturn 0, false\n\t}\n\tnewBalance = acc.balance + amount\n\tif newBalance < 0 {\n\t\treturn acc.balance, false\n\t}\n\tacc.balance = newBalance\n\treturn acc.balance, true\n}", "func (c *Client) Deposit(ctx context.Context, p *DepositRequestBody) (err error) {\n\t_, err = c.DepositEndpoint(ctx, p)\n\treturn\n}", "func (t *TauAPI) GetDepositAddress(coin string) (address string, error error) {\n\tjsonData, err := t.doTauRequest(&TauReq{\n\t\tVersion: 1,\n\t\tMethod: \"GET\",\n\t\tPath: \"data/getdepositaddress?coin=\" + coin,\n\t\tNeedsAuth: true,\n\t})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"TauDepositAddress-> %v\", err)\n\t}\n\tvar d struct {\n\t\tCoin string `json:\"coin\"`\n\t\tAddress string `json:\"address\"`\n\t}\n\tif err := json.Unmarshal(jsonData, &d); err != nil {\n\t\treturn \"\", fmt.Errorf(\"TauDepositAddress-> %v\", err)\n\t}\n\treturn d.Address, nil\n}", "func (dcr *ExchangeWallet) OwnsDepositAddress(address string) (bool, error) {\n\taddr, err := stdaddr.DecodeAddress(address, dcr.chainParams)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn dcr.wallet.AccountOwnsAddress(dcr.ctx, addr, dcr.depositAccount())\n}", "func (a *Account) Deposit(depAmt int) (int, bool) {\n\tcMutex.Lock()\n\tdefer cMutex.Unlock()\n\n\tif a.isOpen && (a.balance+depAmt >= 0) {\n\t\ta.balance += depAmt\n\t\treturn a.balance, true\n\t}\n\n\treturn a.balance, false\n}", "func (a *Account) Deposit(amount int64) (int64, bool) {\n\ta.Lock()\n\tdefer a.Unlock()\n\n\tif a.closed {\n\t\treturn 0, false\n\t}\n\n\tif a.balance+amount < 0 {\n\t\treturn 0, false\n\t}\n\n\ta.balance += amount\n\n\treturn a.balance, true\n}", "func (a *Account) Deposit(amount int64) (int64, bool) {\n\ta.mu.Lock()\n\tdefer a.mu.Unlock()\n\tif !a.open || a.balance+amount < 0 {\n\t\treturn 0, false\n\t}\n\ta.balance += amount\n\treturn a.balance, true\n}", "func (k Keeper) HasDeposit(ctx sdk.Context, id uint64) bool {\n\tstore := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DepositKey))\n\treturn store.Has(GetDepositIDBytes(id))\n}", "func (_Rootchain *RootchainTransactor) Deposit(opts *bind.TransactOpts, _depositTx []byte) (*types.Transaction, error) {\n\treturn _Rootchain.contract.Transact(opts, \"deposit\", _depositTx)\n}", "func checkDeposit(mines map[MineType] int, productType MineType, productNb int) int {\n\tvar toDeliver int\n\n\tif mines[productType] + productNb > siloSize {\n\t\ttoDeliver = siloSize - mines[productType]\n\t} else {\n\t\ttoDeliver = productNb\n\t}\n\n\tmines[productType] += toDeliver\n\n\treturn toDeliver\n}", "func deposit(res http.ResponseWriter, req *http.Request){\n\tvar result Account\n\n\tcollection := client.Database(Database).Collection(Collection)\n\tparams := url_parser(req.URL.String())\n\tfilter := bson.D{{\"identifier\", clean_string(params[\"account\"])}}\n\terr := collection.FindOne(context.TODO(), filter).Decode(&result)\n\t\n\tchange, err := strconv.ParseFloat(clean_string(params[\"deposit\"]), 64)\n\t\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tinitial, err := strconv.ParseFloat(result.Balance, 64)\n\tupdated := strconv.FormatFloat((initial + change), 'f', -1, 64)\n\tresult.Balance = updated\n\tif err != nil{\n\t\tfmt.Println(err)\n\t}\n\tentry, err := bson.Marshal(result)\n\t_ , err = collection.ReplaceOne(context.TODO(), filter, entry)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tgenerate_record(clean_string(params[\"account\"]), updated, \"+\"+clean_string(params[\"deposit\"]), \"deposit\")\n}", "func (a *Account) Deposit(amount int64) (newBalance int64, ok bool) {\n\t// default assumption is that the deposit failed or account is closed\n\tok = false\n\n\ta.mutex.Lock()\n\tdefer a.mutex.Unlock()\n\n\tif a.open {\n\t\tpossibleNewBalance := a.balance + amount\n\n\t\t// If amount is negative, action is permitted only if withdrawl\n\t\t// amount is less than original balance.\n\t\tif possibleNewBalance >= 0 {\n\t\t\tok = true\n\t\t\ta.balance = possibleNewBalance\n\t\t}\n\t}\n\n\treturn a.balance, ok\n}", "func (_PlasmaFramework *PlasmaFrameworkCallerSession) IsDeposit(blockNum *big.Int) (bool, error) {\n\treturn _PlasmaFramework.Contract.IsDeposit(&_PlasmaFramework.CallOpts, blockNum)\n}", "func (_PlasmaFramework *PlasmaFrameworkSession) IsDeposit(blockNum *big.Int) (bool, error) {\n\treturn _PlasmaFramework.Contract.IsDeposit(&_PlasmaFramework.CallOpts, blockNum)\n}", "func checkAccount(t *testing.T, tree *avl.Tree, id AccountID, expectedBalance, expectedReward, expectedStake *uint64) {\n\tvar balance, reward, stake uint64\n\tvar exist bool\n\n\tbalance, exist = ReadAccountBalance(tree, id)\n\tassert.Equal(t, expectedBalance != nil, exist, \"account ID: %x\", id)\n\treward, exist = ReadAccountReward(tree, id)\n\tassert.Equal(t, expectedReward != nil, exist, \"account ID: %x\", id)\n\tstake, exist = ReadAccountStake(tree, id)\n\tassert.Equal(t, expectedStake != nil, exist, \"account ID: %x\", id)\n\n\tif expectedBalance != nil {\n\t\tassert.Equal(t, balance, *expectedBalance, \"account ID: %x\", id)\n\t}\n\n\tif expectedReward != nil {\n\t\tassert.Equal(t, reward, *expectedReward, \"account ID: %x\", id)\n\t}\n\n\tif expectedStake != nil {\n\t\tassert.Equal(t, stake, *expectedStake, \"account ID: %x\", id)\n\t}\n}", "func Deposit(card *types.Card, amount types.Money) {\n\tif amount <= 0{\n\t\treturn\n\t}\n\t\n\tif !(*card).Active{\n\t\treturn\n\t}\n\n\tif amount > depositLimit {\n\t\treturn\n\t}\n\n\t(*card).Balance += amount\n}", "func (_Vault *VaultTransactorSession) Deposit(incognitoAddress string) (*types.Transaction, error) {\n\treturn _Vault.Contract.Deposit(&_Vault.TransactOpts, incognitoAddress)\n}", "func (_TTFT20 *TTFT20CallerSession) IsWithdrawalAddress(_addr common.Address) (bool, error) {\n\treturn _TTFT20.Contract.IsWithdrawalAddress(&_TTFT20.CallOpts, _addr)\n}", "func (_Wmatic *WmaticFilterer) FilterDeposit(opts *bind.FilterOpts, dst []common.Address) (*WmaticDepositIterator, error) {\n\n\tvar dstRule []interface{}\n\tfor _, dstItem := range dst {\n\t\tdstRule = append(dstRule, dstItem)\n\t}\n\n\tlogs, sub, err := _Wmatic.contract.FilterLogs(opts, \"Deposit\", dstRule)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &WmaticDepositIterator{contract: _Wmatic.contract, event: \"Deposit\", logs: logs, sub: sub}, nil\n}", "func (_Vault *VaultSession) Deposit(incognitoAddress string) (*types.Transaction, error) {\n\treturn _Vault.Contract.Deposit(&_Vault.TransactOpts, incognitoAddress)\n}", "func (_Cakevault *CakevaultTransactor) Deposit(opts *bind.TransactOpts, _amount *big.Int) (*types.Transaction, error) {\n\treturn _Cakevault.contract.Transact(opts, \"deposit\", _amount)\n}", "func (a *Act) Deposit(amt int64) (int64, bool) {\n\tbalance, ok := <-a.balance - amt\n\tif <-a.closed || balance < 0 {\n\t\treturn 0, false\n\t}\n\ta.balance <- balance\n\treturn <-a.balance, true\n}", "func (_WELV9 *WELV9Filterer) FilterDeposit(opts *bind.FilterOpts, dst []common.Address) (*WELV9DepositIterator, error) {\n\n\tvar dstRule []interface{}\n\tfor _, dstItem := range dst {\n\t\tdstRule = append(dstRule, dstItem)\n\t}\n\n\tlogs, sub, err := _WELV9.contract.FilterLogs(opts, \"Deposit\", dstRule)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &WELV9DepositIterator{contract: _WELV9.contract, event: \"Deposit\", logs: logs, sub: sub}, nil\n}", "func (a *Account) Deposit(amount int64) (newBalance int64, ok bool) {\n\ta.mutex.Lock()\n\tdefer a.mutex.Unlock()\n\n\t// Check if the account is closed, or if the \"deposit\" is negative and\n\t// would overdraw the account.\n\tif !a.open || (a.balance+amount) < 0 {\n\t\treturn 0, false\n\t}\n\n\ta.balance += amount\n\n\treturn a.balance, true\n}", "func (_Smartchef *SmartchefTransactor) Deposit(opts *bind.TransactOpts, _amount *big.Int) (*types.Transaction, error) {\n\treturn _Smartchef.contract.Transact(opts, \"deposit\", _amount)\n}", "func (_IWETH *IWETHTransactor) Deposit(opts *bind.TransactOpts) (*types.Transaction, error) {\r\n\treturn _IWETH.contract.Transact(opts, \"deposit\")\r\n}", "func (_Depositmanager *DepositmanagerTransactorSession) Deposit(_amount *big.Int, _tokenType *big.Int, _pubkey []byte) (*types.Transaction, error) {\n\treturn _Depositmanager.Contract.Deposit(&_Depositmanager.TransactOpts, _amount, _tokenType, _pubkey)\n}", "func isStakeAddressClean(ctx *action.Context, v *identity.Validator) (bool, error) {\n\toptions, err := ctx.GovernanceStore.GetStakingOptions()\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tzero := balance.NewAmountFromInt(0)\n\n\t// check locked amount\n\tlockedAmt, err := ctx.Delegators.GetValidatorDelegationAmount(v.Address, v.StakeAddress)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif !lockedAmt.Equals(*zero) {\n\t\treturn false, nil\n\t}\n\n\t// check pending amount\n\tpendingAmounts := ctx.Delegators.GetMaturedPendingAmount(v.StakeAddress, ctx.Header.Height, options.MaturityTime+1)\n\tif len(pendingAmounts) != 0 {\n\t\treturn false, nil\n\t}\n\n\t// check bounded amount\n\tboundCoin, err := ctx.Delegators.GetDelegatorBoundedAmount(v.StakeAddress)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif !boundCoin.Equals(*zero) {\n\t\treturn false, nil\n\t}\n\n\treturn true, nil\n}", "func (_SimpleMultiSig *SimpleMultiSigFilterer) FilterDeposit(opts *bind.FilterOpts, _from []common.Address) (*SimpleMultiSigDepositIterator, error) {\n\n\tvar _fromRule []interface{}\n\tfor _, _fromItem := range _from {\n\t\t_fromRule = append(_fromRule, _fromItem)\n\t}\n\n\tlogs, sub, err := _SimpleMultiSig.contract.FilterLogs(opts, \"Deposit\", _fromRule)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &SimpleMultiSigDepositIterator{contract: _SimpleMultiSig.contract, event: \"Deposit\", logs: logs, sub: sub}, nil\n}", "func TestGetMinterDeposAddress(t *testing.T) {\n\n\ta := InitApp(\"https://mbank.dl-dev.ru/api/\")\n\n\taddr, err := a.GetMinterDeposAddress(BitcoinAddress, \"BIP\", 0.1)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif addr == nil {\n\t\tt.Errorf(\"Empty responce\")\n\t}\n\n\tif addr.Data.Tag == \"\" || addr.Data.Address == \"\" {\n\t\tt.Errorf(\"Empty tag or address: %s and %s \", addr.Data.Tag, addr.Data.Address)\n\t}\n\n}", "func (_WELV9 *WELV9Transactor) Deposit(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _WELV9.contract.Transact(opts, \"deposit\")\n}", "func (_Depositmanager *DepositmanagerSession) Deposit(_amount *big.Int, _tokenType *big.Int, _pubkey []byte) (*types.Transaction, error) {\n\treturn _Depositmanager.Contract.Deposit(&_Depositmanager.TransactOpts, _amount, _tokenType, _pubkey)\n}", "func (_Coordinatorproxy *CoordinatorproxyCaller) DepositManager(opts *bind.CallOpts) (common.Address, error) {\n\tvar (\n\t\tret0 = new(common.Address)\n\t)\n\tout := ret0\n\terr := _Coordinatorproxy.contract.Call(opts, out, \"depositManager\")\n\treturn *ret0, err\n}", "func (c *CChainHelper) CheckBalance(client *avalanchegoclient.Client, address string, assetID string, expectedAmount uint64) error {\n\tpanic(\"TODO\")\n}", "func (ctx *DefaultContext) exist(address []byte) bool {\n\tacc := ctx.accounts[string(address)]\n\tif acc != nil {\n\t\treturn true\n\t}\n\treturn ctx.queryEngine.AccountExist(bytesToCommonAddress(address))\n}", "func Deposit(interactor account.Interactor) fiber.Handler {\n\n\treturn func(ctx *fiber.Ctx) error {\n\t\tvar userDetails = ctx.Locals(\"userDetails\").(map[string]string)\n\t\tuserId := userDetails[\"userId\"]\n\n\t\tvar p param\n\t\t_ = ctx.BodyParser(&p)\n\n\t\tbalance, err := interactor.Deposit(uuid.FromStringOrNil(userId), p.Amount)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn ctx.JSON(map[string]interface{}{\n\t\t\t\"message\": fmt.Sprintf(\"Amount successfully deposited. New balance %v\", balance),\n\t\t\t\"balance\": balance,\n\t\t\t\"userId\": userId,\n\t\t})\n\t}\n}", "func Deposit(card *types.Card, amount types.Money) {\n\tif !card.Active {\n\t\treturn\n\t}\n\n\tif amount < 0 {\n\t\treturn\n\t}\n\n\tif amount > 50_000_00 {\n\t\treturn\n\t}\n\n\tcard.Balance += amount\n\n\treturn\n}", "func (tt *UniqueSale) FindByAddress(addr string) (transfers []UniqueSale, err error) {\n\tquery := `select id,tokenid,lookup_id,operation, blocknumber,index,txhash,buyer,seller,price,hash,timestamp from unique_sale where lookup_id = $1 and tokenid=$2 and (buyer=$3 or seller=$3)`\n\tctx, cancel := context.WithTimeout(context.Background(), timeout())\n\tdefer cancel()\n\n\trows, err := db.QueryContext(ctx, query, tt.LookupID, tt.TokenID, addr)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn tt.getSales(rows)\n}", "func (_SingleAuto *SingleAutoFilterer) WatchDeposit(opts *bind.WatchOpts, sink chan<- *SingleAutoDeposit, user []common.Address, pid []*big.Int) (event.Subscription, error) {\n\n\tvar userRule []interface{}\n\tfor _, userItem := range user {\n\t\tuserRule = append(userRule, userItem)\n\t}\n\tvar pidRule []interface{}\n\tfor _, pidItem := range pid {\n\t\tpidRule = append(pidRule, pidItem)\n\t}\n\n\tlogs, sub, err := _SingleAuto.contract.WatchLogs(opts, \"Deposit\", userRule, pidRule)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn event.NewSubscription(func(quit <-chan struct{}) error {\n\t\tdefer sub.Unsubscribe()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase log := <-logs:\n\t\t\t\t// New log arrived, parse the event and forward to the user\n\t\t\t\tevent := new(SingleAutoDeposit)\n\t\t\t\tif err := _SingleAuto.contract.UnpackLog(event, \"Deposit\", log); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tevent.Raw = log\n\n\t\t\t\tselect {\n\t\t\t\tcase sink <- event:\n\t\t\t\tcase err := <-sub.Err():\n\t\t\t\t\treturn err\n\t\t\t\tcase <-quit:\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\tcase err := <-sub.Err():\n\t\t\t\treturn err\n\t\t\tcase <-quit:\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}), nil\n}", "func (_EtherDelta *EtherDeltaTransactor) Deposit(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _EtherDelta.contract.Transact(opts, \"deposit\")\n}", "func (w *Wallet) Deposit(amount Bitcoin) {\n\t// fmt.Printf(\"address of balance in Deposit is %v \\n\", &w.balance)\n\tw.balance += amount\n}", "func (s *server) Deposit(ctx context.Context, request *event.DepositParam) (*event.Response, error) {\n\treturn &event.Response{Status: int32(200), Message: string(\"Deposit\"), Data: []*event.Deposit{}}, nil\n}", "func (sc Funcs) Deposit(ctx wasmlib.ScFuncClientContext) *DepositCall {\n\treturn &DepositCall{Func: wasmlib.NewScFunc(ctx, HScName, HFuncDeposit)}\n}", "func checkContract(t *testing.T, tree *avl.Tree, id TransactionID, codeFilePath string, expectedGasBalance uint64, expectedEmptyMemPages []int, expectedNotEmptyMemPages []int) {\n\tcode, exist := ReadAccountContractCode(tree, id)\n\tassert.True(t, exist, \"contract ID: %x\", id)\n\tassert.NotEmpty(t, code, \"contract ID: %x\", id)\n\n\tgasBalance, exist := ReadAccountContractGasBalance(tree, id)\n\tassert.True(t, exist, \"contract ID: %x\", id)\n\tassert.Equal(t, expectedGasBalance, gasBalance, \"contract ID: %x\", id)\n\n\texpectedCode, err := ioutil.ReadFile(codeFilePath)\n\tassert.NoError(t, err)\n\tassert.EqualValues(t, expectedCode, code, \"contract ID: %x, filepath: %s\", id, codeFilePath)\n\n\tnumPages, exist := ReadAccountContractNumPages(tree, id)\n\tassert.True(t, exist, \"contract ID: %x\", id)\n\tassert.EqualValues(t, expectedPageNum, numPages, \"contract ID: %x\", id)\n\n\tfor _, v := range expectedEmptyMemPages {\n\t\tpage, exist := ReadAccountContractPage(tree, id, uint64(v))\n\t\tassert.False(t, exist)\n\t\tassert.Empty(t, page)\n\t}\n\n\tfor _, v := range expectedNotEmptyMemPages {\n\t\tpage, exist := ReadAccountContractPage(tree, id, uint64(v))\n\t\tassert.True(t, exist)\n\t\tassert.NotEmpty(t, page)\n\t\tassert.Len(t, page, PageSize)\n\t}\n}", "func (_TokensNetwork *TokensNetworkTransactor) Deposit(opts *bind.TransactOpts, token common.Address, participant common.Address, partner common.Address, amount *big.Int, settle_timeout uint64) (*types.Transaction, error) {\n\treturn _TokensNetwork.contract.Transact(opts, \"deposit\", token, participant, partner, amount, settle_timeout)\n}" ]
[ "0.5865928", "0.5765526", "0.5755803", "0.5730663", "0.57218504", "0.57081556", "0.57029444", "0.56777817", "0.5657796", "0.56503814", "0.55861264", "0.5580167", "0.5546772", "0.551311", "0.55073225", "0.54944414", "0.54910946", "0.54830885", "0.5471482", "0.54598916", "0.54572177", "0.54562366", "0.54514265", "0.54249805", "0.5408172", "0.53955036", "0.53890747", "0.538719", "0.5346112", "0.53286916", "0.5323975", "0.5319566", "0.53176117", "0.5313887", "0.53132087", "0.53117496", "0.53117454", "0.5311577", "0.53014535", "0.5299257", "0.52899647", "0.5277609", "0.5269228", "0.5267382", "0.5258762", "0.52497333", "0.52491933", "0.52470636", "0.5240346", "0.5240263", "0.5239636", "0.5238357", "0.52355766", "0.5219752", "0.5209091", "0.52083683", "0.5203757", "0.52027625", "0.5200503", "0.5197249", "0.5196017", "0.519593", "0.51793814", "0.5176929", "0.5172376", "0.5166111", "0.5161764", "0.5158309", "0.51582134", "0.5154724", "0.5150216", "0.51500154", "0.51488173", "0.514809", "0.51472384", "0.5142247", "0.5140507", "0.5138314", "0.5131498", "0.5128413", "0.5127532", "0.51261485", "0.51238066", "0.51198417", "0.5103781", "0.51034653", "0.51033455", "0.5091458", "0.5087914", "0.508595", "0.508513", "0.5072521", "0.5070458", "0.50701404", "0.5057685", "0.50553346", "0.50500304", "0.50486004", "0.5045503", "0.504471" ]
0.8275546
0
Deprecated: Use Price.ProtoReflect.Descriptor instead.
Устарело: используйте Price.ProtoReflect.Descriptor вместо этого.
func (*Price) Descriptor() ([]byte, []int) { return file_price_price_proto_rawDescGZIP(), []int{0} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (*Price) Descriptor() ([]byte, []int) {\n\treturn file_proto_supply_proto_rawDescGZIP(), []int{0}\n}", "func (*PriceInfo) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_retail_v2_common_proto_rawDescGZIP(), []int{6}\n}", "func (*PricingPodPriceRequest) Descriptor() ([]byte, []int) {\n\treturn file_cloudprovider_externalgrpc_protos_externalgrpc_proto_rawDescGZIP(), []int{8}\n}", "func (*PricingNodePriceRequest) Descriptor() ([]byte, []int) {\n\treturn file_cloudprovider_externalgrpc_protos_externalgrpc_proto_rawDescGZIP(), []int{6}\n}", "func (*PricingPodPriceResponse) Descriptor() ([]byte, []int) {\n\treturn file_cloudprovider_externalgrpc_protos_externalgrpc_proto_rawDescGZIP(), []int{9}\n}", "func (*ModifyPriceLevel) Descriptor() ([]byte, []int) {\n\treturn file_openfeed_proto_rawDescGZIP(), []int{19}\n}", "func (*PricingNodePriceResponse) Descriptor() ([]byte, []int) {\n\treturn file_cloudprovider_externalgrpc_protos_externalgrpc_proto_rawDescGZIP(), []int{7}\n}", "func (*Deprecation) Descriptor() ([]byte, []int) {\n\treturn file_external_cfgmgmt_response_nodes_proto_rawDescGZIP(), []int{8}\n}", "func (*OrderPricePair) Descriptor() ([]byte, []int) {\n\treturn file_witness_proto_rawDescGZIP(), []int{10}\n}", "func (*GetDownLinkPriceRequest) Descriptor() ([]byte, []int) {\n\treturn file_wallet_proto_rawDescGZIP(), []int{25}\n}", "func (*ProductPriceRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_Ultimate_Super_WebDev_Corp_gateway_services_widget_widget_proto_rawDescGZIP(), []int{1}\n}", "func (*GasPriceRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{21}\n}", "func (*Money) Descriptor() ([]byte, []int) {\n\treturn file_proto_google_fhir_proto_stu3_datatypes_proto_rawDescGZIP(), []int{32}\n}", "func (*PlanChange_Removed) Descriptor() ([]byte, []int) {\n\treturn edgelq_limits_proto_v1alpha2_plan_change_proto_rawDescGZIP(), []int{0, 3}\n}", "func (*AddPriceLevel) Descriptor() ([]byte, []int) {\n\treturn file_openfeed_proto_rawDescGZIP(), []int{17}\n}", "func (*PlanChange_Modified) Descriptor() ([]byte, []int) {\n\treturn edgelq_limits_proto_v1alpha2_plan_change_proto_rawDescGZIP(), []int{0, 1}\n}", "func (*DeletePriceLevel) Descriptor() ([]byte, []int) {\n\treturn file_openfeed_proto_rawDescGZIP(), []int{18}\n}", "func (*GetDownLinkPriceResponse) Descriptor() ([]byte, []int) {\n\treturn file_wallet_proto_rawDescGZIP(), []int{26}\n}", "func (Type) EnumDescriptor() ([]byte, []int) {\n\treturn file_price_price_proto_rawDescGZIP(), []int{0}\n}", "func (*Instance) Descriptor() ([]byte, []int) {\n\treturn file_cloudprovider_externalgrpc_protos_externalgrpc_proto_rawDescGZIP(), []int{28}\n}", "func (*KindSellTime) Descriptor() ([]byte, []int) {\n\treturn file_kindSellTimeService_proto_rawDescGZIP(), []int{0}\n}", "func (*PlanChange) Descriptor() ([]byte, []int) {\n\treturn edgelq_limits_proto_v1alpha2_plan_change_proto_rawDescGZIP(), []int{0}\n}", "func (*PriceInfo_PriceRange) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_retail_v2_common_proto_rawDescGZIP(), []int{6, 0}\n}", "func ProtoFromMethodDescriptor(d protoreflect.MethodDescriptor) *descriptorpb.MethodDescriptorProto {\n\ttype canProto interface {\n\t\tMethodDescriptorProto() *descriptorpb.MethodDescriptorProto\n\t}\n\tif res, ok := d.(canProto); ok {\n\t\treturn res.MethodDescriptorProto()\n\t}\n\tif res, ok := d.(DescriptorProtoWrapper); ok {\n\t\tif md, ok := res.AsProto().(*descriptorpb.MethodDescriptorProto); ok {\n\t\t\treturn md\n\t\t}\n\t}\n\treturn protodesc.ToMethodDescriptorProto(d)\n}", "func (*VolumeAtPrice) Descriptor() ([]byte, []int) {\n\treturn file_openfeed_proto_rawDescGZIP(), []int{54}\n}", "func (*Performance) Descriptor() ([]byte, []int) {\n\treturn file_commissionService_proto_rawDescGZIP(), []int{2}\n}", "func (*SymbolMarginRate) Descriptor() ([]byte, []int) {\n\treturn file_symbol_margin_rate_proto_rawDescGZIP(), []int{0}\n}", "func (*MetricsServiceRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{18}\n}", "func ToDescriptorProto(message protoreflect.MessageDescriptor) *descriptorpb.DescriptorProto {\n\tp := &descriptorpb.DescriptorProto{\n\t\tName: proto.String(string(message.Name())),\n\t\tOptions: proto.Clone(message.Options()).(*descriptorpb.MessageOptions),\n\t}\n\tfor i, fields := 0, message.Fields(); i < fields.Len(); i++ {\n\t\tp.Field = append(p.Field, ToFieldDescriptorProto(fields.Get(i)))\n\t}\n\tfor i, exts := 0, message.Extensions(); i < exts.Len(); i++ {\n\t\tp.Extension = append(p.Extension, ToFieldDescriptorProto(exts.Get(i)))\n\t}\n\tfor i, messages := 0, message.Messages(); i < messages.Len(); i++ {\n\t\tp.NestedType = append(p.NestedType, ToDescriptorProto(messages.Get(i)))\n\t}\n\tfor i, enums := 0, message.Enums(); i < enums.Len(); i++ {\n\t\tp.EnumType = append(p.EnumType, ToEnumDescriptorProto(enums.Get(i)))\n\t}\n\tfor i, xranges := 0, message.ExtensionRanges(); i < xranges.Len(); i++ {\n\t\txrange := xranges.Get(i)\n\t\tp.ExtensionRange = append(p.ExtensionRange, &descriptorpb.DescriptorProto_ExtensionRange{\n\t\t\tStart: proto.Int32(int32(xrange[0])),\n\t\t\tEnd: proto.Int32(int32(xrange[1])),\n\t\t\tOptions: proto.Clone(message.ExtensionRangeOptions(i)).(*descriptorpb.ExtensionRangeOptions),\n\t\t})\n\t}\n\tfor i, oneofs := 0, message.Oneofs(); i < oneofs.Len(); i++ {\n\t\tp.OneofDecl = append(p.OneofDecl, ToOneofDescriptorProto(oneofs.Get(i)))\n\t}\n\tfor i, ranges := 0, message.ReservedRanges(); i < ranges.Len(); i++ {\n\t\trrange := ranges.Get(i)\n\t\tp.ReservedRange = append(p.ReservedRange, &descriptorpb.DescriptorProto_ReservedRange{\n\t\t\tStart: proto.Int32(int32(rrange[0])),\n\t\t\tEnd: proto.Int32(int32(rrange[1])),\n\t\t})\n\t}\n\tfor i, names := 0, message.ReservedNames(); i < names.Len(); i++ {\n\t\tp.ReservedName = append(p.ReservedName, string(names.Get(i)))\n\t}\n\treturn p\n}", "func (*ProductMetadata) Descriptor() ([]byte, []int) {\n\treturn file_google_ads_googleads_v2_services_reach_plan_service_proto_rawDescGZIP(), []int{5}\n}", "func (*NetRateTalker) Descriptor() ([]byte, []int) {\n\treturn file_pkg_smgrpc_smgrpc_proto_rawDescGZIP(), []int{2}\n}", "func (*Money) Descriptor() ([]byte, []int) {\n\treturn file_protos_person_proto_rawDescGZIP(), []int{2}\n}", "func (*Decl_FunctionDecl_Overload) Descriptor() ([]byte, []int) {\n\treturn file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{2, 1, 0}\n}", "func (*PriceCalendar) Descriptor() ([]byte, []int) {\n\treturn file_fare_proto_rawDescGZIP(), []int{11}\n}", "func ProtoFromDescriptor(d protoreflect.Descriptor) proto.Message {\n\tswitch d := d.(type) {\n\tcase protoreflect.FileDescriptor:\n\t\treturn ProtoFromFileDescriptor(d)\n\tcase protoreflect.MessageDescriptor:\n\t\treturn ProtoFromMessageDescriptor(d)\n\tcase protoreflect.FieldDescriptor:\n\t\treturn ProtoFromFieldDescriptor(d)\n\tcase protoreflect.OneofDescriptor:\n\t\treturn ProtoFromOneofDescriptor(d)\n\tcase protoreflect.EnumDescriptor:\n\t\treturn ProtoFromEnumDescriptor(d)\n\tcase protoreflect.EnumValueDescriptor:\n\t\treturn ProtoFromEnumValueDescriptor(d)\n\tcase protoreflect.ServiceDescriptor:\n\t\treturn ProtoFromServiceDescriptor(d)\n\tcase protoreflect.MethodDescriptor:\n\t\treturn ProtoFromMethodDescriptor(d)\n\tdefault:\n\t\t// WTF??\n\t\tif res, ok := d.(DescriptorProtoWrapper); ok {\n\t\t\treturn res.AsProto()\n\t\t}\n\t\treturn nil\n\t}\n}", "func (*AddPeerRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{8}\n}", "func (*PlanChange_Added) Descriptor() ([]byte, []int) {\n\treturn edgelq_limits_proto_v1alpha2_plan_change_proto_rawDescGZIP(), []int{0, 0}\n}", "func (*PricingRequest) Descriptor() ([]byte, []int) {\n\treturn file_fare_proto_rawDescGZIP(), []int{9}\n}", "func (*Decimal) Descriptor() ([]byte, []int) {\n\treturn file_proto_google_fhir_proto_stu3_datatypes_proto_rawDescGZIP(), []int{5}\n}", "func (*GetVersionRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{9}\n}", "func (*MoneyRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_swap_swap_proto_rawDescGZIP(), []int{0}\n}", "func NewDescriptor(spotPriceAPI api.SpotPriceHistoryDescriber) *descriptor {\n\treturn &descriptor{\n\t\tbucket: make(spotPriceBucket),\n\t\tapi: spotPriceAPI,\n\t}\n}", "func (*GetMXCpriceRequest) Descriptor() ([]byte, []int) {\n\treturn file_wallet_proto_rawDescGZIP(), []int{27}\n}", "func (*Type) Descriptor() ([]byte, []int) {\n\treturn file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{1}\n}", "func (*Decimal) Descriptor() ([]byte, []int) {\n\treturn file_Harmony_proto_rawDescGZIP(), []int{5}\n}", "func (*ProductsListResponse_Discount) Descriptor() ([]byte, []int) {\n\treturn file_protobuf_proto_productslist_products_list_proto_rawDescGZIP(), []int{1, 0}\n}", "func (*GasPriceResponse) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{49}\n}", "func (x *fastReflection_MsgCommunityPoolSpend) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_MsgCommunityPoolSpend\n}", "func (*AddPeerResponse) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{30}\n}", "func (*Spend) Descriptor() ([]byte, []int) {\n\treturn file_recordwants_proto_rawDescGZIP(), []int{3}\n}", "func (x *fastReflection_Supply) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_Supply\n}", "func (*FeedbackMetrics) Descriptor() ([]byte, []int) {\n\treturn file_ssn_dataservice_v1_dataservice_proto_rawDescGZIP(), []int{12}\n}", "func (*TelemetryParams) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{62}\n}", "func (*CalculateDealPriceRequest) Descriptor() ([]byte, []int) {\n\treturn file_api_mindexd_pb_mindexd_proto_rawDescGZIP(), []int{13}\n}", "func (*TradeRequest_Ticker) Descriptor() ([]byte, []int) {\n\treturn file_grpcoin_proto_rawDescGZIP(), []int{8, 0}\n}", "func (*DistributionChange_Modified) Descriptor() ([]byte, []int) {\n\treturn edgelq_applications_proto_v1alpha2_distribution_change_proto_rawDescGZIP(), []int{0, 1}\n}", "func (*DistributionChange_Removed) Descriptor() ([]byte, []int) {\n\treturn edgelq_applications_proto_v1alpha2_distribution_change_proto_rawDescGZIP(), []int{0, 3}\n}", "func (*PlanChange_Current) Descriptor() ([]byte, []int) {\n\treturn edgelq_limits_proto_v1alpha2_plan_change_proto_rawDescGZIP(), []int{0, 2}\n}", "func (*OrderDetail_ShopMoney) Descriptor() ([]byte, []int) {\n\treturn file_order_proto_rawDescGZIP(), []int{1, 19}\n}", "func (*TradeData) Descriptor() ([]byte, []int) {\n\treturn file_stock_service_proto_rawDescGZIP(), []int{2}\n}", "func (*ProvisioningPolicyChange_Modified) Descriptor() ([]byte, []int) {\n\treturn edgelq_devices_proto_v1alpha_provisioning_policy_change_proto_rawDescGZIP(), []int{0, 1}\n}", "func (PriceLevel) EnumDescriptor() ([]byte, []int) {\n\treturn file_google_maps_places_v1_place_proto_rawDescGZIP(), []int{0}\n}", "func (*CancelPlanResponseProto) Descriptor() ([]byte, []int) {\n\treturn file_ClientDatanodeProtocol_proto_rawDescGZIP(), []int{23}\n}", "func (*ReachCurve) Descriptor() ([]byte, []int) {\n\treturn file_google_ads_googleads_v2_services_reach_plan_service_proto_rawDescGZIP(), []int{16}\n}", "func (*Chart) Descriptor() ([]byte, []int) {\n\treturn file_helm_api_proto_rawDescGZIP(), []int{20}\n}", "func (*Police) Descriptor() ([]byte, []int) {\n\treturn file_proto_product_product_proto_rawDescGZIP(), []int{2}\n}", "func (Order_PriceMode) EnumDescriptor() ([]byte, []int) {\n\treturn file_waves_order_proto_rawDescGZIP(), []int{1, 1}\n}", "func (*ComplexType) Descriptor() ([]byte, []int) {\n\treturn file_testing_proto_rawDescGZIP(), []int{4}\n}", "func (*GenerateProductMixIdeasRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_ads_googleads_v2_services_reach_plan_service_proto_rawDescGZIP(), []int{7}\n}", "func (*ProvisioningPolicyChange_Removed) Descriptor() ([]byte, []int) {\n\treturn edgelq_devices_proto_v1alpha_provisioning_policy_change_proto_rawDescGZIP(), []int{0, 3}\n}", "func (*CalculateDealPriceResponse) Descriptor() ([]byte, []int) {\n\treturn file_api_mindexd_pb_mindexd_proto_rawDescGZIP(), []int{14}\n}", "func (*Decl) Descriptor() ([]byte, []int) {\n\treturn file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{2}\n}", "func (*PortfolioPosition_Ticker) Descriptor() ([]byte, []int) {\n\treturn file_grpcoin_proto_rawDescGZIP(), []int{7, 0}\n}", "func (*CSOEconItemDropRateBonus) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_common_proto_rawDescGZIP(), []int{78}\n}", "func (x *fastReflection_MsgUpdateParams) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_MsgUpdateParams\n}", "func (*Trade) Descriptor() ([]byte, []int) {\n\treturn file_openfeed_proto_rawDescGZIP(), []int{25}\n}", "func (*GetMXCpriceResponse) Descriptor() ([]byte, []int) {\n\treturn file_wallet_proto_rawDescGZIP(), []int{28}\n}", "func (*Forecast) Descriptor() ([]byte, []int) {\n\treturn file_google_ads_googleads_v2_services_reach_plan_service_proto_rawDescGZIP(), []int{18}\n}", "func (*OrderDetail_PriceSet) Descriptor() ([]byte, []int) {\n\treturn file_order_proto_rawDescGZIP(), []int{1, 2}\n}", "func (*UpgradeRuntimeRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_notebooks_v1_managed_service_proto_rawDescGZIP(), []int{9}\n}", "func (*TraceProto) Descriptor() ([]byte, []int) {\n\treturn file_internal_tracing_extended_extended_trace_proto_rawDescGZIP(), []int{0}\n}", "func (*ChartInfo) Descriptor() ([]byte, []int) {\n\treturn file_helm_api_proto_rawDescGZIP(), []int{24}\n}", "func (*Listen) Descriptor() ([]byte, []int) {\n\treturn file_pkg_smgrpc_smgrpc_proto_rawDescGZIP(), []int{4}\n}", "func (*PriceCalendarRequest) Descriptor() ([]byte, []int) {\n\treturn file_fare_proto_rawDescGZIP(), []int{12}\n}", "func (*DistributionChange_Current) Descriptor() ([]byte, []int) {\n\treturn edgelq_applications_proto_v1alpha2_distribution_change_proto_rawDescGZIP(), []int{0, 2}\n}", "func (*TradeMessage) Descriptor() ([]byte, []int) {\n\treturn file_trade_proto_rawDescGZIP(), []int{0}\n}", "func (*Preferences) Descriptor() ([]byte, []int) {\n\treturn file_google_ads_googleads_v2_services_reach_plan_service_proto_rawDescGZIP(), []int{8}\n}", "func (*Amount) Descriptor() ([]byte, []int) {\n\treturn file_spacemesh_v1_types_proto_rawDescGZIP(), []int{2}\n}", "func (*VectorClock) Descriptor() ([]byte, []int) {\n\treturn file_pkg_proto_l3_proto_rawDescGZIP(), []int{3}\n}", "func (*Bonus) Descriptor() ([]byte, []int) {\n\treturn file_services_core_protobuf_servers_proto_rawDescGZIP(), []int{27}\n}", "func (*MyProto) Descriptor() ([]byte, []int) {\n\treturn file_my_proto_proto_rawDescGZIP(), []int{0}\n}", "func (*OnTargetAudienceMetrics) Descriptor() ([]byte, []int) {\n\treturn file_google_ads_googleads_v2_services_reach_plan_service_proto_rawDescGZIP(), []int{19}\n}", "func (*RecordSpend) Descriptor() ([]byte, []int) {\n\treturn file_recordwants_proto_rawDescGZIP(), []int{1}\n}", "func (*MaximizeConversions) Descriptor() ([]byte, []int) {\n\treturn file_google_ads_googleads_v14_common_bidding_proto_rawDescGZIP(), []int{6}\n}", "func (*OrderDetail_PresentmentMoney) Descriptor() ([]byte, []int) {\n\treturn file_order_proto_rawDescGZIP(), []int{1, 20}\n}", "func (*GetPeerInfoRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{6}\n}", "func (*DistributionChange) Descriptor() ([]byte, []int) {\n\treturn edgelq_applications_proto_v1alpha2_distribution_change_proto_rawDescGZIP(), []int{0}\n}", "func (*Plan) Descriptor() ([]byte, []int) {\n\treturn file_deliveryapi_pb_service_proto_rawDescGZIP(), []int{2}\n}", "func (*PrivateApiCF) Descriptor() ([]byte, []int) {\n\treturn file_pkg_kascfg_kascfg_proto_rawDescGZIP(), []int{24}\n}", "func (*PatchCollectorsRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{161}\n}" ]
[ "0.7140815", "0.69504553", "0.6876126", "0.6736322", "0.6634963", "0.6624022", "0.65697724", "0.6557077", "0.6546061", "0.6503353", "0.64754117", "0.64043206", "0.6386197", "0.63846004", "0.63826203", "0.63817465", "0.63527876", "0.63320667", "0.6331542", "0.63248783", "0.6304258", "0.6304156", "0.6303828", "0.62835616", "0.62816226", "0.6269427", "0.62608427", "0.6250564", "0.6244573", "0.62343735", "0.6232282", "0.6228927", "0.62244475", "0.6224406", "0.62176275", "0.62143713", "0.6212387", "0.6208411", "0.6195525", "0.61775476", "0.61758053", "0.6172106", "0.6168861", "0.6167394", "0.6163431", "0.6151116", "0.6149939", "0.6147416", "0.6146915", "0.614618", "0.61378527", "0.6134164", "0.6132807", "0.6130586", "0.61224866", "0.61141515", "0.6112712", "0.610901", "0.61066496", "0.6104543", "0.60988295", "0.60960394", "0.6087704", "0.6080907", "0.60806036", "0.6074359", "0.6071701", "0.60692173", "0.60689217", "0.6057819", "0.60505855", "0.6049551", "0.6047693", "0.6046525", "0.6041951", "0.60374904", "0.60336655", "0.6032579", "0.60289", "0.6027157", "0.6026564", "0.6025027", "0.60131705", "0.60121727", "0.6003951", "0.6003855", "0.60036397", "0.6002519", "0.6002074", "0.5999375", "0.59986246", "0.59945637", "0.5990965", "0.5988475", "0.5985194", "0.5984823", "0.5984606", "0.5983416", "0.5983321", "0.59830385" ]
0.723794
0
Len returns the total number of entries in the map.
Len возвращает общее количество записей в карте.
func (m Map) Len() int { return m.n }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Len(m Map) int {\n\treturn m.count()\n}", "func (m Map) Len() (n int) {\n\treturn len(m)\n}", "func (m *Map) Len() int {\n\tm.store.RLock()\n\tdefer m.store.RUnlock()\n\tn := len(m.store.kv)\n\treturn n\n}", "func (t *Map) Len() int {\n\treturn t.keys.Len()\n}", "func (tt Map) Len() int {\n\treturn len(tt)\n}", "func (hm *HashMap) Len() int {\n\treturn hm.np.elemNum()\n}", "func (self *Map) Len() int {\n\treturn len(self.MapNative())\n}", "func (m *Map) Len() int {\n\treturn int(m.len)\n}", "func (hm HashMap) Len(ctx context.Context) (int64, error) {\n\treq := newRequest(\"*2\\r\\n$4\\r\\nHLEN\\r\\n$\")\n\treq.addString(hm.name)\n\treturn hm.c.cmdInt(ctx, req)\n}", "func (fi *FastIntegerHashMap) Len() uint64 {\n\treturn fi.count\n}", "func (s *Int64Map) Len() int {\n\treturn int(atomic.LoadInt64(&s.length))\n}", "func (m *HashMap) Len() int {\n\tm.lock.RLock()\n\tdefer m.lock.RUnlock()\n\treturn len(m.data)\n}", "func (m *Map[K, V]) Len() int {\n\tm.mu.RLock()\n\tdefer m.mu.RUnlock()\n\n\treturn len(m.inner)\n}", "func (tt PMap) Len() int {\n\treturn len(tt)\n}", "func (m Map) Length() int {\n\treturn len(m)\n}", "func (hm HashMap) Len() uint32 {\n\treturn hm.len\n}", "func (sm *ScanMap) Length() int {\n\treturn len(sm.hashMap)\n}", "func (m *Map) Len() int {\n\tm.RLock()\n\tl := len(m.Items)\n\tm.RUnlock()\n\treturn l\n}", "func (m *OrderedIntMap) Len() int { return len(m.m) }", "func (this *LruMap) Len() (size int) {\n\treturn this.m.Len()\n}", "func (p *SliceOfMap) Len() int {\n\tif p == nil {\n\t\treturn 0\n\t}\n\treturn len(*p)\n}", "func (m *OrderedMap) Len() int { return len(m.m) }", "func (j *JPNSoftwareMap) Len() int { return len(*j) }", "func (p IslandTrustMap) Len() int { return len(p) }", "func (m *systrayMap) Len() int {\n\tm.lock.RLock()\n\tl := len(m.m)\n\tm.lock.RUnlock()\n\treturn l\n}", "func (m *Mapping) Len() int { return len(m.Pairs) }", "func (m *OrderedMap) Len() int {\n\treturn len(m.keypairs)\n}", "func (p OrderedMap) Len() int {\n\treturn len(p.keys)\n}", "func (c *Cache) Len() int {\n\treturn len(c.keyMap)\n}", "func (m *OrderedUintMap) Len() int { return len(m.m) }", "func (s *mapSorter) Len() int {\n\treturn len(s.keys)\n}", "func (m *OrderedMap[K, V]) Len() int {\n\tif m == nil {\n\t\treturn 0\n\t}\n\treturn m.len\n}", "func (c *OrderedMap) Len() int {\n\treturn len(c.Keys)\n}", "func (m OrderedMap[K, V]) Len() int {\n\treturn len(m.items)\n}", "func (m *dirtySeriesMap) Len() int {\n\treturn len(m.lookup)\n}", "func (accounts *Accounts) Len() int {\n\tif (accounts == nil) || (accounts.Map == nil) {\n\t\treturn 0\n\t}\n\treturn len(accounts.Map)\n}", "func (cm *CMap) Size() int {\n\treturn len(cm.Entries)\n}", "func (m *MapStringUint64) Len() int {\n\tm.mu.RLock()\n\tl := len(m.m)\n\tm.mu.RUnlock()\n\treturn l\n}", "func (m *privateSetMap) Len() int {\n\treturn int(m.len)\n}", "func (m *TMap) Length() int {\n\treturn m.root.Length()\n}", "func (i IntHashMap[T, V]) Len() int {\n\t// DEBUG:\n\tif len(i.hashToKey) != len(i.hashToVal) {\n\t\tpanic(\"hashToKey and hashToVal have different lengths\")\n\t}\n\treturn len(i.hashToKey)\n}", "func (rm *ResultMap) Len() int {\n\tl := 0\n\trm.sm.Range(func(_, _ interface{}) bool {\n\t\tl++\n\t\treturn true\n\t})\n\treturn l\n}", "func (i StringHashMap[T, V]) Len() int {\n\t// DEBUG:\n\tif len(i.hashToKey) != len(i.hashToVal) {\n\t\tpanic(\"hashToKey and hashToVal have different lengths\")\n\t}\n\treturn len(i.hashToKey)\n}", "func (s *sortMap) Len() int {\n\treturn reflect.ValueOf(s.data).Len()\n}", "func (m *OrderedMap[K,V]) Len() int {\n\treturn len(m.mp)\n}", "func (that *StrAnyMap) Size() int {\n\tthat.mu.RLock()\n\tlength := len(that.data)\n\tthat.mu.RUnlock()\n\treturn length\n}", "func (ts tagMap) Len() int {\n\treturn len(ts)\n}", "func (m *MultiMap) Size() int {\n\tsize := 0\n\tfor _, value := range m.m {\n\t\tsize += len(value)\n\t}\n\treturn size\n}", "func (sm StringMap) Len() int {\n\treturn len(*sm.orig)\n}", "func (sm StringMap) Len() int {\n\treturn len(*sm.orig)\n}", "func (m *mapReact) Length() int {\n\tvar l int\n\tm.ro.RLock()\n\tl = len(m.ma)\n\tm.ro.RUnlock()\n\treturn l\n}", "func (rm *FilteredResultMap) Len() int {\n\tl := 0\n\trm.sm.Range(func(_, _ interface{}) bool {\n\t\tl++\n\t\treturn true\n\t})\n\treturn l\n}", "func (lru *KeyLRU) Len() int {\n\treturn len(lru.m)\n}", "func (sc *Scavenger) Len() int {\n\tsc.mu.Lock()\n\tn := len(sc.entries)\n\tsc.mu.Unlock()\n\treturn n\n}", "func (c *StringValueMap) Len() int {\n\treturn len(c.value)\n}", "func (mm Uint64Uint64Map) Size() int {\n\treturn len(mm)\n}", "func (c *Cache) Len() int {\n\tn := 0\n\tfor _, shard := range c.shards {\n\t\tn += shard.Len()\n\t}\n\treturn n\n}", "func (sm safeMap) Len() int {\n\treply := make(chan interface{})\n\tsm <- commandData{action: COUNT, result: reply}\n\treturn (<-reply).(int)\n}", "func (am *ClientSetAtomicMap) Len() int {\n\treturn len(am.val.Load().(_ClientSetMap))\n}", "func (am AttributeMap) Len() int {\n\treturn len(*am.orig)\n}", "func (am AttributeMap) Len() int {\n\treturn len(*am.orig)\n}", "func (w *WindowedMap) Len() int {\n\treturn len(w.uidList)\n}", "func (tt *TtTable) Len() uint64 {\n\treturn tt.numberOfEntries\n}", "func (h *Hash) Len() int {\n\tsum := 0\n\tfor _, bucket := range h.buckets {\n\t\tsum += len(bucket)\n\t}\n\treturn sum\n}", "func (shortlist *Shortlist) Len() int {\n\tlength := 0\n\tfor _, entry := range shortlist.Entries {\n\t\tif entry != nil {\n\t\t\tlength++\n\t\t}\n\t}\n\treturn length\n}", "func (m Map) Count() int {\n\treturn m.Imm.Len()\n}", "func (m *Mapper) Len() int {\n\treturn len(m.content)\n}", "func (s *shard) len() uint64 {\n\ts.rwMutex.RLock()\n\tlength := uint64(len(s.entryIndexes))\n\ts.rwMutex.RUnlock()\n\n\treturn length\n}", "func (c *Cache) Len() int {\n\treturn len(c.entries)\n}", "func (a ByKey) Len() int {\n\treturn len(a)\n}", "func (hm HashMap) Size() int {\n\treturn hm.size\n}", "func (wm *W3CMap) Length() int {\n\tif wm == nil {\n\t\treturn 0\n\t}\n\treturn len(wm.forNode.HTMLNode().Attr)\n}", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (m Map) Size() int {\n\treturn m.set.Size()\n}", "func (l *LRU) Len() int {\n\tl.lazyInit()\n\tvar len int\n\tfor i := 0; i < l.nshards; i++ {\n\t\tlen += l.shards[i].Len()\n\t}\n\treturn len\n}", "func (m *OMap) Count() int {\n\treturn len(m.keys)\n}", "func (c *Cache) Len() int {\n\tvar len int\n\tfor _, shard := range c.shards {\n\t\tlen += shard.policy.Len()\n\t}\n\n\treturn len\n}", "func (c *NoReplKeyCache) Len() int {\n\tc.lock.RLock()\n\tlength := len(c.cache)\n\tc.lock.RUnlock()\n\treturn length\n}", "func (h hashTables) Len() int { return len(h) }", "func (s *Set) Len() int {\n\treturn s.backingMap.Len()\n}" ]
[ "0.8701872", "0.8485359", "0.8478857", "0.8464097", "0.8455641", "0.8452391", "0.84095365", "0.83661574", "0.83578175", "0.8343607", "0.83260924", "0.83082867", "0.8297326", "0.8243439", "0.8224796", "0.8206305", "0.81053", "0.8102362", "0.807258", "0.80620295", "0.8028638", "0.8021705", "0.80125314", "0.79875773", "0.7982418", "0.7981766", "0.7962034", "0.79533124", "0.7936057", "0.7921086", "0.7920095", "0.78814787", "0.78423995", "0.7835997", "0.78272027", "0.7819052", "0.7802523", "0.7802253", "0.77966744", "0.77901405", "0.77715945", "0.7764561", "0.7761482", "0.7752915", "0.7731472", "0.7720569", "0.77079505", "0.76862127", "0.76320946", "0.76320946", "0.7578892", "0.7570916", "0.75420505", "0.7533134", "0.7509898", "0.7463084", "0.74368817", "0.74129206", "0.74042684", "0.7401709", "0.7401709", "0.73957014", "0.73616827", "0.7350345", "0.7343555", "0.7342259", "0.73309845", "0.73261464", "0.7325397", "0.73191303", "0.7300376", "0.7295106", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7286039", "0.7285952", "0.7277565", "0.7268717", "0.7263373", "0.7255748", "0.7252354", "0.7237513" ]
0.8707754
0
Len returns the number of entries in the directory.
Len возвращает количество записей в каталоге.
func (d Dir) Len() int { return len(d.contents) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d DirEntries) Len() int { return len(d) }", "func (d DirInfos) Len() int {\n\treturn len(d)\n}", "func Size() int {\n\treturn len(directory)\n}", "func (d Directory) Size() int { return binary.Size(d) }", "func (s AllDirectoryData) Len() int {\n\treturn len(s.Data)\n}", "func (e DirectoryEntry) Size() int { return binary.Size(e) }", "func (l Logfiles) Len() int { return len(l) }", "func (p path) Len() int {\n\treturn len(p)\n}", "func (f FileInfos) Len() int {\n\treturn len(f)\n}", "func (paths Paths) Len() int {\n\treturn len(paths)\n}", "func (sc *Scavenger) Len() int {\n\tsc.mu.Lock()\n\tn := len(sc.entries)\n\tsc.mu.Unlock()\n\treturn n\n}", "func (p Path) Len() int {\n\treturn len(p)\n}", "func (p Path) Len() int {\n\treturn len(p)\n}", "func (r *Root) Len() uint64 {\n\treturn r.count\n}", "func (d *Dirent) Size() int {\n\treturn direntSize + len(d.Name) + 8\n}", "func (t *Tree) Len() int { return t.Count }", "func (l *DList) Len() int { return l.n }", "func (sp crSortedPaths) Len() int {\n\treturn len(sp)\n}", "func (s *Store) Len(ctx context.Context) (int64, error) {\n\tvar nb int64\n\tif err := s.List(ctx, \"\", func(string) error {\n\t\tnb++\n\t\treturn nil\n\t}); err != nil {\n\t\treturn 0, err\n\t}\n\treturn nb, nil\n}", "func (files FilesByDate) Len() int {\n\treturn len(files)\n}", "func (t *Tree) Len() int {\n\treturn t.Count\n}", "func (h Handle) Len() int {\n\tl := 8 + 8 + 4 + len(h.Type) + len(h.Name)\n\tif h.MD != nil {\n\t\tswitch h.MD.(type) {\n\t\tcase *AlpcPortInfo:\n\t\t\tl += 16\n\t\tcase *MutantInfo:\n\t\t\tl += 5\n\t\tcase *FileInfo:\n\t\t\tl++\n\t\t}\n\t}\n\treturn l\n}", "func (m orderedMounts) Len() int {\n\treturn len(m)\n}", "func (s *FileSet) Len() int {\n\treturn len(s.files)\n}", "func (shortlist *Shortlist) Len() int {\n\tlength := 0\n\tfor _, entry := range shortlist.Entries {\n\t\tif entry != nil {\n\t\t\tlength++\n\t\t}\n\t}\n\treturn length\n}", "func (n Name) Len() int {\n\tvar length int\n\tfor _, l := range n {\n\t\tlength += l.Len()\n\t}\n\treturn length\n}", "func (e *BackupEnv) GetDirSize(source string) (int64) {\n directory, _ := os.Open(source);\n var sum int64 = 0;\n defer directory.Close();\n\n objects, _ := directory.Readdir(-1)\n for _, obj := range objects {\n if obj.IsDir() {\n sum += e.GetDirSize(source + \"/\" + obj.Name());\n } else {\n stat, _ := os.Stat(source + \"/\" + obj.Name());\n sum += stat.Size();\n }\n }\n\n return sum;\n}", "func (l LDAPDN) size() int {\n\treturn LDAPString(l).size()\n}", "func (lm *LevelMetadata) Len() int {\n\treturn lm.tree.Count()\n}", "func (list *ConcurrentFileMetaDataList) Length() int {\n\treturn len(list.files)\n}", "func (j *_Journal) Length() int {\n\treturn len(j.entries)\n}", "func (s *runLogEntrySorter) Len() int {\n\treturn len(s.entries)\n}", "func (f *AnonymousFile) Len() int {\n\treturn len(f.contents)\n}", "func (d *digest) Len() int64 {\n\treturn int64(d.len)\n}", "func (c *Cache) Len() int {\n\treturn len(c.entries)\n}", "func (bl NamedRepositoryList) Len() int { return len(bl) }", "func (fs *FileSystem) Len(queryCustom ...string) (l int, err error) {\n\t// prepare statement\n\tquery := \"SELECT COUNT(name) FROM FS\"\n\tif len(queryCustom) > 0 {\n\t\tquery = queryCustom[0]\n\t}\n\tstmt, err := fs.db.Prepare(query)\n\tif err != nil {\n\t\terr = errors.Wrap(err, \"preparing query: \"+query)\n\t\treturn\n\t}\n\n\tdefer stmt.Close()\n\trows, err := stmt.Query()\n\tif err != nil {\n\t\terr = errors.Wrap(err, query)\n\t\treturn\n\t}\n\n\t// loop through rows\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\terr = rows.Scan(&l)\n\t\tif err != nil {\n\t\t\terr = errors.Wrap(err, \"getRows\")\n\t\t\treturn\n\t\t}\n\t}\n\terr = rows.Err()\n\tif err != nil {\n\t\terr = errors.Wrap(err, \"getRows\")\n\t}\n\treturn\n}", "func (s papertrailsByName) Len() int { return len(s) }", "func (i *Item) Size() int64 { return int64(i.directoryEntry.FileSize) }", "func (a *BooleanArchive) Len() int {\n\treturn a.size\n}", "func (lc *LruCache) Len() uint {\n\treturn lc.LruStore.Len()\n}", "func (storage *Storage) Len() (n int) {\n\tstorage.mutex.Lock()\n\tn = storage.lruList.Len()\n\tstorage.mutex.Unlock()\n\treturn\n}", "func (g *gnmiPath) Len() int {\n\tif g.isStringSlicePath() {\n\t\treturn len(g.stringSlicePath)\n\t}\n\treturn len(g.pathElemPath)\n}", "func Size(targetDir string) (int64, error) {\n\tfm, err := Walk(targetDir)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tvar size int64\n\tfor _, v := range fm {\n\t\tsize += v.Size()\n\t}\n\treturn size, nil\n}", "func DirCount(dir string) int {\n\tif !DirExists(dir) {\n\t\treturn 0\n\t}\n\tentries, err := os.ReadDir(dir)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn len(entries)\n}", "func (p *PakRun) Len() int\t\t{ return len(p.Files) }", "func (fs *FileSet) Length() int {\n\tsum := 0\n\tfor _, c := range fs.fileChannels {\n\t\tsum += len(c)\n\t}\n\treturn sum\n}", "func (ne nodeEntries) Len() int { return len(ne) }", "func (ac *AuthContext) Len() int {\n\tl := 1\n\tif ac.Parent != nil {\n\t\tl += ac.Parent.Len()\n\t}\n\treturn l\n}", "func (this byDmnInfo) Len() int {\n\treturn len(this)\n}", "func (path *Path) Length() int {\n\treturn path.length\n}", "func (fs Fruits) Len() int { return len(fs) }", "func (l *SList) Len() int { return l.n }", "func (l *Log) Len() int64 {\n\treturn l.count\n}", "func (r RelativeLDAPDN) size() int {\n\treturn LDAPString(r).size()\n}", "func (args *Args) len() int {\n\treturn len(args.items)\n}", "func (u URI) size() int {\n\treturn LDAPString(u).size()\n}", "func (r *aggloSorter) Len() int {\n\treturn len(r.perm)\n}", "func (t *Trie) Len() uint32 {\n\tif t.root == nil {\n\t\treturn 0\n\t}\n\treturn t.root.count\n}", "func (counter *Counter) Len() int {\n\tcounter.mutex.Lock()\n\tdefer counter.mutex.Unlock()\n\treturn len(counter.entries)\n}", "func (t AlterReplicaLogDir34) Size(version int16) int32 {\n\tvar sz int32\n\tsz += sizeof.String(t.Path) // Path\n\tsz += sizeof.ArrayLength // Topics\n\tfor i := len(t.Topics) - 1; i >= 0; i-- {\n\t\tsz += t.Topics[i].Size(version)\n\t}\n\treturn sz\n}", "func (fib *Fib) Len() int {\n\treturn fib.tree.CountEntries()\n}", "func (s *Store) Len() int {\n\tcnt := 0\n\tdl := len(s.delim)\n\tfor i := range s.lines {\n\t\tcnt += s.lines[i].Len() + dl\n\t}\n\treturn cnt\n}", "func (s fqnSorter) Len() int {\n\treturn len(s)\n}", "func (l *List) Len() int {\n return l.size\n}", "func (c *Cache) Len() int {\n\tif c == nil {\n\t\treturn 0\n\t}\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\treturn c.lru.Len() + c.mfa.Len()\n}", "func (c *LRU) Len() int {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\treturn c.ll.Len()\n}", "func (l List) Length() (length uint) {\n\tcurrent := l.Root\n\n\tfor current != nil {\n\t\tlength++\n\t\tcurrent = current.Next\n\t}\n\treturn\n}", "func (r *Reader) Len() int {\n\tif r.file_v0 != nil {\n\t\treturn r.file_v0.Len()\n\t}\n\treturn int(r.header.num)\n}", "func (lr *logRecorder) Len() int {\n\tlr.mutex.Lock()\n\tdefer lr.mutex.Unlock()\n\n\treturn len(lr.entries)\n}", "func (c *DirentCache) Size() uint64 {\n\tif c == nil {\n\t\treturn 0\n\t}\n\tc.mu.Lock()\n\tsize := c.currentSize\n\tc.mu.Unlock()\n\treturn size\n}", "func (lru *KeyLRU) Len() int {\n\treturn len(lru.m)\n}", "func (lru *LRU) Len() int {\n\treturn lru.list.Len()\n}", "func (idx *Tree) Len() (count int) {\n\tidx.Stop()\n\tcount = int(idx.liveObjects)\n\tfor _, a := range idx.allocators {\n\t\tcount += int(a.itemCounter)\n\t}\n\tidx.Start()\n\treturn\n}", "func (f *fakeOpa) Len() int {\n\tf.mu.Lock()\n\tdefer f.mu.Unlock()\n\treturn len(f.data)\n}", "func (i *Inode) Size() int64 {\n\tif i.IsDir() {\n\t\treturn 0\n\t}\n\treturn i.dataStore.GetSize(i.path)\n}", "func (c *Cache) Len() int {\r\n\tc.Lock()\r\n\tdefer c.Unlock()\r\n\r\n\tif c.cache == nil {\r\n\t\treturn 0\r\n\t}\r\n\treturn c.ll.Len()\r\n}", "func (s *Store) Len() int {\n\ts.access.RLock()\n\tdefer s.access.RUnlock()\n\n\treturn len(s.data)\n}", "func (r *Reader) Len() (length int) {\n\t// Lazy open.\n\terr := r.open()\n\tif err != nil {\n\t\treturn\n\t}\n\tn, _ := r.len()\n\tlength = int(n)\n\treturn\n}", "func (c *Cache) Len() int {\n\treturn c.ll.Len()\n}", "func (h CRConfigHistoryThreadsafe) Len() uint64 {\n\tif h.length == nil {\n\t\treturn 0\n\t}\n\treturn *h.length\n}", "func Len(scope common.Scope, args ...interface{}) interface{} {\n\tif s, ok := args[0].(string); ok {\n\t\treturn int64(len(s))\n\t}\n\treturn 0\n}", "func (a byCount) Len() int { return len(a) }", "func (tt *TtTable) Len() uint64 {\n\treturn tt.numberOfEntries\n}", "func (c *Cache) Length(k string) int {\n\treturn len(c.entries[k])\n}", "func (f *IndexFile) Size() int64 { return int64(len(f.data)) }", "func (radius *RADIUS) Len() (int, error) {\n\tn := radiusMinimumRecordSizeInBytes\n\tfor _, v := range radius.Attributes {\n\t\talen, err := attributeValueLength(v.Value)\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\tn += int(alen) + 2 // Added Type and Length\n\t}\n\treturn n, nil\n}", "func (ds *KVStorage) Len() int {\n\treturn len(ds.data)\n}", "func (ms *MultiSorter) Len() int {\n\treturn len(ms.films)\n}", "func (b *BTree) Len() int {\n\tb.mtx.Lock()\n\tdefer b.mtx.Unlock()\n\n\treturn int(b.rootNod.GetLength())\n}", "func (l *List) Len() int {\n\treturn l.size\n}", "func (s *shard) len() uint64 {\n\ts.rwMutex.RLock()\n\tlength := uint64(len(s.entryIndexes))\n\ts.rwMutex.RUnlock()\n\n\treturn length\n}", "func (n Nodes) Len() int", "func (registry *Registry) Len() int {\n\tregistry.lock.RLock()\n\tdefer registry.lock.RUnlock()\n\treturn len(registry.db)\n}", "func (o openList) Len() int {\n\treturn len(o)\n}", "func (sl *List) Len() int { return sl.len }", "func (l DNA8List) Len() int { return len(l) }", "func (ms *multiSorter) Len() int {\n\treturn len(ms.usage)\n}", "func (l *List) Len() int { return l.len }", "func (s SortedNamespaces) Len() int {\n\treturn len(s)\n}" ]
[ "0.8751995", "0.7923306", "0.771949", "0.7581758", "0.74930316", "0.7462367", "0.7380523", "0.72741103", "0.7082246", "0.6989405", "0.6983188", "0.6956884", "0.6956884", "0.69349474", "0.69129854", "0.69084084", "0.6898496", "0.6883263", "0.68695086", "0.6865111", "0.68371457", "0.6818645", "0.6807195", "0.67518127", "0.6745181", "0.67440736", "0.67346895", "0.67236733", "0.67159337", "0.66855246", "0.6678051", "0.6624784", "0.6618561", "0.6616085", "0.6613301", "0.6602759", "0.6602399", "0.6600046", "0.6598689", "0.65849084", "0.65814483", "0.65454954", "0.6542566", "0.6536563", "0.65345937", "0.6525994", "0.6510184", "0.6504921", "0.65021974", "0.6501974", "0.6500714", "0.6490132", "0.64882857", "0.6486678", "0.6485773", "0.6471449", "0.6470664", "0.6461963", "0.6456951", "0.642212", "0.6421646", "0.6404419", "0.64038527", "0.6402329", "0.64001375", "0.6394848", "0.6384847", "0.6370707", "0.6369696", "0.6366728", "0.63489676", "0.6344985", "0.63437134", "0.6343403", "0.6342366", "0.63420177", "0.63375765", "0.6335488", "0.63336235", "0.63266295", "0.63182306", "0.63164556", "0.6315529", "0.6312988", "0.6312708", "0.6304693", "0.6304306", "0.6303334", "0.6302573", "0.63016945", "0.62992597", "0.6293577", "0.62873197", "0.62848926", "0.6271983", "0.6266003", "0.6261291", "0.6261163", "0.6251643", "0.62442935" ]
0.8492832
1
Set sets the directory's entry for the provided path. Set overwrites any previous file set at path.
Set устанавливает запись каталога для указанного пути. Set перезаписывает любой предыдущий файл, установленный по этому пути.
func (d *Dir) Set(path string, file reflow.File) { if d.contents == nil { d.contents = make(map[string]reflow.File) } d.contents[path] = file }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *IndexFile) SetPath(path string) { f.path = path }", "func (l *DirName) Set(dir string) error {\n\tif len(dir) > 0 && dir[0] == '~' {\n\t\treturn fmt.Errorf(\"log directory cannot start with '~': %s\", dir)\n\t}\n\tif len(dir) > 0 {\n\t\tabsDir, err := filepath.Abs(dir)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdir = absDir\n\t}\n\tl.Lock()\n\tdefer l.Unlock()\n\tl.name = dir\n\treturn nil\n}", "func (l *LogFile) Set(path string) {\n\tl.Path = filepath.Join(path, logsFile)\n}", "func (f *LogFile) SetPath(path string) { f.path = path }", "func SetPath(p string) {\n\tcurrentPath = \"\"\n\tbeginPath = p\n\tdirsAmount = 0\n}", "func SetPath(path string) {\n\tc.setPath(path)\n}", "func SetPath(p string) error {\n\tif info, err := os.Stat(p); err != nil {\n\t\treturn err\n\t} else if !info.IsDir() {\n\t\treturn fmt.Errorf(\"path for persistence is not directory\")\n\t}\n\tdataPath = p\n\treturn nil\n}", "func SetPath(newpath string) {\n\tpath = newpath\n}", "func (z *ZkPlus) Set(path string, data []byte, version int32) (*zk.Stat, error) {\n\tz.forPath(path).Log(logkey.ZkMethod, \"Set\")\n\treturn z.blockOnConn().Set(z.realPath(path), data, version)\n}", "func (m *Win32LobAppFileSystemDetection) SetPath(value *string)() {\n err := m.GetBackingStore().Set(\"path\", value)\n if err != nil {\n panic(err)\n }\n}", "func (kvs *FS) Set(key string, value []byte) error {\n\treturn lockedfile.Write(kvs.filename(key), bytes.NewReader(value), 0600)\n}", "func (c *FileConfigReader) SetPath(path string) {\n\tc.path = path\n}", "func (mzk *MockZK) Set(path string, data []byte, version int32) (*zk.Stat, error) {\n\tmzk.Args = append(mzk.Args, []interface{}{\n\t\t\"set\",\n\t\tpath,\n\t\tdata,\n\t\tversion,\n\t})\n\treturn mzk.SetFn(path, data, version)\n}", "func (_m *requestHeaderMapUpdatable) SetPath(path string) {\n\t_m.Called(path)\n}", "func (fs *FSCache) Set(key string, content []byte) error {\n\treturn ioutil.WriteFile(\n\t\tpath.Join(fs.Root, key),\n\t\tcontent,\n\t\t0600,\n\t)\n}", "func (c *Client) SetPath(path string) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tc.path = path\n}", "func SetPackagePath(l *lua.LState, dir string) error {\n\treturn SetPackagePathRaw(l, PackagePath(dir))\n}", "func (v Values) SetAtPath(path string, value interface{}) error {\n\tsegs := strings.Split(path, \".\")\n\terr := v.setAtPath(segs, value)\n\tif err != nil {\n\t\treturn errors.Errorf(\"error adding value at path %q: %s\", path, err)\n\t}\n\treturn nil\n}", "func (pm *PathMap) set(path string, value interface{}) {\n\tparts := strings.Split(path, svnSep)\n\tdir, name := parts[:len(parts)-1], parts[len(parts)-1]\n\tpm._createTree(dir).blobs[name] = value\n}", "func (r *Input) SetPath(path string) error {\n\tquery, err := fetch.Parse(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tr.Lock()\n\tr.Path = query\n\tr.Unlock()\n\treturn nil\n}", "func (j Json) Set(path string, value interface{}) (string, error) {\n\treturn sjson.Set(string(j), path, value)\n}", "func (c *Config) SetPath(path string) error {\n\tvar (\n\t\tisDir = false\n\t\trealPath = \"\"\n\t)\n\tif file := gres.Get(path); file != nil {\n\t\trealPath = path\n\t\tisDir = file.FileInfo().IsDir()\n\t} else {\n\t\t// Absolute path.\n\t\trealPath = gfile.RealPath(path)\n\t\tif realPath == \"\" {\n\t\t\t// Relative path.\n\t\t\tc.searchPaths.RLockFunc(func(array []string) {\n\t\t\t\tfor _, v := range array {\n\t\t\t\t\tif path, _ := gspath.Search(v, path); path != \"\" {\n\t\t\t\t\t\trealPath = path\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t\tif realPath != \"\" {\n\t\t\tisDir = gfile.IsDir(realPath)\n\t\t}\n\t}\n\t// Path not exist.\n\tif realPath == \"\" {\n\t\tbuffer := bytes.NewBuffer(nil)\n\t\tif c.searchPaths.Len() > 0 {\n\t\t\tbuffer.WriteString(fmt.Sprintf(\"[gcfg] SetPath failed: cannot find directory \\\"%s\\\" in following paths:\", path))\n\t\t\tc.searchPaths.RLockFunc(func(array []string) {\n\t\t\t\tfor k, v := range array {\n\t\t\t\t\tbuffer.WriteString(fmt.Sprintf(\"\\n%d. %s\", k+1, v))\n\t\t\t\t}\n\t\t\t})\n\t\t} else {\n\t\t\tbuffer.WriteString(fmt.Sprintf(`[gcfg] SetPath failed: path \"%s\" does not exist`, path))\n\t\t}\n\t\terr := gerror.New(buffer.String())\n\t\tif errorPrint() {\n\t\t\tglog.Error(err)\n\t\t}\n\t\treturn err\n\t}\n\t// Should be a directory.\n\tif !isDir {\n\t\terr := fmt.Errorf(`[gcfg] SetPath failed: path \"%s\" should be directory type`, path)\n\t\tif errorPrint() {\n\t\t\tglog.Error(err)\n\t\t}\n\t\treturn err\n\t}\n\t// Repeated path check.\n\tif c.searchPaths.Search(realPath) != -1 {\n\t\treturn nil\n\t}\n\tc.jsonMap.Clear()\n\tc.searchPaths.Clear()\n\tc.searchPaths.Append(realPath)\n\tintlog.Print(context.TODO(), \"SetPath:\", realPath)\n\treturn nil\n}", "func (j *JSONData) SetPath(v interface{}, path ...string) error {\n\tjson, err := sj.NewJson(j.data)\n\tif err != nil {\n\t\treturn err\n\t}\n\tjson.SetPath(path, v)\n\tbt, err := json.MarshalJSON()\n\tif err != nil {\n\t\treturn err\n\t}\n\tj.data = bt\n\treturn nil\n}", "func (b *Bucket) SetMetadataAtPath(pth string, md Metadata) {\n\tif b.Version == 0 {\n\t\treturn\n\t}\n\n\tx, ok := b.Metadata[pth]\n\tif ok {\n\t\tif md.Key != \"\" {\n\t\t\tx.Key = md.Key\n\t\t}\n\t\tif md.Roles != nil {\n\t\t\tx.Roles = md.Roles\n\t\t}\n\t\tif x.Info == nil {\n\t\t\tx.Info = md.Info\n\t\t} else if md.Info != nil {\n\t\t\tmergemap.Merge(x.Info, md.Info)\n\t\t}\n\t\tx.UpdatedAt = md.UpdatedAt\n\t\tb.Metadata[pth] = x\n\t} else {\n\t\tif md.Roles == nil {\n\t\t\tmd.Roles = make(map[did.DID]Role)\n\t\t}\n\t\tif md.Info == nil {\n\t\t\tmd.Info = make(map[string]interface{})\n\t\t}\n\t\tb.Metadata[pth] = md\n\t}\n}", "func (c *Cookie) SetPath(path string) {\n\tc.path = path\n}", "func (c *FileSystemCache) Set(data []byte, expire time.Duration, key ...string) error {\n\tif len(key) < 1 {\n\t\treturn fmt.Errorf(\"no key specified\")\n\t}\n\tfolder := c.keyPath(key[:len(key)-1]...)\n\t_, err := os.Stat(folder)\n\tif os.IsNotExist(err) {\n\t\tos.MkdirAll(folder, 0700)\n\t}\n\tif expire > 0 {\n\t\texpireTS := time.Now().Add(expire).UnixNano()\n\t\terr := ioutil.WriteFile(c.expirePath(key...), []byte(strconv.FormatInt(expireTS, 10)), 0600)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn ioutil.WriteFile(c.keyPath(key...), data, 0600)\n}", "func SetPath(permissions string) error {\n\tif permissions != \"default\" {\n\t\tpl, err := NewPermissionsLoader(permissions)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif globalPermissions != nil {\n\t\t\tglobalPermissions.Close()\n\t\t}\n\t\tglobalPermissions = pl\n\t\tif !pl.Get().Watch {\n\t\t\tglobalPermissions.Close() // This will still keep the permissions themselves in memory\n\t\t}\n\n\t} else {\n\t\tif globalPermissions != nil {\n\t\t\tglobalPermissions.Close()\n\t\t}\n\t\tglobalPermissions = nil\n\t}\n\treturn nil\n}", "func (c *Quago) setPath(path string) {\n\tc.path = path\n}", "func (c *FakeZkConn) Set(path string, data []byte, version int32) (*zk.Stat, error) {\n\tc.history.addToHistory(\"Set\", path, data, version)\n\treturn nil, nil\n}", "func (c *CmdReal) SetPath(path string) {\n\tc.cmd.Path = path\n}", "func (m *Resource) SetPath(name string) error {\n\tif len(m.name) > 0 {\n\t\treturn errors.New(\"name already set\")\n\t}\n\tname = strings.TrimSpace(strings.ToLower(s))\n\tmatched, err := regexp.MatchString(\"^[a-z]{4,15}$\", name)\n\tif err == nil && matched {\n\t\tm.name = name\n\t\treturn nil\n\t} else {\n\t\treturn errors.New(\"name does not match requirements and has not been set: must be ^[a-z]{4-15}$\")\n\t}\n}", "func (k *Item) SetPath(s string) {\n\tk.SetString(PathKey, s)\n}", "func (t *T) Set(key, value string) error {\n\tif _, err := t.file.WriteString(fmt.Sprintf(\"\\n%s,%s\", key, value)); err != nil {\n\t\treturn err\n\t}\n\tt.links[key] = value\n\treturn nil\n}", "func (b *Binary) SetPath(pathStr string) {\n\tif pathStr == \"\" {\n\t\treturn\n\t}\n\tref, err := url.Parse(pathStr)\n\tif err != nil {\n\t\treturn\n\t}\n\tb.url = b.url.ResolveReference(ref)\n}", "func (c *clientHandler) SetPath(path string) {\n\tc.path = path\n}", "func (self *Path) SetPath(src string, des string) {\n\tself.srcPath = src\n\tself.desPath = des\n}", "func (c *Config) Set(key string, value interface{}) {\n\tif key == \"\" {\n\t\treturn\n\t}\n\n\tpath := strings.Split(key, c.separator)\n\tinsert(c.mp, path, value)\n}", "func (c DirCollector) Set(k string, v *VDir) {\n\tc[k] = v\n}", "func (hook *StackHook) SetLogPath(path string) {\n\thook.lock.Lock()\n\tdefer hook.lock.Unlock()\n\thook.path = path\n\thook.writeToFile = true\n}", "func (c *FileCache) Set(key string, entity *CacheEntity) error {\n\tpath := c.GetCachePath(key)\n\tif err := os.MkdirAll(filepath.Dir(path), 0777); err != nil {\n\t\treturn errors.Wrap(err, \"failed to create directory for cache file\")\n\t}\n\n\t// Need to avoid race condition\n\tfile, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0666)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to open/create a cache file\")\n\t}\n\tdefer file.Close()\n\n\tf := bufio.NewWriter(file)\n\tdefer f.Flush()\n\tenc := gob.NewEncoder(f)\n\tif err = enc.Encode(entity); err != nil {\n\t\treturn errors.Wrap(err, \"failed to encode Entity via gob\")\n\t}\n\n\treturn nil\n}", "func (bam BlockAddressMap) Set(loc BlockLocation, path string) {\n\tif bam[loc.FileIndex] == nil {\n\t\tbam[loc.FileIndex] = make(map[int64]string)\n\t}\n\tbam[loc.FileIndex][loc.BlockIndex] = path\n}", "func (fm *FileMapMutex) Set(UUID string, file File) {\n\tfm.mu.Lock()\n\tdefer fm.mu.Unlock()\n\tfm.Files[UUID] = file\n}", "func (fs *FileStore) Set(key string, w io.WriterTo) error {\n\tkey = fs.mangleKey(key, true)\n\tvar (\n\t\tf *os.File\n\t\terr error\n\t)\n\tif fs.tmpDir != \"\" {\n\t\tf, err = os.CreateTemp(fs.tmpDir, \"keystore\")\n\t} else {\n\t\tf, err = os.Create(filepath.Join(fs.baseDir, key))\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error opening file for writing: %w\", err)\n\t}\n\tif _, err = w.WriteTo(f); err != nil && err != io.EOF {\n\t\tf.Close()\n\t\treturn fmt.Errorf(\"error writing to file: %w\", err)\n\t} else if err = f.Close(); err != nil {\n\t\treturn fmt.Errorf(\"error closing file: %w\", err)\n\t}\n\tif fs.tmpDir != \"\" {\n\t\tfp := f.Name()\n\t\tif err = os.Rename(fp, filepath.Join(fs.baseDir, key)); err != nil {\n\t\t\tos.Remove(fp)\n\t\t\treturn fmt.Errorf(\"error moving tmp file: %w\", err)\n\t\t}\n\t}\n\treturn nil\n}", "func (p *Bucket) SetPath(path string) {\n\tp.path = path\n}", "func (i *Filename) Set(filename string) error {\n\tAssertIfFileExists(filename)\n\t*i = Filename(filename)\n\treturn nil\n}", "func (d *DiskStorage) Set(e Entry) {\n\td.Open()\n\td.memStorage.Set(e)\n\td.Save()\n}", "func (fcs *etcdStruct) Set(key, val string) error {\n\tif len(key) == 0 {\n\t\treturn ErrStoreKeyRequired\n\t}\n\n\t// counting on dotsToSlash to add initial '/' if necessary\n\tkey = dotsToSlash(key)\n\n\t_, err := fcs.client.Put(context.Background(), fcs.prefix+key, val)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (l *Level) Set(value string) error {\n\tv, err := strconv.Atoi(value)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*l = Level(v)\n\treturn nil\n}", "func (m *FileMutation) SetPath(s string) {\n\tm._path = &s\n}", "func setPath(value string) {\n\tos.Setenv(pathEnvVar, value)\n}", "func (this *Value) SetPath(path string, val interface{}) {\n\n\tif this.parsedType == OBJECT {\n\t\tswitch parsedValue := this.parsedValue.(type) {\n\t\tcase map[string]*Value:\n\t\t\t// if we've already parsed the object, store it there\n\t\t\tswitch val := val.(type) {\n\t\t\tcase *Value:\n\t\t\t\tparsedValue[path] = val\n\t\t\tdefault:\n\t\t\t\tparsedValue[path] = NewValue(val)\n\t\t\t}\n\t\tcase nil:\n\t\t\t// if not store it in alias\n\t\t\tif this.alias == nil {\n\t\t\t\tthis.alias = make(map[string]*Value)\n\t\t\t}\n\t\t\tswitch val := val.(type) {\n\t\t\tcase *Value:\n\t\t\t\tthis.alias[path] = val\n\t\t\tdefault:\n\t\t\t\tthis.alias[path] = NewValue(val)\n\t\t\t}\n\n\t\t}\n\t}\n}", "func Set(object *astext.Object, path []string, value ast.Node) error {\n\tif len(path) == 0 {\n\t\treturn errors.New(\"path was empty\")\n\t}\n\n\tcurObj := object\n\n\tfor i, k := range path {\n\t\tfield, err := findField(curObj, k)\n\t\tif err != nil {\n\t\t\tswitch err.(type) {\n\t\t\tdefault:\n\t\t\t\treturn err\n\t\t\tcase *unknownField:\n\t\t\t\tfield, err = astext.CreateField(k)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tfield.Hide = ast.ObjectFieldInherit\n\t\t\t\tcurObj.Fields = append(curObj.Fields, *field)\n\t\t\t}\n\t\t}\n\n\t\tif i == len(path)-1 {\n\t\t\tfield, _ = findField(curObj, k)\n\t\t\tif canUpdateObject(field.Expr2, value) {\n\t\t\t\treturn errors.New(\"can't set object to non object\")\n\t\t\t}\n\t\t\tfield.Expr2 = value\n\t\t\treturn nil\n\t\t}\n\n\t\tif field.Expr2 == nil {\n\t\t\tcurObj = &astext.Object{}\n\t\t\tfield.Expr2 = curObj\n\t\t} else if obj, ok := field.Expr2.(*astext.Object); ok {\n\t\t\tcurObj = obj\n\t\t} else {\n\t\t\treturn errors.Errorf(\"child is not an object at %q\", k)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (st *Store) Set(key, value []byte) error {\n\tst.lock.Lock()\n\tdefer st.lock.Unlock()\n\tif err := st.beforeSet(key, value); err != nil {\n\t\treturn err\n\t}\n\tif st.compression {\n\t\tvalue = compress(value)\n\t}\n\terr := st.store.Put(key, value, ds.ItemOptions{})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn st.writeToLogFile(key, value)\n}", "func (linux *Linux) FileSet(filePath, content string) error {\n\treturn ioutil.WriteFile(linux.applyChroot(filePath), []byte(content), 0777)\n}", "func SetConfig(file string) {\n\tPath.configFile = file\n}", "func (c *walkerContext) setCurrentDir(path string) {\n\tdirpath := filepath.Dir(path)\n\tif path != c.current.Path && dirpath != c.current.Path {\n\t\t// We have descended into a new directory, so set current to the\n\t\t// new entry.\n\t\tdir, ok := c.all[dirpath]\n\t\tif !ok {\n\t\t\tpanic(fmt.Sprintf(\"Fatal: Could not find directory: %s\", dirpath))\n\t\t}\n\t\tc.current = dir\n\t}\n}", "func (m *MetaSpec) Set(key string, value string) error {\n\tif m.IsExternal() {\n\t\treturn errors.New(\"can only meta set current build meta\")\n\t}\n\tmetaFilePath := m.MetaFilePath()\n\tvar previousMeta map[string]interface{}\n\n\tmetaJSON, err := ioutil.ReadFile(metaFilePath)\n\t// Not exist directory\n\tif err != nil {\n\t\tif !os.IsNotExist(err) {\n\t\t\treturn err\n\t\t}\n\t\t_, err := m.SetupDir()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Initialize interface if first setting meta\n\t\tpreviousMeta = make(map[string]interface{})\n\t} else {\n\t\t// Exist meta.json\n\t\tif len(metaJSON) != 0 {\n\t\t\terr = json.Unmarshal(metaJSON, &previousMeta)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\t// Exist meta.json but it is empty\n\t\t\tpreviousMeta = make(map[string]interface{})\n\t\t}\n\t}\n\n\tkey, parsedValue := setMetaValueRecursive(key, value, previousMeta, m.JSONValue)\n\tpreviousMeta[key] = parsedValue\n\n\tresultJSON, err := json.Marshal(previousMeta)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = ioutil.WriteFile(metaFilePath, resultJSON, 0666)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (fc *fileCache) Set(key, value string, ttl int) {\n\tfc.cache.Set(key, &cacheObject{\n\t\tValue: value,\n\t\tTimestamp: time.Now().Unix(),\n\t\tTTL: ttl,\n\t})\n\tfc.dirty = true\n}", "func (o *FileInfoCreateParams) SetPath(path string) {\n\to.Path = path\n}", "func (o *GetNdmpSettingsVariableParams) SetPath(path *string) {\n\to.Path = path\n}", "func (l *DolceLog) Set(key string, value []byte) {\n\tl.logMutex.Lock()\n\tdefer l.logMutex.Unlock()\n\n\twr := bufio.NewWriter(l.file)\n\t_, err := fmt.Fprintf(wr, \"%d S %s %s\\n\", l.index, key, value)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\tl.index++\n\n\terr = wr.Flush()\n\tif err != nil {\n\t\tlog.Fatal(\"Data not writen in file.\")\n\t}\n}", "func (db *DB) Set(key, value string) error {\n\tif db.parent != nil {\n\t\treturn db.parent.Set(path.Join(db.scope, key), value)\n\t}\n\tp := NewPipeline(db.repo)\n\tnewTree, err := p.Base(db.tree).Set(path.Join(db.scope, key), value).Run()\n\tif err != nil {\n\t\treturn err\n\t}\n\tdb.tree = newTree\n\treturn nil\n}", "func (path P) Set(obj, value interface{}) error {\n\tfn := func(p P, ctx *Context) (bool, error) {\n\t\treturn false, set(p, ctx, reflect.ValueOf(value))\n\t}\n\n\treturn path.Apply(obj, &Context{CreateIfMissing: true, Fn: fn})\n}", "func (p *Paths) Set(value string) error {\n\tfor _, val := range strings.Split(value, \",\") {\n\t\t*p = append(*p, val)\n\t}\n\treturn nil\n}", "func (o *GetZippedParams) SetPath(path string) {\n\to.Path = path\n}", "func (u *URL) SetPath(path string) {\n\tu.URL.Path = path\n}", "func (c *EnvConfigFromFile) Set(value string) error {\n\tc.FilePath = value\n\tvar fileContents []byte\n\tvar err error\n\tif c.FilePath != \"\" {\n\t\tfileContents, err = ioutil.ReadFile(c.FilePath)\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"envconfigfromfile: %s\", err.Error())\n\t\t} else {\n\t\t\tc.Value = string(fileContents)\n\t\t}\n\t}\n\treturn err\n}", "func (v *IADsNameTranslate) Set(adsPath string, setType uint32) (err error) {\n\treturn ole.NewError(ole.E_NOTIMPL)\n}", "func (s *AccessRuleService) Set(path string, permission api.Permission, accountName string) (*api.AccessRule, error) {\n\treturn s.Setter.Set(path, permission, accountName)\n}", "func (t *PathTree) Put(path string, value interface{}) interface{} {\n\treturn t.put(treePaths(path), value)\n}", "func SetDir(dir string) {\n\tif dir == \"\" {\n\t\tlog.Warn(\"empty-dir\")\n\t\treturn\n\t}\n\twritingDir = dir\n\tlog.Info(\"set-dir\", \"dir\", dir)\n\tos.MkdirAll(dir, os.ModePerm)\n}", "func (c SplitSize) Set(path string, object Object) error {\n\tobjectSize := len(object.Data)\n\tfor _, child := range c {\n\t\tif objectSize <= child.MaxSize || child.MaxSize == 0 {\n\t\t\treturn child.Cache.Set(path, object)\n\t\t}\n\t}\n\n\t// No cache is large enough to hold this object, but that's ok.\n\treturn nil\n}", "func (c *SDConfig) SetDirectory(dir string) {\n\tfor i, file := range c.Files {\n\t\tc.Files[i] = config.JoinDir(dir, file)\n\t}\n}", "func (c *Client) SetDir(prefix, name string) {\n\tc.Lock()\n\tc.dir = &models.Directory{\n\t\tBase: fmt.Sprintf(\"%v/%v\", prefix, name),\n\t\tElection: fmt.Sprintf(\"%v/%v/%v\", prefix, name, DirectoryElection),\n\t\tRunning: fmt.Sprintf(\"%v/%v/%v\", prefix, name, DirectoryRunning),\n\t\tQueue: fmt.Sprintf(\"%v/%v/%v\", prefix, name, DirectoryQueue),\n\t\tNodes: fmt.Sprintf(\"%v/%v/%v\", prefix, name, DirectoryNodes),\n\t\tMasters: fmt.Sprintf(\"%v/%v/%v\", prefix, name, DirectoryMasters),\n\t}\n\tc.Unlock()\n}", "func (k Keeper) setValue(ctx sdk.Context, accessPath *vm_grpc.VMAccessPath, value []byte) {\n\tstore := ctx.KVStore(k.storeKey)\n\tkey := common_vm.GetPathKey(accessPath)\n\n\tstore.Set(key, value)\n}", "func (store *EntryStore) Set(id []byte, entry *hexalog.Entry) error {\n\tval, err := proto.Marshal(entry)\n\tif err == nil {\n\t\terr = store.db.Put(store.wo, id, val)\n\t}\n\treturn err\n}", "func (cf *ConfigFile) Set(key string, val interface{}) error {\n\tc, err := cf.Open()\n\tif err != nil {\n\t\tswitch err.(type) {\n\t\tcase *os.PathError:\n\t\t\terr := cf.createConfigFile()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tc, _ = cf.Open()\n\t\tdefault:\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tb, err := ioutil.ReadAll(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar m map[string]interface{}\n\terr = yaml.Unmarshal(b, &m)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif m == nil {\n\t\tm = map[string]interface{}{}\n\t}\n\n\tm[key] = val\n\n\tout, err := yaml.Marshal(m)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn ioutil.WriteFile(cf.location, out, 0600)\n}", "func (l *Lockbox) SetValue(path, value []byte) error {\n\tif l.Locked {\n\t\treturn errors.New(\"cannot set value while lockbox is locked\")\n\t}\n\n\t// encrypt the provided value with the current users encryption key.\n\tencval, err := encrypt(value, l.CurrentUser.EncryptionKey)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// store the encrypted value at the desired path\n\treturn l.Store.Update(func(tx *bolt.Tx) error {\n\t\tb := tx.Bucket([]byte(l.CurrentNamespace))\n\t\terr := b.Put(path, encval)\n\t\treturn err\n\t})\n}", "func (c *fileStorageClient) Set(key string, value []byte) error {\n\treturn c.Batch(SetOperation(key, value))\n}", "func (c DeferDirCollector) Set(k string, v func() *VDir) {\n\tc[k] = v\n}", "func (k Keeper) SetValue(ctx sdk.Context, accessPath *vm_grpc.VMAccessPath, value []byte) {\n\tk.modulePerms.AutoCheck(types.PermStorageWrite)\n\n\tk.setValue(ctx, accessPath, value)\n}", "func (options *EditLoadBalancerMonitorOptions) SetPath(path string) *EditLoadBalancerMonitorOptions {\n\toptions.Path = core.StringPtr(path)\n\treturn options\n}", "func (m *Message) SetPath(s []string) {\n\tm.Options = m.Options.Minus(URIPath)\n\tfor _, p := range s {\n\t\tm.Options = append(m.Options, Option{URIPath, p})\n\t}\n}", "func (mc *MenuCreate) SetPath(s string) *MenuCreate {\n\tmc.mutation.SetPath(s)\n\treturn mc\n}", "func SetFromPath(node interface{}, path string, out interface{}) (bool, error) {\n\tval, found, err := GetFromStructPath(node, path)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif !found {\n\t\treturn false, nil\n\t}\n\n\treturn true, Set(val, out)\n}", "func (c FileCollector) Set(k string, v *VFile) {\n\tc[k] = v\n}", "func (options *CreateLoadBalancerMonitorOptions) SetPath(path string) *CreateLoadBalancerMonitorOptions {\n\toptions.Path = core.StringPtr(path)\n\treturn options\n}", "func (s *AccessRuleSetter) Set(path string, permission api.Permission, name string) (*api.AccessRule, error) {\n\ts.ArgPath = path\n\ts.ArgPermission = permission\n\ts.ArgName = name\n\treturn s.ReturnsAccessRule, s.Err\n}", "func (ln *LocalNode) Set(e qnr.Entry) {\n\tln.mu.Lock()\n\tdefer ln.mu.Unlock()\n\n\tln.set(e)\n}", "func (f *RPCFile) SetMediaPath(mediaDirectory string) error {\n\tif f.file == nil {\n\t\terr := errors.New(\"No grpc file. Construct with NewFile\")\n\t\tlog.Fatal().Stack().Err(err).Msg(\"\")\n\t\treturn err\n\t}\n\tf.file.MediaDirectory = mediaDirectory\n\treturn nil\n}", "func setSeek(dirPath string, name string, fPos int64) {\n\tfullname := path.Join(dirPath, seekPrefix+name)\n\tif fPos == 0 {\n\t\tos.Remove(fullname)\n\t} else {\n\t\tfile, _ := os.OpenFile(fullname, os.O_WRONLY|os.O_CREATE, 0666)\n\t\tfile.WriteString(strconv.FormatInt(fPos, 10))\n\t\tfile.Close()\n\t}\n}", "func (fv *FileView) SetPathFile(path, file, ext string) {\n\tfv.DirPath = path\n\tfv.SelFile = file\n\tfv.SetExt(ext)\n\tfv.UpdateFromPath()\n}", "func (*XMLDocument) SetDir(dir string) {\n\tmacro.Rewrite(\"$_.dir = $1\", dir)\n}", "func (me *TPathDataType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (t *FenwickTreeSimple) Set(index int, value int) {\n\tt.Update(index, value-t.Get(index))\n}", "func SetRef(ref string, oid string) error {\n\tp := filepath.Dir(UGIT_DIR + \"/\" + ref)\n\tos.MkdirAll(p, 0777)\n\terr := ioutil.WriteFile(UGIT_DIR+\"/\"+ref, []byte(oid), 0777)\n\treturn err\n}", "func (m *stateManager) Set(key types.StateEntryKey, stateEntry types.StateEntry) (err error) {\n\t// Check stateEntry is not a pointer.\n\tval := reflect.ValueOf(stateEntry)\n\tif val.Kind() == reflect.Ptr {\n\t\treturn errors.New(\"stateEntry must not be a pointer\")\n\t}\n\n\tif err = m.ensureLoaded(); err != nil {\n\t\treturn\n\t}\n\n\t// Update or add state entry.\n\tm.state[key] = stateEntry\n\tm.stateChanged = true\n\n\treturn\n}", "func (t *FileTree) SetFile(f file.Reference) error {\n\toriginal, ok := t.pathToFileRef[f.Path.ID()]\n\n\tif !ok {\n\t\treturn fmt.Errorf(\"file does not already exist in tree (cannot replace)\")\n\t}\n\tdelete(t.pathToFileRef, original.Path.ID())\n\tt.pathToFileRef[f.Path.ID()] = f\n\n\treturn nil\n}", "func (impl *ldapAuthImpl) SetCAPath(path string) error {\n\timpl.Lock()\n\tdefer impl.Unlock()\n\n\tif path != impl.caPath {\n\t\timpl.caPath = path\n\t\terr := impl.initializeCAPool()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (m *MerkleTree) Set(index []byte, key string, value []byte) error {\n\tcommitment, err := crypto.NewCommit([]byte(key), value)\n\tif err != nil {\n\t\treturn err\n\t}\n\ttoAdd := userLeafNode{\n\t\tkey: key,\n\t\tvalue: append([]byte{}, value...), // make a copy of value\n\t\tindex: index,\n\t\tcommitment: commitment,\n\t}\n\tm.insertNode(index, &toAdd)\n\treturn nil\n}" ]
[ "0.7188751", "0.70497656", "0.69994205", "0.69260705", "0.6846642", "0.6761991", "0.67417395", "0.6709446", "0.6564426", "0.64639956", "0.6394431", "0.6356663", "0.63492095", "0.6277019", "0.626828", "0.6263598", "0.6247245", "0.61931396", "0.61799264", "0.61762017", "0.6155869", "0.6112429", "0.6099579", "0.6098902", "0.6058148", "0.6050812", "0.60339594", "0.60254014", "0.60162354", "0.60162", "0.6008411", "0.59825224", "0.5950835", "0.5934299", "0.5933279", "0.5926648", "0.5902473", "0.58861065", "0.5803435", "0.57950914", "0.5767735", "0.57582754", "0.57340306", "0.5725218", "0.57179344", "0.5715757", "0.57034117", "0.568525", "0.5684713", "0.5677626", "0.56582445", "0.56387633", "0.5634334", "0.5619013", "0.5607518", "0.559357", "0.5590478", "0.5572738", "0.55581707", "0.55546033", "0.55513084", "0.5539899", "0.5532587", "0.5528882", "0.55175364", "0.5503568", "0.54706484", "0.54685134", "0.54534674", "0.545049", "0.5449991", "0.5445025", "0.54311013", "0.5430382", "0.54286176", "0.54243284", "0.54071295", "0.5395389", "0.5394963", "0.5388017", "0.5363746", "0.53631604", "0.53528744", "0.5351711", "0.53505135", "0.5349776", "0.53486705", "0.5342619", "0.5339542", "0.53348845", "0.53140676", "0.53004384", "0.5288413", "0.5286081", "0.52784884", "0.527412", "0.52737665", "0.52703696", "0.5267373", "0.5259944" ]
0.8198673
0
Lookup returns the entry associated with the provided path and a boolean indicating whether the entry was found.
Lookup возвращает запись, связанную с предоставленным путем, и булево значение, указывающее, была ли запись найдена.
func (d Dir) Lookup(path string) (file reflow.File, ok bool) { file, ok = d.contents[path] return file, ok }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (registry *Registry) Lookup(handle string) *task.Task {\n\t// TODO: Refactor the interface here to explicitly add an `ok`\n\t// return value (in the style of reading a map[...]...)\n\t// to differentiate a present nil value return vs. a\n\t// not-present-at-all value.\n\tregistry.lock.RLock()\n\tdefer registry.lock.RUnlock()\n\n\tif t, exists := registry.db[handle]; exists {\n\t\treturn t\n\t}\n\n\treturn nil\n}", "func (e entry) lookup(name interface{}) (interface{}, bool) {\n\tif res, ok := e[name]; ok {\n\t\treturn res, true\n\t}\n\treturn nil, false\n}", "func (fs *fsMutable) lookup(p fuseops.InodeID, c string) (le lookupEntry, found bool, lk []byte) {\n\treturn lookup(p, c, fs.lookupTree)\n}", "func (fs *fsMutable) lookup(p fuseops.InodeID, c string) (le lookupEntry, found bool, lk []byte) {\n\treturn lookup(p, c, fs.lookupTree)\n}", "func Lookup(path string) ([]byte, error) {\n\tf, ok := files[path]\n\tif !ok {\n\t\treturn nil, os.ErrNotExist\n\t}\n\treturn f.data, nil\n}", "func (r *Router) Lookup(method, path string) (Handle, Params, bool) {\n\tif root := r.trees[method]; root != nil {\n\t\treturn root.getValue(path)\n\t}\n\treturn nil, nil, false\n}", "func (c *rPathCacheContainer) lookup(cPath string) ([]byte, string) {\n\tc.Lock()\n\tdefer c.Unlock()\n\tif cPath == c.cPath {\n\t\t// hit\n\t\treturn c.dirIV, c.pPath\n\t}\n\t// miss\n\treturn nil, \"\"\n}", "func (fi *FsCache) Lookup(key *fs.FsFile) (*fs.FsData, bool) {\n\tfi.l.RLock()\n\tdefer fi.l.RUnlock()\n\tfdata, ok := fi.lookup(key)\n\treturn fdata, ok\n}", "func lookup(p fuseops.InodeID, c string, lookupTree *iradix.Tree) (le lookupEntry, found bool, lk []byte) {\n\tlk = formLookupKey(p, c)\n\tval, found := lookupTree.Get(lk)\n\tif found {\n\t\tle = val.(lookupEntry)\n\t\treturn le, found, lk\n\t}\n\treturn lookupEntry{}, found, lk\n}", "func lookup(p fuseops.InodeID, c string, lookupTree *iradix.Tree) (le lookupEntry, found bool, lk []byte) {\n\tlk = formLookupKey(p, c)\n\tval, found := lookupTree.Get(lk)\n\tif found {\n\t\tle = val.(lookupEntry)\n\t\treturn le, found, lk\n\t}\n\treturn lookupEntry{}, found, lk\n}", "func (r *HashRing) Lookup(key string) (string, bool) {\n\tstrs := r.LookupN(key, 1)\n\tif len(strs) == 0 {\n\t\treturn \"\", false\n\t}\n\treturn strs[0], true\n}", "func (s *OnDiskStateMachine) Lookup(query interface{}) (interface{}, error) {\n\tif !s.opened {\n\t\tpanic(\"Lookup called when not opened\")\n\t}\n\treturn s.sm.Lookup(query)\n}", "func (s *devNull) Lookup(key string) (interface{}, bool) {\n\treturn nil, false\n}", "func (fi *FsCache) lookup(key *fs.FsFile) (*fs.FsData, bool) {\n\tfdata, ok := fi.dict[key.String()]\n\treturn fdata, ok\n}", "func (s dirServer) Lookup(name upspin.PathName) (*upspin.DirEntry, error) {\n\tp, err := path.Parse(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch p.FilePath() {\n\tcase \"\": // Root directory.\n\t\treturn directory(p.Path()), nil\n\tcase access.AccessFile:\n\t\treturn s.accessEntry, nil\n\t}\n\n\tgit := s.corpus.GitHub()\n\tswitch p.NElem() {\n\tcase 1: // Owner directory.\n\t\tok := false\n\t\tgit.ForeachRepo(func(repo *maintner.GitHubRepo) error {\n\t\t\tif repo.ID().Owner == p.Elem(0) {\n\t\t\t\tok = true\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t\tif ok {\n\t\t\treturn directory(p.Path()), nil\n\t\t}\n\tcase 2: // User directory.\n\t\tif git.Repo(p.Elem(0), p.Elem(1)) != nil {\n\t\t\treturn directory(p.Path()), nil\n\t\t}\n\tcase 3: // State directory.\n\t\tif validState(p.Elem(2)) {\n\t\t\treturn directory(p.Path()), nil\n\t\t}\n\tcase 4: // Issue file or link.\n\t\tstate := p.Elem(2)\n\t\tif !validState(state) {\n\t\t\tbreak\n\t\t}\n\t\trepo := git.Repo(p.Elem(0), p.Elem(1))\n\t\tn, err := strconv.ParseInt(p.Elem(3), 10, 32)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tissue := repo.Issue(int32(n))\n\t\tif issue == nil {\n\t\t\tbreak\n\t\t}\n\t\tif state == \"open\" && issue.Closed || state == \"closed\" && !issue.Closed {\n\t\t\tbreak\n\t\t}\n\t\tif state == \"open\" || state == \"closed\" {\n\t\t\treturn link(p.Path(), issue), upspin.ErrFollowLink\n\t\t}\n\t\tde, err := s.packIssue(p.Path(), issue)\n\t\tif err != nil {\n\t\t\treturn nil, errors.E(name, err)\n\t\t}\n\t\treturn de, nil\n\t}\n\n\treturn nil, errors.E(name, errors.NotExist)\n}", "func (state *State) LookUp(path string) (value reflect.Value, err error) {\n\tvalue, err = utils.LookUp(state.deviceInfo, path)\n\treturn\n}", "func Lookup(name string) (Plugin, bool) {\n\tp, found := directory[name]\n\treturn p, found\n}", "func (inst *hiddenInstance) Lookup(path ...string) Value {\n\treturn inst.value().Lookup(path...)\n}", "func (r propertyTypeRegistry) Lookup(module, key string) bool {\n\t_, found := r[module][key]\n\treturn found\n}", "func (cp Pack) Lookup(accountID string) (bool, Account) {\n\tfor _, c := range cp {\n\t\tfound, account := c.Lookup(accountID)\n\t\tif found {\n\t\t\treturn true, account\n\t\t}\n\t}\n\treturn false, Account{}\n}", "func (lwwset LWWSet) Lookup(value string) (bool, error) {\n\t// Return an error if the value passed is nil\n\tif value == \"\" {\n\t\treturn false, errors.New(\"empty value provided\")\n\t}\n\n\tlwwset, list := lwwset.List()\n\n\t// Iterative over the LWWSet and check if the\n\t// value is the one we're searching\n\t// return true if the value exists\n\tfor _, element := range list {\n\t\tif element == value {\n\t\t\treturn true, nil\n\t\t}\n\t}\n\n\t// If the value isn't found after iterating\n\t// over the entire LWWSet we return false\n\treturn false, nil\n}", "func (dc *DigestCache) Lookup(hash []byte) []byte {\n\tif r, ok := dc.Records[string(hash)]; ok {\n\t\treturn r\n\t}\n\treturn nil\n}", "func (s *mockFSServer) Lookup(ctx context.Context, r *proto.LookupRequest) (*proto.LookupResponse, error) {\n\ts.lock.Lock()\n\tdefer s.lock.Unlock()\n\tif isDir, ok := s.filesCreated[r.Path]; ok {\n\t\treturn &proto.LookupResponse{IsDir: isDir}, nil\n\t}\n\n\treturn nil, os.ErrNotExist\n}", "func (idx *Unique) Lookup(v string) (resultPath []string, err error) {\n\tif idx.caseInsensitive {\n\t\tv = strings.ToLower(v)\n\t}\n\tsearchPath := path.Join(idx.indexRootDir, v)\n\tif err = isValidSymlink(searchPath); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\terr = &idxerrs.NotFoundErr{TypeName: idx.typeName, Key: idx.indexBy, Value: v}\n\t\t}\n\t\treturn\n\t}\n\n\tp, err := os.Readlink(searchPath)\n\tif err != nil {\n\t\treturn []string{}, nil\n\t}\n\n\treturn []string{p}, err\n}", "func (s STags) Lookup(tag string, fields ...string) (value string, ok bool) {\n\tvalue, ok = s.get(tag, fields...)\n\treturn\n}", "func Lookup(opts []map[string]interface{}, key string) (interface{}, bool) {\n\tif len(opts) == 0 {\n\t\treturn nil, false\n\t}\n\tv, ok := opts[0][key]\n\treturn v, ok\n}", "func (cache *FTPDataCache) Look(filename string) (bool, error) {\n\n\treturn false, nil\n}", "func (s *dirServer) Lookup(name upspin.PathName) (*upspin.DirEntry, error) {\n\tp, err := path.Parse(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfp := p.FilePath()\n\tswitch fp {\n\tcase \"\": // Root directory.\n\t\ts.mu.Lock()\n\t\ttotal := len(s.boxes)\n\t\ts.mu.Unlock()\n\t\treturn &upspin.DirEntry{\n\t\t\tName: p.Path(),\n\t\t\tSignedName: p.Path(),\n\t\t\tAttr: upspin.AttrDirectory,\n\t\t\tTime: upspin.Now(),\n\t\t\tSequence: int64(total * 2),\n\t\t}, nil\n\tcase access.AccessFile:\n\t\treturn s.accessEntry, nil\n\t}\n\n\tn := matchBox(fp)\n\tif n < 0 {\n\t\treturn nil, errors.E(name, errors.NotExist)\n\t}\n\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\n\ttotal := len(s.boxes)\n\tif n > total {\n\t\treturn nil, errors.E(name, errors.NotExist)\n\t}\n\n\tif n == total {\n\t\t// A new box is opened!\n\t\tde, data, err := s.pack(fp, int64(total*2+1), randomState())\n\t\tif err != nil {\n\t\t\treturn nil, errors.E(name, err)\n\t\t}\n\t\ts.boxes = append(s.boxes, box{de, data})\n\t\ts.open.Broadcast()\n\t}\n\n\treturn s.boxes[n].DirEntry, nil\n}", "func (s *ConcurrentStateMachine) Lookup(query interface{}) (interface{}, error) {\n\treturn s.sm.Lookup(query)\n}", "func (fsi *fsIOPool) lookupToRead(path string) (*lock.RLockedFile, bool) {\n\trlkFile, ok := fsi.readersMap[path]\n\t// File reference exists on map, validate if its\n\t// really closed and we are safe to purge it.\n\tif ok && rlkFile != nil {\n\t\t// If the file is closed and not removed from map is a bug.\n\t\tif rlkFile.IsClosed() {\n\t\t\t// Log this as an error.\n\t\t\treqInfo := (&logger.ReqInfo{}).AppendTags(\"path\", path)\n\t\t\tctx := logger.SetReqInfo(context.Background(), reqInfo)\n\t\t\tlogger.LogIf(ctx, errUnexpected)\n\n\t\t\t// Purge the cached lock path from map.\n\t\t\tdelete(fsi.readersMap, path)\n\n\t\t\t// Indicate that we can populate the new fd.\n\t\t\tok = false\n\t\t} else {\n\t\t\t// Increment the lock ref, since the file is not closed yet\n\t\t\t// and caller requested to read the file again.\n\t\t\trlkFile.IncLockRef()\n\t\t}\n\t}\n\treturn rlkFile, ok\n}", "func Lookup(domainName string) (bool, string) {\n\tfor index := 0; index < len(entries); index++ {\n\t\tif domainName == entries[index].domainName {\n\t\t\treturn true, entries[index].ip\n\t\t}\n\t}\n\n\treturn false, \"\"\n}", "func (atl Atlas) Get(rtid uintptr) (*AtlasEntry, bool) {\n\tent, ok := atl.mappings[rtid]\n\treturn ent, ok\n}", "func (t *Table) Lookup(s string) (n uint32, ok bool) {\n\ti0 := int(murmurSeed(0).hash(s)) & t.level0Mask\n\tseed := t.level0[i0]\n\ti1 := int(murmurSeed(seed).hash(s)) & t.level1Mask\n\tn = t.level1[i1]\n\treturn n, s == t.keys[int(n)]\n}", "func (d *Dir) Lookup(ctx context.Context, name string) (fs.Node, error) {\n\tlog.Println(\"dir.Lookup\")\n\tinfo, err := d.core.Stat(ctx, name)\n\tif err != nil {\n\t\treturn &notExistFile{\n\t\t\tcore: d.core,\n\t\t\tkey: name,\n\t\t}, nil\n\t}\n\treturn &existingFile{info: info}, nil\n}", "func (c *Config) Lookup(key string) (any, error) {\n\t// check thet key is valid, meaning it starts with one of\n\t// the fields of the config struct\n\tif !c.isValidKey(key) {\n\t\treturn nil, nil\n\t}\n\tval, err := lookupByType(key, reflect.ValueOf(c))\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"lookup: error on key '%s'\", key)\n\t}\n\treturn val, nil\n}", "func (c *Cache) Lookup(buildid int64) (string, error) {\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\n\tif hash, ok := c.hashes[buildid]; !ok {\n\t\treturn \"\", fmt.Errorf(\"BuildId not found in cache: %d\", buildid)\n\t} else {\n\t\treturn hash, nil\n\t}\n}", "func (w *WindowedMap) Lookup(uid UID) (interface{}, bool) {\n\tw.ExpireOldEntries()\n\titem, ok := w.uidMap[uid]\n\tif !ok {\n\t\treturn nil, false\n\t}\n\tw.Put(uid, item.value)\n\treturn item.value, true\n}", "func (r *Mux) Lookup(method, path string) (http.Handler, Params, bool) {\n\tif root := r.trees[method]; root != nil {\n\t\treturn root.getValue(path)\n\t}\n\treturn nil, nil, false\n}", "func (sm *ConcurrentStateMachine) Lookup(query []byte) ([]byte, error) {\n\treturn sm.sm.Lookup(query)\n}", "func (kvStore *KVStore) Lookup(hash KademliaID) (output []byte, err error) {\n kvStore.mutex.Lock()\n if val, ok := kvStore.mapping[hash]; ok {\n output = val.data\n } else {\n err = NotFoundError\n }\n kvStore.mutex.Unlock()\n return\n}", "func (bf BloomFilter) Lookup(entry string) (bool, error) {\n\thashes := hashEntry([]byte(entry), bf.hf)\n\tfor i := 0; i < bf.hf; i++ {\n\t\tlookup_idx := hashes[i] & (bf.size - 1)\n\t\tif exists, err := bf.getBit(lookup_idx); !exists {\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\t\t\treturn false, nil\n\t\t}\n\t}\n\treturn true, nil\n}", "func (d *dataUsageCache) find(path string) *dataUsageEntry {\n\tdue, ok := d.Cache[hashPath(path).Key()]\n\tif !ok {\n\t\treturn nil\n\t}\n\treturn &due\n}", "func Lookup(name string) (value interface{}, ok bool) {\n\tinitialize()\n\tlock.RLock()\n\tvalue, ok = notGlobals[name]\n\tlock.RUnlock()\n\treturn value, ok\n}", "func (m Map) Lookup(d digest.Digest, key T) T {\n\tif _, ok := m.tab[d]; !ok {\n\t\treturn nil\n\t}\n\tentry := *m.tab[d]\n\tfor entry != nil && Less(entry.Key, key) {\n\t\tentry = entry.Next\n\t}\n\tif entry == nil || !Equal(entry.Key, key) {\n\t\treturn nil\n\t}\n\treturn entry.Value\n}", "func (r *Registry) Lookup(name string) *Object {\n\tr.Lock()\n\tdefer r.Unlock()\n\n\tif obj, ok := r.dataStores[name]; ok {\n\t\tif obj.Enabled {\n\t\t\treturn obj\n\t\t}\n\t}\n\treturn nil\n}", "func (t table) lookup(name interface{}) (interface{}, bool) {\n\tfor _, e := range t {\n\t\tif val, ok := e.lookup(name); ok {\n\t\t\treturn val, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func (s *subtasks) Lookup(ctx context.Context, dir *fs.Inode, p string) (*fs.Dirent, error) {\n\ttid, err := strconv.ParseUint(p, 10, 32)\n\tif err != nil {\n\t\treturn nil, syserror.ENOENT\n\t}\n\n\ttask := s.pidns.TaskWithID(kernel.ThreadID(tid))\n\tif task == nil {\n\t\treturn nil, syserror.ENOENT\n\t}\n\tif task.ThreadGroup() != s.t.ThreadGroup() {\n\t\treturn nil, syserror.ENOENT\n\t}\n\n\ttd := newTaskDir(task, dir.MountSource, s.pidns, false)\n\treturn fs.NewDirent(td, p), nil\n}", "func Lookup(node *Node, key int) bool {\n\tif node == nil {\n\t\treturn false\n\t} else {\n\t\tif node.Key == key {\n\t\t\treturn true\n\t\t} else {\n\t\t\tif node.Key > key {\n\t\t\t\treturn Lookup(node.Left, key)\n\t\t\t} else {\n\t\t\t\treturn Lookup(node.Right, key)\n\t\t\t}\n\t\t}\n\t}\n}", "func (dir *Directory) lookup(path string) *Directory {\n\tpath = pathutil.Clean(path);\t// no trailing '/'\n\n\tif dir == nil || path == \"\" || path == \".\" {\n\t\treturn dir\n\t}\n\n\tdpath, dname := pathutil.Split(path);\n\tif dpath == \"\" {\n\t\t// directory-local name\n\t\tfor _, d := range dir.Dirs {\n\t\t\tif dname == d.Name {\n\t\t\t\treturn d\n\t\t\t}\n\t\t}\n\t\treturn nil;\n\t}\n\n\treturn dir.lookup(dpath).lookup(dname);\n}", "func (rad *Radix) Lookup(key string) interface{} {\n\trad.lock.Lock()\n\tdefer rad.lock.Unlock()\n\tif x, ok := rad.root.lookup([]rune(key)); ok {\n\t\treturn x.value\n\t}\n\treturn nil\n}", "func (dir HgmDir) Lookup(ctx context.Context, name string) (fs.Node, error) {\n\tlocalDirent := dir.localDir + name // dirs are ending with a slash -> just append the name\n\ta := fuse.Attr{}\n\td := HgmDir{hgmFs: dir.hgmFs, localDir: localDirent}\n\terr := d.Attr(ctx, &a)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif (a.Mode & os.ModeType) == os.ModeDir {\n\t\treturn HgmDir{hgmFs: dir.hgmFs, localDir: localDirent + \"/\"}, nil\n\t}\n\n\treturn &HgmFile{hgmFs: dir.hgmFs, localFile: localDirent, fileSize: a.Size}, nil\n}", "func (key Key) Lookup() (string, bool) {\n\treturn os.LookupEnv(string(key))\n}", "func (sc *simpleLRUStatsCache) Lookup(id int64) (*statistics.Table, bool) {\n\tsc.mu.Lock()\n\tdefer sc.mu.Unlock()\n\treturn sc.lookupUnsafe(id)\n}", "func (r *Router) Lookup(method, path string, ctx *Context) (RequestHandler, bool) {\n\treturn r.router.Lookup(method, path, ctx)\n}", "func (s *Store) Get(id string) (e Entry, exists bool) {\n\te, exists = (*s)[id]\n\treturn\n}", "func (f *FlagSet) Lookup(name string) *Flag {\n\treturn f.lookup(f.normalizeFlagName(name))\n}", "func (s *RegularStateMachine) Lookup(query interface{}) (interface{}, error) {\n\treturn s.sm.Lookup(query)\n}", "func Lookup(code cid.Cid) (ActorInfo, bool) {\n\tact, ok := actorInfos[code]\n\treturn act, ok\n}", "func (vars Variables) Lookup(n *scparse.VariableNode) (interface{}, bool) {\n\tv := vars.lookup(n)\n\tif !v.IsValid() {\n\t\treturn nil, false\n\t}\n\treturn v.Interface(), true\n}", "func (sm *RegularStateMachine) Lookup(query []byte) ([]byte, error) {\n\treturn sm.sm.Lookup(query), nil\n}", "func lookupPathMap(pathMaps *[]n.ApplicationGatewayURLPathMap, resourceID *string) *n.ApplicationGatewayURLPathMap {\n\tfor idx, pathMap := range *pathMaps {\n\t\tif *pathMap.ID == *resourceID {\n\t\t\treturn &(*pathMaps)[idx]\n\t\t}\n\t}\n\n\treturn nil\n}", "func lookupPath(obj interface{}, path string, kind reflect.Kind) (reflect.Value, bool) {\n\tnodes := strings.Split(path, \".\")\n\n\tvar name string\n\tvalue := reflect.ValueOf(obj)\n\nLOOP:\n\tfor _, node := range nodes {\n\t\tname = node\n\t\tif value.Kind() == reflect.Struct {\n\t\t\tt := value.Type()\n\n\t\t\tfor i := 0; i != t.NumField(); i++ {\n\t\t\t\tif t.Field(i).Name == node {\n\t\t\t\t\tvalue = value.Field(i)\n\t\t\t\t\tif value.Kind() == reflect.Interface || value.Kind() == reflect.Ptr {\n\t\t\t\t\t\tvalue = value.Elem()\n\t\t\t\t\t}\n\n\t\t\t\t\tcontinue LOOP\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tbreak LOOP\n\t\t}\n\t}\n\n\tif name != nodes[len(nodes)-1] {\n\t\treturn value, false\n\t}\n\n\tif kind == reflect.Interface {\n\t\treturn value, true\n\t}\n\n\t// convert result kind to int for all size of interger as then\n\t// only a int64 version will be retrieve by value.Int()\n\trk := value.Kind()\n\tswitch rk {\n\tcase reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\t\trk = reflect.Int\n\t}\n\n\treturn value, rk == kind\n}", "func (r *Wrapper) Lookup(name string) (val any, ok bool) {\n\tfv := r.rv.FieldByName(name)\n\tif !fv.IsValid() {\n\t\treturn\n\t}\n\n\tif fv.CanInterface() {\n\t\treturn fv.Interface(), true\n\t}\n\treturn\n}", "func Lookup(name string) *Flag {\n\treturn CommandLine.Lookup(name)\n}", "func Lookup(L *lua.State, path string, idx int) {\n parts := strings.Split(path, \".\")\n if idx != 0 {\n L.PushValue(idx)\n } else {\n L.GetGlobal(\"_G\")\n }\n for _, field := range parts {\n L.GetField(-1, field)\n L.Remove(-2) // remove table\n }\n}", "func (as AccountSet) Lookup(accountID string) (bool, Account) {\n\tlogger.InfoMsgf(\"looking up accountID %s in set\", accountID)\n\tfor _, a := range as {\n\t\tif a.Account == accountID {\n\t\t\treturn true, a\n\t\t}\n\t}\n\treturn false, Account{}\n}", "func (c *Cache) lookupResult(\n\tpodName, nodeName, predicateKey string,\n\tequivalenceHash uint64,\n) (value predicateResult, ok bool) {\n\tc.mu.RLock()\n\tdefer c.mu.RUnlock()\n\tglog.V(5).Infof(\"Cache lookup: node=%s,predicate=%s,pod=%s\", nodeName, predicateKey, podName)\n\tvalue, ok = c.cache[nodeName][predicateKey][equivalenceHash]\n\treturn value, ok\n}", "func Lookup(files *[]string, routeFileName string) filepath.WalkFunc {\n\treturn func(path string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\n\t\tif len(routeFileName) == 0 {\n\t\t\trouteFileName = \"route_config.json.template\"\n\t\t}\n\n\t\tif info.Name() == routeFileName {\n\t\t\t*files = append(*files, path)\n\t\t}\n\n\t\treturn nil\n\t}\n}", "func (d *Document) lookup(id uint, path []string) uint {\n\tvar (\n\t\tv *V\n\t\tn *node\n\t)\nlookup:\n\tfor _, key := range path {\n\t\tif n = d.get(id); n != nil {\n\t\t\tswitch n.info.Type() {\n\t\t\tcase TypeObject:\n\t\t\t\tfor i := range n.values {\n\t\t\t\t\tv = &n.values[i]\n\t\t\t\t\tif v.key == key {\n\t\t\t\t\t\tid = v.id\n\t\t\t\t\t\tcontinue lookup\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase TypeArray:\n\t\t\t\ti := 0\n\t\t\t\tfor _, c := range []byte(key) {\n\t\t\t\t\tif c -= '0'; 0 <= c && c <= 9 {\n\t\t\t\t\t\ti = i*10 + int(c)\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn maxUint\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif 0 <= i && i < len(n.values) {\n\t\t\t\t\tv = &n.values[i]\n\t\t\t\t\tid = v.id\n\t\t\t\t\tcontinue lookup\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn maxUint\n\t}\n\treturn id\n}", "func (idx *Tree) Lookup(key []byte) (value uint64, found bool) {\n\tid := idx.allocatorQueue.get()\n\tvalue, found = idx.allocators[id].Lookup(key)\n\tidx.allocatorQueue.put(id)\n\treturn\n}", "func (x *Index) Lookup(query string) (match *LookupResult, alt *AltWords, illegal bool) {\n\tss := strings.Split(query, \".\", 0);\n\n\t// check query syntax\n\tfor _, s := range ss {\n\t\tif !isIdentifier(s) {\n\t\t\tillegal = true;\n\t\t\treturn;\n\t\t}\n\t}\n\n\tswitch len(ss) {\n\tcase 1:\n\t\tmatch, alt = x.LookupWord(ss[0])\n\n\tcase 2:\n\t\tpakname := ss[0];\n\t\tmatch, alt = x.LookupWord(ss[1]);\n\t\tif match != nil {\n\t\t\t// found a match - filter by package name\n\t\t\tdecls := match.Decls.filter(pakname);\n\t\t\tothers := match.Others.filter(pakname);\n\t\t\tmatch = &LookupResult{decls, others};\n\t\t}\n\n\tdefault:\n\t\tillegal = true\n\t}\n\n\treturn;\n}", "func (o *OS) Lookup(key string) (interface{}, bool) {\n\treturn os.LookupEnv(key)\n}", "func (n *node) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (fs.Node, error) {\n\tvar requested string = req.Name\n\tp, nm := n.Path(), n.Name()\n\tfp, _ := filepath.Abs(filepath.Join(p, \"/\", nm))\n\ttail := n.Tail()\n\tif len(tail) > 0 {\n\t\tfor _, nn := range tail {\n\t\t\tif nn.Aliased() {\n\t\t\t\tif exists, ad := nn.Find(requested, n, nn); exists {\n\t\t\t\t\tswitch ad.Is() {\n\t\t\t\t\tcase Directory:\n\t\t\t\t\t\tad.SetPath(fp)\n\t\t\t\t\t\treturn ad, nil\n\t\t\t\t\tcase File, Fileio:\n\t\t\t\t\t\taf := NewNodeFile(ad)\n\t\t\t\t\t\taf.InitializeFile(fp, n)\n\t\t\t\t\t\treturn af, nil\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif nn.Name() == requested {\n\t\t\t\tswitch nn.Is() {\n\t\t\t\tcase Directory:\n\t\t\t\t\tnn.InitializeDir(fp, n)\n\t\t\t\t\treturn nn, nil\n\t\t\t\tcase File, Fileio, Socket:\n\t\t\t\t\tf := NewNodeFile(nn)\n\t\t\t\t\tf.InitializeFile(fp, n)\n\t\t\t\t\treturn f, nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil, fuse.ENOENT\n}", "func (bol Boolean) Find(path Ref) (Value, error) {\n\tif len(path) == 0 {\n\t\treturn bol, nil\n\t}\n\treturn nil, errFindNotFound\n}", "func (l *GroupLookup) Lookup(key flux.GroupKey) (interface{}, bool) {\n\tif key == nil || len(l.groups) == 0 {\n\t\treturn nil, false\n\t}\n\n\tgroup := l.lookupGroup(key)\n\tif group == -1 {\n\t\treturn nil, false\n\t}\n\n\ti := l.groups[group].Index(key)\n\tif i != -1 {\n\t\treturn l.groups[group].At(i), true\n\t}\n\treturn nil, false\n}", "func (d *Directory) Entry(name string) *DirectoryEntry {\n\tfor _, e := range d.Entries {\n\t\tif e.Path == name {\n\t\t\treturn e\n\t\t}\n\t}\n\treturn nil\n}", "func (c *Client) lookup(op errors.Op, entry *upspin.DirEntry, fn lookupFn, followFinal bool, s *metric.Span) (resultEntry, finalSuccessfulEntry *upspin.DirEntry, err error) {\n\tss := s.StartSpan(\"lookup\")\n\tdefer ss.End()\n\n\t// As we run, we want to maintain the incoming DirEntry to track the name,\n\t// leaving the rest alone. As the fn will return a newly allocated entry,\n\t// after each link we update the entry to achieve this.\n\toriginalName := entry.Name\n\tvar prevEntry *upspin.DirEntry\n\tcopied := false // Do we need to allocate a new entry to modify its name?\n\tfor loop := 0; loop < upspin.MaxLinkHops; loop++ {\n\t\tparsed, err := path.Parse(entry.Name)\n\t\tif err != nil {\n\t\t\treturn nil, nil, errors.E(op, err)\n\t\t}\n\t\tdir, err := c.DirServer(parsed.Path())\n\t\tif err != nil {\n\t\t\treturn nil, nil, errors.E(op, err)\n\t\t}\n\t\tresultEntry, err := fn(dir, entry, ss)\n\t\tif err == nil {\n\t\t\treturn resultEntry, entry, nil\n\t\t}\n\t\tif prevEntry != nil && errors.Is(errors.NotExist, err) {\n\t\t\treturn resultEntry, nil, errors.E(op, errors.BrokenLink, prevEntry.Name, err)\n\t\t}\n\t\tprevEntry = resultEntry\n\t\tif err != upspin.ErrFollowLink {\n\t\t\treturn resultEntry, nil, errors.E(op, originalName, err)\n\t\t}\n\t\t// Misbehaving servers could return a nil entry. Handle that explicitly. Issue 451.\n\t\tif resultEntry == nil {\n\t\t\treturn nil, nil, errors.E(op, errors.Internal, prevEntry.Name, \"server returned nil entry for link\")\n\t\t}\n\t\t// We have a link.\n\t\t// First, allocate a new entry if necessary so we don't overwrite user's memory.\n\t\tif !copied {\n\t\t\ttmp := *entry\n\t\t\tentry = &tmp\n\t\t\tcopied = true\n\t\t}\n\t\t// Take the prefix of the result entry and substitute that section of the existing name.\n\t\tparsedResult, err := path.Parse(resultEntry.Name)\n\t\tif err != nil {\n\t\t\treturn nil, nil, errors.E(op, err)\n\t\t}\n\t\tresultPath := parsedResult.Path()\n\t\t// The result entry's name must be a prefix of the name we're looking up.\n\t\tif !strings.HasPrefix(parsed.String(), string(resultPath)) {\n\t\t\treturn nil, nil, errors.E(op, resultPath, errors.Internal, \"link path not prefix\")\n\t\t}\n\t\t// Update the entry to have the new Name field.\n\t\tif resultPath == parsed.Path() {\n\t\t\t// We're on the last element. We may be done.\n\t\t\tif followFinal {\n\t\t\t\tentry.Name = resultEntry.Link\n\t\t\t} else {\n\t\t\t\t// Yes, we are done. Return this entry, which is a link.\n\t\t\t\treturn resultEntry, entry, nil\n\t\t\t}\n\t\t} else {\n\t\t\tentry.Name = path.Join(resultEntry.Link, string(parsed.Path()[len(resultPath):]))\n\t\t}\n\t}\n\treturn nil, nil, errors.E(op, errors.IO, originalName, \"link loop\")\n}", "func (l *RandomAccessGroupLookup) Lookup(key flux.GroupKey) (interface{}, bool) {\n\tid := l.idForKey(key)\n\te, ok := l.index[string(id)]\n\tif !ok || e.Deleted {\n\t\treturn nil, false\n\t}\n\treturn e.Value, true\n}", "func (d *Driver) Lookup(id string) ([]byte, error) {\n\td.lockfile.Lock()\n\tdefer d.lockfile.Unlock()\n\n\tsecretData, err := d.getAllData()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif data, ok := secretData[id]; ok {\n\t\treturn data, nil\n\t}\n\treturn nil, fmt.Errorf(\"%s: %w\", id, errNoSecretData)\n}", "func (n *Node) Lookup(ctx context.Context, name string) (fs.Node, error) {\n\tlog.Println(\"Lookup\", name)\n\tnode, ok := n.fs.Nodes[name]\n\tif ok {\n\t\treturn node, nil\n\t}\n\treturn nil, fuse.ENOENT\n}", "func (t *targetCache) Get(path string) *dep.ResolvedTarget {\n\tt.mu.Lock()\n\tdefer t.mu.Unlock()\n\treturn t.data[path]\n}", "func findEntry(t *testing.T, ms *yang.Modules, moduleName, path string) *yang.Entry {\n\tt.Helper()\n\tmodule, errs := ms.GetModule(moduleName)\n\tif errs != nil {\n\t\tt.Fatalf(\"error getting module %q: %v\", moduleName, errs)\n\t}\n\tif path == \"\" {\n\t\treturn module\n\t}\n\tentry := module.Find(path)\n\tif entry == nil {\n\t\tt.Fatalf(\"error getting entry %q in module %q\", path, moduleName)\n\t}\n\treturn entry\n}", "func (db *DB) Lookup(addr net.IP, result interface{}) error {\n\tdb.mu.RLock()\n\tdefer db.mu.RUnlock()\n\tif db.reader != nil {\n\t\treturn db.reader.Lookup(addr, result)\n\t}\n\treturn ErrUnavailable\n}", "func (tree *Tree) Get(key interface{}) (value interface{}, found bool) {\n\tnode := tree.lookup(key)\n\tif node != nil {\n\t\treturn node.Value, true\n\t}\n\treturn nil, false\n}", "func (m *LineMap) Contains(name string) bool {\n\tif m.lookup == nil {\n\t\treturn false\n\t}\n\n\tname = strings.ToLower(name)\n\n\t_, exists := m.lookup[name]\n\treturn exists\n}", "func lookup(name string, context ...interface{}) (interface{}, bool) {\n\t// If the dot notation was used we split the word in two and perform two\n\t// consecutive lookups. If the first one fails we return no value and a\n\t// negative truth. Taken from github.com/hoisie/mustache.\n\tif name != \".\" && strings.Contains(name, \".\") {\n\t\tparts := strings.SplitN(name, \".\", 2)\n\t\tif value, ok := lookup(parts[0], context...); ok {\n\t\t\treturn lookup(parts[1], value)\n\t\t}\n\t\treturn nil, false\n\t}\n\t// Iterate over the context chain and try to match the name to a value.\n\tfor _, c := range context {\n\t\t// Reflect on the value of the current context.\n\t\treflectValue := reflect.ValueOf(c)\n\t\tresult, isTruth := lookupReflectValue(name, reflectValue)\n\t\tif result != nil {\n\t\t\treturn result, isTruth\n\t\t}\n\t\t// If by this point no value was matched, we'll move up a step in the\n\t\t// chain and try to match a value there.\n\t}\n\t// We've exhausted the whole context chain and found nothing. Return a nil\n\t// value and a negative truth.\n\treturn nil, false\n}", "func (r *UIRegistry) Lookup(name string) (webutil.DataSource, error) {\n\n\tr.rwmu.RLock()\n\tdefer r.rwmu.RUnlock()\n\n\tif ret, ok := r.reg[name]; ok {\n\t\treturn ret.DataSource, nil\n\t}\n\n\treturn nil, ErrNotFound\n}", "func (d *Dir) Lookup(ctx context.Context, name string) (fs.Node, error) {\n\t// fmt.Printf(\"doing lookup of dir at inode %d\\n\", d.inodeNum)\n\tvar offset uint64 = 0\n\ttableData, err := d.inode.readFromData(offset, d.inode.Size)\n\tif err != nil {\n\t\tfmt.Println(\"VERY BAD error doing readFromData from offset 0 in Lookup \" + err.Error())\n\t}\n\ttable := new(InodeTable)\n\ttable.UnmarshalBinary(tableData)\n\tinodeNum := table.Table[name]\n\tif inodeNum == 0 {\n\t\treturn nil, fuse.ENOENT\n\t} else {\n\t\tinode, err := getInode(inodeNum)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"VERY BAD error doing getInode on existing entry in Lookup: \" + err.Error())\n\t\t}\n\t\tvar child fs.Node\n\t\tif inode.IsDir == 1 {\n\t\t\tchild = &Dir{\n\t\t\t\tinode: inode,\n\t\t\t\tinodeNum: inodeNum,\n\t\t\t\tinodeStream: d.inodeStream,\n\t\t\t}\n\t\t} else {\n\t\t\tchild = &File{\n\t\t\t\tinode: inode,\n\t\t\t\tinodeNum: inodeNum,\n\t\t\t\tinodeStream: d.inodeStream,\n\t\t\t}\n\t\t}\n\t\treturn child, nil\n\t}\n}", "func (c *cache) Retrieve(key, dest string, mode os.FileMode) bool {\n\tsrc := c.path(key)\n\tif err := c.copier.LinkMode(src, dest, mode); err == nil {\n\t\treturn true\n\t} else if !os.IsNotExist(err) {\n\t\tlog.Warning(\"Failed to retrieve %s from cache: %s\", key, err)\n\t\treturn false\n\t}\n\treturn false\n}", "func (c *ldcache) Lookup(libPrefixes ...string) ([]string, []string) {\n\tc.logger.Debugf(\"Looking up %v in cache\", libPrefixes)\n\n\t// We define a functor to check whether a given library name matches any of the prefixes\n\tmatchesAnyPrefix := func(s string) bool {\n\t\tfor _, p := range libPrefixes {\n\t\t\tif strings.HasPrefix(s, p) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\treturn false\n\t}\n\n\treturn c.resolveSelected(matchesAnyPrefix)\n}", "func (bf NaiveBloomFilter) Lookup(entry string) (bool, error) {\n\thashes := hashEntry([]byte(entry), bf.hf)\n\tfor i := 0; i < bf.hf; i++ {\n\t\tlookup_idx := hashes[i] & (bf.size - 1)\n\t\tif exists, err := bf.getByte(lookup_idx); !exists {\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\t\t\treturn false, nil\n\t\t}\n\t}\n\treturn true, nil\n}", "func (a *addrBook) Lookup(addr p2pcrypto.PublicKey) (*node.Info, error) {\n\ta.mtx.Lock()\n\td := a.lookup(addr)\n\ta.mtx.Unlock()\n\tif d == nil {\n\t\t// Todo: just return empty without error ?\n\t\treturn nil, ErrLookupFailed\n\t}\n\treturn d.na, nil\n}", "func (t *trieNode) Lookup(path string) HandlerFuncs {\n\tfor _, i := range t.childs {\n\t\tif strings.HasPrefix(path, i.path) {\n\t\t\treturn HandlerFuncsCombine(t.vals, i.Lookup(path[len(i.path):]))\n\t\t}\n\t}\n\treturn t.vals\n}", "func Lookup(key string) (string, bool) { return os.LookupEnv(key) }", "func (h *Hosts) Lookup(host string) (ip net.IP) {\n\tif h == nil || host == \"\" {\n\t\treturn\n\t}\n\n\th.mux.RLock()\n\tdefer h.mux.RUnlock()\n\n\tfor _, h := range h.hosts {\n\t\tif h.Hostname == host {\n\t\t\tip = h.IP\n\t\t\tbreak\n\t\t}\n\t\tfor _, alias := range h.Aliases {\n\t\t\tif alias == host {\n\t\t\t\tip = h.IP\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tif ip != nil && Debug {\n\t\tlog.Logf(\"[hosts] hit: %s %s\", host, ip.String())\n\t}\n\treturn\n}", "func (cf *CFilter) Lookup(item []byte) bool {\n\tf := fprint(item, cf.fpSize, cf.hashfn)\n\tj := hashfp(item) % cf.size\n\tk := (j ^ hashfp(f)) % cf.size\n\n\treturn cf.buckets[j].lookup(f) || cf.buckets[k].lookup(f)\n}", "func Lookup(configPath string, key string) ([]string, error) {\n\tout, _, err := checkedRun(exec.Command(\"sshd\", \"-T\", \"-f\", configPath))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to fetch effective config: %w\", err)\n\t}\n\n\t// sshd -T prints out lowercase options\n\tkey = strings.ToLower(key)\n\n\tlineRegexp := regexp.MustCompile(fmt.Sprintf(\"(?m)^%s (.*)$\", regexp.QuoteMeta(key)))\n\tvalues := lineRegexp.FindAllSubmatch(out, -1)\n\tret := make([]string, 0, len(values))\n\tfor _, value := range values {\n\t\tret = append(ret, string(value[1]))\n\t}\n\n\treturn ret, nil\n}", "func (t *Tree) Get(k []byte) ([]byte, bool) {\n\tif t.root == nil {\n\t\treturn nil, false\n\t}\n\treturn t.root.lookup(t, k)\n}", "func passthruLookup(name string) (string, bool) {\n\treturn \"\", false\n}", "func (n *node) Lookup(ctx context.Context, name string) (fspkg.Node, error) {\n\te, ok := n.te.LookupChild(name)\n\tif !ok {\n\t\treturn nil, syscall.ENOENT\n\t}\n\treturn &node{n.fs, e}, nil\n}" ]
[ "0.6632723", "0.6526417", "0.6502644", "0.6502644", "0.6448711", "0.6315723", "0.6277328", "0.6253912", "0.6245476", "0.6245476", "0.62231034", "0.6216919", "0.62092924", "0.6153425", "0.61027765", "0.6026127", "0.5986551", "0.59215796", "0.590627", "0.59048736", "0.5899805", "0.5864351", "0.584182", "0.58093536", "0.57999676", "0.5790596", "0.57542366", "0.5748702", "0.57421", "0.573438", "0.572914", "0.57217675", "0.57170194", "0.570233", "0.5701344", "0.5694191", "0.5689627", "0.5686498", "0.5679511", "0.5666625", "0.5665369", "0.5636752", "0.5633946", "0.5629517", "0.561042", "0.56100714", "0.55981755", "0.55961305", "0.55937165", "0.55909634", "0.5588873", "0.5579958", "0.5579237", "0.55689985", "0.55615747", "0.55557156", "0.5540026", "0.55290455", "0.5529007", "0.5516171", "0.5503529", "0.548569", "0.54795367", "0.54763424", "0.54752266", "0.54456234", "0.543484", "0.54253966", "0.5424694", "0.5422999", "0.5416094", "0.54077864", "0.5405564", "0.5401575", "0.5391069", "0.53824", "0.53783137", "0.53781563", "0.536635", "0.5362566", "0.53393525", "0.53381056", "0.533249", "0.53299534", "0.5327155", "0.5311993", "0.53061086", "0.5300892", "0.53003925", "0.5287179", "0.5282314", "0.52813387", "0.526579", "0.5250867", "0.5233717", "0.5223714", "0.5218517", "0.5217978", "0.5213142", "0.51981103" ]
0.72718596
0
Path returns the path of the currently scanned entry.
Path возвращает путь текущего сканируемого элемента.
func (s *DirScanner) Path() string { return s.path }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (e *entry) Path() string {\n\treturn e.path\n}", "func (fi *fileInfo) Path() string {\n\treturn fi.fullPath\n}", "func Path() string {\n\treturn c.Path\n}", "func (r *readerWithStats) Path() string {\n\treturn r.r.Path()\n}", "func (i *Instance) Path() (string, error) {\n\tref, _, _, err := i.GetAsAny(WmiPathKey)\n\treturn ref.(string), err\n}", "func (i *Image) Path() string {\n\treturn i.p\n}", "func (i *Index) Path() string { return i.path }", "func (d *InfoOutput) Path() string {\n\tval := d.reply[\"path\"]\n\n\treturn val.(string)\n\n}", "func (i *Inode) Path() string {\n\treturn i.path\n}", "func (f *File) Path() string {\n\treturn \"/\" + f.key\n}", "func (t *TreeEntry) GetPath() string {\n\tif t == nil || t.Path == nil {\n\t\treturn \"\"\n\t}\n\treturn *t.Path\n}", "func (tb *Table) Path() string {\n\treturn tb.path\n}", "func (c *FileConfigReader) Path() string {\n\treturn c.path\n}", "func (me *Image) Path() string {\n\treturn me.key.path\n}", "func (f *IndexFile) Path() string { return f.path }", "func (f *File) Path() string {\n\treturn f.path\n}", "func Path() string { return out }", "func (s *SimpleHealthCheck) Path() string {\n\treturn s.path\n}", "func (p *SeriesPartition) Path() string { return p.path }", "func (s *Store) Path() string { return s.path }", "func (s *Store) Path() string { return s.path }", "func (l *Clog) Path() string {\n\treturn l.path\n}", "func (fc *FileCache) Path() string {\n\treturn fc.path\n}", "func (o ApplicationStatusHistorySourcePtrOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ApplicationStatusHistorySource) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Path\n\t}).(pulumi.StringPtrOutput)\n}", "func (o ArgoCDSpecPrometheusIngressPtrOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ArgoCDSpecPrometheusIngress) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Path\n\t}).(pulumi.StringPtrOutput)\n}", "func (r *ManagerResource) Path() string {\n\treturn r.path\n}", "func (f File) Path() string {\n\treturn string(f)\n}", "func (f *LogFile) Path() string { return f.path }", "func (o ApplicationSpecSourcePtrOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ApplicationSpecSource) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Path\n\t}).(pulumi.StringPtrOutput)\n}", "func (d *Document) Path() string {\n\treturn d.path\n}", "func (f *Flock) Path() string {\n\treturn f.path\n}", "func (j *Jail) Path() string {\n\treturn j.path\n}", "func (id ID) Path() string {\n\treturn id.path\n}", "func (s *switchPortAllocations) Path() string {\n\treturn s.path\n}", "func (s *Store) Path() string {\n\treturn s.path\n}", "func (s *Store) Path() string {\n\treturn s.path\n}", "func (o ApplicationStatusSyncComparedToSourcePtrOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ApplicationStatusSyncComparedToSource) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Path\n\t}).(pulumi.StringPtrOutput)\n}", "func (m *Resource) Path() string {\n\treturn m.path\n}", "func (a ArithmeticPage) GetPath() string {\n\treturn a.Common.Path\n}", "func (m *mountPoint) Path() string {\n\tif m.Volume != nil {\n\t\treturn m.Volume.Path()\n\t}\n\n\treturn m.Source\n}", "func (o ApplicationStatusHistorySourceOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationStatusHistorySource) *string { return v.Path }).(pulumi.StringPtrOutput)\n}", "func (ge *GollumEvent) Path() string {\n\treturn \"\"\n}", "func (ctx *Context) Path() string {\r\n\treturn ctx.R.URL.Path\r\n}", "func (a *Address) Path() string {\n\treturn a.path\n}", "func (item *baseItem) Path() *proto.Path {\n\treturn &item.path\n}", "func (jm JSONMeta) Path() string {\n\tsb := make([]string, 0)\n\tvar c JSONMetaNode = jm\n\tfor c != nil {\n\t\tsb = append([]string{c.Key()}, sb...)\n\t\t// Prepend a \".\" for non-index segments.\n\t\tif _, ok := c.Parent().(JSONMetaContainerNode); ok {\n\t\t\tsb = append([]string{\".\"}, sb...)\n\t\t}\n\t\tc = c.Parent()\n\t}\n\n\treturn strings.TrimLeft(strings.Join(sb, \"\"), \".\")\n}", "func (t *Tailer) getPath() string {\n\treturn t.path\n}", "func (o ArgoCDSpecPrometheusIngressOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ArgoCDSpecPrometheusIngress) *string { return v.Path }).(pulumi.StringPtrOutput)\n}", "func (app *Application) Path() dbus.ObjectPath {\n\treturn app.config.ObjectPath\n}", "func (c ArtifactConfig) Path() string {\n\treturn c.File\n}", "func (metadata EventMetadata) GetPath() (string, error) {\n\tpath, err := os.Readlink(\n\t\tfilepath.Join(\n\t\t\tProcFsFdInfo,\n\t\t\tstrconv.FormatUint(\n\t\t\t\tuint64(metadata.Fd),\n\t\t\t\t10,\n\t\t\t),\n\t\t),\n\t)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"fanotify: %w\", err)\n\t}\n\n\treturn path, nil\n}", "func (s *Database) Path() string {\n\treturn s.dbFile\n}", "func (b *Bucket) Path() (string, error) {\n\tconf := b.conf.Viper.ConfigFileUsed()\n\tif conf == \"\" {\n\t\treturn b.cwd, nil\n\t}\n\treturn filepath.Dir(filepath.Dir(conf)), nil\n}", "func (db *DB) Path() string {\n\treturn db.path\n}", "func (db *DB) Path() string {\n\treturn db.path\n}", "func (e *Entry) realPath() string {\n\tparts := make([]string, 1, len(e.path)+1)\n\tparts[0] = e.root.realPath\n\tparts = append(parts, e.path...)\n\treturn filepath.Join(parts...)\n}", "func (o ApplicationStatusSyncComparedToSourceOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationStatusSyncComparedToSource) *string { return v.Path }).(pulumi.StringPtrOutput)\n}", "func (o LocalCopyPtrOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *LocalCopy) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.Path\n\t}).(pulumi.StringPtrOutput)\n}", "func (blt Bolt) Path() string {\n\treturn blt.path\n}", "func (i Import) Path() string {\n\treturn i.path\n}", "func (s *K8s) Path() string {\n\treturn s.moduleDir\n}", "func (o ArgoCDSpecGrafanaIngressPtrOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ArgoCDSpecGrafanaIngress) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Path\n\t}).(pulumi.StringPtrOutput)\n}", "func (me *inode) GetPath() (path string, mount *mountData) {\n\tme.mount.treeLock.RLock()\n\tdefer me.mount.treeLock.RUnlock()\n\t\t\n\tif me.NodeId != FUSE_ROOT_ID && me.Parent == nil {\n\t\t// Deleted node. Treat as if the filesystem was unmounted.\n\t\treturn \".deleted\", nil\n\t}\n\n\trev_components := make([]string, 0, 10)\n\tinode := me\n\n\tfor ; inode != nil && inode.mountPoint == nil; inode = inode.Parent {\n\t\trev_components = append(rev_components, inode.Name)\n\t}\n\tif inode == nil {\n\t\tpanic(fmt.Sprintf(\"did not find parent with mount: %v\", rev_components))\n\t}\n\tmount = inode.mountPoint\n\n\tif mount.unmountPending {\n\t\treturn \"\", nil\n\t}\n\treturn ReverseJoin(rev_components, \"/\"), mount\n}", "func (o ApplicationSpecSourceOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationSpecSource) *string { return v.Path }).(pulumi.StringPtrOutput)\n}", "func (c *CodeResult) GetPath() string {\n\tif c == nil || c.Path == nil {\n\t\treturn \"\"\n\t}\n\treturn *c.Path\n}", "func (e *Element) Path() string {\n\tif e.Parent == nil {\n\t\treturn \"root\"\n\t}\n\treturn e.Parent.Path() + \".\" + e.name\n}", "func (o AppTemplateContainerStartupProbeOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v AppTemplateContainerStartupProbe) *string { return v.Path }).(pulumi.StringPtrOutput)\n}", "func (s *sysCC) Path() string {\n\treturn s.path\n}", "func (o ArgoCDSpecServerIngressPtrOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ArgoCDSpecServerIngress) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Path\n\t}).(pulumi.StringPtrOutput)\n}", "func (o ApplicationStatusSyncComparedToSourceHelmFileParametersOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationStatusSyncComparedToSourceHelmFileParameters) *string { return v.Path }).(pulumi.StringPtrOutput)\n}", "func (l *logPipe) Path() string {\n\treturn l.path\n}", "func (d *device) GetPath() string {\n\tif d.parent == nil {\n\t\treturn d.class.ToString() + \"=\" + d.name\n\n\t}\n\treturn d.parent.GetPath() + \",\" + d.class.ToString() + \"=\" + d.name\n}", "func (h Hashicorp) GetPath() string {\n\treturn h.FilePath\n}", "func (i *Item) GetPath() string {\n\treturn i.folder.GetPath()\n}", "func (o ApplicationStatusOperationStateSyncResultSourceHelmFileParametersOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationStatusOperationStateSyncResultSourceHelmFileParameters) *string { return v.Path }).(pulumi.StringPtrOutput)\n}", "func (server *SingleInstance) Path() string {\n\treturn server.path\n}", "func (o AppTemplateContainerLivenessProbeOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v AppTemplateContainerLivenessProbe) *string { return v.Path }).(pulumi.StringPtrOutput)\n}", "func (k *Kluster) Path() string {\n\treturn k.path\n}", "func (o IopingSpecVolumeVolumeSourceProjectedSourcesSecretItemsOutput) Path() pulumi.StringOutput {\n\treturn o.ApplyT(func(v IopingSpecVolumeVolumeSourceProjectedSourcesSecretItems) string { return v.Path }).(pulumi.StringOutput)\n}", "func (o ApplicationStatusOperationStateSyncResultSourcePtrOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ApplicationStatusOperationStateSyncResultSource) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Path\n\t}).(pulumi.StringPtrOutput)\n}", "func (o LookupContentResultOutput) Path() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LookupContentResult) string { return v.Path }).(pulumi.StringOutput)\n}", "func (file *File) Path() string {\n\treturn filepath.Join(file.dir, file.name)\n}", "func (o ApplicationStatusOperationStateSyncResultSourceOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationStatusOperationStateSyncResultSource) *string { return v.Path }).(pulumi.StringPtrOutput)\n}", "func (o GetAppTemplateContainerStartupProbeOutput) Path() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetAppTemplateContainerStartupProbe) string { return v.Path }).(pulumi.StringOutput)\n}", "func (o ApplicationStatusHistorySourceHelmFileParametersOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationStatusHistorySourceHelmFileParameters) *string { return v.Path }).(pulumi.StringPtrOutput)\n}", "func (t reqInfo) Path() string {\n\treturn t.path\n}", "func (d Document) Path() string { return d.path }", "func (tc *TrafficCapture) Path() (string, error) {\n\ttc.RLock()\n\tdefer tc.RUnlock()\n\n\treturn tc.writer.Path()\n}", "func (o ArgoCDSpecServerGrpcIngressPtrOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ArgoCDSpecServerGrpcIngress) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Path\n\t}).(pulumi.StringPtrOutput)\n}", "func (o ArgoCDSpecGrafanaIngressOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ArgoCDSpecGrafanaIngress) *string { return v.Path }).(pulumi.StringPtrOutput)\n}", "func (o ArgoCDSpecServerIngressOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ArgoCDSpecServerIngress) *string { return v.Path }).(pulumi.StringPtrOutput)\n}", "func (k *Key) path() (string, error) {\n\tusr, err := user.Current()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get current user\")\n\t}\n\treturn path.Join(usr.HomeDir, *identity), nil\n}", "func (o ApplicationSpecSourceHelmFileParametersOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationSpecSourceHelmFileParameters) *string { return v.Path }).(pulumi.StringPtrOutput)\n}", "func (o ApplicationStatusOperationStateOperationSyncSourceHelmFileParametersOutput) Path() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ApplicationStatusOperationStateOperationSyncSourceHelmFileParameters) *string { return v.Path }).(pulumi.StringPtrOutput)\n}", "func (l *ActivityLogger) GetPath() string {\n\treturn l.fullName\n}", "func (o FioSpecVolumeVolumeSourceProjectedSourcesSecretItemsOutput) Path() pulumi.StringOutput {\n\treturn o.ApplyT(func(v FioSpecVolumeVolumeSourceProjectedSourcesSecretItems) string { return v.Path }).(pulumi.StringOutput)\n}", "func (o GetAppTemplateContainerLivenessProbeOutput) Path() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetAppTemplateContainerLivenessProbe) string { return v.Path }).(pulumi.StringOutput)\n}", "func (a Asset) Path() string {\n\treturn a.path\n}", "func (c *Client) Path() string {\n\tc.mu.RLock()\n\tdefer c.mu.RUnlock()\n\treturn c.path\n}", "func (u *URL) Path() string {\n\treturn u.URL.Path\n}" ]
[ "0.814329", "0.7101329", "0.6913344", "0.69013375", "0.6842367", "0.67836183", "0.673894", "0.67302", "0.6706463", "0.66323745", "0.6622492", "0.66114634", "0.6606461", "0.6588219", "0.6560654", "0.6534897", "0.65255404", "0.64959705", "0.6493998", "0.6484852", "0.6484852", "0.6480952", "0.64791065", "0.6474006", "0.6472362", "0.6470495", "0.6456069", "0.64504117", "0.64485806", "0.6438598", "0.64326", "0.6429744", "0.6428604", "0.6427308", "0.6417613", "0.6417613", "0.639873", "0.6393157", "0.63913786", "0.6385903", "0.638221", "0.6381541", "0.6375266", "0.6371166", "0.6358777", "0.6340626", "0.63370097", "0.63345754", "0.6323069", "0.63151795", "0.6309286", "0.62993133", "0.6289948", "0.6289426", "0.6289426", "0.62867504", "0.6279521", "0.6267063", "0.6264103", "0.6263455", "0.62629133", "0.62521684", "0.62502146", "0.62500405", "0.62463236", "0.6244957", "0.6239437", "0.6239019", "0.6238636", "0.622883", "0.6220031", "0.62171376", "0.6213033", "0.621124", "0.620621", "0.61993486", "0.6196375", "0.6193965", "0.61857116", "0.6182239", "0.61813706", "0.61771613", "0.61744237", "0.6174001", "0.6152367", "0.6151474", "0.6148273", "0.61421144", "0.61358565", "0.61280173", "0.6125839", "0.61179817", "0.61144024", "0.6106682", "0.6105979", "0.6091786", "0.60851574", "0.6082825", "0.60772157", "0.60766715" ]
0.7185758
1
File returns the file of the currently scanned entry.
Файл возвращает файл текущей отсканированной записи.
func (s *DirScanner) File() reflow.File { return s.contents[s.path] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m Matcher) File() File { return File{} }", "func (cfg *Configuration) File() string {\n\treturn cfg.FilePath\n}", "func (c *Config) File() string {\n\tif c == nil || c.mx == nil {\n\t\treturn \"\"\n\t}\n\n\treturn c.file\n}", "func (pos *Position) File() string {\n\treturn *pos.file\n}", "func GetFile() string {\n\tfile, _ := GetFileNoByDepth(1)\n\treturn file\n}", "func (ref FileView) File() resource.ID {\n\treturn ref.file\n}", "func (err ErrPermission) File() File {\n\treturn err.file\n}", "func (k Key) File() string {\n\tif k.Type == PrivateKey {\n\t\treturn PrivateKeyFile(k.Usage, k.Version)\n\t}\n\treturn PublicKeyFile(k.Usage, k.IA, k.Version)\n}", "func (p *Post) File() string {\n\treturn fmt.Sprintf(\"%d%s\", p.Name, p.Extenstion)\n}", "func (c *CallerInfo) GetFile() string {\n\tif c.file != \"\" {\n\t\treturn c.file\n\t}\n\n\tc.file = trimGoPath(c.rawFile)\n\treturn c.file\n}", "func (c *Config) File() string { return c.viper.GetString(configFile) }", "func (sf *Associate) File() (f *os.File, err error) {\n\treturn sf.getUnderAssociate().File()\n}", "func (r *LocalRegistry) file() string {\n\treturn filepath.Join(core.RegistryPath(r.ArtHome), \"repository.json\")\n}", "func (p Pos) File() *File {\n\tif p.index() == 0 {\n\t\treturn nil\n\t}\n\treturn p.file\n}", "func (f Frame) File() string {\n\treturn f.tr.getStringDefault(f.file)\n}", "func (s *Store) getFile() string {\n\treturn s.File\n}", "func (f *Function) File() *File {\n\treturn f.file\n}", "func File(pass *analysis.Pass, pos token.Pos) *ast.File {\n\tfor _, f := range pass.Files {\n\t\tif f.Pos() <= pos && pos <= f.End() {\n\t\t\treturn f\n\t\t}\n\t}\n\treturn nil\n}", "func File(pass *analysis.Pass, pos token.Pos) *ast.File {\n\tfor _, f := range pass.Files {\n\t\tif f.Pos() <= pos && pos <= f.End() {\n\t\t\treturn f\n\t\t}\n\t}\n\treturn nil\n}", "func (f *Files) File(name string) string {\n\treturn filepath.Join(f.OutDir, name)\n}", "func GetFile() string {\n\treturn filename\n}", "func (err ErrAlreadyExists) File() File {\n\treturn err.file\n}", "func (o *ResourceVersion) GetFile() string {\n\tif o == nil || o.File == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.File\n}", "func (r *PebbleFileRegistry) GetFileEntry(filename string) *enginepb.FileEntry {\n\tfilename = r.tryMakeRelativePath(filename)\n\tr.mu.Lock()\n\tdefer r.mu.Unlock()\n\treturn r.mu.currProto.Files[filename]\n}", "func (o *InlineObject36) GetFile() map[string]interface{} {\n\tif o == nil {\n\t\tvar ret map[string]interface{}\n\t\treturn ret\n\t}\n\n\treturn o.File\n}", "func (err ErrIsNotDirectory) File() File {\n\treturn err.file\n}", "func (d *Download) File() *os.File {\r\n\treturn d.file\r\n}", "func (err ErrIsDirectory) File() File {\n\treturn err.file\n}", "func (conf blah) File() string {\n\treturn filepath.Join(configPath, defConfigFile)\n}", "func (c *common) GetFile() *FileDescriptor { return c.file }", "func (c *Client) File(name, version, path string) (string, error) {\n\tfile := \"\"\n\tfound := false\n\terr := c.read(name, version, func(name string, contents io.Reader) error {\n\t\tif !found && strings.TrimPrefix(name, \"package/\") == path {\n\t\t\tbuf := new(bytes.Buffer)\n\t\t\t_, err := buf.ReadFrom(contents)\n\t\t\tif err != nil {\n\t\t\t\treturn xerrors.Errorf(\"copy contents: %w\", err)\n\t\t\t}\n\t\t\tfile = buf.String()\n\t\t\tfound = true\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn \"\", xerrors.Errorf(\"read package contents: %w\", err)\n\t}\n\tif !found {\n\t\tlog.Printf(\"ERROR standard registry: file: not found: %v:%v@%v/%v\", c.Host, name, version, path)\n\t\treturn \"\", registry.ErrNotFound\n\t}\n\n\treturn file, nil\n}", "func (e Entry) Filename() (string, error) {\n\treturn e.df.Filename(e.name)\n}", "func (repo Repository) File(fileID resource.ID) drivestream.FileReference {\n\treturn File{\n\t\tdb: repo.db,\n\t\tfile: fileID,\n\t}\n}", "func FILE() string {\n\t_, file, _, _ := runtime.Caller(1)\n\treturn file\n}", "func (o *InlineObject1) GetFile() *os.File {\n\tif o == nil || o.File == nil {\n\t\tvar ret *os.File\n\t\treturn ret\n\t}\n\treturn *o.File\n}", "func (err ErrDoesNotExist) File() (file File, ok bool) {\n\tfile, ok = err.file.(File)\n\treturn file, ok\n}", "func (metadata EventMetadata) File() *os.File {\n\treturn os.NewFile(uintptr(metadata.Fd), \"\")\n}", "func (c *Changes) GetFile() string {\n\treturn c.File\n}", "func (s *SerializeFuncs) File() *gothicgo.File {\n\treturn s.F\n}", "func (l *logger) GetFile() fileLogger {\n\tl.RLock()\n\tdefer l.RUnlock()\n\treturn l.File\n}", "func (file BaseFile) getFile() interface{} {\n\treturn file.File\n}", "func (is *InputStream) GetFile() string {\n\treturn is.file\n}", "func (s *FileSet) File(p token.Pos) (f *File) {\n\tif p != token.NoPos {\n\t\tinnerf := s.FileSet.File(p)\n\t\tf = s.filemap[innerf]\n\t}\n\treturn\n}", "func (m *Magic) File(file string) (string, error) {\n\tif m.ptr == nil {\n\t\treturn \"\", ConnectionError\n\t}\n\n\tcf := C.CString(file)\n\tdefer C.free(unsafe.Pointer(cf))\n\n\tcr := C.magic_file(m.ptr, cf)\n\tif cr == nil {\n\t\treturn \"\", m.check()\n\t}\n\n\tr := C.GoString(cr)\n\tC.free(unsafe.Pointer(cr))\n\treturn r, nil\n}", "func (c *config) File(u *model.User, r *model.Repo, b *model.Build, f string) ([]byte, error) {\n\treturn c.FileRef(u, r, b.Commit, f)\n}", "func (fe *fileEntry) Name() string { return fe.name }", "func (*FileEntry) Kind() string {\n\treturn \"File\"\n}", "func (e *Entry) String() string {\n\treturn \"file.Entry(\" + e.fullPath() + \")\"\n}", "func (o EncryptionServicesPtrOutput) File() EncryptionServicePtrOutput {\n\treturn o.ApplyT(func(v *EncryptionServices) *EncryptionService {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.File\n\t}).(EncryptionServicePtrOutput)\n}", "func (f frame) file() string {\n\tfn := runtime.FuncForPC(f.pc())\n\tif fn == nil {\n\t\treturn \"unknown\"\n\t}\n\tfile, _ := fn.FileLine(f.pc())\n\treturn file\n}", "func mainFile(table *gosym.Table) (string, error) {\n\tmain := table.LookupFunc(\"main.main\")\n\tif main == nil {\n\t\treturn \"\", fmt.Errorf(\"not found\")\n\t}\n\tfile, _, fn := table.PCToLine(main.Entry)\n\tif fn == nil {\n\t\treturn \"\", fmt.Errorf(\"not found\")\n\t}\n\treturn file, nil\n}", "func (f Frame) file() string {\n\tfn := runtime.FuncForPC(f.pc())\n\tif fn == nil {\n\t\treturn \"unknown\"\n\t}\n\tfile, _ := fn.FileLine(f.pc())\n\treturn file\n}", "func File(flagset *flag.FlagSet) flag.Value {\n\treturn flagfile.File(flagset, loader)\n}", "func file(path string) string {\n\tf, err := filepath.Abs(slash(path))\n\tkit.E(err)\n\treturn f\n}", "func (t *FileTree) File(path file.Path) *file.Reference {\n\tif value, ok := t.pathToFileRef[path.ID()]; ok {\n\t\treturn &value\n\t}\n\treturn nil\n}", "func (f File) Path() string {\n\treturn string(f)\n}", "func (c *Config) File(stream string) (string, error) {\n\tkey, err := keyName(stream, \"file\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tt, err := template.New(\"filename\").Parse(c.v.GetString(key))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvar tpl bytes.Buffer\n\tif err := t.Execute(&tpl, c); err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn tpl.String(), nil\n}", "func Get(file string) *File {\n\tf := allFiles[file]\n\treturn &f\n}", "func (s *Scanner) CacheFile() string {\n\treturn filepath.Join(s.Tempdir, \"finder.cache\")\n}", "func GetFileForPatternMatch(ap *PagePattern, pm *PatternMatch) (*File, error) {\n\tif ap == nil {\n\t\treturn nil, errors.New(\"page pattern object cannot be nil\")\n\t}\n\n\tif pm == nil {\n\t\treturn nil, errors.New(\"pattern match cannot be nil\")\n\t}\n\n\tfile := File{}\n\tfile.EditOnGithub = ap.EditOnGithub\n\tfile.AddToMenu = ap.AddToMenu\n\tfile.MenuGroup = ap.MenuGroup\n\tfile.Template = ap.Template\n\tfile.SourceFile = pm.Path\n\n\tvar err error\n\n\tif file.Name, err = stringFromTemplate(ap.Name, pm); err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to parse name template: \\n\\t%s\", err.Error())\n\t} else if file.Path, err = stringFromTemplate(ap.Path, pm); err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to parse path template: \\n\\t%s\", err.Error())\n\t}\n\n\treturn &file, nil\n}", "func (o EncryptionServicesResponsePtrOutput) File() EncryptionServiceResponsePtrOutput {\n\treturn o.ApplyT(func(v *EncryptionServicesResponse) *EncryptionServiceResponse {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.File\n\t}).(EncryptionServiceResponsePtrOutput)\n}", "func (t *Table) Filename() string { return t.fd.Name() }", "func (f *IndexFile) Path() string { return f.path }", "func (o EndpointsResponsePtrOutput) File() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *EndpointsResponse) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.File\n\t}).(pulumi.StringPtrOutput)\n}", "func (fv *FileView) SelectedFile() string {\n\treturn filepath.Join(fv.DirPath, fv.SelFile)\n}", "func (r *Root) File(ctx context.Context, s blob.CAS) (*file.File, error) {\n\tif r.FileKey == \"\" {\n\t\treturn nil, ErrNoData\n\t}\n\tif s == nil {\n\t\ts = r.cas\n\t}\n\treturn file.Open(ctx, s, r.FileKey)\n}", "func (o EncryptionServicesOutput) File() EncryptionServicePtrOutput {\n\treturn o.ApplyT(func(v EncryptionServices) *EncryptionService { return v.File }).(EncryptionServicePtrOutput)\n}", "func (e *entry) Path() string {\n\treturn e.path\n}", "func (f *File) String() string {\n\treturn f.URI()\n}", "func getFile(chart *chart.Chart, name string) *chart.File {\n\tfor _, file := range chart.Files {\n\t\tif file.Name == name {\n\t\t\treturn file\n\t\t}\n\t}\n\treturn nil\n}", "func (e FileEvent) Object() File {\n\treturn e.File\n}", "func (c *client) File(u *model.User, r *model.Repo, b *model.Build, f string) ([]byte, error) {\n\tclient := c.newClientToken(u.Token)\n\tcfg, err := client.GetFile(r.Owner, r.Name, b.Commit, f)\n\treturn cfg, err\n}", "func (g *GitChartProvider) GetIndexFile() (*helmrepo.IndexFile, error) {\n\treturn g.index.IndexFile, nil\n}", "func (fdf ExfatFileDirectoryEntry) TypeName() string {\n\treturn \"File\"\n}", "func (o operator) GetFile(filename string) (types.FileInfo, error) {\n\treturn types.FileInfo{}, fmt.Errorf(\"%s doesn't implement GetFile yet\", operatorName)\n}", "func (w *fileLogger) currentFile() (*os.File, error) {\r\n\tif w.curFile == nil {\r\n\t\t//log.Println(\"Reopening file\")\r\n\t\tfile, err := os.OpenFile(w.file, os.O_APPEND|os.O_CREATE, 0777)\r\n\t\t//defer file.Close()\r\n\t\tif err != nil {\r\n\t\t\treturn nil, err\r\n\t\t}\r\n\t\tw.curFile = file\r\n\t}\r\n\treturn w.curFile, nil\r\n}", "func (e *Event) File() *File {\n\tif e.Type != \"file\" {\n\t\treturn nil\n\t}\n\tvar f File\n\n\tf.Event = *e\n\tif err := json.Unmarshal(e.ContentType, &f.ContentType); err != nil {\n\t\treturn nil\n\t}\n\tif err := json.Unmarshal(e.Name, &f.Name); err != nil {\n\t\treturn nil\n\t}\n\tif err := json.Unmarshal(e.URL, &f.URL); err != nil {\n\t\treturn nil\n\t}\n\tif err := internal.UnmarshalOptionalRawField(e.ThumbnailURL, &f.ThumbnailURL); err != nil {\n\t\treturn nil\n\t}\n\tif err := internal.UnmarshalOptionalRawField(e.Thumbnail2xURL, &f.Thumbnail2xURL); err != nil {\n\t\treturn nil\n\t}\n\tif err := internal.UnmarshalOptionalRawField(e.Width, &f.Width); err != nil {\n\t\treturn nil\n\t}\n\tif err := internal.UnmarshalOptionalRawField(e.Height, &f.Height); err != nil {\n\t\treturn nil\n\t}\n\tif err := internal.UnmarshalOptionalRawField(e.Size, &f.Size); err != nil {\n\t\treturn nil\n\t}\n\tif err := internal.UnmarshalOptionalRawField(e.AlternativeText, &f.AlternativeText); err != nil {\n\t\treturn nil\n\t}\n\n\treturn &f\n}", "func (e *Event) File() *File {\n\tif e.Type != \"file\" {\n\t\treturn nil\n\t}\n\tvar f File\n\n\tf.Event = *e\n\tif err := json.Unmarshal(e.ContentType, &f.ContentType); err != nil {\n\t\treturn nil\n\t}\n\tif err := json.Unmarshal(e.Name, &f.Name); err != nil {\n\t\treturn nil\n\t}\n\tif err := json.Unmarshal(e.URL, &f.URL); err != nil {\n\t\treturn nil\n\t}\n\tif err := internal.UnmarshalOptionalRawField(e.ThumbnailURL, &f.ThumbnailURL); err != nil {\n\t\treturn nil\n\t}\n\tif err := internal.UnmarshalOptionalRawField(e.Thumbnail2xURL, &f.Thumbnail2xURL); err != nil {\n\t\treturn nil\n\t}\n\tif err := internal.UnmarshalOptionalRawField(e.Width, &f.Width); err != nil {\n\t\treturn nil\n\t}\n\tif err := internal.UnmarshalOptionalRawField(e.Height, &f.Height); err != nil {\n\t\treturn nil\n\t}\n\tif err := internal.UnmarshalOptionalRawField(e.Size, &f.Size); err != nil {\n\t\treturn nil\n\t}\n\tif err := internal.UnmarshalOptionalRawField(e.AlternativeText, &f.AlternativeText); err != nil {\n\t\treturn nil\n\t}\n\n\treturn &f\n}", "func (game *Game) CurrentTrnFile() (string, error) {\n\tvar possibleMatches []string\n\n\tfiles, err := ioutil.ReadDir(game.Directory)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tfor _, f := range files {\n\t\tif ValidTrnFileName(f.Name()) {\n\t\t\tpossibleMatches = append(possibleMatches, f.Name())\n\t\t}\n\t}\n\n\tswitch {\n\tcase len(possibleMatches) == 0:\n\t\treturn \"\", errors.New(fmt.Sprintf(\"Could not find a trn file for %s\", game.Name))\n\tcase len(possibleMatches) > 1:\n\t\t// Take the shortest filename. Ugly, but we have no way to check for valid nation names yet\n\t\tsort.Sort(utility.ByLength(possibleMatches))\n\t}\n\n\treturn possibleMatches[0], nil\n}", "func (s *Drive) GetFile(sha256sum []byte) ([]byte, error) {\n\treturn nil, nil\n}", "func getInfile(filename string) *os.File {\n\tf, err := os.Open(filename)\n\tcheck(err)\n\treturn f\n}", "func (c *Contents) FilePath() string {\n\treturn c.filePath\n}", "func (f File) GetFile() (string, error) {\n\tpw := Password{Title: f.Title, Password: f.Password} // Password Struct\n\terr := pw.GetFileName() // Reading FileName from Password\n\n\t// If No Error\n\tif err == nil {\n\t\treturn IsExist(path.Join(FileLoc, pw.FileName))\n\t}\n\n\t// if err.Error() == \"wrong:password\" {\n\t// \treturn \"\", err\n\t// } // I can just comment it ou, as eventually it returns the same Error\n\treturn \"\", err\n}", "func (o EncryptionServicesResponseOutput) File() EncryptionServiceResponsePtrOutput {\n\treturn o.ApplyT(func(v EncryptionServicesResponse) *EncryptionServiceResponse { return v.File }).(EncryptionServiceResponsePtrOutput)\n}", "func GetSnapshotFile() string {\n\n\t_file := Get(\"SnapshotFile\")\n\tif _file == \"\" {\n\t\t_file = \"snapshot.bin\"\n\t}\n\n\t_absFile, err := filepath.Abs(_file)\n\tif err != nil {\n\t\tlog.Fatalf(\"[!] Failed to find real path of `%s` : %s\\n\", _file, err.Error())\n\t}\n\n\treturn _absFile\n\n}", "func (fp *OrgLinkParser) FilePath() string {\n\treturn fp.file\n}", "func (l *listener) ListenerFile() (*os.File, error) {\n\treturn l.rawl.File()\n}", "func (s *Store) File(id string) *File {\n\treturn NewFile(s, id)\n}", "func getFile(fileName string) string {\n\twd, _ := os.Getwd()\n\n\tif !strings.HasSuffix(wd, \"file\") {\n\t\twd += \"\"\n\t}\n\n\treturn wd + \"/\" + fileName\n}", "func (d *Directory) Entry(name string) *DirectoryEntry {\n\tfor _, e := range d.Entries {\n\t\tif e.Path == name {\n\t\t\treturn e\n\t\t}\n\t}\n\treturn nil\n}", "func (f *File) Path() string {\n\treturn f.path\n}", "func (f *File) Path() string {\n\treturn \"/\" + f.key\n}", "func (b *baseBuilder) GetFile() *FileBuilder {\n\tp := b.parent\n\tfor p != nil {\n\t\tif fb, ok := p.(*FileBuilder); ok {\n\t\t\treturn fb\n\t\t}\n\t\tp = p.GetParent()\n\t}\n\treturn nil\n}", "func mainfile() string {\n\tif m := stack.Main(); m != nil {\n\t\treturn m.File\n\t}\n\treturn \"\"\n}", "func (fi *fileInfo) Path() string {\n\treturn fi.fullPath\n}", "func Get() (*File, error) {\n\treturn GetSpecific(Path())\n}", "func (_this *InterventionReportBody) SourceFile() *string {\n\tvar ret *string\n\tvalue := _this.Value_JS.Get(\"sourceFile\")\n\tif value.Type() != js.TypeNull && value.Type() != js.TypeUndefined {\n\t\t__tmp := (value).String()\n\t\tret = &__tmp\n\t}\n\treturn ret\n}", "func (fi *fileInfo) Name() string { return fi.name }", "func (c Config) GetFile(flag int, perm os.FileMode, section, key string) (*os.File, error) {\n\ts, err := c.GetString(section, key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn os.OpenFile(s, flag, perm)\n}", "func (v *View) GetFile(uri protocol.DocumentURI) *File {\n\tv.mu.Lock()\n\tf, found := v.files[uri]\n\tif !found {\n\t\tf := &File{URI: uri}\n\t\tv.files[f.URI] = f\n\t}\n\tv.mu.Unlock()\n\treturn f\n}" ]
[ "0.67540044", "0.67068243", "0.6687292", "0.66767365", "0.66577923", "0.66560775", "0.66108453", "0.65874934", "0.65597", "0.65354407", "0.6456274", "0.64512724", "0.641237", "0.64050615", "0.63878703", "0.63815755", "0.6373724", "0.6353302", "0.6353302", "0.63308656", "0.632238", "0.63106114", "0.62690663", "0.625717", "0.62380433", "0.61436063", "0.61333", "0.61273396", "0.6125658", "0.6122991", "0.61161864", "0.6091069", "0.60845673", "0.6081382", "0.6068328", "0.60626817", "0.60019374", "0.5992227", "0.5986684", "0.5977449", "0.5946669", "0.59253716", "0.5919013", "0.5912656", "0.5910336", "0.5902827", "0.59025806", "0.58987755", "0.58714074", "0.58607066", "0.5847885", "0.58420944", "0.5841182", "0.57753104", "0.5731122", "0.5686133", "0.5673483", "0.566243", "0.5652536", "0.5645846", "0.5634637", "0.56319094", "0.5613513", "0.56006366", "0.55998594", "0.55879974", "0.55838954", "0.5559093", "0.5558037", "0.5551181", "0.5545485", "0.5467709", "0.5466408", "0.5451453", "0.5449991", "0.5442953", "0.54316777", "0.54316777", "0.54111594", "0.5409323", "0.5403663", "0.5394158", "0.5389561", "0.53875834", "0.53834015", "0.53811204", "0.5377937", "0.5375824", "0.5371819", "0.5370738", "0.5360627", "0.5335314", "0.53346926", "0.5330492", "0.5326442", "0.53219676", "0.5311891", "0.53079414", "0.5307171", "0.53061223" ]
0.7276619
0
Digest computes the digest for value v, given type t.
Digest вычисляет хэш для значения v, заданного типом t.
func Digest(v T, t *types.T) digest.Digest { w := Digester.NewWriter() WriteDigest(w, v, t) return w.Digest() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func WriteDigest(w io.Writer, v T, t *types.T) {\n\tif d, ok := v.(digester); ok {\n\t\tdigest.WriteDigest(w, d.Digest())\n\t\treturn\n\t}\n\n\tw.Write([]byte{t.Kind.ID()})\n\tswitch t.Kind {\n\tcase types.ErrorKind, types.BottomKind, types.RefKind:\n\t\tpanic(\"illegal type\")\n\tcase types.IntKind:\n\t\tvi := v.(*big.Int)\n\t\t// Bytes returns the normalized big-endian (i.e., free of a zero\n\t\t// prefix) representation of the absolute value of the integer.\n\t\tp := vi.Bytes()\n\t\tif len(p) == 0 {\n\t\t\t// This is the representation of \"0\"\n\t\t\treturn\n\t\t}\n\t\tif p[0] == 0 {\n\t\t\tpanic(\"big.Int byte representation is not normalized\")\n\t\t}\n\t\tif vi.Sign() < 0 {\n\t\t\tw.Write([]byte{0})\n\t\t}\n\t\tw.Write(p)\n\tcase types.FloatKind:\n\t\tw.Write([]byte(v.(*big.Float).Text('e', 10)))\n\tcase types.StringKind:\n\t\tio.WriteString(w, v.(string))\n\tcase types.BoolKind:\n\t\tif v.(bool) {\n\t\t\tw.Write(trueByte)\n\t\t} else {\n\t\t\tw.Write(falseByte)\n\t\t}\n\tcase types.FileKind:\n\t\tdigest.WriteDigest(w, v.(reflow.File).Digest())\n\tcase types.DirKind:\n\t\tdir := v.(Dir)\n\t\tfor scan := dir.Scan(); scan.Scan(); {\n\t\t\tio.WriteString(w, scan.Path())\n\t\t\tdigest.WriteDigest(w, scan.File().Digest())\n\t\t}\n\t// Filesets are digesters, so they don't need to be handled here.\n\tcase types.UnitKind:\n\tcase types.ListKind:\n\t\twriteLength(w, len(v.(List)))\n\t\tfor _, e := range v.(List) {\n\t\t\tWriteDigest(w, e, t.Elem)\n\t\t}\n\tcase types.MapKind:\n\t\tm := v.(*Map)\n\t\twriteLength(w, m.Len())\n\t\ttype kd struct {\n\t\t\tk T\n\t\t\td digest.Digest\n\t\t}\n\t\tkeys := make([]kd, 0, m.Len())\n\t\tfor _, entryp := range m.tab {\n\t\t\tfor entry := *entryp; entry != nil; entry = entry.Next {\n\t\t\t\tkeys = append(keys, kd{entry.Key, Digest(entry.Key, t.Index)})\n\t\t\t}\n\t\t}\n\t\t// Sort the map so that it produces a consistent digest. We sort\n\t\t// its keys by their digest because the values may not yet be\n\t\t// evaluated.\n\t\tsort.Slice(keys, func(i, j int) bool {\n\t\t\treturn keys[i].d.Less(keys[j].d)\n\t\t})\n\t\tfor _, k := range keys {\n\t\t\tWriteDigest(w, k.k, t.Index)\n\t\t\tWriteDigest(w, m.Lookup(k.d, k.k), t.Elem)\n\t\t}\n\tcase types.TupleKind:\n\t\twriteLength(w, len(t.Fields))\n\t\ttuple := v.(Tuple)\n\t\tfor i, f := range t.Fields {\n\t\t\tWriteDigest(w, tuple[i], f.T)\n\t\t}\n\tcase types.StructKind:\n\t\twriteLength(w, len(t.Fields))\n\t\ts := v.(Struct)\n\t\tkeys := make([]string, len(t.Fields))\n\t\tfor i, f := range t.Fields {\n\t\t\tkeys[i] = f.Name\n\t\t}\n\t\tsort.Strings(keys)\n\t\tfm := t.FieldMap()\n\t\tfor _, k := range keys {\n\t\t\tWriteDigest(w, s[k], fm[k])\n\t\t}\n\tcase types.ModuleKind:\n\t\twriteLength(w, len(t.Fields))\n\t\ts := v.(Module)\n\t\tkeys := make([]string, len(t.Fields))\n\t\tfor i, f := range t.Fields {\n\t\t\tkeys[i] = f.Name\n\t\t}\n\t\tsort.Strings(keys)\n\t\tfm := t.FieldMap()\n\t\tfor _, k := range keys {\n\t\t\tWriteDigest(w, s[k], fm[k])\n\t\t}\n\tcase types.SumKind:\n\t\tvariant := v.(*Variant)\n\t\tio.WriteString(w, variant.Tag)\n\t\tWriteDigest(w, variant.Elem, t.VariantMap()[variant.Tag])\n\tcase types.FuncKind:\n\t\tdigest.WriteDigest(w, v.(Func).Digest())\n\t}\n}", "func (q *Qsign) Digest(v interface{}) ([]byte, error) {\n\tbuf := new(bytes.Buffer)\n\n\tif q.prefixGenerator != nil {\n\t\tif _, err := buf.WriteString(q.prefixGenerator()); err != nil {\n\t\t\treturn buf.Bytes(), err\n\t\t}\n\t}\n\n\tvs := getStructValues(v)\n\n\tpairs := []string{}\n\tfor _, f := range vs {\n\t\tif !q.filter(f.name, f.value) {\n\t\t\tcontinue\n\t\t}\n\n\t\tvar buf strings.Builder\n\t\tbuf.WriteString(f.name)\n\t\tbuf.WriteString(q.connector)\n\t\tbuf.WriteString(f.value)\n\n\t\tpairs = append(pairs, buf.String())\n\t}\n\tconnected := strings.Join(pairs, q.delimiter)\n\tbuf.WriteString(connected)\n\n\tif q.suffixGenerator != nil {\n\t\tif _, err := buf.WriteString(q.suffixGenerator()); err != nil {\n\t\t\treturn buf.Bytes(), err\n\t\t}\n\t}\n\n\treturn buf.Bytes(), nil\n}", "func HashFromDigest(algo Type, digest Digest) Hash {\n\treturn HashFromSum(algo, digest[:])\n}", "func (o VirtualDatabaseStatusOutput) Digest() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v VirtualDatabaseStatus) *string { return v.Digest }).(pulumi.StringPtrOutput)\n}", "func (b SignDetail) Digest() (common.Hash, error) {\n\tvar hash common.Hash\n\tvar signFormatData apitypes.TypedData\n\tif err := json.Unmarshal([]byte(b.SignSchema.Schema), &signFormatData); err != nil {\n\t\treturn hash, err\n\t}\n\tparams, err := b.GetContractParams()\n\tif err != nil {\n\t\treturn hash, err\n\t}\n\tdata, err := buildTypedData(signFormatData, params)\n\n\tif err != nil {\n\t\treturn hash, err\n\t}\n\thash, err = crypto2.Keccak256HashEIP712(data)\n\treturn hash, err\n}", "func Hash(value int64) uint64 {\n\treturn FNVHash64(uint64(value))\n}", "func (t *Tree) Digest() *crypto.Digest { return t.dig }", "func (tc ScannerTestcase) Digest() claircore.Digest {\n\td, err := claircore.ParseDigest(tc.Hash)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn d\n}", "func (n *Node) Digest() ([]byte, error) {\n\t// HMAC(Nonce,Inputs[*]|(Cryptex||Secret||Marker))\n\thash := hmac.New(sha256.New, n.Nonce)\n\n\tfor _, input := range n.Inputs {\n\t\tif _, err := hash.Write(input); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tvar (\n\t\tdata []byte\n\t\terr error\n\t)\n\n\tswitch {\n\tcase n.cryptex != nil:\n\t\tdata, err = n.cryptex.Marshal()\n\tcase n.secret != nil:\n\t\tdata, err = n.secret.Marshal()\n\tcase n.Marker != nil:\n\t\tdata, err = n.Marker.Marshal()\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif _, err := hash.Write(data); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn hash.Sum(nil), nil\n}", "func HashOf(v Value) []byte {\n\treturn quad.HashOf(v)\n}", "func (o GetReposRepoTagOutput) Digest() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetReposRepoTag) string { return v.Digest }).(pulumi.StringOutput)\n}", "func (commit *Commit) Digest() []byte {\n\treturn commit.signingID.Hash(commit.signedRequest.GetRequest())\n}", "func (o VirtualDatabaseStatusPtrOutput) Digest() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *VirtualDatabaseStatus) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Digest\n\t}).(pulumi.StringPtrOutput)\n}", "func Hash(t *Token) (hash []byte) {\n var sum []byte\n\n // Compute the SHA1 sum of the Token\n {\n shasum := sha1.Sum([]byte(salt+string(*t)))\n copy(sum[:], shasum[:20])\n }\n\n // Encode the sum to hexadecimal\n hex.Encode(sum, sum)\n\n return\n}", "func DigestSize() int {\n\treturn sha256DigestSize\n}", "func (oc *OAuthConsumer) digest(key string, m string) string {\n\th := hmac.NewSHA1([]byte(key))\n\th.Write([]byte(m))\n\treturn base64encode(h.Sum())\n\n/*\ts := bytes.TrimSpace(h.Sum())\n\td := make([]byte, base64.StdEncoding.EncodedLen(len(s)))\n\tbase64.StdEncoding.Encode(d, s)\n\tds := strings.TrimSpace(bytes.NewBuffer(d).String())\n*/\n//\treturn ds\n\n}", "func (s *ShardMap) hash(v interface{}) int {\n\tswitch s.Type {\n\tcase \"string\":\n\t\tval, ok := v.(string)\n\t\tif !ok {\n\t\t\treturn -1\n\t\t}\n\n\t\thash := fnv.New32()\n\t\thash.Write([]byte(val))\n\t\treturn int(hash.Sum32() % NumShards)\n\tcase \"int32\":\n\t\t// Values that come as numbers in JSON are of type float64.\n\t\tval, ok := v.(float64)\n\t\tif !ok {\n\t\t\treturn -1\n\t\t}\n\n\t\treturn int(int32(val) % NumShards)\n\tdefault:\n\t\treturn -1\n\t}\n}", "func (b *Base) Digest(req *DigestReq) (*DigestResp, error) {\n\treturn nil, ErrFunctionNotSupported\n}", "func CalcDigest(obj Object, downloadRangeSize int64, algorithm string) ([] byte, error) {\n\th, err := newHash(algorithm)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t_, err = Download(obj, downloadRangeSize, h)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdigest := h.Sum(nil)\n\treturn digest, nil\n}", "func hash(t types.Type, x value) int {\n\tswitch x := x.(type) {\n\tcase bool:\n\t\tif x {\n\t\t\treturn 1\n\t\t}\n\t\treturn 0\n\tcase int:\n\t\treturn x\n\tcase int8:\n\t\treturn int(x)\n\tcase int16:\n\t\treturn int(x)\n\tcase int32:\n\t\treturn int(x)\n\tcase int64:\n\t\treturn int(x)\n\tcase uint:\n\t\treturn int(x)\n\tcase uint8:\n\t\treturn int(x)\n\tcase uint16:\n\t\treturn int(x)\n\tcase uint32:\n\t\treturn int(x)\n\tcase uint64:\n\t\treturn int(x)\n\tcase uintptr:\n\t\treturn int(x)\n\tcase float32:\n\t\treturn int(x)\n\tcase float64:\n\t\treturn int(x)\n\tcase complex64:\n\t\treturn int(real(x))\n\tcase complex128:\n\t\treturn int(real(x))\n\tcase string:\n\t\treturn hashString(x)\n\tcase *value:\n\t\treturn int(uintptr(unsafe.Pointer(x)))\n\tcase chan value:\n\t\treturn int(uintptr(reflect.ValueOf(x).Pointer()))\n\tcase structure:\n\t\treturn x.hash(t)\n\tcase array:\n\t\treturn x.hash(t)\n\tcase iface:\n\t\treturn x.hash(t)\n\tcase rtype:\n\t\treturn x.hash(t)\n\t}\n\tpanic(fmt.Sprintf(\"%T is unhashable\", x))\n}", "func (d Digest) Value() (driver.Value, error) {\n\tb, err := json.Marshal(d)\n\tif err != nil {\n\t\treturn driver.Value([]byte{}), err\n\t}\n\treturn driver.Value(b), nil\n}", "func Hash(i interface{}) string {\n\tv := reflect.ValueOf(i)\n\tif v.Kind() != reflect.Ptr {\n\t\tif !v.CanAddr(){\n\t\t\treturn \"\"\n\t\t}\n\t\tv = v.Addr()\n\t}\n\n\tsize := unsafe.Sizeof(v.Interface())\n\tb := (*[1 << 10]uint8)(unsafe.Pointer(v.Pointer()))[:size:size]\n\n\th := md5.New()\n\treturn base64.StdEncoding.EncodeToString(h.Sum(b))\n}", "func (in *Instance) hash(x, y, mu *big.Int, T uint64) *big.Int {\n\tb := sha512.New()\n\tb.Write(x.Bytes())\n\tb.Write(y.Bytes())\n\tb.Write(mu.Bytes())\n\tbits := make([]byte, 8)\n\tbinary.LittleEndian.PutUint64(bits, T)\n\tb.Write(bits)\n\tres := new(big.Int).SetBytes(b.Sum(nil))\n\tres.Mod(res, in.rsaModulus)\n\treturn res\n}", "func (b *ItemBundle) Digest() (isolated.HexDigest, int64, error) {\n\th := sha1.New()\n\tcw := &iotools.CountingWriter{Writer: h}\n\tif err := b.writeTar(cw); err != nil {\n\t\treturn \"\", 0, err\n\t}\n\treturn isolated.Sum(h), cw.Count, nil\n}", "func (_BondedECDSAKeep *BondedECDSAKeepCaller) Digest(opts *bind.CallOpts) ([32]byte, error) {\n\tvar (\n\t\tret0 = new([32]byte)\n\t)\n\tout := ret0\n\terr := _BondedECDSAKeep.contract.Call(opts, out, \"digest\")\n\treturn *ret0, err\n}", "func (s *GetRunOutput) SetDigest(v string) *GetRunOutput {\n\ts.Digest = &v\n\treturn s\n}", "func (c closure) Digest() digest.Digest {\n\treturn c.expr.Digest(c.env)\n}", "func (me TDigestValueType) String() string { return xsdt.Base64Binary(me).String() }", "func typehash(t *types.Type) uint32 {\n\tp := t.LongString()\n\n\t// Using MD5 is overkill, but reduces accidental collisions.\n\th := md5.Sum([]byte(p))\n\treturn binary.LittleEndian.Uint32(h[:4])\n}", "func (s *WorkflowListItem) SetDigest(v string) *WorkflowListItem {\n\ts.Digest = &v\n\treturn s\n}", "func (o *Object) Hash(ctx context.Context, t hash.Type) (string, error) {\n\tif t == hash.MD5 && o.fs.hasOCMD5 {\n\t\treturn o.md5, nil\n\t}\n\tif t == hash.SHA1 && (o.fs.hasOCSHA1 || o.fs.hasMESHA1) {\n\t\treturn o.sha1, nil\n\t}\n\treturn \"\", hash.ErrUnsupported\n}", "func (m *GGCRImage) Digest() (v1.Hash, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Digest\")\n\tret0, _ := ret[0].(v1.Hash)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func hash(stav Stav) uint64{\n\tstr := \"\"\n\n\tfor i := 0; i < len(stav.Auta); i++ {\n\t\tstr += stav.Auta[i].Farba\n\t\tstr += strconv.Itoa(int(stav.Auta[i].X))\n\t\tstr += strconv.Itoa(int(stav.Auta[i].Y))\n\t\tstr += strconv.FormatBool(stav.Auta[i].Smer)\n\t\tstr += strconv.Itoa(int(stav.Auta[i].Dlzka))\n\t}\n\n\th := fnv.New64a()\n\th.Write([]byte(str))\n\treturn h.Sum64()\n\n}", "func Hash(params PublicParameters, password, salt []byte, workFactor int, preHash bool, postHashLen int) (*Digest, error) {\n\tif _, _, err := wfMant(uint32(workFactor)); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif salt == nil {\n\t\tsalt = make([]byte, 16)\n\t\tif _, err := rand.Read(salt); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif preHash {\n\t\tpassword = kdf(params.Hash, password, 64)\n\t}\n\n\tk := params.N.BitLen() / 8\n\tif k < 160 {\n\t\treturn nil, errors.New(\"modulus too short\")\n\t}\n\n\tu := len(password)\n\tif u > 255 || u > (k-32) {\n\t\treturn nil, errors.New(\"password too long\")\n\t}\n\n\t// sb = KDF(salt || password || BYTE(u), k - 2 - u)\n\tsb := kdf(params.Hash, append(append(salt, password...), byte(u)), k-2-u)\n\n\t//xb = BYTE(0x00) || sb || password || BYTE(u)\n\txb := append(append(append([]byte{0x00}, sb...), password...), byte(u))\n\n\tx := new(big.Int).SetBytes(xb)\n\tfor i := 0; i <= workFactor; i++ {\n\t\tx = new(big.Int).Exp(x, two, params.N)\n\t}\n\n\tout := pad(params.N, x)\n\tif postHashLen > 0 {\n\t\tout = kdf(params.Hash, out, postHashLen)\n\t}\n\n\treturn &Digest{\n\t\tModulusID: params.ModulusID(),\n\t\tHash: out,\n\t\tSalt: salt,\n\t\tWorkFactor: workFactor,\n\t\tPreHash: preHash,\n\t\tPostHashLen: postHashLen,\n\t}, nil\n}", "func HashFromSum(algo Type, digest []byte) Hash {\n\tsize := len(digest)\n\tvar result Encoded\n\t// multihash: hash codec\n\tn := binary.PutUvarint(result[:], algo.Code())\n\t// multihash: digest size\n\tn += binary.PutUvarint(result[n:], uint64(size))\n\t// multihash: copy digest\n\tcopy(result[n:], digest)\n\treturn customHash{code: algo, size: size, start: n, body: result}\n}", "func (o *Object) Hash(ctx context.Context, t hash.Type) (string, error) {\n\treturn \"\", hash.ErrUnsupported\n}", "func (q *findMissingQueue) deriveDigest(blobDigest *remoteexecution.Digest) (digest.Digest, error) {\n\tderivedDigest, err := q.digestFunction.NewDigestFromProto(blobDigest)\n\tif err != nil {\n\t\treturn digest.BadDigest, util.StatusWrapWithCode(err, codes.NotFound, \"Action result contained malformed digest\")\n\t}\n\treturn derivedDigest, err\n}", "func (d *Digester) Digest(ctx context.Context, sub broker.Subscriber, opts ...digester.Option) error {\n\tdopts := digester.Options{}\n\tfor _, apply := range opts {\n\t\tapply(&dopts)\n\t}\n\n\th := dopts.Handler\n\tif h == nil {\n\t\th = handlers.DumpData\n\t}\n\n\treturn d.handle(ctx, sub, h)\n}", "func (s *GetWorkflowOutput) SetDigest(v string) *GetWorkflowOutput {\n\ts.Digest = &v\n\treturn s\n}", "func DigestUrl(baseURL string, digest types.Digest) string {\n\tbaseURL = strings.TrimRight(baseURL, \"/\")\n\treturn fmt.Sprintf(urlTemplate, baseURL, digest)\n}", "func d(digest types.Digest) []byte {\n\tif len(digest) != 2*md5.Size {\n\t\tpanic(\"digest wrong length \" + string(digest))\n\t}\n\tb, err := hex.DecodeString(string(digest))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}", "func d(digest types.Digest) []byte {\n\tif len(digest) != 2*md5.Size {\n\t\tpanic(\"digest wrong length \" + string(digest))\n\t}\n\tb, err := hex.DecodeString(string(digest))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn b\n}", "func DigestInfo(h crypto.Hash, data []byte) []byte {\n\t// Create a copy of the prefix, so that Sum can append to it directly.\n\t// Allocate space for both the prefix and the hash.\n\tp := hp[h]\n\tprefix := make([]byte, len(p), len(p)+h.Size())\n\tcopy(prefix, p)\n\n\thash := h.New()\n\thash.Write(data) // nolint: errcheck, gas, hash.Write never returns an error.\n\treturn hash.Sum(prefix)\n}", "func (t TDigest) AsBytes() ([]byte, error) {\n\tbuffer := new(bytes.Buffer)\n\n\terr := binary.Write(buffer, endianess, smallEncoding)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = binary.Write(buffer, endianess, t.compression)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = binary.Write(buffer, endianess, int32(t.summary.Len()))\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar x float64\n\tt.summary.ForEach(func(mean float64, count uint32) bool {\n\t\tdelta := mean - x\n\t\tx = mean\n\t\terr = binary.Write(buffer, endianess, float32(delta))\n\n\t\treturn err == nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tt.summary.ForEach(func(mean float64, count uint32) bool {\n\t\terr = encodeUint(buffer, count)\n\t\treturn err == nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buffer.Bytes(), nil\n}", "func (v Var) Hash() int {\n\th := xxhash.ChecksumString64S(string(v), hashSeed0)\n\treturn int(h)\n}", "func Hash(k0, k1 uint64, p []byte) uint64 {\n\tvar d digest\n\td.size = Size\n\td.k0 = k0\n\td.k1 = k1\n\td.Reset()\n\td.Write(p)\n\treturn d.Sum64()\n}", "func (w *DiskImage) Digest() digest.Digest {\n\treturn w.digester.Digest()\n}", "func hashType(t types.Type) int {\n\tmu.Lock()\n\th := int(hasher.Hash(t))\n\tmu.Unlock()\n\treturn h\n}", "func (md *Metadata) Digest() metadata.Digest {\n\tsshKeys := make(map[string][]ssh.Key)\n\n\tfor usr, rawKeys := range md.PublicKeys {\n\t\tkeys := strings.Split(rawKeys, \"\\n\")\n\n\t\tfor _, key := range keys {\n\t\t\tif key != \"\" {\n\t\t\t\tsshKeys[usr] = append(sshKeys[usr], ssh.Key(key))\n\t\t\t}\n\t\t}\n\t}\n\n\treturn metadata.Digest{\n\t\tHostname: md.Hostname,\n\t\tSSHKeys: sshKeys,\n\t}\n}", "func hash(i interface{}) string {\n\n var s []byte\n\n switch i.(type) {\n case []byte:\n s = reflect.ValueOf(i).Bytes()\n\n case string:\n s = []byte(reflect.ValueOf(i).String())\n\n default:\n panic(\"Cannot use interface type given in hash\")\n }\n\n h := md5.New()\n\n h.Write(s)\n\n b := h.Sum(nil)\n\n return hex.EncodeToString(b)\n}", "func (o *KubernetesAddonDefinitionAllOf) SetDigest(v string) {\n\to.Digest = &v\n}", "func (es *externalSigner) NewDigest(sig *model.PdfSignature) (model.Hasher, error) {\n\treturn bytes.NewBuffer(nil), nil\n}", "func computeHash(nstObj megav1.NamespaceTemplate) uint64 {\n\thash, err := hashstructure.Hash(nstObj, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Printf(\"computeHash: %d\\n\", hash)\n\treturn hash\n}", "func (f *Filter) Hash(extraBytes []byte) (string, error) {\n\th := sha1.New()\n\n\t// copy by value to ignore ETag without affecting f\n\tf2 := *f\n\tf2.ETag = \"\"\n\n\tfilterBytes, err := bson.Marshal(f2)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif _, err := h.Write(append(filterBytes, extraBytes...)); err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn fmt.Sprintf(\"%x\", h.Sum(nil)), nil\n}", "func Hasher(value string) string {\n\th := fnv.New32a()\n\t_, _ = h.Write([]byte(value))\n\treturn fmt.Sprintf(\"%v\", h.Sum32())\n}", "func F(v *big.Int, gamma []byte) []byte {\n\tvBytes := v.Bytes()\n\thmac_ins := hmac.New(sha256.New, gamma)\n\thmac_ins.Write(vBytes[:])\n\thashed := hmac_ins.Sum(nil)\n\treturn hashed\n}", "func DigestFile(filename string) (string, error) {\n\tb, err := DigestFileBytes(filename)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn hex.EncodeToString(b), nil\n}", "func (me *XsdGoPkgHasElem_DigestValue) Walk() (err error) {\n\tif fn := WalkHandlers.XsdGoPkgHasElem_DigestValue; me != nil {\n\t\tif fn != nil {\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif fn != nil {\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func hash(value string) uint32 {\n\th := fnv.New32a()\n\th.Write([]byte(value))\n\n\treturn h.Sum32()\n}", "func (t *Target) hash() uint64 {\n\th := fnv.New64a()\n\n\t//nolint: errcheck\n\th.Write([]byte(fmt.Sprintf(\"%016d\", t.labels.Hash())))\n\t//nolint: errcheck\n\th.Write([]byte(t.URL().String()))\n\n\treturn h.Sum64()\n}", "func HashTo(v Value, p []byte) {\n\tquad.HashTo(v, p)\n}", "func (o ConnectedRegistryNotificationOutput) Digest() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ConnectedRegistryNotification) *string { return v.Digest }).(pulumi.StringPtrOutput)\n}", "func (s *GenericStorage) Checksum(gvk schema.GroupVersionKind, uid runtime.UID) (string, error) {\n\treturn s.raw.Checksum(KeyForUID(gvk, uid))\n}", "func Hashit(tox string) string {\n h:= sha256.New()\n h.Write([]byte(tox))\n bs := h.Sum([]byte{})\n str := base64.StdEncoding.EncodeToString(bs)\n return str\n}", "func MustNewDigest(instanceName string, digestFunctionEnum remoteexecution.DigestFunction_Value, hash string, sizeBytes int64) Digest {\n\tdigestFunction := MustNewFunction(instanceName, digestFunctionEnum)\n\td, err := digestFunction.NewDigest(hash, sizeBytes)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn d\n}", "func (_BondedECDSAKeep *BondedECDSAKeepSession) Digest() ([32]byte, error) {\n\treturn _BondedECDSAKeep.Contract.Digest(&_BondedECDSAKeep.CallOpts)\n}", "func JavaDigest(h hash.Hash) string {\n\thash := h.Sum(nil)\n \n\t// Check for negative hashes\n\tnegative := (hash[0] & 0x80) == 0x80\n\tif negative {\n\t\thash = twosComplement(hash)\n\t}\n \n\t// Trim away zeroes\n\tres := strings.TrimLeft(fmt.Sprintf(\"%x\", hash), \"0\")\n\tif negative {\n\t\tres = \"-\" + res\n\t}\n \n\treturn res\n}", "func (o *ImageImportManifest) SetDigest(v string) {\n\to.Digest = &v\n}", "func Hash(seed maphash.Seed, k Key) uint64 {\n\tvar buf [8]byte\n\tswitch v := k.(type) {\n\tcase mapKey:\n\t\treturn hashMapKey(seed, v)\n\tcase interfaceKey:\n\t\ts := v.Hash()\n\t\t// Mix up the hash to ensure it covers 64-bits\n\t\tbinary.LittleEndian.PutUint64(buf[:8], uint64(s))\n\t\treturn hashBytes(seed, buf[:8])\n\tcase strKey:\n\t\treturn hashString(seed, string(v))\n\tcase bytesKey:\n\t\treturn hashBytes(seed, []byte(v))\n\tcase int8Key:\n\t\tbuf[0] = byte(v)\n\t\treturn hashBytes(seed, buf[:1])\n\tcase int16Key:\n\t\tbinary.LittleEndian.PutUint16(buf[:2], uint16(v))\n\t\treturn hashBytes(seed, buf[:2])\n\tcase int32Key:\n\t\tbinary.LittleEndian.PutUint32(buf[:4], uint32(v))\n\t\treturn hashBytes(seed, buf[:4])\n\tcase int64Key:\n\t\tbinary.LittleEndian.PutUint64(buf[:8], uint64(v))\n\t\treturn hashBytes(seed, buf[:8])\n\tcase uint8Key:\n\t\tbuf[0] = byte(v)\n\t\treturn hashBytes(seed, buf[:1])\n\tcase uint16Key:\n\t\tbinary.LittleEndian.PutUint16(buf[:2], uint16(v))\n\t\treturn hashBytes(seed, buf[:2])\n\tcase uint32Key:\n\t\tbinary.LittleEndian.PutUint32(buf[:4], uint32(v))\n\t\treturn hashBytes(seed, buf[:4])\n\tcase uint64Key:\n\t\tbinary.LittleEndian.PutUint64(buf[:8], uint64(v))\n\t\treturn hashBytes(seed, buf[:8])\n\tcase float32Key:\n\t\tbinary.LittleEndian.PutUint32(buf[:4], math.Float32bits(float32(v)))\n\t\treturn hashBytes(seed, buf[:4])\n\tcase float64Key:\n\t\tbinary.LittleEndian.PutUint64(buf[:8], math.Float64bits(float64(v)))\n\t\treturn hashBytes(seed, buf[:8])\n\tcase boolKey:\n\t\tif v {\n\t\t\tbuf[0] = 1\n\t\t}\n\t\treturn hashBytes(seed, buf[:1])\n\tcase sliceKey:\n\t\treturn hashSliceKey(seed, v)\n\tcase pointerKey:\n\t\treturn hashSliceKey(seed, v.sliceKey)\n\tcase pathKey:\n\t\treturn hashSliceKey(seed, v.sliceKey)\n\tcase nilKey:\n\t\treturn hashBytes(seed, nil)\n\tcase Hashable:\n\t\t// Mix up the hash to ensure it covers 64-bits\n\t\tbinary.LittleEndian.PutUint64(buf[:8], v.Hash())\n\t\treturn hashBytes(seed, buf[:8])\n\tdefault:\n\t\ts := _nilinterhash(v.Key())\n\t\tbinary.LittleEndian.PutUint64(buf[:8], uint64(s))\n\t\treturn hashBytes(seed, buf[:8])\n\t}\n}", "func (d *DigestEntry) Type() EntityType {\n\treturn EntityTypes.DIGEST\n}", "func Reflect_Value(v interface{}) *vector_tile.Tile_Value {\n\tvar tv *vector_tile.Tile_Value\n\t//fmt.Print(v)\n\tvv := reflect.ValueOf(v)\n\tkd := vv.Kind()\n\tif (reflect.Float64 == kd) || (reflect.Float32 == kd) {\n\t\t//fmt.Print(v, \"float\", k)\n\t\ttv = Make_Tv_Float(float64(vv.Float()))\n\t\t//hash = Hash_Tv(tv)\n\t} else if (reflect.Int == kd) || (reflect.Int8 == kd) || (reflect.Int16 == kd) || (reflect.Int32 == kd) || (reflect.Int64 == kd) || (reflect.Uint8 == kd) || (reflect.Uint16 == kd) || (reflect.Uint32 == kd) || (reflect.Uint64 == kd) {\n\t\t//fmt.Print(v, \"int\", k)\n\t\ttv = Make_Tv_Int(int(vv.Int()))\n\t\t//hash = Hash_Tv(tv)\n\t} else if reflect.String == kd {\n\t\t//fmt.Print(v, \"str\", k)\n\t\ttv = Make_Tv_String(string(vv.String()))\n\t\t//hash = Hash_Tv(tv)\n\n\t} else {\n\t\ttv := new(vector_tile.Tile_Value)\n\t\tt := \"\"\n\t\ttv.StringValue = &t\n\t}\n\treturn tv\n}", "func (d Digest) GetDigestFunction() Function {\n\tdigestFunction, _, _, sizeBytesEnd := d.unpack()\n\treturn Function{\n\t\tinstanceName: InstanceName{\n\t\t\tvalue: d.value[sizeBytesEnd+1:],\n\t\t},\n\t\tbareFunction: getBareFunction(digestFunction, 0),\n\t}\n}", "func (o *Object) Hash(t fs.HashType) (string, error) {\n\treturn \"\", fs.ErrHashUnsupported\n}", "func Hash(v []byte) string {\n\th := sha256.Sum256(v)\n\treturn hex.EncodeToString(h[:])\n}", "func (flavor *Flavor) getFlavorDigest() ([]byte, error) {\n\t// account for a differences in properties set at runtime\n\ttempFlavor := *flavor\n\ttempFlavor.Meta.ID = uuid.Nil\n\n\tflavorJSON, err := json.Marshal(tempFlavor)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"An error occurred attempting to convert the flavor to json\")\n\t}\n\n\tif flavorJSON == nil || len(flavorJSON) == 0 {\n\t\treturn nil, errors.New(\"The flavor json was not provided\")\n\t}\n\n\thashEntity := sha512.New384()\n\t_, err = hashEntity.Write(flavorJSON)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"Error writing flavor hash\")\n\t}\n\treturn hashEntity.Sum(nil), nil\n}", "func (spec Spec) DeepHash() string {\n\thash := sha512.New512_224()\n\tspec.DefaultService.hash(hash)\n\tfor _, rule := range spec.Rules {\n\t\trule.hash(hash)\n\t}\n\tsvcs := make([]string, len(spec.AllServices))\n\ti := 0\n\tfor k := range spec.AllServices {\n\t\tsvcs[i] = k\n\t\ti++\n\t}\n\tsort.Strings(svcs)\n\tfor _, svc := range svcs {\n\t\thash.Write([]byte(svc))\n\t\tspec.AllServices[svc].hash(hash)\n\t}\n\tspec.ShardCluster.hash(hash)\n\thash.Write([]byte(spec.VCL))\n\tfor _, auth := range spec.Auths {\n\t\tauth.hash(hash)\n\t}\n\tfor _, acl := range spec.ACLs {\n\t\tacl.hash(hash)\n\t}\n\tfor _, rw := range spec.Rewrites {\n\t\trw.hash(hash)\n\t}\n\tfor _, reqDisp := range spec.Dispositions {\n\t\treqDisp.hash(hash)\n\t}\n\th := new(big.Int)\n\th.SetBytes(hash.Sum(nil))\n\treturn h.Text(62)\n}", "func SaltedHash(v string) (string, error) {\n\tbSalted := []byte(salted(v))\n\tbSum := md5.Sum(bSalted)\n\treturn fmt.Sprintf(\"%x\", bSum), nil\n}", "func NewDigests(appliedRuleset *rulesets.AppliedRulesetSummary, statuses []scanner.ScanStatus) ([]Digest, error) {\n\tds := make([]Digest, 0)\n\terrs := make([]string, 0, 0)\n\n\tfor i := range statuses {\n\t\ts := statuses[i]\n\n\t\tvar e *scans.Evaluation\n\t\tif appliedRuleset != nil && appliedRuleset.RuleEvaluationSummary != nil {\n\t\t\tfor i := range appliedRuleset.RuleEvaluationSummary.Ruleresults {\n\t\t\t\tif appliedRuleset.RuleEvaluationSummary.Ruleresults[i].ID == s.ID {\n\t\t\t\t\te = &appliedRuleset.RuleEvaluationSummary.Ruleresults[i]\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\td, err := _newDigests(&s, e)\n\t\tif err != nil {\n\t\t\terrs = append(errs, fmt.Sprintf(\"failed to make digest(s) from scan: %v\", err.Error()))\n\t\t\tcontinue\n\t\t}\n\n\t\tds = append(ds, d...)\n\t}\n\n\tsort.Slice(ds, func(i, j int) bool { return ds[i].Index < ds[j].Index })\n\n\tif len(errs) > 0 {\n\t\treturn ds, fmt.Errorf(\"failed to make some digests: %v\", strings.Join(errs, \"; \"))\n\t}\n\n\treturn ds, nil\n}", "func Digest(done <-chan interface{}, f func(interface{}, ...interface{}) interface{}, in <-chan interface{}, params []interface{}) (outchan <-chan interface{}) {\n\tout := make(chan interface{})\n\tvar wg sync.WaitGroup\n\tconst numDigesters = 20\n\twg.Add(numDigesters)\n\tfor i := 0; i < numDigesters; i++ {\n\t\tgo func() {\n\t\t\tdefer func() {\n\t\t\t\t// recover from panic if one occured. Set err to nil otherwise.\n\t\t\t\tif recover() != nil {\n\t\t\t\t\tfmt.Println(\"defer launch\")\n\t\t\t\t\twg.Done()\n\n\t\t\t\t}\n\t\t\t}()\n\t\t\tdigester(done, f, params, in, out)\n\t\t\twg.Done()\n\t\t}()\n\t}\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(out)\n\t}()\n\treturn out\n}", "func computeHash(w http.ResponseWriter, req *http.Request) {\n\tvalues := req.URL.Query()\n\tdata := values.Get(\"data\")\n\tif data == \"\" {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tw.Write([]byte(\"400 - data param not present\"))\n\t\treturn\n\t}\n\tsalt := values.Get(\"salt\")\n\tif salt == \"\" {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tw.Write([]byte(\"400 - salt param not present\"))\n\t\treturn\n\t}\n\th := sha256.Sum256([]byte(data+salt))\n\tencodedStr := hex.EncodeToString(h[:])\n\tw.WriteHeader(http.StatusOK)\n\tw.Write([]byte(encodedStr))\n}", "func (n *NamedRepository) Digest() string {\n\treturn n.digest\n}", "func ComputeHash(template *v1.PodSpec) uint32 {\n\tpodTemplateSpecHasher := fnv.New32a()\n\thashutil.DeepHashObject(podTemplateSpecHasher, *template)\n\treturn podTemplateSpecHasher.Sum32()\n}", "func hash(obj interface{}) KHash {\n\tvar buffer bytes.Buffer\n\tencoder := json.NewEncoder(&buffer)\n\terr := encoder.Encode(obj)\n\tif err != nil {\n\t\tpanic(\"cannot encode object\")\n\t}\n\n\tdata := buffer.Bytes()\n\th := sha256.Sum256(data)\n\n\t// log.Printf(\"hashing %#v represented as %s with hash %X\", obj, data, h)\n\treturn h\n}", "func (_BondedECDSAKeep *BondedECDSAKeepCallerSession) Digest() ([32]byte, error) {\n\treturn _BondedECDSAKeep.Contract.Digest(&_BondedECDSAKeep.CallOpts)\n}", "func hash(values ...[]byte) ([]byte, error) {\n\th := swarm.NewHasher()\n\tfor _, v := range values {\n\t\t_, err := h.Write(v)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn h.Sum(nil), nil\n}", "func (c *Cluster) Hash(v interface{}) (int, error) {\n\th, err := hashstructure.Hash(v, nil)\n\n\tif err != nil {\n\t\treturn -1, err\n\t}\n\n\t// get cluster index\n\tci := int(h % uint64(c.metadata.NumShards))\n\n\treturn ci, nil\n}", "func (bcc *Bcc) Digest(b ...byte) {\n\tfor _, i := range b {\n\t\t*bcc = (*bcc) ^ Bcc(i)\n\t}\n}", "func (k CmdHasher) Hash(r *http.Request) string {\n\n\tencodedReq, err := json.Marshal(&request{r})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tstdin := strings.NewReader(string(encodedReq))\n\n\tvar stderr bytes.Buffer\n\tcmd := k.NewCmd(k.Command, &stderr, stdin)\n\tout, err := k.Run(cmd)\n\n\tif err != nil {\n\t\tlog.Printf(\"%v:\\nSTDOUT:\\n%v\\n\\nSTDERR:\\n%v\", err, string(out), stderr.String())\n\t\tpanic(err)\n\t}\n\n\thasher := md5.New()\n\t// This method always succeeds\n\t_, _ = hasher.Write(out)\n\treturn hex.EncodeToString(hasher.Sum(nil))\n}", "func computeMD5Hash(toBeEncoded int64) string {\n\tvar computedString string\n\n\tbyteArray := make([]byte, 1024)\n\tn := binary.PutVarint(byteArray, toBeEncoded)\n\n\tcomputedMD5 := md5.Sum(byteArray[0:n])\n\n\tcomputedString = fmt.Sprintf(\"%x\", computedMD5)\n\n\treturn computedString\n\n}", "func Hash(obj interface{}) (string, error) {\n\tb, err := GetBytes(obj)\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\thasher := sha256.New()\n\thasher.Write(b)\n\n\treturn base64.URLEncoding.EncodeToString(hasher.Sum(nil)), nil\n}", "func (d Digest64) Sum(b []byte) []byte {\n\th1 := d.Sum64()\n\treturn append(b,\n\t\tbyte(h1>>56), byte(h1>>48), byte(h1>>40), byte(h1>>32),\n\t\tbyte(h1>>24), byte(h1>>16), byte(h1>>8), byte(h1))\n}", "func DigestForBlock(number uint64) (blockdigest.Digest, error) {\n\tglobalData.Lock()\n\tdefer globalData.Unlock()\n\n\t// valid block number\n\tif number <= genesis.BlockNumber {\n\t\tif mode.IsTesting() {\n\t\t\treturn genesis.TestGenesisDigest, nil\n\t\t}\n\t\treturn genesis.LiveGenesisDigest, nil\n\t}\n\n\t// fetch block and compute digest\n\tn := make([]byte, 8)\n\tbinary.BigEndian.PutUint64(n, number)\n\tpacked := storage.Pool.Blocks.Get(n) // ***** FIX THIS: possible optimisation is to store the block hashes in a separate index\n\tif nil == packed {\n\t\treturn blockdigest.Digest{}, fault.ErrBlockNotFound\n\t}\n\n\t_, digest, _, err := blockrecord.ExtractHeader(packed, 0)\n\n\treturn digest, err\n}", "func New(hash string, size int64) (*repb.Digest, error) {\n\tdigest := &repb.Digest{Hash: hash, SizeBytes: size}\n\tif err := Validate(digest); err != nil {\n\t\treturn nil, err\n\t}\n\treturn digest, nil\n}", "func (me TDigestValueType) ToXsdtBase64Binary() xsdt.Base64Binary { return xsdt.Base64Binary(me) }", "func HASH(s string, salt string) string {\n\treturn MD5(SHA256(s, salt), salt)\n}", "func (o *Object) Hash(ctx context.Context, t hash.Type) (string, error) {\n\tif o.fs.opt.SharedFiles || o.fs.opt.SharedFolders {\n\t\treturn \"\", errNotSupportedInSharedMode\n\t}\n\tif t != DbHashType {\n\t\treturn \"\", hash.ErrUnsupported\n\t}\n\terr := o.readMetaData(ctx)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to read hash from metadata: %w\", err)\n\t}\n\treturn o.hash, nil\n}", "func (o *GetIconParams) SetDigest(digest string) {\n\to.Digest = digest\n}", "func hash(s string) string {\n\treturn fmt.Sprintf(\"%x\", md5.Sum([]byte(s)))\n}", "func (d *digest) Sum64() uint64 { return d.crc }", "func New() hash.Digest {\n\tref := &digest{}\n\tref.Reset()\n\treturn ref\n}" ]
[ "0.71098894", "0.64068437", "0.57950824", "0.573337", "0.5672699", "0.55973285", "0.55431145", "0.5513988", "0.5474869", "0.5373887", "0.5371913", "0.53038967", "0.52510256", "0.5207102", "0.52021974", "0.5186848", "0.5170909", "0.513816", "0.50961375", "0.50706947", "0.5042459", "0.50414616", "0.50321144", "0.5014351", "0.4976219", "0.49752614", "0.49664766", "0.496537", "0.4962065", "0.49589628", "0.4952214", "0.49461645", "0.49292457", "0.4923784", "0.49149436", "0.49121195", "0.48923528", "0.48863524", "0.48505706", "0.48500046", "0.48488572", "0.48488572", "0.48415133", "0.48320433", "0.48264122", "0.4825901", "0.4794343", "0.4788074", "0.47612795", "0.47610405", "0.47588974", "0.47492805", "0.47462016", "0.4742307", "0.47416636", "0.4738043", "0.47223198", "0.47171733", "0.47072133", "0.46990147", "0.46965304", "0.4695413", "0.4683856", "0.46753213", "0.46730348", "0.46626124", "0.46582544", "0.46338922", "0.46335796", "0.46278828", "0.4607164", "0.46045032", "0.46024668", "0.4588667", "0.4578069", "0.4573446", "0.45726448", "0.45671678", "0.45524028", "0.4514985", "0.450321", "0.45010847", "0.4498602", "0.4495025", "0.44934738", "0.4493426", "0.44893667", "0.44882768", "0.4485552", "0.4480936", "0.44773096", "0.44769394", "0.44733056", "0.44717368", "0.44652137", "0.44605002", "0.4460424", "0.44489494", "0.4443588", "0.44350636" ]
0.7762607
0
WriteDigest writes digest material for value v (given type t) into the writer w.
WriteDigest записывает материал дайджеста для значения v (данного типа t) в writer w.
func WriteDigest(w io.Writer, v T, t *types.T) { if d, ok := v.(digester); ok { digest.WriteDigest(w, d.Digest()) return } w.Write([]byte{t.Kind.ID()}) switch t.Kind { case types.ErrorKind, types.BottomKind, types.RefKind: panic("illegal type") case types.IntKind: vi := v.(*big.Int) // Bytes returns the normalized big-endian (i.e., free of a zero // prefix) representation of the absolute value of the integer. p := vi.Bytes() if len(p) == 0 { // This is the representation of "0" return } if p[0] == 0 { panic("big.Int byte representation is not normalized") } if vi.Sign() < 0 { w.Write([]byte{0}) } w.Write(p) case types.FloatKind: w.Write([]byte(v.(*big.Float).Text('e', 10))) case types.StringKind: io.WriteString(w, v.(string)) case types.BoolKind: if v.(bool) { w.Write(trueByte) } else { w.Write(falseByte) } case types.FileKind: digest.WriteDigest(w, v.(reflow.File).Digest()) case types.DirKind: dir := v.(Dir) for scan := dir.Scan(); scan.Scan(); { io.WriteString(w, scan.Path()) digest.WriteDigest(w, scan.File().Digest()) } // Filesets are digesters, so they don't need to be handled here. case types.UnitKind: case types.ListKind: writeLength(w, len(v.(List))) for _, e := range v.(List) { WriteDigest(w, e, t.Elem) } case types.MapKind: m := v.(*Map) writeLength(w, m.Len()) type kd struct { k T d digest.Digest } keys := make([]kd, 0, m.Len()) for _, entryp := range m.tab { for entry := *entryp; entry != nil; entry = entry.Next { keys = append(keys, kd{entry.Key, Digest(entry.Key, t.Index)}) } } // Sort the map so that it produces a consistent digest. We sort // its keys by their digest because the values may not yet be // evaluated. sort.Slice(keys, func(i, j int) bool { return keys[i].d.Less(keys[j].d) }) for _, k := range keys { WriteDigest(w, k.k, t.Index) WriteDigest(w, m.Lookup(k.d, k.k), t.Elem) } case types.TupleKind: writeLength(w, len(t.Fields)) tuple := v.(Tuple) for i, f := range t.Fields { WriteDigest(w, tuple[i], f.T) } case types.StructKind: writeLength(w, len(t.Fields)) s := v.(Struct) keys := make([]string, len(t.Fields)) for i, f := range t.Fields { keys[i] = f.Name } sort.Strings(keys) fm := t.FieldMap() for _, k := range keys { WriteDigest(w, s[k], fm[k]) } case types.ModuleKind: writeLength(w, len(t.Fields)) s := v.(Module) keys := make([]string, len(t.Fields)) for i, f := range t.Fields { keys[i] = f.Name } sort.Strings(keys) fm := t.FieldMap() for _, k := range keys { WriteDigest(w, s[k], fm[k]) } case types.SumKind: variant := v.(*Variant) io.WriteString(w, variant.Tag) WriteDigest(w, variant.Elem, t.VariantMap()[variant.Tag]) case types.FuncKind: digest.WriteDigest(w, v.(Func).Digest()) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Digest(v T, t *types.T) digest.Digest {\n\tw := Digester.NewWriter()\n\tWriteDigest(w, v, t)\n\treturn w.Digest()\n}", "func (q *Qsign) Digest(v interface{}) ([]byte, error) {\n\tbuf := new(bytes.Buffer)\n\n\tif q.prefixGenerator != nil {\n\t\tif _, err := buf.WriteString(q.prefixGenerator()); err != nil {\n\t\t\treturn buf.Bytes(), err\n\t\t}\n\t}\n\n\tvs := getStructValues(v)\n\n\tpairs := []string{}\n\tfor _, f := range vs {\n\t\tif !q.filter(f.name, f.value) {\n\t\t\tcontinue\n\t\t}\n\n\t\tvar buf strings.Builder\n\t\tbuf.WriteString(f.name)\n\t\tbuf.WriteString(q.connector)\n\t\tbuf.WriteString(f.value)\n\n\t\tpairs = append(pairs, buf.String())\n\t}\n\tconnected := strings.Join(pairs, q.delimiter)\n\tbuf.WriteString(connected)\n\n\tif q.suffixGenerator != nil {\n\t\tif _, err := buf.WriteString(q.suffixGenerator()); err != nil {\n\t\t\treturn buf.Bytes(), err\n\t\t}\n\t}\n\n\treturn buf.Bytes(), nil\n}", "func (o VirtualDatabaseStatusOutput) Digest() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v VirtualDatabaseStatus) *string { return v.Digest }).(pulumi.StringPtrOutput)\n}", "func (d *digest) Write(p []byte) (n int, err error) {\r\n\td.crc = crc64.Update(d.crc, d.tab, p)\r\n\treturn len(p), nil\r\n}", "func (o VirtualDatabaseStatusPtrOutput) Digest() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *VirtualDatabaseStatus) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Digest\n\t}).(pulumi.StringPtrOutput)\n}", "func (oc *OAuthConsumer) digest(key string, m string) string {\n\th := hmac.NewSHA1([]byte(key))\n\th.Write([]byte(m))\n\treturn base64encode(h.Sum())\n\n/*\ts := bytes.TrimSpace(h.Sum())\n\td := make([]byte, base64.StdEncoding.EncodedLen(len(s)))\n\tbase64.StdEncoding.Encode(d, s)\n\tds := strings.TrimSpace(bytes.NewBuffer(d).String())\n*/\n//\treturn ds\n\n}", "func (t *taprootSigHashOptions) writeDigestExtensions(w io.Writer) error {\n\tswitch t.extFlag {\n\t// The base extension, used for tapscript keypath spends doesn't modify\n\t// the digest at all.\n\tcase baseSigHashExtFlag:\n\t\treturn nil\n\n\t// The tapscript base leaf version extension adds the leaf hash, key\n\t// version, and code separator position to the final digest.\n\tcase tapscriptSighashExtFlag:\n\t\tif _, err := w.Write(t.tapLeafHash); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif _, err := w.Write([]byte{t.keyVersion}); err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr := binary.Write(w, binary.LittleEndian, t.codeSepPos)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func NVWriteValueAuth(rw io.ReadWriter, index, offset uint32, data []byte, auth []byte) error {\n\tif auth == nil {\n\t\treturn fmt.Errorf(\"no auth value given but mandatory\")\n\t}\n\tsharedSecret, osapr, err := newOSAPSession(rw, etOwner, khOwner, auth[:])\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to start new auth session: %v\", err)\n\t}\n\tdefer osapr.Close(rw)\n\tdefer zeroBytes(sharedSecret[:])\n\tauthIn := []interface{}{ordNVWriteValueAuth, index, offset, len(data), data}\n\tca, err := newCommandAuth(osapr.AuthHandle, osapr.NonceEven, nil, sharedSecret[:], authIn)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to construct auth fields: %v\", err)\n\t}\n\tdata, ra, ret, err := nvWriteValue(rw, index, offset, uint32(len(data)), data, ca)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to write to NVRAM: %v\", err)\n\t}\n\traIn := []interface{}{ret, ordNVWriteValueAuth, tpmutil.U32Bytes(data)}\n\tif err := ra.verify(ca.NonceOdd, sharedSecret[:], raIn); err != nil {\n\t\treturn fmt.Errorf(\"failed to verify authenticity of response: %v\", err)\n\t}\n\treturn nil\n}", "func (n *Node) Digest() ([]byte, error) {\n\t// HMAC(Nonce,Inputs[*]|(Cryptex||Secret||Marker))\n\thash := hmac.New(sha256.New, n.Nonce)\n\n\tfor _, input := range n.Inputs {\n\t\tif _, err := hash.Write(input); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tvar (\n\t\tdata []byte\n\t\terr error\n\t)\n\n\tswitch {\n\tcase n.cryptex != nil:\n\t\tdata, err = n.cryptex.Marshal()\n\tcase n.secret != nil:\n\t\tdata, err = n.secret.Marshal()\n\tcase n.Marker != nil:\n\t\tdata, err = n.Marker.Marshal()\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif _, err := hash.Write(data); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn hash.Sum(nil), nil\n}", "func (o *KubernetesAddonDefinitionAllOf) SetDigest(v string) {\n\to.Digest = &v\n}", "func (me TDigestValueType) String() string { return xsdt.Base64Binary(me).String() }", "func EncodePayloadDigest(data []byte) []byte {\n\tsum := md5.Sum(data)\n\treturn sum[:]\n}", "func WriteUint64(w io.Writer, v uint64) error {\n\tvar data [9]byte\n\tvar size int\n\tswitch {\n\tcase v <= 0x80:\n\t\tdata[0] = byte(v)\n\t\tsize = 1\n\tcase v < (1 << 8):\n\t\tdata[0] = 0x80 + 1\n\t\tdata[1] = byte(v)\n\t\tsize = 2\n\tcase v < (1 << 16):\n\t\tdata[0] = 0x80 + 2\n\t\tdata[1] = byte(v >> 8)\n\t\tdata[2] = byte(v)\n\t\tsize = 3\n\tcase v < (1 << 24):\n\t\tdata[0] = 0x80 + 3\n\t\tdata[1] = byte(v >> 16)\n\t\tdata[2] = byte(v >> 8)\n\t\tdata[3] = byte(v)\n\t\tsize = 4\n\tcase v < (1 << 32):\n\t\tdata[0] = 0x80 + 4\n\t\tdata[1] = byte(v >> 24)\n\t\tdata[2] = byte(v >> 16)\n\t\tdata[3] = byte(v >> 8)\n\t\tdata[4] = byte(v)\n\t\tsize = 5\n\tcase v < (1 << 40):\n\t\tdata[0] = 0x80 + 5\n\t\tdata[1] = byte(v >> 32)\n\t\tdata[2] = byte(v >> 24)\n\t\tdata[3] = byte(v >> 16)\n\t\tdata[4] = byte(v >> 8)\n\t\tdata[5] = byte(v)\n\t\tsize = 6\n\tcase v < (1 << 48):\n\t\tdata[0] = 0x80 + 6\n\t\tdata[1] = byte(v >> 40)\n\t\tdata[2] = byte(v >> 32)\n\t\tdata[3] = byte(v >> 24)\n\t\tdata[4] = byte(v >> 16)\n\t\tdata[5] = byte(v >> 8)\n\t\tdata[6] = byte(v)\n\t\tsize = 7\n\tcase v < (1 << 56):\n\t\tdata[0] = 0x80 + 7\n\t\tdata[1] = byte(v >> 48)\n\t\tdata[2] = byte(v >> 40)\n\t\tdata[3] = byte(v >> 32)\n\t\tdata[4] = byte(v >> 24)\n\t\tdata[5] = byte(v >> 16)\n\t\tdata[6] = byte(v >> 8)\n\t\tdata[7] = byte(v)\n\t\tsize = 8\n\tdefault:\n\t\tdata[0] = 0x80 + 8\n\t\tdata[1] = byte(v >> 56)\n\t\tdata[2] = byte(v >> 48)\n\t\tdata[3] = byte(v >> 40)\n\t\tdata[4] = byte(v >> 32)\n\t\tdata[5] = byte(v >> 24)\n\t\tdata[6] = byte(v >> 16)\n\t\tdata[7] = byte(v >> 8)\n\t\tdata[8] = byte(v)\n\t\tsize = 9\n\t}\n\t_, err := w.Write(data[0:size])\n\treturn err\n}", "func (me *XsdGoPkgHasElem_DigestValue) Walk() (err error) {\n\tif fn := WalkHandlers.XsdGoPkgHasElem_DigestValue; me != nil {\n\t\tif fn != nil {\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif fn != nil {\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func (o *GetIconParams) SetDigest(digest string) {\n\to.Digest = digest\n}", "func (o *ImageImportManifest) SetDigest(v string) {\n\to.Digest = &v\n}", "func (s *GetWorkflowOutput) SetDigest(v string) *GetWorkflowOutput {\n\ts.Digest = &v\n\treturn s\n}", "func (t *Tube) writeSync(key string, rev Rev, value interface{}) {\n\tvar wg sync.WaitGroup\n\tfor _, downAvatar := range t.folk.Opened() {\n\t\tydown := YTube{\n\t\t\ttissue.FolkAvatar(downAvatar),\n\t\t}\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tydown.Write(key, rev, value)\n\t\t}()\n\t}\n\twg.Wait()\n}", "func (vd *tValueDiffer) writeTypeValue(idx int, v reflect.Value, ht, hv bool) {\n\tv = vd.writeTypeBeforeValue(idx, v, ht)\n\tvd.writeValueAfterType(idx, v, hv)\n}", "func (s *GetRunOutput) SetDigest(v string) *GetRunOutput {\n\ts.Digest = &v\n\treturn s\n}", "func (s *WorkflowListItem) SetDigest(v string) *WorkflowListItem {\n\ts.Digest = &v\n\treturn s\n}", "func (o ConnectedRegistryNotificationOutput) Digest() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ConnectedRegistryNotification) *string { return v.Digest }).(pulumi.StringPtrOutput)\n}", "func (t TDigest) AsBytes() ([]byte, error) {\n\tbuffer := new(bytes.Buffer)\n\n\terr := binary.Write(buffer, endianess, smallEncoding)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = binary.Write(buffer, endianess, t.compression)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = binary.Write(buffer, endianess, int32(t.summary.Len()))\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar x float64\n\tt.summary.ForEach(func(mean float64, count uint32) bool {\n\t\tdelta := mean - x\n\t\tx = mean\n\t\terr = binary.Write(buffer, endianess, float32(delta))\n\n\t\treturn err == nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tt.summary.ForEach(func(mean float64, count uint32) bool {\n\t\terr = encodeUint(buffer, count)\n\t\treturn err == nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buffer.Bytes(), nil\n}", "func digestToBytes(t *testing.T, digest types.Digest) []byte {\n\tbytes, err := sql.DigestToBytes(digest)\n\trequire.NoError(t, err)\n\treturn bytes\n}", "func (o GetReposRepoTagOutput) Digest() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetReposRepoTag) string { return v.Digest }).(pulumi.StringOutput)\n}", "func Write(w io.Writer, v interface{}, name string) (err error) {\n\tdefer func() {\n\t\tif e := recover(); e != nil {\n\t\t\tif er, ok := e.(error); ok {\n\t\t\t\terr = er\n\t\t\t} else {\n\t\t\t\terr = fmt.Errorf(\"format/nbt: %s\", e)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}()\n\tval := reflect.ValueOf(v)\n\tif val.Kind() == reflect.Ptr {\n\t\tval = val.Elem()\n\t}\n\tfs := fields(val.Type())\n\ten := &msgEncoder{}\n\n\t//Write name\n\tbs := en.b[:3]\n\tbs[0] = 10\n\tbinary.BigEndian.PutUint16(bs[1:], uint16(len(name)))\n\t_, err = w.Write(bs)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = w.Write([]byte(name))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn write(w, en, fs, val)\n}", "func (blob *Blob) SummingWriteContentsTo(w io.Writer, v interface{}) (sum *Sum,\n\tn int64, err error) {\n\tvar (\n\t\tb [BlobRandomSz]byte\n\t\tx N\n\t)\n\th := sha512.New()\n\tm := io.MultiWriter(w, h)\n\tdefer func() {\n\t\tif err == nil {\n\t\t\tsum = new(Sum)\n\t\t\tcopy(sum[:], h.Sum([]byte{}))\n\t\t} else {\n\t\t\tDiag.Println(err)\n\t\t}\n\t\th.Reset()\n\t\th = nil\n\t\tn = int64(x)\n\t}()\n\tif err = x.Plus(Latest.WriteTo(m)); err != nil {\n\t\treturn\n\t}\n\tif err = x.Plus(BlobId.Version(Latest).WriteTo(m)); err != nil {\n\t\treturn\n\t}\n\tif err = x.Plus(m.Write([]byte(BlobMagic))); err != nil {\n\t\treturn\n\t}\n\trand.Reader.Read(b[:BlobRandomSz])\n\tif err = x.Plus(m.Write(b[:BlobRandomSz])); err != nil {\n\t\treturn\n\t}\n\tif err = x.Plus(m.Write(blob.Owner[:])); err != nil {\n\t\treturn\n\t}\n\tif err = x.Plus(m.Write(blob.Author[:])); err != nil {\n\t\treturn\n\t}\n\tif err = x.Plus((NBOWriter{m}).WriteNBO(blob.Time)); err != nil {\n\t\treturn\n\t}\n\tb[0] = byte(len(blob.Name))\n\tif err = x.Plus(m.Write(b[:1])); err != nil {\n\t\treturn\n\t}\n\tif b[0] > 0 {\n\t\tif err = x.Plus(m.Write([]byte(blob.Name[:]))); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\tswitch t := v.(type) {\n\tcase Mark:\n\t\terr = x.Plus(t.WriteTo(m))\n\tcase Sums:\n\t\terr = x.Plus(t.WriteTo(m))\n\tcase *bytes.Buffer:\n\t\terr = x.Plus(t.WriteTo(m))\n\tcase []byte:\n\t\terr = x.Plus(m.Write(t))\n\tcase string:\n\t\terr = x.Plus(m.Write([]byte(t)))\n\tcase io.Reader:\n\t\terr = x.Plus(io.Copy(m, t))\n\t}\n\treturn\n}", "func (vd *tValueDiffer) writeType(idx int, t reflect.Type, hl bool) {\n\tb := vd.bufi(idx)\n\tif t.PkgPath() == \"\" {\n\t\tswitch t.Kind() {\n\t\tcase reflect.Ptr:\n\t\t\tb.Write(hl, \"*\")\n\t\t\tvd.writeType(idx, t.Elem(), hl)\n\t\tcase reflect.Func:\n\t\t\tvd.writeTypeFunc(idx, t, hl)\n\t\tcase reflect.Chan:\n\t\t\tvd.writeTypeHeadChan(idx, t, hl, false)\n\t\t\tvd.writeType(idx, t.Elem(), hl)\n\t\tcase reflect.Array:\n\t\t\tb.Write(hl, \"[\", t.Len(), \"]\")\n\t\t\tvd.writeType(idx, t.Elem(), hl)\n\t\tcase reflect.Slice:\n\t\t\tb.Write(hl, \"[]\")\n\t\t\tvd.writeType(idx, t.Elem(), hl)\n\t\tcase reflect.Map:\n\t\t\tb.Write(hl, \"map[\")\n\t\t\tvd.writeType(idx, t.Key(), hl)\n\t\t\tb.Write(hl, \"]\")\n\t\t\tvd.writeType(idx, t.Elem(), hl)\n\t\tcase reflect.Struct: // must be unnamed\n\t\t\tb.Write(hl, \"struct\")\n\t\tdefault:\n\t\t\tb.Write(hl, t)\n\t\t}\n\t} else {\n\t\tb.Write(hl, t)\n\t}\n}", "func writeVDT(file *os.File, index int64, vdt *virtualDirectoryTree) {\n\tfile.Seek(index, 0)\n\t//Empezamos el proceso de guardar en binario la data en memoria del struct\n\tvar binaryDisc bytes.Buffer\n\tbinary.Write(&binaryDisc, binary.BigEndian, vdt)\n\twriteNextBytes(file, binaryDisc.Bytes())\n}", "func (s *Storage) WriteDiff(hash common.Hash, diff *big.Int) {\n\ts.set(DIFFICULTY, hash.Bytes(), diff.Bytes())\n}", "func (b SignDetail) Digest() (common.Hash, error) {\n\tvar hash common.Hash\n\tvar signFormatData apitypes.TypedData\n\tif err := json.Unmarshal([]byte(b.SignSchema.Schema), &signFormatData); err != nil {\n\t\treturn hash, err\n\t}\n\tparams, err := b.GetContractParams()\n\tif err != nil {\n\t\treturn hash, err\n\t}\n\tdata, err := buildTypedData(signFormatData, params)\n\n\tif err != nil {\n\t\treturn hash, err\n\t}\n\thash, err = crypto2.Keccak256HashEIP712(data)\n\treturn hash, err\n}", "func (i *AppxDigest) digestFile(f *zipslicer.File, doPageHash bool) error {\n\tvar peWriters []io.WriteCloser\n\tvar peResults []<-chan peDigestResult\n\tvar sink io.Writer\n\tif strings.HasSuffix(f.Name, \".exe\") || strings.HasSuffix(f.Name, \".dll\") {\n\t\t// DigestPE wants a Reader so make a pipe for each one and sink data into the pipes\n\t\tpeWriters, peResults = setupPeDigests(f.Name, i.Hash, doPageHash)\n\t\tdefer func() {\n\t\t\tfor _, w := range peWriters {\n\t\t\t\tw.Close()\n\t\t\t}\n\t\t}()\n\t\tmw := make([]io.Writer, len(peWriters))\n\t\tfor i, w := range peWriters {\n\t\t\tmw[i] = w\n\t\t}\n\t\tsink = io.MultiWriter(mw...)\n\t}\n\tif err := i.blockMap.AddFile(f, i.axpc, sink); err != nil {\n\t\treturn err\n\t}\n\tif peWriters != nil {\n\t\tfor _, w := range peWriters {\n\t\t\tw.Close()\n\t\t}\n\t\tfor _, ch := range peResults {\n\t\t\tresult := <-ch\n\t\t\tif result.err != nil {\n\t\t\t\treturn result.err\n\t\t\t}\n\t\t\ti.peDigests = append(i.peDigests, result.digest)\n\t\t}\n\t}\n\treturn nil\n}", "func (vlog *valueLog) write(reqs []*request) error {\n\tvlog.filesLock.RLock()\n\tcurlf := vlog.filesMap[vlog.maxFid]\n\tvlog.filesLock.RUnlock()\n\n\ttoDisk := func() error {\n\t\tif vlog.buf.Len() == 0 {\n\t\t\treturn nil\n\t\t}\n\t\tvlog.elog.Printf(\"Flushing %d blocks of total size: %d\", len(reqs), vlog.buf.Len())\n\t\tn, err := curlf.fd.Write(vlog.buf.Bytes())\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"Unable to write to value log file: %q\", curlf.path)\n\t\t}\n\t\ty.NumWrites.Add(1)\n\t\ty.NumBytesWritten.Add(int64(n))\n\t\tvlog.elog.Printf(\"Done\")\n\t\tcurlf.offset += uint32(n)\n\t\tvlog.buf.Reset()\n\n\t\tif curlf.offset > uint32(vlog.opt.ValueLogFileSize) {\n\t\t\tvar err error\n\t\t\tif err = curlf.doneWriting(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tnewid := atomic.AddUint32(&vlog.maxFid, 1)\n\t\t\ty.AssertTruef(newid < 1<<16, \"newid will overflow uint16: %v\", newid)\n\t\t\tnewlf, err := vlog.createVlogFile(newid)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tcurlf = newlf\n\t\t}\n\t\treturn nil\n\t}\n\n\tfor i := range reqs {\n\t\tb := reqs[i]\n\t\tb.Ptrs = b.Ptrs[:0]\n\t\tfor j := range b.Entries {\n\t\t\te := b.Entries[j]\n\t\t\tvar p valuePointer\n\n\t\t\tif !vlog.opt.SyncWrites && len(e.Value) < vlog.opt.ValueThreshold {\n\t\t\t\t// No need to write to value log.\n\t\t\t\tb.Ptrs = append(b.Ptrs, p)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tp.Fid = curlf.fid\n\t\t\tp.Offset = curlf.offset + uint32(vlog.buf.Len()) // Use the offset including buffer length so far.\n\t\t\tplen, err := encodeEntry(e, &vlog.buf) // Now encode the entry into buffer.\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tp.Len = uint32(plen)\n\t\t\tb.Ptrs = append(b.Ptrs, p)\n\n\t\t\tif p.Offset > uint32(vlog.opt.ValueLogFileSize) {\n\t\t\t\tif err := toDisk(); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn toDisk()\n\n\t// Acquire mutex locks around this manipulation, so that the reads don't try to use\n\t// an invalid file descriptor.\n}", "func (restorer *APTRestorer) writeManifest(manifestType, algorithm string, restoreState *models.RestoreState) {\n\tif algorithm != constants.AlgMd5 && algorithm != constants.AlgSha256 {\n\t\trestorer.Context.MessageLog.Fatalf(\"writeManifest: Unsupported algorithm: %s\", algorithm)\n\t}\n\tmanifestPath := restorer.getManifestPath(manifestType, algorithm, restoreState)\n\tmanifestFile, err := os.Create(manifestPath)\n\tif err != nil {\n\t\trestoreState.PackageSummary.AddError(\"Cannot create manifest file %s: %v\",\n\t\t\tmanifestPath, err)\n\t\treturn\n\t}\n\tdefer manifestFile.Close()\n\tfor _, gf := range restoreState.IntellectualObject.GenericFiles {\n\t\tif !restorer.fileBelongsInManifest(gf, manifestType) {\n\t\t\trestorer.Context.MessageLog.Info(\"Skipping file '%s' for manifest type %s (%s)\",\n\t\t\t\tgf.Identifier, manifestType, algorithm)\n\t\t\tcontinue\n\t\t} else {\n\t\t\trestorer.Context.MessageLog.Info(\"Adding '%s' to %s\", gf.Identifier, manifestFile.Name())\n\t\t}\n\t\tchecksum := gf.GetChecksumByAlgorithm(algorithm)\n\t\tif checksum == nil {\n\t\t\trestoreState.PackageSummary.AddError(\"Cannot find %s checksum for file %s\",\n\t\t\t\talgorithm, gf.OriginalPath())\n\t\t\treturn\n\t\t}\n\t\t_, err := fmt.Fprintln(manifestFile, checksum.Digest, gf.OriginalPath())\n\t\tif err != nil {\n\t\t\trestoreState.PackageSummary.AddError(\"Error writing checksum for file %s \"+\n\t\t\t\t\"to manifest %s: %v\", gf.OriginalPath(), manifestPath, err)\n\t\t\treturn\n\t\t} else {\n\t\t\trestorer.Context.MessageLog.Info(\"Wrote %s digest %s for file %s\", algorithm,\n\t\t\t\tchecksum.Digest, gf.Identifier)\n\t\t}\n\t}\n}", "func WritevRaw(fd uintptr, iovec []syscall.Iovec) (nw int, err error) {\n\tnw_raw, _, errno := syscall.Syscall(syscall.SYS_WRITEV, fd, uintptr(unsafe.Pointer(&iovec[0])), uintptr(len(iovec)))\n\tnw = int(nw_raw)\n\tif errno != 0 {\n\t\terr = errors.New(fmt.Sprintf(\"writev failed with error: %d\", errno))\n\t}\n\treturn\n}", "func (s StatHat) PostEZ(name string, kind Kind, v float64, t *time.Time) error {\n\tif s.noop {\n\t\treturn nil\n\t}\n\n\tu, _ := url.Parse(s.ezPrefix())\n\tq := u.Query()\n\n\tif len(s.ezkey) == 0 {\n\t\treturn ErrMissingEZKey\n\t}\n\tq.Add(\"ezkey\", s.ezkey)\n\tq.Add(\"stat\", name)\n\n\tif t != nil && !t.IsZero() {\n\t\tq.Add(\"t\", strconv.FormatInt(t.Unix(), 10))\n\t}\n\n\tif kind == KindValue {\n\t\tq.Add(\"value\", strconv.FormatFloat(v, 'g', -1, 64))\n\t} else if kind == KindCounter {\n\t\tq.Add(\"count\", strconv.FormatFloat(v, 'g', -1, 64))\n\t} else {\n\t\treturn ErrKindMissing\n\t}\n\n\tu.RawQuery = q.Encode()\n\treq, err := http.NewRequest(http.MethodPost, u.String(), nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\tresp, err := httpDo(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\t// StatHat may return HTTP Status Code 204 to indicate success.\n\t// See: https://blog.stathat.com/2017/05/05/bandwidth.html\n\tif resp.StatusCode == http.StatusNoContent {\n\t\treturn nil\n\t}\n\n\tvar respJSON struct {\n\t\t// {\"msg\":\"stat deleted.\"}\n\t\tMsg string\n\t}\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = json.Unmarshal(body, &respJSON)\n\tif respJSON.Msg != \"ok\" {\n\t\terr = errors.New(respJSON.Msg)\n\t}\n\treturn err\n}", "func (d *swiftDriver) WriteManifest(account keppel.Account, repoName string, manifestDigest digest.Digest, contents []byte) error {\n\tc, _, err := d.getBackendConnection(account)\n\tif err != nil {\n\t\treturn err\n\t}\n\to := manifestObject(c, repoName, manifestDigest)\n\treturn uploadToObject(o, bytes.NewReader(contents), nil, nil)\n}", "func HashFromDigest(algo Type, digest Digest) Hash {\n\treturn HashFromSum(algo, digest[:])\n}", "func Writev(f *os.File, in [][]byte) (nw int, err error) {\n\tiovec := make([]syscall.Iovec, len(in))\n\tfor i, slice := range in {\n\t\tiovec[i] = syscall.Iovec{&slice[0], uint64(len(slice))}\n\t}\n\tnw, err = WritevRaw(uintptr(f.Fd()), iovec)\n\treturn\n}", "func (r *Repository) InstallDigest(d digest.Digest, file string) error {\n\tfile, err := filepath.EvalSymlinks(file)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdir, path := r.Path(d)\n\tif err := os.MkdirAll(dir, 0777); err != nil {\n\t\treturn err\n\t}\n\terr = os.Link(file, path)\n\tif os.IsExist(err) {\n\t\terr = nil\n\t}\n\tif err != nil {\n\t\t// Copy if file was reported to be on a different device.\n\t\tif linkErr, ok := err.(*os.LinkError); ok && linkErr.Err == syscall.EXDEV {\n\t\t\tf, ferr := os.Open(file)\n\t\t\tif ferr != nil {\n\t\t\t\treturn ferr\n\t\t\t}\n\t\t\tdefer func() { _ = f.Close() }()\n\t\t\t_, err = r.Put(context.Background(), f)\n\t\t}\n\t}\n\treturn err\n}", "func (h *hmacsha256) Write(p []byte) {\n\th.inner.Write(p)\n}", "func (w *Writer) WriteValue(v reflect.Value) {\n\tvalueEncoders[v.Kind()](w, v)\n}", "func (b *Base) Digest(req *DigestReq) (*DigestResp, error) {\n\treturn nil, ErrFunctionNotSupported\n}", "func (me *XsdGoPkgHasElems_DigestValue) Walk() (err error) {\n\tif fn := WalkHandlers.XsdGoPkgHasElems_DigestValue; me != nil {\n\t\tif fn != nil {\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif fn != nil {\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func (d *Deployment) WriteHMAC(version string, hmac []byte) error {\n\n\t// Generate the filename, write to file, set ownership.\n\thmacPath, _ := makeHMACPath(d.artifactDir, d.appName, version, d.acfg.Extension)\n\tif err := ioutil.WriteFile(hmacPath, hmac, 0664); err != nil {\n\t\treturn fmt.Errorf(\"Error while writing %q: %s\", hmacPath, err.Error())\n\t}\n\tif err := setOwner(hmacPath, d.uid, d.gid); err != nil {\n\t\treturn fmt.Errorf(\"Unable to set owner on %q: %s\", hmacPath, err.Error())\n\t}\n\n\treturn nil\n}", "func Write(fd uintptr, p unsafe.Pointer, n int32) int32", "func (h *Hash) Write(p []byte) (n int, err error) {\n\treturn h.hmac.Write(p)\n}", "func (w *Writer) Write(entry *pb.DataEntry) error {\n\tw.sizeBuf.Reset()\n\tw.dataBuf.Reset()\n\tif err := w.dataBuf.Marshal(entry); err != nil {\n\t\treturn err\n\t}\n\tentryBytes := w.dataBuf.Bytes()\n\tif err := w.sizeBuf.EncodeVarint(uint64(len(entryBytes))); err != nil {\n\t\treturn err\n\t}\n\tif _, err := w.fd.Write(w.sizeBuf.Bytes()); err != nil {\n\t\treturn err\n\t}\n\tif _, err := w.fd.Write(entryBytes); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func FreezeImageToDigest(template *servingv1alpha1.RevisionTemplateSpec, baseRevision *servingv1alpha1.Revision) error {\n\tif baseRevision == nil {\n\t\treturn nil\n\t}\n\n\tcurrentContainer, err := ContainerOfRevisionTemplate(template)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tbaseContainer, err := ContainerOfRevisionSpec(&baseRevision.Spec)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif currentContainer.Image != baseContainer.Image {\n\t\treturn fmt.Errorf(\"could not freeze image to digest since current revision contains unexpected image\")\n\t}\n\n\tif baseRevision.Status.ImageDigest != \"\" {\n\t\treturn UpdateImage(template, baseRevision.Status.ImageDigest)\n\t}\n\treturn nil\n}", "func write(w io.Writer, en *msgEncoder, fs map[string]interface{}, val reflect.Value) error {\n\tfor _, i := range fs {\n\t\tif f, ok := i.(field); ok {\n\t\t\twritePrefix(en, w, f.name, f.requiredType)\n\t\t\tv := val.Field(f.sField)\n\t\t\terr := f.write(w, en, v)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\tfs := i.(fieldStruct)\n\t\t\twritePrefix(en, w, fs.name, 10)\n\t\t\tv := val.Field(fs.sField)\n\t\t\terr := write(w, en, fs.m, v)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\tbs := en.b[:1]\n\tbs[0] = 0\n\t_, err := w.Write(bs)\n\treturn err\n}", "func (s *ShardMap) hash(v interface{}) int {\n\tswitch s.Type {\n\tcase \"string\":\n\t\tval, ok := v.(string)\n\t\tif !ok {\n\t\t\treturn -1\n\t\t}\n\n\t\thash := fnv.New32()\n\t\thash.Write([]byte(val))\n\t\treturn int(hash.Sum32() % NumShards)\n\tcase \"int32\":\n\t\t// Values that come as numbers in JSON are of type float64.\n\t\tval, ok := v.(float64)\n\t\tif !ok {\n\t\t\treturn -1\n\t\t}\n\n\t\treturn int(int32(val) % NumShards)\n\tdefault:\n\t\treturn -1\n\t}\n}", "func WriteVarUint(writer io.Writer, value uint64) error {\n\tvar buf [9]byte\n\tlen := 0\n\tif value < 0xFD {\n\t\tbuf[0] = uint8(value)\n\t\tlen = 1\n\t} else if value <= 0xFFFF {\n\t\tbuf[0] = 0xFD\n\t\tbinary.LittleEndian.PutUint16(buf[1:], uint16(value))\n\t\tlen = 3\n\t} else if value <= 0xFFFFFFFF {\n\t\tbuf[0] = 0xFE\n\t\tbinary.LittleEndian.PutUint32(buf[1:], uint32(value))\n\t\tlen = 5\n\t} else {\n\t\tbuf[0] = 0xFF\n\t\tbinary.LittleEndian.PutUint64(buf[1:], uint64(value))\n\t\tlen = 9\n\t}\n\t_, err := writer.Write(buf[:len])\n\treturn err\n}", "func (m *wasiSnapshotPreview1Impl) fdWrite(pfd wasiFd, piovs list) (rv wasiSize, err wasiErrno) {\n\tf, err := m.files.getFile(pfd, wasiRightsFdWrite)\n\tif err != wasiErrnoSuccess {\n\t\treturn 0, err\n\t}\n\n\tn, ferr := f.Writev(m.buffers(wasiIovecArray(piovs)))\n\tif ferr != nil {\n\t\treturn n, fileErrno(ferr)\n\t}\n\treturn n, wasiErrnoSuccess\n}", "func (w *Writer) WriteVal(schema Schema, val any) {\n\tencoder := w.cfg.getEncoderFromCache(schema.Fingerprint(), reflect2.RTypeOf(val))\n\tif encoder == nil {\n\t\ttyp := reflect2.TypeOf(val)\n\t\tencoder = w.cfg.EncoderOf(schema, typ)\n\t}\n\tencoder.Encode(reflect2.PtrOf(val), w)\n}", "func tfsWrite(imgFile *os.File, imgOffset uint64, fsSize uint64, label string, root map[string]interface{}) (*tfs, error) {\n\ttfs := newTfs(imgFile, imgOffset, fsSize)\n\ttfs.label = label\n\trand.Seed(time.Now().UnixNano())\n\t_, err := rand.Read(tfs.uuid[:])\n\terr = tfs.logInit()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot create filesystem log: %v\", err)\n\t}\n\ttfs.encodeTupleHeader(len(root))\n\tfor k, v := range root {\n\t\tif k == \"children\" {\n\t\t\terr = tfs.writeDirEntries(v.(map[string]interface{}))\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t} else {\n\t\t\ttfs.encodeMetadata(k, v)\n\t\t}\n\t}\n\treturn tfs, tfs.flush()\n}", "func Digest(done <-chan interface{}, f func(interface{}, ...interface{}) interface{}, in <-chan interface{}, params []interface{}) (outchan <-chan interface{}) {\n\tout := make(chan interface{})\n\tvar wg sync.WaitGroup\n\tconst numDigesters = 20\n\twg.Add(numDigesters)\n\tfor i := 0; i < numDigesters; i++ {\n\t\tgo func() {\n\t\t\tdefer func() {\n\t\t\t\t// recover from panic if one occured. Set err to nil otherwise.\n\t\t\t\tif recover() != nil {\n\t\t\t\t\tfmt.Println(\"defer launch\")\n\t\t\t\t\twg.Done()\n\n\t\t\t\t}\n\t\t\t}()\n\t\t\tdigester(done, f, params, in, out)\n\t\t\twg.Done()\n\t\t}()\n\t}\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(out)\n\t}()\n\treturn out\n}", "func (vd *tValueDiffer) writeElem(idx int, v reflect.Value, hl bool) {\n\tb := vd.bufi(idx)\n\tif !v.IsValid() {\n\t\tb.Write(hl, nil)\n\t} else {\n\t\tswitch v.Kind() {\n\t\tcase reflect.Interface:\n\t\t\tif v.IsNil() {\n\t\t\t\tb.Write(hl, nil)\n\t\t\t} else {\n\t\t\t\tvd.writeElem(idx, v.Elem(), hl)\n\t\t\t}\n\t\tcase reflect.Array:\n\t\t\tvd.writeElemArray(idx, v, hl)\n\t\tcase reflect.Slice:\n\t\t\tvd.writeElemSlice(idx, v, hl)\n\t\tcase reflect.Map:\n\t\t\tvd.writeElemMap(idx, v, hl)\n\t\tcase reflect.Struct:\n\t\t\tvd.writeElemStruct(idx, v, hl)\n\t\tdefault: // bool, integer, float, complex, channel, function, pointer, string\n\t\t\tvd.writeKey(idx, v, hl)\n\t\t}\n\t}\n}", "func (b *ItemBundle) Digest() (isolated.HexDigest, int64, error) {\n\th := sha1.New()\n\tcw := &iotools.CountingWriter{Writer: h}\n\tif err := b.writeTar(cw); err != nil {\n\t\treturn \"\", 0, err\n\t}\n\treturn isolated.Sum(h), cw.Count, nil\n}", "func execWriteType(_ int, p *gop.Context) {\n\targs := p.GetArgs(3)\n\ttypes.WriteType(args[0].(*bytes.Buffer), args[1].(types.Type), args[2].(types.Qualifier))\n}", "func Put(key string, value string){\n \n h := sha256.New()\n h.Write([]byte(value))\n sha := base64.URLEncoding.EncodeToString(h.Sum(nil))\n \n //fmt.Println(sha)\n var n Data \n \n n.val = value //storing key value in keyValue hash map\n n.hash = sha // storing key hash in keyHash hash map \n \n keyValue[key] = n\n}", "func (w *Writer) Write(name string, v interface{}) error {\n\tww, err := w.wz.Create(name)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"npz: could not create npz entry %q: %w\", name, err)\n\t}\n\n\terr = npy.Write(ww, v)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"npz: could not write npz entry %q: %w\", name, err)\n\t}\n\n\treturn nil\n}", "func (me TDigestValueType) ToXsdtBase64Binary() xsdt.Base64Binary { return xsdt.Base64Binary(me) }", "func (b *BTSVShardWriter) marshalValue(ctx MarshalContext, enc *marshal.Encoder, v Value) {\n\tenc.PutByte(byte(v.typ))\n\tswitch v.typ {\n\tcase NullType:\n\t\tif v.Null() == PosNull {\n\t\t\tenc.PutByte(1)\n\t\t} else {\n\t\t\tenc.PutByte(byte(0xff))\n\t\t}\n\tcase BoolType:\n\t\tif v.Bool(nil) {\n\t\t\tenc.PutByte(1)\n\t\t} else {\n\t\t\tenc.PutByte(0)\n\t\t}\n\tcase IntType, CharType:\n\t\tenc.PutVarint(int64(v.v))\n\tcase FloatType:\n\t\tenc.PutUint64(v.v) // v.v encodes the floating point in binary.\n\tcase StringType, FileNameType, EnumType:\n\t\ts := v.Str(nil)\n\t\tenc.PutString(s)\n\tcase DateType, DateTimeType:\n\t\tt := v.DateTime(nil)\n\t\tenc.PutVarint(t.UnixNano())\n\t\tenc.PutVarint(int64(b.getLocationID(t)))\n\tcase TableType:\n\t\tv.Table(nil).Marshal(ctx, enc)\n\tcase StructType:\n\t\ts := v.Struct(nil)\n\t\tnFields := s.Len()\n\t\tenc.PutVarint(int64(nFields))\n\t\ttmp := b.tmpPool.Get()\n\t\ttmp.colNames = tmp.colNames[:0]\n\t\tfor i := 0; i < nFields; i++ {\n\t\t\tf := s.Field(i)\n\t\t\ttmp.colNames = append(tmp.colNames, f.Name)\n\t\t\tcol := b.internCol(f.Name, f.Value.Type())\n\t\t\tenc.PutVarint(int64(col.Col))\n\t\t\tb.marshalValue(ctx, enc, f.Value)\n\t\t}\n\t\tb.colSorter.AddColumns(tmp.colNames)\n\t\tb.tmpPool.Put(tmp)\n\tdefault:\n\t\tlog.Panicf(\"writebinarytsv: invalid value %v (%s)\", v, DescribeValue(v))\n\t}\n}", "func (d *Diskv) Write(key string, val []byte) error {\n\treturn d.write(key, val, false)\n}", "func DigestFile(filename string) (string, error) {\n\tb, err := DigestFileBytes(filename)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn hex.EncodeToString(b), nil\n}", "func (vlog *valueLog) write(reqs []*request) error {\n\tfor i := range reqs {\n\t\tb := reqs[i]\n\t\tfor j := range b.Entries {\n\t\t\te := b.Entries[j]\n\t\t\tplen, err := encodeEntry(e, &vlog.buf) // Now encode the entry into buffer.\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tvlog.curWriter.Append(vlog.buf.Bytes())\n\t\t\tvlog.buf.Reset()\n\t\t\tvlog.pendingLen += plen\n\t\t\te.logOffset.fid = vlog.currentLogFile().fid\n\t\t\t// Use the offset including buffer length so far.\n\t\t\te.logOffset.offset = vlog.writableOffset() + uint32(vlog.pendingLen)\n\t\t}\n\t\tvlog.numEntriesWritten += uint32(len(b.Entries))\n\t\t// We write to disk here so that all entries that are part of the same transaction are\n\t\t// written to the same vlog file.\n\t\twriteNow :=\n\t\t\tvlog.writableOffset()+uint32(vlog.pendingLen) > uint32(vlog.opt.ValueLogFileSize) ||\n\t\t\t\tvlog.numEntriesWritten > uint32(vlog.opt.ValueLogMaxEntries)\n\t\tif writeNow {\n\t\t\tif err := vlog.flush(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn vlog.flush()\n\n\t// Acquire mutex locks around this manipulation, so that the reads don't try to use\n\t// an invalid file descriptor.\n}", "func (p *Stream) WriteUint64(v uint64) {\n\tif v < 10 {\n\t\tp.writeFrame[p.writeIndex] = byte(v + 54)\n\t\tp.writeIndex++\n\t\tif p.writeIndex == streamBlockSize {\n\t\t\tp.gotoNextWriteFrame()\n\t\t}\n\t} else if v < 65536 {\n\t\tif p.writeIndex < streamBlockSize-3 {\n\t\t\tb := p.writeFrame[p.writeIndex:]\n\t\t\tb[0] = 9\n\t\t\tb[1] = byte(v)\n\t\t\tb[2] = byte(v >> 8)\n\t\t\tp.writeIndex += 3\n\t\t\treturn\n\t\t}\n\t\tp.PutBytes([]byte{\n\t\t\t9,\n\t\t\tbyte(v),\n\t\t\tbyte(v >> 8),\n\t\t})\n\t} else if v < 4294967296 {\n\t\tif p.writeIndex < streamBlockSize-5 {\n\t\t\tb := p.writeFrame[p.writeIndex:]\n\t\t\tb[0] = 10\n\t\t\tb[1] = byte(v)\n\t\t\tb[2] = byte(v >> 8)\n\t\t\tb[3] = byte(v >> 16)\n\t\t\tb[4] = byte(v >> 24)\n\t\t\tp.writeIndex += 5\n\t\t\treturn\n\t\t}\n\t\tp.PutBytes([]byte{\n\t\t\t10,\n\t\t\tbyte(v),\n\t\t\tbyte(v >> 8),\n\t\t\tbyte(v >> 16),\n\t\t\tbyte(v >> 24),\n\t\t})\n\t} else {\n\t\tif p.writeIndex < streamBlockSize-9 {\n\t\t\tb := p.writeFrame[p.writeIndex:]\n\t\t\tb[0] = 11\n\t\t\tb[1] = byte(v)\n\t\t\tb[2] = byte(v >> 8)\n\t\t\tb[3] = byte(v >> 16)\n\t\t\tb[4] = byte(v >> 24)\n\t\t\tb[5] = byte(v >> 32)\n\t\t\tb[6] = byte(v >> 40)\n\t\t\tb[7] = byte(v >> 48)\n\t\t\tb[8] = byte(v >> 56)\n\t\t\tp.writeIndex += 9\n\t\t\treturn\n\t\t}\n\t\tp.PutBytes([]byte{\n\t\t\t11,\n\t\t\tbyte(v),\n\t\t\tbyte(v >> 8),\n\t\t\tbyte(v >> 16),\n\t\t\tbyte(v >> 24),\n\t\t\tbyte(v >> 32),\n\t\t\tbyte(v >> 40),\n\t\t\tbyte(v >> 48),\n\t\t\tbyte(v >> 56),\n\t\t})\n\t}\n}", "func (t *Tree) Digest() *crypto.Digest { return t.dig }", "func (entry LogEntry) Write(w io.Writer, byteOrder binary.ByteOrder) (length int, err error) {\n\n\t// logID LSN\n\tlength += binary.Size(entry.logID)\n\terr = binary.Write(w, byteOrder, entry.logID)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tstdlog.Printf(\"write logId: %v\\n\", entry.logID)\n\n\t// symID\n\tlength += binary.Size(entry.symbolID)\n\terr = binary.Write(w, byteOrder, entry.symbolID)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tstdlog.Printf(\"write symId: %v\\n\", entry.symbolID)\n\n\t// timestamp\n\tlength += binary.Size(entry.timeStamp)\n\terr = binary.Write(w, byteOrder, entry.timeStamp)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tstdlog.Printf(\"write timestamp: %v\\n\", entry.timeStamp)\n\n\t// length of value data\n\tlength += 4\n\tvalLen := sizeOfValues(entry.valueList)\n\terr = binary.Write(w, byteOrder, valLen)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tstdlog.Printf(\"write value len: %v\\n\", valLen)\n\n\t// value data\n\t// Note: no type info is stored in the data log\n\t// Type info is kept in the sym file\n\tlength += int(valLen)\n\terr = writeValueList(w, byteOrder, entry.valueList)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn length, nil\n}", "func (g *Graphite) Write(_ context.Context, vl *api.ValueList) error {\n\tfor i, v := range vl.Values {\n\t\tdsName := \"\"\n\t\tif g.AlwaysAppendDS || len(vl.Values) != 1 {\n\t\t\tdsName = vl.DSName(i)\n\t\t}\n\n\t\tname := g.formatName(vl.Identifier, dsName)\n\n\t\tval, err := g.formatValue(v)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tt := vl.Time\n\t\tif t.IsZero() {\n\t\t\tt = time.Now()\n\t\t}\n\n\t\tfmt.Fprintf(g.W, \"%s %s %d\\r\\n\", name, val, t.Unix())\n\t}\n\n\treturn nil\n}", "func (d *Diskv) write(key string, val []byte, sync bool) error {\n\tif len(key) <= 0 {\n\t\treturn fmt.Errorf(\"empty key\")\n\t}\n\n\td.Lock()\n\tdefer d.Unlock()\n\tif err := d.ensurePath(key); err != nil {\n\t\treturn err\n\t}\n\n\tcompressedVal, err := d.compress(val)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmode := os.O_WRONLY | os.O_CREATE | os.O_TRUNC // overwrite if exists\n\tf, err := os.OpenFile(d.completeFilename(key), mode, d.FilePerm)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif _, err = f.Write(compressedVal); err != nil {\n\t\tf.Close() // error deliberately ignored\n\t\treturn err\n\t}\n\n\tif sync {\n\t\tif err := f.Sync(); err != nil {\n\t\t\tf.Close() // error deliberately ignored\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif err := f.Close(); err != nil {\n\t\treturn err\n\t}\n\n\tif d.Index != nil {\n\t\td.Index.Insert(key)\n\t}\n\n\tdelete(d.cache, key) // cache only on read\n\treturn nil\n}", "func (value *Value) write(w io.Writer) {\n\tswitch value.T {\n\tcase StringType:\n\t\tfmt.Fprintf(w, \"{%s}\", value.S)\n\tcase NumberType:\n\t\tfmt.Fprintf(w, \"%d\", value.I)\n\tcase SymbolType:\n\t\tfmt.Fprintf(w, \"%s\", value.S)\n\tdefault:\n\t\tpanic(\"unknown field value type\")\n\t}\n}", "func (e *encoder) writeUint(val uint64, size int) {\n\te.head = align(e.head, size)\n\tfor i := e.head; i < e.head+size; i++ {\n\t\te.buffer[i] = byte(val & 0xFF)\n\t\tval >>= 8\n\t}\n\te.head += size\n}", "func writeTTEntry(tt []TTEntryT, zobrist uint64, eval EvalCp, bestMove dragon.Move, depthToGo int, evalType TTEvalT) {\n\tvar entry TTEntryT // use a full struct overwrite to obliterate old data\n\n\t// Do we already have an entry for the hash?\n\toldTTEntry, isHit := probeTT(tt, zobrist)\n\n\tif isHit {\n\t\tentry = oldTTEntry\n\t\tupdateTTEntry(&entry, eval, bestMove, depthToGo, evalType)\n\t} else {\n\t\t// initialise a new entry\n\t\tentry.zobrist = zobrist\n\n\t\tpEntry := &entry.parityHits[depthToGoParity(depthToGo)]\n\n\t\tpEntry.eval = eval\n\t\tpEntry.bestMove = bestMove\n\t\tpEntry.depthToGo = uint8(depthToGo)\n\t\tpEntry.evalType = evalType\n\t}\n\tindex := ttIndex(tt, zobrist)\n\ttt[index] = entry\n}", "func (d *Digester) Digest(ctx context.Context, sub broker.Subscriber, opts ...digester.Option) error {\n\tdopts := digester.Options{}\n\tfor _, apply := range opts {\n\t\tapply(&dopts)\n\t}\n\n\th := dopts.Handler\n\tif h == nil {\n\t\th = handlers.DumpData\n\t}\n\n\treturn d.handle(ctx, sub, h)\n}", "func (s *Series) Push(t uint32, v float64) {\n\ts.Lock()\n\tdefer s.Unlock()\n\n\tif s.t == 0 {\n\t\t// first point\n\t\ts.t = t\n\t\ts.val = v\n\t\ts.tDelta = t - s.T0\n\t\ts.bw.writeBits(uint64(s.tDelta), 14)\n\t\ts.bw.writeBits(math.Float64bits(v), 64)\n\t\treturn\n\t}\n\n\ttDelta := t - s.t\n\tdod := int32(tDelta - s.tDelta)\n\n\tswitch {\n\tcase dod == 0:\n\t\ts.bw.writeBit(zero)\n\tcase -63 <= dod && dod <= 64:\n\t\ts.bw.writeBits(0x02, 2) // '10'\n\t\ts.bw.writeBits(uint64(dod), 7)\n\tcase -255 <= dod && dod <= 256:\n\t\ts.bw.writeBits(0x06, 3) // '110'\n\t\ts.bw.writeBits(uint64(dod), 9)\n\tcase -2047 <= dod && dod <= 2048:\n\t\ts.bw.writeBits(0x0e, 4) // '1110'\n\t\ts.bw.writeBits(uint64(dod), 12)\n\tdefault:\n\t\ts.bw.writeBits(0x0f, 4) // '1111'\n\t\ts.bw.writeBits(uint64(dod), 32)\n\t}\n\n\tvDelta := math.Float64bits(v) ^ math.Float64bits(s.val)\n\n\tif vDelta == 0 {\n\t\ts.bw.writeBit(zero)\n\t} else {\n\t\ts.bw.writeBit(one)\n\n\t\tleading := uint8(bits.LeadingZeros64(vDelta))\n\t\ttrailing := uint8(bits.TrailingZeros64(vDelta))\n\n\t\t// clamp number of leading zeros to avoid overflow when encoding\n\t\tif leading >= 32 {\n\t\t\tleading = 31\n\t\t}\n\n\t\t// TODO(dgryski): check if it's 'cheaper' to reset the leading/trailing bits instead\n\t\tif s.leading != ^uint8(0) && leading >= s.leading && trailing >= s.trailing {\n\t\t\ts.bw.writeBit(zero)\n\t\t\ts.bw.writeBits(vDelta>>s.trailing, 64-int(s.leading)-int(s.trailing))\n\t\t} else {\n\t\t\ts.leading, s.trailing = leading, trailing\n\n\t\t\ts.bw.writeBit(one)\n\t\t\ts.bw.writeBits(uint64(leading), 5)\n\n\t\t\t// Note that if leading == trailing == 0, then sigbits == 64. But that value doesn't actually fit into the 6 bits we have.\n\t\t\t// Luckily, we never need to encode 0 significant bits, since that would put us in the other case (vdelta == 0).\n\t\t\t// So instead we write out a 0 and adjust it back to 64 on unpacking.\n\t\t\tsigbits := 64 - leading - trailing\n\t\t\ts.bw.writeBits(uint64(sigbits), 6)\n\t\t\ts.bw.writeBits(vDelta>>trailing, int(sigbits))\n\t\t}\n\t}\n\n\ts.tDelta = tDelta\n\ts.t = t\n\ts.val = v\n\n}", "func Hash(i interface{}) string {\n\tv := reflect.ValueOf(i)\n\tif v.Kind() != reflect.Ptr {\n\t\tif !v.CanAddr(){\n\t\t\treturn \"\"\n\t\t}\n\t\tv = v.Addr()\n\t}\n\n\tsize := unsafe.Sizeof(v.Interface())\n\tb := (*[1 << 10]uint8)(unsafe.Pointer(v.Pointer()))[:size:size]\n\n\th := md5.New()\n\treturn base64.StdEncoding.EncodeToString(h.Sum(b))\n}", "func WithDigest(name Named, digest digest.Digest) (Canonical, error) {\n\tif !anchoredDigestRegexp.MatchString(digest.String()) {\n\t\treturn nil, ErrDigestInvalidFormat\n\t}\n\tvar repo repository\n\tif r, ok := name.(namedRepository); ok {\n\t\trepo.domain = r.Domain()\n\t\trepo.path = r.Path()\n\t} else {\n\t\trepo.path = name.Name()\n\t}\n\tif tagged, ok := name.(Tagged); ok {\n\t\treturn reference{\n\t\t\tnamedRepository: repo,\n\t\t\ttag: tagged.Tag(),\n\t\t\tdigest: digest,\n\t\t}, nil\n\t}\n\treturn canonicalReference{\n\t\tnamedRepository: repo,\n\t\tdigest: digest,\n\t}, nil\n}", "func expandDigestToHash(letter string) schema.MD5Hash {\n\tdigest := expandDigest(letter)\n\tdb, err := sql.DigestToBytes(digest)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn sql.AsMD5Hash(db)\n}", "func DigestSize() int {\n\treturn sha256DigestSize\n}", "func NVWriteValue(rw io.ReadWriter, index, offset uint32, data []byte, ownAuth []byte) error {\n\tif ownAuth == nil {\n\t\tif _, _, _, err := nvWriteValue(rw, index, offset, uint32(len(data)), data, nil); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write to NVRAM: %v\", err)\n\t\t}\n\t\treturn nil\n\t}\n\tsharedSecretOwn, osaprOwn, err := newOSAPSession(rw, etOwner, khOwner, ownAuth[:])\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to start new auth session: %v\", err)\n\t}\n\tdefer osaprOwn.Close(rw)\n\tdefer zeroBytes(sharedSecretOwn[:])\n\tauthIn := []interface{}{ordNVWriteValue, index, offset, len(data), data}\n\tca, err := newCommandAuth(osaprOwn.AuthHandle, osaprOwn.NonceEven, nil, sharedSecretOwn[:], authIn)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to construct owner auth fields: %v\", err)\n\t}\n\tdata, ra, ret, err := nvWriteValue(rw, index, offset, uint32(len(data)), data, ca)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to write to NVRAM: %v\", err)\n\t}\n\traIn := []interface{}{ret, ordNVWriteValue, tpmutil.U32Bytes(data)}\n\tif err := ra.verify(ca.NonceOdd, sharedSecretOwn[:], raIn); err != nil {\n\t\treturn fmt.Errorf(\"failed to verify authenticity of response: %v\", err)\n\t}\n\treturn nil\n}", "func (c *cpu) writev() {\n\tsp, iovcnt := popI32(c.sp)\n\tsp, iov := popPtr(sp)\n\tfd := readI32(sp)\n\tn, _, err := syscall.Syscall(syscall.SYS_WRITEV, uintptr(fd), iov, uintptr(iovcnt))\n\tif strace {\n\t\tfmt.Fprintf(os.Stderr, \"writev(%#x, %#x, %#x) %v %v\\t; %s\\n\", fd, iov, iovcnt, n, err, c.pos())\n\t}\n\tif err != 0 {\n\t\tc.setErrno(err)\n\t\twriteLong(c.rp, -1)\n\t\treturn\n\t}\n\n\twriteLong(c.rp, int64(n))\n}", "func (p *Stream) writeRTMap(v RTMap) string {\n\tif thread := v.rt.thread; thread != nil {\n\t\treadStream := thread.rtStream\n\t\tlength := int(*v.length)\n\n\t\tif length == 0 {\n\t\t\tp.writeFrame[p.writeIndex] = 96\n\t\t\tp.writeIndex++\n\t\t\tif p.writeIndex == streamBlockSize {\n\t\t\t\tp.gotoNextWriteFrame()\n\t\t\t}\n\t\t\treturn StreamWriteOK\n\t\t}\n\n\t\tstartPos := p.GetWritePos()\n\n\t\tb := p.writeFrame[p.writeIndex:]\n\t\tif p.writeIndex < streamBlockSize-5 {\n\t\t\tp.writeIndex += 5\n\t\t} else {\n\t\t\tb = b[0:1]\n\t\t\tp.SetWritePos(startPos + 5)\n\t\t}\n\n\t\tif length < 31 {\n\t\t\tb[0] = byte(96 + length)\n\t\t} else {\n\t\t\tb[0] = 127\n\t\t}\n\n\t\tif length > 30 {\n\t\t\tif p.writeIndex < streamBlockSize-4 {\n\t\t\t\tl := p.writeFrame[p.writeIndex:]\n\t\t\t\tl[0] = byte(uint32(length))\n\t\t\t\tl[1] = byte(uint32(length) >> 8)\n\t\t\t\tl[2] = byte(uint32(length) >> 16)\n\t\t\t\tl[3] = byte(uint32(length) >> 24)\n\t\t\t\tp.writeIndex += 4\n\t\t\t} else {\n\t\t\t\tp.PutBytes([]byte{\n\t\t\t\t\tbyte(uint32(length)),\n\t\t\t\t\tbyte(uint32(length) >> 8),\n\t\t\t\t\tbyte(uint32(length) >> 16),\n\t\t\t\t\tbyte(uint32(length) >> 24),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tif v.items != nil {\n\t\t\titems := *v.items\n\t\t\tfor i := 0; i < length; i++ {\n\t\t\t\tp.WriteString(items[i].key)\n\t\t\t\treadStream.SetReadPos(int(items[i].pos.getPos()))\n\t\t\t\tif !p.writeStreamNext(readStream) {\n\t\t\t\t\tp.SetWritePos(startPos)\n\t\t\t\t\treturn StreamWriteIsNotAvailable\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\ttotalLength := uint32(p.GetWritePos() - startPos)\n\t\tif len(b) > 1 {\n\t\t\tb[1] = byte(totalLength)\n\t\t\tb[2] = byte(totalLength >> 8)\n\t\t\tb[3] = byte(totalLength >> 16)\n\t\t\tb[4] = byte(totalLength >> 24)\n\t\t} else {\n\t\t\tendPos := p.GetWritePos()\n\t\t\tp.SetWritePos(startPos + 1)\n\t\t\tp.PutBytes([]byte{\n\t\t\t\tbyte(totalLength),\n\t\t\t\tbyte(totalLength >> 8),\n\t\t\t\tbyte(totalLength >> 16),\n\t\t\t\tbyte(totalLength >> 24),\n\t\t\t})\n\t\t\tp.SetWritePos(endPos)\n\t\t}\n\n\t\treturn StreamWriteOK\n\t}\n\n\treturn StreamWriteIsNotAvailable\n}", "func (s *Storage) WriteCanonicalHash(n *big.Int, hash common.Hash) {\n\ts.set(CANONICAL, n.Bytes(), hash.Bytes())\n}", "func writeTestLayer(driver storagedriver.StorageDriver, pathMapper *pathMapper, name string, dgst digest.Digest, content io.Reader) (digest.Digest, error) {\n\th := sha256.New()\n\trd := io.TeeReader(content, h)\n\n\tp, err := ioutil.ReadAll(rd)\n\n\tif err != nil {\n\t\treturn \"\", nil\n\t}\n\n\tblobDigestSHA := digest.NewDigest(\"sha256\", h)\n\n\tblobPath, err := pathMapper.path(blobDataPathSpec{\n\t\tdigest: dgst,\n\t})\n\n\tif err := driver.PutContent(blobPath, p); err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tlayerLinkPath, err := pathMapper.path(layerLinkPathSpec{\n\t\tname: name,\n\t\tdigest: dgst,\n\t})\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif err := driver.PutContent(layerLinkPath, []byte(dgst)); err != nil {\n\t\treturn \"\", nil\n\t}\n\n\treturn blobDigestSHA, err\n}", "func WriteDouble(buffer []byte, offset int, value float64) {\n WriteUInt64(buffer, offset, math.Float64bits(value))\n}", "func SHA512Digest(s string) string {\n\th := sha512.Sum512([]byte(s))\n\treturn hex.EncodeToString(h[:])\n}", "func (t *Tube) Write(key string, rev Rev, value interface{}) (changed bool) {\n\t// log.Printf(\"tube writing (%s,%d,%v)\", key, rev, value)\n\t// defer func() {\n\t// \tlog.Printf(\"tube written to, changed=%v\\n%s\", changed, t.Dump())\n\t// }()\n\n\tt.Lock()\n\tdefer t.Unlock()\n\tchanged = t.view.Update(&Record{\n\t\tKey: key,\n\t\tRev: rev,\n\t\tValue: value,\n\t\tUpdated: time.Now(),\n\t})\n\tif changed {\n\t\tgo t.writeSync(key, rev, value) // synchronize downstream tubes\n\t}\n\treturn\n}", "func hash(stav Stav) uint64{\n\tstr := \"\"\n\n\tfor i := 0; i < len(stav.Auta); i++ {\n\t\tstr += stav.Auta[i].Farba\n\t\tstr += strconv.Itoa(int(stav.Auta[i].X))\n\t\tstr += strconv.Itoa(int(stav.Auta[i].Y))\n\t\tstr += strconv.FormatBool(stav.Auta[i].Smer)\n\t\tstr += strconv.Itoa(int(stav.Auta[i].Dlzka))\n\t}\n\n\th := fnv.New64a()\n\th.Write([]byte(str))\n\treturn h.Sum64()\n\n}", "func (e *Encoder) PutHash(h hash.Hash) {\n\te.write(h[:])\n}", "func (fi *FileIO) WriteAtv(bs [][]byte, off int64) (int, error) {\n\treturn linuxWriteAtv(fi, bs, off)\n}", "func (es *externalSigner) NewDigest(sig *model.PdfSignature) (model.Hasher, error) {\n\treturn bytes.NewBuffer(nil), nil\n}", "func TestWrite(t *testing.T) {\n\tmockZooKeeper := &MockZooHandle{\n\t\tzk: mock.Mock{},\n\t}\n\n\tbytes := make([]byte, 3)\n\tff := NewFuseFile(bytes, 0, \"mock/path\", mockZooKeeper)\n\n\tmockZooKeeper.zk.On(\"Set\", \"mock/path\", bytes, int32(-1)).Return(&zk.Stat{DataLength: int32(len(bytes))}, nil)\n\n\t// assert that we send 3 bytes into the writer and status out == fuse.OK\n\tsize, stat := ff.Write(bytes, 0)\n\tassert.Equal(t, uint32(3), size)\n\tassert.Equal(t, fuse.OK, stat)\n}", "func (t *Tfhd) Write() []byte {\n\tbuf := new(bytes.Buffer)\n\tvar err error\n\t// Size\n\terr = binary.Write(buf, binary.BigEndian, t.Size)\n\tif err != nil {\n\t\tfmt.Println(\"binary.Write failed:\", err)\n\t}\n\t// BoxType\n\terr = binary.Write(buf, binary.BigEndian, t.BoxType)\n\tif err != nil {\n\t\tfmt.Println(\"binary.Write failed:\", err)\n\t}\n\t//version\n\terr = binary.Write(buf, binary.BigEndian, t.Version)\n\tif err != nil {\n\t\tfmt.Println(\"binary.Write failed:\", err)\n\t}\n\t//flags\n\terr = binary.Write(buf, binary.BigEndian, t.Flags)\n\tif err != nil {\n\t\tfmt.Println(\"binary.Write failed:\", err)\n\t}\n\t//trackID\n\terr = binary.Write(buf, binary.BigEndian, t.TrackID)\n\tif err != nil {\n\t\tfmt.Println(\"binary.Write failed:\", err)\n\t}\n\tif t.BaseDataOffset != 0 {\n\t\terr = binary.Write(buf, binary.BigEndian, t.BaseDataOffset)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"binary.Write failed:\", err)\n\t\t}\n\t}\n\tif t.SampleDescriptionIndex != 0 {\n\t\terr = binary.Write(buf, binary.BigEndian, t.SampleDescriptionIndex)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"binary.Write failed:\", err)\n\t\t}\n\t}\n\tif t.DefaultSampleDuration != 0 {\n\t\terr = binary.Write(buf, binary.BigEndian, t.DefaultSampleDuration)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"binary.Write failed:\", err)\n\t\t}\n\t}\n\tif t.DefaultSampleSize != 0 {\n\t\terr = binary.Write(buf, binary.BigEndian, t.DefaultSampleSize)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"binary.Write failed:\", err)\n\t\t}\n\t}\n\tif t.DefaultSampleFlags != 0 {\n\t\terr = binary.Write(buf, binary.BigEndian, t.DefaultSampleFlags)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"binary.Write failed:\", err)\n\t\t}\n\t}\n\treturn buf.Bytes()\n}", "func (ref *digest) Write(src []byte) (int, error) {\n\tsln := uintptr(len(src))\n\tfln := len(src)\n\tbuf := ref.b[:]\n\tptr := ref.ptr\n\n\tif sln < (BlockSize - ptr) {\n\t\tcopy(buf[ptr:], src)\n\t\tref.ptr += sln\n\t\treturn int(sln), nil\n\t}\n\n\tvar hi, lo [8]uint64\n\thi[0] = ref.h[0x0]\n\tlo[0] = ref.h[0x1]\n\thi[1] = ref.h[0x2]\n\tlo[1] = ref.h[0x3]\n\thi[2] = ref.h[0x4]\n\tlo[2] = ref.h[0x5]\n\thi[3] = ref.h[0x6]\n\tlo[3] = ref.h[0x7]\n\thi[4] = ref.h[0x8]\n\tlo[4] = ref.h[0x9]\n\thi[5] = ref.h[0xA]\n\tlo[5] = ref.h[0xB]\n\thi[6] = ref.h[0xC]\n\tlo[6] = ref.h[0xD]\n\thi[7] = ref.h[0xE]\n\tlo[7] = ref.h[0xF]\n\n\tfor sln > 0 {\n\t\tcln := BlockSize - ptr\n\n\t\tif cln > sln {\n\t\t\tcln = sln\n\t\t}\n\t\tsln -= cln\n\n\t\tcopy(ref.b[ptr:], src[:cln])\n\t\tsrc = src[cln:]\n\t\tptr += cln\n\n\t\tif ptr == BlockSize {\n\t\t\tm0h := decUInt64le(buf[0:])\n\t\t\tm0l := decUInt64le(buf[8:])\n\t\t\tm1h := decUInt64le(buf[16:])\n\t\t\tm1l := decUInt64le(buf[24:])\n\t\t\tm2h := decUInt64le(buf[32:])\n\t\t\tm2l := decUInt64le(buf[40:])\n\t\t\tm3h := decUInt64le(buf[48:])\n\t\t\tm3l := decUInt64le(buf[56:])\n\n\t\t\thi[0] ^= m0h\n\t\t\tlo[0] ^= m0l\n\t\t\thi[1] ^= m1h\n\t\t\tlo[1] ^= m1l\n\t\t\thi[2] ^= m2h\n\t\t\tlo[2] ^= m2l\n\t\t\thi[3] ^= m3h\n\t\t\tlo[3] ^= m3l\n\n\t\t\tfor r := uint64(0); r < 42; r += 7 {\n\t\t\t\tslMutateExtend(r+0, 0, hi[:], lo[:])\n\t\t\t\tslMutateExtend(r+1, 1, hi[:], lo[:])\n\t\t\t\tslMutateExtend(r+2, 2, hi[:], lo[:])\n\t\t\t\tslMutateExtend(r+3, 3, hi[:], lo[:])\n\t\t\t\tslMutateExtend(r+4, 4, hi[:], lo[:])\n\t\t\t\tslMutateExtend(r+5, 5, hi[:], lo[:])\n\t\t\t\tslMutateBasic(r+6, hi[:], lo[:])\n\t\t\t}\n\n\t\t\thi[4] ^= m0h\n\t\t\tlo[4] ^= m0l\n\t\t\thi[5] ^= m1h\n\t\t\tlo[5] ^= m1l\n\t\t\thi[6] ^= m2h\n\t\t\tlo[6] ^= m2l\n\t\t\thi[7] ^= m3h\n\t\t\tlo[7] ^= m3l\n\n\t\t\tref.cnt++\n\t\t\tptr = 0\n\t\t}\n\t}\n\n\tref.h[0x0] = hi[0]\n\tref.h[0x1] = lo[0]\n\tref.h[0x2] = hi[1]\n\tref.h[0x3] = lo[1]\n\tref.h[0x4] = hi[2]\n\tref.h[0x5] = lo[2]\n\tref.h[0x6] = hi[3]\n\tref.h[0x7] = lo[3]\n\tref.h[0x8] = hi[4]\n\tref.h[0x9] = lo[4]\n\tref.h[0xA] = hi[5]\n\tref.h[0xB] = lo[5]\n\tref.h[0xC] = hi[6]\n\tref.h[0xD] = lo[6]\n\tref.h[0xE] = hi[7]\n\tref.h[0xF] = lo[7]\n\n\tref.ptr = ptr\n\treturn fln, nil\n}", "func (r *Repository) Put(ctx context.Context, body io.Reader) (digest.Digest, error) {\n\ttemp, err := r.TempFile(\"create-\")\n\tif err != nil {\n\t\treturn digest.Digest{}, err\n\t}\n\tdefer os.Remove(temp.Name())\n\tdw := reflow.Digester.NewWriter()\n\tdone := make(chan error, 1)\n\t// This is a workaround to make sure that copies respect\n\t// context cancellations. Note that the underlying copy is\n\t// not actually cancelled, so this could lead to goroutine\n\t// leaks.\n\tgo func() {\n\t\t_, err = io.Copy(temp, io.TeeReader(body, dw))\n\t\ttemp.Close()\n\t\tdone <- err\n\t}()\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn digest.Digest{}, ctx.Err()\n\tcase err := <-done:\n\t\tif err != nil {\n\t\t\treturn digest.Digest{}, err\n\t\t}\n\t\tdgst := dw.Digest()\n\t\treturn dgst, r.InstallDigest(dgst, temp.Name())\n\t}\n}", "func DigestUrl(baseURL string, digest types.Digest) string {\n\tbaseURL = strings.TrimRight(baseURL, \"/\")\n\treturn fmt.Sprintf(urlTemplate, baseURL, digest)\n}", "func (x *Index) Write(w io.Writer) error", "func (commit *Commit) Digest() []byte {\n\treturn commit.signingID.Hash(commit.signedRequest.GetRequest())\n}", "func (w *DiskImage) Digest() digest.Digest {\n\treturn w.digester.Digest()\n}" ]
[ "0.7222287", "0.61005545", "0.55415916", "0.5209088", "0.5083807", "0.5052842", "0.4941014", "0.48079118", "0.48077276", "0.48063084", "0.4738801", "0.4712518", "0.4684972", "0.46651158", "0.4654325", "0.4654092", "0.46490794", "0.46484983", "0.46432567", "0.46338454", "0.46325088", "0.4627105", "0.46171677", "0.4612079", "0.4565844", "0.4562752", "0.45210096", "0.4519383", "0.45006034", "0.4480316", "0.44425663", "0.44353738", "0.4428572", "0.44108114", "0.44088423", "0.4405481", "0.44000605", "0.43936613", "0.43879494", "0.43853682", "0.4384337", "0.437897", "0.4376615", "0.4356264", "0.43414104", "0.43393704", "0.43355522", "0.43137047", "0.43119633", "0.42980987", "0.42861038", "0.4272985", "0.42701417", "0.4269588", "0.42682436", "0.42647967", "0.42638192", "0.42537624", "0.42532486", "0.4231795", "0.42201442", "0.42124006", "0.42116523", "0.4200598", "0.41998407", "0.41978604", "0.41939557", "0.41917425", "0.4190685", "0.41854", "0.41842657", "0.41829956", "0.4169701", "0.41615853", "0.41500765", "0.41449952", "0.41440707", "0.41434488", "0.41420862", "0.4140696", "0.4132823", "0.41314262", "0.41280425", "0.4116212", "0.41159177", "0.4115693", "0.4114474", "0.4110506", "0.41075298", "0.4105372", "0.41024035", "0.41003492", "0.40946376", "0.40938383", "0.4092764", "0.40847337", "0.4075287", "0.40735316", "0.4072808", "0.4070842" ]
0.8357803
0
OnUpdateManifest is called when a new manifest is added. It updates metadb according to the type of image pushed(normal images, signatues, etc.). In care of any errors, it makes sure to keep consistency between metadb and the image store.
OnUpdateManifest вызывается при добавлении нового манифеста. Он обновляет metadb в зависимости от типа загруженного изображения (обычные изображения, подписи и т.д.). В случае возникновения любых ошибок он обеспечивает согласованность между metadb и хранилищем изображений.
func OnUpdateManifest(repo, reference, mediaType string, digest godigest.Digest, body []byte, storeController storage.StoreController, metaDB mTypes.MetaDB, log log.Logger, ) error { imgStore := storeController.GetImageStore(repo) // check if image is a signature isSignature, signatureType, signedManifestDigest, err := storage.CheckIsImageSignature(repo, body, reference) if err != nil { log.Error().Err(err).Msg("can't check if image is a signature or not") if err := imgStore.DeleteImageManifest(repo, reference, false); err != nil { log.Error().Err(err).Str("manifest", reference).Str("repository", repo).Msg("couldn't remove image manifest in repo") return err } return err } metadataSuccessfullySet := true if isSignature { layersInfo, errGetLayers := GetSignatureLayersInfo(repo, reference, digest.String(), signatureType, body, imgStore, log) if errGetLayers != nil { metadataSuccessfullySet = false err = errGetLayers } else { err = metaDB.AddManifestSignature(repo, signedManifestDigest, mTypes.SignatureMetadata{ SignatureType: signatureType, SignatureDigest: digest.String(), LayersInfo: layersInfo, }) if err != nil { log.Error().Err(err).Msg("metadb: error while putting repo meta") metadataSuccessfullySet = false } else { err = metaDB.UpdateSignaturesValidity(repo, signedManifestDigest) if err != nil { log.Error().Err(err).Str("repository", repo).Str("reference", reference).Str("digest", signedManifestDigest.String()).Msg("metadb: failed verify signatures validity for signed image") metadataSuccessfullySet = false } } } } else { err = SetImageMetaFromInput(repo, reference, mediaType, digest, body, imgStore, metaDB, log) if err != nil { metadataSuccessfullySet = false } } if !metadataSuccessfullySet { log.Info().Str("tag", reference).Str("repository", repo).Msg("uploading image meta was unsuccessful for tag in repo") if err := imgStore.DeleteImageManifest(repo, reference, false); err != nil { log.Error().Err(err).Str("reference", reference).Str("repository", repo). Msg("couldn't remove image manifest in repo") return err } return err } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func OnGetManifest(name, reference string, body []byte,\n\tstoreController storage.StoreController, metaDB mTypes.MetaDB, log log.Logger,\n) error {\n\t// check if image is a signature\n\tisSignature, _, _, err := storage.CheckIsImageSignature(name, body, reference)\n\tif err != nil {\n\t\tlog.Error().Err(err).Msg(\"can't check if manifest is a signature or not\")\n\n\t\treturn err\n\t}\n\n\tif !isSignature {\n\t\terr := metaDB.IncrementImageDownloads(name, reference)\n\t\tif err != nil {\n\t\t\tlog.Error().Err(err).Str(\"repository\", name).Str(\"reference\", reference).\n\t\t\t\tMsg(\"unexpected error for image\")\n\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func OnDeleteManifest(repo, reference, mediaType string, digest godigest.Digest, manifestBlob []byte,\n\tstoreController storage.StoreController, metaDB mTypes.MetaDB, log log.Logger,\n) error {\n\timgStore := storeController.GetImageStore(repo)\n\n\tisSignature, signatureType, signedManifestDigest, err := storage.CheckIsImageSignature(repo, manifestBlob,\n\t\treference)\n\tif err != nil {\n\t\tlog.Error().Err(err).Msg(\"can't check if image is a signature or not\")\n\n\t\treturn err\n\t}\n\n\tmanageRepoMetaSuccessfully := true\n\n\tif isSignature {\n\t\terr = metaDB.DeleteSignature(repo, signedManifestDigest, mTypes.SignatureMetadata{\n\t\t\tSignatureDigest: digest.String(),\n\t\t\tSignatureType: signatureType,\n\t\t})\n\t\tif err != nil {\n\t\t\tlog.Error().Err(err).Msg(\"metadb: can't check if image is a signature or not\")\n\t\t\tmanageRepoMetaSuccessfully = false\n\t\t}\n\t} else {\n\t\terr = metaDB.DeleteRepoTag(repo, reference)\n\t\tif err != nil {\n\t\t\tlog.Info().Msg(\"metadb: restoring image store\")\n\n\t\t\t// restore image store\n\t\t\t_, _, err := imgStore.PutImageManifest(repo, reference, mediaType, manifestBlob)\n\t\t\tif err != nil {\n\t\t\t\tlog.Error().Err(err).Msg(\"metadb: error while restoring image store, database is not consistent\")\n\t\t\t}\n\n\t\t\tmanageRepoMetaSuccessfully = false\n\t\t}\n\n\t\tif referredDigest, hasSubject := common.GetReferredSubject(manifestBlob); hasSubject {\n\t\t\terr := metaDB.DeleteReferrer(repo, referredDigest, digest)\n\t\t\tif err != nil {\n\t\t\t\tlog.Error().Err(err).Msg(\"metadb: error while deleting referrer\")\n\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif !manageRepoMetaSuccessfully {\n\t\tlog.Info().Str(\"tag\", reference).Str(\"repository\", repo).\n\t\t\tMsg(\"metadb: deleting image meta was unsuccessful for tag in repo\")\n\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (imh *manifestHandler) PutManifest(w http.ResponseWriter, r *http.Request) {\n\tdcontext.GetLogger(imh).Debug(\"PutImageManifest\")\n\tmanifests, err := imh.Repository.Manifests(imh)\n\tif err != nil {\n\t\timh.Errors = append(imh.Errors, err)\n\t\treturn\n\t}\n\n\tvar jsonBuf bytes.Buffer\n\tif err := copyFullPayload(imh, w, r, &jsonBuf, maxManifestBodySize, \"image manifest PUT\"); err != nil {\n\t\t// copyFullPayload reports the error if necessary\n\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestInvalid.WithDetail(err.Error()))\n\t\treturn\n\t}\n\n\tmediaType := r.Header.Get(\"Content-Type\")\n\tmanifest, desc, err := distribution.UnmarshalManifest(mediaType, jsonBuf.Bytes())\n\tif err != nil {\n\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestInvalid.WithDetail(err))\n\t\treturn\n\t}\n\n\tif imh.Digest != \"\" {\n\t\tif desc.Digest != imh.Digest {\n\t\t\tdcontext.GetLogger(imh).Errorf(\"payload digest does not match: %q != %q\", desc.Digest, imh.Digest)\n\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeDigestInvalid)\n\t\t\treturn\n\t\t}\n\t} else if imh.Tag != \"\" {\n\t\timh.Digest = desc.Digest\n\t} else {\n\t\timh.Errors = append(imh.Errors, v2.ErrorCodeTagInvalid.WithDetail(\"no tag or digest specified\"))\n\t\treturn\n\t}\n\n\tisAnOCIManifest := mediaType == v1.MediaTypeImageManifest || mediaType == v1.MediaTypeImageIndex\n\n\tif isAnOCIManifest {\n\t\tdcontext.GetLogger(imh).Debug(\"Putting an OCI Manifest!\")\n\t} else {\n\t\tdcontext.GetLogger(imh).Debug(\"Putting a Docker Manifest!\")\n\t}\n\n\tvar options []distribution.ManifestServiceOption\n\tif imh.Tag != \"\" {\n\t\toptions = append(options, distribution.WithTag(imh.Tag))\n\t}\n\n\tif err := imh.applyResourcePolicy(manifest); err != nil {\n\t\timh.Errors = append(imh.Errors, err)\n\t\treturn\n\t}\n\n\t_, err = manifests.Put(imh, manifest, options...)\n\tif err != nil {\n\t\t// TODO(stevvooe): These error handling switches really need to be\n\t\t// handled by an app global mapper.\n\t\tif err == distribution.ErrUnsupported {\n\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnsupported)\n\t\t\treturn\n\t\t}\n\t\tif err == distribution.ErrAccessDenied {\n\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeDenied)\n\t\t\treturn\n\t\t}\n\t\tswitch err := err.(type) {\n\t\tcase distribution.ErrManifestVerification:\n\t\t\tfor _, verificationError := range err {\n\t\t\t\tswitch verificationError := verificationError.(type) {\n\t\t\t\tcase distribution.ErrManifestBlobUnknown:\n\t\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestBlobUnknown.WithDetail(verificationError.Digest))\n\t\t\t\tcase distribution.ErrManifestNameInvalid:\n\t\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeNameInvalid.WithDetail(err))\n\t\t\t\tcase distribution.ErrManifestUnverified:\n\t\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnverified)\n\t\t\t\tdefault:\n\t\t\t\t\tif verificationError == digest.ErrDigestInvalidFormat {\n\t\t\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeDigestInvalid)\n\t\t\t\t\t} else {\n\t\t\t\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown, verificationError)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tcase errcode.Error:\n\t\t\timh.Errors = append(imh.Errors, err)\n\t\tdefault:\n\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\t}\n\t\treturn\n\t}\n\n\t// Tag this manifest\n\tif imh.Tag != \"\" {\n\t\ttags := imh.Repository.Tags(imh)\n\t\terr = tags.Tag(imh, imh.Tag, desc)\n\t\tif err != nil {\n\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\t\treturn\n\t\t}\n\n\t}\n\n\t// Construct a canonical url for the uploaded manifest.\n\tref, err := reference.WithDigest(imh.Repository.Named(), imh.Digest)\n\tif err != nil {\n\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\treturn\n\t}\n\n\tlocation, err := imh.urlBuilder.BuildManifestURL(ref)\n\tif err != nil {\n\t\t// NOTE(stevvooe): Given the behavior above, this absurdly unlikely to\n\t\t// happen. We'll log the error here but proceed as if it worked. Worst\n\t\t// case, we set an empty location header.\n\t\tdcontext.GetLogger(imh).Errorf(\"error building manifest url from digest: %v\", err)\n\t}\n\n\tw.Header().Set(\"Location\", location)\n\tw.Header().Set(\"Docker-Content-Digest\", imh.Digest.String())\n\tw.WriteHeader(http.StatusCreated)\n\n\tdcontext.GetLogger(imh).Debug(\"Succeeded in putting manifest!\")\n}", "func (is *ImageStoreLocal) PutImageManifest(repo, reference, mediaType string, //nolint: gocyclo\n\tbody []byte,\n) (godigest.Digest, godigest.Digest, error) {\n\tif err := is.InitRepo(repo); err != nil {\n\t\tis.log.Debug().Err(err).Msg(\"init repo\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\tvar lockLatency time.Time\n\n\tvar err error\n\n\tis.Lock(&lockLatency)\n\tdefer func() {\n\t\tis.Unlock(&lockLatency)\n\n\t\tif err == nil {\n\t\t\tmonitoring.SetStorageUsage(is.metrics, is.rootDir, repo)\n\t\t\tmonitoring.IncUploadCounter(is.metrics, repo)\n\t\t}\n\t}()\n\n\trefIsDigest := true\n\n\tmDigest, err := common.GetAndValidateRequestDigest(body, reference, is.log)\n\tif err != nil {\n\t\tif errors.Is(err, zerr.ErrBadManifest) {\n\t\t\treturn mDigest, \"\", err\n\t\t}\n\n\t\trefIsDigest = false\n\t}\n\n\tdigest, err := common.ValidateManifest(is, repo, reference, mediaType, body, is.log)\n\tif err != nil {\n\t\treturn digest, \"\", err\n\t}\n\n\tindex, err := common.GetIndex(is, repo, is.log)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\t// create a new descriptor\n\tdesc := ispec.Descriptor{\n\t\tMediaType: mediaType, Size: int64(len(body)), Digest: mDigest,\n\t}\n\n\tif !refIsDigest {\n\t\tdesc.Annotations = map[string]string{ispec.AnnotationRefName: reference}\n\t}\n\n\tvar subjectDigest godigest.Digest\n\n\tartifactType := \"\"\n\n\tif mediaType == ispec.MediaTypeImageManifest {\n\t\tvar manifest ispec.Manifest\n\n\t\terr := json.Unmarshal(body, &manifest)\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", err\n\t\t}\n\n\t\tif manifest.Subject != nil {\n\t\t\tsubjectDigest = manifest.Subject.Digest\n\t\t}\n\n\t\tartifactType = zcommon.GetManifestArtifactType(manifest)\n\t} else if mediaType == ispec.MediaTypeImageIndex {\n\t\tvar index ispec.Index\n\n\t\terr := json.Unmarshal(body, &index)\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", err\n\t\t}\n\n\t\tif index.Subject != nil {\n\t\t\tsubjectDigest = index.Subject.Digest\n\t\t}\n\n\t\tartifactType = zcommon.GetIndexArtifactType(index)\n\t}\n\n\tupdateIndex, oldDgst, err := common.CheckIfIndexNeedsUpdate(&index, &desc, is.log)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\tif !updateIndex {\n\t\treturn desc.Digest, subjectDigest, nil\n\t}\n\n\t// write manifest to \"blobs\"\n\tdir := path.Join(is.rootDir, repo, \"blobs\", mDigest.Algorithm().String())\n\t_ = ensureDir(dir, is.log)\n\tfile := path.Join(dir, mDigest.Encoded())\n\n\t// in case the linter will not pass, it will be garbage collected\n\tif err := is.writeFile(file, body); err != nil {\n\t\tis.log.Error().Err(err).Str(\"file\", file).Msg(\"unable to write\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\terr = common.UpdateIndexWithPrunedImageManifests(is, &index, repo, desc, oldDgst, is.log)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\t// now update \"index.json\"\n\tindex.Manifests = append(index.Manifests, desc)\n\tdir = path.Join(is.rootDir, repo)\n\tfile = path.Join(dir, \"index.json\")\n\n\tbuf, err := json.Marshal(index)\n\tif err := inject.Error(err); err != nil {\n\t\tis.log.Error().Err(err).Str(\"file\", file).Msg(\"unable to marshal JSON\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\t// update the descriptors artifact type in order to check for signatures when applying the linter\n\tdesc.ArtifactType = artifactType\n\n\t// apply linter only on images, not signatures or indexes\n\tpass, err := common.ApplyLinter(is, is.linter, repo, desc)\n\tif !pass {\n\t\tis.log.Error().Err(err).Str(\"repository\", repo).Str(\"reference\", reference).Msg(\"linter didn't pass\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\terr = is.writeFile(file, buf)\n\tif err := inject.Error(err); err != nil {\n\t\tis.log.Error().Err(err).Str(\"file\", file).Msg(\"unable to write\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\treturn desc.Digest, subjectDigest, nil\n}", "func PushManifest(img string, auth dockertypes.AuthConfig) (hash string, length int, err error) {\n\tsrcImages := []types.ManifestEntry{}\n\n\tfor i, platform := range platformsToSearchForIndex {\n\t\tosArchArr := strings.Split(platform, \"/\")\n\t\tif len(osArchArr) != 2 && len(osArchArr) != 3 {\n\t\t\treturn hash, length, fmt.Errorf(\"platform argument %d is not of form 'os/arch': '%s'\", i, platform)\n\t\t}\n\t\tvariant := \"\"\n\t\tos, arch := osArchArr[0], osArchArr[1]\n\t\tif len(osArchArr) == 3 {\n\t\t\tvariant = osArchArr[2]\n\t\t}\n\t\tsrcImages = append(srcImages, types.ManifestEntry{\n\t\t\tImage: fmt.Sprintf(\"%s-%s\", img, arch),\n\t\t\tPlatform: ocispec.Platform{\n\t\t\t\tOS: os,\n\t\t\t\tArchitecture: arch,\n\t\t\t\tVariant: variant,\n\t\t\t},\n\t\t})\n\t}\n\n\tyamlInput := types.YAMLInput{\n\t\tImage: img,\n\t\tManifests: srcImages,\n\t}\n\n\tlog.Debugf(\"pushing manifest list for %s -> %#v\", img, yamlInput)\n\n\t// push the manifest list with the auth as given, ignore missing, do not allow insecure\n\treturn registry.PushManifestList(auth.Username, auth.Password, yamlInput, true, false, false, types.OCI, \"\")\n}", "func (is *ObjectStorage) PutImageManifest(repo, reference, mediaType string, //nolint: gocyclo\n\tbody []byte,\n) (godigest.Digest, godigest.Digest, error) {\n\tif err := is.InitRepo(repo); err != nil {\n\t\tis.log.Debug().Err(err).Msg(\"init repo\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\tvar lockLatency time.Time\n\n\tvar err error\n\n\tis.Lock(&lockLatency)\n\tdefer func() {\n\t\tis.Unlock(&lockLatency)\n\n\t\tif err == nil {\n\t\t\tmonitoring.SetStorageUsage(is.metrics, is.rootDir, repo)\n\t\t\tmonitoring.IncUploadCounter(is.metrics, repo)\n\t\t}\n\t}()\n\n\trefIsDigest := true\n\n\tmDigest, err := common.GetAndValidateRequestDigest(body, reference, is.log)\n\tif err != nil {\n\t\tif errors.Is(err, zerr.ErrBadManifest) {\n\t\t\treturn mDigest, \"\", err\n\t\t}\n\n\t\trefIsDigest = false\n\t}\n\n\tdig, err := common.ValidateManifest(is, repo, reference, mediaType, body, is.log)\n\tif err != nil {\n\t\treturn dig, \"\", err\n\t}\n\n\tindex, err := common.GetIndex(is, repo, is.log)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\t// create a new descriptor\n\tdesc := ispec.Descriptor{\n\t\tMediaType: mediaType, Size: int64(len(body)), Digest: mDigest,\n\t}\n\n\tif !refIsDigest {\n\t\tdesc.Annotations = map[string]string{ispec.AnnotationRefName: reference}\n\t}\n\n\tvar subjectDigest godigest.Digest\n\n\tartifactType := \"\"\n\n\tif mediaType == ispec.MediaTypeImageManifest {\n\t\tvar manifest ispec.Manifest\n\n\t\terr := json.Unmarshal(body, &manifest)\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", err\n\t\t}\n\n\t\tif manifest.Subject != nil {\n\t\t\tsubjectDigest = manifest.Subject.Digest\n\t\t}\n\n\t\tartifactType = zcommon.GetManifestArtifactType(manifest)\n\t} else if mediaType == ispec.MediaTypeImageIndex {\n\t\tvar index ispec.Index\n\n\t\terr := json.Unmarshal(body, &index)\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", err\n\t\t}\n\n\t\tif index.Subject != nil {\n\t\t\tsubjectDigest = index.Subject.Digest\n\t\t}\n\n\t\tartifactType = zcommon.GetIndexArtifactType(index)\n\t}\n\n\tupdateIndex, oldDgst, err := common.CheckIfIndexNeedsUpdate(&index, &desc, is.log)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\tif !updateIndex {\n\t\treturn desc.Digest, subjectDigest, nil\n\t}\n\n\t// write manifest to \"blobs\"\n\tdir := path.Join(is.rootDir, repo, \"blobs\", mDigest.Algorithm().String())\n\tmanifestPath := path.Join(dir, mDigest.Encoded())\n\n\tif err = is.store.PutContent(context.Background(), manifestPath, body); err != nil {\n\t\tis.log.Error().Err(err).Str(\"file\", manifestPath).Msg(\"unable to write\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\terr = common.UpdateIndexWithPrunedImageManifests(is, &index, repo, desc, oldDgst, is.log)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\t// now update \"index.json\"\n\tindex.Manifests = append(index.Manifests, desc)\n\tdir = path.Join(is.rootDir, repo)\n\tindexPath := path.Join(dir, \"index.json\")\n\n\tbuf, err := json.Marshal(index)\n\tif err != nil {\n\t\tis.log.Error().Err(err).Str(\"file\", indexPath).Msg(\"unable to marshal JSON\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\t// update the descriptors artifact type in order to check for signatures when applying the linter\n\tdesc.ArtifactType = artifactType\n\n\t// apply linter only on images, not signatures\n\tpass, err := common.ApplyLinter(is, is.linter, repo, desc)\n\tif !pass {\n\t\tis.log.Error().Err(err).Str(\"repository\", repo).Str(\"reference\", reference).Msg(\"linter didn't pass\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\tif err = is.store.PutContent(context.Background(), indexPath, buf); err != nil {\n\t\tis.log.Error().Err(err).Str(\"file\", manifestPath).Msg(\"unable to write\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\treturn desc.Digest, subjectDigest, nil\n}", "func UpdateManifest(m Manifests, root string, paths []string, id flux.ResourceID, f func(manifest []byte) ([]byte, error)) error {\n\tresources, err := m.LoadManifests(root, paths)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresource, ok := resources[id.String()]\n\tif !ok {\n\t\treturn ErrResourceNotFound(id.String())\n\t}\n\n\tpath := filepath.Join(root, resource.Source())\n\tdef, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tnewDef, err := f(def)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfi, err := os.Stat(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(path, newDef, fi.Mode())\n}", "func (s *Stargate) UpdateManifest() error {\n\tts := time.Now().Unix()\n\tkey := fmt.Sprintf(\"%s/%s\", service.Stargate, s.ID)\n\tmanifest := &consul.ServiceManifest{\n\t\tID: s.ID,\n\t\tType: service.Stargate,\n\t\tLastActive: ts,\n\t}\n\n\tif err := s.Consul.WriteStructToKey(key, manifest); err != nil {\n\t\treturn fmt.Errorf(\"error updating manifest: %v\", err)\n\t}\n\n\tfmt.Printf(\"Updated manifest %v\\n\", manifest)\n\treturn nil\n}", "func UpdateManifest(m Manifests, root string, serviceID flux.ResourceID, f func(manifest []byte) ([]byte, error)) error {\n\tservices, err := m.FindDefinedServices(root)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpaths := services[serviceID]\n\tif len(paths) == 0 {\n\t\treturn ErrNoResourceFilesFoundForService\n\t}\n\tif len(paths) > 1 {\n\t\treturn ErrMultipleResourceFilesFoundForService\n\t}\n\n\tdef, err := ioutil.ReadFile(paths[0])\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tnewDef, err := f(def)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfi, err := os.Stat(paths[0])\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(paths[0], newDef, fi.Mode())\n}", "func (imh *manifestHandler) DeleteManifest(w http.ResponseWriter, r *http.Request) {\n\tdcontext.GetLogger(imh).Debug(\"DeleteImageManifest\")\n\n\tif imh.App.isCache {\n\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnsupported)\n\t\treturn\n\t}\n\n\tif imh.Tag != \"\" {\n\t\tdcontext.GetLogger(imh).Debug(\"DeleteImageTag\")\n\t\ttagService := imh.Repository.Tags(imh.Context)\n\t\tif err := tagService.Untag(imh.Context, imh.Tag); err != nil {\n\t\t\tswitch err.(type) {\n\t\t\tcase distribution.ErrTagUnknown, driver.PathNotFoundError:\n\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown.WithDetail(err))\n\t\t\tdefault:\n\t\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tw.WriteHeader(http.StatusAccepted)\n\t\treturn\n\t}\n\n\tmanifests, err := imh.Repository.Manifests(imh)\n\tif err != nil {\n\t\timh.Errors = append(imh.Errors, err)\n\t\treturn\n\t}\n\n\terr = manifests.Delete(imh, imh.Digest)\n\tif err != nil {\n\t\tswitch err {\n\t\tcase digest.ErrDigestUnsupported:\n\t\tcase digest.ErrDigestInvalidFormat:\n\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeDigestInvalid)\n\t\t\treturn\n\t\tcase distribution.ErrBlobUnknown:\n\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown)\n\t\t\treturn\n\t\tcase distribution.ErrUnsupported:\n\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnsupported)\n\t\t\treturn\n\t\tdefault:\n\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown)\n\t\t\treturn\n\t\t}\n\t}\n\n\ttagService := imh.Repository.Tags(imh)\n\treferencedTags, err := tagService.Lookup(imh, distribution.Descriptor{Digest: imh.Digest})\n\tif err != nil {\n\t\timh.Errors = append(imh.Errors, err)\n\t\treturn\n\t}\n\n\tfor _, tag := range referencedTags {\n\t\tif err := tagService.Untag(imh, tag); err != nil {\n\t\t\timh.Errors = append(imh.Errors, err)\n\t\t\treturn\n\t\t}\n\t}\n\n\tw.WriteHeader(http.StatusAccepted)\n}", "func (d *InboundCacheDriver) StoreManifest(location models.ImageReference, contents []byte, mediaType string, now time.Time) error {\n\td.Entries[location] = inboundCacheEntry{contents, mediaType, now}\n\treturn nil\n}", "func convertManifestIfRequiredWithUpdate(ctx context.Context, options types.ManifestUpdateOptions, converters map[string]manifestConvertFn) (types.Image, error) {\n\tif options.ManifestMIMEType == \"\" {\n\t\treturn nil, nil\n\t}\n\n\tconverter, ok := converters[options.ManifestMIMEType]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"Unsupported conversion type: %v\", options.ManifestMIMEType)\n\t}\n\n\toptionsCopy := options\n\tconvertedManifest, err := converter(ctx, &optionsCopy)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconvertedImage := memoryImageFromManifest(convertedManifest)\n\n\toptionsCopy.ManifestMIMEType = \"\"\n\treturn convertedImage.UpdatedImage(ctx, optionsCopy)\n}", "func (b *Backend) ManifestAnnotate(ctx context.Context, req *pb.ManifestAnnotateRequest) (*gogotypes.Empty, error) {\n\tvar emptyResp = &gogotypes.Empty{}\n\n\tif !b.daemon.opts.Experimental {\n\t\treturn emptyResp, errors.New(\"please enable experimental to use manifest feature\")\n\t}\n\n\tlogrus.WithFields(logrus.Fields{\n\t\t\"ManifestList\": req.GetManifestList(),\n\t\t\"Manifest\": req.GetManifest(),\n\t}).Info(\"ManifestAnnotateRequest received\")\n\n\tmanifestName := req.GetManifestList()\n\tmanifestImage := req.GetManifest()\n\timageOS := req.GetOs()\n\timageArch := req.GetArch()\n\timageOSFeature := req.GetOsFeatures()\n\timageVariant := req.GetVariant()\n\n\t// get list image\n\t_, listImage, err := image.FindImage(b.daemon.localStore, manifestName)\n\tif err != nil {\n\t\treturn emptyResp, err\n\t}\n\n\t// load list from list image\n\t_, list, err := loadListFromImage(b.daemon.localStore, listImage.ID)\n\tif err != nil {\n\t\treturn emptyResp, err\n\t}\n\n\t// add image to list, if image already exists, it will be substituted\n\tinstanceDigest, err := list.addImage(ctx, b.daemon.localStore, manifestImage)\n\tif err != nil {\n\t\treturn emptyResp, err\n\t}\n\n\t// modify image platform if user specifies\n\tfor i := range list.docker.Manifests {\n\t\tif list.docker.Manifests[i].Digest == instanceDigest {\n\t\t\tif imageOS != \"\" {\n\t\t\t\tlist.docker.Manifests[i].Platform.OS = imageOS\n\t\t\t}\n\t\t\tif imageArch != \"\" {\n\t\t\t\tlist.docker.Manifests[i].Platform.Architecture = imageArch\n\t\t\t}\n\t\t\tif len(imageOSFeature) > 0 {\n\t\t\t\tlist.docker.Manifests[i].Platform.OSFeatures = append([]string{}, imageOSFeature...)\n\t\t\t}\n\t\t\tif imageVariant != \"\" {\n\t\t\t\tlist.docker.Manifests[i].Platform.Variant = imageVariant\n\t\t\t}\n\t\t}\n\t}\n\n\t// save list to image\n\t_, err = list.saveListToImage(b.daemon.localStore, listImage.ID, \"\", manifest.DockerV2ListMediaType)\n\n\treturn emptyResp, err\n}", "func (r *Registry) ImageManifest(image Image, token string) (*ImageManifest, error) {\n\turl := r.GetDigestUrl(image)\n\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Accept\", schema2.MediaTypeManifest)\n\tif token != \"\" {\n\t\treq.Header.Set(\"Authorization\", fmt.Sprintf(\"Bearer %s\", token))\n\t}\n\n\tresp, err := r.Client.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := GetRespBody(resp)\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tif resp.StatusCode == http.StatusNotFound || resp.StatusCode == http.StatusUnauthorized {\n\t\t\tklog.Error(statusUnauthorized)\n\t\t\treturn nil, restful.NewError(resp.StatusCode, statusUnauthorized)\n\t\t}\n\t\tklog.Errorf(\"got response: statusCode is '%d', body is '%s'\\n\", resp.StatusCode, respBody)\n\t\treturn nil, restful.NewError(resp.StatusCode, \"got image manifest failed\")\n\t}\n\n\timageManifest := &ImageManifest{}\n\terr = json.Unmarshal(respBody, imageManifest)\n\n\treturn imageManifest, err\n}", "func appendImageManifest(tarFile string, manifest []byte) error {\n\thash := sha256.Sum256(manifest)\n\treturn appendToTarFile(tarFile, fmt.Sprintf(\"%s-%x.json\", \"imagemanifest\", hash), manifest)\n}", "func (ir *ImageEngine) ManifestPush(ctx context.Context, name, destination string, opts entities.ImagePushOptions) (string, error) {\n\tif opts.Signers != nil {\n\t\treturn \"\", fmt.Errorf(\"forwarding Signers is not supported for remote clients\")\n\t}\n\n\toptions := new(images.PushOptions)\n\toptions.WithUsername(opts.Username).WithPassword(opts.Password).WithAuthfile(opts.Authfile).WithRemoveSignatures(opts.RemoveSignatures).WithAll(opts.All).WithFormat(opts.Format).WithCompressionFormat(opts.CompressionFormat).WithQuiet(opts.Quiet).WithProgressWriter(opts.Writer).WithAddCompression(opts.AddCompression).WithForceCompressionFormat(opts.ForceCompressionFormat)\n\n\tif s := opts.SkipTLSVerify; s != types.OptionalBoolUndefined {\n\t\tif s == types.OptionalBoolTrue {\n\t\t\toptions.WithSkipTLSVerify(true)\n\t\t} else {\n\t\t\toptions.WithSkipTLSVerify(false)\n\t\t}\n\t}\n\tdigest, err := manifests.Push(ir.ClientCtx, name, destination, options)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"pushing manifest list %s: %w\", name, err)\n\t}\n\n\tif opts.Rm {\n\t\tif _, rmErrors := ir.Remove(ctx, []string{name}, entities.ImageRemoveOptions{LookupManifest: true}); len(rmErrors) > 0 {\n\t\t\treturn \"\", fmt.Errorf(\"removing manifest after push: %w\", rmErrors[0])\n\t\t}\n\t}\n\n\treturn digest, err\n}", "func (m *manifestService) Put(ctx context.Context, manifest distribution.Manifest, options ...distribution.ManifestServiceOption) (digest.Digest, error) {\n\tcontext.GetLogger(ctx).Debugf(\"(*manifestService).Put\")\n\n\tmh, err := NewManifestHandler(m.repo, manifest)\n\tif err != nil {\n\t\treturn \"\", regapi.ErrorCodeManifestInvalid.WithDetail(err)\n\t}\n\tmediaType, payload, _, err := mh.Payload()\n\tif err != nil {\n\t\treturn \"\", regapi.ErrorCodeManifestInvalid.WithDetail(err)\n\t}\n\n\t// this is fast to check, let's do it before verification\n\tif !m.acceptschema2 && mediaType == schema2.MediaTypeManifest {\n\t\treturn \"\", regapi.ErrorCodeManifestInvalid.WithDetail(fmt.Errorf(\"manifest V2 schema 2 not allowed\"))\n\t}\n\n\t// in order to stat the referenced blobs, repository need to be set on the context\n\tif err := mh.Verify(withRepository(ctx, m.repo), false); err != nil {\n\t\treturn \"\", err\n\t}\n\n\t_, err = m.manifests.Put(withRepository(ctx, m.repo), manifest, options...)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tconfig, err := mh.Config(ctx)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tdgst, err := mh.Digest()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Upload to openshift\n\tism := imageapiv1.ImageStreamMapping{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tNamespace: m.repo.namespace,\n\t\t\tName: m.repo.name,\n\t\t},\n\t\tImage: imageapiv1.Image{\n\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\tName: dgst.String(),\n\t\t\t\tAnnotations: map[string]string{\n\t\t\t\t\timageapi.ManagedByOpenShiftAnnotation: \"true\",\n\t\t\t\t\timageapi.ImageManifestBlobStoredAnnotation: \"true\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tDockerImageReference: fmt.Sprintf(\"%s/%s/%s@%s\", m.repo.config.registryAddr, m.repo.namespace, m.repo.name, dgst.String()),\n\t\t\tDockerImageManifest: string(payload),\n\t\t\tDockerImageManifestMediaType: mediaType,\n\t\t\tDockerImageConfig: string(config),\n\t\t},\n\t}\n\n\tfor _, option := range options {\n\t\tif opt, ok := option.(distribution.WithTagOption); ok {\n\t\t\tism.Tag = opt.Tag\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif _, err = m.repo.registryOSClient.ImageStreamMappings(m.repo.namespace).Create(&ism); err != nil {\n\t\t// if the error was that the image stream wasn't found, try to auto provision it\n\t\tstatusErr, ok := err.(*kerrors.StatusError)\n\t\tif !ok {\n\t\t\tcontext.GetLogger(ctx).Errorf(\"error creating ImageStreamMapping: %s\", err)\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tif quotautil.IsErrorQuotaExceeded(statusErr) {\n\t\t\tcontext.GetLogger(ctx).Errorf(\"denied creating ImageStreamMapping: %v\", statusErr)\n\t\t\treturn \"\", distribution.ErrAccessDenied\n\t\t}\n\n\t\tstatus := statusErr.ErrStatus\n\t\tkind := strings.ToLower(status.Details.Kind)\n\t\tisValidKind := kind == \"imagestream\" /*pre-1.2*/ || kind == \"imagestreams\" /*1.2 to 1.6*/ || kind == \"imagestreammappings\" /*1.7+*/\n\t\tif !isValidKind || status.Code != http.StatusNotFound || status.Details.Name != m.repo.name {\n\t\t\tcontext.GetLogger(ctx).Errorf(\"error creating ImageStreamMapping: %s\", err)\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tif _, err := m.repo.createImageStream(ctx); err != nil {\n\t\t\tif e, ok := err.(errcode.Error); ok && e.ErrorCode() == errcode.ErrorCodeUnknown {\n\t\t\t\t// TODO: convert statusErr to distribution error\n\t\t\t\treturn \"\", statusErr\n\t\t\t}\n\t\t\treturn \"\", err\n\t\t}\n\n\t\t// try to create the ISM again\n\t\tif _, err := m.repo.registryOSClient.ImageStreamMappings(m.repo.namespace).Create(&ism); err != nil {\n\t\t\tif quotautil.IsErrorQuotaExceeded(err) {\n\t\t\t\tcontext.GetLogger(ctx).Errorf(\"denied a creation of ImageStreamMapping: %v\", err)\n\t\t\t\treturn \"\", distribution.ErrAccessDenied\n\t\t\t}\n\t\t\tcontext.GetLogger(ctx).Errorf(\"error creating ImageStreamMapping: %s\", err)\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\treturn dgst, nil\n}", "func (s *storageImageDestination) PutManifest(ctx context.Context, manifest []byte) error {\n\ts.manifest = make([]byte, len(manifest))\n\tcopy(s.manifest, manifest)\n\treturn nil\n}", "func Update(cfg *Config) error {\n\tmetadir := filepath.Join(cfg.OutputDir, \"meta\")\n\tos.MkdirAll(metadir, os.ModePerm)\n\tmanifest, err := cfg.Manifest()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := writeABIRevision(cfg, manifest); err != nil {\n\t\treturn err\n\t}\n\n\tcontentsPath := filepath.Join(metadir, \"contents\")\n\tpkgContents := manifest.Content()\n\n\tif cfg.SubpackagesPath != \"\" {\n\t\tif err := writeSubpackagesMeta(cfg, cfg.SubpackagesPath); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// manifestLines is a channel containing unpacked manifest paths\n\tvar manifestLines = make(chan struct{ src, dest string }, len(pkgContents))\n\tgo func() {\n\t\tfor dest, src := range pkgContents {\n\t\t\tmanifestLines <- struct{ src, dest string }{src, dest}\n\t\t}\n\t\tclose(manifestLines)\n\t}()\n\n\t// contentCollector receives entries to include in contents\n\ttype contentEntry struct {\n\t\tpath string\n\t\troot MerkleRoot\n\t}\n\tvar contentCollector = make(chan contentEntry, len(pkgContents))\n\tvar errors = make(chan error)\n\n\t// w is a group that is done when contentCollector is fully populated\n\tvar w sync.WaitGroup\n\tfor i := runtime.NumCPU(); i > 0; i-- {\n\t\tw.Add(1)\n\n\t\tgo func() {\n\t\t\tdefer w.Done()\n\n\t\t\tfor in := range manifestLines {\n\t\t\t\tvar t merkle.Tree\n\t\t\t\tcf, err := os.Open(in.src)\n\t\t\t\tif err != nil {\n\t\t\t\t\terrors <- fmt.Errorf(\"build.Update: open %s for %s: %s\", in.src, in.dest, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\t_, err = t.ReadFrom(bufio.NewReader(cf))\n\t\t\t\tcf.Close()\n\t\t\t\tif err != nil {\n\t\t\t\t\terrors <- err\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tvar root MerkleRoot\n\t\t\t\tcopy(root[:], t.Root())\n\t\t\t\tcontentCollector <- contentEntry{in.dest, root}\n\t\t\t}\n\t\t}()\n\t}\n\n\t// close the collector channel when all workers are done\n\tgo func() {\n\t\tw.Wait()\n\t\tclose(contentCollector)\n\t}()\n\n\t// collect all results and close done to signal the waiting select\n\tvar done = make(chan struct{})\n\tcontents := MetaContents{}\n\tgo func() {\n\t\tfor entry := range contentCollector {\n\t\t\tcontents[entry.path] = entry.root\n\t\t}\n\t\tclose(done)\n\t}()\n\n\tselect {\n\tcase <-done:\n\t\t// contents is populated\n\tcase err := <-errors:\n\t\t// exit on the first error\n\t\treturn err\n\t}\n\n\tmanifest.Paths[\"meta/contents\"] = contentsPath\n\n\treturn os.WriteFile(contentsPath,\n\t\t[]byte(contents.String()), os.ModePerm)\n}", "func (m *ImageManifest) UnmarshalJSON(data []byte) (err error) {\n\tmanifestMap := make(map[string]json.RawMessage)\n\tif err = json.Unmarshal(data, &manifestMap); err != nil {\n\t\terr = errors.WithStack(err)\n\t\treturn\n\t}\n\n\tfor k, v := range manifestMap {\n\t\tswitch k {\n\t\tcase \"mediaType\":\n\t\t\terr = json.Unmarshal(v, &m.MediaType)\n\t\tcase \"schemaVersion\":\n\t\t\terr = json.Unmarshal(v, &m.SchemaVersion)\n\t\tcase \"config\":\n\t\t\tm.Config, err = unmarshalConfig(v)\n\t\tcase \"layers\":\n\t\t\tm.Layers, err = unmarshalLayers(v)\n\t\tdefault:\n\t\t}\n\t\tif err != nil {\n\t\t\terr = errors.WithStack(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\treturn\n}", "func (mr *ManifestResource) Put(_ http.ResponseWriter, req *http.Request, _ httprouter.Params) restful.Exchanger {\n\treturn &PUTManifestHandler{\n\t\tState: mr.context.liveState(),\n\t\tLogSink: mr.context.LogSink,\n\t\tRequest: req,\n\t\tQueryValues: mr.ParseQuery(req),\n\t\tUser: mr.GetUser(req),\n\t\tStateWriter: sous.StateWriter(mr.context.StateManager),\n\t}\n}", "func (p *Processor) ValidateAndStoreManifest(account keppel.Account, repo keppel.Repository, m IncomingManifest, actx keppel.AuditContext) (*keppel.Manifest, error) {\n\t//check if the objects we want to create already exist in the database; this\n\t//check is not 100% reliable since it does not run in the same transaction as\n\t//the actual upsert, so results should be taken with a grain of salt; but the\n\t//result is accurate enough to avoid most duplicate audit events\n\tcontentsDigest := digest.Canonical.FromBytes(m.Contents)\n\tmanifestExistsAlready, err := p.db.SelectBool(checkManifestExistsQuery, repo.ID, contentsDigest.String())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlogg.Debug(\"ValidateAndStoreManifest: in repo %d, manifest %s already exists = %t\", repo.ID, contentsDigest, manifestExistsAlready)\n\tvar tagExistsAlready bool\n\tif m.Reference.IsTag() {\n\t\ttagExistsAlready, err = p.db.SelectBool(checkTagExistsAtSameDigestQuery, repo.ID, m.Reference.Tag, contentsDigest.String())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tlogg.Debug(\"ValidateAndStoreManifest: in repo %d, tag %s @%s already exists = %t\", repo.ID, m.Reference.Tag, contentsDigest, tagExistsAlready)\n\t}\n\n\t//the quota check can be skipped if we are sure that we won't need to insert\n\t//a new row into the manifests table\n\tif !manifestExistsAlready {\n\t\terr = p.checkQuotaForManifestPush(account)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tmanifest := &keppel.Manifest{\n\t\t//NOTE: .Digest and .SizeBytes are computed by validateAndStoreManifestCommon()\n\t\tRepositoryID: repo.ID,\n\t\tMediaType: m.MediaType,\n\t\tPushedAt: m.PushedAt,\n\t\tValidatedAt: m.PushedAt,\n\t}\n\tif m.Reference.IsDigest() {\n\t\t//allow validateAndStoreManifestCommon() to validate the user-supplied\n\t\t//digest against the actual manifest data\n\t\tmanifest.Digest = m.Reference.Digest\n\t}\n\terr = p.validateAndStoreManifestCommon(account, repo, manifest, m.Contents,\n\t\tfunc(tx *gorp.Transaction) error {\n\t\t\tif m.Reference.IsTag() {\n\t\t\t\terr = upsertTag(tx, keppel.Tag{\n\t\t\t\t\tRepositoryID: repo.ID,\n\t\t\t\t\tName: m.Reference.Tag,\n\t\t\t\t\tDigest: manifest.Digest,\n\t\t\t\t\tPushedAt: m.PushedAt,\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//after making all DB changes, but before committing the DB transaction,\n\t\t\t//write the manifest into the backend\n\t\t\treturn p.sd.WriteManifest(account, repo.Name, manifest.Digest, m.Contents)\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t//submit audit events, but only if we are reasonably sure that we actually\n\t//inserted a new manifest and/or changed a tag (without this restriction, we\n\t//would log an audit event everytime a manifest is validated or a tag is\n\t//synced; before the introduction of this check, we generated millions of\n\t//useless audit events per month)\n\tif userInfo := actx.UserIdentity.UserInfo(); userInfo != nil {\n\t\trecord := func(target audittools.TargetRenderer) {\n\t\t\tp.auditor.Record(audittools.EventParameters{\n\t\t\t\tTime: p.timeNow(),\n\t\t\t\tRequest: actx.Request,\n\t\t\t\tUser: userInfo,\n\t\t\t\tReasonCode: http.StatusOK,\n\t\t\t\tAction: cadf.CreateAction,\n\t\t\t\tTarget: target,\n\t\t\t})\n\t\t}\n\t\tif !manifestExistsAlready {\n\t\t\trecord(auditManifest{\n\t\t\t\tAccount: account,\n\t\t\t\tRepository: repo,\n\t\t\t\tDigest: manifest.Digest,\n\t\t\t})\n\t\t}\n\t\tif m.Reference.IsTag() && !tagExistsAlready {\n\t\t\trecord(auditTag{\n\t\t\t\tAccount: account,\n\t\t\t\tRepository: repo,\n\t\t\t\tDigest: manifest.Digest,\n\t\t\t\tTagName: m.Reference.Tag,\n\t\t\t})\n\t\t}\n\t}\n\treturn manifest, nil\n}", "func uploadManifest(registry, name, tag, layerDigest string) error {\n\tfmt.Printf(\"Upload manifest to %s (%s:%s): %s\\n\", registry, name, tag, layerDigest)\n\n\tmanifest, err := buildManifest(name, tag, layerDigest)\n\tif err != nil {\n\t\treturn err\n\t}\n\tmanifestURL := fmt.Sprintf(\"%s/v2/%s/manifests/%s\", registry, name, tag)\n\treq, err := http.NewRequest(http.MethodPut, manifestURL, manifest)\n\treq.Header.Set(\"Content-Type\", \"application/vnd.docker.distribution.manifest.v1+json\")\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(\"Got response: %s\\n\", resp.Status)\n\tfor k, v := range resp.Header {\n\t\tfmt.Printf(\"%s: %s\\n\", k, v)\n\t}\n\tfmt.Printf(\"\\n\")\n\tio.Copy(os.Stdout, resp.Body)\n\tfmt.Printf(\"\\n\")\n\n\tif resp.StatusCode < 200 || resp.StatusCode > 299 {\n\t\treturn fmt.Errorf(\"Registry error: %s\", resp.Status)\n\t}\n\treturn nil\n}", "func (imh *manifestHandler) GetManifest(w http.ResponseWriter, r *http.Request) {\n\tdcontext.GetLogger(imh).Debug(\"GetImageManifest\")\n\tmanifests, err := imh.Repository.Manifests(imh)\n\tif err != nil {\n\t\timh.Errors = append(imh.Errors, err)\n\t\treturn\n\t}\n\tvar supports [numStorageTypes]bool\n\n\t// this parsing of Accept headers is not quite as full-featured as godoc.org's parser, but we don't care about \"q=\" values\n\t// https://github.com/golang/gddo/blob/e91d4165076d7474d20abda83f92d15c7ebc3e81/httputil/header/header.go#L165-L202\n\tfor _, acceptHeader := range r.Header[\"Accept\"] {\n\t\t// r.Header[...] is a slice in case the request contains the same header more than once\n\t\t// if the header isn't set, we'll get the zero value, which \"range\" will handle gracefully\n\n\t\t// we need to split each header value on \",\" to get the full list of \"Accept\" values (per RFC 2616)\n\t\t// https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1\n\t\tfor _, mediaType := range strings.Split(acceptHeader, \",\") {\n\t\t\tif mediaType, _, err = mime.ParseMediaType(mediaType); err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif mediaType == schema2.MediaTypeManifest {\n\t\t\t\tsupports[manifestSchema2] = true\n\t\t\t}\n\t\t\tif mediaType == manifestlist.MediaTypeManifestList {\n\t\t\t\tsupports[manifestlistSchema] = true\n\t\t\t}\n\t\t\tif mediaType == v1.MediaTypeImageManifest {\n\t\t\t\tsupports[ociSchema] = true\n\t\t\t}\n\t\t\tif mediaType == v1.MediaTypeImageIndex {\n\t\t\t\tsupports[ociImageIndexSchema] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tif imh.Tag != \"\" {\n\t\ttags := imh.Repository.Tags(imh)\n\t\tdesc, err := tags.Get(imh, imh.Tag)\n\t\tif err != nil {\n\t\t\tif _, ok := err.(distribution.ErrTagUnknown); ok {\n\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown.WithDetail(err))\n\t\t\t} else {\n\t\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\timh.Digest = desc.Digest\n\t}\n\n\tif etagMatch(r, imh.Digest.String()) {\n\t\tw.WriteHeader(http.StatusNotModified)\n\t\treturn\n\t}\n\n\tvar options []distribution.ManifestServiceOption\n\tif imh.Tag != \"\" {\n\t\toptions = append(options, distribution.WithTag(imh.Tag))\n\t}\n\tmanifest, err := manifests.Get(imh, imh.Digest, options...)\n\tif err != nil {\n\t\tif _, ok := err.(distribution.ErrManifestUnknownRevision); ok {\n\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown.WithDetail(err))\n\t\t} else {\n\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\t}\n\t\treturn\n\t}\n\t// determine the type of the returned manifest\n\tmanifestType := manifestSchema1\n\tschema2Manifest, isSchema2 := manifest.(*schema2.DeserializedManifest)\n\tmanifestList, isManifestList := manifest.(*manifestlist.DeserializedManifestList)\n\tif isSchema2 {\n\t\tmanifestType = manifestSchema2\n\t} else if _, isOCImanifest := manifest.(*ocischema.DeserializedManifest); isOCImanifest {\n\t\tmanifestType = ociSchema\n\t} else if isManifestList {\n\t\tif manifestList.MediaType == manifestlist.MediaTypeManifestList {\n\t\t\tmanifestType = manifestlistSchema\n\t\t} else if manifestList.MediaType == v1.MediaTypeImageIndex {\n\t\t\tmanifestType = ociImageIndexSchema\n\t\t}\n\t}\n\n\tif manifestType == ociSchema && !supports[ociSchema] {\n\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown.WithMessage(\"OCI manifest found, but accept header does not support OCI manifests\"))\n\t\treturn\n\t}\n\tif manifestType == ociImageIndexSchema && !supports[ociImageIndexSchema] {\n\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown.WithMessage(\"OCI index found, but accept header does not support OCI indexes\"))\n\t\treturn\n\t}\n\t// Only rewrite schema2 manifests when they are being fetched by tag.\n\t// If they are being fetched by digest, we can't return something not\n\t// matching the digest.\n\tif imh.Tag != \"\" && manifestType == manifestSchema2 && !supports[manifestSchema2] {\n\t\t// Rewrite manifest in schema1 format\n\t\tdcontext.GetLogger(imh).Infof(\"rewriting manifest %s in schema1 format to support old client\", imh.Digest.String())\n\n\t\tmanifest, err = imh.convertSchema2Manifest(schema2Manifest)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t} else if imh.Tag != \"\" && manifestType == manifestlistSchema && !supports[manifestlistSchema] {\n\t\t// Rewrite manifest in schema1 format\n\t\tdcontext.GetLogger(imh).Infof(\"rewriting manifest list %s in schema1 format to support old client\", imh.Digest.String())\n\n\t\t// Find the image manifest corresponding to the default\n\t\t// platform\n\t\tvar manifestDigest digest.Digest\n\t\tfor _, manifestDescriptor := range manifestList.Manifests {\n\t\t\tif manifestDescriptor.Platform.Architecture == defaultArch && manifestDescriptor.Platform.OS == defaultOS {\n\t\t\t\tmanifestDigest = manifestDescriptor.Digest\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif manifestDigest == \"\" {\n\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown)\n\t\t\treturn\n\t\t}\n\n\t\tmanifest, err = manifests.Get(imh, manifestDigest)\n\t\tif err != nil {\n\t\t\tif _, ok := err.(distribution.ErrManifestUnknownRevision); ok {\n\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown.WithDetail(err))\n\t\t\t} else {\n\t\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\t// If necessary, convert the image manifest\n\t\tif schema2Manifest, isSchema2 := manifest.(*schema2.DeserializedManifest); isSchema2 && !supports[manifestSchema2] {\n\t\t\tmanifest, err = imh.convertSchema2Manifest(schema2Manifest)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\timh.Digest = manifestDigest\n\t\t}\n\t}\n\n\tct, p, err := manifest.Payload()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", ct)\n\tw.Header().Set(\"Content-Length\", fmt.Sprint(len(p)))\n\tw.Header().Set(\"Docker-Content-Digest\", imh.Digest.String())\n\tw.Header().Set(\"Etag\", fmt.Sprintf(`\"%s\"`, imh.Digest))\n\tw.Write(p)\n}", "func (m *EC2Manifest) Add(version string, image *EC2Image) {\n\tversions := make(sortVersions, 0, len(m.Versions)+1)\n\tfor _, v := range m.Versions {\n\t\tif v.version() == version {\n\t\t\timages := make([]*EC2Image, len(v.Images))\n\t\t\tadded := false\n\t\t\tfor n, i := range v.Images {\n\t\t\t\tif i.Region == image.Region {\n\t\t\t\t\t// replace existing image\n\t\t\t\t\timages[n] = image\n\t\t\t\t\tadded = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\timages[n] = i\n\t\t\t}\n\t\t\tif !added {\n\t\t\t\timages = append(images, image)\n\t\t\t}\n\t\t\tv.Images = images\n\t\t\treturn\n\t\t}\n\t\tversions = append(versions, v)\n\t}\n\tversions = append(versions, &EC2Version{\n\t\tVersion: version,\n\t\tImages: []*EC2Image{image},\n\t})\n\tsort.Sort(sort.Reverse(versions))\n\tm.Versions = make([]*EC2Version, 0, maxVersions)\n\tfor i := 0; i < len(versions) && i < maxVersions; i++ {\n\t\tm.Versions = append(m.Versions, versions[i].(*EC2Version))\n\t}\n}", "func (j *Janitor) ValidateNextManifest() (returnErr error) {\n\tdefer func() {\n\t\tif returnErr == nil {\n\t\t\tvalidateManifestSuccessCounter.Inc()\n\t\t} else if returnErr != sql.ErrNoRows {\n\t\t\tvalidateManifestFailedCounter.Inc()\n\t\t\treturnErr = fmt.Errorf(\"while validating a manifest: %s\", returnErr.Error())\n\t\t}\n\t}()\n\n\t//find manifest\n\tvar manifest keppel.Manifest\n\tmaxValidatedAt := j.timeNow().Add(-6 * time.Hour)\n\terr := j.db.SelectOne(&manifest, outdatedManifestSearchQuery, maxValidatedAt)\n\tif err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\tlogg.Debug(\"no manifests to validate - slowing down...\")\n\t\t\treturn sql.ErrNoRows\n\t\t}\n\t\treturn err\n\t}\n\n\t//find corresponding account and repo\n\tvar repo keppel.Repository\n\terr = j.db.SelectOne(&repo, `SELECT * FROM repos WHERE id = $1`, manifest.RepositoryID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot find repo %d for manifest %s: %s\", manifest.RepositoryID, manifest.Digest, err.Error())\n\t}\n\taccount, err := keppel.FindAccount(j.db, repo.AccountName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot find account for manifest %s/%s: %s\", repo.FullName(), manifest.Digest, err.Error())\n\t}\n\n\t//perform validation\n\tctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\n\tdefer cancel()\n\terr = retry(ctx, defaultRetryOpts, func() error {\n\t\treturn j.processor().ValidateExistingManifest(*account, repo, &manifest, j.timeNow())\n\t})\n\tif err == nil {\n\t\t//update `validated_at` and reset error message\n\t\t_, err := j.db.Exec(`\n\t\t\tUPDATE manifests SET validated_at = $1, validation_error_message = ''\n\t\t\t WHERE repo_id = $2 AND digest = $3`,\n\t\t\tj.timeNow(), repo.ID, manifest.Digest,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\t//attempt to log the error message, and also update the `validated_at`\n\t\t//timestamp to ensure that the ValidateNextManifest() loop does not get\n\t\t//stuck on this one\n\t\t_, updateErr := j.db.Exec(`\n\t\t\tUPDATE manifests SET validated_at = $1, validation_error_message = $2\n\t\t\t WHERE repo_id = $3 AND digest = $4`,\n\t\t\tj.timeNow(), err.Error(), repo.ID, manifest.Digest,\n\t\t)\n\t\tif updateErr != nil {\n\t\t\terr = fmt.Errorf(\"%s (additional error encountered while recording validation error: %s)\", err.Error(), updateErr.Error())\n\t\t}\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (s *tagStore) Manifest(ctx context.Context, t *models.Tag) (*models.Manifest, error) {\n\tdefer metrics.InstrumentQuery(\"tag_manifest\")()\n\tq := `SELECT\n\t\t\tm.id,\n\t\t\tm.top_level_namespace_id,\n\t\t\tm.repository_id,\n\t\t\tm.schema_version,\n\t\t\tmt.media_type,\n\t\t\tencode(m.digest, 'hex') as digest,\n\t\t\tm.payload,\n\t\t\tmtc.media_type as configuration_media_type,\n\t\t\tencode(m.configuration_blob_digest, 'hex') as configuration_blob_digest,\n\t\t\tm.configuration_payload,\n\t\t\tm.created_at\n\t\tFROM\n\t\t\tmanifests AS m\n\t\t\tJOIN media_types AS mt ON mt.id = m.media_type_id\n\t\t\tLEFT JOIN media_types AS mtc ON mtc.id = m.configuration_media_type_id\n\t\tWHERE\n\t\t\tm.top_level_namespace_id = $1\n\t\t\tAND m.repository_id = $2\n\t\t\tAND m.id = $3`\n\trow := s.db.QueryRowContext(ctx, q, t.NamespaceID, t.RepositoryID, t.ManifestID)\n\n\treturn scanFullManifest(row)\n}", "func ComputeManifest(refToImage map[name.Reference]v1.Image) (Manifest, error) {\n\timageToTags := dedupRefToImage(refToImage)\n\treturn calculateManifest(imageToTags)\n}", "func (cb *ManifestBuffer) appendManifest(m interface{}, sender sender.Sender) {\n\tif len(cb.bufferedManifests) >= cb.Cfg.MaxBufferedManifests {\n\t\tcb.flushManifest(sender)\n\t}\n\n\tcb.bufferedManifests = append(cb.bufferedManifests, m)\n}", "func generateManifest(gitRepo *gitRepo, imageName, imageTag string) (*registry.ManifestData, error) {\n\tbranches, err := gitRepo.branch()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar imageChecksums []string = make([]string, len(branches))\n\tfor _, br := range branches {\n\t\tchecksum := br.imageID()\n\t\tsumTypeBytes, err := gitRepo.branchDescription(br)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\timageChecksums[br.number()] = string(sumTypeBytes) + \":\" + checksum\n\t}\n\n\tmanifest := &registry.ManifestData{\n\t\tName: imageName,\n\t\tArchitecture: \"amd64\", //unclean but so far looks ok ...\n\t\tTag: imageTag,\n\t\tSchemaVersion: 1,\n\t\tFSLayers: make([]*registry.FSLayer, 0, 4),\n\t}\n\n\tfor i, checksum := range imageChecksums {\n\t\tif tarsum.VersionLabelForChecksum(checksum) != tarsum.Version1.String() {\n\t\t\t//need to calculate the tarsum V1 for each layer ...\n\t\t\tlayerData, err := gitRepo.exportChangeSet(branches[i])\n\t\t\tif err == ErrNoChange {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tdefer layerData.Close()\n\n\t\t\ttarSum, err := tarsum.NewTarSum(layerData, true, tarsum.Version1)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif _, err := io.Copy(ioutil.Discard, tarSum); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tchecksum = tarSum.Sum(nil)\n\t\t}\n\t\tmanifest.FSLayers = append(manifest.FSLayers, &registry.FSLayer{BlobSum: checksum})\n\t}\n\treturn manifest, nil\n}", "func UploadManifest(ctx context.Context, repo distribution.Repository, tag string, manifest distribution.Manifest) error {\n\tcanonical, err := CanonicalManifest(manifest)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tms, err := repo.Manifests(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get manifest service for %s: %w\", repo.Named(), err)\n\t}\n\n\tdgst, err := ms.Put(ctx, manifest, distribution.WithTag(tag))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to upload manifest to %s: %w\", repo.Named(), err)\n\t}\n\n\tif expectedDgst := digest.FromBytes(canonical); dgst != expectedDgst {\n\t\treturn fmt.Errorf(\"upload manifest to %s failed: digest mismatch: got %s, want %s\", repo.Named(), dgst, expectedDgst)\n\t}\n\n\treturn nil\n}", "func (is *ImageStoreLocal) DeleteImageManifest(repo, reference string, detectCollision bool) error {\n\tdir := path.Join(is.rootDir, repo)\n\tif !is.DirExists(dir) {\n\t\treturn zerr.ErrRepoNotFound\n\t}\n\n\tvar lockLatency time.Time\n\n\tvar err error\n\n\tis.Lock(&lockLatency)\n\tdefer func() {\n\t\tis.Unlock(&lockLatency)\n\n\t\tif err == nil {\n\t\t\tmonitoring.SetStorageUsage(is.metrics, is.rootDir, repo)\n\t\t}\n\t}()\n\n\tindex, err := common.GetIndex(is, repo, is.log)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmanifestDesc, err := common.RemoveManifestDescByReference(&index, reference, detectCollision)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = common.UpdateIndexWithPrunedImageManifests(is, &index, repo, manifestDesc, manifestDesc.Digest, is.log)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// now update \"index.json\"\n\tdir = path.Join(is.rootDir, repo)\n\tfile := path.Join(dir, \"index.json\")\n\n\tbuf, err := json.Marshal(index)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := is.writeFile(file, buf); err != nil {\n\t\treturn err\n\t}\n\n\t// Delete blob only when blob digest not present in manifest entry.\n\t// e.g. 1.0.1 & 1.0.2 have same blob digest so if we delete 1.0.1, blob should not be removed.\n\ttoDelete := true\n\n\tfor _, manifest := range index.Manifests {\n\t\tif manifestDesc.Digest.String() == manifest.Digest.String() {\n\t\t\ttoDelete = false\n\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif toDelete {\n\t\tp := path.Join(dir, \"blobs\", manifestDesc.Digest.Algorithm().String(), manifestDesc.Digest.Encoded())\n\n\t\t_ = os.Remove(p)\n\t}\n\n\treturn nil\n}", "func UpdateApplication(updateConf *UpdateConfiguration, state *SyncIterationState) ImageUpdaterResult {\n\tvar needUpdate bool = false\n\n\tresult := ImageUpdaterResult{}\n\tapp := updateConf.UpdateApp.Application.GetName()\n\tchangeList := make([]ChangeEntry, 0)\n\n\t// Get all images that are deployed with the current application\n\tapplicationImages := GetImagesFromApplication(&updateConf.UpdateApp.Application)\n\n\tresult.NumApplicationsProcessed += 1\n\n\t// Loop through all images of current application, and check whether one of\n\t// its images is eligible for updating.\n\t//\n\t// Whether an image qualifies for update is dependent on semantic version\n\t// constraints which are part of the application's annotation values.\n\t//\n\tfor _, applicationImage := range updateConf.UpdateApp.Images {\n\t\tupdateableImage := applicationImages.ContainsImage(applicationImage, false)\n\t\tif updateableImage == nil {\n\t\t\tlog.WithContext().AddField(\"application\", app).Debugf(\"Image '%s' seems not to be live in this application, skipping\", applicationImage.ImageName)\n\t\t\tresult.NumSkipped += 1\n\t\t\tcontinue\n\t\t}\n\n\t\t// In some cases, the running image has no tag set. We create a dummy\n\t\t// tag, without name, digest and a timestamp of zero. This dummy tag\n\t\t// will trigger an update on the first run.\n\t\tif updateableImage.ImageTag == nil {\n\t\t\tupdateableImage.ImageTag = tag.NewImageTag(\"\", time.Unix(0, 0), \"\")\n\t\t}\n\n\t\tresult.NumImagesConsidered += 1\n\n\t\timgCtx := log.WithContext().\n\t\t\tAddField(\"application\", app).\n\t\t\tAddField(\"registry\", updateableImage.RegistryURL).\n\t\t\tAddField(\"image_name\", updateableImage.ImageName).\n\t\t\tAddField(\"image_tag\", updateableImage.ImageTag).\n\t\t\tAddField(\"alias\", applicationImage.ImageAlias)\n\n\t\tif updateableImage.KustomizeImage != nil {\n\t\t\timgCtx.AddField(\"kustomize_image\", updateableImage.KustomizeImage)\n\t\t}\n\n\t\timgCtx.Debugf(\"Considering this image for update\")\n\n\t\trep, err := registry.GetRegistryEndpoint(applicationImage.RegistryURL)\n\t\tif err != nil {\n\t\t\timgCtx.Errorf(\"Could not get registry endpoint from configuration: %v\", err)\n\t\t\tresult.NumErrors += 1\n\t\t\tcontinue\n\t\t}\n\n\t\tvar vc image.VersionConstraint\n\t\tif applicationImage.ImageTag != nil {\n\t\t\tvc.Constraint = applicationImage.ImageTag.TagName\n\t\t\timgCtx.Debugf(\"Using version constraint '%s' when looking for a new tag\", vc.Constraint)\n\t\t} else {\n\t\t\timgCtx.Debugf(\"Using no version constraint when looking for a new tag\")\n\t\t}\n\n\t\tvc.SortMode = applicationImage.GetParameterUpdateStrategy(updateConf.UpdateApp.Application.Annotations)\n\t\tvc.MatchFunc, vc.MatchArgs = applicationImage.GetParameterMatch(updateConf.UpdateApp.Application.Annotations)\n\t\tvc.IgnoreList = applicationImage.GetParameterIgnoreTags(updateConf.UpdateApp.Application.Annotations)\n\n\t\t// The endpoint can provide default credentials for pulling images\n\t\terr = rep.SetEndpointCredentials(updateConf.KubeClient)\n\t\tif err != nil {\n\t\t\timgCtx.Errorf(\"Could not set registry endpoint credentials: %v\", err)\n\t\t\tresult.NumErrors += 1\n\t\t\tcontinue\n\t\t}\n\n\t\timgCredSrc := applicationImage.GetParameterPullSecret(updateConf.UpdateApp.Application.Annotations)\n\t\tvar creds *image.Credential = &image.Credential{}\n\t\tif imgCredSrc != nil {\n\t\t\tcreds, err = imgCredSrc.FetchCredentials(rep.RegistryAPI, updateConf.KubeClient)\n\t\t\tif err != nil {\n\t\t\t\timgCtx.Warnf(\"Could not fetch credentials: %v\", err)\n\t\t\t\tresult.NumErrors += 1\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tregClient, err := updateConf.NewRegFN(rep, creds.Username, creds.Password)\n\t\tif err != nil {\n\t\t\timgCtx.Errorf(\"Could not create registry client: %v\", err)\n\t\t\tresult.NumErrors += 1\n\t\t\tcontinue\n\t\t}\n\n\t\t// Get list of available image tags from the repository\n\t\ttags, err := rep.GetTags(applicationImage, regClient, &vc)\n\t\tif err != nil {\n\t\t\timgCtx.Errorf(\"Could not get tags from registry: %v\", err)\n\t\t\tresult.NumErrors += 1\n\t\t\tcontinue\n\t\t}\n\n\t\timgCtx.Tracef(\"List of available tags found: %v\", tags.Tags())\n\n\t\t// Get the latest available tag matching any constraint that might be set\n\t\t// for allowed updates.\n\t\tlatest, err := updateableImage.GetNewestVersionFromTags(&vc, tags)\n\t\tif err != nil {\n\t\t\timgCtx.Errorf(\"Unable to find newest version from available tags: %v\", err)\n\t\t\tresult.NumErrors += 1\n\t\t\tcontinue\n\t\t}\n\n\t\t// If we have no latest tag information, it means there was no tag which\n\t\t// has met our version constraint (or there was no semantic versioned tag\n\t\t// at all in the repository)\n\t\tif latest == nil {\n\t\t\timgCtx.Debugf(\"No suitable image tag for upgrade found in list of available tags.\")\n\t\t\tresult.NumSkipped += 1\n\t\t\tcontinue\n\t\t}\n\n\t\t// If the user has specified digest as update strategy, but the running\n\t\t// image is configured to use a tag and no digest, we need to set an\n\t\t// initial dummy digest, so that tag.Equals() will return false.\n\t\t// TODO: Fix this. This is just a workaround.\n\t\tif vc.SortMode == image.VersionSortDigest {\n\t\t\tif !updateableImage.ImageTag.IsDigest() {\n\t\t\t\tlog.Tracef(\"Setting dummy digest for image %s\", updateableImage.GetFullNameWithTag())\n\t\t\t\tupdateableImage.ImageTag.TagDigest = \"dummy\"\n\t\t\t}\n\t\t}\n\n\t\tif needsUpdate(updateableImage, applicationImage, latest) {\n\n\t\t\timgCtx.Infof(\"Setting new image to %s\", applicationImage.WithTag(latest).GetFullNameWithTag())\n\t\t\tneedUpdate = true\n\n\t\t\terr = setAppImage(&updateConf.UpdateApp.Application, applicationImage.WithTag(latest))\n\n\t\t\tif err != nil {\n\t\t\t\timgCtx.Errorf(\"Error while trying to update image: %v\", err)\n\t\t\t\tresult.NumErrors += 1\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\tcontainerImageNew := applicationImage.WithTag(latest)\n\t\t\t\timgCtx.Infof(\"Successfully updated image '%s' to '%s', but pending spec update (dry run=%v)\", updateableImage.GetFullNameWithTag(), containerImageNew.GetFullNameWithTag(), updateConf.DryRun)\n\t\t\t\tchangeList = append(changeList, ChangeEntry{containerImageNew, updateableImage.ImageTag, containerImageNew.ImageTag})\n\t\t\t}\n\t\t} else {\n\t\t\t// We need to explicitly set the up-to-date images in the spec too, so\n\t\t\t// that we correctly marshal out the parameter overrides to include all\n\t\t\t// images, regardless of those were updated or not.\n\t\t\terr = setAppImage(&updateConf.UpdateApp.Application, applicationImage.WithTag(updateableImage.ImageTag))\n\t\t\tif err != nil {\n\t\t\t\timgCtx.Errorf(\"Error while trying to update image: %v\", err)\n\t\t\t\tresult.NumErrors += 1\n\t\t\t}\n\t\t\timgCtx.Debugf(\"Image '%s' already on latest allowed version\", updateableImage.GetFullNameWithTag())\n\t\t}\n\t}\n\n\twbc, err := getWriteBackConfig(&updateConf.UpdateApp.Application, updateConf.KubeClient, updateConf.ArgoClient)\n\tif err != nil {\n\t\treturn result\n\t}\n\n\tif wbc.Method == WriteBackGit {\n\t\tif updateConf.GitCommitUser != \"\" {\n\t\t\twbc.GitCommitUser = updateConf.GitCommitUser\n\t\t}\n\t\tif updateConf.GitCommitEmail != \"\" {\n\t\t\twbc.GitCommitEmail = updateConf.GitCommitEmail\n\t\t}\n\t\tif len(changeList) > 0 && updateConf.GitCommitMessage != nil {\n\t\t\twbc.GitCommitMessage = TemplateCommitMessage(updateConf.GitCommitMessage, updateConf.UpdateApp.Application.Name, changeList)\n\t\t}\n\t}\n\n\tif needUpdate {\n\t\tlogCtx := log.WithContext().AddField(\"application\", app)\n\t\tlog.Debugf(\"Using commit message: %s\", wbc.GitCommitMessage)\n\t\tif !updateConf.DryRun {\n\t\t\tlogCtx.Infof(\"Committing %d parameter update(s) for application %s\", result.NumImagesUpdated, app)\n\t\t\terr := commitChangesLocked(&updateConf.UpdateApp.Application, wbc, state)\n\t\t\tif err != nil {\n\t\t\t\tlogCtx.Errorf(\"Could not update application spec: %v\", err)\n\t\t\t\tresult.NumErrors += 1\n\t\t\t\tresult.NumImagesUpdated = 0\n\t\t\t} else {\n\t\t\t\tlogCtx.Infof(\"Successfully updated the live application spec\")\n\t\t\t\tresult.NumImagesUpdated += 1\n\t\t\t\tif !updateConf.DisableKubeEvents && updateConf.KubeClient != nil {\n\t\t\t\t\tannotations := map[string]string{}\n\t\t\t\t\tfor i, c := range changeList {\n\t\t\t\t\t\tannotations[fmt.Sprintf(\"argocd-image-updater.image-%d/full-image-name\", i)] = c.Image.GetFullNameWithoutTag()\n\t\t\t\t\t\tannotations[fmt.Sprintf(\"argocd-image-updater.image-%d/image-name\", i)] = c.Image.ImageName\n\t\t\t\t\t\tannotations[fmt.Sprintf(\"argocd-image-updater.image-%d/old-tag\", i)] = c.OldTag.String()\n\t\t\t\t\t\tannotations[fmt.Sprintf(\"argocd-image-updater.image-%d/new-tag\", i)] = c.NewTag.String()\n\t\t\t\t\t}\n\t\t\t\t\tmessage := fmt.Sprintf(\"Successfully updated application '%s'\", app)\n\t\t\t\t\t_, err = updateConf.KubeClient.CreateApplicationEvent(&updateConf.UpdateApp.Application, \"ImagesUpdated\", message, annotations)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlogCtx.Warnf(\"Event could not be sent: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tlogCtx.Infof(\"Dry run - not commiting %d changes to application\", result.NumImagesUpdated)\n\t\t}\n\t}\n\n\treturn result\n}", "func (h *proxyHandler) cacheTargetManifest(img *openImage) error {\n\tctx := context.Background()\n\tif img.cachedimg != nil {\n\t\treturn nil\n\t}\n\tunparsedToplevel := image.UnparsedInstance(img.src, nil)\n\tmfest, manifestType, err := unparsedToplevel.Manifest(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar target *image.UnparsedImage\n\tif manifest.MIMETypeIsMultiImage(manifestType) {\n\t\tmanifestList, err := manifest.ListFromBlob(mfest, manifestType)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tinstanceDigest, err := manifestList.ChooseInstance(h.sysctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\ttarget = image.UnparsedInstance(img.src, &instanceDigest)\n\t} else {\n\t\ttarget = unparsedToplevel\n\t}\n\tcachedimg, err := image.FromUnparsedImage(ctx, h.sysctx, target)\n\tif err != nil {\n\t\treturn err\n\t}\n\timg.cachedimg = cachedimg\n\treturn nil\n}", "func (m *Monocular) UpdateMetadata(info *interfaces.Info, userGUID string, echoContext echo.Context) {\n}", "func (ir *ImageEngine) ManifestAdd(_ context.Context, name string, imageNames []string, opts entities.ManifestAddOptions) (string, error) {\n\toptions := new(manifests.AddOptions).WithAll(opts.All).WithArch(opts.Arch).WithVariant(opts.Variant)\n\toptions.WithFeatures(opts.Features).WithImages(imageNames).WithOS(opts.OS).WithOSVersion(opts.OSVersion)\n\toptions.WithUsername(opts.Username).WithPassword(opts.Password).WithAuthfile(opts.Authfile)\n\n\tif len(opts.Annotation) != 0 {\n\t\tannotations := make(map[string]string)\n\t\tfor _, annotationSpec := range opts.Annotation {\n\t\t\tspec := strings.SplitN(annotationSpec, \"=\", 2)\n\t\t\tif len(spec) != 2 {\n\t\t\t\treturn \"\", fmt.Errorf(\"no value given for annotation %q\", spec[0])\n\t\t\t}\n\t\t\tannotations[spec[0]] = spec[1]\n\t\t}\n\t\topts.Annotations = envLib.Join(opts.Annotations, annotations)\n\t}\n\toptions.WithAnnotation(opts.Annotations)\n\n\tif s := opts.SkipTLSVerify; s != types.OptionalBoolUndefined {\n\t\tif s == types.OptionalBoolTrue {\n\t\t\toptions.WithSkipTLSVerify(true)\n\t\t} else {\n\t\t\toptions.WithSkipTLSVerify(false)\n\t\t}\n\t}\n\n\tid, err := manifests.Add(ir.ClientCtx, name, options)\n\tif err != nil {\n\t\treturn id, fmt.Errorf(\"adding to manifest list %s: %w\", name, err)\n\t}\n\treturn id, nil\n}", "func ImageManifestString(im *schema.ImageManifest) (string, error) {\n\t// When nil have been passed as an argument, it will create an\n\t// empty manifest and define the minimal attributes.\n\tif im == nil {\n\t\tim = new(schema.ImageManifest)\n\t}\n\n\t// Set the default kind of the AC image manifest.\n\tif im.ACKind == \"\" {\n\t\tim.ACKind = schema.ImageManifestKind\n\t}\n\n\t// Set the default version of the AC image manifest.\n\tif im.ACVersion == zeroVersion {\n\t\tim.ACVersion = schema.AppContainerVersion\n\t}\n\n\t// Set the default name of the AC image manifest.\n\tif im.Name == \"\" {\n\t\tim.Name = defaultName\n\t}\n\n\tb, err := json.Marshal(toImageManifest(im))\n\treturn string(b), err\n}", "func ConvertManifest(ctx context.Context, store content.Store, desc ocispec.Descriptor) (ocispec.Descriptor, error) {\n\tif !(desc.MediaType == images.MediaTypeDockerSchema2Manifest ||\n\t\tdesc.MediaType == ocispec.MediaTypeImageManifest) {\n\n\t\tlog.G(ctx).Warnf(\"do nothing for media type: %s\", desc.MediaType)\n\t\treturn desc, nil\n\t}\n\n\t// read manifest data\n\tmb, err := content.ReadBlob(ctx, store, desc)\n\tif err != nil {\n\t\treturn ocispec.Descriptor{}, fmt.Errorf(\"failed to read index data: %w\", err)\n\t}\n\n\tvar manifest ocispec.Manifest\n\tif err := json.Unmarshal(mb, &manifest); err != nil {\n\t\treturn ocispec.Descriptor{}, fmt.Errorf(\"failed to unmarshal data into manifest: %w\", err)\n\t}\n\n\t// check config media type\n\tif manifest.Config.MediaType != LegacyConfigMediaType {\n\t\treturn desc, nil\n\t}\n\n\tmanifest.Config.MediaType = images.MediaTypeDockerSchema2Config\n\tdata, err := json.MarshalIndent(manifest, \"\", \" \")\n\tif err != nil {\n\t\treturn ocispec.Descriptor{}, fmt.Errorf(\"failed to marshal manifest: %w\", err)\n\t}\n\n\t// update manifest with gc labels\n\tdesc.Digest = digest.Canonical.FromBytes(data)\n\tdesc.Size = int64(len(data))\n\n\tlabels := map[string]string{}\n\tfor i, c := range append([]ocispec.Descriptor{manifest.Config}, manifest.Layers...) {\n\t\tlabels[fmt.Sprintf(\"containerd.io/gc.ref.content.%d\", i)] = c.Digest.String()\n\t}\n\n\tref := remotes.MakeRefKey(ctx, desc)\n\tif err := content.WriteBlob(ctx, store, ref, bytes.NewReader(data), desc, content.WithLabels(labels)); err != nil {\n\t\treturn ocispec.Descriptor{}, fmt.Errorf(\"failed to update content: %w\", err)\n\t}\n\treturn desc, nil\n}", "func (pmc *proxyMetricsCollector) ManifestPush(bytesPushed uint64) {\n\tatomic.AddUint64(&pmc.manifestMetrics.Requests, 1)\n\tatomic.AddUint64(&pmc.manifestMetrics.Hits, 1)\n\tatomic.AddUint64(&pmc.manifestMetrics.BytesPushed, bytesPushed)\n}", "func (restorer *APTRestorer) writeManifest(manifestType, algorithm string, restoreState *models.RestoreState) {\n\tif algorithm != constants.AlgMd5 && algorithm != constants.AlgSha256 {\n\t\trestorer.Context.MessageLog.Fatalf(\"writeManifest: Unsupported algorithm: %s\", algorithm)\n\t}\n\tmanifestPath := restorer.getManifestPath(manifestType, algorithm, restoreState)\n\tmanifestFile, err := os.Create(manifestPath)\n\tif err != nil {\n\t\trestoreState.PackageSummary.AddError(\"Cannot create manifest file %s: %v\",\n\t\t\tmanifestPath, err)\n\t\treturn\n\t}\n\tdefer manifestFile.Close()\n\tfor _, gf := range restoreState.IntellectualObject.GenericFiles {\n\t\tif !restorer.fileBelongsInManifest(gf, manifestType) {\n\t\t\trestorer.Context.MessageLog.Info(\"Skipping file '%s' for manifest type %s (%s)\",\n\t\t\t\tgf.Identifier, manifestType, algorithm)\n\t\t\tcontinue\n\t\t} else {\n\t\t\trestorer.Context.MessageLog.Info(\"Adding '%s' to %s\", gf.Identifier, manifestFile.Name())\n\t\t}\n\t\tchecksum := gf.GetChecksumByAlgorithm(algorithm)\n\t\tif checksum == nil {\n\t\t\trestoreState.PackageSummary.AddError(\"Cannot find %s checksum for file %s\",\n\t\t\t\talgorithm, gf.OriginalPath())\n\t\t\treturn\n\t\t}\n\t\t_, err := fmt.Fprintln(manifestFile, checksum.Digest, gf.OriginalPath())\n\t\tif err != nil {\n\t\t\trestoreState.PackageSummary.AddError(\"Error writing checksum for file %s \"+\n\t\t\t\t\"to manifest %s: %v\", gf.OriginalPath(), manifestPath, err)\n\t\t\treturn\n\t\t} else {\n\t\t\trestorer.Context.MessageLog.Info(\"Wrote %s digest %s for file %s\", algorithm,\n\t\t\t\tchecksum.Digest, gf.Identifier)\n\t\t}\n\t}\n}", "func (h *proxyHandler) GetManifest(args []any) (replyBuf, error) {\n\th.lock.Lock()\n\tdefer h.lock.Unlock()\n\n\tvar ret replyBuf\n\n\tif h.sysctx == nil {\n\t\treturn ret, fmt.Errorf(\"client error: must invoke Initialize\")\n\t}\n\tif len(args) != 1 {\n\t\treturn ret, fmt.Errorf(\"invalid request, expecting one argument\")\n\t}\n\timgref, err := h.parseImageFromID(args[0])\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = h.cacheTargetManifest(imgref)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\timg := imgref.cachedimg\n\n\tctx := context.Background()\n\trawManifest, manifestType, err := img.Manifest(ctx)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t// We only support OCI and docker2schema2. We know docker2schema2 can be easily+cheaply\n\t// converted into OCI, so consumers only need to see OCI.\n\tswitch manifestType {\n\tcase imgspecv1.MediaTypeImageManifest, manifest.DockerV2Schema2MediaType:\n\t\tbreak\n\t// Explicitly reject e.g. docker schema 1 type with a \"legacy\" note\n\tcase manifest.DockerV2Schema1MediaType, manifest.DockerV2Schema1SignedMediaType:\n\t\treturn ret, fmt.Errorf(\"unsupported legacy manifest MIME type: %s\", manifestType)\n\tdefault:\n\t\treturn ret, fmt.Errorf(\"unsupported manifest MIME type: %s\", manifestType)\n\t}\n\n\t// We always return the original digest, as that's what clients need to do pull-by-digest\n\t// and in general identify the image.\n\tdigest, err := manifest.Digest(rawManifest)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\tvar serialized []byte\n\t// But, we convert to OCI format on the wire if it's not already. The idea here is that by reusing the containers/image\n\t// stack, clients to this proxy can pretend the world is OCI only, and not need to care about e.g.\n\t// docker schema and MIME types.\n\tif manifestType != imgspecv1.MediaTypeImageManifest {\n\t\tmanifestUpdates := types.ManifestUpdateOptions{ManifestMIMEType: imgspecv1.MediaTypeImageManifest}\n\t\tociImage, err := img.UpdatedImage(ctx, manifestUpdates)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\tociSerialized, _, err := ociImage.Manifest(ctx)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\t\tserialized = ociSerialized\n\t} else {\n\t\tserialized = rawManifest\n\t}\n\treturn h.returnBytes(digest, serialized)\n}", "func (d *InboundCacheDriver) LoadManifest(location models.ImageReference, now time.Time) (contents []byte, mediaType string, err error) {\n\tmaxInsertedAt := now.Add(-d.MaxAge)\n\tentry, ok := d.Entries[location]\n\tif ok && entry.InsertedAt.After(maxInsertedAt) {\n\t\treturn entry.Contents, entry.MediaType, nil\n\t}\n\treturn nil, \"\", sql.ErrNoRows\n}", "func UpdateFileMeta(fmeta FileMeta) {\n\tfileMetas[fmeta.FileSha1] = fmeta\n}", "func (b *Backend) ManifestInspect(ctx context.Context, req *pb.ManifestInspectRequest) (*pb.ManifestInspectResponse, error) {\n\tif !b.daemon.opts.Experimental {\n\t\treturn &pb.ManifestInspectResponse{}, errors.New(\"please enable experimental to use manifest feature\")\n\t}\n\n\tlogrus.WithFields(logrus.Fields{\n\t\t\"ManifestList\": req.GetManifestList(),\n\t}).Info(\"ManifestInspectRequest received\")\n\n\tmanifestName := req.GetManifestList()\n\n\t// get list image\n\tref, _, err := image.FindImage(b.daemon.localStore, manifestName)\n\tif err != nil {\n\t\treturn &pb.ManifestInspectResponse{}, err\n\t}\n\n\t// get image reference\n\tsrc, err := ref.NewImageSource(ctx, image.GetSystemContext())\n\tif err != nil {\n\t\treturn &pb.ManifestInspectResponse{}, err\n\t}\n\n\tdefer func() {\n\t\tif cErr := src.Close(); cErr != nil {\n\t\t\tlogrus.Warnf(\"Image source closing error: %v\", cErr)\n\t\t}\n\t}()\n\n\t// get image manifest\n\tmanifestBytes, manifestType, err := src.GetManifest(ctx, nil)\n\tif err != nil {\n\t\treturn &pb.ManifestInspectResponse{}, err\n\t}\n\n\t// check whether image is a list image\n\tif !manifest.MIMETypeIsMultiImage(manifestType) {\n\t\treturn &pb.ManifestInspectResponse{}, errors.Errorf(\"%v is not a manifest list\", manifestName)\n\t}\n\n\t// return list image data\n\treturn &pb.ManifestInspectResponse{\n\t\tData: manifestBytes,\n\t}, nil\n}", "func (is *ObjectStorage) DeleteImageManifest(repo, reference string, detectCollisions bool) error {\n\tdir := path.Join(is.rootDir, repo)\n\tif fi, err := is.store.Stat(context.Background(), dir); err != nil || !fi.IsDir() {\n\t\treturn zerr.ErrRepoNotFound\n\t}\n\n\tvar lockLatency time.Time\n\n\tvar err error\n\n\tis.Lock(&lockLatency)\n\tdefer func() {\n\t\tis.Unlock(&lockLatency)\n\n\t\tif err == nil {\n\t\t\tmonitoring.SetStorageUsage(is.metrics, is.rootDir, repo)\n\t\t}\n\t}()\n\n\tindex, err := common.GetIndex(is, repo, is.log)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmanifestDesc, err := common.RemoveManifestDescByReference(&index, reference, detectCollisions)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = common.UpdateIndexWithPrunedImageManifests(is, &index, repo, manifestDesc, manifestDesc.Digest, is.log)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// now update \"index.json\"\n\tdir = path.Join(is.rootDir, repo)\n\tfile := path.Join(dir, \"index.json\")\n\n\tbuf, err := json.Marshal(index)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif _, err := writeFile(is.store, file, buf); err != nil {\n\t\tis.log.Debug().Str(\"deleting reference\", reference).Msg(\"\")\n\n\t\treturn err\n\t}\n\n\t// Delete blob only when blob digest not present in manifest entry.\n\t// e.g. 1.0.1 & 1.0.2 have same blob digest so if we delete 1.0.1, blob should not be removed.\n\ttoDelete := true\n\n\tfor _, manifest := range index.Manifests {\n\t\tif manifestDesc.Digest.String() == manifest.Digest.String() {\n\t\t\ttoDelete = false\n\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif toDelete {\n\t\tp := path.Join(dir, \"blobs\", manifestDesc.Digest.Algorithm().String(), manifestDesc.Digest.Encoded())\n\n\t\terr = is.store.Delete(context.Background(), p)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (s HTTPServer) UpdateImages(w http.ResponseWriter, r *http.Request) {\n\tvar (\n\t\tvars = mux.Vars(r)\n\t\timage = vars[\"image\"]\n\t\tkind = vars[\"kind\"]\n\t)\n\tif err := r.ParseForm(); err != nil {\n\t\ttransport.WriteError(w, r, http.StatusBadRequest, errors.Wrapf(err, \"parsing form\"))\n\t\treturn\n\t}\n\tvar serviceSpecs []update.ResourceSpec\n\tfor _, service := range r.Form[\"service\"] {\n\t\tserviceSpec, err := update.ParseResourceSpec(service)\n\t\tif err != nil {\n\t\t\ttransport.WriteError(w, r, http.StatusBadRequest, errors.Wrapf(err, \"parsing service spec %q\", service))\n\t\t\treturn\n\t\t}\n\t\tserviceSpecs = append(serviceSpecs, serviceSpec)\n\t}\n\timageSpec, err := update.ParseImageSpec(image)\n\tif err != nil {\n\t\ttransport.WriteError(w, r, http.StatusBadRequest, errors.Wrapf(err, \"parsing image spec %q\", image))\n\t\treturn\n\t}\n\treleaseKind, err := update.ParseReleaseKind(kind)\n\tif err != nil {\n\t\ttransport.WriteError(w, r, http.StatusBadRequest, errors.Wrapf(err, \"parsing release kind %q\", kind))\n\t\treturn\n\t}\n\n\tvar excludes []resource.ID\n\tfor _, ex := range r.URL.Query()[\"exclude\"] {\n\t\ts, err := resource.ParseID(ex)\n\t\tif err != nil {\n\t\t\ttransport.WriteError(w, r, http.StatusBadRequest, errors.Wrapf(err, \"parsing excluded service %q\", ex))\n\t\t\treturn\n\t\t}\n\t\texcludes = append(excludes, s)\n\t}\n\n\tspec := update.ReleaseImageSpec{\n\t\tServiceSpecs: serviceSpecs,\n\t\tImageSpec: imageSpec,\n\t\tKind: releaseKind,\n\t\tExcludes: excludes,\n\t}\n\tcause := update.Cause{\n\t\tUser: r.FormValue(\"user\"),\n\t\tMessage: r.FormValue(\"message\"),\n\t}\n\tresult, err := s.server.UpdateManifests(r.Context(), update.Spec{Type: update.Images, Cause: cause, Spec: spec})\n\tif err != nil {\n\t\ttransport.ErrorResponse(w, r, err)\n\t\treturn\n\t}\n\ttransport.JSONResponse(w, r, result)\n}", "func (p *Processor) ReplicateManifest(ctx context.Context, account keppel.Account, repo keppel.Repository, reference models.ManifestReference, actx keppel.AuditContext) (*keppel.Manifest, []byte, error) {\n\tmanifestBytes, manifestMediaType, err := p.downloadManifestViaInboundCache(ctx, account, repo, reference)\n\tif err != nil {\n\t\tif errorIsManifestNotFound(err) {\n\t\t\treturn nil, nil, UpstreamManifestMissingError{reference, err}\n\t\t}\n\t\treturn nil, nil, err\n\t}\n\n\t//parse the manifest to discover references to other manifests and blobs\n\tmanifestParsed, _, err := keppel.ParseManifest(manifestMediaType, manifestBytes)\n\tif err != nil {\n\t\treturn nil, nil, keppel.ErrManifestInvalid.With(err.Error())\n\t}\n\n\t//replicate referenced manifests recursively if required\n\tfor _, desc := range manifestParsed.ManifestReferences(account.PlatformFilter) {\n\t\t_, err := keppel.FindManifest(p.db, repo, desc.Digest)\n\t\tif errors.Is(err, sql.ErrNoRows) {\n\t\t\t_, _, err = p.ReplicateManifest(ctx, account, repo, models.ManifestReference{Digest: desc.Digest}, actx)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t}\n\n\t//mark all missing blobs as pending replication\n\tfor _, desc := range manifestParsed.BlobReferences() {\n\t\t//mark referenced blobs as pending replication if not replicated yet\n\t\tblob, err := p.FindBlobOrInsertUnbackedBlob(desc, account)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\t//also ensure that the blob is mounted in this repo (this is also\n\t\t//important if the blob exists; it may only have been replicated in a\n\t\t//different repo)\n\t\terr = keppel.MountBlobIntoRepo(p.db, *blob, repo)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t}\n\n\t//if the manifest is an image, we need to replicate the image configuration\n\t//blob immediately because ValidateAndStoreManifest() uses it for validation\n\t//purposes\n\tconfigBlobDesc := manifestParsed.FindImageConfigBlob()\n\tif configBlobDesc != nil {\n\t\tconfigBlob, err := keppel.FindBlobByAccountName(p.db, configBlobDesc.Digest, account)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\tif configBlob.StorageID == \"\" {\n\t\t\t_, err = p.ReplicateBlob(ctx, *configBlob, account, repo, nil)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\tmanifest, err := p.ValidateAndStoreManifest(account, repo, IncomingManifest{\n\t\tReference: reference,\n\t\tMediaType: manifestMediaType,\n\t\tContents: manifestBytes,\n\t\tPushedAt: p.timeNow(),\n\t}, actx)\n\treturn manifest, manifestBytes, err\n}", "func toImageManifest(m *schema.ImageManifest) *aciManifest {\n\treturn &aciManifest{\n\t\tACKind: aciKind(m.ACKind),\n\t\tACVersion: m.ACVersion,\n\t\tName: aciName(m.Name),\n\t\tLabels: aciLabels(m.Labels),\n\t\tApp: (*aciApp)(m.App),\n\t\tAnnotations: aciAnnotations(m.Annotations),\n\t\tDependencies: aciDependencies(m.Dependencies),\n\t\tPathWhitelist: m.PathWhitelist,\n\t}\n}", "func (p *postProcessor) Manifest() (map[string]ManifestEntry, error) {\n\tlog.Println(\"updating gapic manifest\")\n\tentries := map[string]ManifestEntry{} // Key is the package name.\n\tf, err := os.Create(filepath.Join(p.googleCloudDir, \"internal\", \".repo-metadata-full.json\"))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer f.Close()\n\tfor _, manual := range p.config.ManualClientInfo {\n\t\tentries[manual.DistributionName] = *manual\n\t}\n\tfor inputDir, conf := range p.config.GoogleapisToImportPath {\n\t\tif conf.ServiceConfig == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tyamlPath := filepath.Join(p.googleapisDir, inputDir, conf.ServiceConfig)\n\t\tyamlFile, err := os.Open(yamlPath)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tyamlConfig := struct {\n\t\t\tTitle string `yaml:\"title\"` // We only need the title field.\n\t\t}{}\n\t\tif err := yaml.NewDecoder(yamlFile).Decode(&yamlConfig); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"decode: %v\", err)\n\t\t}\n\t\tdocURL, err := docURL(p.googleCloudDir, conf.ImportPath)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to build docs URL: %v\", err)\n\t\t}\n\t\treleaseLevel, err := releaseLevel(p.googleCloudDir, conf.ImportPath)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to calculate release level for %v: %v\", inputDir, err)\n\t\t}\n\n\t\tentry := ManifestEntry{\n\t\t\tDistributionName: conf.ImportPath,\n\t\t\tDescription: yamlConfig.Title,\n\t\t\tLanguage: \"Go\",\n\t\t\tClientLibraryType: \"generated\",\n\t\t\tDocsURL: docURL,\n\t\t\tReleaseLevel: releaseLevel,\n\t\t\tLibraryType: gapicAutoLibraryType,\n\t\t}\n\t\tentries[conf.ImportPath] = entry\n\t}\n\t// Remove base module entry\n\tdelete(entries, \"\")\n\tenc := json.NewEncoder(f)\n\tenc.SetIndent(\"\", \" \")\n\treturn entries, enc.Encode(entries)\n}", "func (d *Daemon) UpdateManifests(ctx context.Context, spec update.Spec) (job.ID, error) {\n\tvar id job.ID\n\tif spec.Type == \"\" {\n\t\treturn id, errors.New(\"no type in update spec\")\n\t}\n\tswitch s := spec.Spec.(type) {\n\tcase release.Changes:\n\t\tif s.ReleaseKind() == update.ReleaseKindPlan {\n\t\t\tid := job.ID(guid.New())\n\t\t\t_, err := d.executeJob(id, d.makeJobFromUpdate(d.release(spec, s)), d.Logger)\n\t\t\treturn id, err\n\t\t}\n\t\treturn d.queueJob(d.makeLoggingJobFunc(d.makeJobFromUpdate(d.release(spec, s)))), nil\n\tcase resource.PolicyUpdates:\n\t\treturn d.queueJob(d.makeLoggingJobFunc(d.makeJobFromUpdate(d.updatePolicies(spec, s)))), nil\n\tcase update.ManualSync:\n\t\treturn d.queueJob(d.sync()), nil\n\tdefault:\n\t\treturn id, fmt.Errorf(`unknown update type \"%s\"`, spec.Type)\n\t}\n}", "func (b *Backend) ManifestCreate(ctx context.Context, req *pb.ManifestCreateRequest) (*pb.ManifestCreateResponse, error) {\n\tif !b.daemon.opts.Experimental {\n\t\treturn &pb.ManifestCreateResponse{}, errors.New(\"please enable experimental to use manifest feature\")\n\t}\n\n\tlogrus.WithFields(logrus.Fields{\n\t\t\"ManifestList\": req.GetManifestList(),\n\t\t\"Manifest\": req.GetManifests(),\n\t}).Info(\"ManifestCreateRequest received\")\n\n\tmanifestName := req.GetManifestList()\n\tmanifests := req.GetManifests()\n\n\tlist := &manifestList{\n\t\tdocker: manifest.Schema2List{\n\t\t\tSchemaVersion: container.SchemaVersion,\n\t\t\tMediaType: manifest.DockerV2ListMediaType,\n\t\t},\n\t\tinstances: make(map[digest.Digest]string, 0),\n\t}\n\n\tfor _, imageSpec := range manifests {\n\t\t// add image to list\n\t\tif _, err := list.addImage(ctx, b.daemon.localStore, imageSpec); err != nil {\n\t\t\treturn &pb.ManifestCreateResponse{}, err\n\t\t}\n\t}\n\n\t// expand list name\n\t_, imageName, err := dockerfile.CheckAndExpandTag(manifestName)\n\tif err != nil {\n\t\treturn &pb.ManifestCreateResponse{}, err\n\t}\n\t// save list to image\n\timageID, err := list.saveListToImage(b.daemon.localStore, \"\", imageName, list.docker.MediaType)\n\n\treturn &pb.ManifestCreateResponse{\n\t\tImageID: imageID,\n\t}, err\n}", "func (f *File) AddManifest(mainClass string) error {\n\tmanifest := fmt.Sprintf(\"Manifest-Version: 1.0\\nMain-Class: %s\\n\", mainClass)\n\treturn f.WriteFile(\"META-INF/MANIFEST.MF\", []byte(manifest), 0644)\n}", "func calculateManifest(imageToTags map[v1.Image][]string) (m Manifest, err error) {\n\tif len(imageToTags) == 0 {\n\t\treturn nil, errors.New(\"set of images is empty\")\n\t}\n\n\tfor img, tags := range imageToTags {\n\t\tcfgName, err := img.ConfigName()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// Store foreign layer info.\n\t\tlayerSources := make(map[v1.Hash]v1.Descriptor)\n\n\t\t// Write the layers.\n\t\tlayers, err := img.Layers()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tlayerFiles := make([]string, len(layers))\n\t\tfor i, l := range layers {\n\t\t\td, err := l.Digest()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t// Munge the file name to appease ancient technology.\n\t\t\t//\n\t\t\t// tar assumes anything with a colon is a remote tape drive:\n\t\t\t// https://www.gnu.org/software/tar/manual/html_section/tar_45.html\n\t\t\t// Drop the algorithm prefix, e.g. \"sha256:\"\n\t\t\thex := d.Hex\n\n\t\t\t// gunzip expects certain file extensions:\n\t\t\t// https://www.gnu.org/software/gzip/manual/html_node/Overview.html\n\t\t\tlayerFiles[i] = fmt.Sprintf(\"%s.tar.gz\", hex)\n\n\t\t\t// Add to LayerSources if it's a foreign layer.\n\t\t\tdesc, err := partial.BlobDescriptor(img, d)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif !desc.MediaType.IsDistributable() {\n\t\t\t\tdiffid, err := partial.BlobToDiffID(img, d)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tlayerSources[diffid] = *desc\n\t\t\t}\n\t\t}\n\n\t\t// Generate the tar descriptor and write it.\n\t\tm = append(m, Descriptor{\n\t\t\tConfig: cfgName.String(),\n\t\t\tRepoTags: tags,\n\t\t\tLayers: layerFiles,\n\t\t\tLayerSources: layerSources,\n\t\t})\n\t}\n\t// sort by name of the repotags so it is consistent. Alternatively, we could sort by hash of the\n\t// descriptor, but that would make it hard for humans to process\n\tsort.Slice(m, func(i, j int) bool {\n\t\treturn strings.Join(m[i].RepoTags, \",\") < strings.Join(m[j].RepoTags, \",\")\n\t})\n\n\treturn m, nil\n}", "func (p *Pvr) UpdateApplication(app AppData) error {\n\tappManifest, err := p.GetApplicationManifest(app.Appname)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !app.DoOverlay && (appManifest.Base == \"\" || appManifest.Base == app.Appname) {\n\t\tapp.SquashFile = SQUASH_FILE\n\t\tapp.DoOverlay = false\n\t\tfmt.Println(\"Update base: \" + app.SquashFile)\n\t\tappManifest.DockerOvlDigest = \"\"\n\t} else {\n\t\tapp.DoOverlay = true\n\t\tapp.SquashFile = SQUASH_OVL_FILE\n\t\tfmt.Println(\"Update ovl: \" + app.SquashFile)\n\t}\n\tswitch app.SourceType {\n\tcase models.SourceTypeDocker:\n\t\terr = UpdateDockerApp(p, &app, appManifest)\n\tcase models.SourceTypeRootFs:\n\t\terr = UpdateRootFSApp(p, &app, appManifest)\n\tcase models.SourceTypePvr:\n\t\terr = UpdatePvApp(p, &app, appManifest)\n\tdefault:\n\t\terr = fmt.Errorf(\"type %s not supported yet\", models.SourceTypePvr)\n\t}\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = p.InstallApplication(&app)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tapps, err := p.GetApplications()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Printf(\"Searching for dependencies of %s\\n\", app.Appname)\n\tfor _, a := range apps {\n\t\tif appManifest.Base == app.Appname {\n\t\t\tfmt.Printf(\"Updating dependency %s\\n\", a.Appname)\n\t\t\tif err := UpdateDockerApp(p, &a, appManifest); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfmt.Printf(\"%s is up to date\\n\", a.Appname)\n\t\t}\n\t}\n\n\treturn err\n}", "func (a *ACBuild) ReplaceManifest(manifestPath string) (err error) {\n\tif err = a.lock(); err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\tif err1 := a.unlock(); err == nil {\n\t\t\terr = err1\n\t\t}\n\t}()\n\n\tfinfo, err := os.Stat(manifestPath)\n\tswitch {\n\tcase os.IsNotExist(err):\n\t\treturn fmt.Errorf(\"no such file or directory: %s\", manifestPath)\n\tcase err != nil:\n\t\treturn err\n\tcase finfo.IsDir():\n\t\treturn fmt.Errorf(\"%s is a directory\", manifestPath)\n\tdefault:\n\t\tbreak\n\t}\n\n\tmanblob, err := ioutil.ReadFile(manifestPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Marshal and Unmarshal the manifest to assert that it's valid and to\n\t// strip any whitespace\n\n\tvar man schema.ImageManifest\n\terr = man.UnmarshalJSON(manblob)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmanblob, err = man.MarshalJSON()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn ioutil.WriteFile(path.Join(a.CurrentACIPath, aci.ManifestFile), manblob, 0755)\n}", "func (s *Stargate) InitializeManifestUpdateCycle() {\n\tgo func() {\n\t\tfor {\n\t\t\tif err := s.UpdateManifest(); err != nil {\n\t\t\t\tfmt.Printf(\"Error updating manifest: %v\\n\", err)\n\t\t\t}\n\t\t\ttime.Sleep(time.Duration(s.UpdatePeriod) * time.Second)\n\t\t}\n\t}()\n}", "func (*CNETMsg_SpawnGroup_ManifestUpdate) Descriptor() ([]byte, []int) {\n\treturn file_artifact_networkbasetypes_proto_rawDescGZIP(), []int{17}\n}", "func (ir *ImageEngine) ManifestRemoveDigest(ctx context.Context, name string, image string) (string, error) {\n\tupdatedListID, err := manifests.Remove(ir.ClientCtx, name, image, nil)\n\tif err != nil {\n\t\treturn updatedListID, fmt.Errorf(\"removing from manifest %s: %w\", name, err)\n\t}\n\treturn fmt.Sprintf(\"%s :%s\\n\", updatedListID, image), nil\n}", "func (client *Client) AddImage(manifest map[string][]byte, layers map[string][]byte) (string, error) {\n\tmf := make(map[string]files.Node)\n\tfor k, v := range manifest {\n\t\tmf[k] = files.NewBytesFile(v)\n\t}\n\n\tbf := make(map[string]files.Node)\n\tfor k, v := range layers {\n\t\tbf[k] = files.NewBytesFile(v)\n\t}\n\n\tsf := files.NewMapDirectory(map[string]files.Node{\n\t\t\"blobs\": files.NewMapDirectory(bf),\n\t\t\"manifests\": files.NewMapDirectory(mf),\n\t})\n\tslf := files.NewSliceDirectory([]files.DirEntry{files.FileEntry(\"image\", sf)})\n\n\treader := files.NewMultiFileReader(slf, true)\n\tresp, err := client.client.Request(\"add\").\n\t\tOption(\"recursive\", true).\n\t\tOption(\"cid-version\", 1).\n\t\tBody(reader).\n\t\tSend(context.Background())\n\tif err != nil {\n\t\treturn \"\", nil\n\t}\n\n\tdefer resp.Close()\n\n\tif resp.Error != nil {\n\t\treturn \"\", resp.Error\n\t}\n\n\tdec := json.NewDecoder(resp.Output)\n\tvar final string\n\tfor {\n\t\tvar out object\n\t\terr = dec.Decode(&out)\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn \"\", err\n\t\t}\n\t\tfinal = out.Hash\n\t}\n\n\tif final == \"\" {\n\t\treturn \"\", errors.New(\"no results received\")\n\t}\n\n\treturn final, nil\n}", "func Update(fileMeta FileMeta){\n\tfileMetas[fileMeta.FileSha1] = fileMeta\n}", "func (c *Controller) syncHandler(key string) error {\n\t// If an error occurs during handling, we'll requeue the item so we can\n\t// attempt processing again later. This could have been caused by a\n\t// temporary network failure, or any other transient reason.\n\n\t// Convert the namespace/name string into a distinct namespace and name\n\tns, name, err := cache.SplitMetaNamespaceKey(key)\n\tif err != nil {\n\t\tutilruntime.HandleError(fmt.Errorf(\"invalid resource key: %s\", key))\n\t\treturn nil\n\t}\n\n\tklog.V(4).Infof(\"start processing Manifest %q\", key)\n\t// Get the Manifest resource with this name\n\tmanifest, err := c.manifestLister.Manifests(ns).Get(name)\n\t// The Manifest resource may no longer exist, in which case we stop processing.\n\tif errors.IsNotFound(err) {\n\t\tklog.V(2).Infof(\"Manifest %q has been deleted\", key)\n\t\treturn nil\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif manifest.Template.Raw == nil {\n\t\tklog.Warning(\"manifest.Template.Raw is empty, %q\", klog.KObj(manifest))\n\t\treturn nil\n\t}\n\tutd := &unstructured.Unstructured{}\n\terr = json.Unmarshal(manifest.Template.Raw, &utd.Object)\n\tif err != nil {\n\t\tklog.Errorf(\"unmarshal error, %q, err=%v\", klog.KObj(manifest), err)\n\t\treturn err\n\t}\n\n\tresourceKind := utd.GroupVersionKind().Kind\n\n\tmatchAnnotations := util.FindAnnotationsMathKeyPrefix(utd.GetAnnotations())\n\t//为空则表示在update时候进行过更新,清除过annotation\n\tdeleteSubscription := len(matchAnnotations) == 0\n\tif manifest.DeletionTimestamp != nil {\n\t\t//删除\n\t\tdeleteSubscription = true\n\t}\n\tmatchLabels := map[string]string{\n\t\t\"bkbcs.tencent.com/resource-kind\": resourceKind,\n\t\t\"bkbcs.tencent.com/resource-ns\": utd.GetNamespace(),\n\t\t\"bkbcs.tencent.com/resource-name\": utd.GetName(),\n\t}\n\tsubscriptionName := c.genAutoCreateSubscriptionName(utd.GetName())\n\n\tsubscriptionList, err := c.clusternetClient.AppsV1alpha1().Subscriptions(utd.GetNamespace()).List(context.Background(), metav1.ListOptions{\n\t\tLabelSelector: labels.Set(matchLabels).String(),\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\t//只会存在0个或1个\n\tif len(subscriptionList.Items) > 1 {\n\t\treturn fmt.Errorf(\"auto create sub matchLabels match %d\", len(subscriptionList.Items))\n\t}\n\tif deleteSubscription {\n\t\tklog.Infof(\"start delete subscription %s\", subscriptionName)\n\t\t//删除Subscription\n\t\terr = c.clusternetClient.AppsV1alpha1().Subscriptions(utd.GetNamespace()).Delete(context.Background(), subscriptionList.Items[0].Name, metav1.DeleteOptions{})\n\t\tif errors.IsNotFound(err) {\n\t\t\tklog.V(2).Infof(\"Subscription %s:%s has been deleted\", ns, name)\n\t\t\treturn nil\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\t//更新或创建Subscription\n\tif len(subscriptionList.Items) == 0 {\n\t\t//create\n\t\tsubscription := &appsapi.Subscription{\n\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\tName: subscriptionName,\n\t\t\t\tNamespace: utd.GetNamespace(),\n\t\t\t\tAnnotations: map[string]string{\n\t\t\t\t\t\"bkbcs.tencent.com/created-by\": \"bcs-clusternet-controller\",\n\t\t\t\t},\n\t\t\t\tLabels: matchLabels,\n\t\t\t},\n\t\t\tSpec: c.genSubscriptionSpec(matchAnnotations, utd.GroupVersionKind(), utd.GetNamespace(), utd.GetName()),\n\t\t}\n\t\tklog.Infof(\"start create Subscriptions %q\", klog.KObj(subscription))\n\t\t_, err = c.clusternetClient.AppsV1alpha1().Subscriptions(utd.GetNamespace()).Create(context.Background(), subscription, metav1.CreateOptions{})\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"create Subscriptions %q error, err=%+v\", klog.KObj(subscription), err)\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\t//update\n\tmatchSubscription := subscriptionList.Items[0]\n\tmatchSubscription.Spec = c.genSubscriptionSpec(matchAnnotations, utd.GroupVersionKind(), utd.GetNamespace(), utd.GetName())\n\tklog.Infof(\"start update Subscriptions %q\", klog.KObj(&matchSubscription))\n\t_, err = c.clusternetClient.AppsV1alpha1().Subscriptions(utd.GetNamespace()).Update(context.Background(), &matchSubscription, metav1.UpdateOptions{})\n\tif err != nil {\n\t\tklog.Errorf(\"update subscriptions %q error, err=%v\", klog.KObj(&matchSubscription), err)\n\t\treturn err\n\t}\n\treturn nil\n}", "func (i *Images) GetManifestImages(\n\tregistry, version, buildPath string,\n\tforTarballFn func(path, origTag, newTagWithArch string) error,\n) (map[string][]string, error) {\n\tmanifestImages := make(map[string][]string)\n\n\treleaseImagesPath := filepath.Join(buildPath, ImagesPath)\n\tlogrus.Infof(\"Getting manifest images in %s\", releaseImagesPath)\n\n\tarchPaths, err := os.ReadDir(releaseImagesPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"read images path %s: %w\", releaseImagesPath, err)\n\t}\n\n\tfor _, archPath := range archPaths {\n\t\tarch := archPath.Name()\n\t\tif !archPath.IsDir() {\n\t\t\tlogrus.Infof(\"Skipping %s because it's not a directory\", arch)\n\t\t\tcontinue\n\t\t}\n\n\t\tif err := filepath.Walk(\n\t\t\tfilepath.Join(releaseImagesPath, arch),\n\t\t\tfunc(path string, info os.FileInfo, err error) error {\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif info.IsDir() {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\n\t\t\t\tfileName := info.Name()\n\t\t\t\tif !strings.HasSuffix(fileName, \".tar\") {\n\t\t\t\t\tlogrus.Infof(\"Skipping non-tarball %s\", fileName)\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\n\t\t\t\torigTag, err := i.RepoTagFromTarball(path)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"getting repo tags for tarball: %w\", err)\n\t\t\t\t}\n\n\t\t\t\ttagMatches := tagRegex.FindStringSubmatch(origTag)\n\t\t\t\tif len(tagMatches) != 2 {\n\t\t\t\t\treturn fmt.Errorf(\n\t\t\t\t\t\t\"malformed tag %s in %s\", origTag, path,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tbinary := tagMatches[1]\n\t\t\t\tnewTag := filepath.Join(\n\t\t\t\t\tregistry,\n\t\t\t\t\tstrings.TrimSuffix(binary, \"-\"+arch),\n\t\t\t\t)\n\t\t\t\tnewTagWithArch := fmt.Sprintf(\"%s-%s:%s\", newTag, arch, version)\n\t\t\t\tmanifestImages[newTag] = append(manifestImages[newTag], arch)\n\n\t\t\t\tif forTarballFn != nil {\n\t\t\t\t\tif err := forTarballFn(\n\t\t\t\t\t\tpath, origTag, newTagWithArch,\n\t\t\t\t\t); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"executing tarball callback: %w\", err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t},\n\t\t); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"traversing path: %w\", err)\n\t\t}\n\t}\n\treturn manifestImages, nil\n}", "func (l logger) LogManifest(reference models.ManifestReference, level int, err error, isCached bool) {\n\tindent := strings.Repeat(\" \", level)\n\tsuffix := \"\"\n\tif isCached {\n\t\tsuffix = \" (cached result)\"\n\t}\n\tif err == nil {\n\t\tlogg.Info(\"%smanifest %s looks good%s\", indent, reference, suffix)\n\t} else {\n\t\tlogg.Error(\"%smanifest %s validation failed: %s%s\", indent, reference, err.Error(), suffix)\n\t}\n}", "func (a *App) UpdateMeta(w http.ResponseWriter, r *http.Request) {\n\tdecoder := json.NewDecoder(r.Body)\n\tvar metadata map[string]string\n\terr := decoder.Decode(&metadata)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\tdefer r.Body.Close()\n\tdoc := &types.MetaDoc{\n\t\tID: a.eventID,\n\t\tCorrelationID: a.correlationID,\n\t\tParentEventID: a.parentEventID,\n\t\tMetadata: metadata,\n\t}\n\terr = a.Meta.AddOrUpdateMetaDoc(doc)\n\tif err != nil {\n\t\trespondWithError(err, http.StatusNotFound, w)\n\t\treturn\n\t}\n\tw.WriteHeader(http.StatusOK)\n}", "func (w *Worker) updateDeploymentImage(dep types.Deployment, artifactID int64) {\n\tartifact, err := w.ciClient.GetBuildArtifactByID(artifactID)\n\tif err != nil {\n\t\tw.log.Error(\"Failed to get build artifact\", err)\n\t\treturn\n\t}\n\tw.log.Info(\"Got artifact with url \" + artifact.Name)\n\tlockRes := strconv.FormatInt(dep.ID, 10)\n\terr = w.distLock.Lock(lockRes)\n\tif err != nil {\n\t\tw.log.Error(\"Failed to acquire deployment lock\", err)\n\t\treturn\n\t}\n\tchangedOk, stdout := w.kubectl.ChangeImage(dep.K8SName, artifact.Name)\n\terr = w.distLock.Unlock(lockRes)\n\tif err != nil {\n\t\tw.log.Error(\"Failed to release deployment lock\", err)\n\t}\n\tdep.ArtifactID = artifact.ID\n\terr = w.recordRevision(dep, stdout)\n\tif err != nil {\n\t\tw.log.Error(\"Failed to record revision\", err)\n\t}\n\tif changedOk == true {\n\t\terr = w.databaseClient.SaveDeployment(&dep)\n\t\tif err != nil {\n\t\t\tw.log.Error(\"Failed to save deployment to db\", err)\n\t\t\treturn\n\t\t}\n\t}\n}", "func (d *swiftDriver) WriteManifest(account keppel.Account, repoName string, manifestDigest digest.Digest, contents []byte) error {\n\tc, _, err := d.getBackendConnection(account)\n\tif err != nil {\n\t\treturn err\n\t}\n\to := manifestObject(c, repoName, manifestDigest)\n\treturn uploadToObject(o, bytes.NewReader(contents), nil, nil)\n}", "func cleanupManifest(origData, finalData []byte) ([]byte, error) {\n\tobjectMetacreationTs := []byte(\"\\n creationTimestamp: null\\n\")\n\tspecTemplatecreationTs := []byte(\"\\n creationTimestamp: null\\n\")\n\tjobSpecTemplatecreationTs := []byte(\"\\n creationTimestamp: null\\n\")\n\tnullStatus := []byte(\"\\nstatus: {}\\n\")\n\tnullReplicaStatus := []byte(\"status:\\n replicas: 0\\n\")\n\tnullLBStatus := []byte(\"status:\\n loadBalancer: {}\\n\")\n\tnullMetaStatus := []byte(\"\\n status: {}\\n\")\n\n\tvar hasObjectMetacreationTs, hasSpecTemplatecreationTs, hasJobSpecTemplatecreationTs, hasNullStatus,\n\t\thasNullReplicaStatus, hasNullLBStatus, hasNullMetaStatus bool\n\n\tif origData != nil {\n\t\thasObjectMetacreationTs = bytes.Contains(origData, objectMetacreationTs)\n\t\thasSpecTemplatecreationTs = bytes.Contains(origData, specTemplatecreationTs)\n\t\thasJobSpecTemplatecreationTs = bytes.Contains(origData, jobSpecTemplatecreationTs)\n\n\t\thasNullStatus = bytes.Contains(origData, nullStatus)\n\t\thasNullReplicaStatus = bytes.Contains(origData, nullReplicaStatus)\n\t\thasNullLBStatus = bytes.Contains(origData, nullLBStatus)\n\t\thasNullMetaStatus = bytes.Contains(origData, nullMetaStatus)\n\t} // null value is false in case of origFile\n\n\tif !hasObjectMetacreationTs {\n\t\tfinalData = bytes.Replace(finalData, objectMetacreationTs, []byte(\"\\n\"), -1)\n\t}\n\tif !hasSpecTemplatecreationTs {\n\t\tfinalData = bytes.Replace(finalData, specTemplatecreationTs, []byte(\"\\n\"), -1)\n\t}\n\tif !hasJobSpecTemplatecreationTs {\n\t\tfinalData = bytes.Replace(finalData, jobSpecTemplatecreationTs, []byte(\"\\n\"), -1)\n\t}\n\tif !hasNullStatus {\n\t\tfinalData = bytes.Replace(finalData, nullStatus, []byte(\"\\n\"), -1)\n\t}\n\tif !hasNullReplicaStatus {\n\t\tfinalData = bytes.Replace(finalData, nullReplicaStatus, []byte(\"\\n\"), -1)\n\t}\n\tif !hasNullLBStatus {\n\t\tfinalData = bytes.Replace(finalData, nullLBStatus, []byte(\"\\n\"), -1)\n\t}\n\tif !hasNullMetaStatus {\n\t\tfinalData = bytes.Replace(finalData, nullMetaStatus, []byte(\"\\n\"), -1)\n\t}\n\n\treturn finalData, nil\n}", "func (p *postProcessor) Manifest() (map[string]ManifestEntry, error) {\n\tlog.Println(\"updating gapic manifest\")\n\tentries := map[string]ManifestEntry{} // Key is the package name.\n\tf, err := os.Create(filepath.Join(p.googleCloudDir, \"internal\", \".repo-metadata-full.json\"))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer f.Close()\n\tfor _, manual := range p.config.ManualClientInfo {\n\t\tentries[manual.DistributionName] = *manual\n\t}\n\tfor inputDir, conf := range p.config.GoogleapisToImportPath {\n\t\tif conf.ServiceConfig == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tyamlPath := filepath.Join(p.googleapisDir, inputDir, conf.ServiceConfig)\n\t\tyamlFile, err := os.Open(yamlPath)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tyamlConfig := struct {\n\t\t\tTitle string `yaml:\"title\"` // We only need the title and name.\n\t\t\tNameFull string `yaml:\"name\"` // We only need the title and name.\n\t\t}{}\n\t\tif err := yaml.NewDecoder(yamlFile).Decode(&yamlConfig); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"decode: %v\", err)\n\t\t}\n\t\tdocURL, err := docURL(p.googleCloudDir, conf.ImportPath, conf.RelPath)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to build docs URL: %v\", err)\n\t\t}\n\t\treleaseLevel, err := releaseLevel(p.googleCloudDir, conf.ImportPath, conf.RelPath)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to calculate release level for %v: %v\", inputDir, err)\n\t\t}\n\n\t\tapiShortname, err := apiShortname(yamlConfig.NameFull)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to determine api_shortname from %v: %v\", yamlConfig.NameFull, err)\n\t\t}\n\n\t\tentry := ManifestEntry{\n\t\t\tAPIShortname: apiShortname,\n\t\t\tDistributionName: conf.ImportPath,\n\t\t\tDescription: yamlConfig.Title,\n\t\t\tLanguage: \"go\",\n\t\t\tClientLibraryType: \"generated\",\n\t\t\tClientDocumentation: docURL,\n\t\t\tReleaseLevel: releaseLevel,\n\t\t\tLibraryType: gapicAutoLibraryType,\n\t\t}\n\t\tentries[conf.ImportPath] = entry\n\t}\n\t// Remove base module entry\n\tdelete(entries, \"\")\n\tenc := json.NewEncoder(f)\n\tenc.SetIndent(\"\", \" \")\n\treturn entries, enc.Encode(entries)\n}", "func revertToManifest(kv *DB, mf *Manifest, idMap map[uint64]struct{}) error {\n\t// 1. Check all files in manifest exist.\n\tfor id := range mf.Tables {\n\t\tif _, ok := idMap[id]; !ok {\n\t\t\treturn fmt.Errorf(\"file does not exist for table %d\", id)\n\t\t}\n\t}\n\n\t// 2. Delete files that shouldn't exist.\n\tfor id := range idMap {\n\t\tif _, ok := mf.Tables[id]; !ok {\n\t\t\tkv.elog.Printf(\"Table file %d not referenced in MANIFEST\\n\", id)\n\t\t\tfilename := table.NewFilename(id, kv.opt.Dir)\n\t\t\tif err := os.Remove(filename); err != nil {\n\t\t\t\treturn y.Wrapf(err, \"While removing table %d\", id)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func RegisterManifestHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {\n\treturn RegisterManifestHandlerClient(ctx, mux, NewManifestClient(conn))\n}", "func (i *Images) Validate(registry, version, buildPath string) error {\n\tlogrus.Infof(\"Validating image manifests in %s\", registry)\n\tversion = i.normalizeVersion(version)\n\n\tmanifestImages, err := i.GetManifestImages(\n\t\tregistry, version, buildPath,\n\t\tfunc(_, _, image string) error {\n\t\t\tlogrus.Infof(\"Verifying that image is signed: %s\", image)\n\t\t\tif err := i.VerifyImage(i.signer, image); err != nil {\n\t\t\t\treturn fmt.Errorf(\"verify signed image: %w\", err)\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get manifest images: %w\", err)\n\t}\n\tlogrus.Infof(\"Got manifest images %+v\", manifestImages)\n\n\tfor image, arches := range manifestImages {\n\t\timageVersion := fmt.Sprintf(\"%s:%s\", image, version)\n\n\t\tmanifestBytes, err := crane.Manifest(imageVersion)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"get remote manifest from %s: %w\", imageVersion, err)\n\t\t}\n\n\t\tlogrus.Info(\"Verifying that image manifest list is signed\")\n\t\tif err := i.VerifyImage(i.signer, imageVersion); err != nil {\n\t\t\treturn fmt.Errorf(\"verify signed manifest list: %w\", err)\n\t\t}\n\n\t\tmanifest := string(manifestBytes)\n\t\tmanifestFile, err := os.CreateTemp(\"\", \"manifest-\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"create temp file for manifest: %w\", err)\n\t\t}\n\t\tif _, err := manifestFile.WriteString(manifest); err != nil {\n\t\t\treturn fmt.Errorf(\"write manifest to %s: %w\", manifestFile.Name(), err)\n\t\t}\n\n\t\tfor _, arch := range arches {\n\t\t\tlogrus.Infof(\n\t\t\t\t\"Checking image digest for %s on %s architecture\", image, arch,\n\t\t\t)\n\n\t\t\tdigest, err := i.ExecuteOutput(\n\t\t\t\t\"jq\", \"--arg\", \"a\", arch, \"-r\",\n\t\t\t\t\".manifests[] | select(.platform.architecture == $a) | .digest\",\n\t\t\t\tmanifestFile.Name(),\n\t\t\t)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"get digest from manifest file %s for arch %s: %w\", manifestFile.Name(), arch, err)\n\t\t\t}\n\n\t\t\tif digest == \"\" {\n\t\t\t\treturn fmt.Errorf(\n\t\t\t\t\t\"could not find the image digest for %s on %s\",\n\t\t\t\t\timageVersion, arch,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tlogrus.Infof(\"Digest for %s on %s: %s\", imageVersion, arch, digest)\n\t\t}\n\n\t\tif err := os.RemoveAll(manifestFile.Name()); err != nil {\n\t\t\treturn fmt.Errorf(\"remove manifest file: %w\", err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (r *Runtime) imagesIDsForManifest(manifestBytes []byte, sys *types.SystemContext) ([]string, error) {\n\tvar imageDigest digest.Digest\n\tmanifestType := manifest.GuessMIMEType(manifestBytes)\n\tif manifest.MIMETypeIsMultiImage(manifestType) {\n\t\tlist, err := manifest.ListFromBlob(manifestBytes, manifestType)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"parsing manifest list: %w\", err)\n\t\t}\n\t\td, err := list.ChooseInstance(sys)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"choosing instance from manifest list: %w\", err)\n\t\t}\n\t\timageDigest = d\n\t} else {\n\t\td, err := manifest.Digest(manifestBytes)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"digesting manifest\")\n\t\t}\n\t\timageDigest = d\n\t}\n\timages, err := r.store.ImagesByDigest(imageDigest)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"listing images by manifest digest: %w\", err)\n\t}\n\n\t// If you have additionStores defined and the same image stored in\n\t// both storage and additional store, it can be output twice.\n\t// Fixes github.com/containers/podman/issues/18647\n\tresults := []string{}\n\timageMap := map[string]bool{}\n\tfor _, image := range images {\n\t\tif imageMap[image.ID] {\n\t\t\tcontinue\n\t\t}\n\t\timageMap[image.ID] = true\n\t\tresults = append(results, image.ID)\n\t}\n\tif len(results) == 0 {\n\t\treturn nil, fmt.Errorf(\"identifying new image by manifest digest: %w\", storage.ErrImageUnknown)\n\t}\n\treturn results, nil\n}", "func WriteManifest(manifestWriter io.Writer, compression *pwr.CompressionSettings, container *tlc.Container, blockHashes *BlockHashMap) error {\n\trawWire := wire.NewWriteContext(manifestWriter)\n\terr := rawWire.WriteMagic(pwr.ManifestMagic)\n\tif err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\n\terr = rawWire.WriteMessage(&pwr.ManifestHeader{\n\t\tCompression: compression,\n\t\tAlgorithm: pwr.HashAlgorithm_SHAKE128_32,\n\t})\n\tif err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\n\twire, err := pwr.CompressWire(rawWire, compression)\n\tif err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\n\terr = wire.WriteMessage(container)\n\tif err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\n\tsh := &pwr.SyncHeader{}\n\tmbh := &pwr.ManifestBlockHash{}\n\n\tfor fileIndex, f := range container.Files {\n\t\tsh.Reset()\n\t\tsh.FileIndex = int64(fileIndex)\n\t\terr = wire.WriteMessage(sh)\n\t\tif err != nil {\n\t\t\treturn errors.WithStack(err)\n\t\t}\n\n\t\tnumBlocks := ComputeNumBlocks(f.Size)\n\n\t\tfor blockIndex := int64(0); blockIndex < numBlocks; blockIndex++ {\n\t\t\tloc := BlockLocation{FileIndex: int64(fileIndex), BlockIndex: blockIndex}\n\t\t\thash := blockHashes.Get(loc)\n\t\t\tif hash == nil {\n\t\t\t\terr = fmt.Errorf(\"missing BlockHash for block %+v\", loc)\n\t\t\t\treturn errors.WithStack(err)\n\t\t\t}\n\n\t\t\tmbh.Reset()\n\t\t\tmbh.Hash = hash\n\n\t\t\terr = wire.WriteMessage(mbh)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.WithStack(err)\n\t\t\t}\n\t\t}\n\t}\n\n\terr = wire.Close()\n\tif err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\n\treturn nil\n}", "func getManifest(fimg *sif.FileImage) pluginapi.Manifest {\n\treturn pluginapi.Manifest{}\n}", "func buildManifestResourceMeta(\n\tindex int,\n\tmanifest workapiv1.Manifest,\n\trestMapper meta.RESTMapper) (resourceMeta workapiv1.ManifestResourceMeta, gvr schema.GroupVersionResource, err error) {\n\terrs := []error{}\n\n\tvar object runtime.Object\n\n\t// try to get resource meta from manifest if the one got from apply result is incompleted\n\tswitch {\n\tcase manifest.Object != nil:\n\t\tobject = manifest.Object\n\tdefault:\n\t\tunstructuredObj := &unstructured.Unstructured{}\n\t\tif err = unstructuredObj.UnmarshalJSON(manifest.Raw); err != nil {\n\t\t\terrs = append(errs, err)\n\t\t\treturn resourceMeta, gvr, utilerrors.NewAggregate(errs)\n\t\t}\n\t\tobject = unstructuredObj\n\t}\n\tresourceMeta, gvr, err = buildResourceMeta(index, object, restMapper)\n\tif err == nil {\n\t\treturn resourceMeta, gvr, nil\n\t}\n\n\treturn resourceMeta, gvr, utilerrors.NewAggregate(errs)\n}", "func (mm manifestManager) Update(lastLock addr, newContents manifestContents, stats *Stats, writeHook func()) manifestContents {\n\tif upstream, _, hit := mm.cache.Get(mm.Name()); hit {\n\t\tif lastLock != upstream.lock {\n\t\t\treturn upstream\n\t\t}\n\t}\n\tt := time.Now()\n\n\tmm.lockOutFetch()\n\tdefer mm.allowFetch()\n\n\tcontents := mm.m.Update(lastLock, newContents, stats, writeHook)\n\tmm.cache.Put(mm.Name(), contents, t)\n\treturn contents\n}", "func (s *storageImageSource) GetManifest(ctx context.Context, instanceDigest *digest.Digest) (manifestBlob []byte, MIMEType string, err error) {\n\tif instanceDigest != nil {\n\t\treturn nil, \"\", ErrNoManifestLists\n\t}\n\tif len(s.cachedManifest) == 0 {\n\t\t// We stored the manifest as an item named after storage.ImageDigestBigDataKey.\n\t\tcachedBlob, err := s.imageRef.transport.store.ImageBigData(s.image.ID, storage.ImageDigestBigDataKey)\n\t\tif err != nil {\n\t\t\treturn nil, \"\", err\n\t\t}\n\t\ts.cachedManifest = cachedBlob\n\t}\n\treturn s.cachedManifest, manifest.GuessMIMEType(s.cachedManifest), err\n}", "func (p *Processor) DeleteManifest(account keppel.Account, repo keppel.Repository, manifestDigest digest.Digest, actx keppel.AuditContext) error {\n\tvar (\n\t\ttagResults []keppel.Tag\n\t\ttags []string\n\t)\n\n\t_, err := p.db.Select(&tagResults,\n\t\t`SELECT * FROM tags WHERE repo_id = $1 AND digest = $2`,\n\t\trepo.ID, manifestDigest)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, tagResult := range tagResults {\n\t\ttags = append(tags, tagResult.Name)\n\t}\n\n\tresult, err := p.db.Exec(\n\t\t//this also deletes tags referencing this manifest because of \"ON DELETE CASCADE\"\n\t\t`DELETE FROM manifests WHERE repo_id = $1 AND digest = $2`,\n\t\trepo.ID, manifestDigest)\n\tif err != nil {\n\t\totherDigest, err2 := p.db.SelectStr(\n\t\t\t`SELECT parent_digest FROM manifest_manifest_refs WHERE repo_id = $1 AND child_digest = $2`,\n\t\t\trepo.ID, manifestDigest)\n\t\t// more than one manifest is referenced by another manifest\n\t\tif otherDigest != \"\" && err2 == nil {\n\t\t\treturn fmt.Errorf(\"cannot delete a manifest which is referenced by the manifest %s\", otherDigest)\n\t\t}\n\t\t// if the SELECT failed return the previous error to not shadow it\n\t\treturn err\n\t}\n\trowsDeleted, err := result.RowsAffected()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif rowsDeleted == 0 {\n\t\treturn sql.ErrNoRows\n\t}\n\n\t//We delete in the storage *after* the deletion is durable in the DB to be\n\t//extra sure that we did not break any constraints (esp. manifest-manifest\n\t//refs and manifest-blob refs) that the DB enforces. Doing things in this\n\t//order might mean that, if DeleteManifest fails, we're left with a manifest\n\t//in the backing storage that is not referenced in the DB anymore, but this\n\t//is not a huge problem since the janitor can clean those up after the fact.\n\t//What's most important is that we don't lose any data in the backing storage\n\t//while it is still referenced in the DB.\n\t//\n\t//Also, the DELETE statement could fail if some concurrent process created a\n\t//manifest reference in the meantime. If that happens, and we have already\n\t//deleted the manifest in the backing storage, we've caused an inconsistency\n\t//that we cannot recover from.\n\terr = p.sd.DeleteManifest(account, repo.Name, manifestDigest)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif userInfo := actx.UserIdentity.UserInfo(); userInfo != nil {\n\t\tp.auditor.Record(audittools.EventParameters{\n\t\t\tTime: p.timeNow(),\n\t\t\tRequest: actx.Request,\n\t\t\tUser: userInfo,\n\t\t\tReasonCode: http.StatusOK,\n\t\t\tAction: cadf.DeleteAction,\n\t\t\tTarget: auditManifest{\n\t\t\t\tAccount: account,\n\t\t\t\tRepository: repo,\n\t\t\t\tDigest: manifestDigest,\n\t\t\t\tTags: tags,\n\t\t\t},\n\t\t})\n\t}\n\n\treturn nil\n}", "func GrowManifest(\n\tctx context.Context,\n\to *GrowManifestOptions,\n) error {\n\tvar err error\n\tvar riiCombined RegInvImage\n\n\t// (1) Scan the BaseDir and find the promoter manifest to modify.\n\tmanifest, err := FindManifest(o)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// (2) Scan the StagingRepo, and whittle the read results down with some\n\t// filters (Filter* fields in GrowManifestOptions).\n\triiUnfiltered, err := ReadStagingRepo(o)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// (3) Apply some filters.\n\triiFiltered, err := ApplyFilters(o, riiUnfiltered)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// (4) Inject (2)'s output into (1)'s manifest's images to create a larger\n\t// RegInvImage.\n\triiCombined = Union(manifest.ToRegInvImage(), riiFiltered)\n\n\t// (5) Write back RegInvImage as Manifest ([]Image field}) back onto disk.\n\terr = WriteImages(manifest, riiCombined)\n\n\treturn err\n}", "func increment(c *cli.Context) error {\n\tallFiles, err := findManifests(getGivenPathOrWorkingDir(c), handlers)\n\n\t// validations\n\tif err != nil {\n\t\treturn cli.NewExitError(err, 1)\n\t}\n\n\tif len(allFiles) == 0 {\n\t\treturn cli.NewExitError(\"No application has been found\", 2)\n\t}\n\n\tfor _, file := range allFiles {\n\t\tif file.HasError {\n\t\t\treturn cli.NewExitError(fmt.Sprintf(\"Invalid file content: %v\", file.Path), 3)\n\t\t}\n\t}\n\n\t// execute version update\n\tfor _, file := range allFiles {\n\n\t\tnewVersion := file.Version\n\t\tswitch incrementType := c.String(\"type\"); incrementType {\n\t\tcase \"major\":\n\t\t\tnewVersion = incrementMajor(file.Version)\n\t\tcase \"minor\":\n\t\t\tnewVersion = incrementMinor(file.Version)\n\t\tcase \"patch\":\n\t\t\tnewVersion = incrementPatch(file.Version)\n\t\tdefault:\n\t\t\treturn cli.NewExitError(fmt.Sprintf(\"Invalid type %v\", incrementType), 4)\n\t\t}\n\n\t\tsetVersion(file, newVersion)\n\t\tupdatedManifest, err := findManifests(file.Path, handlers)\n\n\t\tif err != nil {\n\t\t\treturn cli.NewExitError(err, 5)\n\t\t}\n\n\t\tfmt.Println(fmt.Sprintf(\"%v: New version: %v (%v)\", file.Version, updatedManifest[0].Version, file.Path))\n\t}\n\treturn nil\n}", "func (mh *MetadataHandler) HandlePutMetadata(w http.ResponseWriter, r *http.Request) {\n\tdefer r.Body.Close()\n\n\tvar payload metadata.ApplicationMetadata\n\tb, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusBadRequest) // 400\n\t\treturn\n\t}\n\terr = yaml.Unmarshal(b, &payload)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusBadRequest) // 400\n\t\treturn\n\t}\n\n\t// validate the payload first\n\tvalid, desc := payload.IsValid()\n\tif !valid {\n\t\tw.WriteHeader(http.StatusBadRequest) // 400\n\t\tyaml.NewEncoder(w).Encode(desc)\n\t\treturn\n\t}\n\n\tvars := mux.Vars(r)\n\tvar (\n\t\tappID string\n\t\tok bool\n\t)\n\tif appID, ok = vars[\"appID\"]; !ok {\n\t\tw.WriteHeader(http.StatusBadRequest) // 400\n\t\treturn\n\t}\n\n\tpayload.ApplicationID = appID\n\n\terr = mh.Repository.Update(appID, &payload)\n\tif err != nil {\n\t\tif err == repository.ErrIDNotFound {\n\t\t\tw.WriteHeader(http.StatusConflict) // 409\n\t\t} else {\n\t\t\tw.WriteHeader(http.StatusInternalServerError) // 500\n\t\t}\n\t\tyaml.NewEncoder(w).Encode(err.Error())\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusOK) // 200\n\tyaml.NewEncoder(w).Encode(payload)\n}", "func manifestDispatcher(ctx *Context, r *http.Request) http.Handler {\n\tmanifestHandler := &manifestHandler{\n\t\tContext: ctx,\n\t}\n\tref := getReference(ctx)\n\tdgst, err := digest.Parse(ref)\n\tif err != nil {\n\t\t// We just have a tag\n\t\tmanifestHandler.Tag = ref\n\t} else {\n\t\tmanifestHandler.Digest = dgst\n\t}\n\n\tmhandler := handlers.MethodHandler{\n\t\thttp.MethodGet: http.HandlerFunc(manifestHandler.GetManifest),\n\t\thttp.MethodHead: http.HandlerFunc(manifestHandler.GetManifest),\n\t}\n\n\tif !ctx.readOnly {\n\t\tmhandler[http.MethodPut] = http.HandlerFunc(manifestHandler.PutManifest)\n\t\tmhandler[http.MethodDelete] = http.HandlerFunc(manifestHandler.DeleteManifest)\n\t}\n\n\treturn mhandler\n}", "func (s *Store) GetImageManifest(key string) (*schema.ImageManifest, error) {\n\timj, err := s.GetImageManifestJSON(key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar im *schema.ImageManifest\n\tif err = json.Unmarshal(imj, &im); err != nil {\n\t\treturn nil, errwrap.Wrap(errors.New(\"error unmarshalling image manifest\"), err)\n\t}\n\treturn im, nil\n}", "func deployS3Manifest(c Client, log utils.Logger, pd *DeployData, params DeployAppParams, out *DeployAppResult) error {\n\tdata, err := json.Marshal(pd.Manifest)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"can't marshal manifest for app - %s\", pd.Manifest.AppID)\n\t}\n\tbuffer := bytes.NewBuffer(data)\n\n\t// Make the manifest publicly visible.\n\turl, err := c.UploadS3(params.Bucket, pd.ManifestKey, buffer, false)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"can't upload manifest file for the app - %s\", pd.Manifest.AppID)\n\t}\n\n\tout.Manifest = *pd.Manifest\n\tout.ManifestURL = url\n\tlog.Infow(\"Uploaded manifest to S3 (public-read)\", \"bucket\", params.Bucket, \"key\", pd.ManifestKey)\n\treturn nil\n}", "func AddonsBaseManifest(client clientset.Interface) error {\n\tcurrentClusterVersion, err := kubeadm.GetCurrentClusterVersion(client)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tclusterConfiguration, err := kubeadm.GetClusterConfiguration(client)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Could not fetch cluster configuration\")\n\t}\n\n\t// re-render all addons manifest\n\taddonConfiguration := addons.AddonConfiguration{\n\t\tClusterVersion: currentClusterVersion,\n\t\tControlPlane: clusterConfiguration.ControlPlaneEndpoint,\n\t\tClusterName: clusterConfiguration.ClusterName,\n\t}\n\tfor addonName, addon := range addons.Addons {\n\t\tif !addon.IsPresentForClusterVersion(currentClusterVersion) {\n\t\t\tcontinue\n\t\t}\n\t\tif err := addon.Write(addonConfiguration); err != nil {\n\t\t\treturn errors.Wrapf(err, \"failed to refresh addon %s manifest\", string(addonName))\n\t\t}\n\t}\n\n\tfmt.Println(\"Successfully refreshed addons base manifests\")\n\treturn nil\n}", "func (esc *BgMetadataElasticSearchConnector) UpdateMetricMetadata(metric *Metric) error {\n\treturn esc.addDocumentToBuff(metric)\n}", "func ParseManifest(filename string) Manifest {\n\tlog.WithFields(log.Fields{\"From\": filename}).Info(\"Loading manifest\")\n\n\tfile, err := os.Open(filename)\n\tdefer file.Close()\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\tvar data map[string]interface{}\n\n\tjsonParser := json.NewDecoder(file)\n\terr = jsonParser.Decode(&data)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\tmWants := map[string]string{}\n\tmRepositories := map[string]ManifestRepositoryInfo{}\n\n\tif wants, ok := data[\"wants\"]; ok {\n\t\twants := wants.(map[string]interface{})\n\t\tfor w, v := range wants {\n\t\t\tmWants[w] = v.(string)\n\t\t}\n\t}\n\n\tif repositories, ok := data[\"repositories\"]; ok {\n\t\trepositories := repositories.(map[string]interface{})\n\t\tfor reponame, repo := range repositories {\n\n\t\t\trepo := repo.([]interface{})\n\t\t\trepopath := repo[0].(map[string]interface{})\n\t\t\trepovals := repo[1].(map[string]interface{})\n\n\t\t\tvar r = ManifestRepositoryInfo{\n\t\t\t\tValues: repovals,\n\t\t\t}\n\n\t\t\tif _, ok := repopath[\"file\"]; ok {\n\t\t\t\tr.SrcType = \"file\"\n\t\t\t\tr.SrcValue = repopath[\"file\"].(string)\n\t\t\t}\n\n\t\t\tfor k, v := range repovals {\n\t\t\t\tr.Values[k] = v.(string)\n\t\t\t}\n\n\t\t\tmRepositories[reponame] = r\n\t\t}\n\t}\n\n\tmanifest := Manifest{\n\t\tWants: mWants,\n\t\tRepositories: mRepositories,\n\n\t\tPackages: map[string]map[string]map[string]interface{}{},\n\t\tOutPackages: map[string]map[string]interface{}{},\n\t}\n\n\tfor rn, rv := range manifest.Repositories {\n\t\tlog.WithFields(log.Fields{\"Name\": rn}).Info(\"Loading repository\")\n\t\tr := RepositoryFromInfo(rv)\n\t\tfor pn, pf := range r.PackageFiles {\n\t\t\tfor pv, p := range pf.Packages {\n\t\t\t\tif l, ok := manifest.Packages[pn]; ok {\n\t\t\t\t\tl[pv] = p\n\t\t\t\t\tmanifest.Packages[pn] = l\n\t\t\t\t} else {\n\t\t\t\t\tmanifest.Packages[pn] = map[string]map[string]interface{}{pv: p}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfor pn, pc := range manifest.Wants {\n\t\tmanifest.Filter(pn, pc)\n\t}\n\n\tfor pn := range manifest.Wants {\n\t\tmanifest.Resolve(pn, []string{})\n\t}\n\n\tfor pn := range manifest.Wants {\n\t\tmanifest.Merge(pn, []string{})\n\t}\n\n\tmanifest.Dump()\n\n\treturn manifest\n}", "func (mdm *MetaDagModifier) AddMetadata(root ipld.Node, metadata []byte) (ipld.Node, error) {\n\t// Read the existing metadata map from the first element of the metadata list.\n\tb, encodedTree, err := util.ReadMetadataListFromDag(mdm.ctx, root, mdm.dagserv, false)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ttreeSize := len(encodedTree)\n\n\t// Determine the specific scenario.\n\t// Scenario #1:\n\tvar newMetaNode ipld.Node\n\tvar children *ft.DagMetaNodes\n\tif b == nil || util.IsMetadataEmpty(b) {\n\t\t// Create a metadata sub-DAG\n\t\tnewMetaNode, err = mdm.buildNewMetaDataDag(metadata, encodedTree)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\tchildren, err = ft.GetChildrenForDagWithMeta(mdm.ctx, root, mdm.dagserv)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// Create existing map and input metadata map and check.\n\t\tm := make(map[string]interface{})\n\t\terr = json.Unmarshal(b, &m)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tinputM := make(map[string]interface{})\n\t\terr = json.Unmarshal(metadata, &inputM)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\texists := util.Intersects(m, inputM)\n\t\t// Scenario #2: Update case.\n\t\tif exists {\n\t\t\tif !mdm.Overwrite {\n\t\t\t\treturn nil, errors.New(\"Found existing key value pairs. Use --overwrite to force to update.\")\n\t\t\t}\n\t\t\t// Truncate(0) on the metadata sub-DAG.\n\t\t\terr := mdm.Truncate(0)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\t// iterate the inputM to put its (k, v) pairs to existing map.\n\t\t\tfor k, v := range inputM {\n\t\t\t\tm[k] = v\n\t\t\t}\n\t\t\tb, err = json.Marshal(m)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t// Create a metadata sub-DAG\n\t\t\tnewMetaNode, err = mdm.buildNewMetaDataDag(b, encodedTree)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t} else\n\t\t// Scenario #3: Append case.\n\t\t{\n\t\t\t// Append the given metadata items to the metadata sub-DAG.\n\t\t\tmdm.curNode = children.MetaNode\n\t\t\tfileSize, err := FileSize(mdm.curNode)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\t// Combine two JSON format byte arrays. E.g.,\n\t\t\t// `{\"price\":12.22} + `{\"number\":1234}` -> `{\"price\":12.22,\"number\":1234}`\n\t\t\tmetadata[0] = ','\n\t\t\tmetadata = append(append(metadata[:], '#'), encodedTree[:]...)\n\t\t\toffset := int(fileSize) - treeSize - 2\n\t\t\tnmod, err := mdm.WriteAt(metadata, int64(offset))\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tif nmod != int(len(metadata)) {\n\t\t\t\treturn nil, errors.New(\"Modified length not correct!\")\n\t\t\t}\n\n\t\t\tnewMetaNode, err = mdm.GetNode()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\t// Attach the modified metadata sub-DAG to a new root for the BTFS file DAG.\n\tvar dnode ipld.Node\n\tif children == nil {\n\t\tdnode = root\n\t} else {\n\t\tdnode = children.DataNode\n\t}\n\n\tfileSize, err := FileSize(dnode)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tnewRoot, err := mdm.GetDb().AttachMetadataDag(dnode, fileSize, newMetaNode)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tmdm.GetDb().Add(newRoot)\n\n\treturn newRoot, nil\n}", "func RegisterManifestHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ManifestServer) error {\n\n\tmux.Handle(\"POST\", pattern_Manifest_ManifestCreate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {\n\t\tctx, cancel := context.WithCancel(req.Context())\n\t\tdefer cancel()\n\t\tvar stream runtime.ServerTransportStream\n\t\tctx = grpc.NewContextWithServerTransportStream(ctx, &stream)\n\t\tinboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)\n\t\trctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)\n\t\tif err != nil {\n\t\t\truntime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)\n\t\t\treturn\n\t\t}\n\t\tresp, md, err := local_request_Manifest_ManifestCreate_0(rctx, inboundMarshaler, server, req, pathParams)\n\t\tmd.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())\n\t\tctx = runtime.NewServerMetadataContext(ctx, md)\n\t\tif err != nil {\n\t\t\truntime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)\n\t\t\treturn\n\t\t}\n\n\t\tforward_Manifest_ManifestCreate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)\n\n\t})\n\n\tmux.Handle(\"POST\", pattern_Manifest_ManifestConfigCreate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {\n\t\tctx, cancel := context.WithCancel(req.Context())\n\t\tdefer cancel()\n\t\tvar stream runtime.ServerTransportStream\n\t\tctx = grpc.NewContextWithServerTransportStream(ctx, &stream)\n\t\tinboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)\n\t\trctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)\n\t\tif err != nil {\n\t\t\truntime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)\n\t\t\treturn\n\t\t}\n\t\tresp, md, err := local_request_Manifest_ManifestConfigCreate_0(rctx, inboundMarshaler, server, req, pathParams)\n\t\tmd.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())\n\t\tctx = runtime.NewServerMetadataContext(ctx, md)\n\t\tif err != nil {\n\t\t\truntime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)\n\t\t\treturn\n\t\t}\n\n\t\tforward_Manifest_ManifestConfigCreate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)\n\n\t})\n\n\treturn nil\n}", "func (bm *BlobsManifest) Write() error {\n\n\tdirpath := blobsManifestDirPath(bm.BlobSum)\n\tutils.CreateDir(dirpath)\n\n\tfilePath := dirpath + \"/\" + bm.BlobSum\n\tutils.Remove(filePath)\n\n\tfd, err := os.Create(filePath)\n\tif err != nil {\n\t\tlogger.Errorf(\"create file %s error\\n\", filePath)\n\t\treturn err\n\t}\n\n\tdefer fd.Close()\n\n\tdata, _ := json.MarshalIndent(bm, \"\", \" \")\n\tfd.Write(data)\n\n\treturn nil\n}", "func ImageManifestSchema() *gojsonschema.Schema {\n\treturn loadSchema(\"image-manifest.schema.json\")\n}", "func (mc *manifestCache) Put(db string, contents manifestContents, t time.Time) error {\n\tmc.mu.Lock()\n\tdefer mc.mu.Unlock()\n\n\tif entry, ok := mc.entry(db); ok {\n\t\tmc.totalSize -= entry.contents.size()\n\t\tmc.lru.Remove(entry.lruEntry)\n\t\tdelete(mc.cache, db)\n\t}\n\n\tif contents.size() <= mc.maxSize {\n\t\tnewEl := mc.lru.PushBack(db)\n\t\tce := manifestCacheEntry{lruEntry: newEl, contents: contents, t: t}\n\t\tmc.cache[db] = ce\n\t\tmc.totalSize += ce.contents.size()\n\t\tfor el := mc.lru.Front(); el != nil && mc.totalSize > mc.maxSize; {\n\t\t\tkey1 := el.Value.(string)\n\t\t\tce, ok := mc.cache[key1]\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"manifestCache is missing expected value for %s\", key1)\n\t\t\t}\n\t\t\tnext := el.Next()\n\t\t\tdelete(mc.cache, key1)\n\t\t\tmc.totalSize -= ce.contents.size()\n\t\t\tmc.lru.Remove(el)\n\t\t\tel = next\n\t\t}\n\t}\n\n\treturn nil\n}", "func (sd *SiaDir) UpdateMetadata(metadata Metadata) error {\n\tsd.mu.Lock()\n\tdefer sd.mu.Unlock()\n\tsd.metadata.AggregateHealth = metadata.AggregateHealth\n\tsd.metadata.AggregateLastHealthCheckTime = metadata.AggregateLastHealthCheckTime\n\tsd.metadata.AggregateMinRedundancy = metadata.AggregateMinRedundancy\n\tsd.metadata.AggregateModTime = metadata.AggregateModTime\n\tsd.metadata.AggregateNumFiles = metadata.AggregateNumFiles\n\tsd.metadata.AggregateNumStuckChunks = metadata.AggregateNumStuckChunks\n\tsd.metadata.AggregateNumSubDirs = metadata.AggregateNumSubDirs\n\tsd.metadata.AggregateSize = metadata.AggregateSize\n\tsd.metadata.AggregateStuckHealth = metadata.AggregateStuckHealth\n\n\tsd.metadata.Health = metadata.Health\n\tsd.metadata.LastHealthCheckTime = metadata.LastHealthCheckTime\n\tsd.metadata.MinRedundancy = metadata.MinRedundancy\n\tsd.metadata.ModTime = metadata.ModTime\n\tsd.metadata.NumFiles = metadata.NumFiles\n\tsd.metadata.NumStuckChunks = metadata.NumStuckChunks\n\tsd.metadata.NumSubDirs = metadata.NumSubDirs\n\tsd.metadata.Size = metadata.Size\n\tsd.metadata.StuckHealth = metadata.StuckHealth\n\treturn sd.saveDir()\n}", "func (j *Janitor) SyncManifestsInNextRepo() (returnErr error) {\n\tdefer func() {\n\t\tif returnErr == nil {\n\t\t\tsyncManifestsSuccessCounter.Inc()\n\t\t} else if returnErr != sql.ErrNoRows {\n\t\t\tsyncManifestsFailedCounter.Inc()\n\t\t\treturnErr = fmt.Errorf(\"while syncing manifests in a replica repo: %s\", returnErr.Error())\n\t\t}\n\t}()\n\n\t//find repository to sync\n\tvar repo keppel.Repository\n\terr := j.db.SelectOne(&repo, syncManifestRepoSelectQuery, j.timeNow())\n\tif err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\tlogg.Debug(\"no accounts to sync manifests in - slowing down...\")\n\t\t\treturn sql.ErrNoRows\n\t\t}\n\t\treturn err\n\t}\n\n\t//find corresponding account\n\taccount, err := keppel.FindAccount(j.db, repo.AccountName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot find account for repo %s: %s\", repo.FullName(), err.Error())\n\t}\n\n\t//do not perform manifest sync while account is in maintenance (maintenance mode blocks all kinds of replication)\n\tif !account.InMaintenance {\n\t\terr = j.performManifestSync(*account, repo)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t_, err = j.db.Exec(syncManifestDoneQuery, repo.ID, j.timeNow().Add(1*time.Hour))\n\treturn err\n}", "func (is *ImageStoreLocal) GetImageManifest(repo, reference string) ([]byte, godigest.Digest, string, error) {\n\tdir := path.Join(is.rootDir, repo)\n\tif !is.DirExists(dir) {\n\t\treturn nil, \"\", \"\", zerr.ErrRepoNotFound\n\t}\n\n\tvar lockLatency time.Time\n\n\tvar err error\n\n\tis.RLock(&lockLatency)\n\tdefer func() {\n\t\tis.RUnlock(&lockLatency)\n\n\t\tif err == nil {\n\t\t\tmonitoring.IncDownloadCounter(is.metrics, repo)\n\t\t}\n\t}()\n\n\tindex, err := common.GetIndex(is, repo, is.log)\n\tif err != nil {\n\t\treturn nil, \"\", \"\", err\n\t}\n\n\tmanifestDesc, found := common.GetManifestDescByReference(index, reference)\n\tif !found {\n\t\treturn nil, \"\", \"\", zerr.ErrManifestNotFound\n\t}\n\n\tbuf, err := is.GetBlobContent(repo, manifestDesc.Digest)\n\tif err != nil {\n\t\tif errors.Is(err, zerr.ErrBlobNotFound) {\n\t\t\treturn nil, \"\", \"\", zerr.ErrManifestNotFound\n\t\t}\n\n\t\treturn nil, \"\", \"\", err\n\t}\n\n\tvar manifest ispec.Manifest\n\tif err := json.Unmarshal(buf, &manifest); err != nil {\n\t\tis.log.Error().Err(err).Str(\"dir\", dir).Msg(\"invalid JSON\")\n\n\t\treturn nil, \"\", \"\", err\n\t}\n\n\treturn buf, manifestDesc.Digest, manifestDesc.MediaType, nil\n}", "func (_m *Backend) UpdateManifest(ctx context.Context, request *models.UpdateManifestRequest) error {\n\tret := _m.Called(ctx, request)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(context.Context, *models.UpdateManifestRequest) error); ok {\n\t\tr0 = rf(ctx, request)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func (m *GGCRImage) Manifest() (*v1.Manifest, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Manifest\")\n\tret0, _ := ret[0].(*v1.Manifest)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func ReadManifest(manifestReader savior.SeekSource) (*tlc.Container, *BlockHashMap, error) {\n\tcontainer := &tlc.Container{}\n\tblockHashes := NewBlockHashMap()\n\n\trawWire := wire.NewReadContext(manifestReader)\n\terr := rawWire.ExpectMagic(pwr.ManifestMagic)\n\tif err != nil {\n\t\treturn nil, nil, errors.WithStack(err)\n\t}\n\n\tmh := &pwr.ManifestHeader{}\n\terr = rawWire.ReadMessage(mh)\n\tif err != nil {\n\t\treturn nil, nil, errors.WithStack(err)\n\t}\n\n\tif mh.Algorithm != pwr.HashAlgorithm_SHAKE128_32 {\n\t\terr = fmt.Errorf(\"Manifest has unsupported hash algorithm %d, expected %d\", mh.Algorithm, pwr.HashAlgorithm_SHAKE128_32)\n\t\treturn nil, nil, errors.WithStack(err)\n\t}\n\n\twire, err := pwr.DecompressWire(rawWire, mh.GetCompression())\n\tif err != nil {\n\t\treturn nil, nil, errors.WithStack(err)\n\t}\n\n\terr = wire.ReadMessage(container)\n\tif err != nil {\n\t\treturn nil, nil, errors.WithStack(err)\n\t}\n\n\tsh := &pwr.SyncHeader{}\n\tmbh := &pwr.ManifestBlockHash{}\n\n\tfor fileIndex, f := range container.Files {\n\t\tsh.Reset()\n\t\terr = wire.ReadMessage(sh)\n\t\tif err != nil {\n\t\t\treturn nil, nil, errors.WithStack(err)\n\t\t}\n\n\t\tif int64(fileIndex) != sh.FileIndex {\n\t\t\terr = fmt.Errorf(\"manifest format error: expected file %d, got %d\", fileIndex, sh.FileIndex)\n\t\t\treturn nil, nil, errors.WithStack(err)\n\t\t}\n\n\t\tnumBlocks := ComputeNumBlocks(f.Size)\n\t\tfor blockIndex := int64(0); blockIndex < numBlocks; blockIndex++ {\n\t\t\tmbh.Reset()\n\t\t\terr = wire.ReadMessage(mbh)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, errors.WithStack(err)\n\t\t\t}\n\n\t\t\tloc := BlockLocation{FileIndex: int64(fileIndex), BlockIndex: blockIndex}\n\t\t\tblockHashes.Set(loc, append([]byte{}, mbh.Hash...))\n\t\t}\n\t}\n\n\treturn container, blockHashes, nil\n}", "func PushContent(ctx context.Context, pusher Pusher, desc ocispec.Descriptor, store content.Store, limiter *semaphore.Weighted, platform platforms.MatchComparer, wrapper func(h images.Handler) images.Handler) error {\n\n\tvar m sync.Mutex\n\tmanifestStack := []ocispec.Descriptor{}\n\n\tfilterHandler := images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {\n\t\tswitch desc.MediaType {\n\t\tcase images.MediaTypeDockerSchema2Manifest, ocispec.MediaTypeImageManifest,\n\t\t\timages.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex:\n\t\t\tm.Lock()\n\t\t\tmanifestStack = append(manifestStack, desc)\n\t\t\tm.Unlock()\n\t\t\treturn nil, images.ErrStopHandler\n\t\tdefault:\n\t\t\treturn nil, nil\n\t\t}\n\t})\n\n\tpushHandler := PushHandler(pusher, store)\n\n\tplatformFilterhandler := images.FilterPlatforms(images.ChildrenHandler(store), platform)\n\n\tannotateHandler := annotateDistributionSourceHandler(platformFilterhandler, store)\n\n\tvar handler images.Handler = images.Handlers(\n\t\tannotateHandler,\n\t\tfilterHandler,\n\t\tpushHandler,\n\t)\n\tif wrapper != nil {\n\t\thandler = wrapper(handler)\n\t}\n\n\tif err := images.Dispatch(ctx, handler, limiter, desc); err != nil {\n\t\treturn err\n\t}\n\n\t// Iterate in reverse order as seen, parent always uploaded after child\n\tfor i := len(manifestStack) - 1; i >= 0; i-- {\n\t\t_, err := pushHandler(ctx, manifestStack[i])\n\t\tif err != nil {\n\t\t\t// TODO(estesp): until we have a more complete method for index push, we need to report\n\t\t\t// missing dependencies in an index/manifest list by sensing the \"400 Bad Request\"\n\t\t\t// as a marker for this problem\n\t\t\tif (manifestStack[i].MediaType == ocispec.MediaTypeImageIndex ||\n\t\t\t\tmanifestStack[i].MediaType == images.MediaTypeDockerSchema2ManifestList) &&\n\t\t\t\terrors.Unwrap(err) != nil && strings.Contains(errors.Unwrap(err).Error(), \"400 Bad Request\") {\n\t\t\t\treturn fmt.Errorf(\"manifest list/index references to blobs and/or manifests are missing in your target registry: %w\", err)\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (s *Store) GetImageManifestJSON(key string) ([]byte, error) {\n\tkey, err := s.ResolveKey(key)\n\tif err != nil {\n\t\treturn nil, errwrap.Wrap(errors.New(\"error resolving image ID\"), err)\n\t}\n\tkeyLock, err := lock.SharedKeyLock(s.imageLockDir, key)\n\tif err != nil {\n\t\treturn nil, errwrap.Wrap(errors.New(\"error locking image\"), err)\n\t}\n\tdefer keyLock.Close()\n\n\timj, err := s.stores[imageManifestType].Read(key)\n\tif err != nil {\n\t\treturn nil, errwrap.Wrap(errors.New(\"error retrieving image manifest\"), err)\n\t}\n\treturn imj, nil\n}" ]
[ "0.7010766", "0.66876704", "0.6556861", "0.5991127", "0.59570235", "0.5899974", "0.5800305", "0.5798259", "0.5712472", "0.5641731", "0.5567172", "0.55645925", "0.5563863", "0.5545608", "0.55113065", "0.54682016", "0.54171425", "0.5391867", "0.53072697", "0.5294346", "0.52491206", "0.52232593", "0.5156525", "0.51499933", "0.5138121", "0.5096326", "0.50845486", "0.5083501", "0.50699955", "0.5051783", "0.5048233", "0.5014765", "0.501162", "0.49990457", "0.49907577", "0.4988504", "0.49797848", "0.49776164", "0.49662793", "0.49609208", "0.4952872", "0.49408513", "0.49341825", "0.49028334", "0.490021", "0.48941484", "0.4892671", "0.4892144", "0.48871708", "0.4878904", "0.4874638", "0.48498702", "0.48375973", "0.48359916", "0.48343647", "0.48145634", "0.47916007", "0.47896552", "0.47771862", "0.47771418", "0.47724852", "0.47645622", "0.47556284", "0.4754419", "0.47526306", "0.4747289", "0.47411466", "0.47353104", "0.47138062", "0.4700822", "0.46996227", "0.4699013", "0.46972016", "0.4690487", "0.468993", "0.46839532", "0.46795058", "0.46728757", "0.46684164", "0.46654987", "0.4664932", "0.46573317", "0.46424815", "0.46371606", "0.46355888", "0.46300554", "0.46164542", "0.4615714", "0.46127918", "0.46120253", "0.46065447", "0.46009424", "0.45915487", "0.45907688", "0.45863208", "0.4582113", "0.457934", "0.4574636", "0.45704705", "0.45603585" ]
0.8265896
0
OnDeleteManifest is called when a manifest is deleted. It updates metadb according to the type of image pushed(normal images, signatues, etc.). In care of any errors, it makes sure to keep consistency between metadb and the image store.
OnDeleteManifest вызывается при удалении манифеста. Он обновляет metadb в соответствии с типом загруженного изображения (нормальные изображения, подписи и т.д.). В случае любых ошибок он обеспечивает согласованность между metadb и хранилищем изображений.
func OnDeleteManifest(repo, reference, mediaType string, digest godigest.Digest, manifestBlob []byte, storeController storage.StoreController, metaDB mTypes.MetaDB, log log.Logger, ) error { imgStore := storeController.GetImageStore(repo) isSignature, signatureType, signedManifestDigest, err := storage.CheckIsImageSignature(repo, manifestBlob, reference) if err != nil { log.Error().Err(err).Msg("can't check if image is a signature or not") return err } manageRepoMetaSuccessfully := true if isSignature { err = metaDB.DeleteSignature(repo, signedManifestDigest, mTypes.SignatureMetadata{ SignatureDigest: digest.String(), SignatureType: signatureType, }) if err != nil { log.Error().Err(err).Msg("metadb: can't check if image is a signature or not") manageRepoMetaSuccessfully = false } } else { err = metaDB.DeleteRepoTag(repo, reference) if err != nil { log.Info().Msg("metadb: restoring image store") // restore image store _, _, err := imgStore.PutImageManifest(repo, reference, mediaType, manifestBlob) if err != nil { log.Error().Err(err).Msg("metadb: error while restoring image store, database is not consistent") } manageRepoMetaSuccessfully = false } if referredDigest, hasSubject := common.GetReferredSubject(manifestBlob); hasSubject { err := metaDB.DeleteReferrer(repo, referredDigest, digest) if err != nil { log.Error().Err(err).Msg("metadb: error while deleting referrer") return err } } } if !manageRepoMetaSuccessfully { log.Info().Str("tag", reference).Str("repository", repo). Msg("metadb: deleting image meta was unsuccessful for tag in repo") return err } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (imh *manifestHandler) DeleteManifest(w http.ResponseWriter, r *http.Request) {\n\tdcontext.GetLogger(imh).Debug(\"DeleteImageManifest\")\n\n\tif imh.App.isCache {\n\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnsupported)\n\t\treturn\n\t}\n\n\tif imh.Tag != \"\" {\n\t\tdcontext.GetLogger(imh).Debug(\"DeleteImageTag\")\n\t\ttagService := imh.Repository.Tags(imh.Context)\n\t\tif err := tagService.Untag(imh.Context, imh.Tag); err != nil {\n\t\t\tswitch err.(type) {\n\t\t\tcase distribution.ErrTagUnknown, driver.PathNotFoundError:\n\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown.WithDetail(err))\n\t\t\tdefault:\n\t\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tw.WriteHeader(http.StatusAccepted)\n\t\treturn\n\t}\n\n\tmanifests, err := imh.Repository.Manifests(imh)\n\tif err != nil {\n\t\timh.Errors = append(imh.Errors, err)\n\t\treturn\n\t}\n\n\terr = manifests.Delete(imh, imh.Digest)\n\tif err != nil {\n\t\tswitch err {\n\t\tcase digest.ErrDigestUnsupported:\n\t\tcase digest.ErrDigestInvalidFormat:\n\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeDigestInvalid)\n\t\t\treturn\n\t\tcase distribution.ErrBlobUnknown:\n\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown)\n\t\t\treturn\n\t\tcase distribution.ErrUnsupported:\n\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnsupported)\n\t\t\treturn\n\t\tdefault:\n\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown)\n\t\t\treturn\n\t\t}\n\t}\n\n\ttagService := imh.Repository.Tags(imh)\n\treferencedTags, err := tagService.Lookup(imh, distribution.Descriptor{Digest: imh.Digest})\n\tif err != nil {\n\t\timh.Errors = append(imh.Errors, err)\n\t\treturn\n\t}\n\n\tfor _, tag := range referencedTags {\n\t\tif err := tagService.Untag(imh, tag); err != nil {\n\t\t\timh.Errors = append(imh.Errors, err)\n\t\t\treturn\n\t\t}\n\t}\n\n\tw.WriteHeader(http.StatusAccepted)\n}", "func (p *Processor) DeleteManifest(account keppel.Account, repo keppel.Repository, manifestDigest digest.Digest, actx keppel.AuditContext) error {\n\tvar (\n\t\ttagResults []keppel.Tag\n\t\ttags []string\n\t)\n\n\t_, err := p.db.Select(&tagResults,\n\t\t`SELECT * FROM tags WHERE repo_id = $1 AND digest = $2`,\n\t\trepo.ID, manifestDigest)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, tagResult := range tagResults {\n\t\ttags = append(tags, tagResult.Name)\n\t}\n\n\tresult, err := p.db.Exec(\n\t\t//this also deletes tags referencing this manifest because of \"ON DELETE CASCADE\"\n\t\t`DELETE FROM manifests WHERE repo_id = $1 AND digest = $2`,\n\t\trepo.ID, manifestDigest)\n\tif err != nil {\n\t\totherDigest, err2 := p.db.SelectStr(\n\t\t\t`SELECT parent_digest FROM manifest_manifest_refs WHERE repo_id = $1 AND child_digest = $2`,\n\t\t\trepo.ID, manifestDigest)\n\t\t// more than one manifest is referenced by another manifest\n\t\tif otherDigest != \"\" && err2 == nil {\n\t\t\treturn fmt.Errorf(\"cannot delete a manifest which is referenced by the manifest %s\", otherDigest)\n\t\t}\n\t\t// if the SELECT failed return the previous error to not shadow it\n\t\treturn err\n\t}\n\trowsDeleted, err := result.RowsAffected()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif rowsDeleted == 0 {\n\t\treturn sql.ErrNoRows\n\t}\n\n\t//We delete in the storage *after* the deletion is durable in the DB to be\n\t//extra sure that we did not break any constraints (esp. manifest-manifest\n\t//refs and manifest-blob refs) that the DB enforces. Doing things in this\n\t//order might mean that, if DeleteManifest fails, we're left with a manifest\n\t//in the backing storage that is not referenced in the DB anymore, but this\n\t//is not a huge problem since the janitor can clean those up after the fact.\n\t//What's most important is that we don't lose any data in the backing storage\n\t//while it is still referenced in the DB.\n\t//\n\t//Also, the DELETE statement could fail if some concurrent process created a\n\t//manifest reference in the meantime. If that happens, and we have already\n\t//deleted the manifest in the backing storage, we've caused an inconsistency\n\t//that we cannot recover from.\n\terr = p.sd.DeleteManifest(account, repo.Name, manifestDigest)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif userInfo := actx.UserIdentity.UserInfo(); userInfo != nil {\n\t\tp.auditor.Record(audittools.EventParameters{\n\t\t\tTime: p.timeNow(),\n\t\t\tRequest: actx.Request,\n\t\t\tUser: userInfo,\n\t\t\tReasonCode: http.StatusOK,\n\t\t\tAction: cadf.DeleteAction,\n\t\t\tTarget: auditManifest{\n\t\t\t\tAccount: account,\n\t\t\t\tRepository: repo,\n\t\t\t\tDigest: manifestDigest,\n\t\t\t\tTags: tags,\n\t\t\t},\n\t\t})\n\t}\n\n\treturn nil\n}", "func OnUpdateManifest(repo, reference, mediaType string, digest godigest.Digest, body []byte,\n\tstoreController storage.StoreController, metaDB mTypes.MetaDB, log log.Logger,\n) error {\n\timgStore := storeController.GetImageStore(repo)\n\n\t// check if image is a signature\n\tisSignature, signatureType, signedManifestDigest, err := storage.CheckIsImageSignature(repo, body, reference)\n\tif err != nil {\n\t\tlog.Error().Err(err).Msg(\"can't check if image is a signature or not\")\n\n\t\tif err := imgStore.DeleteImageManifest(repo, reference, false); err != nil {\n\t\t\tlog.Error().Err(err).Str(\"manifest\", reference).Str(\"repository\", repo).Msg(\"couldn't remove image manifest in repo\")\n\n\t\t\treturn err\n\t\t}\n\n\t\treturn err\n\t}\n\n\tmetadataSuccessfullySet := true\n\n\tif isSignature {\n\t\tlayersInfo, errGetLayers := GetSignatureLayersInfo(repo, reference, digest.String(), signatureType, body,\n\t\t\timgStore, log)\n\t\tif errGetLayers != nil {\n\t\t\tmetadataSuccessfullySet = false\n\t\t\terr = errGetLayers\n\t\t} else {\n\t\t\terr = metaDB.AddManifestSignature(repo, signedManifestDigest, mTypes.SignatureMetadata{\n\t\t\t\tSignatureType: signatureType,\n\t\t\t\tSignatureDigest: digest.String(),\n\t\t\t\tLayersInfo: layersInfo,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\tlog.Error().Err(err).Msg(\"metadb: error while putting repo meta\")\n\t\t\t\tmetadataSuccessfullySet = false\n\t\t\t} else {\n\t\t\t\terr = metaDB.UpdateSignaturesValidity(repo, signedManifestDigest)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Error().Err(err).Str(\"repository\", repo).Str(\"reference\", reference).Str(\"digest\",\n\t\t\t\t\t\tsignedManifestDigest.String()).Msg(\"metadb: failed verify signatures validity for signed image\")\n\t\t\t\t\tmetadataSuccessfullySet = false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\terr = SetImageMetaFromInput(repo, reference, mediaType, digest, body,\n\t\t\timgStore, metaDB, log)\n\t\tif err != nil {\n\t\t\tmetadataSuccessfullySet = false\n\t\t}\n\t}\n\n\tif !metadataSuccessfullySet {\n\t\tlog.Info().Str(\"tag\", reference).Str(\"repository\", repo).Msg(\"uploading image meta was unsuccessful for tag in repo\")\n\n\t\tif err := imgStore.DeleteImageManifest(repo, reference, false); err != nil {\n\t\t\tlog.Error().Err(err).Str(\"reference\", reference).Str(\"repository\", repo).\n\t\t\t\tMsg(\"couldn't remove image manifest in repo\")\n\n\t\t\treturn err\n\t\t}\n\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (is *ImageStoreLocal) DeleteImageManifest(repo, reference string, detectCollision bool) error {\n\tdir := path.Join(is.rootDir, repo)\n\tif !is.DirExists(dir) {\n\t\treturn zerr.ErrRepoNotFound\n\t}\n\n\tvar lockLatency time.Time\n\n\tvar err error\n\n\tis.Lock(&lockLatency)\n\tdefer func() {\n\t\tis.Unlock(&lockLatency)\n\n\t\tif err == nil {\n\t\t\tmonitoring.SetStorageUsage(is.metrics, is.rootDir, repo)\n\t\t}\n\t}()\n\n\tindex, err := common.GetIndex(is, repo, is.log)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmanifestDesc, err := common.RemoveManifestDescByReference(&index, reference, detectCollision)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = common.UpdateIndexWithPrunedImageManifests(is, &index, repo, manifestDesc, manifestDesc.Digest, is.log)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// now update \"index.json\"\n\tdir = path.Join(is.rootDir, repo)\n\tfile := path.Join(dir, \"index.json\")\n\n\tbuf, err := json.Marshal(index)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := is.writeFile(file, buf); err != nil {\n\t\treturn err\n\t}\n\n\t// Delete blob only when blob digest not present in manifest entry.\n\t// e.g. 1.0.1 & 1.0.2 have same blob digest so if we delete 1.0.1, blob should not be removed.\n\ttoDelete := true\n\n\tfor _, manifest := range index.Manifests {\n\t\tif manifestDesc.Digest.String() == manifest.Digest.String() {\n\t\t\ttoDelete = false\n\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif toDelete {\n\t\tp := path.Join(dir, \"blobs\", manifestDesc.Digest.Algorithm().String(), manifestDesc.Digest.Encoded())\n\n\t\t_ = os.Remove(p)\n\t}\n\n\treturn nil\n}", "func (is *ObjectStorage) DeleteImageManifest(repo, reference string, detectCollisions bool) error {\n\tdir := path.Join(is.rootDir, repo)\n\tif fi, err := is.store.Stat(context.Background(), dir); err != nil || !fi.IsDir() {\n\t\treturn zerr.ErrRepoNotFound\n\t}\n\n\tvar lockLatency time.Time\n\n\tvar err error\n\n\tis.Lock(&lockLatency)\n\tdefer func() {\n\t\tis.Unlock(&lockLatency)\n\n\t\tif err == nil {\n\t\t\tmonitoring.SetStorageUsage(is.metrics, is.rootDir, repo)\n\t\t}\n\t}()\n\n\tindex, err := common.GetIndex(is, repo, is.log)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmanifestDesc, err := common.RemoveManifestDescByReference(&index, reference, detectCollisions)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = common.UpdateIndexWithPrunedImageManifests(is, &index, repo, manifestDesc, manifestDesc.Digest, is.log)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// now update \"index.json\"\n\tdir = path.Join(is.rootDir, repo)\n\tfile := path.Join(dir, \"index.json\")\n\n\tbuf, err := json.Marshal(index)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif _, err := writeFile(is.store, file, buf); err != nil {\n\t\tis.log.Debug().Str(\"deleting reference\", reference).Msg(\"\")\n\n\t\treturn err\n\t}\n\n\t// Delete blob only when blob digest not present in manifest entry.\n\t// e.g. 1.0.1 & 1.0.2 have same blob digest so if we delete 1.0.1, blob should not be removed.\n\ttoDelete := true\n\n\tfor _, manifest := range index.Manifests {\n\t\tif manifestDesc.Digest.String() == manifest.Digest.String() {\n\t\t\ttoDelete = false\n\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif toDelete {\n\t\tp := path.Join(dir, \"blobs\", manifestDesc.Digest.Algorithm().String(), manifestDesc.Digest.Encoded())\n\n\t\terr = is.store.Delete(context.Background(), p)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func OnGetManifest(name, reference string, body []byte,\n\tstoreController storage.StoreController, metaDB mTypes.MetaDB, log log.Logger,\n) error {\n\t// check if image is a signature\n\tisSignature, _, _, err := storage.CheckIsImageSignature(name, body, reference)\n\tif err != nil {\n\t\tlog.Error().Err(err).Msg(\"can't check if manifest is a signature or not\")\n\n\t\treturn err\n\t}\n\n\tif !isSignature {\n\t\terr := metaDB.IncrementImageDownloads(name, reference)\n\t\tif err != nil {\n\t\t\tlog.Error().Err(err).Str(\"repository\", name).Str(\"reference\", reference).\n\t\t\t\tMsg(\"unexpected error for image\")\n\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (mr *ManifestResource) Delete(_ http.ResponseWriter, req *http.Request, _ httprouter.Params) restful.Exchanger {\n\treturn &DELETEManifestHandler{\n\t\tState: mr.context.liveState(),\n\t\tQueryValues: mr.ParseQuery(req),\n\t\tStateWriter: sous.StateWriter(mr.context.StateManager),\n\t}\n}", "func DeleteManifest(registry, repository string, manifest manifest.Data) error {\n\t// Will perform an actual delete\n\tdeleteCmd := newDeleteManifestsCommand(registry, repository, manifest.Digest)\n\n\tvar outb bytes.Buffer\n\tdeleteCmd.Stdout = &outb\n\n\treturn deleteCmd.Run()\n}", "func (d *swiftDriver) DeleteManifest(account keppel.Account, repoName string, manifestDigest digest.Digest) error {\n\tc, _, err := d.getBackendConnection(account)\n\tif err != nil {\n\t\treturn err\n\t}\n\to := manifestObject(c, repoName, manifestDigest)\n\treturn o.Delete(nil, nil)\n}", "func (m *manifestService) Delete(ctx context.Context, dgst digest.Digest) error {\n\tcontext.GetLogger(ctx).Debugf(\"(*manifestService).Delete\")\n\treturn m.manifests.Delete(withRepository(ctx, m.repo), dgst)\n}", "func (bm *BlobsManifest) Delete() error {\n\n\tfor _, chunk := range bm.Chunks {\n\t\t// for Huge Blob mode, no need remove blobs\n\t\t_, _, length := utils.ParseBlobDigest(chunk)\n\t\tif length != 0 {\n\t\t\tbreak\n\t\t}\n\n\t\tb := blobs.GetBlobPartial(\"\", chunk)\n\t\tif b != nil {\n\t\t\tb.Delete()\n\t\t}\n\t}\n\n\t// to remove Huge Blob Image\n\timageDir := configuration.RootDirectory() + manifest.ManifestDir + \"/\" + bm.BlobSum\n\tutils.RemoveDir(imageDir)\n\n\tutils.Remove(blobsManifestPath(bm.BlobSum))\n\n\treturn nil\n}", "func (s *s3ManifestService) Delete(ctx context.Context, dgst godigest.Digest) error {\n\treturn fmt.Errorf(\"unimplemented\")\n}", "func (mh *MetadataHandler) HandleDeleteMetadata(w http.ResponseWriter, r *http.Request) {\n\tdefer r.Body.Close()\n\n\tvars := mux.Vars(r)\n\tvar (\n\t\tappID string\n\t\tok bool\n\t)\n\tif appID, ok = vars[\"appID\"]; !ok {\n\t\tw.WriteHeader(http.StatusBadRequest) // 400\n\t\treturn\n\t}\n\n\terr := mh.Repository.Delete(appID)\n\tif err != nil {\n\t\tif err == repository.ErrIDNotFound {\n\t\t\tw.WriteHeader(http.StatusConflict) // 409\n\t\t} else {\n\t\t\tw.WriteHeader(http.StatusInternalServerError) // 500\n\t\t}\n\t\tyaml.NewEncoder(w).Encode(err.Error())\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusNoContent) // 204\n}", "func deleteManifests(ctx context.Context, acrClient api.AcrCLIClientInterface, loginURL string, repoName string, args []string) error {\n\tfor i := 0; i < len(args); i++ {\n\t\t_, err := acrClient.DeleteManifest(ctx, repoName, args[i])\n\t\tif err != nil {\n\t\t\t// If there is an error (this includes not found and not allowed operations) the deletion of the images is stopped and an error is returned.\n\t\t\treturn errors.Wrap(err, \"failed to delete manifests\")\n\t\t}\n\t\tfmt.Printf(\"%s/%s@%s\\n\", loginURL, repoName, args[i])\n\t}\n\treturn nil\n}", "func revertToManifest(kv *DB, mf *Manifest, idMap map[uint64]struct{}) error {\n\t// 1. Check all files in manifest exist.\n\tfor id := range mf.Tables {\n\t\tif _, ok := idMap[id]; !ok {\n\t\t\treturn fmt.Errorf(\"file does not exist for table %d\", id)\n\t\t}\n\t}\n\n\t// 2. Delete files that shouldn't exist.\n\tfor id := range idMap {\n\t\tif _, ok := mf.Tables[id]; !ok {\n\t\t\tkv.elog.Printf(\"Table file %d not referenced in MANIFEST\\n\", id)\n\t\t\tfilename := table.NewFilename(id, kv.opt.Dir)\n\t\t\tif err := os.Remove(filename); err != nil {\n\t\t\t\treturn y.Wrapf(err, \"While removing table %d\", id)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (imh *manifestHandler) PutManifest(w http.ResponseWriter, r *http.Request) {\n\tdcontext.GetLogger(imh).Debug(\"PutImageManifest\")\n\tmanifests, err := imh.Repository.Manifests(imh)\n\tif err != nil {\n\t\timh.Errors = append(imh.Errors, err)\n\t\treturn\n\t}\n\n\tvar jsonBuf bytes.Buffer\n\tif err := copyFullPayload(imh, w, r, &jsonBuf, maxManifestBodySize, \"image manifest PUT\"); err != nil {\n\t\t// copyFullPayload reports the error if necessary\n\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestInvalid.WithDetail(err.Error()))\n\t\treturn\n\t}\n\n\tmediaType := r.Header.Get(\"Content-Type\")\n\tmanifest, desc, err := distribution.UnmarshalManifest(mediaType, jsonBuf.Bytes())\n\tif err != nil {\n\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestInvalid.WithDetail(err))\n\t\treturn\n\t}\n\n\tif imh.Digest != \"\" {\n\t\tif desc.Digest != imh.Digest {\n\t\t\tdcontext.GetLogger(imh).Errorf(\"payload digest does not match: %q != %q\", desc.Digest, imh.Digest)\n\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeDigestInvalid)\n\t\t\treturn\n\t\t}\n\t} else if imh.Tag != \"\" {\n\t\timh.Digest = desc.Digest\n\t} else {\n\t\timh.Errors = append(imh.Errors, v2.ErrorCodeTagInvalid.WithDetail(\"no tag or digest specified\"))\n\t\treturn\n\t}\n\n\tisAnOCIManifest := mediaType == v1.MediaTypeImageManifest || mediaType == v1.MediaTypeImageIndex\n\n\tif isAnOCIManifest {\n\t\tdcontext.GetLogger(imh).Debug(\"Putting an OCI Manifest!\")\n\t} else {\n\t\tdcontext.GetLogger(imh).Debug(\"Putting a Docker Manifest!\")\n\t}\n\n\tvar options []distribution.ManifestServiceOption\n\tif imh.Tag != \"\" {\n\t\toptions = append(options, distribution.WithTag(imh.Tag))\n\t}\n\n\tif err := imh.applyResourcePolicy(manifest); err != nil {\n\t\timh.Errors = append(imh.Errors, err)\n\t\treturn\n\t}\n\n\t_, err = manifests.Put(imh, manifest, options...)\n\tif err != nil {\n\t\t// TODO(stevvooe): These error handling switches really need to be\n\t\t// handled by an app global mapper.\n\t\tif err == distribution.ErrUnsupported {\n\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnsupported)\n\t\t\treturn\n\t\t}\n\t\tif err == distribution.ErrAccessDenied {\n\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeDenied)\n\t\t\treturn\n\t\t}\n\t\tswitch err := err.(type) {\n\t\tcase distribution.ErrManifestVerification:\n\t\t\tfor _, verificationError := range err {\n\t\t\t\tswitch verificationError := verificationError.(type) {\n\t\t\t\tcase distribution.ErrManifestBlobUnknown:\n\t\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestBlobUnknown.WithDetail(verificationError.Digest))\n\t\t\t\tcase distribution.ErrManifestNameInvalid:\n\t\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeNameInvalid.WithDetail(err))\n\t\t\t\tcase distribution.ErrManifestUnverified:\n\t\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnverified)\n\t\t\t\tdefault:\n\t\t\t\t\tif verificationError == digest.ErrDigestInvalidFormat {\n\t\t\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeDigestInvalid)\n\t\t\t\t\t} else {\n\t\t\t\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown, verificationError)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tcase errcode.Error:\n\t\t\timh.Errors = append(imh.Errors, err)\n\t\tdefault:\n\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\t}\n\t\treturn\n\t}\n\n\t// Tag this manifest\n\tif imh.Tag != \"\" {\n\t\ttags := imh.Repository.Tags(imh)\n\t\terr = tags.Tag(imh, imh.Tag, desc)\n\t\tif err != nil {\n\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\t\treturn\n\t\t}\n\n\t}\n\n\t// Construct a canonical url for the uploaded manifest.\n\tref, err := reference.WithDigest(imh.Repository.Named(), imh.Digest)\n\tif err != nil {\n\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\treturn\n\t}\n\n\tlocation, err := imh.urlBuilder.BuildManifestURL(ref)\n\tif err != nil {\n\t\t// NOTE(stevvooe): Given the behavior above, this absurdly unlikely to\n\t\t// happen. We'll log the error here but proceed as if it worked. Worst\n\t\t// case, we set an empty location header.\n\t\tdcontext.GetLogger(imh).Errorf(\"error building manifest url from digest: %v\", err)\n\t}\n\n\tw.Header().Set(\"Location\", location)\n\tw.Header().Set(\"Docker-Content-Digest\", imh.Digest.String())\n\tw.WriteHeader(http.StatusCreated)\n\n\tdcontext.GetLogger(imh).Debug(\"Succeeded in putting manifest!\")\n}", "func (ir *ImageEngine) ManifestRemoveDigest(ctx context.Context, name string, image string) (string, error) {\n\tupdatedListID, err := manifests.Remove(ir.ClientCtx, name, image, nil)\n\tif err != nil {\n\t\treturn updatedListID, fmt.Errorf(\"removing from manifest %s: %w\", name, err)\n\t}\n\treturn fmt.Sprintf(\"%s :%s\\n\", updatedListID, image), nil\n}", "func (job *purgeManifestJob) process(ctx context.Context, acrClient api.AcrCLIClientInterface) error {\n\tresp, err := acrClient.DeleteManifest(ctx, job.repoName, job.digest)\n\tif err == nil {\n\t\tfmt.Printf(\"Deleted %s/%s@%s\\n\", job.loginURL, job.repoName, job.digest)\n\t\treturn nil\n\t}\n\n\tif resp != nil && resp.Response != nil && resp.StatusCode == http.StatusNotFound {\n\t\t// If the manifest is not found it can be assumed to have been deleted.\n\t\tfmt.Printf(\"Skipped %s/%s@%s, HTTP status: %d\\n\", job.loginURL, job.repoName, job.digest, resp.StatusCode)\n\t\treturn nil\n\t}\n\n\treturn err\n}", "func (mc *manifestCache) Delete(db string) {\n\tmc.mu.Lock()\n\tdefer mc.mu.Unlock()\n\n\tif entry, ok := mc.entry(db); ok {\n\t\tmc.totalSize -= entry.contents.size()\n\t\tmc.lru.Remove(entry.lruEntry)\n\t\tdelete(mc.cache, db)\n\t}\n\n\treturn\n}", "func DeleteImageMeta(key string) error {\n\terr := imageDb.Delete([]byte(key), pebble.Sync)\n\n\treturn err\n}", "func (rl *ReferrerList) Delete(m manifest.Manifest) error {\n\trlM, ok := rl.Manifest.GetOrig().(v1.Index)\n\tif !ok {\n\t\treturn fmt.Errorf(\"referrer list manifest is not an OCI index for %s\", rl.Subject.CommonName())\n\t}\n\t// delete matching entries from the list\n\tmDesc := m.GetDescriptor()\n\tfound := false\n\tfor i := len(rlM.Manifests) - 1; i >= 0; i-- {\n\t\tif rlM.Manifests[i].Digest == mDesc.Digest {\n\t\t\tif i < len(rlM.Manifests)-1 {\n\t\t\t\trlM.Manifests = append(rlM.Manifests[:i], rlM.Manifests[i+1:]...)\n\t\t\t} else {\n\t\t\t\trlM.Manifests = rlM.Manifests[:i]\n\t\t\t}\n\t\t\tfound = true\n\t\t}\n\t}\n\tif !found {\n\t\treturn fmt.Errorf(\"subject not found in referrer list%.0w\", types.ErrNotFound)\n\t}\n\terr := rl.Manifest.SetOrig(rlM)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func handleAppInstanceStatusDelete(ctxArg interface{}, key string,\n\tstatusArg interface{}) {\n\tctx := ctxArg.(*zedmanagerContext)\n\tpublishAppInstanceSummary(ctx)\n}", "func (_m *DirectRepositoryWriter) DeleteManifest(ctx context.Context, id manifest.ID) error {\n\tret := _m.Called(ctx, id)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(context.Context, manifest.ID) error); ok {\n\t\tr0 = rf(ctx, id)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func handleDelete(ctx *verifierContext, status *types.VerifyImageStatus) {\n\n\tlog.Functionf(\"handleDelete(%s) refcount %d\",\n\t\tstatus.ImageSha256, status.RefCount)\n\n\tif _, err := os.Stat(status.FileLocation); err == nil {\n\t\tlog.Functionf(\"handleDelete removing %s\",\n\t\t\tstatus.FileLocation)\n\t\tif err := os.RemoveAll(status.FileLocation); err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t} else {\n\t\tlog.Warnf(\"handleDelete: Unable to delete %s: %s\",\n\t\t\tstatus.FileLocation, err)\n\t}\n\n\tunpublishVerifyImageStatus(ctx, status)\n\tlog.Functionf(\"handleDelete done for %s\", status.ImageSha256)\n}", "func (g Goba) DeleteImage(typ DatabaseType, name string) error {\n\tfor _, handler := range g.handlers {\n\t\tif handler.Type() == typ {\n\t\t\treturn handler.DeleteImage(name)\n\t\t}\n\t}\n\treturn ErrNoSuchHandler\n}", "func (sma *SmIPAM) OnIPAMPolicyDelete(obj *ctkit.IPAMPolicy) error {\n\tlog.Info(\"OnIPAMPolicyDelete: received: \", obj.Spec)\n\n\tpolicy, err := sma.FindIPAMPolicy(obj.Tenant, obj.Namespace, obj.Name)\n\n\tif err != nil {\n\t\tlog.Error(\"FindIPAMPolicy returned an error: \", err, \"for: \", obj.Tenant, obj.Namespace, obj.Name)\n\t\treturn errors.New(\"Object doesn't exist\")\n\t}\n\n\t// delete it from the DB\n\treturn sma.sm.DeleteObjectToMbus(\"\", policy, nil)\n}", "func (ir *ImageEngine) ManifestRm(ctx context.Context, names []string) (*entities.ImageRemoveReport, []error) {\n\treturn ir.Remove(ctx, names, entities.ImageRemoveOptions{LookupManifest: true})\n}", "func (_m *RepositoryWriter) DeleteManifest(ctx context.Context, id manifest.ID) error {\n\tret := _m.Called(ctx, id)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(context.Context, manifest.ID) error); ok {\n\t\tr0 = rf(ctx, id)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func deleteMetadata(id string) error {\n\terr := db.Update(func(tx *bolt.Tx) error {\n\t\treturn tx.Bucket(dbBucket).Delete([]byte(id))\n\t})\n\treturn err\n}", "func (m *ImageManifest) UnmarshalJSON(data []byte) (err error) {\n\tmanifestMap := make(map[string]json.RawMessage)\n\tif err = json.Unmarshal(data, &manifestMap); err != nil {\n\t\terr = errors.WithStack(err)\n\t\treturn\n\t}\n\n\tfor k, v := range manifestMap {\n\t\tswitch k {\n\t\tcase \"mediaType\":\n\t\t\terr = json.Unmarshal(v, &m.MediaType)\n\t\tcase \"schemaVersion\":\n\t\t\terr = json.Unmarshal(v, &m.SchemaVersion)\n\t\tcase \"config\":\n\t\t\tm.Config, err = unmarshalConfig(v)\n\t\tcase \"layers\":\n\t\t\tm.Layers, err = unmarshalLayers(v)\n\t\tdefault:\n\t\t}\n\t\tif err != nil {\n\t\t\terr = errors.WithStack(err)\n\t\t\treturn\n\t\t}\n\t}\n\n\treturn\n}", "func (s *tagStore) Manifest(ctx context.Context, t *models.Tag) (*models.Manifest, error) {\n\tdefer metrics.InstrumentQuery(\"tag_manifest\")()\n\tq := `SELECT\n\t\t\tm.id,\n\t\t\tm.top_level_namespace_id,\n\t\t\tm.repository_id,\n\t\t\tm.schema_version,\n\t\t\tmt.media_type,\n\t\t\tencode(m.digest, 'hex') as digest,\n\t\t\tm.payload,\n\t\t\tmtc.media_type as configuration_media_type,\n\t\t\tencode(m.configuration_blob_digest, 'hex') as configuration_blob_digest,\n\t\t\tm.configuration_payload,\n\t\t\tm.created_at\n\t\tFROM\n\t\t\tmanifests AS m\n\t\t\tJOIN media_types AS mt ON mt.id = m.media_type_id\n\t\t\tLEFT JOIN media_types AS mtc ON mtc.id = m.configuration_media_type_id\n\t\tWHERE\n\t\t\tm.top_level_namespace_id = $1\n\t\t\tAND m.repository_id = $2\n\t\t\tAND m.id = $3`\n\trow := s.db.QueryRowContext(ctx, q, t.NamespaceID, t.RepositoryID, t.ManifestID)\n\n\treturn scanFullManifest(row)\n}", "func (is *ObjectStorage) PutImageManifest(repo, reference, mediaType string, //nolint: gocyclo\n\tbody []byte,\n) (godigest.Digest, godigest.Digest, error) {\n\tif err := is.InitRepo(repo); err != nil {\n\t\tis.log.Debug().Err(err).Msg(\"init repo\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\tvar lockLatency time.Time\n\n\tvar err error\n\n\tis.Lock(&lockLatency)\n\tdefer func() {\n\t\tis.Unlock(&lockLatency)\n\n\t\tif err == nil {\n\t\t\tmonitoring.SetStorageUsage(is.metrics, is.rootDir, repo)\n\t\t\tmonitoring.IncUploadCounter(is.metrics, repo)\n\t\t}\n\t}()\n\n\trefIsDigest := true\n\n\tmDigest, err := common.GetAndValidateRequestDigest(body, reference, is.log)\n\tif err != nil {\n\t\tif errors.Is(err, zerr.ErrBadManifest) {\n\t\t\treturn mDigest, \"\", err\n\t\t}\n\n\t\trefIsDigest = false\n\t}\n\n\tdig, err := common.ValidateManifest(is, repo, reference, mediaType, body, is.log)\n\tif err != nil {\n\t\treturn dig, \"\", err\n\t}\n\n\tindex, err := common.GetIndex(is, repo, is.log)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\t// create a new descriptor\n\tdesc := ispec.Descriptor{\n\t\tMediaType: mediaType, Size: int64(len(body)), Digest: mDigest,\n\t}\n\n\tif !refIsDigest {\n\t\tdesc.Annotations = map[string]string{ispec.AnnotationRefName: reference}\n\t}\n\n\tvar subjectDigest godigest.Digest\n\n\tartifactType := \"\"\n\n\tif mediaType == ispec.MediaTypeImageManifest {\n\t\tvar manifest ispec.Manifest\n\n\t\terr := json.Unmarshal(body, &manifest)\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", err\n\t\t}\n\n\t\tif manifest.Subject != nil {\n\t\t\tsubjectDigest = manifest.Subject.Digest\n\t\t}\n\n\t\tartifactType = zcommon.GetManifestArtifactType(manifest)\n\t} else if mediaType == ispec.MediaTypeImageIndex {\n\t\tvar index ispec.Index\n\n\t\terr := json.Unmarshal(body, &index)\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", err\n\t\t}\n\n\t\tif index.Subject != nil {\n\t\t\tsubjectDigest = index.Subject.Digest\n\t\t}\n\n\t\tartifactType = zcommon.GetIndexArtifactType(index)\n\t}\n\n\tupdateIndex, oldDgst, err := common.CheckIfIndexNeedsUpdate(&index, &desc, is.log)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\tif !updateIndex {\n\t\treturn desc.Digest, subjectDigest, nil\n\t}\n\n\t// write manifest to \"blobs\"\n\tdir := path.Join(is.rootDir, repo, \"blobs\", mDigest.Algorithm().String())\n\tmanifestPath := path.Join(dir, mDigest.Encoded())\n\n\tif err = is.store.PutContent(context.Background(), manifestPath, body); err != nil {\n\t\tis.log.Error().Err(err).Str(\"file\", manifestPath).Msg(\"unable to write\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\terr = common.UpdateIndexWithPrunedImageManifests(is, &index, repo, desc, oldDgst, is.log)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\t// now update \"index.json\"\n\tindex.Manifests = append(index.Manifests, desc)\n\tdir = path.Join(is.rootDir, repo)\n\tindexPath := path.Join(dir, \"index.json\")\n\n\tbuf, err := json.Marshal(index)\n\tif err != nil {\n\t\tis.log.Error().Err(err).Str(\"file\", indexPath).Msg(\"unable to marshal JSON\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\t// update the descriptors artifact type in order to check for signatures when applying the linter\n\tdesc.ArtifactType = artifactType\n\n\t// apply linter only on images, not signatures\n\tpass, err := common.ApplyLinter(is, is.linter, repo, desc)\n\tif !pass {\n\t\tis.log.Error().Err(err).Str(\"repository\", repo).Str(\"reference\", reference).Msg(\"linter didn't pass\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\tif err = is.store.PutContent(context.Background(), indexPath, buf); err != nil {\n\t\tis.log.Error().Err(err).Str(\"file\", manifestPath).Msg(\"unable to write\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\treturn desc.Digest, subjectDigest, nil\n}", "func (is *ImageStoreLocal) PutImageManifest(repo, reference, mediaType string, //nolint: gocyclo\n\tbody []byte,\n) (godigest.Digest, godigest.Digest, error) {\n\tif err := is.InitRepo(repo); err != nil {\n\t\tis.log.Debug().Err(err).Msg(\"init repo\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\tvar lockLatency time.Time\n\n\tvar err error\n\n\tis.Lock(&lockLatency)\n\tdefer func() {\n\t\tis.Unlock(&lockLatency)\n\n\t\tif err == nil {\n\t\t\tmonitoring.SetStorageUsage(is.metrics, is.rootDir, repo)\n\t\t\tmonitoring.IncUploadCounter(is.metrics, repo)\n\t\t}\n\t}()\n\n\trefIsDigest := true\n\n\tmDigest, err := common.GetAndValidateRequestDigest(body, reference, is.log)\n\tif err != nil {\n\t\tif errors.Is(err, zerr.ErrBadManifest) {\n\t\t\treturn mDigest, \"\", err\n\t\t}\n\n\t\trefIsDigest = false\n\t}\n\n\tdigest, err := common.ValidateManifest(is, repo, reference, mediaType, body, is.log)\n\tif err != nil {\n\t\treturn digest, \"\", err\n\t}\n\n\tindex, err := common.GetIndex(is, repo, is.log)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\t// create a new descriptor\n\tdesc := ispec.Descriptor{\n\t\tMediaType: mediaType, Size: int64(len(body)), Digest: mDigest,\n\t}\n\n\tif !refIsDigest {\n\t\tdesc.Annotations = map[string]string{ispec.AnnotationRefName: reference}\n\t}\n\n\tvar subjectDigest godigest.Digest\n\n\tartifactType := \"\"\n\n\tif mediaType == ispec.MediaTypeImageManifest {\n\t\tvar manifest ispec.Manifest\n\n\t\terr := json.Unmarshal(body, &manifest)\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", err\n\t\t}\n\n\t\tif manifest.Subject != nil {\n\t\t\tsubjectDigest = manifest.Subject.Digest\n\t\t}\n\n\t\tartifactType = zcommon.GetManifestArtifactType(manifest)\n\t} else if mediaType == ispec.MediaTypeImageIndex {\n\t\tvar index ispec.Index\n\n\t\terr := json.Unmarshal(body, &index)\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", err\n\t\t}\n\n\t\tif index.Subject != nil {\n\t\t\tsubjectDigest = index.Subject.Digest\n\t\t}\n\n\t\tartifactType = zcommon.GetIndexArtifactType(index)\n\t}\n\n\tupdateIndex, oldDgst, err := common.CheckIfIndexNeedsUpdate(&index, &desc, is.log)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\tif !updateIndex {\n\t\treturn desc.Digest, subjectDigest, nil\n\t}\n\n\t// write manifest to \"blobs\"\n\tdir := path.Join(is.rootDir, repo, \"blobs\", mDigest.Algorithm().String())\n\t_ = ensureDir(dir, is.log)\n\tfile := path.Join(dir, mDigest.Encoded())\n\n\t// in case the linter will not pass, it will be garbage collected\n\tif err := is.writeFile(file, body); err != nil {\n\t\tis.log.Error().Err(err).Str(\"file\", file).Msg(\"unable to write\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\terr = common.UpdateIndexWithPrunedImageManifests(is, &index, repo, desc, oldDgst, is.log)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\t// now update \"index.json\"\n\tindex.Manifests = append(index.Manifests, desc)\n\tdir = path.Join(is.rootDir, repo)\n\tfile = path.Join(dir, \"index.json\")\n\n\tbuf, err := json.Marshal(index)\n\tif err := inject.Error(err); err != nil {\n\t\tis.log.Error().Err(err).Str(\"file\", file).Msg(\"unable to marshal JSON\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\t// update the descriptors artifact type in order to check for signatures when applying the linter\n\tdesc.ArtifactType = artifactType\n\n\t// apply linter only on images, not signatures or indexes\n\tpass, err := common.ApplyLinter(is, is.linter, repo, desc)\n\tif !pass {\n\t\tis.log.Error().Err(err).Str(\"repository\", repo).Str(\"reference\", reference).Msg(\"linter didn't pass\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\terr = is.writeFile(file, buf)\n\tif err := inject.Error(err); err != nil {\n\t\tis.log.Error().Err(err).Str(\"file\", file).Msg(\"unable to write\")\n\n\t\treturn \"\", \"\", err\n\t}\n\n\treturn desc.Digest, subjectDigest, nil\n}", "func (signup *EventSignup) OnDeleted(container *ioccontainer.Container) error {\n\terr := signup.Validate()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar eventRepository EventRepository\n\tcontainer.Make(&eventRepository)\n\n\tevent, err := eventRepository.GetEventByID(signup.EventID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn signup.sendNotification(event, \"member_signed_out\", container)\n}", "func (imh *manifestHandler) GetManifest(w http.ResponseWriter, r *http.Request) {\n\tdcontext.GetLogger(imh).Debug(\"GetImageManifest\")\n\tmanifests, err := imh.Repository.Manifests(imh)\n\tif err != nil {\n\t\timh.Errors = append(imh.Errors, err)\n\t\treturn\n\t}\n\tvar supports [numStorageTypes]bool\n\n\t// this parsing of Accept headers is not quite as full-featured as godoc.org's parser, but we don't care about \"q=\" values\n\t// https://github.com/golang/gddo/blob/e91d4165076d7474d20abda83f92d15c7ebc3e81/httputil/header/header.go#L165-L202\n\tfor _, acceptHeader := range r.Header[\"Accept\"] {\n\t\t// r.Header[...] is a slice in case the request contains the same header more than once\n\t\t// if the header isn't set, we'll get the zero value, which \"range\" will handle gracefully\n\n\t\t// we need to split each header value on \",\" to get the full list of \"Accept\" values (per RFC 2616)\n\t\t// https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1\n\t\tfor _, mediaType := range strings.Split(acceptHeader, \",\") {\n\t\t\tif mediaType, _, err = mime.ParseMediaType(mediaType); err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif mediaType == schema2.MediaTypeManifest {\n\t\t\t\tsupports[manifestSchema2] = true\n\t\t\t}\n\t\t\tif mediaType == manifestlist.MediaTypeManifestList {\n\t\t\t\tsupports[manifestlistSchema] = true\n\t\t\t}\n\t\t\tif mediaType == v1.MediaTypeImageManifest {\n\t\t\t\tsupports[ociSchema] = true\n\t\t\t}\n\t\t\tif mediaType == v1.MediaTypeImageIndex {\n\t\t\t\tsupports[ociImageIndexSchema] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tif imh.Tag != \"\" {\n\t\ttags := imh.Repository.Tags(imh)\n\t\tdesc, err := tags.Get(imh, imh.Tag)\n\t\tif err != nil {\n\t\t\tif _, ok := err.(distribution.ErrTagUnknown); ok {\n\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown.WithDetail(err))\n\t\t\t} else {\n\t\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\timh.Digest = desc.Digest\n\t}\n\n\tif etagMatch(r, imh.Digest.String()) {\n\t\tw.WriteHeader(http.StatusNotModified)\n\t\treturn\n\t}\n\n\tvar options []distribution.ManifestServiceOption\n\tif imh.Tag != \"\" {\n\t\toptions = append(options, distribution.WithTag(imh.Tag))\n\t}\n\tmanifest, err := manifests.Get(imh, imh.Digest, options...)\n\tif err != nil {\n\t\tif _, ok := err.(distribution.ErrManifestUnknownRevision); ok {\n\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown.WithDetail(err))\n\t\t} else {\n\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\t}\n\t\treturn\n\t}\n\t// determine the type of the returned manifest\n\tmanifestType := manifestSchema1\n\tschema2Manifest, isSchema2 := manifest.(*schema2.DeserializedManifest)\n\tmanifestList, isManifestList := manifest.(*manifestlist.DeserializedManifestList)\n\tif isSchema2 {\n\t\tmanifestType = manifestSchema2\n\t} else if _, isOCImanifest := manifest.(*ocischema.DeserializedManifest); isOCImanifest {\n\t\tmanifestType = ociSchema\n\t} else if isManifestList {\n\t\tif manifestList.MediaType == manifestlist.MediaTypeManifestList {\n\t\t\tmanifestType = manifestlistSchema\n\t\t} else if manifestList.MediaType == v1.MediaTypeImageIndex {\n\t\t\tmanifestType = ociImageIndexSchema\n\t\t}\n\t}\n\n\tif manifestType == ociSchema && !supports[ociSchema] {\n\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown.WithMessage(\"OCI manifest found, but accept header does not support OCI manifests\"))\n\t\treturn\n\t}\n\tif manifestType == ociImageIndexSchema && !supports[ociImageIndexSchema] {\n\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown.WithMessage(\"OCI index found, but accept header does not support OCI indexes\"))\n\t\treturn\n\t}\n\t// Only rewrite schema2 manifests when they are being fetched by tag.\n\t// If they are being fetched by digest, we can't return something not\n\t// matching the digest.\n\tif imh.Tag != \"\" && manifestType == manifestSchema2 && !supports[manifestSchema2] {\n\t\t// Rewrite manifest in schema1 format\n\t\tdcontext.GetLogger(imh).Infof(\"rewriting manifest %s in schema1 format to support old client\", imh.Digest.String())\n\n\t\tmanifest, err = imh.convertSchema2Manifest(schema2Manifest)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t} else if imh.Tag != \"\" && manifestType == manifestlistSchema && !supports[manifestlistSchema] {\n\t\t// Rewrite manifest in schema1 format\n\t\tdcontext.GetLogger(imh).Infof(\"rewriting manifest list %s in schema1 format to support old client\", imh.Digest.String())\n\n\t\t// Find the image manifest corresponding to the default\n\t\t// platform\n\t\tvar manifestDigest digest.Digest\n\t\tfor _, manifestDescriptor := range manifestList.Manifests {\n\t\t\tif manifestDescriptor.Platform.Architecture == defaultArch && manifestDescriptor.Platform.OS == defaultOS {\n\t\t\t\tmanifestDigest = manifestDescriptor.Digest\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif manifestDigest == \"\" {\n\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown)\n\t\t\treturn\n\t\t}\n\n\t\tmanifest, err = manifests.Get(imh, manifestDigest)\n\t\tif err != nil {\n\t\t\tif _, ok := err.(distribution.ErrManifestUnknownRevision); ok {\n\t\t\t\timh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown.WithDetail(err))\n\t\t\t} else {\n\t\t\t\timh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown.WithDetail(err))\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\t// If necessary, convert the image manifest\n\t\tif schema2Manifest, isSchema2 := manifest.(*schema2.DeserializedManifest); isSchema2 && !supports[manifestSchema2] {\n\t\t\tmanifest, err = imh.convertSchema2Manifest(schema2Manifest)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\timh.Digest = manifestDigest\n\t\t}\n\t}\n\n\tct, p, err := manifest.Payload()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", ct)\n\tw.Header().Set(\"Content-Length\", fmt.Sprint(len(p)))\n\tw.Header().Set(\"Docker-Content-Digest\", imh.Digest.String())\n\tw.Header().Set(\"Etag\", fmt.Sprintf(`\"%s\"`, imh.Digest))\n\tw.Write(p)\n}", "func (rc *regClient) TagDelete(ctx context.Context, ref types.Ref) error {\n\tvar tempManifest manifest.Manifest\n\tif ref.Tag == \"\" {\n\t\treturn ErrMissingTag\n\t}\n\n\t// attempt to delete the tag directly, available in OCI distribution-spec, and Hub API\n\treq := httpReq{\n\t\thost: ref.Registry,\n\t\tnoMirrors: true,\n\t\tapis: map[string]httpReqAPI{\n\t\t\t\"\": {\n\t\t\t\tmethod: \"DELETE\",\n\t\t\t\trepository: ref.Repository,\n\t\t\t\tpath: \"manifests/\" + ref.Tag,\n\t\t\t\tignoreErr: true, // do not trigger backoffs if this fails\n\t\t\t},\n\t\t\t\"hub\": {\n\t\t\t\tmethod: \"DELETE\",\n\t\t\t\tpath: \"repositories/\" + ref.Repository + \"/tags/\" + ref.Tag + \"/\",\n\t\t\t},\n\t\t},\n\t}\n\n\tresp, err := rc.httpDo(ctx, req)\n\tif resp != nil {\n\t\tdefer resp.Close()\n\t}\n\t// TODO: Hub may return a different status\n\tif err == nil && resp != nil && resp.HTTPResponse().StatusCode == 202 {\n\t\treturn nil\n\t}\n\t// ignore errors, fallback to creating a temporary manifest to replace the tag and deleting that manifest\n\n\t// lookup the current manifest media type\n\tcurManifest, err := rc.ManifestHead(ctx, ref)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// create empty image config with single label\n\t// Note, this should be MediaType specific, but it appears that docker uses OCI for the config\n\tnow := time.Now()\n\tconf := ociv1.Image{\n\t\tCreated: &now,\n\t\tConfig: ociv1.ImageConfig{\n\t\t\tLabels: map[string]string{\n\t\t\t\t\"delete-tag\": ref.Tag,\n\t\t\t\t\"delete-date\": now.String(),\n\t\t\t},\n\t\t},\n\t\tOS: \"linux\",\n\t\tArchitecture: \"amd64\",\n\t\tRootFS: ociv1.RootFS{\n\t\t\tType: \"layers\",\n\t\t\tDiffIDs: []digest.Digest{},\n\t\t},\n\t}\n\tconfB, err := json.Marshal(conf)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdigester := digest.Canonical.Digester()\n\tconfBuf := bytes.NewBuffer(confB)\n\t_, err = confBuf.WriteTo(digester.Hash())\n\tif err != nil {\n\t\treturn err\n\t}\n\tconfDigest := digester.Digest()\n\n\t// create manifest with config, matching the original tag manifest type\n\tswitch curManifest.GetMediaType() {\n\tcase MediaTypeOCI1Manifest, MediaTypeOCI1ManifestList:\n\t\ttempManifest, err = manifest.FromOrig(ociv1.Manifest{\n\t\t\tVersioned: ociv1Specs.Versioned{\n\t\t\t\tSchemaVersion: 1,\n\t\t\t},\n\t\t\tConfig: ociv1.Descriptor{\n\t\t\t\tMediaType: MediaTypeOCI1ImageConfig,\n\t\t\t\tDigest: confDigest,\n\t\t\t\tSize: int64(len(confB)),\n\t\t\t},\n\t\t\tLayers: []ociv1.Descriptor{},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\tdefault: // default to the docker v2 schema\n\t\ttempManifest, err = manifest.FromOrig(dockerSchema2.Manifest{\n\t\t\tVersioned: dockerManifest.Versioned{\n\t\t\t\tSchemaVersion: 2,\n\t\t\t\tMediaType: MediaTypeDocker2Manifest,\n\t\t\t},\n\t\t\tConfig: dockerDistribution.Descriptor{\n\t\t\t\tMediaType: MediaTypeDocker2ImageConfig,\n\t\t\t\tDigest: confDigest,\n\t\t\t\tSize: int64(len(confB)),\n\t\t\t},\n\t\t\tLayers: []dockerDistribution.Descriptor{},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\trc.log.WithFields(logrus.Fields{\n\t\t\"ref\": ref.Reference,\n\t}).Debug(\"Sending dummy manifest to replace tag\")\n\n\t// push config\n\t_, _, err = rc.BlobPut(ctx, ref, confDigest, ioutil.NopCloser(bytes.NewReader(confB)), MediaTypeDocker2ImageConfig, int64(len(confB)))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed sending dummy config to delete %s: %w\", ref.CommonName(), err)\n\t}\n\n\t// push manifest to tag\n\terr = rc.ManifestPut(ctx, ref, tempManifest)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed sending dummy manifest to delete %s: %w\", ref.CommonName(), err)\n\t}\n\n\tref.Digest = tempManifest.GetDigest().String()\n\n\t// delete manifest by digest\n\trc.log.WithFields(logrus.Fields{\n\t\t\"ref\": ref.Reference,\n\t\t\"digest\": ref.Digest,\n\t}).Debug(\"Deleting dummy manifest\")\n\terr = rc.ManifestDelete(ctx, ref)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed deleting dummy manifest for %s: %w\", ref.CommonName(), err)\n\t}\n\n\treturn nil\n}", "func (announcement *Announcement) DeleteMetadata(key Metadata_Key, value []byte) {\n\tnewMeta := make([]*Metadata, 0, len(announcement.Metadata))\n\tfor _, meta := range announcement.Metadata {\n\t\tif !(meta.Key == key && bytes.Equal(value, meta.Value)) {\n\t\t\tnewMeta = append(newMeta, meta)\n\t\t}\n\t}\n\tannouncement.Metadata = newMeta\n}", "func (p *Processor) ValidateAndStoreManifest(account keppel.Account, repo keppel.Repository, m IncomingManifest, actx keppel.AuditContext) (*keppel.Manifest, error) {\n\t//check if the objects we want to create already exist in the database; this\n\t//check is not 100% reliable since it does not run in the same transaction as\n\t//the actual upsert, so results should be taken with a grain of salt; but the\n\t//result is accurate enough to avoid most duplicate audit events\n\tcontentsDigest := digest.Canonical.FromBytes(m.Contents)\n\tmanifestExistsAlready, err := p.db.SelectBool(checkManifestExistsQuery, repo.ID, contentsDigest.String())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlogg.Debug(\"ValidateAndStoreManifest: in repo %d, manifest %s already exists = %t\", repo.ID, contentsDigest, manifestExistsAlready)\n\tvar tagExistsAlready bool\n\tif m.Reference.IsTag() {\n\t\ttagExistsAlready, err = p.db.SelectBool(checkTagExistsAtSameDigestQuery, repo.ID, m.Reference.Tag, contentsDigest.String())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tlogg.Debug(\"ValidateAndStoreManifest: in repo %d, tag %s @%s already exists = %t\", repo.ID, m.Reference.Tag, contentsDigest, tagExistsAlready)\n\t}\n\n\t//the quota check can be skipped if we are sure that we won't need to insert\n\t//a new row into the manifests table\n\tif !manifestExistsAlready {\n\t\terr = p.checkQuotaForManifestPush(account)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tmanifest := &keppel.Manifest{\n\t\t//NOTE: .Digest and .SizeBytes are computed by validateAndStoreManifestCommon()\n\t\tRepositoryID: repo.ID,\n\t\tMediaType: m.MediaType,\n\t\tPushedAt: m.PushedAt,\n\t\tValidatedAt: m.PushedAt,\n\t}\n\tif m.Reference.IsDigest() {\n\t\t//allow validateAndStoreManifestCommon() to validate the user-supplied\n\t\t//digest against the actual manifest data\n\t\tmanifest.Digest = m.Reference.Digest\n\t}\n\terr = p.validateAndStoreManifestCommon(account, repo, manifest, m.Contents,\n\t\tfunc(tx *gorp.Transaction) error {\n\t\t\tif m.Reference.IsTag() {\n\t\t\t\terr = upsertTag(tx, keppel.Tag{\n\t\t\t\t\tRepositoryID: repo.ID,\n\t\t\t\t\tName: m.Reference.Tag,\n\t\t\t\t\tDigest: manifest.Digest,\n\t\t\t\t\tPushedAt: m.PushedAt,\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//after making all DB changes, but before committing the DB transaction,\n\t\t\t//write the manifest into the backend\n\t\t\treturn p.sd.WriteManifest(account, repo.Name, manifest.Digest, m.Contents)\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t//submit audit events, but only if we are reasonably sure that we actually\n\t//inserted a new manifest and/or changed a tag (without this restriction, we\n\t//would log an audit event everytime a manifest is validated or a tag is\n\t//synced; before the introduction of this check, we generated millions of\n\t//useless audit events per month)\n\tif userInfo := actx.UserIdentity.UserInfo(); userInfo != nil {\n\t\trecord := func(target audittools.TargetRenderer) {\n\t\t\tp.auditor.Record(audittools.EventParameters{\n\t\t\t\tTime: p.timeNow(),\n\t\t\t\tRequest: actx.Request,\n\t\t\t\tUser: userInfo,\n\t\t\t\tReasonCode: http.StatusOK,\n\t\t\t\tAction: cadf.CreateAction,\n\t\t\t\tTarget: target,\n\t\t\t})\n\t\t}\n\t\tif !manifestExistsAlready {\n\t\t\trecord(auditManifest{\n\t\t\t\tAccount: account,\n\t\t\t\tRepository: repo,\n\t\t\t\tDigest: manifest.Digest,\n\t\t\t})\n\t\t}\n\t\tif m.Reference.IsTag() && !tagExistsAlready {\n\t\t\trecord(auditTag{\n\t\t\t\tAccount: account,\n\t\t\t\tRepository: repo,\n\t\t\t\tDigest: manifest.Digest,\n\t\t\t\tTagName: m.Reference.Tag,\n\t\t\t})\n\t\t}\n\t}\n\treturn manifest, nil\n}", "func (l *Logger) OnMessageDelete(ds *discordgo.Session, md *discordgo.MessageDelete) {\n\tif l.LogDeletes == false {\n\t\treturn\n\t}\n\n\t// TODO: Create separate log for bots.\n\tif md.Author.ID == ds.State.User.ID {\n\t\treturn\n\t}\n\n\tlog.Printf(\"%+v\", md)\n\tlog.Printf(\"%+v\", md.Message)\n\n\t// TODO: Implement delete logging\n\tembed := message.GetDefaultEmbed()\n\tembed.Title = \"Message Deleted\"\n\tembed.Description = fmt.Sprintf(\"Message Deleted: %s\", md.Content)\n\n\tmessage.SendEmbed(ds, l.ChannelID, embed)\n}", "func TriggerPostDelete(appName string) {\n\terr := common.PropertyDestroy(\"buildpacks\", appName)\n\tif err != nil {\n\t\tcommon.LogFail(err.Error())\n\t}\n}", "func (s *store) OnDelete(obj interface{}) {\n\tpod, ok := obj.(*api.Pod)\n\tif !ok {\n\t\tdeletedObj, dok := obj.(kcache.DeletedFinalStateUnknown)\n\t\tif dok {\n\t\t\tpod, ok = deletedObj.Obj.(*api.Pod)\n\t\t}\n\t}\n\n\tif !ok {\n\t\tlog.Errorf(\"Expected Pod but OnDelete handler received %+v\", obj)\n\t\treturn\n\t}\n\n\tif pod.Status.PodIP != \"\" {\n\t\ts.mutex.Lock()\n\t\tdelete(s.rolesByIP, pod.Status.PodIP)\n\t\ts.mutex.Unlock()\n\t}\n}", "func PushManifest(img string, auth dockertypes.AuthConfig) (hash string, length int, err error) {\n\tsrcImages := []types.ManifestEntry{}\n\n\tfor i, platform := range platformsToSearchForIndex {\n\t\tosArchArr := strings.Split(platform, \"/\")\n\t\tif len(osArchArr) != 2 && len(osArchArr) != 3 {\n\t\t\treturn hash, length, fmt.Errorf(\"platform argument %d is not of form 'os/arch': '%s'\", i, platform)\n\t\t}\n\t\tvariant := \"\"\n\t\tos, arch := osArchArr[0], osArchArr[1]\n\t\tif len(osArchArr) == 3 {\n\t\t\tvariant = osArchArr[2]\n\t\t}\n\t\tsrcImages = append(srcImages, types.ManifestEntry{\n\t\t\tImage: fmt.Sprintf(\"%s-%s\", img, arch),\n\t\t\tPlatform: ocispec.Platform{\n\t\t\t\tOS: os,\n\t\t\t\tArchitecture: arch,\n\t\t\t\tVariant: variant,\n\t\t\t},\n\t\t})\n\t}\n\n\tyamlInput := types.YAMLInput{\n\t\tImage: img,\n\t\tManifests: srcImages,\n\t}\n\n\tlog.Debugf(\"pushing manifest list for %s -> %#v\", img, yamlInput)\n\n\t// push the manifest list with the auth as given, ignore missing, do not allow insecure\n\treturn registry.PushManifestList(auth.Username, auth.Password, yamlInput, true, false, false, types.OCI, \"\")\n}", "func (e *EventHandler) OnDelete(obj interface{}) {\n\td := event.DeleteEvent{}\n\n\t// Deal with tombstone events by pulling the object out. Tombstone events wrap the object in a\n\t// DeleteFinalStateUnknown struct, so the object needs to be pulled out.\n\t// Copied from sample-controller\n\t// This should never happen if we aren't missing events, which we have concluded that we are not\n\t// and made decisions off of this belief. Maybe this shouldn't be here?\n\tvar ok bool\n\tif _, ok = obj.(client.Object); !ok {\n\t\t// If the object doesn't have Metadata, assume it is a tombstone object of type DeletedFinalStateUnknown\n\t\ttombstone, ok := obj.(cache.DeletedFinalStateUnknown)\n\t\tif !ok {\n\t\t\tlog.Error(nil, \"Error decoding objects. Expected cache.DeletedFinalStateUnknown\",\n\t\t\t\t\"type\", fmt.Sprintf(\"%T\", obj),\n\t\t\t\t\"object\", obj)\n\t\t\treturn\n\t\t}\n\n\t\t// Set DeleteStateUnknown to true\n\t\td.DeleteStateUnknown = true\n\n\t\t// Set obj to the tombstone obj\n\t\tobj = tombstone.Obj\n\t}\n\n\t// Pull Object out of the object\n\tif o, ok := obj.(client.Object); ok {\n\t\td.Object = o\n\t} else {\n\t\tlog.Error(nil, \"OnDelete missing Object\",\n\t\t\t\"object\", obj, \"type\", fmt.Sprintf(\"%T\", obj))\n\t\treturn\n\t}\n\n\tfor _, p := range e.predicates {\n\t\tif !p.Delete(d) {\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Invoke delete handler\n\tctx, cancel := context.WithCancel(e.ctx)\n\tdefer cancel()\n\te.handler.Delete(ctx, d, e.queue)\n}", "func (st *MemStorage) Delete(gun string) error {\n\tst.lock.Lock()\n\tdefer st.lock.Unlock()\n\tfor k := range st.tufMeta {\n\t\tif strings.HasPrefix(k, gun) {\n\t\t\tdelete(st.tufMeta, k)\n\t\t}\n\t}\n\tdelete(st.checksums, gun)\n\treturn nil\n}", "func (s *TattooStorage) DeleteMetadata(name string) {\n\ts.MetadataDB.Delete(name)\n\ts.MetadataDB.SaveIndex()\n}", "func (s *storageImageDestination) PutManifest(ctx context.Context, manifest []byte) error {\n\ts.manifest = make([]byte, len(manifest))\n\tcopy(s.manifest, manifest)\n\treturn nil\n}", "func (reg *Reg) referrerDelete(ctx context.Context, r ref.Ref, m manifest.Manifest) error {\n\t// get subject field\n\tmSubject, ok := m.(manifest.Subjecter)\n\tif !ok {\n\t\treturn fmt.Errorf(\"manifest does not support the subject field: %w\", types.ErrUnsupportedMediaType)\n\t}\n\tsubject, err := mSubject.GetSubject()\n\tif err != nil {\n\t\treturn err\n\t}\n\t// validate/set subject descriptor\n\tif subject == nil || subject.MediaType == \"\" || subject.Digest == \"\" || subject.Size <= 0 {\n\t\treturn fmt.Errorf(\"refers is not set%.0w\", types.ErrNotFound)\n\t}\n\n\trSubject := r\n\trSubject.Tag = \"\"\n\trSubject.Digest = subject.Digest.String()\n\n\t// if referrer API is available, nothing to do, return\n\tif reg.referrerPing(ctx, rSubject) {\n\t\treturn nil\n\t}\n\n\t// fallback to using tag schema for refers\n\trl, err := reg.referrerListTag(ctx, rSubject)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = rl.Delete(m)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// push updated referrer list by tag\n\trlTag, err := referrer.FallbackTag(rSubject)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif rl.IsEmpty() {\n\t\terr = reg.TagDelete(ctx, rlTag)\n\t\tif err == nil {\n\t\t\treturn nil\n\t\t}\n\t\t// if delete is not supported, fall back to pushing empty list\n\t}\n\treturn reg.ManifestPut(ctx, rlTag, rl.Manifest)\n}", "func (b *Backend) ManifestAnnotate(ctx context.Context, req *pb.ManifestAnnotateRequest) (*gogotypes.Empty, error) {\n\tvar emptyResp = &gogotypes.Empty{}\n\n\tif !b.daemon.opts.Experimental {\n\t\treturn emptyResp, errors.New(\"please enable experimental to use manifest feature\")\n\t}\n\n\tlogrus.WithFields(logrus.Fields{\n\t\t\"ManifestList\": req.GetManifestList(),\n\t\t\"Manifest\": req.GetManifest(),\n\t}).Info(\"ManifestAnnotateRequest received\")\n\n\tmanifestName := req.GetManifestList()\n\tmanifestImage := req.GetManifest()\n\timageOS := req.GetOs()\n\timageArch := req.GetArch()\n\timageOSFeature := req.GetOsFeatures()\n\timageVariant := req.GetVariant()\n\n\t// get list image\n\t_, listImage, err := image.FindImage(b.daemon.localStore, manifestName)\n\tif err != nil {\n\t\treturn emptyResp, err\n\t}\n\n\t// load list from list image\n\t_, list, err := loadListFromImage(b.daemon.localStore, listImage.ID)\n\tif err != nil {\n\t\treturn emptyResp, err\n\t}\n\n\t// add image to list, if image already exists, it will be substituted\n\tinstanceDigest, err := list.addImage(ctx, b.daemon.localStore, manifestImage)\n\tif err != nil {\n\t\treturn emptyResp, err\n\t}\n\n\t// modify image platform if user specifies\n\tfor i := range list.docker.Manifests {\n\t\tif list.docker.Manifests[i].Digest == instanceDigest {\n\t\t\tif imageOS != \"\" {\n\t\t\t\tlist.docker.Manifests[i].Platform.OS = imageOS\n\t\t\t}\n\t\t\tif imageArch != \"\" {\n\t\t\t\tlist.docker.Manifests[i].Platform.Architecture = imageArch\n\t\t\t}\n\t\t\tif len(imageOSFeature) > 0 {\n\t\t\t\tlist.docker.Manifests[i].Platform.OSFeatures = append([]string{}, imageOSFeature...)\n\t\t\t}\n\t\t\tif imageVariant != \"\" {\n\t\t\t\tlist.docker.Manifests[i].Platform.Variant = imageVariant\n\t\t\t}\n\t\t}\n\t}\n\n\t// save list to image\n\t_, err = list.saveListToImage(b.daemon.localStore, listImage.ID, \"\", manifest.DockerV2ListMediaType)\n\n\treturn emptyResp, err\n}", "func (mdm *MetaDagModifier) RemoveMetadata(root ipld.Node, metakeys []byte) (ipld.Node, error) {\n\t// Read the existing metadata map.\n\tb, encodedTree, err := util.ReadMetadataListFromDag(mdm.ctx, root, mdm.dagserv, false)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif b == nil {\n\t\treturn nil, errors.New(\"no metadata exists\")\n\t}\n\n\t// Determine the specific scenario.\n\t// Scenario #1:\n\tvar newMetaNode ipld.Node\n\tvar children *ft.DagMetaNodes\n\tvar clear bool\n\tchildren, err = ft.GetChildrenForDagWithMeta(mdm.ctx, root, mdm.dagserv)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif children == nil {\n\t\treturn nil, errors.New(\"expected DAG node with metadata child node\")\n\t}\n\n\t// Create existing map and check with the given key list.\n\tm := make(map[string]interface{})\n\terr = json.Unmarshal(b, &m)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tinputKeys := strings.Split(string(metakeys), \",\")\n\n\texists := util.KeyIntersects(m, inputKeys)\n\tif !exists {\n\t\treturn nil, errors.New(\"no metadata entries with the given keys\")\n\t} else {\n\t\t// Truncate(0) on the metadata sub-DAG.\n\t\terr := mdm.Truncate(0)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// Check if inputM and m have the same key set\n\t\tif util.EqualKeySets(m, inputKeys) {\n\t\t\t// Scenario #1: clear metadata.\n\t\t\tclear = true\n\t\t} else {\n\t\t\t// Scenario #2: delete a subset of the metadata map.\n\t\t\t// iterate the inputKeys to delete each key from the existing map.\n\t\t\tfor _, k := range inputKeys {\n\t\t\t\tdelete(m, k)\n\t\t\t}\n\n\t\t\tb, err = json.Marshal(m)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t// Create a metadata sub-DAG\n\t\t\tnewMetaNode, err = mdm.buildNewMetaDataDag(b, encodedTree)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\tdnode := children.DataNode\n\t// if clear is true, return dnode as root.\n\tif clear {\n\t\treturn dnode, nil\n\t}\n\n\t// Attach the modified metadata sub-DAG to a new root for the BTFS file DAG.\n\tfileSize, err := FileSize(dnode)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tnewRoot, err := mdm.GetDb().AttachMetadataDag(dnode, fileSize, newMetaNode)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tmdm.GetDb().Add(newRoot)\n\n\treturn newRoot, nil\n}", "func (ctrler CtrlDefReactor) OnSnapshotRestoreDelete(obj *SnapshotRestore) error {\n\tlog.Info(\"OnSnapshotRestoreDelete is not implemented\")\n\treturn nil\n}", "func Remove(options types.RemoveOptions, config config.Store) error {\n\tapp := &AppImage{}\n\n\tindexFile := fmt.Sprintf(\"%s.json\", path.Join(config.IndexStore, options.Executable))\n\tlogger.Debugf(\"Checking if %s exists\", indexFile)\n\tif !helpers.CheckIfFileExists(indexFile) {\n\t\tfmt.Printf(\"%s is not installed \\n\", tui.Yellow(options.Executable))\n\t\treturn nil\n\t}\n\n\tbar := tui.NewProgressBar(7, \"r\")\n\n\tlogger.Debugf(\"Unmarshalling JSON from %s\", indexFile)\n\tindexBytes, err := ioutil.ReadFile(indexFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\tbar.Add(1)\n\n\terr = json.Unmarshal(indexBytes, app)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif app.IconPath != \"\" {\n\t\tlogger.Debugf(\"Removing thumbnail, %s\", app.IconPath)\n\t\tos.Remove(app.IconPath)\n\t}\n\tbar.Add(1)\n\n\tif app.IconPathHicolor != \"\" {\n\t\tlogger.Debugf(\"Removing symlink to hicolor theme, %s\", app.IconPathHicolor)\n\t\tos.Remove(app.IconPathHicolor)\n\t}\n\tbar.Add(1)\n\n\tif app.DesktopFile != \"\" {\n\t\tlogger.Debugf(\"Removing desktop file, %s\", app.DesktopFile)\n\t\tos.Remove(app.DesktopFile)\n\t}\n\tbar.Add(1)\n\n\tbinDir := path.Join(xdg.Home, \".local\", \"bin\")\n\tbinFile := path.Join(binDir, options.Executable)\n\n\tif helpers.CheckIfFileExists(binFile) {\n\t\tbinAbsPath, err := filepath.EvalSymlinks(binFile)\n\t\tif err == nil && strings.HasPrefix(binAbsPath, config.LocalStore) {\n\t\t\t// this link points to config.LocalStore, where all AppImages are stored\n\t\t\t// I guess we need to remove them, no asking and all\n\t\t\t// make sure we remove the file first to prevent conflicts in future\n\t\t\t_ = os.Remove(binFile)\n\t\t}\n\t}\n\tbar.Add(1)\n\n\tlogger.Debugf(\"Removing appimage, %s\", app.Filepath)\n\t_ = os.Remove(app.Filepath)\n\tbar.Add(1)\n\n\tlogger.Debugf(\"Removing index file, %s\", indexFile)\n\t_ = os.Remove(indexFile)\n\tbar.Add(1)\n\n\tbar.Finish()\n\tfmt.Printf(\"\\n\")\n\tfmt.Printf(\"✅ %s removed successfully\\n\", app.Executable)\n\tlogger.Debugf(\"Removing all files completed successfully\")\n\n\treturn bar.Finish()\n}", "func (m *Manifest) UnmarshalJSON(data []byte) error {\n\taux := &manifestAux{\n\t\tABI: &m.ABI,\n\t\tTrusts: &m.Trusts,\n\t\tSafeMethods: &m.SafeMethods,\n\t}\n\n\tif err := json.Unmarshal(data, aux); err != nil {\n\t\treturn err\n\t}\n\n\tif aux.Features[\"storage\"] {\n\t\tm.Features |= smartcontract.HasStorage\n\t}\n\tif aux.Features[\"payable\"] {\n\t\tm.Features |= smartcontract.IsPayable\n\t}\n\n\tm.Groups = aux.Groups\n\tm.Permissions = aux.Permissions\n\tm.SupportedStandards = aux.SupportedStandards\n\tm.Extra = aux.Extra\n\n\treturn nil\n}", "func (r *Registry) ImageManifest(image Image, token string) (*ImageManifest, error) {\n\turl := r.GetDigestUrl(image)\n\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.Header.Add(\"Accept\", schema2.MediaTypeManifest)\n\tif token != \"\" {\n\t\treq.Header.Set(\"Authorization\", fmt.Sprintf(\"Bearer %s\", token))\n\t}\n\n\tresp, err := r.Client.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := GetRespBody(resp)\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tif resp.StatusCode == http.StatusNotFound || resp.StatusCode == http.StatusUnauthorized {\n\t\t\tklog.Error(statusUnauthorized)\n\t\t\treturn nil, restful.NewError(resp.StatusCode, statusUnauthorized)\n\t\t}\n\t\tklog.Errorf(\"got response: statusCode is '%d', body is '%s'\\n\", resp.StatusCode, respBody)\n\t\treturn nil, restful.NewError(resp.StatusCode, \"got image manifest failed\")\n\t}\n\n\timageManifest := &ImageManifest{}\n\terr = json.Unmarshal(respBody, imageManifest)\n\n\treturn imageManifest, err\n}", "func AppDeleteHandler(context utils.Context, w http.ResponseWriter, r *http.Request) {\n\n\tdbConn := context.DBConn\n\tdbBucket := context.DBBucketApp\n\n\tvars := mux.Vars(r)\n\n\tenv := vars[\"environment\"]\n\tapp := vars[\"application\"]\n\n\tkey := []byte(env + \"_\" + app)\n\n\tif err := database.DeleteDBValue(dbConn, dbBucket, key); err != nil {\n\t\tlog.LogInfo.Printf(\"Failed to read db value: %v\", err)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusOK)\n\tw.Write([]byte(\"200 - OK: valued deleted or was not found\"))\n\n}", "func (follower *Follower) OnDelete(m *Message, w io.Writer) (err error) {\n\tfollower.mutex.Lock()\n\tdelete(follower.table, m.GetKey())\n\tfollower.mutex.Unlock()\n\n\tlog.Printf(\"Table after Delete: %v\\n\", follower.table)\n\treturn nil\n}", "func (ms *schema2ManifestHandler) verifyManifest(ctx context.Context, mnfst schema2.DeserializedManifest, skipDependencyVerification bool) error {\n\tvar errs distribution.ErrManifestVerification\n\n\tif mnfst.Manifest.SchemaVersion != 2 {\n\t\treturn fmt.Errorf(\"unrecognized manifest schema version %d\", mnfst.Manifest.SchemaVersion)\n\t}\n\n\tif skipDependencyVerification {\n\t\treturn nil\n\t}\n\n\tmanifestService, err := ms.repository.Manifests(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tblobsService := ms.repository.Blobs(ctx)\n\n\tfor _, descriptor := range mnfst.References() {\n\t\tvar err error\n\n\t\tswitch descriptor.MediaType {\n\t\tcase schema2.MediaTypeForeignLayer:\n\t\t\t// Clients download this layer from an external URL, so do not check for\n\t\t\t// its presence.\n\t\t\tif len(descriptor.URLs) == 0 {\n\t\t\t\terr = errMissingURL\n\t\t\t}\n\t\t\tallow := ms.manifestURLs.allow\n\t\t\tdeny := ms.manifestURLs.deny\n\t\t\tfor _, u := range descriptor.URLs {\n\t\t\t\tvar pu *url.URL\n\t\t\t\tpu, err = url.Parse(u)\n\t\t\t\tif err != nil || (pu.Scheme != \"http\" && pu.Scheme != \"https\") || pu.Fragment != \"\" || (allow != nil && !allow.MatchString(u)) || (deny != nil && deny.MatchString(u)) {\n\t\t\t\t\terr = errInvalidURL\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\tcase schema2.MediaTypeManifest, schema1.MediaTypeManifest:\n\t\t\tvar exists bool\n\t\t\texists, err = manifestService.Exists(ctx, descriptor.Digest)\n\t\t\tif err != nil || !exists {\n\t\t\t\terr = distribution.ErrBlobUnknown // just coerce to unknown.\n\t\t\t}\n\n\t\t\tfallthrough // double check the blob store.\n\t\tdefault:\n\t\t\t// forward all else to blob storage\n\t\t\tif len(descriptor.URLs) == 0 {\n\t\t\t\t_, err = blobsService.Stat(ctx, descriptor.Digest)\n\t\t\t}\n\t\t}\n\n\t\tif err != nil {\n\t\t\tif err != distribution.ErrBlobUnknown {\n\t\t\t\terrs = append(errs, err)\n\t\t\t}\n\n\t\t\t// On error here, we always append unknown blob errors.\n\t\t\terrs = append(errs, distribution.ErrManifestBlobUnknown{Digest: descriptor.Digest})\n\t\t}\n\t}\n\n\tif len(errs) != 0 {\n\t\treturn errs\n\t}\n\n\treturn nil\n}", "func (es *EventSyncer) handleDeleteEvent(obj interface{}) {\n\tevent, ok := obj.(*corev1.Event)\n\tif !ok {\n\t\ttombstone, ok := obj.(cache.DeletedFinalStateUnknown)\n\t\tif !ok {\n\t\t\tklog.Errorf(\"Couldn't get object from tombstone %v\", obj)\n\t\t\treturn\n\t\t}\n\t\tevent, ok = tombstone.Obj.(*corev1.Event)\n\t\tif !ok {\n\t\t\tklog.Errorf(\"Tombstone contained object that is not a event %v\", obj)\n\t\t\treturn\n\t\t}\n\t}\n\n\tes.addKindAndVersion(event)\n\n\tgo syncToNode(watch.Deleted, util.ResourceEvent, event)\n\n\tsyncToStorage(es.ctx, watch.Deleted, util.ResourceEvent, event)\n}", "func (o *OCIDir) referrerDelete(ctx context.Context, r ref.Ref, m manifest.Manifest) error {\n\t// get refers field\n\tmSubject, ok := m.(manifest.Subjecter)\n\tif !ok {\n\t\treturn fmt.Errorf(\"manifest does not support subject: %w\", types.ErrUnsupportedMediaType)\n\t}\n\tsubject, err := mSubject.GetSubject()\n\tif err != nil {\n\t\treturn err\n\t}\n\t// validate/set subject descriptor\n\tif subject == nil || subject.MediaType == \"\" || subject.Digest == \"\" || subject.Size <= 0 {\n\t\treturn fmt.Errorf(\"subject is not set%.0w\", types.ErrNotFound)\n\t}\n\n\t// get descriptor for subject\n\trSubject := r\n\trSubject.Tag = \"\"\n\trSubject.Digest = subject.Digest.String()\n\n\t// pull existing referrer list\n\trl, err := o.ReferrerList(ctx, rSubject)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = rl.Delete(m)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// push updated referrer list by tag\n\trlTag, err := referrer.FallbackTag(rSubject)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif rl.IsEmpty() {\n\t\terr = o.TagDelete(ctx, rlTag)\n\t\tif err == nil {\n\t\t\treturn nil\n\t\t}\n\t\t// if delete is not supported, fall back to pushing empty list\n\t}\n\treturn o.ManifestPut(ctx, rlTag, rl.Manifest)\n}", "func (c *Controller) onDelete(obj interface{}) {\n\t//cluster := obj.(*crv1.Pgcluster)\n\t//\tlog.Debugf(\"[Controller] ns=%s onDelete %s\", cluster.ObjectMeta.Namespace, cluster.ObjectMeta.SelfLink)\n\n\t//handle pgcluster cleanup\n\t//\tclusteroperator.DeleteClusterBase(c.PgclusterClientset, c.PgclusterClient, cluster, cluster.ObjectMeta.Namespace)\n}", "func UploadManifest(ctx context.Context, repo distribution.Repository, tag string, manifest distribution.Manifest) error {\n\tcanonical, err := CanonicalManifest(manifest)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tms, err := repo.Manifests(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get manifest service for %s: %w\", repo.Named(), err)\n\t}\n\n\tdgst, err := ms.Put(ctx, manifest, distribution.WithTag(tag))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to upload manifest to %s: %w\", repo.Named(), err)\n\t}\n\n\tif expectedDgst := digest.FromBytes(canonical); dgst != expectedDgst {\n\t\treturn fmt.Errorf(\"upload manifest to %s failed: digest mismatch: got %s, want %s\", repo.Named(), dgst, expectedDgst)\n\t}\n\n\treturn nil\n}", "func (d *DataPolicyManifest) UnmarshalJSON(data []byte) error {\n\tvar rawMsg map[string]json.RawMessage\n\tif err := json.Unmarshal(data, &rawMsg); err != nil {\n\t\treturn fmt.Errorf(\"unmarshalling type %T: %v\", d, err)\n\t}\n\tfor key, val := range rawMsg {\n\t\tvar err error\n\t\tswitch key {\n\t\tcase \"id\":\n\t\t\terr = unpopulate(val, \"ID\", &d.ID)\n\t\t\tdelete(rawMsg, key)\n\t\tcase \"name\":\n\t\t\terr = unpopulate(val, \"Name\", &d.Name)\n\t\t\tdelete(rawMsg, key)\n\t\tcase \"properties\":\n\t\t\terr = unpopulate(val, \"Properties\", &d.Properties)\n\t\t\tdelete(rawMsg, key)\n\t\tcase \"type\":\n\t\t\terr = unpopulate(val, \"Type\", &d.Type)\n\t\t\tdelete(rawMsg, key)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unmarshalling type %T: %v\", d, err)\n\t\t}\n\t}\n\treturn nil\n}", "func (manager *Manager) onDeleteEgressPolicy(policy *Policy) {\n\tconfigID := ParseCEGPConfigID(policy)\n\n\tmanager.Lock()\n\tdefer manager.Unlock()\n\n\tlogger := log.WithField(logfields.CiliumEgressGatewayPolicyName, configID.Name)\n\n\tif manager.policyConfigs[configID] == nil {\n\t\tlogger.Warn(\"Can't delete CiliumEgressGatewayPolicy: policy not found\")\n\t}\n\n\tlogger.Debug(\"Deleted CiliumEgressGatewayPolicy\")\n\n\tdelete(manager.policyConfigs, configID)\n\n\tmanager.setEventBitmap(eventDeletePolicy)\n\tmanager.reconciliationTrigger.TriggerWithReason(\"policy deleted\")\n}", "func (am *ArtifactMap) DeleteApp(AppGUID string) {\n\tvar desiredApp *ArtifactEntry\n\tindex := 0\n\tfor i, app := range am.AppList {\n\t\tif app.GUID == AppGUID {\n\t\t\tdesiredApp = app\n\t\t\tindex = i\n\t\t\tbreak\n\t\t}\n\t}\n\tif desiredApp != nil {\n\t\tam.AppList = append(am.AppList[:index], am.AppList[index+1:]...)\n\t\tam.appTitleToID.Delete(desiredApp.Title)\n\t\tam.appTitleToItemID.Delete(desiredApp.Title)\n\t}\n}", "func (sm *stateMachine) OnDelete(key string) {\n\tif !sm.running.Load() {\n\t\tsm.logger.Warn(\"state machine is stopped\",\n\t\t\tlogger.String(\"type\", sm.stateMachineType.String()))\n\t\treturn\n\t}\n\tsm.logger.Info(\"discovery state removed\",\n\t\tlogger.String(\"type\", sm.stateMachineType.String()),\n\t\tlogger.String(\"key\", key))\n\tif sm.onDeleteFn != nil {\n\t\tsm.onDeleteFn(key)\n\t}\n}", "func ConvertManifest(ctx context.Context, store content.Store, desc ocispec.Descriptor) (ocispec.Descriptor, error) {\n\tif !(desc.MediaType == images.MediaTypeDockerSchema2Manifest ||\n\t\tdesc.MediaType == ocispec.MediaTypeImageManifest) {\n\n\t\tlog.G(ctx).Warnf(\"do nothing for media type: %s\", desc.MediaType)\n\t\treturn desc, nil\n\t}\n\n\t// read manifest data\n\tmb, err := content.ReadBlob(ctx, store, desc)\n\tif err != nil {\n\t\treturn ocispec.Descriptor{}, fmt.Errorf(\"failed to read index data: %w\", err)\n\t}\n\n\tvar manifest ocispec.Manifest\n\tif err := json.Unmarshal(mb, &manifest); err != nil {\n\t\treturn ocispec.Descriptor{}, fmt.Errorf(\"failed to unmarshal data into manifest: %w\", err)\n\t}\n\n\t// check config media type\n\tif manifest.Config.MediaType != LegacyConfigMediaType {\n\t\treturn desc, nil\n\t}\n\n\tmanifest.Config.MediaType = images.MediaTypeDockerSchema2Config\n\tdata, err := json.MarshalIndent(manifest, \"\", \" \")\n\tif err != nil {\n\t\treturn ocispec.Descriptor{}, fmt.Errorf(\"failed to marshal manifest: %w\", err)\n\t}\n\n\t// update manifest with gc labels\n\tdesc.Digest = digest.Canonical.FromBytes(data)\n\tdesc.Size = int64(len(data))\n\n\tlabels := map[string]string{}\n\tfor i, c := range append([]ocispec.Descriptor{manifest.Config}, manifest.Layers...) {\n\t\tlabels[fmt.Sprintf(\"containerd.io/gc.ref.content.%d\", i)] = c.Digest.String()\n\t}\n\n\tref := remotes.MakeRefKey(ctx, desc)\n\tif err := content.WriteBlob(ctx, store, ref, bytes.NewReader(data), desc, content.WithLabels(labels)); err != nil {\n\t\treturn ocispec.Descriptor{}, fmt.Errorf(\"failed to update content: %w\", err)\n\t}\n\treturn desc, nil\n}", "func (c *Controller) syncHandler(key string) error {\n\t// If an error occurs during handling, we'll requeue the item so we can\n\t// attempt processing again later. This could have been caused by a\n\t// temporary network failure, or any other transient reason.\n\n\t// Convert the namespace/name string into a distinct namespace and name\n\tns, name, err := cache.SplitMetaNamespaceKey(key)\n\tif err != nil {\n\t\tutilruntime.HandleError(fmt.Errorf(\"invalid resource key: %s\", key))\n\t\treturn nil\n\t}\n\n\tklog.V(4).Infof(\"start processing Manifest %q\", key)\n\t// Get the Manifest resource with this name\n\tmanifest, err := c.manifestLister.Manifests(ns).Get(name)\n\t// The Manifest resource may no longer exist, in which case we stop processing.\n\tif errors.IsNotFound(err) {\n\t\tklog.V(2).Infof(\"Manifest %q has been deleted\", key)\n\t\treturn nil\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif manifest.Template.Raw == nil {\n\t\tklog.Warning(\"manifest.Template.Raw is empty, %q\", klog.KObj(manifest))\n\t\treturn nil\n\t}\n\tutd := &unstructured.Unstructured{}\n\terr = json.Unmarshal(manifest.Template.Raw, &utd.Object)\n\tif err != nil {\n\t\tklog.Errorf(\"unmarshal error, %q, err=%v\", klog.KObj(manifest), err)\n\t\treturn err\n\t}\n\n\tresourceKind := utd.GroupVersionKind().Kind\n\n\tmatchAnnotations := util.FindAnnotationsMathKeyPrefix(utd.GetAnnotations())\n\t//为空则表示在update时候进行过更新,清除过annotation\n\tdeleteSubscription := len(matchAnnotations) == 0\n\tif manifest.DeletionTimestamp != nil {\n\t\t//删除\n\t\tdeleteSubscription = true\n\t}\n\tmatchLabels := map[string]string{\n\t\t\"bkbcs.tencent.com/resource-kind\": resourceKind,\n\t\t\"bkbcs.tencent.com/resource-ns\": utd.GetNamespace(),\n\t\t\"bkbcs.tencent.com/resource-name\": utd.GetName(),\n\t}\n\tsubscriptionName := c.genAutoCreateSubscriptionName(utd.GetName())\n\n\tsubscriptionList, err := c.clusternetClient.AppsV1alpha1().Subscriptions(utd.GetNamespace()).List(context.Background(), metav1.ListOptions{\n\t\tLabelSelector: labels.Set(matchLabels).String(),\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\t//只会存在0个或1个\n\tif len(subscriptionList.Items) > 1 {\n\t\treturn fmt.Errorf(\"auto create sub matchLabels match %d\", len(subscriptionList.Items))\n\t}\n\tif deleteSubscription {\n\t\tklog.Infof(\"start delete subscription %s\", subscriptionName)\n\t\t//删除Subscription\n\t\terr = c.clusternetClient.AppsV1alpha1().Subscriptions(utd.GetNamespace()).Delete(context.Background(), subscriptionList.Items[0].Name, metav1.DeleteOptions{})\n\t\tif errors.IsNotFound(err) {\n\t\t\tklog.V(2).Infof(\"Subscription %s:%s has been deleted\", ns, name)\n\t\t\treturn nil\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\t//更新或创建Subscription\n\tif len(subscriptionList.Items) == 0 {\n\t\t//create\n\t\tsubscription := &appsapi.Subscription{\n\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\tName: subscriptionName,\n\t\t\t\tNamespace: utd.GetNamespace(),\n\t\t\t\tAnnotations: map[string]string{\n\t\t\t\t\t\"bkbcs.tencent.com/created-by\": \"bcs-clusternet-controller\",\n\t\t\t\t},\n\t\t\t\tLabels: matchLabels,\n\t\t\t},\n\t\t\tSpec: c.genSubscriptionSpec(matchAnnotations, utd.GroupVersionKind(), utd.GetNamespace(), utd.GetName()),\n\t\t}\n\t\tklog.Infof(\"start create Subscriptions %q\", klog.KObj(subscription))\n\t\t_, err = c.clusternetClient.AppsV1alpha1().Subscriptions(utd.GetNamespace()).Create(context.Background(), subscription, metav1.CreateOptions{})\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"create Subscriptions %q error, err=%+v\", klog.KObj(subscription), err)\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\t//update\n\tmatchSubscription := subscriptionList.Items[0]\n\tmatchSubscription.Spec = c.genSubscriptionSpec(matchAnnotations, utd.GroupVersionKind(), utd.GetNamespace(), utd.GetName())\n\tklog.Infof(\"start update Subscriptions %q\", klog.KObj(&matchSubscription))\n\t_, err = c.clusternetClient.AppsV1alpha1().Subscriptions(utd.GetNamespace()).Update(context.Background(), &matchSubscription, metav1.UpdateOptions{})\n\tif err != nil {\n\t\tklog.Errorf(\"update subscriptions %q error, err=%v\", klog.KObj(&matchSubscription), err)\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m *SGController) onSgDeleted(sg *v1alpha1.Statefulguardian) {\n\tglog.Infof(\"Cluster %s deleted\", sg.Name)\n\texecCont:= NewExecController(sg)\n execCont.ClusterQuit(m.ctx)\n\tmetrics.IncEventCounter(sgsDeletedCount)\n\tmetrics.DecEventGauge(sgsTotalCount)\n\tglog.Infof(\"Delete statefulset\")\n\tm.statefulSetControl.DeleteStatefulSet(sg)\n}", "func (m *BoltMeta) Delete(key []byte) error {\n\terr := m.DS.Update(func(tx *bolt.Tx) error {\n\t\tbucket, err := tx.CreateBucketIfNotExists(m.MetadataBucket)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = bucket.Delete(key)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n\n\treturn err\n}", "func RegisterManifestHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {\n\treturn RegisterManifestHandlerClient(ctx, mux, NewManifestClient(conn))\n}", "func UpdateManifest(m Manifests, root string, serviceID flux.ResourceID, f func(manifest []byte) ([]byte, error)) error {\n\tservices, err := m.FindDefinedServices(root)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpaths := services[serviceID]\n\tif len(paths) == 0 {\n\t\treturn ErrNoResourceFilesFoundForService\n\t}\n\tif len(paths) > 1 {\n\t\treturn ErrMultipleResourceFilesFoundForService\n\t}\n\n\tdef, err := ioutil.ReadFile(paths[0])\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tnewDef, err := f(def)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfi, err := os.Stat(paths[0])\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(paths[0], newDef, fi.Mode())\n}", "func (s *MetalLBSpeaker) OnDeleteService(svc *slim_corev1.Service) error {\n\tif s.shutDown() {\n\t\treturn ErrShutDown\n\t}\n\tvar (\n\t\tsvcID = k8s.ParseServiceID(svc)\n\t\tl = log.WithFields(logrus.Fields{\n\t\t\t\"component\": \"MetalLBSpeaker.OnDeleteService\",\n\t\t\t\"service-id\": svcID,\n\t\t})\n\t\tmeta = fence.Meta{}\n\t)\n\n\ts.Lock()\n\tdelete(s.services, svcID)\n\ts.Unlock()\n\n\tif err := meta.FromObjectMeta(&svc.ObjectMeta); err != nil {\n\t\tl.WithError(err).Error(\"failed to parse event metadata\")\n\t}\n\n\tl.Debug(\"adding event to queue\")\n\t// Passing nil as the service will force the MetalLB speaker to withdraw\n\t// the BGP announcement.\n\ts.queue.Add(svcEvent{\n\t\tMeta: meta,\n\t\top: Delete,\n\t\tid: svcID,\n\t\tsvc: nil,\n\t\teps: nil,\n\t})\n\treturn nil\n}", "func (ctrler CtrlDefReactor) OnConfigurationSnapshotDelete(obj *ConfigurationSnapshot) error {\n\tlog.Info(\"OnConfigurationSnapshotDelete is not implemented\")\n\treturn nil\n}", "func (m *Manifest) Unarchive(id uuid.UUID, txes ...*sqlx.Tx) (*db.Manifest, error) {\n\tconn := prepConn(m.Conn, txes...)\n\n\tu, err := db.FindManifest(conn, id.String())\n\tif err != nil {\n\t\treturn nil, terror.New(err, \"\")\n\t}\n\n\tif !u.Archived {\n\t\treturn u, nil\n\t}\n\n\tu.Archived = false\n\tu.ArchivedAt = null.TimeFromPtr(nil)\n\t_, err = u.Update(conn, boil.Whitelist(db.ManifestColumns.Archived, db.ManifestColumns.ArchivedAt))\n\tif err != nil {\n\t\treturn nil, terror.New(err, \"\")\n\t}\n\treturn u, nil\n}", "func TestSwizzlerRemoveMetadata(t *testing.T) {\n\tf, origMeta := createNewSwizzler(t)\n\n\tf.RemoveMetadata(\"targets/a\")\n\n\tfor role, metaBytes := range origMeta {\n\t\tnewMeta, err := f.MetadataCache.GetSized(role.String(), store.NoSizeLimit)\n\t\tif role != \"targets/a\" {\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.True(t, bytes.Equal(metaBytes, newMeta), \"bytes have changed for role %s\", role)\n\t\t} else {\n\t\t\trequire.Error(t, err)\n\t\t\trequire.IsType(t, store.ErrMetaNotFound{}, err)\n\t\t}\n\t}\n}", "func jsonDeleteHandler(w http.ResponseWriter, r *http.Request) {\n\trunID := r.FormValue(\"runID\")\n\n\t// Extract the username from the runID and the cookie to make sure they match.\n\trunUser := strings.Split(runID, \"-\")[0]\n\tloggedInUser := strings.Split(login.LoggedInAs(r), \"@\")[0]\n\tif !login.IsAdmin(r) && runUser != loggedInUser {\n\t\thttputils.ReportError(w, r, nil, \"You must be logged on as an admin to delete other users' runs.\")\n\t\treturn\n\t}\n\n\t// Remove ResultStore data.\n\terr := resultStore.RemoveRun(runID)\n\tif err != nil {\n\t\thttputils.ReportError(w, r, err, fmt.Sprintf(\"Failed to remove run %s from server\", runID))\n\t\treturn\n\t}\n\n\t// TODO(lchoi): Create a storage container class that has an aggregate remove\n\t// function and call that here to simplify the handler logic. PurgeDigests in\n\t// MemDiffStore must first be refactored to also remove diff images.\n\n\t// Remove screenshots and diff images from the DiffStore.\n\timagePath := filepath.Join(*imageDir, diffstore.DEFAULT_IMG_DIR_NAME, runID)\n\tdiffPath := filepath.Join(*imageDir, diffstore.DEFAULT_DIFFIMG_DIR_NAME, runID)\n\terr = os.RemoveAll(imagePath)\n\tif err != nil {\n\t\thttputils.ReportError(w, r, err, fmt.Sprintf(\"Failed to remove screenshots for run %s from DiffStore\", runID))\n\t\treturn\n\t}\n\terr = os.RemoveAll(diffPath)\n\tif err != nil {\n\t\thttputils.ReportError(w, r, err, fmt.Sprintf(\"Failed to remove diff images for run %s from DiffStore\", runID))\n\t\treturn\n\t}\n}", "func (m *manifestService) Put(ctx context.Context, manifest distribution.Manifest, options ...distribution.ManifestServiceOption) (digest.Digest, error) {\n\tcontext.GetLogger(ctx).Debugf(\"(*manifestService).Put\")\n\n\tmh, err := NewManifestHandler(m.repo, manifest)\n\tif err != nil {\n\t\treturn \"\", regapi.ErrorCodeManifestInvalid.WithDetail(err)\n\t}\n\tmediaType, payload, _, err := mh.Payload()\n\tif err != nil {\n\t\treturn \"\", regapi.ErrorCodeManifestInvalid.WithDetail(err)\n\t}\n\n\t// this is fast to check, let's do it before verification\n\tif !m.acceptschema2 && mediaType == schema2.MediaTypeManifest {\n\t\treturn \"\", regapi.ErrorCodeManifestInvalid.WithDetail(fmt.Errorf(\"manifest V2 schema 2 not allowed\"))\n\t}\n\n\t// in order to stat the referenced blobs, repository need to be set on the context\n\tif err := mh.Verify(withRepository(ctx, m.repo), false); err != nil {\n\t\treturn \"\", err\n\t}\n\n\t_, err = m.manifests.Put(withRepository(ctx, m.repo), manifest, options...)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tconfig, err := mh.Config(ctx)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tdgst, err := mh.Digest()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Upload to openshift\n\tism := imageapiv1.ImageStreamMapping{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tNamespace: m.repo.namespace,\n\t\t\tName: m.repo.name,\n\t\t},\n\t\tImage: imageapiv1.Image{\n\t\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\t\tName: dgst.String(),\n\t\t\t\tAnnotations: map[string]string{\n\t\t\t\t\timageapi.ManagedByOpenShiftAnnotation: \"true\",\n\t\t\t\t\timageapi.ImageManifestBlobStoredAnnotation: \"true\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tDockerImageReference: fmt.Sprintf(\"%s/%s/%s@%s\", m.repo.config.registryAddr, m.repo.namespace, m.repo.name, dgst.String()),\n\t\t\tDockerImageManifest: string(payload),\n\t\t\tDockerImageManifestMediaType: mediaType,\n\t\t\tDockerImageConfig: string(config),\n\t\t},\n\t}\n\n\tfor _, option := range options {\n\t\tif opt, ok := option.(distribution.WithTagOption); ok {\n\t\t\tism.Tag = opt.Tag\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif _, err = m.repo.registryOSClient.ImageStreamMappings(m.repo.namespace).Create(&ism); err != nil {\n\t\t// if the error was that the image stream wasn't found, try to auto provision it\n\t\tstatusErr, ok := err.(*kerrors.StatusError)\n\t\tif !ok {\n\t\t\tcontext.GetLogger(ctx).Errorf(\"error creating ImageStreamMapping: %s\", err)\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tif quotautil.IsErrorQuotaExceeded(statusErr) {\n\t\t\tcontext.GetLogger(ctx).Errorf(\"denied creating ImageStreamMapping: %v\", statusErr)\n\t\t\treturn \"\", distribution.ErrAccessDenied\n\t\t}\n\n\t\tstatus := statusErr.ErrStatus\n\t\tkind := strings.ToLower(status.Details.Kind)\n\t\tisValidKind := kind == \"imagestream\" /*pre-1.2*/ || kind == \"imagestreams\" /*1.2 to 1.6*/ || kind == \"imagestreammappings\" /*1.7+*/\n\t\tif !isValidKind || status.Code != http.StatusNotFound || status.Details.Name != m.repo.name {\n\t\t\tcontext.GetLogger(ctx).Errorf(\"error creating ImageStreamMapping: %s\", err)\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tif _, err := m.repo.createImageStream(ctx); err != nil {\n\t\t\tif e, ok := err.(errcode.Error); ok && e.ErrorCode() == errcode.ErrorCodeUnknown {\n\t\t\t\t// TODO: convert statusErr to distribution error\n\t\t\t\treturn \"\", statusErr\n\t\t\t}\n\t\t\treturn \"\", err\n\t\t}\n\n\t\t// try to create the ISM again\n\t\tif _, err := m.repo.registryOSClient.ImageStreamMappings(m.repo.namespace).Create(&ism); err != nil {\n\t\t\tif quotautil.IsErrorQuotaExceeded(err) {\n\t\t\t\tcontext.GetLogger(ctx).Errorf(\"denied a creation of ImageStreamMapping: %v\", err)\n\t\t\t\treturn \"\", distribution.ErrAccessDenied\n\t\t\t}\n\t\t\tcontext.GetLogger(ctx).Errorf(\"error creating ImageStreamMapping: %s\", err)\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\treturn dgst, nil\n}", "func (bot *bot) onGuildDelete(s *discordgo.Session, msg *discordgo.GuildDelete) {\n\tbot.logger.Debugf(\"Got GuildDelete event: %s\", msg.ID)\n\tbot.removeGuildChannels(guildID(msg.ID))\n}", "func deleteAppConfigHandler(ctx *gin.Context) {\n log.Info(fmt.Sprintf(\"received request to delete config %s\", ctx.Param(\"appId\")))\n\n // get app ID from path and convert to UUID\n appId, err := uuid.Parse(ctx.Param(\"appId\"))\n if err != nil {\n log.Error(fmt.Errorf(\"unable to app ID: %+v\", err))\n ctx.JSON(http.StatusBadRequest, gin.H{\n \"status_code\": http.StatusBadRequest, \"message\": \"Invalid app ID\"})\n return\n }\n\n db, _ := ctx.MustGet(\"db\").(*Persistence)\n _, err = db.GetConfigByAppId(appId)\n if err != nil {\n switch err {\n case ErrAppNotFound:\n log.Warn(fmt.Sprintf(\"cannot find config for app %s\", appId))\n ctx.JSON(http.StatusNotFound, gin.H{\n \"http_code\": http.StatusNotFound, \"message\": \"Cannot find config for app\"})\n default:\n log.Error(fmt.Errorf(\"unable to retrieve config from database: %+v\", err))\n ctx.JSON(http.StatusInternalServerError, gin.H{\n \"http_code\": http.StatusInternalServerError, \"message\": \"Internal server error\"})\n }\n return\n }\n\n if err := db.DeleteConfigByAppId(appId); err != nil {\n log.Error(fmt.Errorf(\"unable to delete config: %+v\", err))\n ctx.JSON(http.StatusInternalServerError, gin.H{\n \"http_code\": http.StatusInternalServerError, \"message\": \"Internal server error\"})\n return\n }\n ctx.JSON(http.StatusOK, gin.H{\n \"http_code\": http.StatusOK, \"message\": \"Successfully delete config\"})\n}", "func (i *IpScheduler) OnDelete(del interface{}) {\n\tdelPod, ok := del.(*v1.Pod)\n\tif !ok {\n\t\treturn\n\t}\n\tif delPod.GetNamespace() == \"bcs-system\" {\n\t\treturn\n\t}\n\tblog.Infof(\"pod %s/%s is deletd\", delPod.GetName(), delPod.GetNamespace())\n\ti.CacheLock.Lock()\n\ti.NodeIPCache.DeleteResource(cache.GetMetaKey(delPod.GetName(), delPod.GetNamespace()))\n\ti.CacheLock.Unlock()\n}", "func UpdateManifest(m Manifests, root string, paths []string, id flux.ResourceID, f func(manifest []byte) ([]byte, error)) error {\n\tresources, err := m.LoadManifests(root, paths)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresource, ok := resources[id.String()]\n\tif !ok {\n\t\treturn ErrResourceNotFound(id.String())\n\t}\n\n\tpath := filepath.Join(root, resource.Source())\n\tdef, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tnewDef, err := f(def)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfi, err := os.Stat(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(path, newDef, fi.Mode())\n}", "func cleanupManifest(origData, finalData []byte) ([]byte, error) {\n\tobjectMetacreationTs := []byte(\"\\n creationTimestamp: null\\n\")\n\tspecTemplatecreationTs := []byte(\"\\n creationTimestamp: null\\n\")\n\tjobSpecTemplatecreationTs := []byte(\"\\n creationTimestamp: null\\n\")\n\tnullStatus := []byte(\"\\nstatus: {}\\n\")\n\tnullReplicaStatus := []byte(\"status:\\n replicas: 0\\n\")\n\tnullLBStatus := []byte(\"status:\\n loadBalancer: {}\\n\")\n\tnullMetaStatus := []byte(\"\\n status: {}\\n\")\n\n\tvar hasObjectMetacreationTs, hasSpecTemplatecreationTs, hasJobSpecTemplatecreationTs, hasNullStatus,\n\t\thasNullReplicaStatus, hasNullLBStatus, hasNullMetaStatus bool\n\n\tif origData != nil {\n\t\thasObjectMetacreationTs = bytes.Contains(origData, objectMetacreationTs)\n\t\thasSpecTemplatecreationTs = bytes.Contains(origData, specTemplatecreationTs)\n\t\thasJobSpecTemplatecreationTs = bytes.Contains(origData, jobSpecTemplatecreationTs)\n\n\t\thasNullStatus = bytes.Contains(origData, nullStatus)\n\t\thasNullReplicaStatus = bytes.Contains(origData, nullReplicaStatus)\n\t\thasNullLBStatus = bytes.Contains(origData, nullLBStatus)\n\t\thasNullMetaStatus = bytes.Contains(origData, nullMetaStatus)\n\t} // null value is false in case of origFile\n\n\tif !hasObjectMetacreationTs {\n\t\tfinalData = bytes.Replace(finalData, objectMetacreationTs, []byte(\"\\n\"), -1)\n\t}\n\tif !hasSpecTemplatecreationTs {\n\t\tfinalData = bytes.Replace(finalData, specTemplatecreationTs, []byte(\"\\n\"), -1)\n\t}\n\tif !hasJobSpecTemplatecreationTs {\n\t\tfinalData = bytes.Replace(finalData, jobSpecTemplatecreationTs, []byte(\"\\n\"), -1)\n\t}\n\tif !hasNullStatus {\n\t\tfinalData = bytes.Replace(finalData, nullStatus, []byte(\"\\n\"), -1)\n\t}\n\tif !hasNullReplicaStatus {\n\t\tfinalData = bytes.Replace(finalData, nullReplicaStatus, []byte(\"\\n\"), -1)\n\t}\n\tif !hasNullLBStatus {\n\t\tfinalData = bytes.Replace(finalData, nullLBStatus, []byte(\"\\n\"), -1)\n\t}\n\tif !hasNullMetaStatus {\n\t\tfinalData = bytes.Replace(finalData, nullMetaStatus, []byte(\"\\n\"), -1)\n\t}\n\n\treturn finalData, nil\n}", "func TriggerPostDelete(appName string) error {\n\tif err := common.PropertyDestroy(\"apps\", appName); err != nil {\n\t\tcommon.LogWarn(err.Error())\n\t}\n\n\treturn nil\n}", "func Delete(config Config, plugin plugins.PluginSpec) error {\n\treturn handleYaml(config, delete, plugin)\n}", "func (c *Config) handleActionDeleteMessage(client MQTT.Client, message MQTT.Message) {\n\tactionsToBeDeleted := []actionmanager.Action{}\n\terr := json.Unmarshal(message.Payload(), &actionsToBeDeleted)\n\tif err != nil {\n\t\tklog.Errorf(\"Error in unmarshalling: %s\", err)\n\t}\n\tfor _, actionToBeDeleted := range actionsToBeDeleted {\n\t\tactionExists := false\n\t\tfor index, action := range c.ActionManager.Actions {\n\t\t\tif strings.EqualFold(action.Name, actionToBeDeleted.Name) {\n\t\t\t\tactionExists = true\n\t\t\t\tcopy(c.ActionManager.Actions[index:], c.ActionManager.Actions[index+1:])\n\t\t\t\tc.ActionManager.Actions = c.ActionManager.Actions[:len(c.ActionManager.Actions)-1]\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tconfiguration.Config.ActionManager = c.ActionManager\n\t\tif !actionExists {\n\t\t\tklog.Errorf(\"Action: %s did not exist\", actionToBeDeleted.Name)\n\t\t} else {\n\t\t\tklog.Infof(\"Action: %s has been deleted \", actionToBeDeleted.Name)\n\t\t}\n\t}\n}", "func (p *PCache) Delete(kind string, in interface{}) error {\n\t// Deletes from cache and statemgr\n\tobj, err := runtime.GetObjectMeta(in)\n\tkey := obj.GetKey()\n\tif err != nil {\n\t\treturn fmt.Errorf((\"Object is not an apiserver object\"))\n\t}\n\tp.Log.Debugf(\"delete for %s %s\", kind, key)\n\n\terr = p.DeletePcache(kind, in)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tp.RLock()\n\tkindInfo := p.kindOptsMap[kind]\n\tp.RUnlock()\n\n\tif kindInfo.WriteToApiserver {\n\t\tp.Log.Debugf(\"%s %s attempting to delete from statemgr\", kind, key)\n\t\treturn p.deleteStatemgr(in, kindInfo)\n\t}\n\treturn nil\n}", "func TriggerPostDelete(appName string) error {\n\treturn common.PropertyDestroy(\"registry\", appName)\n}", "func ExtractKindFromManifest(manifest string) string {\n\tre := regexp.MustCompile(kindRegex)\n\tmatches := re.FindStringSubmatch(manifest)\n\n\tif len(matches) > 0 {\n\t\treturn matches[1]\n\t}\n\n\treturn \"\"\n}", "func (t *targetrunner) receiveBucketMD(newbucketmd *bucketMD, msg *ActionMsg) (errstr string) {\n\tif msg.Action == \"\" {\n\t\tglog.Infof(\"receive bucket-metadata: version %d\", newbucketmd.version())\n\t} else {\n\t\tglog.Infof(\"receive bucket-metadata: version %d, message %+v\", newbucketmd.version(), msg)\n\t}\n\tt.bmdowner.Lock()\n\tbucketmd := t.bmdowner.get()\n\tmyver := bucketmd.version()\n\tif newbucketmd.version() <= myver {\n\t\tt.bmdowner.Unlock()\n\t\tif newbucketmd.version() < myver {\n\t\t\terrstr = fmt.Sprintf(\"Attempt to downgrade bucket-metadata version %d to %d\", myver, newbucketmd.version())\n\t\t}\n\t\treturn\n\t}\n\tt.bmdowner.put(newbucketmd)\n\tt.bmdowner.Unlock()\n\n\tfor bucket := range bucketmd.LBmap {\n\t\t_, ok := newbucketmd.LBmap[bucket]\n\t\tif !ok {\n\t\t\tglog.Infof(\"Destroy local bucket %s\", bucket)\n\t\t\tfor mpath := range ctx.mountpaths.Available {\n\t\t\t\tlocalbucketfqn := filepath.Join(makePathLocal(mpath), bucket)\n\t\t\t\tif err := os.RemoveAll(localbucketfqn); err != nil {\n\t\t\t\t\tglog.Errorf(\"Failed to destroy local bucket dir %q, err: %v\", localbucketfqn, err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor mpath := range ctx.mountpaths.Available {\n\t\tfor bucket := range bucketmd.LBmap {\n\t\t\tlocalbucketfqn := filepath.Join(makePathLocal(mpath), bucket)\n\t\t\tif err := CreateDir(localbucketfqn); err != nil {\n\t\t\t\tglog.Errorf(\"Failed to create local bucket dir %q, err: %v\", localbucketfqn, err)\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func (ctrler CtrlDefReactor) OnBucketDelete(obj *Bucket) error {\n\tlog.Info(\"OnBucketDelete is not implemented\")\n\treturn nil\n}", "func ComputeManifest(refToImage map[name.Reference]v1.Image) (Manifest, error) {\n\timageToTags := dedupRefToImage(refToImage)\n\treturn calculateManifest(imageToTags)\n}", "func (d *InboundCacheDriver) StoreManifest(location models.ImageReference, contents []byte, mediaType string, now time.Time) error {\n\td.Entries[location] = inboundCacheEntry{contents, mediaType, now}\n\treturn nil\n}", "func deleteTaskMeta(db *leveldb.DB, name string) error {\n\tif db == nil {\n\t\treturn terror.ErrWorkerLogInvalidHandler.Generate()\n\t}\n\n\terr := db.Delete(encodeTaskMetaKey(name), nil)\n\tif err != nil {\n\t\treturn terror.ErrWorkerLogDeleteTaskMeta.Delegate(err, name)\n\t}\n\n\treturn nil\n}", "func DeleteMatterHandler(c *gin.Context) {\n\tvar p form.BaseQueryParam\n\tif err := c.ShouldBind(&p); err != nil {\n\t\tutils.Error(c, err)\n\t\treturn\n\t}\n\n\tif err := models.DeleteMatterByUUID(p.UUID); err != nil {\n\t\tutils.Error(c, err)\n\t\treturn\n\t}\n\n\tutils.Ok(c, p.UUID)\n}", "func afterObjectDelete(ctx context.Context, object *storage.ObjectHandle, err error) error {\n\treturn err\n}", "func (p *Processor) ReplicateManifest(ctx context.Context, account keppel.Account, repo keppel.Repository, reference models.ManifestReference, actx keppel.AuditContext) (*keppel.Manifest, []byte, error) {\n\tmanifestBytes, manifestMediaType, err := p.downloadManifestViaInboundCache(ctx, account, repo, reference)\n\tif err != nil {\n\t\tif errorIsManifestNotFound(err) {\n\t\t\treturn nil, nil, UpstreamManifestMissingError{reference, err}\n\t\t}\n\t\treturn nil, nil, err\n\t}\n\n\t//parse the manifest to discover references to other manifests and blobs\n\tmanifestParsed, _, err := keppel.ParseManifest(manifestMediaType, manifestBytes)\n\tif err != nil {\n\t\treturn nil, nil, keppel.ErrManifestInvalid.With(err.Error())\n\t}\n\n\t//replicate referenced manifests recursively if required\n\tfor _, desc := range manifestParsed.ManifestReferences(account.PlatformFilter) {\n\t\t_, err := keppel.FindManifest(p.db, repo, desc.Digest)\n\t\tif errors.Is(err, sql.ErrNoRows) {\n\t\t\t_, _, err = p.ReplicateManifest(ctx, account, repo, models.ManifestReference{Digest: desc.Digest}, actx)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t}\n\n\t//mark all missing blobs as pending replication\n\tfor _, desc := range manifestParsed.BlobReferences() {\n\t\t//mark referenced blobs as pending replication if not replicated yet\n\t\tblob, err := p.FindBlobOrInsertUnbackedBlob(desc, account)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\t//also ensure that the blob is mounted in this repo (this is also\n\t\t//important if the blob exists; it may only have been replicated in a\n\t\t//different repo)\n\t\terr = keppel.MountBlobIntoRepo(p.db, *blob, repo)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t}\n\n\t//if the manifest is an image, we need to replicate the image configuration\n\t//blob immediately because ValidateAndStoreManifest() uses it for validation\n\t//purposes\n\tconfigBlobDesc := manifestParsed.FindImageConfigBlob()\n\tif configBlobDesc != nil {\n\t\tconfigBlob, err := keppel.FindBlobByAccountName(p.db, configBlobDesc.Digest, account)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\tif configBlob.StorageID == \"\" {\n\t\t\t_, err = p.ReplicateBlob(ctx, *configBlob, account, repo, nil)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\tmanifest, err := p.ValidateAndStoreManifest(account, repo, IncomingManifest{\n\t\tReference: reference,\n\t\tMediaType: manifestMediaType,\n\t\tContents: manifestBytes,\n\t\tPushedAt: p.timeNow(),\n\t}, actx)\n\treturn manifest, manifestBytes, err\n}", "func delImage(w http.ResponseWriter, req *http.Request) {\n\n\t// Manage Cors\n\tsetCors(&w)\n\tif req.Method == \"OPTIONS\" {\n\t\treturn\n\t}\n\n\t// Authenticate user\n\tclaims, err := authRequest(req)\n\tif err != nil {\n\t\tlogger.Error(\"Unauthorized request to upload sending 401: %v\", err)\n\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\tw.Write([]byte(\"401 - Unauthorized request, ensure you sign in and obtain the jwt auth token\"))\n\t\treturn\n\t}\n\n\tvars := mux.Vars(req)\n\t// validate url parameters and retrieve imageMeta\n\timageMeta, err := validateVars(vars)\n\tif err != nil {\n\t\tlogger.Error(\"Failed to validate vars sending 400: %v\", err)\n\t\tif strings.Contains(err.Error(), \"404 - Not found\") {\n\t\t\tw.WriteHeader(http.StatusNotFound)\n\t\t\tw.Write([]byte(\"404 - Not found, no image with that information available\"))\n\t\t\treturn\n\t\t}\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tw.Write([]byte(\"400 - Bad request unable to parse url parameters\"))\n\t\treturn\n\t}\n\n\t// Ensure there is no uid miss match\n\tuidVal, err := strconv.Atoi(vars[\"uid\"])\n\tif uidVal != int(imageMeta.Uid) {\n\t\tlogger.Error(\"uid miss match when attempting to delete image sending 400\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tw.Write([]byte(\"400 - Uid mismatch ensure you are using the correct image reference\"))\n\t\treturn\n\t}\n\n\t// Ensure user has access permissions\n\tif claims.Uid != int(imageMeta.Uid) {\n\t\tlogger.Error(\"unauthorized user attempting to delete image\")\n\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\tw.Write([]byte(\"401 - Unauthorized, you do not have permissions to modify this image\"))\n\t\treturn\n\t}\n\n\t// Delete meta from database\n\terr = DeleteImageData(imageMeta)\n\tif err != nil {\n\t\tlogger.Error(\"failed to delete image from database sending 500: %v\", err)\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tw.Write([]byte(\"500 - Unable to delete image from database, try again later\"))\n\t\treturn\n\t}\n\n\t// Delete file from storage\n\tfileRef := fmt.Sprintf(\"./%s/%s/%s\", IMAGE_DIR, vars[\"uid\"], vars[\"fileId\"])\n\terr = os.Remove(fileRef)\n\t// Orphaned file is ok to leave as database entry is already deleted\n\t// Automated data integrity checks or manual removal is recommended\n\t// This will look like a successfull deletion from the users perspective\n\tif err != nil {\n\t\tlogger.Error(\"failed to delete image data, clean orphaned files via automated data integrity check: %v\", err)\n\t} else {\n\t\tlogger.Info(\"Successfully deleted image: %v\", imageMeta.Id)\n\t}\n\n\treturn\n}", "func (a *ACBuild) ReplaceManifest(manifestPath string) (err error) {\n\tif err = a.lock(); err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\tif err1 := a.unlock(); err == nil {\n\t\t\terr = err1\n\t\t}\n\t}()\n\n\tfinfo, err := os.Stat(manifestPath)\n\tswitch {\n\tcase os.IsNotExist(err):\n\t\treturn fmt.Errorf(\"no such file or directory: %s\", manifestPath)\n\tcase err != nil:\n\t\treturn err\n\tcase finfo.IsDir():\n\t\treturn fmt.Errorf(\"%s is a directory\", manifestPath)\n\tdefault:\n\t\tbreak\n\t}\n\n\tmanblob, err := ioutil.ReadFile(manifestPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Marshal and Unmarshal the manifest to assert that it's valid and to\n\t// strip any whitespace\n\n\tvar man schema.ImageManifest\n\terr = man.UnmarshalJSON(manblob)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmanblob, err = man.MarshalJSON()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn ioutil.WriteFile(path.Join(a.CurrentACIPath, aci.ManifestFile), manblob, 0755)\n}", "func (m *MinishiftRunner) EnsureDeleted() error {\n\tm.RunCommandAndPrintError(\"delete --force\")\n\n\tdeleted := m.CheckStatus(\"Does Not Exist\")\n\tif deleted == false {\n\t\treturn errors.New(\"Deletion of minishift instance was not successful!\")\n\t}\n\n\treturn nil\n}", "func newManifestDeleteCmd(manifestParams *manifestParameters) *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"delete\",\n\t\tShort: \"Delete manifest from a repository\",\n\t\tLong: newManifestDeleteCmdLongMessage,\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tregistryName, err := manifestParams.GetRegistryName()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tloginURL := api.LoginURL(registryName)\n\t\t\tacrClient, err := api.GetAcrCLIClientWithAuth(loginURL, manifestParams.username, manifestParams.password, manifestParams.configs)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tctx := context.Background()\n\t\t\terr = deleteManifests(ctx, acrClient, loginURL, manifestParams.repoName, args)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t}\n\n\treturn cmd\n}", "func (service *ProjectService) RemoveManifestEntry(at int) error {\n\tmanifest := service.mod.World()\n\tentry, err := manifest.Entry(at)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn service.commander.Register(\n\t\tcmd.Named(\"RemoveManifestEntry\"),\n\t\tcmd.Forward(func(modder world.Modder) error {\n\t\t\treturn manifest.RemoveEntry(at)\n\t\t}),\n\t\tcmd.Reverse(func(modder world.Modder) error {\n\t\t\treturn manifest.InsertEntry(at, entry)\n\t\t}),\n\t)\n}" ]
[ "0.7518358", "0.72563094", "0.6750114", "0.6628918", "0.6548979", "0.65356153", "0.6269419", "0.61748946", "0.6108742", "0.5964179", "0.5844784", "0.5762061", "0.57612425", "0.5721427", "0.5636067", "0.55578166", "0.55270004", "0.54325235", "0.5378246", "0.5231348", "0.51393896", "0.5107284", "0.5041435", "0.50396556", "0.49881947", "0.49754554", "0.4965625", "0.4962901", "0.49559453", "0.4948405", "0.4942128", "0.49223283", "0.4896784", "0.489515", "0.4891379", "0.48751673", "0.48710933", "0.48521778", "0.48502922", "0.48497415", "0.48493102", "0.48293012", "0.48275676", "0.4806508", "0.48009673", "0.4799116", "0.47955748", "0.47675937", "0.47594693", "0.47561574", "0.4744037", "0.47410232", "0.47368357", "0.4736163", "0.4733307", "0.4722616", "0.46885628", "0.46885228", "0.46831283", "0.4680995", "0.4677794", "0.46759054", "0.46686164", "0.4663949", "0.4661308", "0.4659165", "0.46454698", "0.46424967", "0.45962298", "0.459237", "0.45847657", "0.45823514", "0.4580604", "0.4574006", "0.45738888", "0.45723897", "0.4571063", "0.4569047", "0.45666575", "0.4561441", "0.45595175", "0.4535443", "0.45316228", "0.45232156", "0.4521395", "0.45146322", "0.45118627", "0.45056283", "0.45012575", "0.44972104", "0.44962814", "0.44780597", "0.44779342", "0.44755685", "0.44728416", "0.44707215", "0.4462026", "0.4454086", "0.44480476", "0.44438004" ]
0.86380994
0
committee_api GetCommitteeRequest api request get_committee_request
committee_api GetCommitteeRequest api request get_committee_request
func (api *API) GetCommitteeRequest(id uint32, count int32) (*CommitteeObject, error) { var resp CommitteeObject err := api.call("committee_api", "get_committee_request", []interface{}{id, count}, &resp) return &resp, err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (_IOrakuruCore *IOrakuruCoreCallerSession) GetRequest(_requestId [32]byte) (struct {\n\tId [32]byte\n\tDataSource string\n\tSelector string\n\tCallbackAddr common.Address\n\tExecutionTimestamp *big.Int\n\tIsFulfilled bool\n\tAggrType uint8\n\tPrecision uint8\n}, error) {\n\treturn _IOrakuruCore.Contract.GetRequest(&_IOrakuruCore.CallOpts, _requestId)\n}", "func (_IOrakuruCore *IOrakuruCoreSession) GetRequest(_requestId [32]byte) (struct {\n\tId [32]byte\n\tDataSource string\n\tSelector string\n\tCallbackAddr common.Address\n\tExecutionTimestamp *big.Int\n\tIsFulfilled bool\n\tAggrType uint8\n\tPrecision uint8\n}, error) {\n\treturn _IOrakuruCore.Contract.GetRequest(&_IOrakuruCore.CallOpts, _requestId)\n}", "func (api *API) GetCommitteeRequestsList(status uint16) ([]*uint16, error) {\n\tvar resp []*uint16\n\terr := api.call(\"committee_api\", \"get_committee_requests_list\", []interface{}{status}, &resp)\n\treturn resp, err\n}", "func (s *PublicBlockChainAPI) GetCommittee(ctx context.Context, epoch int64) (map[string]interface{}, error) {\n\tcommittee, err := s.b.GetCommittee(big.NewInt(epoch))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvalidators := make([]map[string]interface{}, 0)\n\tfor _, validator := range committee.NodeList {\n\t\tvalidatorBalance := new(hexutil.Big)\n\t\tvalidatorBalance, err = s.b.GetBalance(validator.EcdsaAddress)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\toneAddress, err := internal_common.AddressToBech32(validator.EcdsaAddress)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tvalidatorsFields := map[string]interface{}{\n\t\t\t\"address\": oneAddress,\n\t\t\t\"balance\": validatorBalance,\n\t\t}\n\t\tvalidators = append(validators, validatorsFields)\n\t}\n\tresult := map[string]interface{}{\n\t\t\"shardID\": committee.ShardID,\n\t\t\"validators\": validators,\n\t}\n\treturn result, nil\n}", "func (s *Service) GetRequest(identifiable DocIdentifiable) (*json.RawMessage, error) {\n\t// TODO: accept ctx as param\n\tget, err := s.Client.Get().\n\t\tIndex(s.RequestsIndex).\n\t\tType(\"_doc\").\n\t\tId(identifiable.DocID()).\n\t\tDo(context.TODO())\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn get.Source, nil\n}", "func (_CommitteeManager *CommitteeManagerCallerSession) Committee() (common.Address, error) {\n\treturn _CommitteeManager.Contract.Committee(&_CommitteeManager.CallOpts)\n}", "func (api *API) GetCommitteeRequestVotes(id uint32) ([]*CommitteeVoteState, error) {\n\tvar resp []*CommitteeVoteState\n\terr := api.call(\"committee_api\", \"get_committee_request_votes\", []interface{}{id}, &resp)\n\treturn resp, err\n}", "func (c *TogglHttpClient) GetRequest(endpoint string) (*json.RawMessage, error) {\n\treturn request(c, \"GET\", endpoint, nil)\n}", "func GetCmdQueryCommittee(queryRoute string, cdc *codec.Codec) *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"committee [committee-id]\",\n\t\tArgs: cobra.ExactArgs(1),\n\t\tShort: \"Query details of a single committee\",\n\t\tExample: fmt.Sprintf(\"%s query %s committee 1\", version.ClientName, types.ModuleName),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tcliCtx := context.NewCLIContext().WithCodec(cdc)\n\n\t\t\t// Prepare params for querier\n\t\t\tcommitteeID, err := strconv.ParseUint(args[0], 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"committee-id %s not a valid uint\", args[0])\n\t\t\t}\n\t\t\tbz, err := cdc.MarshalJSON(types.NewQueryCommitteeParams(committeeID))\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// Query\n\t\t\tres, _, err := cliCtx.QueryWithData(fmt.Sprintf(\"custom/%s/%s\", queryRoute, types.QueryCommittee), bz)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// Decode and print result\n\t\t\tcommittee := types.Committee{}\n\t\t\tif err = cdc.UnmarshalJSON(res, &committee); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn cliCtx.PrintOutput(committee)\n\t\t},\n\t}\n\treturn cmd\n}", "func (_CommitteeManager *CommitteeManagerSession) Committee() (common.Address, error) {\n\treturn _CommitteeManager.Contract.Committee(&_CommitteeManager.CallOpts)\n}", "func (_IOrakuruCore *IOrakuruCoreCaller) GetRequest(opts *bind.CallOpts, _requestId [32]byte) (struct {\n\tId [32]byte\n\tDataSource string\n\tSelector string\n\tCallbackAddr common.Address\n\tExecutionTimestamp *big.Int\n\tIsFulfilled bool\n\tAggrType uint8\n\tPrecision uint8\n}, error) {\n\tvar out []interface{}\n\terr := _IOrakuruCore.contract.Call(opts, &out, \"getRequest\", _requestId)\n\n\toutstruct := new(struct {\n\t\tId [32]byte\n\t\tDataSource string\n\t\tSelector string\n\t\tCallbackAddr common.Address\n\t\tExecutionTimestamp *big.Int\n\t\tIsFulfilled bool\n\t\tAggrType uint8\n\t\tPrecision uint8\n\t})\n\tif err != nil {\n\t\treturn *outstruct, err\n\t}\n\n\toutstruct.Id = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte)\n\toutstruct.DataSource = *abi.ConvertType(out[1], new(string)).(*string)\n\toutstruct.Selector = *abi.ConvertType(out[2], new(string)).(*string)\n\toutstruct.CallbackAddr = *abi.ConvertType(out[3], new(common.Address)).(*common.Address)\n\toutstruct.ExecutionTimestamp = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int)\n\toutstruct.IsFulfilled = *abi.ConvertType(out[5], new(bool)).(*bool)\n\toutstruct.AggrType = *abi.ConvertType(out[6], new(uint8)).(*uint8)\n\toutstruct.Precision = *abi.ConvertType(out[7], new(uint8)).(*uint8)\n\n\treturn *outstruct, err\n\n}", "func (client IdentityClient) getWorkRequest(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/workRequests/{workRequestId}\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response GetWorkRequestResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (_CommitteeManager *CommitteeManagerCaller) Committee(opts *bind.CallOpts) (common.Address, error) {\n\tvar (\n\t\tret0 = new(common.Address)\n\t)\n\tout := ret0\n\terr := _CommitteeManager.contract.Call(opts, out, \"_committee\")\n\treturn *ret0, err\n}", "func GetRequest(ctx context.Context, r *http.Request) (*skillserver.EchoRequest, error) {\n\tvar echoReq *skillserver.EchoRequest\n\terr := json.NewDecoder(r.Body).Decode(&echoReq)\n\treturn echoReq, err\n}", "func (c *Client) NewGetDraftRequest(ctx context.Context, path string) (*http.Request, error) {\n\tscheme := c.Scheme\n\tif scheme == \"\" {\n\t\tscheme = \"http\"\n\t}\n\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func GetActionCommitment(ctx iris.Context) {\n\ty1, err := ctx.URLParamInt64(\"FirstYear\")\n\tif err != nil {\n\t\ty1 = int64(time.Now().Year()) + 1\n\t}\n\tvar resp models.ActionCommitments\n\tdb := ctx.Values().Get(\"db\").(*sql.DB)\n\tif err = resp.GetAll(y1, db); err != nil {\n\t\tctx.StatusCode(http.StatusInternalServerError)\n\t\tctx.JSON(jsonError{\"Prévisions AP par actions budgétaires, requête : \" + err.Error()})\n\t}\n\tctx.StatusCode(http.StatusOK)\n\tctx.JSON(resp)\n}", "func (client *CertificateOrdersClient) retrieveCertificateEmailHistoryCreateRequest(ctx context.Context, resourceGroupName string, name string, options *CertificateOrdersClientRetrieveCertificateEmailHistoryOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{name}/retrieveEmailHistory\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-09-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (a *RepoAPI) getCommit(params interface{}) (resp *rpc.Response) {\n\tm := objx.New(cast.ToStringMap(params))\n\treturn rpc.Success(util.Map{\n\t\t\"commit\": a.mods.Repo.GetCommit(m.Get(\"name\").Str(), m.Get(\"hash\").Str()),\n\t})\n}", "func decodeGetRequest(_ context.Context, r *http1.Request) (interface{}, error) {\n\treq := endpoint.GetRequest{}\n\treturn req, nil\n}", "func decodeGetRequest(_ context.Context, r *http1.Request) (interface{}, error) {\n\treq := endpoint.GetRequest{}\n\treturn req, nil\n}", "func (c *ThreeScaleClient) buildGetReq(ep string) (*http.Request, error) {\n\treq, err := http.NewRequest(\"GET\", c.adminPortal.rawURL+ep, nil)\n\treq.Header.Set(\"Accept\", \"application/xml\")\n\treq.Header.Set(\"Authorization\", \"Basic \"+basicAuth(\"\", c.credential))\n\treturn req, err\n}", "func (client BastionClient) getWorkRequest(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) {\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/workRequests/{workRequestId}\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response GetWorkRequestResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (client *RoleAssignmentsClient) getCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, options *RoleAssignmentsGetOptions) (*policy.Request, error) {\n\thost := \"{vaultBaseUrl}\"\n\thost = strings.ReplaceAll(host, \"{vaultBaseUrl}\", vaultBaseURL)\n\turlPath := \"/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}\"\n\tif scope == \"\" {\n\t\treturn nil, errors.New(\"parameter scope cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\tif roleAssignmentName == \"\" {\n\t\treturn nil, errors.New(\"parameter roleAssignmentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{roleAssignmentName}\", url.PathEscape(roleAssignmentName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"7.3-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *AlertOperationClient) getCreateRequest(ctx context.Context, scope string, operationID string, options *AlertOperationClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.Authorization/roleManagementAlertOperations/{operationId}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\turlPath = strings.ReplaceAll(urlPath, \"{operationId}\", operationID)\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ConsumerInvitationsClient) getCreateRequest(ctx context.Context, location string, invitationID string, options *ConsumerInvitationsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.DataShare/locations/{location}/consumerInvitations/{invitationId}\"\n\tif location == \"\" {\n\t\treturn nil, errors.New(\"parameter location cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{location}\", url.PathEscape(location))\n\tif invitationID == \"\" {\n\t\treturn nil, errors.New(\"parameter invitationID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{invitationId}\", url.PathEscape(invitationID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-09-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func getRecipientTx(r *http.Request, pb transactionPb.TransactionService) (proto.Message, error) {\n\tr.ParseForm()\n\trecipientCryptoID := r.FormValue(\"recipientCryptoId\")\n\t// Create protobuf request\n\tpbRequest := &transactionPb.TxByRecipientReq{\n\t\tRecipientCryptoId: recipientCryptoID,\n\t}\n\t// Call RPC function and get protobuf response\n\tpbResponse, err := pb.GetRecipientTx(context.Background(), pbRequest)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// Send back to Client\n\treturn pbResponse, nil\n}", "func GetDetailedActionCommitment(ctx iris.Context) {\n\ty1, err := ctx.URLParamInt64(\"FirstYear\")\n\tif err != nil {\n\t\ty1 = int64(time.Now().Year()) + 1\n\t}\n\tvar resp models.DetailedActionCommitments\n\tdb := ctx.Values().Get(\"db\").(*sql.DB)\n\tif err = resp.GetAll(y1, db); err != nil {\n\t\tctx.StatusCode(http.StatusInternalServerError)\n\t\tctx.JSON(jsonError{\"Prévisions AP détaillées par actions budgétaires, requête : \" + err.Error()})\n\t\treturn\n\t}\n\tctx.StatusCode(http.StatusOK)\n\tctx.JSON(resp)\n}", "func getServiceCmdRequest(cmd cmdType, cred credential, body []byte) (*http.Request, error) {\n\treq, err := newTestRequest(cmd.apiMethod(), \"/?service\", 0, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Set body\n\treq.Body = ioutil.NopCloser(bytes.NewReader(body))\n\n\t// minioAdminOpHeader is to identify the request as a\n\t// management REST API request.\n\treq.Header.Set(minioAdminOpHeader, cmd.String())\n\treq.Header.Set(\"X-Amz-Content-Sha256\", getSHA256Hash(body))\n\n\t// management REST API uses signature V4 for authentication.\n\terr = signRequestV4(req, cred.AccessKey, cred.SecretKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (e *Endpoints) getOrgByRequest(r *http.Request) (*orgpb.Org, error) {\n\torgIDStr := r.Header.Get(httputil.OrgHeader)\n\tif orgIDStr == \"\" {\n\t\treturn nil, errors.Errorf(\"missing org id header\")\n\t}\n\n\torgResp, err := e.org.GetOrg(apis.WithInternalClientContext(context.Background(), discover.SvcCMP),\n\t\t&orgpb.GetOrgRequest{IdOrName: orgIDStr})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn orgResp.Data, nil\n}", "func (db *DB) GetRequest(id *record.ID) (record.Request, error) {\n\ttx := db.BeginTransaction(false)\n\tdefer tx.Discard()\n\treturn tx.GetRequest(id)\n}", "func getRequest(url string) ([]byte, error) {\n\treq, err := http.NewRequest(http.MethodGet, url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp, err := makeRequest(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resp == nil {\n\t\treturn nil, ErrResponseNil\n\t}\n\tdefer resp.Body.Close()\n\n\tbodyBytes, err := getBody(resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, types.NewErrServiceClient(resp.StatusCode, bodyBytes)\n\t}\n\n\treturn bodyBytes, nil\n}", "func (method *Method) GetRequest() specs.Message {\n\tif method.Request == nil {\n\t\treturn make(specs.Message, 0)\n\t}\n\n\treturn method.Request.Definition.Property.Message\n}", "func NewGetRequest(payload *todo.GetPayload) *todopb.GetRequest {\n\tmessage := &todopb.GetRequest{\n\t\tId: payload.ID,\n\t}\n\treturn message\n}", "func (c *NATSTestClient) GetRequest(t *testing.T) *Request {\n\tselect {\n\tcase r := <-c.reqs:\n\t\treturn r\n\tcase <-time.After(timeoutSeconds * time.Second):\n\t\tif t == nil {\n\t\t\tpprof.Lookup(\"goroutine\").WriteTo(os.Stdout, 1)\n\t\t\tpanic(\"expected a request but found none\")\n\t\t} else {\n\t\t\tt.Fatal(\"expected a request but found none\")\n\t\t}\n\t}\n\treturn nil\n}", "func (m *ThreatAssessmentRequest) GetRequestSource()(*ThreatAssessmentRequestSource) {\n return m.requestSource\n}", "func (b *Handler) Committee(round uint64, step uint8) user.VotingCommittee {\n\treturn b.Handler.Committee(round, step, config.ConsensusSelectionCommitteeSize)\n}", "func (client *AlertsClient) getCreateRequest(ctx context.Context, scope string, alertID string, options *AlertsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\turlPath = strings.ReplaceAll(urlPath, \"{alertId}\", alertID)\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ContainerAppsDiagnosticsClient) getRevisionCreateRequest(ctx context.Context, resourceGroupName string, containerAppName string, revisionName string, options *ContainerAppsDiagnosticsClientGetRevisionOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectorProperties/revisionsApi/revisions/{revisionName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif containerAppName == \"\" {\n\t\treturn nil, errors.New(\"parameter containerAppName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{containerAppName}\", url.PathEscape(containerAppName))\n\tif revisionName == \"\" {\n\t\treturn nil, errors.New(\"parameter revisionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{revisionName}\", url.PathEscape(revisionName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, resourceType string, resourceName string, changeResourceID string, options *ClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes/{changeResourceId}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif resourceProviderNamespace == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceProviderNamespace cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceProviderNamespace}\", url.PathEscape(resourceProviderNamespace))\n\tif resourceType == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceType}\", url.PathEscape(resourceType))\n\tif resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(resourceName))\n\tif changeResourceID == \"\" {\n\t\treturn nil, errors.New(\"parameter changeResourceID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{changeResourceId}\", url.PathEscape(changeResourceID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (k Keeper) GetRequest(ctx sdk.Context, id uint64) (val types.Request, found bool) {\n\tstores := k.GetStoreRequestMap(ctx)\n\tfor _, store := range stores {\n\t\tb := store.Get(GetRequestIDBytes(id))\n\t\tif b == nil {\n\t\t\tcontinue\n\t\t}\n\t\tk.cdc.MustUnmarshal(b, &val)\n\t\tfound = true\n\t\tbreak\n\t}\n\treturn\n}", "func makeAuthRequest(apiKey string) string {\n\n\tclient := &http.Client{}\n\treq, _ := http.NewRequest(\"GET\", \"https://rep.checkpoint.com/rep-auth/service/v1.0/request\", nil)\n\treq.Header.Set(\"Client-Key\", apiKey)\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\t// log.Println(string(body))\n\treturn string(body)\n}", "func (r *ApprovalWorkflowProviderRequestsCollectionRequest) Get(ctx context.Context) ([]RequestObject, error) {\n\treturn r.GetN(ctx, 0)\n}", "func (client *CassandraClustersClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *CassandraClustersClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-03-15-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (a *RequestServiceApiService) GetRequest(ctx _context.Context, uuid string) ApiGetRequestRequest {\n\treturn ApiGetRequestRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t\tuuid: uuid,\n\t}\n}", "func (_BaseLibrary *BaseLibraryCaller) GetPendingApprovalRequest(opts *bind.CallOpts, index *big.Int) (common.Address, error) {\n\tvar out []interface{}\n\terr := _BaseLibrary.contract.Call(opts, &out, \"getPendingApprovalRequest\", index)\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "func (v GithubVCS) getPullRequest(ctx context.Context, runinfo RunInfo, prNumber int) (RunInfo, error) {\n\tpr, _, err := v.Client.PullRequests.Get(ctx, runinfo.Owner, runinfo.Repository, prNumber)\n\tif err != nil {\n\t\treturn runinfo, err\n\t}\n\t// Make sure to use the Base for Default BaseBranch or there would be a potential hijack\n\truninfo.DefaultBranch = pr.GetBase().GetRepo().GetDefaultBranch()\n\truninfo.URL = pr.GetBase().GetRepo().GetHTMLURL()\n\truninfo.SHA = pr.GetHead().GetSHA()\n\truninfo.SHAURL = fmt.Sprintf(\"%s/commit/%s\", pr.GetHTMLURL(), pr.GetHead().GetSHA())\n\t// TODO: Maybe if we wanted to allow rerequest from non approved user we\n\t// would use the CheckRun Sender instead of the rerequest sender, could it\n\t// be a room for abuse? 🤔\n\truninfo.Sender = pr.GetUser().GetLogin()\n\truninfo.HeadBranch = pr.GetHead().GetRef()\n\truninfo.BaseBranch = pr.GetBase().GetRef()\n\truninfo.EventType = \"pull_request\"\n\treturn runinfo, nil\n}", "func (c *CoinbaseAPIKeyAuth) makeRequest(req *http.Request) ([]byte, error) {\n\treq.Header.Set(\"CB-ACCESS-KEY\", c.APIKey)\n\treq.Header.Set(\"CB-VERSION\", time.Now().Format(\"20060102\"))\n\treq.Header.Set(\"CB-ACCESS-TIMESTAMP\", \"2017-03-27\")\n\tbv := []byte(time.Now().Format(\"20060102\") + \"GET\" + req.URL.String())\n\thasher := sha256.New()\n\thasher.Write(bv)\n\tsha := base64.URLEncoding.EncodeToString(hasher.Sum(nil))\n\treq.Header.Set(\"CB-ACCESS-SIGN\", sha)\n\tresp, err := c.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfmt.Println(req)\n\n\t// Make sure we close the body stream no matter what\n\tdefer resp.Body.Close()\n\n\t// Read body\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t//fmt.Println(string(body))\n\n\t// Check status code\n\tif resp.StatusCode != 200 {\n\t\tfmt.Println(string(body))\n\t\treturn nil, fmt.Errorf(\"Invalid HTTP response code: %d\", resp.StatusCode)\n\t}\n\n\t// Return\n\treturn body, nil\n}", "func (r *PullsListCommitsReq) HTTPRequest(ctx context.Context, opt ...RequestOption) (*http.Request, error) {\n\treturn buildHTTPRequest(ctx, r, opt)\n}", "func (*GetTransactionByEventIdRequest) Descriptor() ([]byte, []int) {\n\treturn file_com_daml_ledger_api_v1_transaction_service_proto_rawDescGZIP(), []int{3}\n}", "func CreateGetKeywordChEcomRequest() (request *GetKeywordChEcomRequest) {\n\trequest = &GetKeywordChEcomRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"alinlp\", \"2020-06-29\", \"GetKeywordChEcom\", \"alinlp\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func GetTracerRequest(tracerID uint) ([]byte, error) {\n\tlog.Trace.Printf(\"Getting request for the given tracer ID.\")\n\tvar ret []byte\n\tvar err error\n\n\tvar request types.Request\n\tif err = store.DB.First(&request).Error; err == nil {\n\t\tlog.Trace.Printf(\"Successfully got the request: %+v\", request)\n\t\tret, err = json.Marshal(request)\n\t}\n\n\tif err != nil {\n\t\tlog.Warning.Printf(err.Error())\n\t}\n\n\treturn ret, err\n}", "func (client *PipelinesClient) getCreateRequest(ctx context.Context, resourceGroupName string, factoryName string, pipelineName string, options *PipelinesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/pipelines/{pipelineName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif factoryName == \"\" {\n\t\treturn nil, errors.New(\"parameter factoryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{factoryName}\", url.PathEscape(factoryName))\n\tif pipelineName == \"\" {\n\t\treturn nil, errors.New(\"parameter pipelineName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{pipelineName}\", url.PathEscape(pipelineName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfNoneMatch != nil {\n\t\treq.Raw().Header[\"If-None-Match\"] = []string{*options.IfNoneMatch}\n\t}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (pr ParallelRequests) GetRequest(t *testing.T, subject string) *Request {\n\tfor _, r := range pr {\n\t\tif r.Subject == subject {\n\t\t\treturn r\n\t\t}\n\t}\n\n\tt.Fatalf(\"expected parallel requests to contain subject %#v, but found none\", subject)\n\treturn nil\n}", "func (client *LocalRulestacksClient) getChangeLogCreateRequest(ctx context.Context, resourceGroupName string, localRulestackName string, options *LocalRulestacksClientGetChangeLogOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/getChangeLog\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif localRulestackName == \"\" {\n\t\treturn nil, errors.New(\"parameter localRulestackName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{localRulestackName}\", url.PathEscape(localRulestackName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-29\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func getCrtcInfoRequest(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) []byte {\n\tsize := 12\n\tb := 0\n\tbuf := make([]byte, size)\n\n\tc.ExtLock.RLock()\n\tbuf[b] = c.Extensions[\"RANDR\"]\n\tc.ExtLock.RUnlock()\n\tb += 1\n\n\tbuf[b] = 20 // request opcode\n\tb += 1\n\n\txgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units\n\tb += 2\n\n\txgb.Put32(buf[b:], uint32(Crtc))\n\tb += 4\n\n\txgb.Put32(buf[b:], uint32(ConfigTimestamp))\n\tb += 4\n\n\treturn buf\n}", "func (oc *OpenshiftClient) GetRequest(path string) (*http.Response, error) {\n\treq, err := http.NewRequest(\"GET\", fmt.Sprintf(\"https://%s%s\", oc.MasterUrl, path), nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error occurred while creating new http request : %w\", err)\n\t}\n\tresp, err := oc.HTTPClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error occurred while performing http request : %w\", err)\n\t}\n\treturn resp, nil\n}", "func (*GetCommitRequest) Descriptor() ([]byte, []int) {\n\treturn file_modeldb_versioning_VersioningService_proto_rawDescGZIP(), []int{17}\n}", "func (t *SimpleChaincode) getRequest(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) {\n\n\tif len(args) != 2 {\n\t\treturn nil, errors.New(\"Incorrect number of arguments. Expecting 2, \\\"RequestID\\\" : \\\"xxxxxx\\\"\")\n\t}\n\n\tif args[0] != \"RequestID\" {\n\t\treturn nil, errors.New(\"Unsupoprted query arguments [\" + args[0] + \"]\")\n\t}\n\n\tfmt.Println(\"Start to query a Request ...\")\n\n\trequestID := args[1]\n\n\tvar columns []shim.Column\n\tkeyCol1 := shim.Column{Value: &shim.Column_String_{String_: requestID}}\n\n\tcolumns = append(columns, keyCol1)\n\n\trow, err := stub.GetRow(\"Request\", columns)\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Query one request (RequestID = %s) in the table Request failed\", requestID)\n\t}\n\n\tif len(row.Columns) == 0 {\n\t\treturn nil, errors.New(\"Request was NOT found\")\n\t}\n\n\tfmt.Println(\"Query one request (RequestID = \" + requestID + \") in the table Request successfully...\")\n\n\t// Convert to the structure Request, the returns would be key1:value1,key2:value2,key3:value3, ...\n\trequest := &Request{\n\t\trow.Columns[0].GetString_(),\n\t\trow.Columns[1].GetString_(),\n\t\trow.Columns[2].GetString_(),\n\t\trow.Columns[3].GetString_(),\n\t\trow.Columns[4].GetString_(),\n\t\trow.Columns[5].GetString_(),\n\t\trow.Columns[6].GetString_(),\n\t\trow.Columns[7].GetString_(),\n\t\trow.Columns[8].GetString_(),\n\t\trow.Columns[9].GetString_(),\n\t\trow.Columns[10].GetString_(),\n\t\trow.Columns[11].GetString_(),\n\t\trow.Columns[12].GetString_(),\n\t}\n\n\treturnRequest, err := json.Marshal(request)\n\n\tif err != nil {\n\t\treturn nil, errors.New(\"getRequest() json marshal error\")\n\t}\n\n\tfmt.Println(\"End to query a Request ...\")\n\n\treturn returnRequest, nil\n}", "func (*GetEmailRequest) Descriptor() ([]byte, []int) {\n\treturn file_dictybase_api_jsonapi_request_proto_rawDescGZIP(), []int{1}\n}", "func makeRequest(changes []store.Change) *store.ChangeRequest {\n\treq := new(store.ChangeRequest)\n\treq.RequestEntity = uint64(config.Id())\n\treq.RequestNode = config.Id()\n\treq.RequestId = store.AllocateRequestId()\n\treq.Changeset = changes\n\n\treturn req\n}", "func (store *Engine) Request(requestID string) (request *Request, err error) {\n\trequest = new(Request)\n\n\t_, err = store.api.\n\t\tURL(\"/workflow-engine/api/v1/requests/%s\", url.PathEscape(requestID)).\n\t\tGet(request)\n\n\treturn request, err\n}", "func (*GetUTXORequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{10}\n}", "func (_IOrakuruCore *IOrakuruCoreTransactor) MakeRequest(opts *bind.TransactOpts, _dataSource string, _selector string, _calldataAddr common.Address, _aggrType uint8, _precision uint8, _executionTimestamp *big.Int) (*types.Transaction, error) {\n\treturn _IOrakuruCore.contract.Transact(opts, \"makeRequest\", _dataSource, _selector, _calldataAddr, _aggrType, _precision, _executionTimestamp)\n}", "func (c *Client) NewShowContractRequest(ctx context.Context, path string) (*http.Request, error) {\n\tscheme := c.Scheme\n\tif scheme == \"\" {\n\t\tscheme = \"http\"\n\t}\n\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (c Client) request(method string, u *url.URL, body io.Reader) (io.ReadCloser, error) {\n\treq, err := http.NewRequest(method, u.String(), body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"creating request failed: %s\", err.Error())\n\t}\n\treq.Header.Add(tokenHeader, c.token)\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\tresp, err := c.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"request failed: %s\", err.Error())\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"status code: %d, message: %s\", resp.StatusCode, decodeError(resp.Body))\n\t}\n\n\treturn resp.Body, nil\n}", "func (client *VirtualMachineScaleSetRollingUpgradesClient) getLatestCreateRequest(ctx context.Context, resourceGroupName string, vmScaleSetName string, options *VirtualMachineScaleSetRollingUpgradesGetLatestOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest\"\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{vmScaleSetName}\", url.PathEscape(vmScaleSetName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-06-01\")\n\treq.URL.RawQuery = query.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client IdentityClient) getTaggingWorkRequest(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/taggingWorkRequests/{workRequestId}\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response GetTaggingWorkRequestResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func GetRequest(url string, endpoint string) (int, error) {\n\taddr := fmt.Sprintf(\"%s/%s/\", url, endpoint)\n\tr, err := http.NewRequest(\"GET\", addr, bytes.NewBuffer([]byte{}))\n\n\tif err != nil {\n\t\tlog.Println(\"Error creating collection request, error:\", err)\n\t\treturn 0, err\n\t}\n\n\tclient := &http.Client{\n\t\tTimeout: 5 * time.Second,\n\t}\n\tresp, err := client.Do(r)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn resp.StatusCode, err\n\n}", "func CreateGetIndustryCommerceInfoRequest() (request *GetIndustryCommerceInfoRequest) {\n\trequest = &GetIndustryCommerceInfoRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"companyreg\", \"2020-10-22\", \"GetIndustryCommerceInfo\", \"companyreg\", \"openAPI\")\n\trequest.Method = requests.GET\n\treturn\n}", "func (client *Client) getChatCompletionsCreateRequest(ctx context.Context, body ChatCompletionsOptions, options *GetChatCompletionsOptions) (*policy.Request, error) {\n\turlPath := \"chat/completions\"\n\treq, err := runtime.NewRequest(ctx, http.MethodPost, client.formatURL(urlPath, getDeploymentID(body)))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-07-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, body); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func SendRequest(workflowID string) (string, error) {\n\taccessKey, clusterID, serverAddr, err := getAgentConfigMapData()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tpayload := `{\"query\": \"mutation { gitopsNotifer(clusterInfo: { cluster_id: \\\"` + clusterID + `\\\", access_key: \\\"` + accessKey + `\\\"}, workflow_id: \\\"` + workflowID + `\\\")\\n}\"}`\n\treq, err := http.NewRequest(\"POST\", serverAddr, bytes.NewBuffer([]byte(payload)))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != 200 {\n\t\treturn \"URL is not reachable or Bad request\", nil\n\t}\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(body), nil\n}", "func (*GetRequest) Descriptor() ([]byte, []int) {\n\treturn file_dictybase_api_jsonapi_request_proto_rawDescGZIP(), []int{0}\n}", "func handleGetRequest(key string, s *Sailor, st *storage.State) (string, error) {\n\tgt := storage.GenerateTransaction(storage.GetOp, key, \"\")\n\treturn st.ApplyTransaction(gt)\n}", "func getProviderInfoRequest(c *xgb.Conn, Provider Provider, ConfigTimestamp xproto.Timestamp) []byte {\n\tsize := 12\n\tb := 0\n\tbuf := make([]byte, size)\n\n\tc.ExtLock.RLock()\n\tbuf[b] = c.Extensions[\"RANDR\"]\n\tc.ExtLock.RUnlock()\n\tb += 1\n\n\tbuf[b] = 33 // request opcode\n\tb += 1\n\n\txgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units\n\tb += 2\n\n\txgb.Put32(buf[b:], uint32(Provider))\n\tb += 4\n\n\txgb.Put32(buf[b:], uint32(ConfigTimestamp))\n\tb += 4\n\n\treturn buf\n}", "func (session *BobSession) GetRequest(requestFile string) error {\n\tif err := utils.CheckDirOfPathExistence(requestFile); err != nil {\n\t\treturn err\n\t}\n\n\thandle := C.handle_t(session.handle)\n\n\trequestFileCStr := C.CString(requestFile)\n\tdefer C.free(unsafe.Pointer(requestFileCStr))\n\n\tif ret := bool(\n\t\tC.E_TableOtComplaintBobGetRequest(handle, requestFileCStr)); !ret {\n\t\treturn fmt.Errorf(\"E_TableOtComplaintBobGetRequest(%v, %s) failed\",\n\t\t\thandle, requestFile)\n\t}\n\n\treturn nil\n}", "func CreateDescribeExplorerRequest() (request *DescribeExplorerRequest) {\n\trequest = &DescribeExplorerRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Baas\", \"2018-07-31\", \"DescribeExplorer\", \"\", \"\")\n\treturn\n}", "func getCommitID(r *http.Request) (vcs.CommitID, bool, error) {\n\treturn checkCommitID(mux.Vars(r)[\"CommitID\"])\n}", "func CreateGetOpenNLURequest() (request *GetOpenNLURequest) {\n\trequest = &GetOpenNLURequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"alinlp\", \"2020-06-29\", \"GetOpenNLU\", \"alinlp\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (*GetRepositoryCommitByReferenceRequest) Descriptor() ([]byte, []int) {\n\treturn file_buf_alpha_registry_v1alpha1_repository_commit_proto_rawDescGZIP(), []int{5}\n}", "func (client *Client) getCompletionsCreateRequest(ctx context.Context, body CompletionsOptions, options *GetCompletionsOptions) (*policy.Request, error) {\n\turlPath := \"completions\"\n\treq, err := runtime.NewRequest(ctx, http.MethodPost, client.formatURL(urlPath, getDeploymentID(body)))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-07-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, body); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func revisionFromRequest(recent types.FileContractRevision, pbcr modules.PayByContractRequest) types.FileContractRevision {\n\trev := recent\n\n\trev.NewRevisionNumber = pbcr.NewRevisionNumber\n\trev.NewValidProofOutputs = make([]types.SiacoinOutput, len(pbcr.NewValidProofValues))\n\tfor i, v := range pbcr.NewValidProofValues {\n\t\tif i >= len(recent.NewValidProofOutputs) {\n\t\t\tbreak\n\t\t}\n\t\trev.NewValidProofOutputs[i] = types.SiacoinOutput{\n\t\t\tValue: v,\n\t\t\tUnlockHash: recent.NewValidProofOutputs[i].UnlockHash,\n\t\t}\n\t}\n\n\trev.NewMissedProofOutputs = make([]types.SiacoinOutput, len(pbcr.NewMissedProofValues))\n\tfor i, v := range pbcr.NewMissedProofValues {\n\t\tif i >= len(recent.NewMissedProofOutputs) {\n\t\t\tbreak\n\t\t}\n\t\trev.NewMissedProofOutputs[i] = types.SiacoinOutput{\n\t\t\tValue: v,\n\t\t\tUnlockHash: recent.NewMissedProofOutputs[i].UnlockHash,\n\t\t}\n\t}\n\n\treturn rev\n}", "func (_BaseLibrary *BaseLibraryTransactor) AccessRequest(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _BaseLibrary.contract.Transact(opts, \"accessRequest\")\n}", "func (*ERC20WithdrawalApprovalRequest) Descriptor() ([]byte, []int) {\n\treturn file_api_trading_proto_rawDescGZIP(), []int{134}\n}", "func (rt *rtuTransport) ReadRequest() (req *pdu, err error) {\n\t// reading requests from RTU links is currently unsupported\n\terr\t= fmt.Errorf(\"unimplemented\")\n\n\treturn\n}", "func ValidateGetRequest(request *GetHistoryRequest) error {\n\tif request.NamespaceID == \"\" {\n\t\treturn errEmptyNamespaceID\n\t}\n\tif request.WorkflowID == \"\" {\n\t\treturn errEmptyWorkflowID\n\t}\n\tif request.RunID == \"\" {\n\t\treturn errEmptyRunID\n\t}\n\tif request.PageSize == 0 {\n\t\treturn errInvalidPageSize\n\t}\n\treturn nil\n}", "func (r *tee) Request(fc filters.FilterContext) {\n\treq := fc.Request()\n\tcopyOfRequest, tr, err := cloneRequest(r, req)\n\tif err != nil {\n\t\tfc.Logger().Warnf(\"tee: error while cloning the tee request %v\", err)\n\t\treturn\n\t}\n\n\treq.Body = tr\n\n\tgo func() {\n\t\tdefer func() {\n\t\t\tif r.shadowRequestDone != nil {\n\t\t\t\tr.shadowRequestDone()\n\t\t\t}\n\t\t}()\n\n\t\trsp, err := r.client.Do(copyOfRequest)\n\t\tif err != nil {\n\t\t\tfc.Logger().Warnf(\"tee: error while tee request %v\", err)\n\t\t\treturn\n\t\t}\n\n\t\trsp.Body.Close()\n\t}()\n}", "func (store *Engine) CreateRequest(request *Request) (string, error) {\n\tvar id struct {\n\t\tID string `json:\"id\"`\n\t}\n\n\t_, err := store.api.\n\t\tURL(\"/workflow-engine/api/v1/requests\").\n\t\tPost(&request, &id)\n\n\treturn id.ID, err\n}", "func (client *RoleDefinitionsClient) getByIDCreateRequest(ctx context.Context, roleID string, options *RoleDefinitionsGetByIDOptions) (*policy.Request, error) {\n\turlPath := \"/{roleId}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{roleId}\", roleID)\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (_e *MockPlcWriteResponse_Expecter) GetRequest() *MockPlcWriteResponse_GetRequest_Call {\n\treturn &MockPlcWriteResponse_GetRequest_Call{Call: _e.mock.On(\"GetRequest\")}\n}", "func (p *Printer) ReadRequest(ctx context.Context) ([]byte, error) {\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn nil, errors.Wrap(ctx.Err(), \"ReadRequest timed out\")\n\tcase v, ok := <-p.ch:\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"p.ch is unexpectedly closed\")\n\t\t}\n\t\treturn v, nil\n\t}\n}", "func (dc DefaultContainer) GetRequest() *http.Request { return dc.Request }", "func (c *APIGateway) GetStagesRequest(input *GetStagesInput) (req *request.Request, output *GetStagesOutput) {\n\top := &request.Operation{\n\t\tName: opGetStages,\n\t\tHTTPMethod: \"GET\",\n\t\tHTTPPath: \"/restapis/{restapi_id}/stages\",\n\t}\n\n\tif input == nil {\n\t\tinput = &GetStagesInput{}\n\t}\n\n\treq = c.newRequest(op, input, output)\n\toutput = &GetStagesOutput{}\n\treq.Data = output\n\treturn\n}", "func (r *ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequest) Get(ctx context.Context) ([]RequestObject, error) {\n\treturn r.GetN(ctx, 0)\n}", "func (*GetRequest) Descriptor() ([]byte, []int) {\n\treturn file_grpc_exercicio_proto_rawDescGZIP(), []int{3}\n}", "func (client *ClustersClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (_IOrakuruCore *IOrakuruCoreTransactorSession) MakeRequest(_dataSource string, _selector string, _calldataAddr common.Address, _aggrType uint8, _precision uint8, _executionTimestamp *big.Int) (*types.Transaction, error) {\n\treturn _IOrakuruCore.Contract.MakeRequest(&_IOrakuruCore.TransactOpts, _dataSource, _selector, _calldataAddr, _aggrType, _precision, _executionTimestamp)\n}", "func (client *IncidentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, incidentID string, options *IncidentsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/incidents/{incidentId}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif incidentID == \"\" {\n\t\treturn nil, errors.New(\"parameter incidentID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{incidentId}\", url.PathEscape(incidentID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-05-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (*GetRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_task_v1_task_proto_rawDescGZIP(), []int{3}\n}", "func (*GetProvisioningApprovalRequestRequest) Descriptor() ([]byte, []int) {\n\treturn edgelq_devices_proto_v1alpha_provisioning_approval_request_service_proto_rawDescGZIP(), []int{0}\n}", "func (r *vtmClient) buildAPIRequest(method, uri string, reader io.Reader) (request *http.Request, err error) {\n\t// Create the endpoint URL\n\turl := fmt.Sprintf(\"%s/%s\", r.config.URL, uri)\n\n\t// Make the http request to VTM\n\trequest, err = http.NewRequest(method, url, reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Add any basic auth and the content headers\n\tif r.config.HTTPBasicAuthUser != \"\" && r.config.HTTPBasicPassword != \"\" {\n\t\trequest.SetBasicAuth(r.config.HTTPBasicAuthUser, r.config.HTTPBasicPassword)\n\t}\n\n\trequest.Header.Add(\"Content-Type\", \"application/json\")\n\trequest.Header.Add(\"Accept\", \"application/json\")\n\n\treturn request, nil\n}" ]
[ "0.6219865", "0.6180947", "0.60726804", "0.57100993", "0.56391525", "0.55845666", "0.55674565", "0.55537844", "0.5511908", "0.5506123", "0.542247", "0.54088473", "0.5395237", "0.5330503", "0.53254104", "0.5315587", "0.52814925", "0.52538687", "0.524927", "0.524927", "0.521511", "0.5209663", "0.5195773", "0.518548", "0.5167153", "0.51520675", "0.514349", "0.51173383", "0.5104785", "0.5100844", "0.50975066", "0.50900525", "0.50721115", "0.50705534", "0.5060392", "0.504271", "0.50316775", "0.50188774", "0.5017002", "0.5013452", "0.5002642", "0.49971446", "0.49958268", "0.49917328", "0.49859953", "0.4982854", "0.49782956", "0.49763", "0.49692646", "0.49610773", "0.495777", "0.4957689", "0.49342757", "0.49311796", "0.49296695", "0.4922861", "0.492223", "0.49128973", "0.49116707", "0.49086472", "0.49038845", "0.4902123", "0.4898198", "0.4855922", "0.48557776", "0.48551196", "0.48514584", "0.48511663", "0.48506176", "0.48493704", "0.4846399", "0.48432586", "0.48403645", "0.48401505", "0.48357776", "0.48319831", "0.48259532", "0.4823683", "0.48197883", "0.48179218", "0.48143408", "0.4813552", "0.48045933", "0.4804029", "0.4801078", "0.47995347", "0.4795707", "0.4795607", "0.4794961", "0.47939512", "0.47927257", "0.47924608", "0.47890735", "0.4787683", "0.47876093", "0.47867587", "0.478554", "0.47833878", "0.47809857", "0.4780299" ]
0.8301529
0
GetCommitteeRequestVotes api request get_committee_request_votes
GetCommitteeRequestVotes api запрос get_committee_request_votes
func (api *API) GetCommitteeRequestVotes(id uint32) ([]*CommitteeVoteState, error) { var resp []*CommitteeVoteState err := api.call("committee_api", "get_committee_request_votes", []interface{}{id}, &resp) return resp, err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (n *Node) requestVotes(currTerm uint64) (fallback, electionResult bool) {\n\t// TODO: Students should implement this method\n\treturn\n}", "func (api *API) GetCommitteeRequest(id uint32, count int32) (*CommitteeObject, error) {\n\tvar resp CommitteeObject\n\terr := api.call(\"committee_api\", \"get_committee_request\", []interface{}{id, count}, &resp)\n\treturn &resp, err\n}", "func (r *Node) requestVotes(electionResults chan bool, fallbackChan chan bool, currTerm uint64) {\n\t// Votes received\n\tremaining := 0\n\tresultChan := make(chan RequestVoteResult)\n\tfor _, peer := range r.Peers {\n\t\tif r.Self.GetId() == peer.GetId() {\n\t\t\tcontinue\n\t\t}\n\t\tmsg := rpc.RequestVoteRequest{\n\t\t\tTerm: currTerm,\n\t\t\tCandidate: r.Self,\n\t\t\tLastLogIndex: r.LastLogIndex(),\n\t\t\tLastLogTerm: r.GetLog(r.LastLogIndex()).GetTermId(),\n\t\t}\n\t\tremaining++\n\t\tgo r.requestPeerVote(peer, &msg, resultChan)\n\t}\n\n\tvote := 1\n\treject := 0\n\tmajority := r.config.ClusterSize/2 + 1\n\tif vote >= majority {\n\t\telectionResults <- true\n\t\treturn\n\t}\n\tfor remaining > 0 {\n\t\trequestVoteResult := <-resultChan\n\t\tremaining--\n\t\tif requestVoteResult == RequestVoteFallback {\n\t\t\tfallbackChan <- true\n\t\t\treturn\n\t\t}\n\t\tif requestVoteResult == RequestVoteSuccess {\n\t\t\tvote++\n\t\t\tif vote >= majority {\n\t\t\t\telectionResults <- true\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\treject++\n\t\t\tif reject >= majority {\n\t\t\t\telectionResults <- false\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}", "func (s *RaftServer) RequestVote(_ context.Context, request *raftapi.RequestVoteMessage) (*raftapi.RequestVoteResponse, error) {\n\tlog.WithFields(s.LogFields()).Debugln(\"Received RequestVote\")\n\ts.lastHeartbeat = time.Now()\n\tterm := s.getTerm()\n\tif votedFor, has := s.votedOn[term]; !has || votedFor == request.Candidate {\n\t\tlogSize, _ := s.logRepo.LogSize()\n\t\tif term < request.Term || (term == request.Term && logSize < request.LogSize) {\n\t\t\ts.votedOn[term] = request.Candidate\n\t\t\treturn &raftapi.RequestVoteResponse{\n\t\t\t\tTerm: term,\n\t\t\t\tApproved: true,\n\t\t\t}, nil\n\t\t}\n\t}\n\treturn &raftapi.RequestVoteResponse{Term: term}, nil\n}", "func (r *Raft) serviceRequestVote(request RequestVote, state int) {\n\t//fmt.Println(\"In service RV method of \", r.Myconfig.Id)\n\tresponse := RequestVoteResponse{}\n\tcandidateId := request.CandidateId\n\tresponse.Id = r.Myconfig.Id\n\tif r.isDeservingCandidate(request) {\n\t\tresponse.VoteGranted = true\n\t\tr.myCV.VotedFor = candidateId\n\t\tr.myCV.CurrentTerm = request.Term\n\t} else {\n\t\tif request.Term > r.myCV.CurrentTerm {\n\t\t\tr.myCV.CurrentTerm = request.Term\n\t\t\tr.myCV.VotedFor = -1\n\t\t}\n\t\tresponse.VoteGranted = false\n\t}\n\tif request.Term > r.myCV.CurrentTerm {\n\t\tr.WriteCVToDisk()\n\t}\n\tresponse.Term = r.myCV.CurrentTerm\n\tr.send(candidateId, response) //send to sender using send(sender,response)\n}", "func (node *Node) ReceiveRequestVote(ctx context.Context, buffer []byte) (candidateAddress string, request RequestVote, err error) {\n candidateAddress, err = node.receive(ctx, buffer, &request)\n return\n}", "func (m *Member) RequestVote(ctx context.Context, leader string, term uint64, logSize uint64) (*raftapi.RequestVoteResponse, error) {\n\tlog.WithFields(log.Fields{\"member_name\": m.Name}).Debugln(\"Requesting vote from\")\n\tvar conn *grpc.ClientConn\n\tconn, err := grpc.Dial(m.Address(), grpc.WithInsecure())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer conn.Close()\n\tapi := raftapi.NewRaftServiceClient(conn)\n\tresponse, err := api.RequestVote(ctx, &raftapi.RequestVoteMessage{\n\t\tTerm: term,\n\t\tCandidate: leader,\n\t\tLogSize: logSize,\n\t\tLastLogTerm: 0,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn response, nil\n}", "func (r *Raft) serviceRequestVote(request RequestVote) {\n\t//fmt.Println(\"In service RV method of \", r.Myconfig.Id)\n\tresponse := RequestVoteResponse{} //prep response object,for responding back to requester\n\tcandidateId := request.candidateId\n\tresponse.id = r.Myconfig.Id\n\t//fmt.Println(\"Follower\", r.Myconfig.Id, \"log as complete?\", r.logAsGoodAsMine(request))\n\tif r.isDeservingCandidate(request) {\n\t\tresponse.voteGranted = true\n\t\tr.votedFor = candidateId\n\t\tr.currentTerm = request.term\n\n\t\t//Writing current term and voteFor to disk\n\t\tr.WriteCVToDisk()\n\n\t} else {\n\t\tresponse.voteGranted = false\n\t}\n\tresponse.term = r.currentTerm //to return self's term too\n\n\t//fmt.Println(\"Follower\", r.Myconfig.Id, \"voting\", response.voteGranted) //\"because votefor is\", r.votedFor, \"my and request terms are:\", r.currentTerm, request.term)\n\t//fmt.Println(\"Follower\", r.Myconfig.Id, \"Current term,request.term is\", r.currentTerm, request.term, \"Self lastLogIndex is\", r.myMetaData.lastLogIndex, \"VotedFor,request.lastLogTerm\", r.votedFor, request.lastLogTerm)\n\t//fmt.Println(\"VotedFor,request.lastLogTerm\", r.votedFor, request.lastLogTerm)\n\n\t//fmt.Printf(\"In serviceRV of %v, obj prep is %v \\n\", r.Myconfig.Id, response)\n\tsend(candidateId, response) //send to sender using send(sender,response)\n}", "func (q queryServer) Votes(ctx context.Context, req *v1.QueryVotesRequest) (*v1.QueryVotesResponse, error) {\n\tif req == nil {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"invalid request\")\n\t}\n\n\tif req.ProposalId == 0 {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"proposal id can not be 0\")\n\t}\n\n\tvotes, pageRes, err := query.CollectionPaginate(ctx, q.k.Votes, req.Pagination, func(_ collections.Pair[uint64, sdk.AccAddress], value v1.Vote) (vote *v1.Vote, err error) {\n\t\treturn &value, nil\n\t}, query.WithCollectionPaginationPairPrefix[uint64, sdk.AccAddress](req.ProposalId))\n\tif err != nil {\n\t\treturn nil, status.Error(codes.Internal, err.Error())\n\t}\n\n\treturn &v1.QueryVotesResponse{Votes: votes, Pagination: pageRes}, nil\n}", "func (api *API) GetCommitteeRequestsList(status uint16) ([]*uint16, error) {\n\tvar resp []*uint16\n\terr := api.call(\"committee_api\", \"get_committee_requests_list\", []interface{}{status}, &resp)\n\treturn resp, err\n}", "func parseVoteRequest(r *http.Request) (electionID string, ballotID string, err error) {\n\t// Parse URL and route\n\turlparts := strings.Split(r.RequestURI, \"/\")\n\n\t// Check for the correct number of request parts\n\tif len(urlparts) < 3 || len(urlparts) > 4 {\n\t\terr = parseError{\"Invalid number of url parts. 404 Not Found.\", http.StatusNotFound}\n\t\treturn\n\t}\n\n\t// Get the electionID\n\telectionID = urlparts[2]\n\tif len(electionID) > MaxElectionIDSize || !ValidElectionID.MatchString(electionID) {\n\t\terr = parseError{\"Invalid Election ID. 404 Not Found.\", http.StatusNotFound}\n\t\treturn\n\t}\n\n\t// If we are only length 3, that's it, we are asking for a full report / ballot roll for an election\n\tif len(urlparts) == 3 || urlparts[3] == \"\" {\n\t\treturn\n\t}\n\n\t// Get the ballotID (hex encoded SHA512 of base64 encoded public-key)\n\tballotID = urlparts[3]\n\tif len(ballotID) > MaxBallotIDSize || !ValidBallotID.MatchString(ballotID) {\n\t\terr = parseError{\"Invalid Ballot ID. 404 Not Found.\", http.StatusNotFound}\n\t}\n\n\t// If the user has provided a signature of the request in the headers, verify it\n\tif r.Header.Get(\"X-Voteflow-Signature\") != \"\" {\n\t\t// Verify the signature headers, do a cryptographic check to make sure the header and Method / URL request is signed\n\t\tif suberr := verifySignatureHeaders(r); suberr != nil {\n\t\t\terr = parseError{suberr.Error(), http.StatusBadRequest}\n\t\t\treturn\n\t\t}\n\t}\n\n\t// All checks pass\n\treturn\n}", "func (*ObserveProposalVotesRequest) Descriptor() ([]byte, []int) {\n\treturn file_api_trading_proto_rawDescGZIP(), []int{43}\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\n\trf.mu.Lock()\n\trf.debug(\"***************Inside the RPC handler for sendRequestVote *********************\")\n\tdefer rf.mu.Unlock()\n\tvar lastIndex int\n\t//var lastTerm int\n\tif len(rf.log) > 0 {\n\t\tlastLogEntry := rf.log[len(rf.log)-1]\n\t\tlastIndex = lastLogEntry.LastLogIndex\n\t\t//lastTerm = lastLogEntry.lastLogTerm\n\t}else{\n\t\tlastIndex = 0\n\t\t//lastTerm = 0\n\t}\n\treply.Term = rf.currentTerm\n\t//rf.debug()\n\tif args.Term < rf.currentTerm {\n\t\treply.VoteGranted = false\n\t\trf.debug(\"My term is higher than candidate's term, myTerm = %d, candidate's term = %d\", rf.currentTerm,args.Term )\n\t} else if (rf.votedFor == -1 || rf.votedFor == args.CandidateId) && args.LastLogIndex >= lastIndex {\n\t\trf.votedFor = args.CandidateId\n\t\treply.VoteGranted = true\n\t\trf.currentTerm = args.Term\n\t\trf.resetElectionTimer()\n\t\t//rf.debug(\"I am setting my currentTerm to -->\",args.Term,\"I am \",rf.me)\n\t}\n}", "func queryVotesOnProposalHandlerFn(cdc *wire.Codec) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tvars := mux.Vars(r)\n\t\tstrProposalID := vars[RestProposalID]\n\n\t\tif len(strProposalID) == 0 {\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\terr := errors.New(\"proposalId required but not specified\")\n\t\t\tw.Write([]byte(err.Error()))\n\t\t\treturn\n\t\t}\n\n\t\tproposalID, err := strconv.ParseInt(strProposalID, 10, 64)\n\t\tif err != nil {\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\terr := errors.Errorf(\"proposalID [%s] is not positive\", proposalID)\n\t\t\tw.Write([]byte(err.Error()))\n\t\t\treturn\n\t\t}\n\n\t\tctx := context.NewCoreContextFromViper()\n\n\t\tres, err := ctx.QueryStore(gov.KeyProposal(proposalID), storeName)\n\t\tif err != nil || len(res) == 0 {\n\t\t\terr := errors.Errorf(\"proposalID [%d] does not exist\", proposalID)\n\t\t\tw.Write([]byte(err.Error()))\n\t\t\treturn\n\t\t}\n\n\t\tvar proposal gov.Proposal\n\t\tcdc.MustUnmarshalBinary(res, &proposal)\n\n\t\tif proposal.GetStatus() != gov.StatusVotingPeriod {\n\t\t\terr := errors.Errorf(\"proposal is not in Voting Period\", proposalID)\n\t\t\tw.Write([]byte(err.Error()))\n\t\t\treturn\n\t\t}\n\n\t\tres2, err := ctx.QuerySubspace(cdc, gov.KeyVotesSubspace(proposalID), storeName)\n\t\tif err != nil {\n\t\t\terr = errors.New(\"ProposalID doesn't exist\")\n\t\t\tw.Write([]byte(err.Error()))\n\t\t\treturn\n\t\t}\n\n\t\tvar votes []gov.Vote\n\n\t\tfor i := 0; i < len(res2); i++ {\n\t\t\tvar vote gov.Vote\n\t\t\tcdc.MustUnmarshalBinary(res2[i].Value, &vote)\n\t\t\tvotes = append(votes, vote)\n\t\t}\n\n\t\toutput, err := wire.MarshalJSONIndent(cdc, votes)\n\t\tif err != nil {\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\tw.Write([]byte(err.Error()))\n\t\t\treturn\n\t\t}\n\t\tw.Write(output)\n\t}\n}", "func (t transporter) SendVoteRequest(server *raft.Server, peer *raft.Peer, req *raft.RequestVoteRequest) *raft.RequestVoteResponse {\n\tvar rvrsp *raft.RequestVoteResponse\n\tvar b bytes.Buffer\n\tjson.NewEncoder(&b).Encode(req)\n\n\tdebug(\"Send Vote to %s\", peer.Name())\n\n\tresp, err := t.Post(fmt.Sprintf(\"%s/vote\", peer.Name()), &b)\n\n\tif err != nil {\n\t\tdebug(\"Cannot send VoteRequest to %s : %s\", peer.Name(), err)\n\t}\n\n\tif resp != nil {\n\t\tdefer resp.Body.Close()\n\t\trvrsp := &raft.RequestVoteResponse{}\n\t\tif err := json.NewDecoder(resp.Body).Decode(&rvrsp); err == nil || err == io.EOF {\n\t\t\treturn rvrsp\n\t\t}\n\n\t}\n\treturn rvrsp\n}", "func (*GetVotesByPartyRequest) Descriptor() ([]byte, []int) {\n\treturn file_api_trading_proto_rawDescGZIP(), []int{25}\n}", "func (rf *Raft) requestVote(req *opRequest) {\n\targs := req.args.(*pb.RequestVoteRequest)\n\treply := req.reply.(*pb.RequestVoteReply)\n\n\tif args.Term < rf.term {\n\t\treply.Term = rf.term\n\t\treply.Reject = true\n\t\treq.errorCh <- nil\n\t\treturn\n\t}\n\n\tif args.Term > rf.term {\n\t\trf.term = args.Term\n\t\trf.voteFor = 0\n\t}\n\tcanVote := rf.voteFor == args.Id ||\n\t\t(rf.voteFor == 0 && rf.raftLog.IsUptoDate(args.LastIndex, args.LastTerm))\n\tif canVote {\n\t\trf.voteFor = args.Id\n\t\trf.electionTimeoutCounter = 0\n\t\trf.becomeFollower(args.Term, 0)\n\t} else {\n\t\treply.Reject = true\n\t}\n\treply.Term = rf.term\n\treq.errorCh <- nil\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\trf.Lock()\n\tdefer rf.Unlock()\n\tRaftInfo(\"Get Request from %s\", rf, args.CandidateId)\n\tlastIndex, lastTerm := rf.getLastEntryInfo()\n\tisLogUpToDate := func() bool {\n\t\tif lastTerm == args.LastLogTerm {\n\t\t\treturn lastIndex <= args.LastLogIndex\n\t\t} else {\n\t\t\treturn lastTerm < args.LastLogTerm\n\t\t}\n\t}()\n\n\treply.Term = rf.currentTerm\n\treply.Id = rf.id\n\n\tif args.Term < rf.currentTerm {\n\t\treply.VoteGranted = false\n\t} else if args.Term >= rf.currentTerm && isLogUpToDate {\n\t\trf.transitionToFollower(args.Term)\n\t\trf.voteForID = args.CandidateId\n\t\treply.VoteGranted = true\n\t} else if (rf.voteForID == \"\" || args.CandidateId == rf.voteForID) && isLogUpToDate {\n\t\trf.voteForID = args.CandidateId\n\t\treply.VoteGranted = true\n\t}\n\n\trf.persist()\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\tcurrentTerm := rf.currentTerm\n\tif args == nil {\n\t\tDPrintf(\"Peer-%d received a null vote request.\", rf.me)\n\t\treturn\n\t}\n\tcandidateTerm := args.Term\n\tcandidateId := args.Candidate\n\tDPrintf(\"Peer-%d received a vote request %v from peer-%d.\", rf.me, *args, candidateId)\n\tif candidateTerm < currentTerm {\n\t\tDPrintf(\"Peer-%d's term=%d > candidate's term=%d.\\n\", rf.me, currentTerm, candidateTerm)\n\t\treply.Term = currentTerm\n\t\treply.VoteGrant = false\n\t\treturn\n\t} else if candidateTerm == currentTerm {\n\t\tif rf.voteFor != -1 && rf.voteFor != candidateId {\n\t\t\tDPrintf(\"Peer-%d has grant to peer-%d before this request from peer-%d.\", rf.me, rf.voteFor, candidateId)\n\t\t\treply.Term = currentTerm\n\t\t\treply.VoteGrant = false\n\t\t\treturn\n\t\t}\n\t\tDPrintf(\"Peer-%d's term=%d == candidate's term=%d, to check index.\\n\", rf.me, currentTerm, candidateTerm)\n\t} else {\n\t\tDPrintf(\"Peer-%d's term=%d < candidate's term=%d.\\n\", rf.me, currentTerm, candidateTerm)\n\t\t// begin to update status\n\t\trf.currentTerm = candidateTerm // find larger term, up to date\n\t\trf.transitionState(NewTerm) // transition to Follower.\n\t\tgo func() {\n\t\t\trf.eventChan <- NewTerm // tell the electionService to change state.\n\t\t}()\n\t}\n\t// check whose log is up-to-date\n\tcandiLastLogIndex := args.LastLogIndex\n\tcandiLastLogTerm := args.LastLogTerm\n\tlocalLastLogIndex := len(rf.log) - 1\n\tlocalLastLogTerm := -1\n\tif localLastLogIndex >= 0 {\n\t\tlocalLastLogTerm = rf.log[localLastLogIndex].Term\n\t}\n\t// check term first, if term is the same, then check the index.\n\tDPrintf(\"Peer-%d try to check last entry, loacl: index=%d;term=%d, candi: index=%d,term=%d.\", rf.me, localLastLogIndex, localLastLogTerm, candiLastLogIndex, candiLastLogTerm)\n\tif localLastLogTerm > candiLastLogTerm {\n\t\treply.Term = rf.currentTerm\n\t\treply.VoteGrant = false\n\t\treturn\n\t} else if localLastLogTerm == candiLastLogTerm {\n\t\tif localLastLogIndex > candiLastLogIndex {\n\t\t\treply.Term = rf.currentTerm\n\t\t\treply.VoteGrant = false\n\t\t\treturn\n\t\t}\n\t} else {\n\t}\n\t// heartbeat.\n\tgo func() {\n\t\trf.eventChan <- HeartBeat\n\t}()\n\t// local log are up-to-date, grant\n\t// before grant to candidate, we should reset ourselves state.\n\trf.transitionState(NewLeader)\n\trf.voteFor = candidateId\n\treply.Term = rf.currentTerm\n\treply.VoteGrant = true\n\tDPrintf(\"Peer-%d grant to peer-%d.\", rf.me, candidateId)\n\trf.persist()\n\treturn\n}", "func (q queryServer) Vote(ctx context.Context, req *v1.QueryVoteRequest) (*v1.QueryVoteResponse, error) {\n\tif req == nil {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"invalid request\")\n\t}\n\n\tif req.ProposalId == 0 {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"proposal id can not be 0\")\n\t}\n\n\tif req.Voter == \"\" {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"empty voter address\")\n\t}\n\n\tvoter, err := q.k.authKeeper.AddressCodec().StringToBytes(req.Voter)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvote, err := q.k.Votes.Get(ctx, collections.Join(req.ProposalId, sdk.AccAddress(voter)))\n\tif err != nil {\n\t\tif errors.IsOf(err, collections.ErrNotFound) {\n\t\t\treturn nil, status.Errorf(codes.InvalidArgument,\n\t\t\t\t\"voter: %v not found for proposal: %v\", req.Voter, req.ProposalId)\n\t\t}\n\t\treturn nil, status.Error(codes.Internal, err.Error())\n\t}\n\n\treturn &v1.QueryVoteResponse{Vote: &vote}, nil\n}", "func (rf *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here.\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\tdefer rf.persist()\n\trf.updateTerm(args.Term)\n\treply.Term = rf.currentTerm\n\tlastLogIndex := rf.lastIncludedIndex + len(rf.log) - 1\n\tlastLogTerm := rf.log[len(rf.log)-1].Term\n\treply.VoteGranted = (rf.votedFor == -1 || rf.votedFor == args.CandidateId) && (lastLogTerm < args.LastLogTerm || lastLogTerm == args.LastLogTerm && lastLogIndex <= args.LastLogIndex)\n\tif reply.VoteGranted {\n\t\trf.votedFor = args.CandidateId\n\t}\n}", "func (_Bep20 *Bep20Caller) GetPriorVotes(opts *bind.CallOpts, account common.Address, blockNumber *big.Int) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _Bep20.contract.Call(opts, &out, \"getPriorVotes\", account, blockNumber)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (r *Raft) requestVote(rpc RPC, req *RequestVoteRequest) (transition bool) {\n\tr.peerLock.Lock()\n\tdefer r.peerLock.Unlock()\n\t// Setup a response\n\tpeers := make([][]byte, 0, len(r.peers))\n\tfor _, p := range r.peers {\n\t\tpeers = append(peers, []byte(p.String()))\n\t}\n\tresp := &RequestVoteResponse{\n\t\tTerm: r.getCurrentTerm(),\n\t\tGranted: false,\n\t\tPeers: peers,\n\t}\n\tvar err error\n\tdefer rpc.Respond(resp, err)\n\n\t// Ignore an older term\n\tif req.Term < r.getCurrentTerm() {\n\t\terr = errors.New(\"obsolete term\")\n\t\treturn\n\t}\n\n\t// Increase the term if we see a newer one\n\tif req.Term > r.getCurrentTerm() {\n\t\tif err := r.setCurrentTerm(req.Term); err != nil {\n\t\t\tr.logE.Printf(\"Failed to update current term: %w\", err)\n\t\t\treturn\n\t\t}\n\t\tresp.Term = req.Term\n\n\t\t// Ensure transition to follower\n\t\ttransition = true\n\t\tr.setState(Follower)\n\t}\n\n\t// Check if we have voted yet\n\tlastVoteTerm, err := r.stable.GetUint64(keyLastVoteTerm)\n\tif err != nil && err.Error() != \"not found\" {\n\t\tr.logE.Printf(\"raft: Failed to get last vote term: %w\", err)\n\t\treturn\n\t}\n\tlastVoteCandyBytes, err := r.stable.Get(keyLastVoteCand)\n\tif err != nil && err.Error() != \"not found\" {\n\t\tr.logE.Printf(\"raft: Failed to get last vote candidate: %w\", err)\n\t\treturn\n\t}\n\n\t// Check if we've voted in this election before\n\tif lastVoteTerm == req.Term && lastVoteCandyBytes != nil {\n\t\tr.logW.Printf(\"raft: Duplicate RequestVote for same term: %d\", req.Term)\n\t\tif bytes.Compare(lastVoteCandyBytes, req.Candidate) == 0 {\n\t\t\tr.logW.Printf(\"raft: Duplicate RequestVote from candidate: %s\", req.Candidate)\n\t\t\tresp.Granted = true\n\t\t}\n\t\treturn\n\t}\n\n\t// Reject if their term is older\n\tif r.getLastLogIndex() > 0 {\n\t\tvar lastLog Log\n\t\tif err := r.logs.GetLog(r.getLastLogIndex(), &lastLog); err != nil {\n\t\t\tr.logE.Printf(\"Failed to get last log: %d %v\",\n\t\t\t\tr.getLastLogIndex(), err)\n\t\t\treturn\n\t\t}\n\t\tif lastLog.Term > req.LastLogTerm {\n\t\t\tr.logW.Printf(\"Rejecting vote since our last term is greater\")\n\t\t\treturn\n\t\t}\n\n\t\tif lastLog.Index > req.LastLogIndex {\n\t\t\tr.logW.Printf(\"Rejecting vote since our last index is greater\")\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Persist a vote for safety\n\tif err := r.persistVote(req.Term, req.Candidate); err != nil {\n\t\tr.logE.Printf(\"raft: Failed to persist vote: %w\", err)\n\t\treturn\n\t}\n\n\tresp.Granted = true\n\treturn\n}", "func GetUserVotes(c *gin.Context) {\n\tuuid := c.Param(\"uuid\")\n\tvar user models.User\n\tvar votes []models.Vote\n\n\t// check if vote exists throw an not found error if not\n\tdb := db.GetDB()\n\tif err := db.Where(\"uuid = ?\", uuid).First(&user).Error; err != nil {\n\t\tc.AbortWithStatus(http.StatusNotFound)\n\t\treturn\n\t}\n\n\t// // Find vote and associated voter\n\t// db.Model(&vote).Association(\"UUIDVote\").Find(&user.UUIDVote)\n\n\t// // Get only all uuid from voter list\n\t// voteUUIDs := []string{}\n\t// for _, v := range user.UUIDVote {\n\t// \tvoteUUIDs = append(voteUUIDs, v.UUID.String())\n\t// }\n\n\tdb.Model(&user).Related(&votes, \"Votes\")\n\n\t// return json data\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"user\": user,\n\t\t\"votes\": votes,\n\t})\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n fmt.Printf(\"\\n -> I the Peer %d in got Vote Request from cadidate %d!\\n\",rf.me, args.CandidateId)\n \n rf.mu.Lock()\n defer rf.mu.Unlock() // TODO: ask professor/TA about this atomisitc and if mutex is needed.\n \n reply.FollowerTerm = rf.currentTerm\n \n rf.CheckTerm(args.CandidateTerm) \n \n // 2B code - fix if needed\n logUpToDate := false\n if len(rf.log) == 0 {\n logUpToDate = true\n } else if rf.log[len(rf.log)-1].Term < args.LastLogTerm {\n logUpToDate = true\n } else if rf.log[len(rf.log)-1].Term == args.LastLogTerm && \n len(rf.log) <= (args.LastLogIndex+1) {\n logUpToDate = true\n }\n // 2B code end\n \n reply.VoteGranted = (rf.currentTerm <= args.CandidateTerm && \n (rf.votedFor == -1 || rf.votedFor == args.CandidateId) &&\n logUpToDate) \n\n if reply.VoteGranted {\n rf.votedFor = args.CandidateId\n fmt.Printf(\"-> I the Peer %d say: Vote for cadidate %d Granted!\\n\",rf.me, args.CandidateId)\n } else {\n fmt.Printf(\"-> I the Peer %d say: Vote for cadidate %d Denied :/\\n\",rf.me, args.CandidateId)\n }\n}", "func FetchVotes(c *gin.Context) {\n\tid, err := utils.GetSessionID(c)\n\tif err != nil || id != \"CEO\" {\n\t\tc.String(http.StatusForbidden, \"Only the CEO can access this.\")\n\t\treturn\n\t}\n\n\tvotes, err := ElectionDb.GetVotes()\n\tif err != nil {\n\t\tc.String(http.StatusInternalServerError, \"Error while fetching votes.\")\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, &votes)\n}", "func (rf *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply) {\n\tresp := make(chan interface{})\n\trf.rpcCh <- rpcCall{command: args, reply: resp}\n\n\t*reply = (<-resp).(RequestVoteReply)\n}", "func (*CommissionVotesRequest) Descriptor() ([]byte, []int) {\n\treturn file_resources_proto_rawDescGZIP(), []int{5}\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\n\tlastLogIndex, lastLogTerm := len(rf.log) + rf.compactIndex , 0\n\tif lastLogIndex > rf.compactIndex {\n\t\tlastLogTerm = rf.log[lastLogIndex - rf.compactIndex -1].Term\n\t} else if lastLogIndex == rf.compactIndex {\n\t\tlastLogTerm = rf.compactTerm\n\t}\n\n\tif args.Term < rf.currentTerm || (args.Term == rf.currentTerm && args.CandidateID != rf.votedFor) || args.LastLogTerm < lastLogTerm || (args.LastLogTerm == lastLogTerm && lastLogIndex > args.LastLogIndex) {\n\t\t// 1. The Term of RequestVote is out of date.\n\t\t// 2. The instance vote for other peer in this term.\n\t\t// 3. The log of Candidate is not the most update.\n\t\treply.VoteGranted = false\n\t\treply.Term = rf.currentTerm\n\t} else {\n\t\t// DPrintf(\"instance %d vote for %d, Term is %d, lastLogTerm is %d, args.LastLogTerm is %d, lastLogIndex is %d, args.LastLogIndex is %d, original votedFor is %d\", rf.me, args.CandidateID, args.Term, lastLogTerm, args.LastLogTerm, lastLogIndex, args.LastLogIndex, rf.votedFor)\n\t\trf.votedFor = args.CandidateID\n\t\trf.currentTerm = args.Term\n\n\t\treply.VoteGranted = true\n\t\treply.Term = rf.currentTerm\n\n\t\tif rf.role == Follower {\n\t\t\trf.validRpcTimestamp = time.Now()\n\t\t} else {\n\t\t\t// Notify the change of the role of instance.\n\t\t\tclose(rf.rollback)\n\t\t\trf.role = Follower\n\t\t}\n\t}\n\n\treturn\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\tgrantVote := false\n\trf.updateTerm(args.Term) // All servers: if args.Term > rf.currentTerm, set currentTerm, convert to follower\n\n\tswitch rf.state {\n\tcase Follower:\n\t\tif args.Term < rf.currentTerm {\n\t\t\tgrantVote = false\n\t\t} else if rf.votedFor == -1 || rf.votedFor == args.CandidateId {\n\t\t\tif len(rf.logs) == 0 {\n\t\t\t\tgrantVote = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tlastLogTerm := rf.logs[len(rf.logs) - 1].Term\n\t\t\tif (lastLogTerm == args.LastLogTerm && len(rf.logs) <= args.LastLogIndex) || lastLogTerm < args.LastLogTerm {\n\t\t\t\tgrantVote = true\n\t\t\t}\n\t\t}\n\tcase Leader:\n\t\t// may need extra operation since the sender might be out-dated\n\tcase Candidate:\n\t\t// reject because rf has already voted for itself since it's in\n\t\t// Candidate state\n\t}\n\n\tif grantVote {\n\t\t// DPrintf(\"Peer %d: Granted RequestVote RPC from %d.(@%s state)\\n\", rf.me, args.CandidateId, rf.state)\n\t\treply.VoteGranted = true\n\t\trf.votedFor = args.CandidateId\n\t\t// reset election timeout\n\t\trf.hasHeartbeat = true\n\t} else {\n\t\t// DPrintf(\"Peer %d: Rejected RequestVote RPC from %d.(@%s state)\\n\", rf.me, args.CandidateId, rf.state)\n\t\treply.VoteGranted = false\n\t}\n\treply.VotersTerm = rf.currentTerm\n\n\t// when deal with cluster member changes, may also need to reject Request\n\t// within MINIMUM ELECTION TIMEOUT\n}", "func (r *Raft) broadcastRequestVote(ctx context.Context) {\n\tr.stateMutex.RLock()\n\trequest := &pb.RequestVoteRequest{\n\t\tTerm: r.stateManager.GetCurrentTerm(),\n\t\tCandidateId: r.settings.ID,\n\t\tLastLogIndex: r.logManager.GetLastLogIndex(),\n\t\tLastLogTerm: r.logManager.GetLastLogTerm(),\n\t}\n\tr.stateMutex.RUnlock()\n\n\tresponses := r.cluster.BroadcastRequestVoteRPCs(ctx, request)\n\n\t// Count of votes starts at one because the server always votes for itself\n\tcountOfVotes := 1\n\n\tr.stateMutex.Lock()\n\tdefer r.stateMutex.Unlock()\n\n\t// Check if the state hasn't been changed in the meantime\n\tif r.stateManager.GetRole() != CANDIDATE {\n\t\treturn\n\t}\n\n\t// Count the number of votes\n\tfor _, response := range responses {\n\t\t// Server was unable to respond\n\t\tif response == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\t// If the response contains higher term, we convert to follower\n\t\tif response.GetTerm() > r.stateManager.GetCurrentTerm() {\n\t\t\tr.stateManager.SwitchPersistentState(response.GetTerm(), nil, FOLLOWER)\n\t\t\treturn\n\t\t}\n\n\t\tif response.GetVoteGranted() {\n\t\t\tcountOfVotes++\n\t\t}\n\t}\n\n\t// Check if majority reached\n\tif r.checkClusterMajority(countOfVotes) {\n\t\tr.stateManager.SwitchPersistentState(r.stateManager.GetCurrentTerm(), nil, LEADER)\n\t}\n}", "func (_Bep20 *Bep20CallerSession) GetPriorVotes(account common.Address, blockNumber *big.Int) (*big.Int, error) {\n\treturn _Bep20.Contract.GetPriorVotes(&_Bep20.CallOpts, account, blockNumber)\n}", "func (r *Raft) prepRequestVote() RequestVote {\n\tLastLogIndex := r.MyMetaData.LastLogIndex\n\t//if this is the request when log is empty\n\tvar lastLogTerm int\n\tif len(r.MyLog) == 0 {\n\t\tlastLogTerm = -1\n\t} else {\n\t\tlastLogTerm = r.MyLog[LastLogIndex].Term\n\t}\n\t//fmt.Println(\"here2\")\n\treqVoteObj := RequestVote{r.myCV.CurrentTerm, r.Myconfig.Id, LastLogIndex, lastLogTerm}\n\treturn reqVoteObj\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\n\tdefer rf.persist()\n\n\treply.VoteGranted = false\n\n\tif args.Term < rf.currentTerm {\n\t\treply.Term = rf.currentTerm\n\t\treply.VoteGranted = false\n\t\treturn\n\t}\n\n\tif args.Term == rf.currentTerm {\n\t\tif rf.voteFor == -1 || rf.voteFor == args.CandidateId {\n\t\t\tlastLogTerm, lastLogIdx := rf.getLastLogTermAndIdx()\n\t\t\tif lastLogTerm < args.LastLogTerm || lastLogTerm == args.LastLogTerm && lastLogIdx <= args.LastLogIdx {\n\t\t\t\treply.VoteGranted = true\n\t\t\t\trf.voteFor = args.CandidateId\n\t\t\t\treturn\n\t\t\t} else {\n\t\t\t\treply.VoteGranted = false\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\treply.VoteGranted = false\n\t\t\treturn\n\t\t}\n\t}\n\n\tif args.Term > rf.currentTerm {\n\t\t//收到更大的term,先更新状态;再判断日志的新旧来投票\n\t\trf.changeToFollower(args.Term)\n\t\t//fixbug: 忘记在收到更大的term时更新votefor\n\t\trf.voteFor = -1\n\n\t\treply.Term = args.Term\n\n\t\tlastLogTerm, lastLogIdx := rf.getLastLogTermAndIdx()\n\t\tif lastLogTerm < args.LastLogTerm || lastLogTerm == args.LastLogTerm && lastLogIdx <= args.LastLogIdx {\n\t\t\treply.VoteGranted = true\n\t\t\trf.voteFor = args.CandidateId\n\t\t\treturn\n\t\t} else {\n\t\t\treply.VoteGranted = false\n\t\t\treturn\n\t\t}\n\t}\n\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\t//fmt.Println(\"got vote request at server id: \", rf.me)\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\n\tif rf.currentTerm > args.Term {\n\t\treply.VoteGranted = false\n\t\treply.Term = rf.currentTerm\n\t\treturn\n\t} else if rf.currentTerm < args.Term {\n\t\trf.currentTerm = args.Term\n\t\treply.Term = rf.currentTerm\n\t\trf.state = follower\n\t}\n\t\n\tgranted := false\n\tif rf.votedFor == nil {\n\t\tgranted = true\n\t} else if *rf.votedFor == args.CandidateId {\n\t\tgranted = true\n\t}\n\tif !granted {\n\t\treply.VoteGranted = false\n\t\treturn\n\t}\n\n\tif args.LastLogIndex != len(rf.log)-1 {\n\t\tgranted = false\n\t} else {\n\t\tif args.LastLogTerm != rf.log[len(rf.log)-1].Term {\n\t\t\tgranted = false\n\t\t}\n\t}\n\t\n\tif !granted {\n\t\treply.VoteGranted = false\n\t\treturn\n\t}\n\n\treply.VoteGranted = true\n\trf.rpcCh<-voteRpc\n\treturn\n}", "func (*ObservePartyVotesRequest) Descriptor() ([]byte, []int) {\n\treturn file_api_trading_proto_rawDescGZIP(), []int{45}\n}", "func (_Bep20 *Bep20Session) GetPriorVotes(account common.Address, blockNumber *big.Int) (*big.Int, error) {\n\treturn _Bep20.Contract.GetPriorVotes(&_Bep20.CallOpts, account, blockNumber)\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\tDPrintf(\"peer-%d gets a RequestVote RPC.\", rf.me)\n\t// Your code here (2A, 2B).\n\t// First, we need to detect obsolete information\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\tif args.Term < rf.currentTerm {\n\t\treply.VoteGranted = false\n\t\treply.Term = rf.currentTerm\n\t\treturn\n\t}\n\n\tstepdown := false\n\t// step down and convert to follower, adopt the args.Term\n\tif args.Term > rf.currentTerm {\n\t\trf.currentTerm = args.Term\n\t\told_state := rf.state\n\t\trf.state = Follower\n\t\tif old_state == Leader {\n\t\t\trf.nonleaderCh <- true\n\t\t}\n\t\trf.votedFor = -1\n\t\trf.persist()\n\t\tstepdown = true\n\t}\n\n\t// 5.4.1 Election restriction : if the requester's log isn't more up-to-date than this peer's, don't vote for it.\n\t// check whether the requester's log is more up-to-date.(5.4.1 last paragraph)\n\tif len(rf.log) > 0 { // At first, there's no log entry in rf.log\n\t\tif rf.log[len(rf.log)-1].Term > args.LastLogTerm {\n\t\t\t// this peer's log is more up-to-date than requester's.\n\t\t\treply.VoteGranted = false\n\t\t\treply.Term = rf.currentTerm\n\t\t\treturn\n\t\t} else if rf.log[len(rf.log)-1].Term == args.LastLogTerm {\n\t\t\tif len(rf.log) > args.LastLogIndex {\n\t\t\t\t// this peer's log is more up-to-date than requester's.\n\t\t\t\treply.VoteGranted = false\n\t\t\t\treply.Term = rf.currentTerm\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\t// requester's log is more up-to-date than requester's.\n\t// Then, we should check whether this server has voted for another server in the same term\n\tif stepdown {\n\t\trf.resetElectionTimeout()\n\t\t// now we need to reset the election timer.\n\t\trf.votedFor = args.CandidateId // First-come-first-served\n\t\trf.persist()\n\t\treply.VoteGranted = true\n\t\treply.Term = rf.currentTerm\n\t\treturn\n\t}\n\n\t/* Section 5.5 :\n\t * The server may crash after it completing an RPC but before responsing, then it will receive the same RPC again after it restarts.\n\t * Raft RPCs are idempotent, so this causes no harm.\n\t */\n\tif rf.votedFor == -1 || rf.votedFor == args.CandidateId {\n\t\trf.votedFor = args.CandidateId\n\t\trf.persist()\n\t\treply.VoteGranted = true\n\t} else {\n\t\treply.VoteGranted = false // First-come-first-served, this server has voted for another server before.\n\t}\n\treply.Term = rf.currentTerm\n\treturn\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\t// defer DPrintf(\"%d(%d|term%d|vote%d) replyed %d(%d) with %s\", rf.me, rf.state, rf.currentTerm, rf.votedFor, args.CandidateId, args.Term, reply)\n\n\tif args.Term < rf.currentTerm {\n\t\treply.VoteGranted = false\n\t\treturn\n\t}\n\n\tif (rf.votedFor == -1 || rf.votedFor == args.CandidateId) && args.LastLogIndex >= rf.lastApplied {\n\t\t//rf.resetHeartBeatsTimer()\n\n\t\treply.VoteGranted = true\n\t\t// rf.currentTerm += 1\n\t\trf.currentTerm = args.Term\n\t\trf.votedFor = args.CandidateId\n\t\trf.state = FOLLOWER\n\t\treturn\n\t} else {\n\t\treply.VoteGranted = false\n\t}\n\treply.Term = rf.currentTerm\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\tcurrentTerm := rf.currentTerm\n\n\t//If RPC request or response contains term T > currentTerm:\n\t//set currentTerm = T, convert to follower\n\tif (args.Term > currentTerm) {\n\t\trf.currentTerm = args.Term\n\t\trf.votedFor = NILVOTE\n\n\t\tif rf.role == LEADER {\n\t\t\tDPrintf(\"LeaderCondition sorry server %d term %d not a leader, logs %v, commitIndex %d\\n\",rf.me, rf.currentTerm, rf.log, rf.commitIndex) \n\t\t} \n\t\trf.role = FOLLOWER\n\t\trf.persist()\n\t}\n\n\tif args.Term < currentTerm {\n\t\t// Reply false if term < currentTerm \n\t\treply.VoteGranted = false\n\t\treply.Term = currentTerm \n\t}else {\n\t\t//If votedFor is null or candidateId,\n\t\t//and candidate’s log is at least as up-to-date as receiver’s log,\n\t\t//&& rf.atLeastUptodate(args.LastLogIndex, args.LastLogTerm)\n\t\tif (rf.votedFor == NILVOTE || rf.votedFor == args.CandidateId) && rf.atLeastUptodate(args.LastLogIndex, args.LastLogTerm) {\n\t\t\ti , t := rf.lastLogIdxAndTerm()\n\t\t\tPrefixDPrintf(rf, \"voted to candidate %d, args %v, lastlogIndex %d, lastlogTerm %d\\n\", args.CandidateId, args, i, t)\n\t\t\trf.votedFor = args.CandidateId\n\t\t\trf.persist()\t\n\t\t\treply.VoteGranted = true\n\t\t\treply.Term = rf.currentTerm\n\t\t\t//you grant a vote to another peer.\n\t\t\trf.resetTimeoutEvent = makeTimestamp()\n\t\t}else {\n\t\t\treply.VoteGranted = false\n\t\t\treply.Term = rf.currentTerm\n\t\t}\t\n\t}\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\n\t//defer rf.updateAppliedLock()\n\t//Your code here (2A, 2B).\n\tisALeader := rf.role == Leader\n\n\tif rf.updateTermLock(args.Term) && isALeader {\n\t\t//DPrintf(\"[DEBUG] Server %d from %d to Follower {requestVote : Term higher}\", rf.me, Leader)\n\t}\n\treply.VoteCranted = false\n\tvar votedFor interface{}\n\t//var isLeader bool\n\tvar candidateID, currentTerm, candidateTerm, currentLastLogIndex, candidateLastLogIndex, currentLastLogTerm, candidateLastLogTerm int\n\n\tcandidateID = args.CandidateID\n\tcandidateTerm = args.Term\n\tcandidateLastLogIndex = args.LastLogIndex\n\tcandidateLastLogTerm = args.LastLogTerm\n\n\trf.mu.Lock()\n\n\treply.Term = rf.currentTerm\n\tcurrentTerm = rf.currentTerm\n\tcurrentLastLogIndex = len(rf.logs) - 1 //TODO: fix the length corner case\n\tcurrentLastLogTerm = rf.logs[len(rf.logs)-1].Term\n\tvotedFor = rf.votedFor\n\tisFollower := rf.role == Follower\n\trf.mu.Unlock()\n\t//case 0 => I'm leader, so you must stop election\n\tif !isFollower {\n\t\tDPrintf(\"[DEBUG] Case0 I [%d] is Candidate than %d\", rf.me, args.CandidateID)\n\t\treturn\n\t}\n\n\t//case 1 => the candidate is not suit to be voted\n\tif currentTerm > candidateTerm {\n\t\tDPrintf(\"[DEBUG] Case1 Follower %d > Candidate %d \", rf.me, args.CandidateID)\n\t\treturn\n\t}\n\n\t//case 2 => the candidate's log is not lastest than the follwer\n\tif currentLastLogTerm > candidateLastLogTerm || (currentLastLogTerm == candidateLastLogTerm && currentLastLogIndex > candidateLastLogIndex) {\n\t\tDPrintf(\"[DEBUG] Case2 don't my[%d] newer than can[%d]\", rf.me, args.CandidateID)\n\t\treturn\n\t}\n\trf.mu.Lock()\n\t//case3 => I have voted and is not you\n\tif votedFor != nil && votedFor != candidateID {\n\t\trf.mu.Unlock()\n\t\treturn\n\t}\n\n\t//now I will vote you\n\n\tvar notFollower bool\n\trf.votedFor = candidateID\n\tif rf.role != Follower {\n\t\tnotFollower = true\n\t}\n\tDPrintf(\"[Vote] Server[%d] vote to Can[%d]\", rf.me, args.CandidateID)\n\trf.role = Follower\n\treply.VoteCranted = true\n\trf.mu.Unlock()\n\trf.persist()\n\tif notFollower {\n\t\trf.msgChan <- RecivedVoteRequest\n\t} else {\n\t\trf.msgChan <- RecivedVoteRequest\n\t}\n\n\treturn\n}", "func (r *RaftNode) Vote(rv RequestVoteStruct, response *RPCResponse) error {\n\tr.Lock()\n\tdefer r.Unlock()\n\tif r.verbose {\n\t\tlog.Println(\"Vote()\")\n\t}\n\n\tdefer r.persistState()\n\n\tresponse.Term = r.CurrentTerm\n\n\tmyLastLogTerm := r.getLastLogTerm()\n\tmyLastLogIdx := r.getLastLogIndex()\n\n\tif r.verbose {\n\t\tlog.Printf(\"RequestVoteStruct: %s. \\nMy node: term: %d, votedFor %d, lastLogTerm: %d, lastLogIdx: %d\",\n\t\t\trv.String(), r.CurrentTerm, r.VotedFor, myLastLogTerm, myLastLogIdx)\n\t}\n\n\tlooksEligible := r.CandidateLooksEligible(rv.LastLogIdx, rv.LastLogTerm)\n\n\tif rv.Term > r.CurrentTerm {\n\t\tr.shiftToFollower(rv.Term, HostID(-1)) // We do not yet know who is leader for this term\n\t}\n\n\tif rv.Term < r.CurrentTerm {\n\t\tif r.verbose {\n\t\t\tlog.Println(\"RV from prior term - do not grant vote\")\n\t\t}\n\t\tresponse.Success = false\n\t} else if (r.VotedFor == -1 || r.VotedFor == rv.CandidateID) && looksEligible {\n\t\tif r.verbose {\n\t\t\tlog.Println(\"Grant vote\")\n\t\t}\n\t\tr.resetTickers()\n\t\tresponse.Success = true\n\t\tr.VotedFor = rv.CandidateID\n\t} else {\n\t\tif r.verbose {\n\t\t\tlog.Println(\"Do not grant vote\")\n\t\t}\n\t\tresponse.Success = false\n\t}\n\n\treturn nil\n}", "func (rf *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here.\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\n\tmay_grant_vote := true\n\tif len(rf.logs) > 0 {\n\t\t// rf.logs_term[len(rf.logs)-1] will always there, no matter snapshotedCount\n\t\tif rf.logs_term[len(rf.logs)-1] > args.LastLogTerm ||\n\t\t\t(rf.logs_term[len(rf.logs)-1] == args.LastLogTerm && len(rf.logs) > args.LogCount) {\n\t\t\tmay_grant_vote = false\n\t\t}\n\t}\n\trf.logger.Printf(\"Got vote request: %v, may grant vote: %v\\n\", args, may_grant_vote)\n\n\tif args.Term < rf.currentTerm {\n\t\trf.logger.Printf(\"Got vote request with term = %v, reject\\n\", args.Term)\n\t\treply.Term = rf.currentTerm\n\t\treply.Granted = false\n\t\treturn\n\t}\n\n\tif args.Term == rf.currentTerm {\n\t\trf.logger.Printf(\"Got vote request with current term, now voted for %v\\n\", rf.votedFor)\n\t\tif rf.votedFor == -1 && may_grant_vote {\n\t\t\trf.votedFor = args.CandidateID\n\t\t\trf.persist()\n\t\t}\n\t\treply.Granted = (rf.votedFor == args.CandidateID)\n\t\treply.Term = rf.currentTerm\n\t\treturn\n\t}\n\tif args.Term > rf.currentTerm {\n\t\trf.logger.Printf(\"Got vote request with term = %v, follow it\\n\", args.Term)\n\t\trf.state = FOLLOWER\n\t\trf.currentTerm = args.Term\n\t\trf.votedFor = -1\n\t\tif may_grant_vote {\n\t\t\trf.votedFor = args.CandidateID\n\t\t\trf.persist()\n\t\t}\n\t\trf.resetTimer()\n\n\t\treply.Granted = (rf.votedFor == args.CandidateID)\n\t\treply.Term = args.Term\n\t\treturn\n\t}\n}", "func (_Bep20 *Bep20Caller) GetCurrentVotes(opts *bind.CallOpts, account common.Address) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _Bep20.contract.Call(opts, &out, \"getCurrentVotes\", account)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func voteInv(c *cmdVoteInv) (map[string][]string, error) {\n\t// Setup client\n\topts := pclient.Opts{\n\t\tHTTPSCert: cfg.HTTPSCert,\n\t\tVerbose: cfg.Verbose,\n\t\tRawJSON: cfg.RawJSON,\n\t}\n\tpc, err := pclient.New(cfg.Host, opts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Setup status and page number\n\tvar status tkv1.VoteStatusT\n\tif c.Args.Status != \"\" {\n\t\t// Parse status. This can be either the numeric status code or the\n\t\t// human readable equivalent.\n\t\tstatus, err = parseVoteStatus(c.Args.Status)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// If a status was given but no page number was give, default\n\t\t// to page number 1.\n\t\tif c.Args.Page == 0 {\n\t\t\tc.Args.Page = 1\n\t\t}\n\t}\n\n\t// Get vote inventory\n\ti := tkv1.Inventory{\n\t\tStatus: status,\n\t\tPage: c.Args.Page,\n\t}\n\tir, err := pc.TicketVoteInventory(i)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Print inventory\n\tprintJSON(ir)\n\n\treturn ir.Vetted, nil\n\n}", "func (rf *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply) {\n\t//fmt.Printf(\"[::RequestVote]\\n\")\n\t// Your code here.\n\trf.mtx.Lock()\n\tdefer rf.mtx.Unlock()\n\tdefer rf.persist()\n\n\treply.VoteGranted = false\n\n\t// case 1: check term\n\tif args.Term < rf.currentTerm {\n\t\treply.Term = rf.currentTerm\n\t\treturn\n\t}\n\n\tif args.Term > rf.currentTerm { // set term to max. and then maybe become leader.\n\t\trf.currentTerm = args.Term\n\t\trf.state = STATE_FOLLOWER\n\t\trf.voteFor = -1\n\t}\n\treply.Term = rf.currentTerm\n\n\t// case 2: check log\n\tisNewer := false\n\tif args.LastLogTerm == rf.log[len(rf.log)-1].Term {\n\t\tisNewer = args.LastLogIndex >= rf.log[len(rf.log)-1].LogIndex\n\t} else {\n\t\tisNewer = args.LastLogTerm > rf.log[len(rf.log)-1].Term\n\t}\n\n\tif (rf.voteFor == -1 || rf.voteFor == args.CandidateId) && isNewer {\n\t\trf.chanVoteOther <- 1\n\t\trf.state = STATE_FOLLOWER\n\t\treply.VoteGranted = true\n\t\trf.voteFor = args.CandidateId\n\t}\n\n}", "func (rf *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here.\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\n\tbbit := true\n\tif len(rf.log) > 0 {\n\t\tlastLogTerm := rf.log[len(rf.log)-1].Term\n\t\tif lastLogTerm > args.LastLogTerm {\n\t\t\tbbit = false\n\t\t} else if lastLogTerm == args.LastLogTerm &&\n\t\t\tlen(rf.log)-1 > args.LastLogIndex {\n\t\t\tbbit = false\n\t\t}\n\t}\n\n\tif args.Term < rf.currentTerm {\n\t\treply.Term = rf.currentTerm\n\t\treply.VoteGranted = false\n\t\treturn\n\t}\n\tif args.Term == rf.currentTerm {\n\t\treply.Term = rf.currentTerm\n\t\tif rf.votedFor == -1 && bbit {\n\t\t\trf.votedFor = args.CandidateId\n\t\t\trf.persist()\n\t\t\treply.VoteGranted = true\n\t\t} else {\n\t\t\treply.VoteGranted = false\n\t\t}\n\t\treturn\n\t}\n\tif args.Term > rf.currentTerm {\n\t\trf.state = FOLLOWER\n\t\trf.currentTerm = args.Term\n\t\trf.votedFor = -1\n\t\trf.timer.Reset(properTimeDuration(rf.state))\n\t\treply.Term = args.Term\n\t\tif bbit {\n\t\t\trf.votedFor = args.CandidateId\n\t\t\trf.persist()\n\t\t\treply.VoteGranted = true\n\t\t} else {\n\t\t\treply.VoteGranted = false\n\t\t}\n\t\treturn\n\t}\n\treturn\n}", "func (_Contract *ContractCaller) GetVote(opts *bind.CallOpts, from common.Address, delegatedTo common.Address, proposalID *big.Int) (struct {\n\tWeight *big.Int\n\tChoices []*big.Int\n}, error) {\n\tvar out []interface{}\n\terr := _Contract.contract.Call(opts, &out, \"getVote\", from, delegatedTo, proposalID)\n\n\toutstruct := new(struct {\n\t\tWeight *big.Int\n\t\tChoices []*big.Int\n\t})\n\tif err != nil {\n\t\treturn *outstruct, err\n\t}\n\n\toutstruct.Weight = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\toutstruct.Choices = *abi.ConvertType(out[1], new([]*big.Int)).(*[]*big.Int)\n\n\treturn *outstruct, err\n\n}", "func (remote *RemoteNode) RequestVoteRPC(local *RemoteNode, request *RequestVoteRequest) (*RequestVoteReply, error) {\n\t// if local.NetworkPolicy.IsDenied(*local.Self, *remote) {\n\t// \treturn nil, ErrorNetworkPolicyDenied\n\t// }\n\n\tcc, err := remote.RaftRPCClientConn()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treply, err := cc.RequestVoteCaller(context.Background(), request)\n\treturn reply, remote.connCheck(err)\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\treply.VoterId = rf.peerId\n\tif args.Term < rf.currentTerm {\n\t\treply.Term = rf.currentTerm\n\t\treply.VoteGranted = false\n\t\treturn\n\t}\n\tif args.Term > rf.currentTerm {\n\t\trf.stepDownToFollower(args.Term)\n\t}\n\tlastLog := rf.getLastLog()\n\tif (rf.votedFor == \"\" || rf.votedFor == args.CandidateId) && (lastLog.Term < args.LastLogTerm || (lastLog.Index <= args.LastLogIndex && lastLog.Term == args.LastLogTerm)) {\n\t\treply.Term = rf.currentTerm\n\t\trf.grantCh <- true\n\t\treply.VoteGranted = true\n\t\t// set voteFor\n\t\trf.votedFor = args.CandidateId\n\t\tlog.Printf(\"peer %v elect peer %v as leader\\n\", rf.peerId, args.CandidateId)\n\t}\n\treturn\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) { //RequestVote handdler\r\n\t// Your code here.\r\n\trf.mu.Lock() //get the lock\r\n\tdefer rf.mu.Unlock()\r\n\tif args.Term < rf.currentTerm {\r\n\t\treply.VoteGranted = false\r\n\t\treply.Term = rf.currentTerm\r\n\t}else if args.Term > rf.currentTerm {\r\n\t\trf.currentTerm = args.Term\r\n\t\trf.updateStateTo(FOLLOWER)\r\n\t\trf.votedFor = args.CandidateId\r\n\t\treply.VoteGranted = true\r\n\t}else {\r\n\t\tif rf.votedFor == -1 {//haven't vote for anyone\r\n\t\t\trf.votedFor = args.CandidateId\r\n\t\t\treply.VoteGranted = true\r\n\t\t}else {\r\n\t\t\treply.VoteGranted = false\r\n\t\t}\r\n\t}\r\n\tif reply.VoteGranted == true { // vote for current requester\r\n\t\tgo func() { rf.voteCh <- struct{}{} }() //send the struct{}{} to the voteCh channel\r\n\t}\t\r\n}", "func (_Contract *ContractCallerSession) GetVote(from common.Address, delegatedTo common.Address, proposalID *big.Int) (struct {\n\tWeight *big.Int\n\tChoices []*big.Int\n}, error) {\n\treturn _Contract.Contract.GetVote(&_Contract.CallOpts, from, delegatedTo, proposalID)\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\t/*\n\tIf votedFor is null or candidateId, and candidate’s\n\tlog is at least as up-to-date as receiver’s log, grant vote\n\t */\n\tif rf.isCandidateUpToDate(args) &&\n\t\t(rf.votedFor == -1 || rf.votedFor == args.CandidateId) {\n\t\t// grant vote and update rf's term.\n\t\trf.currentTerm = args.Term\n\n\t\treply.Term = args.Term\n\n\t\treply.VoteGranted = true\n\t} else {\n\t\t// don't grant vote to the candidate.\n\t\treply.Term = rf.currentTerm\n\n\t\treply.VoteGranted = false\n\t}\n\n}", "func (rf *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here.\n\trf.mu.Lock()\n\tdefer rf.persist()\n\tdefer rf.mu.Unlock()\n\treply.Term = rf.CurrentTerm\n\n\tif args.Term < rf.CurrentTerm {\n\t\treply.VoteGranted = false\n\t\treturn\n\t}\n\n\tif args.Term > rf.CurrentTerm {\n\t\trf.VotedFor = -1\n\t\trf.CurrentTerm = args.Term\n\t\trf.identity = FOLLOWER\n\t}\n\n\tif rf.VotedFor != -1 && rf.VotedFor != args.CandidateId {\n\t\treply.VoteGranted = false\n\t\treturn\n\t}\n\tvar rfLogIndex int\n\tvar rfLogTerm int\n\tif len(rf.Log) > 0 {\n\t\trfLogIndex = rf.Log[len(rf.Log)-1].Index\n\t\trfLogTerm = rf.Log[len(rf.Log)-1].Term\n\t} else {\n\t\trfLogIndex = rf.lastIncludedIndex\n\t\trfLogTerm = rf.lastIncludedTerm\n\t}\n\n\tif args.LastLogTerm > rfLogTerm || args.LastLogTerm == rfLogTerm && args.LastLogIndex >= rfLogIndex {\n\t\treply.VoteGranted = true\n\t\trf.VotedFor = args.CandidateId\n\t\trf.identity = FOLLOWER\n\t\trf.hasVoted <- true\n\t} else {\n\t\treply.VoteGranted = false\n\t}\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\tdefer rf.persist()\n\n\treply.VoteGranted = false\n\n\tif args.Term < rf.currentTerm {\n\t\treply.Term = rf.currentTerm\n\t\tDPrintf(\"[reject] %v currentTerm:%v vote reject for:%v term:%v\",rf.me,rf.currentTerm,args.CandidateId,args.Term)\n\t\treturn\n\t}\n\n\tif args.Term > rf.currentTerm {\n\t\trf.state = FOLLOWER\n\t\trf.votedFor = -1\n\t\trf.currentTerm = args.Term\n\t}\n\n\treply.Term = rf.currentTerm\n\n\tlastLogTerm := rf.getLastLogTerm()\n\tlastLogIndex := rf.getLastLogIndex()\n\n\tlogFlag := false\n\tif (args.LastLogTerm > lastLogTerm) || (args.LastLogTerm == lastLogTerm && args.LastLogIndex >= lastLogIndex) {\n\t\tlogFlag = true\n\t}\n\n\tif (-1 == rf.votedFor || args.CandidateId == rf.votedFor) && logFlag {\n\t\treply.VoteGranted = true\n\t\trf.votedFor = args.CandidateId\n\t\trf.voteChan <- true\n\t\trf.state = FOLLOWER\n\t}\n\t//DPrintf(\"[RequestVote]: server %v send %v\", rf.me, args.CandidateId)\n}", "func (*UpdateVotesRequest) Descriptor() ([]byte, []int) {\n\treturn file_resources_proto_rawDescGZIP(), []int{14}\n}", "func (node *Node) RequestVote(args RequestVoteArgs, reply *RequestVoteReply) error {\n\tnode.mu.Lock()\n\tdefer node.mu.Unlock()\n\tif node.state == dead {\n\t\treturn nil\n\t}\n\n\tlog.Printf(\"RequestVote args: %+v\\ncurrentTerm=%d\\nvotedFor=%d\", args, node.currentTerm, node.votedFor)\n\n\t// If the RPC term is less than the current term then we must reject the\n\t// vote request.\n\tif args.term < node.currentTerm {\n\t\treply.term = node.currentTerm\n\t\treply.voteGranted = false\n\t\tlog.Printf(\"RequestVote has been rejected by %d\", node.id)\n\t\treturn nil\n\t}\n\n\tif args.term > node.currentTerm {\n\t\t// Update the current node's state to follower.\n\t\tnode.updateStateToFollower(args.term)\n\t}\n\n\t// If the above condition was not true then we have to ensure that we have\n\t// not voted for some other node with the same term.\n\tif args.term == node.currentTerm && (node.votedFor == -1 || node.votedFor == args.candidateID) {\n\t\treply.voteGranted = true\n\t\tnode.votedFor = args.candidateID\n\t\tnode.timeSinceTillLastReset = time.Now()\n\t} else {\n\t\treply.voteGranted = false\n\t}\n\treply.term = node.currentTerm\n\tlog.Printf(\"RequestVote reply: %+v\", reply)\n\treturn nil\n}", "func GetCmdQueryVotes(queryRoute string, cdc *codec.Codec) *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: budget.QueryVotes,\n\t\tShort: \"Query votes, filtered by voterAddress \",\n\t\tLong: strings.TrimSpace(`\nQuery vote details for a single program by its identifier.\n\nExample:\n$ terracli query budget votes 1\n`),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tcliCtx := context.NewCLIContext().WithCodec(cdc)\n\n\t\t\tparams := budget.QueryVotesParams{}\n\n\t\t\t// Get voting address\n\t\t\tvoterAddrStr := viper.GetString(flagVoter)\n\t\t\tif len(voterAddrStr) > 0 {\n\t\t\t\tacc, err := cliCtx.GetAccount([]byte(voterAddrStr))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tparams.Voter = acc.GetAddress()\n\t\t\t}\n\n\t\t\tprogramIDStr := viper.GetString(flagProgramID)\n\t\t\tif len(programIDStr) > 0 {\n\t\t\t\t// validate that the program id is a uint\n\t\t\t\tprogramID, err := strconv.ParseUint(args[0], 10, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"program-id %s not a valid int, please input a valid program-id\", args[0])\n\t\t\t\t}\n\n\t\t\t\tparams.ProgramID = programID\n\t\t\t}\n\n\t\t\tbz, err := cdc.MarshalJSON(params)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tres, err := cliCtx.QueryWithData(fmt.Sprintf(\"custom/%s/%s\", queryRoute, budget.QueryVotes), bz)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tvar matchingVotes []budget.MsgVoteProgram\n\t\t\tcdc.MustUnmarshalJSON(res, &matchingVotes)\n\n\t\t\tif len(matchingVotes) == 0 {\n\t\t\t\tfmt.Println(\"No matching votes found\")\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tfor _, vote := range matchingVotes {\n\t\t\t\tfmt.Println(vote.String())\n\t\t\t}\n\n\t\t\treturn nil\n\t\t},\n\t}\n\n\tcmd.Flags().String(flagVoter, \"\", \"voter for the program\")\n\n\treturn cmd\n}", "func (r *Raft) prepRequestVote() RequestVote {\n\tlastLogIndex := r.myMetaData.lastLogIndex\n\t//if this is the request when log is empty\n\tvar lastLogTerm int\n\tif len(r.myLog) == 0 {\n\t\t//fmt.Println(\"In if of prepRV()\")\n\t\t//lastLogTerm = -1 //Just for now--Modify later\n\t\tlastLogTerm = r.currentTerm\n\t} else {\n\t\t//fmt.Println(\"In else of prepRV()\")\n\t\tlastLogTerm = r.myLog[lastLogIndex].Term\n\t}\n\t//fmt.Println(\"here2\")\n\treqVoteObj := RequestVote{r.currentTerm, r.Myconfig.Id, lastLogIndex, lastLogTerm}\n\treturn reqVoteObj\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\n\treply.Term = rf.currentTerm\n\treply.VoteGranted = false\n\tDPrintf(\"before voted reply is %v, me id is %d, votedFor is %d, candidateId is %d, current term is %v, \" +\n\t\t\"args term is %v args log is %v log is %v\", reply, rf.me, rf.votedFor, args.CandidateId,\n\t\trf.currentTerm, args.LastLogTerm, args.LastLogIndex, rf.addLastIncludedIndex(len(rf.log)-1))\n\n\tif rf.currentTerm < args.Term {\n\t\trf.votedFor = -1\n\t\trf.currentTerm = args.Term\n\t\trf.raftState = Follower\n\t\trf.resetTimer()\n\t}\n\tif rf.votedFor == args.CandidateId || rf.votedFor == -1 {\n\t\tlastIndex := len(rf.log) - 1\n\t\tlastLogTerm := rf.log[lastIndex].Term\n\t\tif (args.LastLogTerm > lastLogTerm) ||\n\t\t\t(args.LastLogTerm == lastLogTerm && args.LastLogIndex >= rf.addLastIncludedIndex(lastIndex)) {\n\t\t\trf.votedFor = args.CandidateId\n\t\t\trf.raftState = Follower\n\t\t\treply.VoteGranted = true\n\t\t\trf.resetTimer()\n\t\t}\n\t}\n\trf.persist()\n}", "func (r *Raft) callRequestVote(server int, args requestVoteArgs, reply *requestVoteReply) bool {\n\t// When there are no peers, return a test response, if any.\n\tif len(r.peers) == 0 {\n\t\t// Under test, return injected reply.\n\t\tglog.V(2).Infof(\"Under test, returning injected reply %v\", reply)\n\t\tif r.testRequestvotesuccess {\n\t\t\t*reply = *r.testRequestvotereply\n\t\t}\n\t\treturn r.testRequestvotesuccess\n\t}\n\tok := r.peers[server].Call(\"Raft.RequestVote\", args, reply)\n\treturn ok\n}", "func (*VoteRequest) Descriptor() ([]byte, []int) {\n\treturn file_vote_proto_rawDescGZIP(), []int{2}\n}", "func (_Votes *VotesCaller) GetCandidates(opts *bind.CallOpts) (struct {\n\tAddresses []common.Address\n\tTickets []*big.Int\n}, error) {\n\tret := new(struct {\n\t\tAddresses []common.Address\n\t\tTickets []*big.Int\n\t})\n\tout := ret\n\terr := _Votes.contract.Call(opts, out, \"getCandidates\")\n\treturn *ret, err\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\tif rf.currentTerm > args.Term {\n\t\treply.VoteGranted = false\n\t\treply.Term = rf.currentTerm\n\t\treturn\n\t}\n\n\tif rf.currentTerm < args.Term {\n\t\trf.currentTerm = args.Term\n\t\trf.updateStateTo(FOLLOWER)\n\t\t//妈的咋突然少了段代码~~ 这里要变为follower状态\n\t\t//var wg sync.WaitGroup\n\t\t//wg.Add(1)\n\t\tgo func() {\n\t\t\t//\tdefer wg.Done()\n\t\t\trf.stateChangeCh <- struct{}{}\n\t\t}()\n\n\t\t//wg.Wait()\n\n\t\t//直接return,等待下一轮投票会导致活锁,比如node 1 ,2,3 。 node 1 加term为2,发请求给node2,3,term1。 node2,3更新term拒绝投票\n\t\t//return\n\t}\n\n\t//此处if 在 currentTerm < args.Term下必然成立,在currentTerm等于args.Term下不一定成立\n\n\tif rf.votedFor == -1 || rf.votedFor == args.CandidatedId {\n\t\t//if candidate的log 至少 as up-to-date as reveiver's log\n\t\tlastLogIndex := len(rf.logEntries) - 1\n\t\t//fmt.Println(lastLogIndex,rf.me,rf.logEntries )\n\t\tlastLogTerm := rf.logEntries[len(rf.logEntries)-1].Term\n\t\t//fmt.Println(lastLogIndex,lastLogTerm , args.LastLogIndex,args.LastLogTerm)\n\t\tif lastLogTerm < args.LastLogTerm || (lastLogTerm == args.LastLogTerm && lastLogIndex <= args.LastLogIndex) {\n\t\t\trf.votedFor = args.CandidatedId\n\t\t\treply.Term = rf.currentTerm\n\t\t\treply.VoteGranted = true\n\t\t\t//fmt.Printf(\"[Term %d],Node %d Reply 值为%v. Term= %d , lastIndex = %d <= args.lastLogIndex %d\\n\", rf.currentTerm, rf.me, reply, args.LastLogTerm, lastLogIndex, args.LastLogIndex)\n\t\t\tif rf.status == FOLLOWER {\n\t\t\t\tgo func() { rf.giveVoteCh <- struct{}{} }()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tfmt.Println(lastLogIndex, lastLogTerm, args.LastLogIndex, args.LastLogTerm)\n\t}\n\n\treply.Term = rf.currentTerm\n\treply.VoteGranted = false\n\t//fmt.Printf(\"[Term %d] Node %d Reply 值为%v,rf.votefor=%d,\\n\", rf.currentTerm, rf.me, reply, rf.votedFor)\n\n}", "func (c *gitlabClient) PullRequestEvents(context.Context, string, []interface{}) ([]sdk.VCSPullRequestEvent, error) {\n\treturn nil, fmt.Errorf(\"Not implemented on Gitlab\")\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// TODO: fail this rpc when killed\n\n\t// Your code here (2A, 2B).\n\tisGoodRequestVote := false\n\trf.mu.Lock()\n\n\tdefer func() {\n\t\tAssertF(reply.Term >= args.Term, \"reply.Term {%d} >= args.Term {%d}\", reply.Term, args.Term)\n\t\trf.mu.Unlock()\n\t\trf.resetElectionTimerIf(isGoodRequestVote)\n\t}()\n\n\tif args.Term < rf.currentTerm {\n\t\t*reply = RequestVoteReply{Term: rf.currentTerm, VoteGranted: false}\n\t\treturn\n\t}\n\n\tif args.Term > rf.currentTerm {\n\t\trf.transitionToFollower(args.Term, -1)\n\t}\n\n\tAssertF(args.Term == rf.currentTerm, \"\")\n\n\tif (rf.votedFor == -1 || rf.votedFor == args.CandidateId) && rf.isUptoDate(args.LastLogIndex, args.LastLogTerm) {\n\t\tisGoodRequestVote = true\n\t\trf.votedFor = args.CandidateId\n\t\t*reply = RequestVoteReply{Term: args.Term, VoteGranted: true}\n\t} else {\n\t\t*reply = RequestVoteReply{Term: args.Term, VoteGranted: false}\n\t}\n\n\trf.persist()\n}", "func GetCmdQueryVotes(queryRoute string, cdc *codec.Codec) *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: oracle.QueryVotes,\n\t\tArgs: cobra.NoArgs,\n\t\tShort: \"Query outstanding oracle votes, filtered by denom and voter address.\",\n\t\tLong: strings.TrimSpace(`\nQuery outstanding oracle votes, filtered by denom and voter address.\n\n$ terracli query oracle votes --denom=\"uusd\" --validator=\"terravaloper...\"\n\nreturns oracle votes submitted by the validator for the denom uusd \n`),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tcliCtx := context.NewCLIContext().WithCodec(cdc)\n\n\t\t\tdenom := viper.GetString(flagDenom)\n\n\t\t\t// Check voter address exists, then valids\n\t\t\tvar voterAddress sdk.ValAddress\n\n\t\t\tbechVoterAddr := viper.GetString(flagValidator)\n\t\t\tif len(bechVoterAddr) != 0 {\n\t\t\t\tvar err error\n\n\t\t\t\tvoterAddress, err = sdk.ValAddressFromBech32(bechVoterAddr)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tparams := oracle.NewQueryVotesParams(voterAddress, denom)\n\t\t\tbz, err := cdc.MarshalJSON(params)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tres, err := cliCtx.QueryWithData(fmt.Sprintf(\"custom/%s/%s\", queryRoute, oracle.QueryVotes), bz)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tvar matchingVotes oracle.QueryVotesResponse\n\t\t\tcdc.MustUnmarshalJSON(res, &matchingVotes)\n\n\t\t\treturn cliCtx.PrintOutput(matchingVotes)\n\t\t},\n\t}\n\n\tcmd.Flags().String(flagDenom, \"\", \"filter by votes matching the denom\")\n\tcmd.Flags().String(flagValidator, \"\", \"(optional) filter by votes by validator\")\n\n\tcmd.MarkFlagRequired(flagDenom)\n\n\treturn cmd\n}", "func (rf *Raft) createRequestVoteArgs() *RequestVoteArgs {\n\treturn &RequestVoteArgs{\n\t\tTerm: rf.currentTerm,\n\t\tCandidateID: rf.me,\n\t\tLastLogIndex: rf.lastLogEntryIndex(),\n\t\tLastLogTerm: rf.lastLogEntryTerm(),\n\t}\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\trf.mu.Lock()\n\tif args.Term < rf.currentTerm {\n\t\treply.Term = rf.currentTerm\n\t\treply.VoteGranted = false\n\t\trf.mu.Unlock()\n\t\treturn\n\t}\n\t// follow the second rule in \"Rules for Servers\" in figure 2 before handling an incoming RPC\n\tif args.Term > rf.currentTerm {\n\t\trf.currentTerm = args.Term\n\t\trf.state = FOLLOWER\n\t\trf.votedFor = -1\n\t\trf.persist()\n\t}\n\n\treply.Term = rf.currentTerm\n\treply.VoteGranted = true\n\t// deny vote if already voted\n\tif rf.votedFor != -1 {\n\t\treply.VoteGranted = false\n\t\trf.mu.Unlock()\n\t\treturn\n\t}\n\t// deny vote if consistency check fails (candidate is less up-to-date)\n\tlastLog := rf.log[len(rf.log)-1]\n\tif args.LastLogTerm < lastLog.Term || (args.LastLogTerm == lastLog.Term && args.LastLogIndex < len(rf.log)-1) {\n\t\treply.VoteGranted = false\n\t\trf.mu.Unlock()\n\t\treturn\n\t}\n\t// now this peer must vote for the candidate\n\trf.votedFor = args.CandidateID\n\trf.mu.Unlock()\n\n\trf.resetTimer()\n}", "func (rf *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply) {\n\tswitch {\n\tcase args.Term < rf.currentTerm:\n\t\treply.VoteGranted = false\n\t\treturn\n\tcase args.Term > rf.currentTerm:\n\t\trf.setTerm(args.Term) // only reset term (and votedFor) if rf is behind\n\t}\n\n\treply.Term = rf.currentTerm\n\n\tif rf.votedFor == -1 || rf.votedFor == args.CandidateId && rf.AtLeastAsUpToDate(args) {\n\t\treply.VoteGranted = true\n\t\trf.votedFor = args.CandidateId\n\t} else {\n\t\treply.VoteGranted = false\n\t}\n\n\t// TODO move me somewhere else\n\tif reply.VoteGranted {\n\t\trf.requestVoteCh <- struct{}{}\n\t}\n}", "func GetCmdQueryVotes(cdc *codec.Codec) *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"query-votes\",\n\t\tShort: \"Query votes on a proposal\",\n\t\tExample: \"iriscli gov query-votes --proposal-id=1\",\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tcliCtx := context.NewCLIContext().WithCodec(cdc)\n\t\t\tproposalID := uint64(viper.GetInt64(flagProposalID))\n\n\t\t\tparams := gov.QueryVotesParams{\n\t\t\t\tProposalID: proposalID,\n\t\t\t}\n\t\t\tbz, err := cdc.MarshalJSON(params)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tres, err := cliCtx.QueryWithData(fmt.Sprintf(\"custom/%s/votes\", protocol.GovRoute), bz)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tvar votes gov.Votes\n\t\t\tif err := cdc.UnmarshalJSON(res, &votes); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\treturn cliCtx.PrintOutput(votes)\n\t\t},\n\t}\n\n\tcmd.Flags().String(flagProposalID, \"\", \"proposalID of which proposal's votes are being queried\")\n\tcmd.MarkFlagRequired(flagProposalID)\n\treturn cmd\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\tdefer rf.persist()\n\n\tif args.Term < rf.currentTerm {\n\t\t\treply.Term = rf.currentTerm\n\t\t\treply.VoteGranted = false\n\t\t\treturn\n\t\t}\n\tif args.Term > rf.currentTerm{\n\t\trf.currentTerm = args.Term\n\t\trf.votedFor = -1\n\t\trf.role = 0\n\t\trf.roleChan <- 0\n\t\t}\n\treply.Term = args.Term\n\tfmt.Printf(\"LastLogTerm:%v rf.log:%v sever:%v \\n\", args.LastLogTerm, rf.log[len(rf.log)-1].Term, rf.me)\n\tif rf.votedFor != -1 && rf.votedFor != args.CandidateId {\n\t reply.VoteGranted = false \n\t }else if rf.log[len(rf.log)-1].Term > args.LastLogTerm{\n\t \treply.VoteGranted = false\n\t }else if rf.log[len(rf.log)-1].Index > args.LastLogIndex && rf.log[len(rf.log)-1].Term == args.LastLogTerm{\n\t \treply.VoteGranted = false\n\t }else{\n\t fmt.Printf(\"Server %v vote for server %v \\n\", rf.me, args.CandidateId)\n\t reply.VoteGranted = true\n\t rf.votedFor = args.CandidateId\n\t rf.GrantVote <- true\n\t }\n\n\t}", "func (r *Raft) sendVoteRequestRpc(value ServerConfig, VoteCount chan int) error {\n\n\tclient, err := rpc.Dial(\"tcp\", \"localhost:\"+strconv.Itoa(value.LogPort))\n\tlog.Println(\"Dialing vote request rpc from:\",r.Id,\" to:\",value.Id)\n\n\t if err != nil {\n\t\tlog.Print(\"Error Dialing sendVoteRequestRpc:\", err)\n\t\tVoteCount<-0\n\t\treturn err\n\t }\n\n\t logLen:= len(r.Log)\n\t var lastLogIndex int\n\t var lastLogTerm int\n\n\t if logLen >0 { // if log is not empty, send index and term of last log\n\t \tlastLogIndex=logLen-1\t \t\n\t \tlastLogTerm = r.Log[lastLogIndex].Term\n\t } else { // if log is empty, send index and term as 0\n\t \tlastLogIndex=0\n\t \tlastLogTerm=0\n\t }\n\n\t // Prepare argumenst to be sent to follower\n\t args:= RequestVoteRPCArgs{r.CurrentTerm,r.Id,lastLogTerm,lastLogIndex,}\n\n\tvar reply bool // reply variable will reciece the vote from other server, true is voted, false otherwise\n\tdefer client.Close()\n\terr1 := client.Call(\"RPC.VoteForLeader\", &args, &reply) \n\n\tif err1 != nil {\n\t\tlog.Print(\"Remote Method Invocation Error:Vote Request:\", err1)\n\t}\n\tif(reply) { // if reply is positive infrom the candiate \n\t\t//fmt.Println(\"Received reply of vote request from:\",value.Id,\" for:\",r.Id)\n\t\tVoteCount <-1\t\n\t}else{\n\t\tVoteCount <-0 // if reply is negative infrom the candiate \n\t\t//fmt.Println(\"Received Negative reply of vote request from:\",value.Id,\" for:\",r.Id)\n\t}\n\treturn nil\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\n\n\t//fmt.Printf(\"成功调用RequestVote!\\n\")\n\t// Your code here (2A, 2B).\n\t//rf.mu.Lock()\n\t//current_time:=time.Now().UnixNano()/1e6\n\t//&&current_time-rf.voted_time>800\n\trf.mu.Lock()\n\n\tif (rf.term>args.Candidate_term)&&((args.Last_log_term>rf.Last_log_term)||(args.Last_log_term==rf.Last_log_term&&args.Last_log_term_lenth>=rf.last_term_log_lenth)){\n\t\trf.term=args.Candidate_term\n\t\trf.state=0\n\t}\n\n\n\t/*\n\t\tif args.Append==true&&((args.Newest_log.Log_Term<rf.Last_log_term)||(args.Newest_log.Log_Term==rf.Last_log_term&&args.Last_log_term_lenth<rf.Last_log_term)){\n\t\t\treply.Term=args.Candidate_term+1\n\t\t\treply.Last_log_term=rf.Last_log_term\n\t\t\treply.Last_log_lenth=rf.last_term_log_lenth\n\t\t\treply.Append_success=false\n\t\t\trf.mu.Unlock()\n\t\t\treturn\n\t\t}\n\t*/\n\t//if args.Second==true{\n\t//\tfmt.Printf(\"!\\n!\\n!\\n!\\n!\\n编号为%d的raft实例收到编号为%d的leader的second请求!本机term是%d,leader term是%d,args.Append是%v\\n\",rf.me,args.From,rf.term,args.Candidate_term,args.Append)\n\t//}\n\n\tif rf.state==2&&((rf.term<args.Candidate_term)||(rf.term==args.Candidate_term&&args.Last_log_term<rf.Last_log_term))&&args.Votemsg==false{\n\t\t//fmt.Printf(\"分区恢复后编号为%d的raft实例的term是%d,发现自己已经不是leader!leader是%d,leader的term是%d\\n\",rf.me,rf.term,args.From,args.Candidate_term)\n\t\trf.state=0\n\t\trf.leaderID=args.From\n\t}\n\n\n\n\tif args.Candidate_term>=rf.term{\n\t\t//rf.term=args.Candidate_term\n\t\t//if args.Second==true{\n\t\t//\tfmt.Printf(\"服务器上的SECOND进入第一个大括号\\n\")\n\t\t//}\n\t\tif args.Append == false {\n\t\t\tif args.Votemsg == true && rf.voted[args.Candidate_term] == 0&&((args.Last_log_term>rf.Last_log_term)||(args.Last_log_term==rf.Last_log_term&&args.Last_log_term_lenth>=rf.last_term_log_lenth)) { //合法投票请求\n\t\t\t\t//fmt.Printf(\"编号为%d的raft实例对投票请求的回答为true,term统一更新为为%d\\n\",rf.me,rf.term)\n\n\t\t\t\t//rf.term = args.Candidate_term\n\t\t\t\trf.voted[args.Candidate_term] = 1\n\t\t\t\treply.Vote_sent = true\n\n\t\t\t\t//rf.voted_time=time.Now().UnixNano()/1e6\n\n\t\t\t}else if args.Votemsg==true{ //合法的纯heartbeat\n\t\t\t\tif rf.voted[args.Candidate_term]==1 {\n\t\t\t\t\treply.Voted = true\n\t\t\t\t}\n\t\t\t\t//fmt.Printf(\"请求方的term是%d,本机的term是%d,来自%d的投票请求被%d拒绝!rf.last_log_term是%d,rf.last_log_lenth是%d,本机的rf.last_log_term是%d,rf.last_log_lenth是%d\\n\",args.Candidate_term,rf.term,args.From,rf.me,args.Last_log_term,args.Last_log_term_lenth,rf.Last_log_term,rf.last_term_log_lenth)\n\t\t\t}\n\t\t\treply.Term=rf.term\n\n\t\t\t//rf.term=args.Candidate_term//!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\t\t\t//if args.Votemsg==true{//!!!!!!!!!!!!!!\n\t\t\t//\trf.term=args.Candidate_term//!!!!!!!!!!!!\n\t\t\t//}//!!!!!!!!!!!!!!!!!\n\n\t\t} else { //这条是关于日志的\n\t\t\t//这个请求是日志同步请求,接收方需要将自己的日志最后一条和leader发过来的声称的进行比较,如果leader的更新且leader的PREV和自己的LAST相同就接受\n\t\t\t//还得找到最后一个一致的日志位置,然后将后面的全部更新为和leader一致的,这意味着中间多次的RPC通信\n\n\t\t\t/*\n\t\t\tif args.Newest_log.Log_Term<rf.Last_log_term{\n\t\t\t\treply.Wrong_leader=true\n\t\t\t\treply.Term=rf.term\n\t\t\t\treply.Append_success=false\n\t\t\t\treply.Last_log_lenth=rf.last_term_log_lenth\n\t\t\t\treturn\n\t\t\t}\n*/\n\n\t\t\tif (rf.Last_log_term>args.Last_log_term)||(rf.Last_log_term==args.Last_log_term&&rf.last_term_log_lenth>args.Last_log_term_lenth){\n\t\t\t\treply.Append_success=false\n\t\t\t\treply.Last_log_term=rf.Last_log_term\n\t\t\t\treply.Last_log_lenth=rf.last_term_log_lenth\n\t\t\t\trf.mu.Unlock()\n\t\t\t\treturn\n\t\t\t}\n\n\n\t\t\trf.term=args.Candidate_term\n\t\t\tif args.Second==true{\n\t\t\t\t//\tfmt.Printf(\"在服务器端进入second阶段!\\n\")\n\t\t\t\trf.log=rf.log[:args.Second_position]\n\t\t\t\trf.log=append(rf.log,args.Second_log...)\n\t\t\t\treply.Append_success=true\n\t\t\t\trf.Last_log_term=args.Last_log_term\n\t\t\t\trf.last_term_log_lenth=args.Last_log_term_lenth\n\t\t\t\trf.Last_log_index=len(rf.log)-1\n\t\t\t\trf.Log_Term=args.Log_Term\n\t\t\t\t//fmt.Printf(\"Second APPend在服务器端成功!现在编号为%d的raft实例的log是%v, last_log_term是%d,term是%d\\n\",rf.me,rf.log,rf.Last_log_term,rf.term)\n\t\t\t}else{\n\t\t\t\tif args.Append_Try == false {//try用于表示是否是第一次append失败了现在正在沟通\n\t\t\t\t\trf.append_try_log_index = rf.Last_log_index\n\t\t\t\t\trf.append_try_log_term=rf.Last_log_term\n\t\t\t\t}\n\t\t\t\tif args.Prev_log_index != rf.append_try_log_index || args.Prev_log_term != rf.append_try_log_term{\n\t\t\t\t\t//fmt.Printf(\"匹配失败!!!%d号leader发过来的PREV_log_index是%d,本机%d的last_log_index是%d,PREV_term是%d,本机的last_log_term是%d!\\n\",args.From,args.Prev_log_index,rf.me,rf.append_try_log_index,args.Prev_log_term,rf.append_try_log_term)\n\t\t\t\t\treply.Vote_sent = false//匹配失败后进入双方沟通try\n\t\t\t\t\treply.Append_success = false\n\n\t\t\t\t\treply.Log_Term=rf.Log_Term\n\n\t\t\t\t\trf.mu.Unlock()\n\t\t\t\t\treturn\n\t\t\t\t} else { //说明没问题。可以更新\n\t\t\t\t\t//fmt.Printf(\"匹配成功!!!%d号是leader,发过来的PREV_log_index是%d,本机的last_log_index是%d,PREV_term是%d,本机的last_log_term是%d,准备更新本机日志!!\\n\", args.From, args.Prev_log_index, rf.append_try_log_index, args.Prev_log_term, rf.append_try_log_term)\n\t\t\t\t\t//rf.Last_log_term = args.Last_log_term\n\t\t\t\t\trf.last_term_log_lenth=args.Last_log_term_lenth\n\t\t\t\t\trf.log = append(rf.log, args.Newest_log)\n\t\t\t\t\trf.Last_log_index += 1\n\t\t\t\t\trf.Log_Term = args.Log_Term\n\t\t\t\t\trf.Last_log_term=args.Newest_log.Log_Term\n\t\t\t\t\treply.Append_success = true\n\t\t\t\t\t//fmt.Printf(\"APPend成功,现在编号为%d的raft实例的log是%v,last_log_term是%d,term是%d\\n\",rf.me,rf.log,rf.Last_log_term,rf.term)\n\t\t\t\t}\n\t\t\t}\n\t\t\trf.log_added_content = args.Newest_log\n\t\t\trf.last_term_log_lenth=0\n\n\t\t\tfor cc:=len(rf.log)-1;cc>-1;cc--{\n\t\t\t\tif rf.log[cc].Log_Term!=rf.Last_log_term{\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\trf.last_term_log_lenth+=1\n\t\t\t}\n\n\n\t\t}\n\n\t\t//fmt.Printf(\"在更新heartbeat之前\\n\")\n\t\tif args.Votemsg==false {//加上个约束条件更严谨,加上了表示是在heartbeat开始之后认同了这个是leader,否则在投票阶段就认同了\n\t\t\t//fmt.Printf(\"rf.last_log_term %d, args.last_log_term %d\\n\",rf.Last_log_term,args.Last_log_term)\n\t\t\tif args.Last_log_term==rf.Last_log_term {//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\t\t\t\tif args.Commit_MSG == true {\n\t\t\t\t\t//if len(rf.Log_Term)==len(args.Log_Term)&&rf.Log_Term[len(rf.Log_Term)-1]==args.Log_Term[len(args.Log_Term)-1]{\n\t\t\t\t\t//if len(args.Log_Term)==len(rf.Log_Term)&&args.Last_log_term==rf.Last_log_term {\n\t\t\t\t\tfor cc := rf.committed_index + 1; cc <= rf.Last_log_index; cc++ {\n\t\t\t\t\t\trf.committed_index = cc\n\t\t\t\t\t\t//!-------------------------fmt.Printf(\"在follower %d 上进行commit,commit_index是%d,commit的内容是%v,commit的term是%d,last_log_term是%d, rf.log是太长暂时鸽了\\n\", rf.me, cc, rf.log[cc].Log_Command, rf.log[cc].Log_Term, rf.Last_log_term)\n\t\t\t\t\t\trf.applych <- ApplyMsg{true, rf.log[rf.committed_index].Log_Command, rf.committed_index}\n\t\t\t\t\t}\n\n\t\t\t\t\treply.Commit_finished = true\n\t\t\t\t\t//}else{\n\t\t\t\t\t//}\n\t\t\t\t\t//}\n\t\t\t\t}\n\t\t\t}//!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\t\t\trf.leaderID = args.From\n\t\t\trf.term = args.Candidate_term\n\t\t\trf.leaderID=args.From\n\n\n\t\t}\n\t\treply.Last_log_lenth=rf.last_term_log_lenth\n\t\treply.Last_log_term=rf.Last_log_term\n\n\t\tif args.Votemsg==false {\n\t\t\tif rf.state == 0 {\n\t\t\t\trf.last_heartbeat <- 1\n\t\t\t}\n\t\t}\n\n\t}else{\n\t\t//fmt.Printf(\"term都不符,明显是非法的!\\n\")\n\t\treply.Vote_sent = false\n\t\treply.Append_success = false\n\t\treply.Term=rf.term\n\t\treply.Last_log_lenth=rf.last_term_log_lenth\n\t\treply.Last_log_term=rf.Last_log_term\n\t\t//-------------------if (args.Last_log_term>rf.Last_log_term)||(args.Last_log_term==rf.Last_log_term&&args.Last_log_term_lenth>=rf.last_term_log_lenth){\n\t\t//----------------------\treply.You_are_true=true\n\t\t//------------------------}\n\t}\n\trf.mu.Unlock()\n\t//fmt.Printf(\"编号为%d的raft实例通过RequestVote()收到了heartbeat\\n\",rf.me)\n\t//reply.voted<-true\n\t//rf.mu.Unlock()\n}", "func (_Contract *ContractSession) GetVote(from common.Address, delegatedTo common.Address, proposalID *big.Int) (struct {\n\tWeight *big.Int\n\tChoices []*big.Int\n}, error) {\n\treturn _Contract.Contract.GetVote(&_Contract.CallOpts, from, delegatedTo, proposalID)\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\trf.mu.Lock()\n\tdefer DPrintf(\"%d received RequestVote from %d, args.Term : %d, args.LastLogIndex: %d, args.LastLogTerm: %d, rf.log: %v, rf.voteFor: %d, \" +\n\t\t\"reply: %v\", rf.me, args.CandidatedId, args.Term, args.LastLogIndex, args.LastLogTerm, rf.log, rf.voteFor, reply)\n\t// Your code here (2A, 2B).\n\trf.resetElectionTimer()\n\treply.Term = rf.currentTerm\n\treply.VoteGranted = false\n\tlastLogIndex := rf.log[len(rf.log)-1].Index\n\tlastLogTerm := rf.log[lastLogIndex].Term\n\n\tif lastLogTerm > args.LastLogTerm || (args.LastLogTerm == lastLogTerm && args.LastLogIndex < lastLogIndex) {\n\t\trf.mu.Unlock()\n\t\treturn\n\t}\n\n\t// 5.1 Reply false if term < currentTerm\n\tif args.Term < rf.currentTerm {\n\t\trf.mu.Unlock()\n\t\treturn\n\t}\n\n\tif (args.Term == rf.currentTerm && rf.state == \"leader\") || (args.Term == rf.currentTerm && rf.voteFor != -1){\n\t\trf.mu.Unlock()\n\t\treturn\n\t}\n\n\tif args.Term == rf.currentTerm && rf.voteFor == args.CandidatedId {\n\t\treply.VoteGranted = true\n\t\trf.mu.Unlock()\n\t\treturn\n\t}\n\n\t// Rules for Servers\n\t// All Servers\n\t// If RPC request or response contains term T > currentTerm: set currentTerm = T, convert to follower\n\tif args.Term > rf.currentTerm {\n\t\trf.currentTerm = args.Term\n\t\trf.voteFor = -1\n\t\trf.mu.Unlock()\n\t\trf.changeState(\"follower\")\n\t\trf.mu.Lock()\n\t}\n\n\trf.voteFor = args.CandidatedId\n\treply.VoteGranted = true\n\t//rf.persist()\n\trf.mu.Unlock()\n\treturn\n}", "func (_Contracts *ContractsCallerSession) AllVotes(arg0 *big.Int) (struct {\n\tProposalId *big.Int\n\tPositionId *big.Int\n\tCandidateId *big.Int\n\tVoterId *big.Int\n}, error) {\n\treturn _Contracts.Contract.AllVotes(&_Contracts.CallOpts, arg0)\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\trf.executeLock.Lock()\n\tdefer rf.executeLock.Unlock()\n\n\t//DPrintf(\"[ReceiveRequestVote] [me %v] from [peer %v] start\", rf.me, args.CandidateId)\n\trf.stateLock.Lock()\n\n\tdebugVoteArgs := &RequestVoteArgs{\n\t\tTerm: rf.currentTerm,\n\t\tCandidateId: rf.votedFor,\n\t\tLastLogIndex: int32(len(rf.log) - 1),\n\t\tLastLogTerm: rf.log[len(rf.log)-1].Term,\n\t}\n\tDPrintf(\"[ReceiveRequestVote] [me %#v] self info: %#v from [peer %#v] start\", rf.me, debugVoteArgs, args)\n\treply.Term = rf.currentTerm\n\treply.VoteGranted = false\n\treply.LastLog = int32(len(rf.log) - 1)\n\treply.LastLogTerm = rf.log[reply.LastLog].Term\n\tif args.Term < rf.currentTerm {\n\t\tDPrintf(\"[ReceiveRequestVote] [me %v] from %v Term :%v <= currentTerm: %v, return\", rf.me, args.CandidateId, args.Term, rf.currentTerm)\n\t\trf.stateLock.Unlock()\n\t\treturn\n\t}\n\n\tconvrt2Follower := false\n\tif args.Term > rf.currentTerm {\n\t\trf.currentTerm = args.Term\n\t\trf.votedFor = -1\n\t\tconvrt2Follower = true\n\t\trf.persist()\n\t}\n\n\tif rf.votedFor == -1 || rf.votedFor == args.CandidateId {\n\t\tlastLogIndex := int32(len(rf.log) - 1)\n\t\tlastLogTerm := rf.log[lastLogIndex].Term\n\n\t\tif args.LastLogTerm < lastLogTerm || (args.LastLogTerm == lastLogTerm && args.LastLogIndex < lastLogIndex) {\n\t\t\trf.votedFor = -1\n\t\t\trf.lastHeartbeat = time.Now()\n\t\t\tDPrintf(\"[ReceiveRequestVote] [me %v] index from [%v] is oldest, return\", rf.me, args.CandidateId)\n\n\t\t\tif convrt2Follower && rf.role != _Follower {\n\t\t\t\tDPrintf(\"[ReceiveRequestVote] [me %v] from %v Term :%v (non-follower) > currentTerm: %v, return\", rf.me, args.CandidateId, args.Term, rf.currentTerm)\n\t\t\t\trf.role = _Unknown\n\t\t\t\trf.stateLock.Unlock()\n\t\t\t\tselect {\n\t\t\t\tcase <-rf.closeCh:\n\t\t\t\tcase rf.roleCh <- _Follower:\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\trf.stateLock.Unlock()\n\t\t\treturn\n\t\t}\n\n\t\trf.votedFor = args.CandidateId\n\t\t// [WARNING] 一旦授权,应该重置超时\n\t\trf.lastHeartbeat = time.Now()\n\t\treply.VoteGranted = true\n\t\tDPrintf(\"[ReceiveRequestVote] [me %v] granted vote for %v\", rf.me, args.CandidateId)\n\t\tif rf.role != _Follower {\n\t\t\tDPrintf(\"[ReceiveRequestVote] [me %v] become follower\", rf.me)\n\t\t\trf.role = _Unknown\n\t\t\trf.stateLock.Unlock()\n\t\t\tselect {\n\t\t\tcase <-rf.closeCh:\n\t\t\t\treturn\n\t\t\tcase rf.roleCh <- _Follower:\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\trf.stateLock.Unlock()\n\t\treturn\n\t}\n\tDPrintf(\"[ReceiveRequestVote] [me %v] have voted: %v, return\", rf.me, rf.votedFor)\n\trf.stateLock.Unlock()\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\tdefer rf.persist()\n\n\treply.VoteGranted = false\n\treply.Term = rf.currentTerm\n\n\t// Rule for all servers: If RPC request or response contains term T > currentTerm: set currentTerm = T, convert to follower (§5.1)\n\tif args.Term > rf.currentTerm {\n\t\trf.convertToFollower(args.Term)\n\t}\n\n\t// 1. Reply false if term < currentTerm (§5.1)\n\tif args.Term < rf.currentTerm {\n\t\t_, _ = DPrintf(vote(\"[T%v] %v: Received RequestVote from %v | Discarded Vote | Received Lower Term \"), rf.currentTerm, rf.me, args.CandidateID, args.CandidateID)\n\t\treturn\n\t}\n\n\t/* 2. If\n\t *\t\t1. votedFor is null or candidateId\n\t *\t\t2. candidate’s log is at least as up-to-date as receiver’s log\n\t *\tgrant vote (§5.2, §5.4)\n\t */\n\n\t// Check 1 vote: should be able to vote or voted for candidate\n\tvoteCheck := rf.votedFor == noVote || rf.votedFor == args.CandidateID\n\t// Check 2 up-to-date = (same indices OR candidate's lastLogIndex > current peer's lastLogIndex)\n\tlastLogIndex, lastLogTerm := rf.lastLogEntryIndex(), rf.lastLogEntryTerm()\n\tlogCheck := lastLogTerm < args.LastLogTerm || (lastLogTerm == args.LastLogTerm && lastLogIndex <= args.LastLogIndex)\n\n\t// Both checks should be true to grant vote\n\tif voteCheck && logCheck {\n\t\treply.VoteGranted = true\n\t\t_, _ = DPrintf(vote(\"[T%v] %v: Received RequestVote from %v | Vote Successful\"), rf.currentTerm, rf.me, args.CandidateID)\n\t\trf.currentTerm = args.Term\n\t\trf.votedFor = args.CandidateID\n\t} else if !voteCheck {\n\t\t_, _ = DPrintf(vote(\"[T%v] %v: Received RequestVote from %v | Vote Failure | Already voted for %v\"), rf.currentTerm, rf.me, args.CandidateID, rf.votedFor)\n\t} else {\n\t\t_, _ = DPrintf(vote(\"[T%v] %v: Received RequestVote from %v | Vote Failure | No Up-To-Date Log | Received {LastLogTerm: %v, LastLogIndex: %v} | Current {LastLogTerm: %v, LastLogIndex: %v}\"),\n\t\t\trf.currentTerm, rf.me, args.CandidateID, args.LastLogTerm, args.LastLogIndex, lastLogTerm, lastLogIndex)\n\t}\n\trf.resetTTL()\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\n\t// Your code here (2A, 2B).\n\n\tDPrintf(\" before %v 's request,%v 's votefor is %v\", args.CandidateId, rf.me, rf.voteFor)\n\t//log.Printf(\" before %v 's request,%v 's votefor is %v\", args.CandidateId, rf.me, rf.voteFor)\n\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\tdefer rf.persist()\n\tlog.Printf(\" before %v 's request,%v 's votefor is %v\", args.CandidateId, rf.me, rf.voteFor)\n\n\tDPrintf(\" %v's requesetvote args is %v, and the reciever %v currentTerm is %v\", args.CandidateId, *args, rf.me, rf.currentTerm)\n\t//log.Printf(\" %v's requesetvote args is %v, and the reciever %v currentTerm is %v\", args.CandidateId, *args, rf.me, rf.currentTerm)\n\n\t// all servers\n\tif rf.currentTerm < args.Term {\n\t\trf.convertToFollower(args.Term)\n\t}\n\n\t_voteGranted := false\n\tif rf.currentTerm == args.Term && (rf.voteFor == VOTENULL || rf.voteFor == args.CandidateId) && (rf.getLastLogTerm() < args.LastLogTerm || (rf.getLastLogTerm() == args.LastLogTerm && rf.getLastLogIndex() <= args.LastLogIndex)) {\n\t\trf.state = Follower\n\t\tdropAndSet(rf.grantVoteCh)\n\t\t_voteGranted = true\n\t\trf.voteFor = args.CandidateId\n\t}\n\n\treply.VoteGranted = _voteGranted\n\treply.Term = rf.currentTerm\n\n\tDPrintf(\" after %v 's request,%v 's votefor is %v\", args.CandidateId, rf.me, rf.voteFor)\n\tlog.Printf(\" after %v 's request,%v 's votefor is %v\", args.CandidateId, rf.me, rf.voteFor)\n}", "func (_Contracts *ContractsCaller) AllVotes(opts *bind.CallOpts, arg0 *big.Int) (struct {\n\tProposalId *big.Int\n\tPositionId *big.Int\n\tCandidateId *big.Int\n\tVoterId *big.Int\n}, error) {\n\tret := new(struct {\n\t\tProposalId *big.Int\n\t\tPositionId *big.Int\n\t\tCandidateId *big.Int\n\t\tVoterId *big.Int\n\t})\n\tout := ret\n\terr := _Contracts.contract.Call(opts, out, \"allVotes\", arg0)\n\treturn *ret, err\n}", "func (*RequestVoteRequest) Descriptor() ([]byte, []int) {\n\treturn file_request_vote_request_proto_rawDescGZIP(), []int{0}\n}", "func (rf *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply) {\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\tdefer rf.persist()\n\n\tif args.Term > rf.currentTerm {\n\t\trf.convert2Follower(args.Term)\n\t}\n\n\treply.Term = rf.currentTerm\n\treply.VoteGranted = false\n\n\tif args.Term < rf.currentTerm {\n\t\treturn\n\t}\n\n\tlastLogTerm := rf.getLastLogTerm()\n\tlastLogIndex := rf.getLastLogIndex()\n\t// voted-none && least-up-to-date\n\n\tup2Date := false\n\tif lastLogTerm < args.LastLogTerm {\n\t\tup2Date = true\n\t}\n\tif lastLogTerm == args.LastLogTerm && lastLogIndex <= args.LastLogIndex {\n\t\tup2Date = true\n\t}\n\n\tif up2Date && (rf.votedFor == -1 || rf.votedFor == args.CandidateId) {\n\t\treply.VoteGranted = true\n\t\trf.votedFor = args.CandidateId\n\t\t// DPrintf(\"Server [%v] vote [%v] for Term [%v]\", rf.me, args.CandidateId, rf.currentTerm)\n\t}\n}", "func (*CUserAccount_GetAvailableValveDiscountPromotions_Request) Descriptor() ([]byte, []int) {\n\treturn file_steammessages_useraccount_steamclient_proto_rawDescGZIP(), []int{0}\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\n\tif rf.currentTerm < args.Term {\n\t\trf.debug(\"Updating term to new term %v\\n\", args.Term)\n\t\trf.currentTerm = args.Term\n\t\tatomic.StoreInt32(&rf.state, FOLLOWER)\n\t\trf.votedFor = LEADER_UNKNOWN\n\t}\n\n\treply.Term = rf.currentTerm\n\treply.VoteGranted = false\n\n\t// late candidates\n\tif args.Term < rf.currentTerm {\n\t\trf.debug(\"Rejecting candidate %v. Reason: late term=%v\\n\", args.CandidateId, args.Term)\n\t\treturn\n\t}\n\n\t// avoid double vote\n\tif rf.votedFor != LEADER_UNKNOWN && rf.votedFor != args.CandidateId {\n\t\trf.debug(\"Rejecting candidate %v. Reason: already voted\\n\", args.CandidateId)\n\t\treturn\n\t}\n\n\tlastLogIndex := rf.lastEntryIndex()\n\n\t// reject old logs\n\tif rf.index(lastLogIndex).Term > args.LastLogTerm {\n\t\trf.debug(\"Rejecting candidate %v. Reason: old log\\n\", args.CandidateId)\n\t\treturn\n\t}\n\n\t// log is smaller\n\tif rf.index(lastLogIndex).Term == args.LastLogTerm && args.LastLogIndex < lastLogIndex {\n\t\trf.debug(\"Rejecting candidate %v. Reason: small log\\n\", args.CandidateId)\n\t\treturn\n\t}\n\n\trf.votedFor = args.CandidateId\n\trf.gotContacted = true\n\n\trf.debug(\"Granting vote to %v. me=(%v,%v), candidate=(%v,%v)\\n\", args.CandidateId, lastLogIndex, rf.index(lastLogIndex).Term, args.LastLogIndex, args.LastLogTerm)\n\treply.VoteGranted = true\n\n\t// save state\n\trf.persist(false)\n}", "func Vote(w http.ResponseWriter, r *http.Request) {\n\tvar data voteRequest // Create struct to store data.\n\terr := json.NewDecoder(r.Body).Decode(&data) // Decode response to struct.\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\thelpers.ThrowErr(w, r, \"JSON decoding error\", err)\n\t\treturn\n\t}\n\n\t// Secure our request with reCAPTCHA v2 and v3.\n\tif !captcha.V3(data.CaptchaV2, data.Captcha, r.Header.Get(\"CF-Connecting-IP\"), \"vote\") {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tvars := mux.Vars(r)\n\n\tpost, err := db.GetPost(vars[\"uuid\"])\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\thelpers.ThrowErr(w, r, \"Getting post from DB error\", err)\n\t\treturn\n\t}\n\n\tif post.Creation == 0 {\n\t\t// Post has been deleted.\n\t\tw.WriteHeader(http.StatusGone)\n\t\treturn\n\t}\n\n\tscore, err := db.SetVote(post, context.Get(r, \"uuid\").(string), data.Upvote)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\thelpers.ThrowErr(w, r, \"Setting vote error\", err)\n\t\treturn\n\t}\n\n\thelpers.JSONResponse(voteResponse{\n\t\tScore: score,\n\t}, w)\n\treturn\n}", "func (rf *Raft) RequestVote(args RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here.\n\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\tif rf.state == Follower {\n\t\trf.ResetHeartBeatTimer()\n\t}\n\n\t// term in candidate old than this follower\n\tif args.Term < rf.currentTerm {\n\t\treply.Term = rf.currentTerm\n\t\treply.VoteGranted = false\n\t\treturn\n\t}\n\n\tif args.Term > rf.currentTerm {\n\t\trf.UpdateNewTerm(args.Term)\n\t\trf.stateCh <- Follower\n\t}\n\n\tlogIndexSelf := len(rf.log) - 1\n\n\tvar isNew bool\n\t// the term is equal check the index\n\tif args.LastLogTerm == rf.log[logIndexSelf].Term {\n\t\tisNew = args.LastLogIndex >= logIndexSelf\n\t} else {\n\t\tisNew = args.LastLogTerm > rf.log[logIndexSelf].Term\n\t}\n\n\tif (rf.votedFor == -1 || rf.me == args.CandidateId) && isNew {\n\t\treply.Term = rf.currentTerm\n\t\treply.VoteGranted = true\n\t\trf.votedFor = args.CandidateId\n\t\trf.persist()\n\t\treturn\n\t} else {\n\t\treply.Term = rf.currentTerm\n\t\treply.VoteGranted = false\n\t}\n\n}", "func (r *ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequest) Get(ctx context.Context) ([]RequestObject, error) {\n\treturn r.GetN(ctx, 0)\n}", "func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo string, number int, logins []string) (*PullRequest, *Response, error) {\n\tu := fmt.Sprintf(\"repos/%s/%s/pulls/%d/requested_reviewers\", owner, repo, number)\n\n\treviewers := struct {\n\t\tReviewers []string `json:\"reviewers,omitempty\"`\n\t}{\n\t\tReviewers: logins,\n\t}\n\treq, err := s.client.NewRequest(\"POST\", u, &reviewers)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tr := new(PullRequest)\n\tresp, err := s.client.Do(ctx, req, r)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn r, resp, nil\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n DPrintf(\"%d: %d recieve RequestVote from %d:%d\\n\", rf.currentTerm, rf.me, args.Term, args.Candidate)\n // Your code here (2A, 2B).\n rf.mu.Lock()\n defer rf.mu.Unlock()\n if args.Term < rf.currentTerm {\n \n reply.VoteGranted = false\n reply.Term = rf.currentTerm\n DPrintf(\"%d: %d recieve voteRequest from %d:%d %v\\n\", rf.currentTerm, rf.me, args.Term, args.Candidate, reply.VoteGranted)\n return\n }\n\n if args.Term > rf.currentTerm {\n rf.votedFor = -1\n rf.currentTerm = args.Term\n }\n\n if rf.votedFor == -1 || rf.votedFor == args.Candidate {\n // election restriction\n if args.LastLogTerm < rf.log[len(rf.log) - 1].Term ||\n (args.LastLogTerm == rf.log[len(rf.log) - 1].Term &&\n args.LastLogIndex < len(rf.log) - 1) {\n rf.votedFor = -1\n reply.VoteGranted = false\n DPrintf(\"%d: %d recieve voteRequest from %d:%d %v\\n\", rf.currentTerm, rf.me, args.Term, args.Candidate, reply.VoteGranted)\n return\n }\n\n \n if rf.state == FOLLOWER {\n rf.heartbeat <- true\n }\n rf.state = FOLLOWER\n rf.resetTimeout()\n rf.votedFor = args.Candidate\n\n \n reply.VoteGranted = true\n reply.Term = args.Term\n DPrintf(\"%d: %d recieve voteRequest from %d:%d %v\\n\", rf.currentTerm, rf.me, args.Term, args.Candidate, reply.VoteGranted)\n return\n }\n reply.VoteGranted = false\n reply.Term = args.Term\n DPrintf(\"%d: %d recieve voteRequest from %d:%d %v\\n\", rf.currentTerm, rf.me, args.Term, args.Candidate, reply.VoteGranted)\n}", "func (*VoteRequest) Descriptor() ([]byte, []int) {\n\treturn file_internal_proto_crypto_proto_rawDescGZIP(), []int{1}\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\trf.lock()\n\tdefer rf.unLock()\n\treply.Term = rf.currentTerm\n\treply.VoteGranted = false\n\tif args.Term < rf.currentTerm {\n\t\treturn\n\t} else if args.Term > rf.currentTerm {\n\t\trf.currentTerm = args.Term\n\t\trf.votedFor = -1\n\t\trf.myState = FollowerState\n\t\trf.persist()\n\t}\n\n\tif rf.votedFor < 0 || rf.votedFor == args.CandidateId {\n\t\t// candidate's logEntries is at least as up-to-date as receiver's logEntries, grant vote\n\t\tlastLogTerm := -1\n\t\tif len(rf.logEntries) != 0 {\n\t\t\tlastLogTerm = rf.logEntries[len(rf.logEntries)-1].Term\n\t\t} else {\n\t\t\tlastLogTerm = rf.lastIncludedTerm\n\t\t}\n\t\tif args.LastLogTerm < lastLogTerm || (args.LastLogTerm == lastLogTerm && args.LastLogIndex < rf.lastIncludedIndex+len(rf.logEntries)) {\n\t\t\treturn\n\t\t} else {\n\t\t\trf.votedFor = args.CandidateId\n\t\t\treply.VoteGranted = true\n\t\t\trf.timerReset = time.Now()\n\t\t\trf.persist()\n\t\t\treturn\n\t\t}\n\t}\n\t// Your code here (2A, 2B).\n}", "func (c *RepoAPI) VoteProposal(body *api.BodyRepoVote) (*api.ResultHash, error) {\n\n\tif body.SigningKey == nil {\n\t\treturn nil, errors.ReqErr(400, ErrCodeBadParam, \"signingKey\", \"signing key is required\")\n\t}\n\n\ttx := txns.NewBareRepoProposalVote()\n\ttx.RepoName = body.RepoName\n\ttx.ProposalID = body.ProposalID\n\ttx.Vote = body.Vote\n\ttx.Nonce = body.Nonce\n\ttx.Fee = util.String(cast.ToString(body.Fee))\n\ttx.Timestamp = time.Now().Unix()\n\ttx.SenderPubKey = body.SigningKey.PubKey().ToPublicKey()\n\n\tvar err error\n\ttx.Sig, err = tx.Sign(body.SigningKey.PrivKey().Base58())\n\tif err != nil {\n\t\treturn nil, errors.ReqErr(400, ErrCodeClient, \"privkey\", err.Error())\n\t}\n\n\tresp, statusCode, err := c.c.call(\"repo_vote\", tx.ToMap())\n\tif err != nil {\n\t\treturn nil, makeReqErrFromCallErr(statusCode, err)\n\t}\n\n\tvar r api.ResultHash\n\tif err = util.DecodeMap(resp, &r); err != nil {\n\t\treturn nil, errors.ReqErr(500, ErrCodeDecodeFailed, \"\", err.Error())\n\t}\n\n\treturn &r, nil\n}", "func vote(w http.ResponseWriter, req *http.Request, upvote bool, isComment bool, t VoteRequest) error {\n\tif t.Id == \"\" {\n\t\treturn fmt.Errorf(\"missing post id\")\n\t}\n\ttable := \"posts\"\n\tif isComment {\n\t\ttable = \"comments\"\n\t}\n\trsp, err := client.DbService.Read(&db.ReadRequest{\n\t\tTable: table,\n\t\tId: t.Id,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(rsp.Records) == 0 {\n\t\treturn fmt.Errorf(\"post or comment not found\")\n\t}\n\n\t// auth\n\tsessionRsp, err := client.UserService.ReadSession(&user.ReadSessionRequest{\n\t\tSessionId: t.SessionID,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\tif sessionRsp.Session.UserId == \"\" {\n\t\treturn fmt.Errorf(\"user id not found\")\n\t}\n\n\t// prevent double votes\n\tcheckTable := table + \"votecheck\"\n\tcheckId := t.Id + sessionRsp.Session.UserId\n\tcheckRsp, err := client.DbService.Read(&db.ReadRequest{\n\t\tTable: checkTable,\n\t\tId: checkId,\n\t})\n\tmod := isMod(sessionRsp.Session.UserId, mods)\n\tif err == nil && (checkRsp != nil && len(checkRsp.Records) > 0) {\n\t\tif !mod {\n\t\t\treturn fmt.Errorf(\"already voted\")\n\t\t}\n\t}\n\tval := float64(1)\n\tif mod {\n\t\trand.Seed(time.Now().UnixNano())\n\t\tval = float64(rand.Intn(17-4) + 4)\n\t}\n\n\tif !mod {\n\t\t_, err = client.DbService.Create(&db.CreateRequest{\n\t\t\tTable: checkTable,\n\t\t\tRecord: map[string]interface{}{\n\t\t\t\t\"id\": checkId,\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tobj := rsp.Records[0]\n\tkey := \"upvotes\"\n\tif !upvote {\n\t\tkey = \"downvotes\"\n\t}\n\n\tif _, ok := obj[\"upvotes\"].(float64); !ok {\n\t\tobj[\"upvotes\"] = float64(0)\n\t}\n\tif _, ok := obj[\"downvotes\"].(float64); !ok {\n\t\tobj[\"downvotes\"] = float64(0)\n\t}\n\n\tobj[key] = obj[key].(float64) + val\n\tobj[\"score\"] = obj[\"upvotes\"].(float64) - obj[\"downvotes\"].(float64)\n\n\t_, err = client.DbService.Update(&db.UpdateRequest{\n\t\tTable: table,\n\t\tId: t.Id,\n\t\tRecord: obj,\n\t})\n\treturn err\n}", "func (commit *Commit) VoteBlockRequestID() []byte {\n\trequestIDMessage := []byte(\"dpbvote\")\n\theightByteArray := make([]byte, 8)\n\tbinary.LittleEndian.PutUint64(heightByteArray, uint64(commit.Height))\n\troundByteArray := make([]byte, 4)\n\tbinary.LittleEndian.PutUint32(roundByteArray, uint32(commit.Round))\n\n\trequestIDMessage = append(requestIDMessage, heightByteArray...)\n\trequestIDMessage = append(requestIDMessage, roundByteArray...)\n\n\treturn crypto.Sha256(requestIDMessage)\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\n\t//fmt.Printf(\"Server %d: log is %v\\n\", rf.me, rf.log)\n\n\tvar newer bool\n\n\tif args.Term > rf.currentTerm {\n\t\trf.votedFor = -1\n\t}\n\n\tif len(rf.log) == 0 || args.LastLogTerm > rf.log[len(rf.log)-1].Term {\n\t\tnewer = true\n\t} else if args.LastLogTerm == rf.log[len(rf.log)-1].Term && len(rf.log) <= args.LastLogIndex+1 {\n\t\tnewer = true\n\t}\n\n\tif newer == true && (rf.votedFor == -1 || rf.votedFor == args.CandidateID) {\n\t\treply.VoteGranted = true\n\t} else {\n\t\treply.VoteGranted = false\n\t}\n\n\tvar votedFor int\n\tif reply.VoteGranted {\n\t\tvotedFor = args.CandidateID\n\t} else {\n\t\tvotedFor = -1\n\t}\n\trf.votedFor = votedFor\n\n\tif args.Term < rf.currentTerm {\n\t\treply.VoteGranted = false\n\t} else if args.Term > rf.currentTerm {\n\t\trf.currentTerm = args.Term\n\t\tif rf.state != Follower {\n\t\t\trf.convertToFollower(rf.currentTerm, votedFor)\n\t\t}\n\t}\n\n\treply.Term = rf.currentTerm\n\n\trf.persist()\n\n\tif reply.VoteGranted == true {\n\t\tgo func() {\n\t\t\tselect {\n\t\t\tcase <-rf.grantVoteCh:\n\t\t\tdefault:\n\t\t\t}\n\t\t\trf.grantVoteCh <- true\n\t\t}()\n\t}\n}", "func revisionFromRequest(recent types.FileContractRevision, pbcr modules.PayByContractRequest) types.FileContractRevision {\n\trev := recent\n\n\trev.NewRevisionNumber = pbcr.NewRevisionNumber\n\trev.NewValidProofOutputs = make([]types.SiacoinOutput, len(pbcr.NewValidProofValues))\n\tfor i, v := range pbcr.NewValidProofValues {\n\t\tif i >= len(recent.NewValidProofOutputs) {\n\t\t\tbreak\n\t\t}\n\t\trev.NewValidProofOutputs[i] = types.SiacoinOutput{\n\t\t\tValue: v,\n\t\t\tUnlockHash: recent.NewValidProofOutputs[i].UnlockHash,\n\t\t}\n\t}\n\n\trev.NewMissedProofOutputs = make([]types.SiacoinOutput, len(pbcr.NewMissedProofValues))\n\tfor i, v := range pbcr.NewMissedProofValues {\n\t\tif i >= len(recent.NewMissedProofOutputs) {\n\t\t\tbreak\n\t\t}\n\t\trev.NewMissedProofOutputs[i] = types.SiacoinOutput{\n\t\t\tValue: v,\n\t\t\tUnlockHash: recent.NewMissedProofOutputs[i].UnlockHash,\n\t\t}\n\t}\n\n\treturn rev\n}", "func (rf *Raft) sendRequestVote(server int, args *RequestVoteArgs, reply *RequestVoteReply, voteCount *int32) bool {\n\tok := rf.peers[server].Call(\"Raft.RequestVote\", args, reply)\n\tlog.Printf(\"peer %v request vote to peer %v result %v\", rf.peerId, reply.VoterId, reply)\n\tif !ok {\n\t\treturn ok\n\t}\n\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\tif rf.getState() != Candidate || args.Term != rf.currentTerm {\n\t\treturn ok\n\t}\n\tif reply.Term > rf.currentTerm {\n\t\trf.stepDownToFollower(reply.Term)\n\t}\n\tif reply.VoteGranted {\n\t\tatomic.AddInt32(voteCount, 1)\n\t}\n\tif int(atomic.LoadInt32(voteCount)) > len(rf.peers)/2 {\n\t\trf.setState(Leader)\n\t\trf.electAsLeaderCh <- true\n\t}\n\treturn ok\n}", "func (keeper Keeper) GetVotes(ctx sdk.Context, proposalID uint64) (votes types.Votes) {\n\tkeeper.IterateVotes(ctx, proposalID, func(vote types.Vote) bool {\n\t\tvotes = append(votes, vote)\n\t\treturn false\n\t})\n\treturn\n}", "func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {\n\t// Your code here (2A, 2B).\n\tDPrintf(\"Raft node (%d) handles with RequestVote, candidateId: %v\\n\", rf.me, args.CandidateId)\n\trf.mu.Lock()\n\tdefer rf.mu.Unlock()\n\n\treply.Term = rf.currentTerm\n\treply.PeerId = rf.me\n\n\tif rf.currentTerm == args.Term && rf.votedFor != -1 && rf.votedFor != args.CandidateId {\n\t\tDPrintf(\"Raft node (%v) denied vote, votedFor: %v, candidateId: %v.\\n\", rf.me,\n\t\t\trf.votedFor, args.CandidateId)\n\t\treply.VoteGranted = false\n\t\treturn\n\t}\n\n\tlastLogIndex := len(rf.logs) - 1\n\tlastLogEntry := rf.logs[lastLogIndex]\n\tif lastLogEntry.Term > args.LastLogTerm || lastLogIndex > args.LastLogIndex {\n\t\t// If this node is more up-to-date than candidate, then reject vote\n\t\t//DPrintf(\"Raft node (%v) LastLogIndex: %v, LastLogTerm: %v, args (%v, %v)\\n\", rf.me,\n\t\t//\tlastLogIndex, lastLogEntry.Term, args.LastLogIndex, args.LastLogTerm)\n\t\treply.VoteGranted = false\n\t\treturn\n\t}\n\n\trf.tryEnterFollowState(args.Term)\n\n\trf.currentTerm = args.Term\n\trf.votedFor = args.CandidateId\n\treply.VoteGranted = true\n}" ]
[ "0.61757547", "0.6035921", "0.55281144", "0.5522556", "0.5502034", "0.5381857", "0.5226636", "0.51511484", "0.5136846", "0.5118304", "0.50843143", "0.5066021", "0.5065501", "0.50638837", "0.49484923", "0.49452785", "0.49406174", "0.4903563", "0.48684135", "0.48664993", "0.4847217", "0.48467264", "0.4831342", "0.4828591", "0.480906", "0.48023817", "0.47939476", "0.47804308", "0.47768643", "0.47753012", "0.47674584", "0.47615245", "0.4754029", "0.4747477", "0.4720985", "0.4713356", "0.47130835", "0.47129223", "0.46952382", "0.4693013", "0.46927628", "0.4684932", "0.46797743", "0.4668367", "0.4667689", "0.4653999", "0.46521637", "0.46504027", "0.46496215", "0.46457985", "0.4638288", "0.46163607", "0.46157253", "0.46091697", "0.45999536", "0.459412", "0.4586752", "0.45862198", "0.45751578", "0.45709395", "0.45701525", "0.4566862", "0.4562645", "0.4559903", "0.45585206", "0.45517704", "0.45489812", "0.45478618", "0.45359105", "0.45341852", "0.45084196", "0.4505923", "0.4502941", "0.45018262", "0.4501159", "0.4498306", "0.44977093", "0.44928256", "0.44832876", "0.44832322", "0.4473499", "0.44729653", "0.44680732", "0.44612536", "0.44552764", "0.44506845", "0.4449672", "0.4445938", "0.44399658", "0.44380847", "0.44315034", "0.44278756", "0.44266808", "0.44148165", "0.44077054", "0.4406762", "0.44053656", "0.4399242", "0.43938738", "0.43867618" ]
0.8009276
0
GetCommitteeRequestsList api request get_committee_requests_list
GetCommitteeRequestsList api запрос get_committee_requests_list
func (api *API) GetCommitteeRequestsList(status uint16) ([]*uint16, error) { var resp []*uint16 err := api.call("committee_api", "get_committee_requests_list", []interface{}{status}, &resp) return resp, err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (api *API) GetCommitteeRequest(id uint32, count int32) (*CommitteeObject, error) {\n\tvar resp CommitteeObject\n\terr := api.call(\"committee_api\", \"get_committee_request\", []interface{}{id, count}, &resp)\n\treturn &resp, err\n}", "func (api *API) GetCommitteeRequestVotes(id uint32) ([]*CommitteeVoteState, error) {\n\tvar resp []*CommitteeVoteState\n\terr := api.call(\"committee_api\", \"get_committee_request_votes\", []interface{}{id}, &resp)\n\treturn resp, err\n}", "func (c *Client) ListPullRequestCommits(owner, repo string, index int64, opt ListPullRequestCommitsOptions) ([]*Commit, *Response, error) {\n\tif err := escapeValidatePathSegments(&owner, &repo); err != nil {\n\t\treturn nil, nil, err\n\t}\n\tlink, _ := url.Parse(fmt.Sprintf(\"/repos/%s/%s/pulls/%d/commits\", owner, repo, index))\n\topt.setDefaults()\n\tcommits := make([]*Commit, 0, opt.PageSize)\n\tlink.RawQuery = opt.getURLQuery().Encode()\n\tresp, err := c.getParsedResponse(\"GET\", link.String(), nil, nil, &commits)\n\treturn commits, resp, err\n}", "func (r *ApprovalWorkflowProviderRequestsCollectionRequest) Get(ctx context.Context) ([]RequestObject, error) {\n\treturn r.GetN(ctx, 0)\n}", "func (client IdentityClient) listWorkRequests(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/workRequests\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response ListWorkRequestsResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (client BastionClient) listWorkRequests(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) {\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/workRequests\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response ListWorkRequestsResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (api MWSAPI) GetReportRequestList(params map[string]string) (string, error) {\n\t// params := make(map[string]string)\n\tparams[\"MarketplaceId\"] = string(api.MarketplaceID)\n\treturn api.genSignAndFetch(\"GetReportRequestList\", reportAPI, params)\n}", "func (r *ScheduleOpenShiftChangeRequestsCollectionRequest) Get(ctx context.Context) ([]OpenShiftChangeRequestObject, error) {\n\treturn r.GetN(ctx, 0)\n}", "func (c APIClient) ListCommit(repoName string, to string, from string, number uint64) ([]*pfs.CommitInfo, error) {\n\tvar result []*pfs.CommitInfo\n\tif err := c.ListCommitF(repoName, to, from, number, func(ci *pfs.CommitInfo) error {\n\t\tresult = append(result, ci)\n\t\treturn nil\n\t}); err != nil {\n\t\treturn nil, err\n\t}\n\treturn result, nil\n}", "func (client IdentityClient) ListWorkRequests(ctx context.Context, request ListWorkRequestsRequest) (response ListWorkRequestsResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.listWorkRequests, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = ListWorkRequestsResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = ListWorkRequestsResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(ListWorkRequestsResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into ListWorkRequestsResponse\")\n\t}\n\treturn\n}", "func (client IdentityClient) listTaggingWorkRequests(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/taggingWorkRequests\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response ListTaggingWorkRequestsResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (client BastionClient) listWorkRequestLogs(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) {\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/workRequests/{workRequestId}/logs\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response ListWorkRequestLogsResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (client BastionClient) ListWorkRequests(ctx context.Context, request ListWorkRequestsRequest) (response ListWorkRequestsResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.listWorkRequests, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = ListWorkRequestsResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = ListWorkRequestsResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(ListWorkRequestsResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into ListWorkRequestsResponse\")\n\t}\n\treturn\n}", "func (store *Engine) Requests(offset, limit, filter string) ([]Request, error) {\n\tresult := requestsResult{}\n\tfilters := Params{\n\t\tOffset: offset,\n\t\tLimit: limit,\n\t\tFilter: filter,\n\t}\n\n\t_, err := store.api.\n\t\tURL(\"/workflow-engine/api/v1/requests\").\n\t\tQuery(&filters).\n\t\tGet(&result)\n\n\treturn result.Items, err\n}", "func (g *Gatherer) listCommits(branch, start, end string) ([]*gogithub.RepositoryCommit, error) {\n\tstartCommit, _, err := g.client.GetCommit(g.context, g.options.GithubOrg, g.options.GithubRepo, start)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"retrieve start commit: %w\", err)\n\t}\n\n\tendCommit, _, err := g.client.GetCommit(g.context, g.options.GithubOrg, g.options.GithubRepo, end)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"retrieve end commit: %w\", err)\n\t}\n\n\tallCommits := &commitList{}\n\n\tworker := func(clo *gogithub.CommitsListOptions) (\n\t\tcommits []*gogithub.RepositoryCommit, resp *gogithub.Response, err error,\n\t) {\n\t\tfor {\n\t\t\tcommits, resp, err = g.client.ListCommits(g.context, g.options.GithubOrg, g.options.GithubRepo, clo)\n\t\t\tif err != nil {\n\t\t\t\tif !canWaitAndRetry(resp, err) {\n\t\t\t\t\treturn nil, nil, err\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn commits, resp, err\n\t}\n\n\tclo := gogithub.CommitsListOptions{\n\t\tSHA: branch,\n\t\tSince: startCommit.GetCommitter().GetDate().Time,\n\t\tUntil: endCommit.GetCommitter().GetDate().Time,\n\t\tListOptions: gogithub.ListOptions{\n\t\t\tPage: 1,\n\t\t\tPerPage: 100,\n\t\t},\n\t}\n\n\tcommits, resp, err := worker(&clo)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tallCommits.Add(commits)\n\n\tremainingPages := resp.LastPage - 1\n\tif remainingPages < 1 {\n\t\treturn allCommits.List(), nil\n\t}\n\n\tt := throttler.New(maxParallelRequests, remainingPages)\n\tfor page := 2; page <= resp.LastPage; page++ {\n\t\tclo := clo\n\t\tclo.ListOptions.Page = page\n\n\t\tgo func() {\n\t\t\tcommits, _, err := worker(&clo)\n\t\t\tif err == nil {\n\t\t\t\tallCommits.Add(commits)\n\t\t\t}\n\t\t\tt.Done(err)\n\t\t}()\n\n\t\t// abort all, if we got one error\n\t\tif t.Throttle() > 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif err := t.Err(); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn allCommits.List(), nil\n}", "func FetchRequestList(db *sql.DB, appID string, entriesPerPage, offset int) []SummarizedRequest {\n\tvar result []SummarizedRequest\n\n\trows, err := queryGetRequests(db, appID, entriesPerPage, offset)\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\n\t\treturn result\n\t}\n\n\tif rows.Err() != nil {\n\t\tlog.Println(rows.Err().Error())\n\n\t\treturn result\n\t}\n\n\tdefer rows.Close()\n\n\tfor rows.Next() {\n\t\tvar request SummarizedRequest\n\n\t\terr := rows.Scan(\n\t\t\t&request.UID,\n\t\t\t&request.Method,\n\t\t\t&request.Path,\n\t\t\t&request.Time,\n\t\t\t&request.ResponseStatus,\n\t\t)\n\t\tif err != nil {\n\t\t\tlog.Println(err.Error())\n\t\t\treturn result\n\t\t}\n\n\t\tresult = append(result, request)\n\t}\n\n\treturn result\n}", "func (p *PullRequestsService) ListCommits(owner, repoSlug string, pullRequestID int64, opts ...interface{}) (*Commits, *Response, error) {\n\tresult := new(Commits)\n\turlStr := p.client.requestURL(\"/repositories/%s/%s/pullrequests/%v/commits\", owner, repoSlug, pullRequestID)\n\turlStr, addOptErr := addQueryParams(urlStr, opts...)\n\tif addOptErr != nil {\n\t\treturn nil, nil, addOptErr\n\t}\n\n\tresponse, err := p.client.execute(\"GET\", urlStr, result, nil)\n\n\treturn result, response, err\n}", "func NewListRequest() *todopb.ListRequest {\n\tmessage := &todopb.ListRequest{}\n\treturn message\n}", "func (client BastionClient) ListWorkRequestLogs(ctx context.Context, request ListWorkRequestLogsRequest) (response ListWorkRequestLogsResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.listWorkRequestLogs, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = ListWorkRequestLogsResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = ListWorkRequestLogsResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(ListWorkRequestLogsResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into ListWorkRequestLogsResponse\")\n\t}\n\treturn\n}", "func (a *RepoAPI) listMergeRequests(params interface{}) (resp *rpc.Response) {\n\tm := objx.New(cast.ToStringMap(params))\n\tname := m.Get(\"name\").Str()\n\treturn rpc.Success(util.Map{\n\t\t\"data\": a.mods.Repo.ListIssues(name),\n\t})\n}", "func MergeRequestListCmd(targetRepo pl.LocalRepo, args *MergeRequestListArgs) (pl.Posts, error) {\n\n\t// Get merge requests posts\n\tmergeReqs, err := args.PostGetter(targetRepo, func(ref plumbing.ReferenceName) bool {\n\t\treturn pl.IsMergeRequestReference(ref.String())\n\t})\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to get merge requests posts\")\n\t}\n\n\t// Sort by their first post time\n\tmergeReqs.SortByFirstPostCreationTimeDesc()\n\n\t// Reverse merge requests if requested\n\tif args.Reverse {\n\t\tmergeReqs.Reverse()\n\t}\n\n\t// Limited the merge requests if requested\n\tif args.Limit > 0 && args.Limit < len(mergeReqs) {\n\t\tmergeReqs = mergeReqs[:args.Limit]\n\t}\n\n\treturn mergeReqs, nil\n}", "func (server *RepositoriesService) ListPullRequests(ctx context.Context, project, repo string, opt *PullRequestListOpts) (*PullRequests, *http.Response, error) {\n\t// Detailed info: https://docs.atlassian.com/bitbucket-server/rest/6.5.1/bitbucket-rest.html#idp254\n\tu := fmt.Sprintf(\"rest/api/1.0/projects/%s/repos/%s/pull-requests\", project, repo)\n\treq, err := server.v1Client.NewRequest(http.MethodGet, u, nil, opt)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tvar prs PullRequests\n\tresp, err := server.v1Client.Do(req, &prs)\n\treturn &prs, resp, err\n}", "func (client IdentityClient) listIamWorkRequests(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/iamWorkRequests\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response ListIamWorkRequestsResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func requestCredList(ctx aws.Context, client *ec2metadata.EC2Metadata) ([]string, error) {\n\tresp, err := client.GetMetadataWithContext(ctx, iamSecurityCredsPath)\n\tif err != nil {\n\t\treturn nil, awserr.New(\"EC2RoleRequestError\", \"no EC2 instance role found\", err)\n\t}\n\n\tcredsList := []string{}\n\ts := bufio.NewScanner(strings.NewReader(resp))\n\tfor s.Scan() {\n\t\tcredsList = append(credsList, s.Text())\n\t}\n\n\tif err := s.Err(); err != nil {\n\t\treturn nil, awserr.New(request.ErrCodeSerialization,\n\t\t\t\"failed to read EC2 instance role from metadata service\", err)\n\t}\n\n\treturn credsList, nil\n}", "func ListRequest(baseURL, resourceType string) (*http.Request, error) {\n\tu, err := url.Parse(baseURL)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error parsing URL: %v\", err)\n\t}\n\tsetPath(u, resourceType)\n\n\treturn NewRequest(\"GET\", u.String(), nil)\n}", "func GetRequestListing(tx *sql.Tx, options *RequestListingOptions) ([]*model.RequestSummary, error) {\n\n\t// Prepare the primary listing query as a subquery.\n\tsubquery := psql.Select().Distinct().\n\t\tColumn(\"r.id\").\n\t\tColumn(\"regexp_replace(u.username, '@.*', '') AS username\").\n\t\tColumn(\"rt.name AS request_type\").\n\t\tColumn(\"first(ru.created_date) OVER w AS created_date\").\n\t\tColumn(\"last(rsc.name) OVER w AS status\").\n\t\tColumn(\"last(rsc.display_name) OVER w AS display_status\").\n\t\tColumn(\"last(ru.created_date) OVER w AS updated_date\").\n\t\tColumn(\"CAST(r.details AS text) AS details\").\n\t\tFrom(\"requests r\").\n\t\tJoin(\"users u ON r.requesting_user_id = u.id\").\n\t\tJoin(\"request_types rt ON r.request_type_id = rt.id\").\n\t\tJoin(\"request_updates ru ON r.id = ru.request_id\").\n\t\tJoin(\"request_status_codes rsc ON ru.request_status_code_id = rsc.id\").\n\t\tSuffix(\"WINDOW w AS (\" +\n\t\t\t\"PARTITION BY ru.request_id \" +\n\t\t\t\"ORDER BY ru.created_date \" +\n\t\t\t\"RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)\")\n\n\t// Prepare the base query.\n\tbase := psql.Select().\n\t\tColumn(\"id\").\n\t\tColumn(\"username\").\n\t\tColumn(\"request_type\").\n\t\tColumn(\"created_date\").\n\t\tColumn(\"display_status\").\n\t\tColumn(\"updated_date\").\n\t\tColumn(\"details\").\n\t\tFromSelect(subquery, \"subquery\").\n\t\tOrderBy(\"created_date\")\n\n\t// Add the filter to omit completed requests if we're not supposed to include them in the listing.\n\tif !options.IncludeCompletedRequests {\n\t\tbase = base.Where(sq.NotEq{\"status\": []string{\"approved\", \"rejected\"}})\n\t}\n\n\t// Add the filter to limit the listing to requests of a given type if applicable.\n\tif options.RequestType != \"\" {\n\t\tbase = base.Where(sq.Eq{\"request_type\": options.RequestType})\n\t}\n\n\t// Add the filter to limit the listing to requests submitted by a user if applicable.\n\tif options.RequestingUser != \"\" {\n\t\tbase = base.Where(sq.Eq{\"username\": options.RequestingUser})\n\t}\n\n\t// Build the query.\n\tquery, args, err := base.ToSql()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Query the database.\n\trows, err := tx.Query(query, args...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\n\t// Build the listing from the result set.\n\tlisting := make([]*model.RequestSummary, 0)\n\tfor rows.Next() {\n\t\tvar request model.RequestSummary\n\t\tvar requestDetails string\n\t\terr = rows.Scan(\n\t\t\t&request.ID,\n\t\t\t&request.RequestingUser,\n\t\t\t&request.RequestType,\n\t\t\t&request.CreatedDate,\n\t\t\t&request.Status,\n\t\t\t&request.UpdatedDate,\n\t\t\t&requestDetails,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\terr = json.Unmarshal([]byte(requestDetails), &request.Details)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tlisting = append(listing, &request)\n\t}\n\n\treturn listing, nil\n}", "func (ag *TSMClient) ListTechSupportRequests() []*tsproto.TechSupportRequestEvent {\n\treturn ag.notifications\n}", "func (r *ApprovalWorkflowProviderRequestsAwaitingMyDecisionCollectionRequest) Get(ctx context.Context) ([]RequestObject, error) {\n\treturn r.GetN(ctx, 0)\n}", "func (r *ScheduleSwapShiftsChangeRequestsCollectionRequest) Get(ctx context.Context) ([]SwapShiftsChangeRequestObject, error) {\n\treturn r.GetN(ctx, 0)\n}", "func (client IdentityClient) listTaggingWorkRequestLogs(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/taggingWorkRequests/{workRequestId}/logs\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response ListTaggingWorkRequestLogsResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func GetTRBRequests(ctx context.Context, archived bool, store *storage.Store) ([]*models.TRBRequest, error) {\n\tTRBRequests, err := store.GetTRBRequests(ctx, archived)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn TRBRequests, err\n}", "func (client IdentityClient) listIamWorkRequestLogs(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/iamWorkRequests/{iamWorkRequestId}/logs\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response ListIamWorkRequestLogsResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (client IdentityClient) ListTaggingWorkRequests(ctx context.Context, request ListTaggingWorkRequestsRequest) (response ListTaggingWorkRequestsResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.listTaggingWorkRequests, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = ListTaggingWorkRequestsResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = ListTaggingWorkRequestsResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(ListTaggingWorkRequestsResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into ListTaggingWorkRequestsResponse\")\n\t}\n\treturn\n}", "func (c *client) GetPullRequestChanges(org, repo string, number int) ([]PullRequestChange, error) {\n\tdurationLogger := c.log(\"GetPullRequestChanges\", org, repo, number)\n\tdefer durationLogger()\n\n\tif c.fake {\n\t\treturn []PullRequestChange{}, nil\n\t}\n\tpath := fmt.Sprintf(\"/repos/%s/%s/pulls/%d/files\", org, repo, number)\n\tvar changes []PullRequestChange\n\terr := c.readPaginatedResults(\n\t\tpath,\n\t\tacceptNone,\n\t\torg,\n\t\tfunc() interface{} {\n\t\t\treturn &[]PullRequestChange{}\n\t\t},\n\t\tfunc(obj interface{}) {\n\t\t\tchanges = append(changes, *(obj.(*[]PullRequestChange))...)\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn changes, nil\n}", "func NewListRequest() *rolespb.ListRequest {\n\tmessage := &rolespb.ListRequest{}\n\treturn message\n}", "func (k Keeper) GetAllRequest(ctx sdk.Context) (list []types.Request) {\n\tstores := k.GetStoreRequestMap(ctx)\n\tfor _, store := range stores {\n\t\tfunc(store prefix.Store) {\n\t\t\titerator := sdk.KVStorePrefixIterator(store, []byte{})\n\t\t\tdefer iterator.Close()\n\n\t\t\tfor ; iterator.Valid(); iterator.Next() {\n\t\t\t\tvar val types.Request\n\t\t\t\tk.cdc.MustUnmarshal(iterator.Value(), &val)\n\t\t\t\tlist = append(list, val)\n\t\t\t}\n\t\t}(store)\n\t}\n\treturn\n}", "func (s *PublicBlockChainAPI) GetCommittee(ctx context.Context, epoch int64) (map[string]interface{}, error) {\n\tcommittee, err := s.b.GetCommittee(big.NewInt(epoch))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvalidators := make([]map[string]interface{}, 0)\n\tfor _, validator := range committee.NodeList {\n\t\tvalidatorBalance := new(hexutil.Big)\n\t\tvalidatorBalance, err = s.b.GetBalance(validator.EcdsaAddress)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\toneAddress, err := internal_common.AddressToBech32(validator.EcdsaAddress)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tvalidatorsFields := map[string]interface{}{\n\t\t\t\"address\": oneAddress,\n\t\t\t\"balance\": validatorBalance,\n\t\t}\n\t\tvalidators = append(validators, validatorsFields)\n\t}\n\tresult := map[string]interface{}{\n\t\t\"shardID\": committee.ShardID,\n\t\t\"validators\": validators,\n\t}\n\treturn result, nil\n}", "func (c *ECS) ListTasksRequest(input *ListTasksInput) (req *aws.Request, output *ListTasksOutput) {\n\toprw.Lock()\n\tdefer oprw.Unlock()\n\n\tif opListTasks == nil {\n\t\topListTasks = &aws.Operation{\n\t\t\tName: \"ListTasks\",\n\t\t\tHTTPMethod: \"POST\",\n\t\t\tHTTPPath: \"/\",\n\t\t}\n\t}\n\n\treq = c.newRequest(opListTasks, input, output)\n\toutput = &ListTasksOutput{}\n\treq.Data = output\n\treturn\n}", "func GetRequests(c *gin.Context) {}", "func (a *BulkApiService) GetBulkRequestList(ctx context.Context) ApiGetBulkRequestListRequest {\n\treturn ApiGetBulkRequestListRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t}\n}", "func (r *friendRepository) RequestList(id string) (*[]model.FriendRequest, error) {\n\tvar requests []model.FriendRequest\n\n\tresult := r.DB.\n\t\tRaw(`\n\t\t select u.id, u.username, u.image, 1 as \"type\" from users u\n\t\t join friend_requests fr on u.id = fr.\"sender_id\"\n\t\t where fr.\"receiver_id\" = @id\n\t\t UNION\n\t\t select u.id, u.username, u.image, 0 as \"type\" from users u\n\t\t join friend_requests fr on u.id = fr.\"receiver_id\"\n\t\t where fr.\"sender_id\" = @id\n\t\t order by username;\n\t\t`, sql.Named(\"id\", id)).\n\t\tFind(&requests)\n\n\treturn &requests, result.Error\n}", "func (b *ApprovalWorkflowProviderRequestBuilder) Requests() *ApprovalWorkflowProviderRequestsCollectionRequestBuilder {\n\tbb := &ApprovalWorkflowProviderRequestsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}\n\tbb.baseURL += \"/requests\"\n\treturn bb\n}", "func (client IdentityClient) ListTaggingWorkRequestLogs(ctx context.Context, request ListTaggingWorkRequestLogsRequest) (response ListTaggingWorkRequestLogsResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.listTaggingWorkRequestLogs, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = ListTaggingWorkRequestLogsResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = ListTaggingWorkRequestLogsResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(ListTaggingWorkRequestLogsResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into ListTaggingWorkRequestLogsResponse\")\n\t}\n\treturn\n}", "func (c *gitlabClient) PullRequestEvents(context.Context, string, []interface{}) ([]sdk.VCSPullRequestEvent, error) {\n\treturn nil, fmt.Errorf(\"Not implemented on Gitlab\")\n}", "func (c APIClient) ListCommitF(repoName string, to string, from string, number uint64, f func(*pfs.CommitInfo) error) error {\n\treq := &pfs.ListCommitRequest{\n\t\tRepo: NewRepo(repoName),\n\t\tNumber: number,\n\t}\n\tif from != \"\" {\n\t\treq.From = NewCommit(repoName, from)\n\t}\n\tif to != \"\" {\n\t\treq.To = NewCommit(repoName, to)\n\t}\n\tstream, err := c.PfsAPIClient.ListCommitStream(c.Ctx(), req)\n\tif err != nil {\n\t\treturn grpcutil.ScrubGRPC(err)\n\t}\n\tfor {\n\t\tci, err := stream.Recv()\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t} else if err != nil {\n\t\t\treturn grpcutil.ScrubGRPC(err)\n\t\t}\n\t\tif err := f(ci); err != nil {\n\t\t\tif err == errutil.ErrBreak {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (a *API) DoctorRequestsList(r *gin.Context) {\n\tvar (\n\t\taccountIDString = r.Query(\"account_id\")\n\t\tstatus = r.Query(\"status\")\n\t\tincludeAccounts = r.Query(\"include_accounts\") == \"true\"\n\t\tskipAnswer = r.Query(\"skip_answer\") == \"true\"\n\t\toffsetString = r.Query(\"offset\")\n\t\tlimitString = r.Query(\"limit\")\n\t\torderBy = r.DefaultQuery(\"order_by\", \"requests.created_at\")\n\t)\n\n\tvar (\n\t\toffset int\n\t\tlimit = 50\n\t)\n\n\tif parsedOffset, err := strconv.Atoi(offsetString); err == nil {\n\t\toffset = parsedOffset\n\t}\n\n\tif parsedLimit, err := strconv.Atoi(limitString); err == nil {\n\t\tlimit = parsedLimit\n\t}\n\n\tquery := psql.Select(\n\t\t\"requests.id\",\n\t\t\"requests.account_id\",\n\t\t\"requests.status\",\n\t\t\"requests.answer_text\",\n\t\t\"requests.answered_by\",\n\t\t\"requests.answered_at\",\n\t\t\"requests.created_at\",\n\t\t\"requests.updated_at\",\n\t\t\"accounts.id\",\n\t\t\"accounts.name\",\n\t\t\"accounts.email\",\n\t\t\"accounts.phone\",\n\t\t\"accounts.gender\",\n\t\t\"accounts.birth_date\",\n\t\t\"accounts.created_at\",\n\t\t\"accounts.updated_at\",\n\t).From(\"requests\").\n\t\tLeftJoin(\"accounts ON accounts.id = requests.account_id\").\n\t\tOrderBy(orderBy)\n\n\tquery = query.Columns(`COUNT(*) OVER() AS \"total_count\"`)\n\n\tif accountIDString != \"\" {\n\t\taccountID, err := types.StringToUUID(accountIDString)\n\t\tif err != nil {\n\t\t\tr.AbortWithStatusJSON(http.StatusBadRequest, gin.H{\n\t\t\t\t\"error\": \"Invalid account ID\",\n\t\t\t})\n\t\t\treturn\n\t\t}\n\t\tquery = query.Where(\"requests.account_id = ?\", &accountID)\n\t}\n\n\tif status != \"\" {\n\t\tquery = query.Where(\"requests.status = ?\", status)\n\t}\n\n\tif filters := r.QueryMap(\"filters\"); len(filters) > 0 {\n\t\tfor key, value := range filters {\n\t\t\tvar (\n\t\t\t\tparts = strings.SplitN(value, \":\", 2)\n\t\t\t\tdesired = []interface{}{}\n\t\t\t\tsymbol string\n\t\t\t)\n\t\t\tswitch parts[0] {\n\t\t\tcase \"eq\":\n\t\t\t\tsymbol = \"= ?\"\n\t\t\t\tdesired = append(desired, tryParse(key, parts[1]))\n\t\t\tcase \"like\":\n\t\t\t\tsymbol = \"LIKE ?\"\n\t\t\t\tdesired = append(desired, tryParse(key, parts[1]))\n\t\t\tcase \"ilike\":\n\t\t\t\tsymbol = \"ILIKE ?\"\n\t\t\t\tdesired = append(desired, tryParse(key, parts[1]))\n\t\t\tcase \"contains\":\n\t\t\t\tsymbol = \"LIKE ?\"\n\t\t\t\tdesired = append(desired, \"%\"+parts[1]+\"%\")\n\t\t\tcase \"icontains\":\n\t\t\t\tsymbol = \"ILIKE ?\"\n\t\t\t\tdesired = append(desired, \"%\"+parts[1]+\"%\")\n\t\t\tcase \"ne\":\n\t\t\t\tsymbol = \"!= ?\"\n\t\t\t\tdesired = append(desired, tryParse(key, parts[1]))\n\t\t\tcase \"gt\":\n\t\t\t\tsymbol = \"> ?\"\n\t\t\t\tdesired = append(desired, tryParse(key, parts[1]))\n\t\t\tcase \"gte\":\n\t\t\t\tsymbol = \">= ?\"\n\t\t\t\tdesired = append(desired, tryParse(key, parts[1]))\n\t\t\tcase \"lt\":\n\t\t\t\tsymbol = \"< ?\"\n\t\t\t\tdesired = append(desired, tryParse(key, parts[1]))\n\t\t\tcase \"lte\":\n\t\t\t\tsymbol = \"<= ?\"\n\t\t\t\tdesired = append(desired, tryParse(key, parts[1]))\n\t\t\tcase \"between\":\n\t\t\t\tsymbol = \"BETWEEN ? AND ?\"\n\t\t\t\tsubparts := strings.SplitN(parts[1], \":\", 2)\n\t\t\t\tdesired = append(desired, tryParse(key, subparts[0]), tryParse(key, subparts[1]))\n\t\t\t}\n\n\t\t\tquery = query.Where(key+\" \"+symbol, desired...)\n\t\t}\n\t}\n\n\tquery = query.Offset(uint64(offset)).Limit(uint64(limit))\n\n\tsql, args, err := query.ToSql()\n\tif err != nil {\n\t\tlog.Println(\"Error while building the ListRequests query\", err)\n\t\tr.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{\n\t\t\t\"error\": \"Unable to build the query\",\n\t\t})\n\t\treturn\n\t}\n\n\trows, err := a.DB.QueryEx(r, sql, nil, args...)\n\tif err != nil {\n\t\tlog.Println(\"Error while executing the ListRequests query\", err)\n\t\tr.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{\n\t\t\t\"error\": \"Unable to list requests, \" + err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tresponse := &extResponse{\n\t\tData: []*extRequest{},\n\t}\n\n\tfor rows.Next() {\n\t\titem := &extRequest{\n\t\t\tRequest: &models.Request{},\n\t\t\tAccount: &models.Account{},\n\t\t}\n\n\t\tif err := rows.Scan(\n\t\t\t&item.Request.ID,\n\t\t\t&item.Request.AccountID,\n\t\t\t&item.Request.Status,\n\t\t\t&item.Request.AnswerText,\n\t\t\t&item.Request.AnsweredBy,\n\t\t\t&item.Request.AnsweredAt,\n\t\t\t&item.Request.CreatedAt,\n\t\t\t&item.Request.UpdatedAt,\n\t\t\t&item.Account.ID,\n\t\t\t&item.Account.Name,\n\t\t\t&item.Account.Email,\n\t\t\t&item.Account.Phone,\n\t\t\t&item.Account.Gender,\n\t\t\t&item.Account.BirthDate,\n\t\t\t&item.Account.CreatedAt,\n\t\t\t&item.Account.UpdatedAt,\n\t\t\t&response.TotalCount,\n\t\t); err != nil {\n\t\t\tr.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{\n\t\t\t\t\"error\": \"Unable to scan requests\",\n\t\t\t})\n\t\t\treturn\n\t\t}\n\n\t\tif skipAnswer {\n\t\t\titem.AnswerText = types.ExtendedText{\n\t\t\t\tStatus: pgtype.Null,\n\t\t\t}\n\t\t}\n\n\t\tif !includeAccounts {\n\t\t\titem.Account = nil\n\t\t}\n\n\t\tresponse.Data = append(response.Data, item)\n\t}\n\n\tr.JSON(http.StatusOK, response)\n}", "func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo string, number int, logins []string) (*PullRequest, *Response, error) {\n\tu := fmt.Sprintf(\"repos/%s/%s/pulls/%d/requested_reviewers\", owner, repo, number)\n\n\treviewers := struct {\n\t\tReviewers []string `json:\"reviewers,omitempty\"`\n\t}{\n\t\tReviewers: logins,\n\t}\n\treq, err := s.client.NewRequest(\"POST\", u, &reviewers)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tr := new(PullRequest)\n\tresp, err := s.client.Do(ctx, req, r)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn r, resp, nil\n}", "func (r *InformationProtectionThreatAssessmentRequestsCollectionRequest) Get(ctx context.Context) ([]ThreatAssessmentRequestObject, error) {\n\treturn r.GetN(ctx, 0)\n}", "func (client *DiskEncryptionSetsClient) listCreateRequest(ctx context.Context, options *DiskEncryptionSetsListOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (dal *UserDAL) GetUserRequests(id int, before time.Time, size int) ([]models.Request, error) {\n\treqs := []models.Request{}\n\terr := dal.db.Select(&reqs,\n\t\t`SELECT * FROM request WHERE userid = $1 AND timestamp < $2\n\t\t\tORDER BY timestamp DESC\n\t\t\tLIMIT $3`, id, before.UTC(), size)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn reqs, nil\n}", "func (g *channelClient) GetTicketList(ctx context.Context, in *types.ReqNil) ([]*ty.Ticket, error) {\n\tinn := *in\n\tdata, err := g.ExecWalletFunc(ty.TicketX, \"WalletGetTickets\", &inn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn data.(*ty.ReplyWalletTickets).Tickets, nil\n}", "func (_BaseLibrary *BaseLibraryCaller) ApprovalRequests(opts *bind.CallOpts, arg0 *big.Int) (common.Address, error) {\n\tvar out []interface{}\n\terr := _BaseLibrary.contract.Call(opts, &out, \"approvalRequests\", arg0)\n\n\tif err != nil {\n\t\treturn *new(common.Address), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)\n\n\treturn out0, err\n\n}", "func (client *Client) listCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, resourceType string, resourceName string, options *ClientListOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Resources/changes\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif resourceProviderNamespace == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceProviderNamespace cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceProviderNamespace}\", url.PathEscape(resourceProviderNamespace))\n\tif resourceType == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceType}\", url.PathEscape(resourceType))\n\tif resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(resourceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-05-01\")\n\tif options != nil && options.Top != nil {\n\t\treqQP.Set(\"$top\", strconv.FormatInt(*options.Top, 10))\n\t}\n\tif options != nil && options.SkipToken != nil {\n\t\treqQP.Set(\"$skipToken\", *options.SkipToken)\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (c *Client) CommittedTickets(ct *walletrpc.CommittedTicketsRequest) (*walletrpc.CommittedTicketsResponse, error) {\n\tif c.wallet == nil {\n\t\treturn nil, fmt.Errorf(\"walletrpc client not loaded\")\n\t}\n\n\tif c.cfg.Verbose {\n\t\tfmt.Printf(\"walletrpc %v CommittedTickets\\n\", c.cfg.WalletHost)\n\t}\n\n\tctr, err := c.wallet.CommittedTickets(c.ctx, ct)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif c.cfg.Verbose {\n\t\terr := prettyPrintJSON(ctr)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn ctr, nil\n}", "func GetCommitList(dbOwner, dbFolder, dbName string) (map[string]CommitEntry, error) {\n\tdbQuery := `\n\t\tWITH u AS (\n\t\t\tSELECT user_id\n\t\t\tFROM users\n\t\t\tWHERE lower(user_name) = lower($1)\n\t\t)\n\t\tSELECT commit_list as commits\n\t\tFROM sqlite_databases AS db, u\n\t\tWHERE db.user_id = u.user_id\n\t\t\tAND db.folder = $2\n\t\t\tAND db.db_name = $3\n\t\t\tAND db.is_deleted = false`\n\tvar l map[string]CommitEntry\n\terr := pdb.QueryRow(dbQuery, dbOwner, dbFolder, dbName).Scan(&l)\n\tif err != nil {\n\t\tlog.Printf(\"Retrieving commit list for '%s%s%s' failed: %v\\n\", dbOwner, dbFolder, dbName, err)\n\t\treturn map[string]CommitEntry{}, err\n\t}\n\treturn l, nil\n}", "func (r *PullsListCommitsReq) HTTPRequest(ctx context.Context, opt ...RequestOption) (*http.Request, error) {\n\treturn buildHTTPRequest(ctx, r, opt)\n}", "func (c *Client) BuildListRequest(ctx context.Context, v interface{}) (*http.Request, error) {\n\tu := &url.URL{Scheme: c.scheme, Host: c.host, Path: ListLogPath()}\n\treq, err := http.NewRequest(\"POST\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, goahttp.ErrInvalidURL(\"log\", \"list\", u.String(), err)\n\t}\n\tif ctx != nil {\n\t\treq = req.WithContext(ctx)\n\t}\n\n\treturn req, nil\n}", "func (r *ScheduleTimeOffRequestsCollectionRequest) Get(ctx context.Context) ([]TimeOffRequestObject, error) {\n\treturn r.GetN(ctx, 0)\n}", "func (client IdentityClient) ListIamWorkRequests(ctx context.Context, request ListIamWorkRequestsRequest) (response ListIamWorkRequestsResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.listIamWorkRequests, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = ListIamWorkRequestsResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = ListIamWorkRequestsResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(ListIamWorkRequestsResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into ListIamWorkRequestsResponse\")\n\t}\n\treturn\n}", "func (*ListProvisioningApprovalRequestsRequest) Descriptor() ([]byte, []int) {\n\treturn edgelq_devices_proto_v1alpha_provisioning_approval_request_service_proto_rawDescGZIP(), []int{3}\n}", "func (client *ManagedClustersClient) listCreateRequest(ctx context.Context, options *ManagedClustersClientListOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.ContainerService/managedClusters\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *CertificateOrdersClient) listCreateRequest(ctx context.Context, options *CertificateOrdersClientListOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.CertificateRegistration/certificateOrders\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-09-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (c *ExplorerController) GetCrossTxList() {\n\t// get parameter\n\tvar crossTxListReq model.CrossTxListReq\n\tvar err error\n\tif err = json.Unmarshal(c.Ctx.Input.RequestBody, &crossTxListReq); err != nil {\n\t\tc.Data[\"json\"] = model.MakeErrorRsp(fmt.Sprintf(\"request parameter is invalid!\"))\n\t\tc.Ctx.ResponseWriter.WriteHeader(400)\n\t\tc.ServeJSON()\n\t}\n\n\tsrcPolyDstRelations := make([]*model.SrcPolyDstRelation, 0)\n\tdb.Model(&model.PolyTransaction{}).\n\t\tSelect(\"src_transactions.hash as src_hash, poly_transactions.hash as poly_hash, dst_transactions.hash as dst_hash\").\n\t\tWhere(\"src_transactions.standard = ?\", 0).\n\t\tJoins(\"left join src_transactions on src_transactions.hash = poly_transactions.src_hash\").\n\t\tJoins(\"left join dst_transactions on poly_transactions.hash = dst_transactions.poly_hash\").\n\t\tPreload(\"SrcTransaction\").\n\t\tPreload(\"SrcTransaction.SrcTransfer\").\n\t\tPreload(\"PolyTransaction\").\n\t\tPreload(\"DstTransaction\").\n\t\tPreload(\"DstTransaction.DstTransfer\").\n\t\tLimit(crossTxListReq.PageSize).Offset(crossTxListReq.PageSize * crossTxListReq.PageNo).\n\t\tFind(&srcPolyDstRelations)\n\n\tvar transactionNum int64\n\tdb.Model(&model.PolyTransaction{}).Where(\"src_transactions.standard = ?\", 0).\n\t\tJoins(\"left join src_transactions on src_transactions.hash = poly_transactions.src_hash\").Count(&transactionNum)\n\n\tc.Data[\"json\"] = model.MakeCrossTxListResp(srcPolyDstRelations)\n\tc.ServeJSON()\n}", "func (o *FiltersApiLog) GetRequestIds() []string {\n\tif o == nil || o.RequestIds == nil {\n\t\tvar ret []string\n\t\treturn ret\n\t}\n\treturn *o.RequestIds\n}", "func (c *Client) NewListAssignedResourceRolesRequest(ctx context.Context, path string) (*http.Request, error) {\n\tscheme := c.Scheme\n\tif scheme == \"\" {\n\t\tscheme = \"http\"\n\t}\n\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif c.JWTSigner != nil {\n\t\tc.JWTSigner.Sign(req)\n\t}\n\treturn req, nil\n}", "func (o *CommitteeInfoResponse) GetCommitteeNodes() []CommitteeNode {\n\tif o == nil {\n\t\tvar ret []CommitteeNode\n\t\treturn ret\n\t}\n\n\treturn o.CommitteeNodes\n}", "func NewListEventsRequest(server string, params *ListEventsParams) (*http.Request, error) {\n\tvar err error\n\n\tqueryUrl, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbasePath := fmt.Sprintf(\"/event\")\n\tif basePath[0] == '/' {\n\t\tbasePath = basePath[1:]\n\t}\n\n\tqueryUrl, err = queryUrl.Parse(basePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tqueryValues := queryUrl.Query()\n\n\tif params.From != nil {\n\n\t\tif queryFrag, err := runtime.StyleParam(\"form\", true, \"from\", *params.From); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif params.To != nil {\n\n\t\tif queryFrag, err := runtime.StyleParam(\"form\", true, \"to\", *params.To); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tqueryUrl.RawQuery = queryValues.Encode()\n\n\treq, err := http.NewRequest(\"GET\", queryUrl.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "func (c *Client) ListQualificationRequests(ctx context.Context, params *ListQualificationRequestsInput, optFns ...func(*Options)) (*ListQualificationRequestsOutput, error) {\n\tif params == nil {\n\t\tparams = &ListQualificationRequestsInput{}\n\t}\n\n\tresult, metadata, err := c.invokeOperation(ctx, \"ListQualificationRequests\", params, optFns, addOperationListQualificationRequestsMiddlewares)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tout := result.(*ListQualificationRequestsOutput)\n\tout.ResultMetadata = metadata\n\treturn out, nil\n}", "func (c *Client) NewListRolesRequest(ctx context.Context, path string, resourceType *string) (*http.Request, error) {\n\tscheme := c.Scheme\n\tif scheme == \"\" {\n\t\tscheme = \"http\"\n\t}\n\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\n\tvalues := u.Query()\n\tif resourceType != nil {\n\t\tvalues.Set(\"resource_type\", *resourceType)\n\t}\n\tu.RawQuery = values.Encode()\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif c.JWTSigner != nil {\n\t\tc.JWTSigner.Sign(req)\n\t}\n\treturn req, nil\n}", "func (n *QriNode) RequestPeersList(id peer.ID) {\n\tres, err := n.SendMessage(id, &Message{\n\t\tType: MtPeers,\n\t\tPayload: &PeersReqParams{\n\t\t\tOffset: 0,\n\t\t\tLimit: 10,\n\t\t},\n\t})\n\n\tif err != nil {\n\t\tfmt.Println(\"send peers message error:\", err.Error())\n\t\treturn\n\t}\n\n\tif res.Phase == MpResponse {\n\t\tif err := n.handlePeersResponse(res); err != nil {\n\t\t\tfmt.Println(\"peers response error\", err.Error())\n\t\t\treturn\n\t\t}\n\t}\n}", "func (c *NATSTestClient) GetParallelRequests(t *testing.T, n int) ParallelRequests {\n\tpr := make(ParallelRequests, n)\n\tfor i := 0; i < n; i++ {\n\t\tpr[i] = c.GetRequest(t)\n\t}\n\treturn pr\n}", "func (client IdentityClient) listCompartments(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/compartments\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response ListCompartmentsResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (ct *CountingTransport) Requests() []*http.Request {\n\treturn ct.reqs\n}", "func (c *Client) BuildListRequest(ctx context.Context, v interface{}) (*http.Request, error) {\n\tu := &url.URL{Scheme: c.scheme, Host: c.host, Path: ListRecorderPath()}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, goahttp.ErrInvalidURL(\"recorder\", \"list\", u.String(), err)\n\t}\n\tif ctx != nil {\n\t\treq = req.WithContext(ctx)\n\t}\n\n\treturn req, nil\n}", "func (_IOrakuruCore *IOrakuruCoreCaller) GetPendingRequests(opts *bind.CallOpts) ([][32]byte, error) {\n\tvar out []interface{}\n\terr := _IOrakuruCore.contract.Call(opts, &out, \"getPendingRequests\")\n\n\tif err != nil {\n\t\treturn *new([][32]byte), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new([][32]byte)).(*[][32]byte)\n\n\treturn out0, err\n\n}", "func (_Bridge *BridgeSession) GetInterchainRequests(b []byte) (string, error) {\n\treturn _Bridge.Contract.GetInterchainRequests(&_Bridge.CallOpts, b)\n}", "func (b *ScheduleRequestBuilder) OpenShiftChangeRequests() *ScheduleOpenShiftChangeRequestsCollectionRequestBuilder {\n\tbb := &ScheduleOpenShiftChangeRequestsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}\n\tbb.baseURL += \"/openShiftChangeRequests\"\n\treturn bb\n}", "func listSystemCountersRequest(c *xgb.Conn) []byte {\n\tsize := 4\n\tb := 0\n\tbuf := make([]byte, size)\n\n\tbuf[b] = c.Extensions[\"SYNC\"]\n\tb += 1\n\n\tbuf[b] = 1 // request opcode\n\tb += 1\n\n\txgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units\n\tb += 2\n\n\treturn buf\n}", "func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.RecoveryServices/operations\"\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (r *SynchronizationJobsCollectionRequest) Get(ctx context.Context) ([]SynchronizationJob, error) {\n\treturn r.GetN(ctx, 0)\n}", "func (ftm *FtmBridge) withdrawRequestsList(addr *common.Address, staker *big.Int) ([]*types.WithdrawRequest, error) {\n\t// we need to have the address to continue\n\tif addr == nil {\n\t\tftm.log.Error(\"can not pull withdraw requests for empty address\")\n\t\treturn nil, fmt.Errorf(\"withdraw requests address filter not defined\")\n\t}\n\n\t// prepare to interact with the SFC contract\n\tcontract, err := contracts.NewSfcContract(ftm.sfcConfig.SFCContract, ftm.eth)\n\tif err != nil {\n\t\tftm.log.Criticalf(\"failed to instantiate SFC contract: %v\", err)\n\t\treturn nil, err\n\t}\n\n\t// get a list of finalized requests\n\tfin, err := ftm.withdrawnByRequest(contract, *addr, staker)\n\tif err != nil {\n\t\tftm.log.Error(\"can not pull finalized withdraw requests; %s\", err.Error())\n\t\treturn nil, err\n\t}\n\n\t// get a list of requests\n\treturn ftm.createdWithdrawRequests(contract, *addr, staker, fin)\n}", "func (r *Review) ListCommits() ([]string, error) {\n\tbaseCommit, err := r.GetBaseCommit()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\theadCommit, err := r.GetHeadCommit()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn r.Repo.ListCommitsBetween(baseCommit, headCommit)\n}", "func (gc *GithubClient) ListPullRequests(org, repo, head, base string) ([]*github.PullRequest, error) {\n\tPRsListOptions := github.PullRequestListOptions{\n\t\tState: string(PullRequestAllState),\n\t\tHead: head,\n\t\tBase: base,\n\t}\n\n\tgenericList, err := gc.depaginate(\n\t\tfmt.Sprintf(\"listing Pull Requests with head '%s' and base '%s'\", head, base),\n\t\tmaxRetryCount,\n\t\t&PRsListOptions.ListOptions,\n\t\tfunc() ([]interface{}, *github.Response, error) {\n\t\t\tpage, resp, err := gc.Client.PullRequests.List(ctx, org, repo, &PRsListOptions)\n\t\t\tvar interfaceList []interface{}\n\t\t\tif nil == err {\n\t\t\t\tfor _, PR := range page {\n\t\t\t\t\tinterfaceList = append(interfaceList, PR)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn interfaceList, resp, err\n\t\t},\n\t)\n\tres := make([]*github.PullRequest, len(genericList))\n\tfor i, elem := range genericList {\n\t\tres[i] = elem.(*github.PullRequest)\n\t}\n\treturn res, err\n}", "func (_IOrakuruCore *IOrakuruCoreSession) GetPendingRequests() ([][32]byte, error) {\n\treturn _IOrakuruCore.Contract.GetPendingRequests(&_IOrakuruCore.CallOpts)\n}", "func (client IdentityClient) ListIamWorkRequestLogs(ctx context.Context, request ListIamWorkRequestLogsRequest) (response ListIamWorkRequestLogsResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.listIamWorkRequestLogs, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = ListIamWorkRequestLogsResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = ListIamWorkRequestLogsResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(ListIamWorkRequestLogsResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into ListIamWorkRequestLogsResponse\")\n\t}\n\treturn\n}", "func (b *ApprovalWorkflowProviderRequestsCollectionRequestBuilder) Request() *ApprovalWorkflowProviderRequestsCollectionRequest {\n\treturn &ApprovalWorkflowProviderRequestsCollectionRequest{\n\t\tBaseRequest: BaseRequest{baseURL: b.baseURL, client: b.client},\n\t}\n}", "func (r *RequestAPI) ListRequestV1(ctx context.Context, req *desc.ListRequestsV1Request) (*desc.ListRequestsV1Response, error) {\n\tlog.Printf(\"Got list request: %v\", req)\n\tspan, ctx := opentracing.StartSpanFromContext(ctx, \"ListRequestV1\")\n\tdefer span.Finish()\n\n\tif err := r.validateAndSendErrorEvent(ctx, req, producer.ReadEvent); err != nil {\n\t\treturn nil, err\n\t}\n\tvar (\n\t\trequests []models.Request\n\t\terr error\n\t)\n\n\tif req.SearchQuery != \"\" { // ideally would move search to a separate endpoint, so it's easier to extend\n\t\trequests, err = r.searcher.Search(ctx, req.SearchQuery, req.Limit, req.Offset)\n\t} else {\n\t\trequests, err = r.repo.List(ctx, req.Limit, req.Offset)\n\t}\n\n\tif err != nil {\n\t\tlog.Error().\n\t\t\tErr(err).\n\t\t\tStr(\"endpoint\", \"ListRequestV1\").\n\t\t\tUint64(\"limit\", req.Limit).\n\t\t\tUint64(\"offset\", req.Offset).\n\t\t\tMsgf(\"Failed to list requests\")\n\t\tr.producer.Send(producer.NewEvent(ctx, 0, producer.ReadEvent, err))\n\t\treturn nil, err\n\t}\n\n\tret := make([]*desc.Request, 0, len(requests))\n\teventMsgs := make([]producer.EventMsg, 0, len(requests))\n\n\tfor _, req := range requests {\n\t\tret = append(ret, &desc.Request{\n\t\t\tId: req.Id,\n\t\t\tUserId: req.UserId,\n\t\t\tType: req.Type,\n\t\t\tText: req.Text,\n\t\t})\n\t\teventMsgs = append(eventMsgs, producer.NewEvent(ctx, req.Id, producer.ReadEvent, nil))\n\t\tr.producer.Send(eventMsgs...)\n\n\t}\n\tr.metrics.IncList(1, \"ListRequestV1\")\n\treturn &desc.ListRequestsV1Response{\n\t\tRequests: ret,\n\t}, nil\n}", "func (s *Service) GetRequest(identifiable DocIdentifiable) (*json.RawMessage, error) {\n\t// TODO: accept ctx as param\n\tget, err := s.Client.Get().\n\t\tIndex(s.RequestsIndex).\n\t\tType(\"_doc\").\n\t\tId(identifiable.DocID()).\n\t\tDo(context.TODO())\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn get.Source, nil\n}", "func (_IOrakuruCore *IOrakuruCoreCallerSession) GetPendingRequests() ([][32]byte, error) {\n\treturn _IOrakuruCore.Contract.GetPendingRequests(&_IOrakuruCore.CallOpts)\n}", "func (*ListCommitBlobsRequest) Descriptor() ([]byte, []int) {\n\treturn file_modeldb_versioning_VersioningService_proto_rawDescGZIP(), []int{20}\n}", "func (c *Client) BuildListRequest(ctx context.Context, v interface{}) (*http.Request, error) {\n\tu := &url.URL{Scheme: c.scheme, Host: c.host, Path: ListRecipePath()}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, goahttp.ErrInvalidURL(\"recipe\", \"list\", u.String(), err)\n\t}\n\tif ctx != nil {\n\t\treq = req.WithContext(ctx)\n\t}\n\n\treturn req, nil\n}", "func (client *AvailabilitySetsClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *AvailabilitySetsListOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (*CUserAccount_GetFriendInviteTokens_Request) Descriptor() ([]byte, []int) {\n\treturn file_steammessages_useraccount_steamclient_proto_rawDescGZIP(), []int{8}\n}", "func (_Bridge *BridgeCallerSession) GetInterchainRequests(b []byte) (string, error) {\n\treturn _Bridge.Contract.GetInterchainRequests(&_Bridge.CallOpts, b)\n}", "func (g *V3) ListPullRequests(repo, state string) ([]scm.PullRequest, error) {\n\t// GitLab mr state: opened, closed, locked, merged, all\n\tvar s string\n\tswitch state {\n\tcase scm.PullRequestStateOpen:\n\t\ts = openedPullRequestState\n\tcase openedPullRequestState, \"closed\", \"locked\", \"merged\", \"all\":\n\t\ts = state\n\tdefault:\n\t\treturn nil, cerr.ErrorUnsupported.Error(\"GitLab(v3) pull request state\", state)\n\t}\n\n\topts := &v3.ListMergeRequestsOptions{\n\t\tState: &s,\n\t\tListOptions: v3.ListOptions{\n\t\t\tPerPage: scm.ListOptPerPage,\n\t\t},\n\t}\n\n\tvar allPRs []scm.PullRequest\n\tfor {\n\t\tprs, resp, err := g.client.MergeRequests.ListMergeRequests(repo, opts)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Fail to list merge requests for %s\", repo)\n\t\t\treturn nil, convertGitlabError(err, resp)\n\t\t}\n\n\t\tfor _, p := range prs {\n\t\t\tallPRs = append(allPRs, scm.PullRequest{\n\t\t\t\tID: p.IID,\n\t\t\t\tTitle: p.Title,\n\t\t\t\tDescription: p.Description,\n\t\t\t\tState: p.State,\n\t\t\t\tTargetBranch: p.TargetBranch,\n\t\t\t})\n\t\t}\n\t\tif resp.NextPage == 0 {\n\t\t\tbreak\n\t\t}\n\t\topts.Page = resp.NextPage\n\t}\n\n\treturn allPRs, nil\n}", "func (gc *GithubClient) ListCommits(org, repo string, ID int) ([]*github.RepositoryCommit, error) {\n\toptions := &github.ListOptions{}\n\tgenericList, err := gc.depaginate(\n\t\tfmt.Sprintf(\"listing commits in Pull Requests '%d'\", ID),\n\t\tmaxRetryCount,\n\t\toptions,\n\t\tfunc() ([]interface{}, *github.Response, error) {\n\t\t\tpage, resp, err := gc.Client.PullRequests.ListCommits(ctx, org, repo, ID, options)\n\t\t\tvar interfaceList []interface{}\n\t\t\tif nil == err {\n\t\t\t\tfor _, commit := range page {\n\t\t\t\t\tinterfaceList = append(interfaceList, commit)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn interfaceList, resp, err\n\t\t},\n\t)\n\tres := make([]*github.RepositoryCommit, len(genericList))\n\tfor i, elem := range genericList {\n\t\tres[i] = elem.(*github.RepositoryCommit)\n\t}\n\treturn res, err\n}", "func bulkRequest(list *AddressList) ([]byte, error) {\n\n\t// The max limit by WOC\n\tif len(list.Addresses) > MaxAddressesForLookup {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"max limit of addresses is %d and you sent %d\",\n\t\t\tMaxAddressesForLookup, len(list.Addresses),\n\t\t)\n\t}\n\n\t// Convert to JSON\n\treturn json.Marshal(list)\n}", "func (client *ApplyUpdatesClient) listCreateRequest(ctx context.Context, options *ApplyUpdatesClientListOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/applyUpdates\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (*ListCommitsRequest) Descriptor() ([]byte, []int) {\n\treturn file_modeldb_versioning_VersioningService_proto_rawDescGZIP(), []int{16}\n}", "func (g *Gitlab) ListProjectMergeRequests(projectID int, since, until *time.Time, page int) (mrs []*gitlab.MergeRequest, resp *gitlab.Response, err error) {\n\n\topt := &gitlab.ListProjectMergeRequestsOptions{}\n\topt.UpdatedAfter = since\n\topt.UpdatedBefore = until\n\tif page != -1 {\n\t\topt.PerPage = _defaultPerPage\n\t\topt.Page = page\n\t}\n\tif mrs, resp, err = g.client.MergeRequests.ListProjectMergeRequests(projectID, opt); err != nil {\n\t\terr = errors.Wrapf(err, \"ListProjectMergeRequests projectId(%d), err(%+v)\", projectID, err)\n\t\treturn\n\t}\n\treturn\n}" ]
[ "0.6726568", "0.60950726", "0.586521", "0.58409595", "0.58262", "0.5651529", "0.56400454", "0.5546509", "0.54614383", "0.54555523", "0.54187846", "0.5413614", "0.53488183", "0.5328241", "0.5320421", "0.5247767", "0.5227244", "0.5193367", "0.51814556", "0.51613", "0.51548237", "0.51507753", "0.51348835", "0.5126457", "0.51058555", "0.509366", "0.5088158", "0.5072668", "0.50578666", "0.5048555", "0.50237244", "0.50199956", "0.500786", "0.49749464", "0.4959912", "0.49524903", "0.49359754", "0.49349767", "0.4919758", "0.49015194", "0.48813763", "0.4839936", "0.4808469", "0.47891715", "0.4781909", "0.47586235", "0.47582963", "0.47325847", "0.47300786", "0.47212115", "0.47207266", "0.47185096", "0.4704169", "0.4701519", "0.46858352", "0.4675497", "0.46747357", "0.466636", "0.46658716", "0.4663552", "0.46478435", "0.46357915", "0.46329263", "0.462789", "0.46251485", "0.4623658", "0.46215618", "0.46156025", "0.46155426", "0.46107525", "0.46105766", "0.46092197", "0.46072093", "0.46058565", "0.46044436", "0.45984003", "0.45898333", "0.45867363", "0.4584807", "0.45826778", "0.45779404", "0.45722905", "0.457129", "0.45701164", "0.4569999", "0.4564677", "0.4564492", "0.45619726", "0.45614997", "0.45565656", "0.4556313", "0.4553868", "0.4544514", "0.4538372", "0.45381796", "0.45379522", "0.4533261", "0.45302185", "0.45301524", "0.4529612" ]
0.8405216
0
TODO GetNewAddress does map to `getnewaddress` rpc call now rpcclient doesn't have such golang wrapper func.
TODO GetNewAddress теперь отображает вызов rpc getnewaddress, но rpcclient не имеет такой функции обертки на golang.
func (client *BtcClient) GetNewAddress(account string) (string, error) { if len(account) == 0 { account = DEFAULT_ACCOUNT } address, err := client.rpcClient.GetNewAddress(account) if err != nil { return "", err } return address.String(), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (b *Bitcoind) GetNewAddress(account ...string) (addr string, err error) {\n\t// 0 or 1 account\n\tif len(account) > 1 {\n\t\terr = errors.New(\"Bad parameters for GetNewAddress: you can set 0 or 1 account\")\n\t\treturn\n\t}\n\n\tr, err := b.client.call(\"getnewaddress\", account)\n\tif err = handleError(err, &r); err != nil {\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(r.Result, &addr)\n\treturn\n}", "func (i *Instance) GetNewAddress(_ trinary.Trytes, _ api.GetNewAddressOptions) (trinary.Hashes, error) {\n\treturn i.addressResultValue, i.addressResultError\n}", "func (serv *ExchangeServer) GetNewAddress(cp string) string {\n\tserv.wltMtx.Lock()\n\tdefer serv.wltMtx.Unlock()\n\taddrEntry, err := serv.wallets.NewAddresses(cp, 1)\n\tif err != nil {\n\t\tpanic(\"server get new address failed\")\n\t}\n\treturn addrEntry[0].Address\n}", "func (lu *litUiClient) NewAddress() (string, error) {\n\n\t// cointype of 0 means default, not mainnet.\n\t// this is ugly but does prevent mainnet use for now.\n\n\tvar cointype, numadrs uint32\n\n\t// if no arguments given, generate 1 new address.\n\t// if no cointype given, assume type 1 (testnet)\n\n\tnumadrs = 1\n\n\treply := new(litrpc.AddressReply)\n\n\targs := new(litrpc.AddressArgs)\n\targs.CoinType = cointype\n\targs.NumToMake = numadrs\n\n\tfmt.Printf(\"adr cointye: %d num:%d\\n\", args.CoinType, args.NumToMake)\n\terr := lu.rpccon.Call(\"LitRPC.Address\", args, reply)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tresponse := reply.WitAddresses[0]\n\t//\tfmt.Fprintf(color.Output, \"new adr(s): %s\\nold: %s\\n\",\n\t//\t\tlnutil.Address(reply.WitAddresses), lnutil.Address(reply.LegacyAddresses))\n\treturn response, nil // reply.WitAddresses[]\n\n}", "func (p *Poloniex) GenerateNewAddress(ctx context.Context, curr string) (string, error) {\n\ttype Response struct {\n\t\tSuccess int\n\t\tError string\n\t\tResponse string\n\t}\n\tresp := Response{}\n\tvalues := url.Values{}\n\tvalues.Set(\"currency\", curr)\n\n\terr := p.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost, poloniexGenerateNewAddress, values, &resp)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif resp.Error != \"\" {\n\t\treturn \"\", errors.New(resp.Error)\n\t}\n\n\treturn resp.Response, nil\n}", "func (c *Client) GetNewAddressT(account string) (string, error) {\n\treturn c.GetNewAddressAsync(account).ReceiveT()\n}", "func (h *HitBTC) GenerateNewAddress(ctx context.Context, currency string) (DepositCryptoAddresses, error) {\n\tresp := DepositCryptoAddresses{}\n\terr := h.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodPost,\n\t\tapiV2CryptoAddress+\"/\"+currency,\n\t\turl.Values{},\n\t\totherRequests,\n\t\t&resp)\n\n\treturn resp, err\n}", "func (c *Client) GetNewAddressAndKey() (string, string, error) {\n\treturn c.GetNewAddressAndKeyAsync().Receive()\n}", "func (c *Constructor) newAddress(ctx context.Context) (string, error) {\n\tkp, err := keys.GenerateKeypair(c.curveType)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w unable to generate keypair\", err)\n\t}\n\n\taddress, _, err := c.helper.Derive(\n\t\tctx,\n\t\tc.network,\n\t\tkp.PublicKey,\n\t\tnil,\n\t)\n\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w: unable to derive address\", err)\n\t}\n\n\terr = c.helper.StoreKey(ctx, address, kp)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w: unable to store address\", err)\n\t}\n\n\tif err := c.handler.AddressCreated(ctx, address); err != nil {\n\t\treturn \"\", fmt.Errorf(\"%w: could not handle address creation\", err)\n\t}\n\n\treturn address, nil\n}", "func NewAddresser() Addresser { return &addresser{execute: rtnlExecute} }", "func (dcr *ExchangeWallet) NewAddress() (string, error) {\n\treturn dcr.DepositAddress()\n}", "func (f *FFS) NewAddr(ctx context.Context, name string, options ...NewAddressOption) (string, error) {\n\tr := &rpc.NewAddrRequest{Name: name}\n\tfor _, opt := range options {\n\t\topt(r)\n\t}\n\tresp, err := f.client.NewAddr(ctx, r)\n\treturn resp.Addr, err\n}", "func (walletAPI *WalletAPI) WalletNewAddress(protocol address.Protocol) (address.Address, error) {\n\treturn wallet.NewAddress(walletAPI.wallet.Wallet, protocol)\n}", "func newPeerAddr(ip net.IP, curTime time.Time) *peerAddr {\n\n\t// Create the new peer address.\n\tp := &peerAddr{\n\t\tip: ip,\n\t\tlastPing: ring.New(6),\n\t}\n\n\t// Record the current ping.\n\tp.lastPing.Value = curTime\n\n\treturn p\n}", "func NewAddress(street string) *Address {\n // Just return a dummy for STUB\n return &Address{}\n}", "func CreateAddress() *addresspb.Address {\n\ta := addresspb.Address{\n\t\tCorrespondanceAddr: &addresspb.Location{\n\t\t\tLocation: \"loc 1\",\n\t\t\tCity: &addresspb.City{\n\t\t\t\tName: \"Mumbai\",\n\t\t\t\tZipCode: \"400005\",\n\t\t\t\tRegion: addresspb.Division_WEST,\n\t\t\t},\n\t\t},\n\n\t\tAdditionalAddr: []*addresspb.Location{\n\t\t\t{\n\t\t\t\tLocation: \"loc 2\",\n\t\t\t\tCity: &addresspb.City{\n\t\t\t\t\tName: \"Srinagar\",\n\t\t\t\t\tZipCode: \"190001\",\n\t\t\t\t\tRegion: addresspb.Division_NORTH,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tLocation: \"loc 3\",\n\t\t\t\tCity: &addresspb.City{\n\t\t\t\t\tName: \"Imphal\",\n\t\t\t\t\tZipCode: \"795001\",\n\t\t\t\t\tRegion: addresspb.Division_EAST,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tLocation: \"loc 4\",\n\t\t\t\tCity: &addresspb.City{\n\t\t\t\t\tName: \"Mysore\",\n\t\t\t\t\tZipCode: \"570001\",\n\t\t\t\t\tRegion: addresspb.Division_SOUTH,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\treturn &a\n}", "func (eth *Eth) NewAddress(set bool) string {\n\tnewpair := crypto.GenerateNewKeyPair()\n\taddr := ethutil.Bytes2Hex(newpair.Address())\n\tring := eth.keyManager.KeyRing()\n\tring.AddKeyPair(newpair)\n\tif set {\n\t\teth.SetAddressN(ring.Len() - 1)\n\t}\n\treturn addr\n}", "func (b *Backend) NewAddress() wallet.Address {\n\taddr := Address{}\n\treturn &addr\n}", "func (wallet *Wallet) NewReceiveAddress() address.Address {\n\treturn wallet.addressManager.NewAddress()\n}", "func newNetAddress(addr net.Addr, services wire.ServiceFlag) (*wire.NetAddress, error) {\n\t// addr will be a net.TCPAddr when not using a proxy.\n\tif tcpAddr, ok := addr.(*net.TCPAddr); ok {\n\t\tip := tcpAddr.IP\n\t\tport := uint16(tcpAddr.Port)\n\t\tna := wire.NewNetAddressIPPort(ip, port, services)\n\t\treturn na, nil\n\t}\n\n\t// addr will be a socks.ProxiedAddr when using a proxy.\n\tif proxiedAddr, ok := addr.(*socks.ProxiedAddr); ok {\n\t\tip := net.ParseIP(proxiedAddr.Host)\n\t\tif ip == nil {\n\t\t\tip = net.ParseIP(\"0.0.0.0\")\n\t\t}\n\t\tport := uint16(proxiedAddr.Port)\n\t\tna := wire.NewNetAddressIPPort(ip, port, services)\n\t\treturn na, nil\n\t}\n\n\t// For the most part, addr should be one of the two above cases, but\n\t// to be safe, fall back to trying to parse the information from the\n\t// address string as a last resort.\n\thost, portStr, err := net.SplitHostPort(addr.String())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tip := net.ParseIP(host)\n\tport, err := strconv.ParseUint(portStr, 10, 16)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tna := wire.NewNetAddressIPPort(ip, uint16(port), services)\n\treturn na, nil\n}", "func (addressManager *AddressManager) NewAddress() address.Address {\n\treturn addressManager.Address(addressManager.lastAddressIndex + 1)\n}", "func (mc *MoacChain) createChainAddress(tradePassword string) (addr string, err error) {\n\n\tdefer func() {\n\t\tif re := recover(); re != nil {\n\t\t\terr = re.(error)\n\t\t}\n\t}()\n\n\terr = rpcClient.Call(&addr, \"personal_newAccount\", tradePassword)\n\n\treturn addr, err\n}", "func (a *Account) NewAddress() (btcutil.Address, error) {\n\t// Get current block's height and hash.\n\trpcc, err := accessClient()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbs, err := rpcc.BlockStamp()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Get next address from wallet.\n\taddr, err := a.KeyStore.NextChainedAddress(&bs, cfg.KeypoolSize)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Immediately write updated wallet to disk.\n\tAcctMgr.ds.ScheduleWalletWrite(a)\n\tif err := AcctMgr.ds.FlushAccount(a); err != nil {\n\t\treturn nil, fmt.Errorf(\"account write failed: %v\", err)\n\t}\n\n\t// Mark this new address as belonging to this account.\n\tAcctMgr.MarkAddressForAccount(addr, a)\n\n\t// Request updates from btcd for new transactions sent to this address.\n\tif err := rpcc.NotifyReceived([]btcutil.Address{addr}); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn addr, nil\n}", "func TestGenerateAddress(t *testing.T) {\n\tif _, err := GenerateAddress(); err != nil {\n\t\tt.Fatalf(\"Failed to generate new address: %v\", err)\n\t}\n}", "func (h *Harness) NewAddress() (btcaddr.Address, error) {\n\treturn h.wallet.NewAddress()\n}", "func (lu *litUiClient) Address() (string, error) {\n\n\t// cointype of 0 means default, not mainnet.\n\t// this is ugly but does prevent mainnet use for now.\n\n\tvar cointype, numadrs uint32\n\n\t// if no arguments given, generate 1 new address.\n\t// if no cointype given, assume type 1 (testnet)\n\n\tnumadrs = 0\n\n\treply := new(litrpc.AddressReply)\n\n\targs := new(litrpc.AddressArgs)\n\targs.CoinType = cointype\n\targs.NumToMake = numadrs\n\n\tfmt.Printf(\"adr cointye: %d num:%d\\n\", args.CoinType, args.NumToMake)\n\terr := lu.rpccon.Call(\"LitRPC.Address\", args, reply)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tresponse := reply.WitAddresses[len(reply.WitAddresses)-1]\n\treturn response, nil\n}", "func (t *SimpleChaincode) modifyAddress(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tvar dni, address string // Entities\n\tvar err error\n\n\tif len(args) != 2 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 3\")\n\t}\n\n\tdni = args[0]\n\taddress = args[1]\n\n\tvar personObject Person;\n\tpersonStored, err := stub.GetState(dni)\n\tif err != nil {\n\t\treturn shim.Error(\"Failed to get state\")\n\t}\n\terr = json.Unmarshal(personStored, &personObject)\n\t\n\tfmt.Println(\"Modifying person DNI \" + dni + \" with Name \" + personObject.Name)\n\tpersonObject.Address = address\n\n\tdata, err := json.Marshal(personObject)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\terr = stub.PutState(dni, data)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\n\treturn shim.Success(nil)\n}", "func (m *MockFullNode) WalletNewAddress(arg0 context.Context, arg1 byte) (address.Address, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"WalletNewAddress\", arg0, arg1)\n\tret0, _ := ret[0].(address.Address)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func newClient(address string) (c *client, err error) {\n\tif address, err = Host(address); err != nil {\n\t\treturn\n\t}\n\tc = new(client)\n\tif c.client, err = rpc.Dial(\"tcp\", address); err != nil {\n\t\treturn nil, err\n\t}\n\tc.address = address\n\treturn\n}", "func (a *Account) NewAddress() (btcutil.Address, error) {\n\t// Get current block's height and hash.\n\tbs, err := GetCurBlock()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Get next address from wallet.\n\taddr, err := a.Wallet.NextChainedAddress(&bs, cfg.KeypoolSize)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Immediately write updated wallet to disk.\n\tAcctMgr.ds.ScheduleWalletWrite(a)\n\tif err := AcctMgr.ds.FlushAccount(a); err != nil {\n\t\treturn nil, fmt.Errorf(\"account write failed: %v\", err)\n\t}\n\n\t// Mark this new address as belonging to this account.\n\tAcctMgr.MarkAddressForAccount(addr, a)\n\n\t// Request updates from btcd for new transactions sent to this address.\n\ta.ReqNewTxsForAddress(addr)\n\n\treturn addr, nil\n}", "func NewAddr(address, network string) net.Addr {\n\treturn &addr{address: address, network: network}\n}", "func NewAddr(address, network string) net.Addr {\n\treturn &addr{address: address, network: network}\n}", "func (a *addrBook) GetAddress() *KnownAddress {\n\t// Protect concurrent access.\n\ta.mtx.Lock()\n\tdefer a.mtx.Unlock()\n\n\tif a.numAddresses() == 0 {\n\t\treturn nil\n\t}\n\n\t// Use a 50% chance for choosing between tried and new table entries.\n\tif a.nTried > 0 && (a.nNew == 0 || a.rand.Intn(2) == 0) {\n\t\t// Tried entry.\n\t\tlarge := 1 << 30\n\t\tfactor := 1.0\n\t\tfor {\n\t\t\t// pick a random bucket.\n\t\t\tbucket := a.rand.Intn(len(a.addrTried))\n\t\t\tif len(a.addrTried[bucket]) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Pick a random entry in it\n\t\t\tvar ka *KnownAddress\n\t\t\tnth := a.rand.Intn(len(a.addrTried[bucket]))\n\t\t\tfor _, value := range a.addrTried[bucket] {\n\t\t\t\tif nth == 0 {\n\t\t\t\t\tka = value\n\t\t\t\t}\n\t\t\t\tnth--\n\t\t\t}\n\n\t\t\trandval := a.rand.Intn(large)\n\t\t\tif float64(randval) < (factor * ka.chance() * float64(large)) {\n\t\t\t\ta.logger.Debug(\"Selected %v from tried bucket\", ka.na.String())\n\t\t\t\treturn ka\n\t\t\t}\n\t\t\tfactor *= 1.2\n\t\t}\n\t} else {\n\t\t// new node.\n\t\t// XXX use a closure/function to avoid repeating this.\n\t\tlarge := 1 << 30\n\t\tfactor := 1.0\n\t\tfor {\n\t\t\t// Pick a random bucket.\n\t\t\tbucket := a.rand.Intn(len(a.addrNew))\n\t\t\tif len(a.addrNew[bucket]) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Then, a random entry in it.\n\t\t\tvar ka *KnownAddress\n\t\t\tnth := a.rand.Intn(len(a.addrNew[bucket]))\n\t\t\tfor _, value := range a.addrNew[bucket] {\n\t\t\t\tif nth == 0 {\n\t\t\t\t\tka = value\n\t\t\t\t}\n\t\t\t\tnth--\n\t\t\t}\n\t\t\trandval := a.rand.Intn(large)\n\t\t\tif float64(randval) < (factor * ka.chance() * float64(large)) {\n\t\t\t\ta.logger.Debug(\"Selected %v from new bucket\", ka.na.String())\n\t\t\t\treturn ka\n\t\t\t}\n\t\t\tfactor *= 1.2\n\t\t}\n\t}\n}", "func (c *Client) GetNewAddressAndKeyAsync() FutureGetNewAddressAndKeyResult {\n\tcmd := tcoinjson.NewGetNewAddressAndKeyCmd()\n\treturn c.sendCmd(cmd)\n}", "func newAddress(pos int, address []string, value int) string {\n\tvar temp [4]int64\n\n\tfor i := 0; i < 4; i++ {\n\t\tnumber, _ := strconv.ParseInt(address[i], 2, 64)\n\t\ttemp[i] = number\n\t}\n\n\ttemp[pos] = int64(value)\n\n\treturn fmt.Sprint(temp[0], \".\", temp[1], \".\", temp[2], \".\", temp[3])\n}", "func WithMakeDefault(makeDefault bool) NewAddressOption {\n\treturn func(r *rpc.NewAddrRequest) {\n\t\tr.MakeDefault = makeDefault\n\t}\n}", "func newAddressMutation(c config, op Op, opts ...addressOption) *AddressMutation {\n\tm := &AddressMutation{\n\t\tconfig: c,\n\t\top: op,\n\t\ttyp: TypeAddress,\n\t\tclearedFields: make(map[string]struct{}),\n\t}\n\tfor _, opt := range opts {\n\t\topt(m)\n\t}\n\treturn m\n}", "func ResolveNewAddresses(ctx context.Context, dns *dnsclient.Client, data *ResolverData) map[string]*am.ScanGroupAddress {\n\tnewRecords := make(map[string]*am.ScanGroupAddress, 0)\n\n\tnumHosts := len(data.NewAddresses)\n\trps := data.RequestsPerSecond\n\tif numHosts < rps {\n\t\trps = numHosts\n\t}\n\tpool := workerpool.New(rps)\n\n\tout := make(chan *results, numHosts) // how many results we expect\n\n\ttask := func(ctx context.Context, host string, out chan<- *results) func() {\n\t\treturn func() {\n\t\t\tif ctx.Err() != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// check if our group has been paused/deleted prior to continuing.\n\t\t\tgroup, err := data.Cache.GetGroupByIDs(data.Address.OrgID, data.Address.GroupID)\n\t\t\tif err == nil {\n\t\t\t\tif group.Paused || group.Deleted {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlog.Ctx(ctx).Warn().Err(err).Msg(\"failed to get group from cache during resolve, continuing\")\n\t\t\t}\n\t\t\tr, err := dns.ResolveName(ctx, host)\n\t\t\tif err != nil {\n\t\t\t\tlog.Ctx(ctx).Error().Err(err).Msg(\"error\")\n\t\t\t}\n\t\t\tout <- &results{Hostname: host, R: r, Err: err}\n\t\t}\n\t}\n\n\t// submit all hosts to our worker pool\n\tfor newHost := range data.NewAddresses {\n\t\th := newHost\n\t\tpool.Submit(task(ctx, h, out))\n\t}\n\n\tpool.StopWait()\n\tclose(out)\n\n\tlog.Ctx(ctx).Info().Msg(\"all tasks completed\")\n\n\tfor result := range out {\n\t\tif result.Err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, rr := range result.R {\n\t\t\tfor _, ip := range rr.IPs {\n\t\t\t\tnewAddress := NewAddressFromDNS(data.Address, ip, result.Hostname, data.DiscoveryMethod, uint(rr.RecordType))\n\t\t\t\tif newAddress == nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tnewAddress.ConfidenceScore = CalculateConfidence(ctx, data.Address, newAddress)\n\t\t\t\tnewRecords[newAddress.AddressHash] = newAddress\n\t\t\t\t//log.Ctx(ctx).Info().Str(\"hostname\", result.Hostname).Str(\"ip_address\", ip).Str(\"newAddress.AddressHash\", newAddress.AddressHash).Str(\"hash\", convert.HashAddress(ip, result.Hostname)).Msg(\"found new record\")\n\t\t\t}\n\t\t}\n\t}\n\tlog.Ctx(ctx).Info().Int(\"record_count\", len(newRecords)).Msg(\"found new records\")\n\treturn newRecords\n}", "func RawChangeAddress(c *rpcd.Client, currency string) (diviutil.Address, error) {\n\tnetwork := RetrieveNetwork(currency)\n\n\tparams := []json.RawMessage{[]byte(`\"legacy\"`)}\n\trawResp, err := c.RawRequest(\"getrawchangeaddress\", params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar addrStr string\n\terr = json.Unmarshal(rawResp, &addrStr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\taddr, err := diviutil.DecodeAddress(addrStr, network)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !addr.IsForNet(network) {\n\t\treturn nil, fmt.Errorf(\"address %v is not intended for use on %v\", addrStr, network.Name)\n\t}\n\n\tif _, ok := addr.(*diviutil.AddressPubKeyHash); !ok {\n\t\treturn nil, fmt.Errorf(\"getrawchangeaddress: address %v is not P2PKH\", addr)\n\t}\n\n\treturn addr, nil\n}", "func (s IpNetwork_getRemoteHost_Params) NewAddress() (IpAddress, error) {\n\tss, err := NewIpAddress(s.Struct.Segment())\n\tif err != nil {\n\t\treturn IpAddress{}, err\n\t}\n\terr = s.Struct.SetPtr(0, ss.Struct.ToPtr())\n\treturn ss, err\n}", "func CreateQueryCustomerAddressListRequest() (request *QueryCustomerAddressListRequest) {\nrequest = &QueryCustomerAddressListRequest{\nRpcRequest: &requests.RpcRequest{},\n}\nrequest.InitWithApiInfo(\"BssOpenApi\", \"2017-12-14\", \"QueryCustomerAddressList\", \"\", \"\")\nreturn\n}", "func generateNewAccount() string {\n\taccount := crypto.GenerateAccount()\n\tpassphrase, err := mnemonic.FromPrivateKey(account.PrivateKey)\n\tif err != nil {\n\t\tfmt.Printf(\"Error creating new account: %s\\n\", err)\n\t} else {\n\t\tfmt.Printf(\"Created new account: %s\\n\", account.Address)\n\t\tfmt.Printf(\"Generated mnemonic: \\\"%s\\\"\\n\", passphrase)\n\t}\n\treturn account.Address.String()\n}", "func (r *RPCKeyRing) NewAddress(addrType lnwallet.AddressType, change bool,\n\taccount string) (btcutil.Address, error) {\n\n\tctxt, cancel := context.WithTimeout(context.Background(), r.rpcTimeout)\n\tdefer cancel()\n\n\trpcAddrType := walletrpc.AddressType_WITNESS_PUBKEY_HASH\n\tif addrType == lnwallet.NestedWitnessPubKey {\n\t\trpcAddrType = walletrpc.AddressType_NESTED_WITNESS_PUBKEY_HASH\n\t}\n\n\tremoteAddr, err := r.walletClient.NextAddr(ctxt, &walletrpc.AddrRequest{\n\t\tAccount: account,\n\t\tType: rpcAddrType,\n\t\tChange: change,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error deriving address on remote \"+\n\t\t\t\"signer instance: %v\", err)\n\t}\n\n\tlocalAddr, err := r.WalletController.NewAddress(\n\t\taddrType, change, account,\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error deriving address on local \"+\n\t\t\t\"wallet instance: %v\", err)\n\t}\n\n\t// We need to make sure we've derived the same address on the remote\n\t// signing machine, otherwise we don't know whether we're at the same\n\t// address index (and therefore the same wallet state in general).\n\tif localAddr.String() != remoteAddr.Addr {\n\t\treturn nil, fmt.Errorf(\"error deriving address on remote \"+\n\t\t\t\"signing instance, got different address (%s) than \"+\n\t\t\t\"on local wallet instance (%s)\", remoteAddr.Addr,\n\t\t\tlocalAddr.String())\n\t}\n\n\treturn localAddr, nil\n}", "func (a *Account) NewChangeAddress() (btcutil.Address, error) {\n\t// Get current block's height and hash.\n\trpcc, err := accessClient()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbs, err := rpcc.BlockStamp()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Get next chained change address from wallet.\n\taddr, err := a.KeyStore.ChangeAddress(&bs, cfg.KeypoolSize)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Immediately write updated wallet to disk.\n\tAcctMgr.ds.ScheduleWalletWrite(a)\n\tif err := AcctMgr.ds.FlushAccount(a); err != nil {\n\t\treturn nil, fmt.Errorf(\"account write failed: %v\", err)\n\t}\n\n\t// Mark this new address as belonging to this account.\n\tAcctMgr.MarkAddressForAccount(addr, a)\n\n\t// Request updates from btcd for new transactions sent to this address.\n\tif err := rpcc.NotifyReceived([]btcutil.Address{addr}); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn addr, nil\n}", "func NewAddress() platformservices.Address {\n\n\tvar lat = 37.7917146\n\tvar lng = -122.397054\n\n\treturn platformservices.Address{\n\t\tAddressType: platformservices.AddressTypeLegal,\n\t\tStreetAddress: \"100 Main Street\",\n\t\tCity: \"San Francisco\",\n\t\tState: \"CA\",\n\t\tCountry: \"US\",\n\t\tPostalCode: \"94100\",\n\t\tLatitude: &lat,\n\t\tLongitude: &lng,\n\t}\n}", "func CreateQueryCustomerAddressListResponse() (response *QueryCustomerAddressListResponse) {\nresponse = &QueryCustomerAddressListResponse{\nBaseResponse: &responses.BaseResponse{},\n}\nreturn\n}", "func (s *SkyСoinService) GenerateAddr(pubStr string) (maddr *AddressResponse, err error) {\n\tmaddr = &AddressResponse{}\n\n\tpubKey, err := cipher.PubKeyFromHex(pubStr)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\taddress := cipher.AddressFromPubKey(pubKey)\n\n\tmaddr.Address = address.String()\n\treturn maddr, nil\n}", "func main() {\n\tvar template string\n\tvar network string\n\tvar generate bool\n\tvar showVer bool\n\tflag.StringVar(&template, \"t\", \"\",\"template\")\n\tflag.StringVar(&network, \"n\",defaultNetwork ,\"network [mainnet|testnet|0.9testnet|mixnet|privnet]\")\n\tflag.BoolVar(&generate, \"new\", false, \"generate new address\")\n\tflag.BoolVar(&showVer, \"version\", false, \"show version\")\n\tflag.Parse()\n\tif showVer {\n\t\tversion();\n\t\tos.Exit(0);\n\t}\n\tp, err := getParams(network);\n\texitIfErr(err)\n\tif template == \"\" {\n\t\ttemplate = genTemplateByParams(p,network)\n\t}\n\taddr, err := getAddr(template,p,generate)\n\texitIfErr(err)\n\tfmt.Printf(\" network = %s \\n\", network)\n\tfmt.Printf(\"template = %s \\n\", template)\n\tfmt.Printf(\" addr = %v \\n\", string(addr));\n}", "func (a *Client) PostReturnAddressesGet(params *PostReturnAddressesGetParams, authInfo runtime.ClientAuthInfoWriter) (*PostReturnAddressesGetOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewPostReturnAddressesGetParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"PostReturnAddressesGet\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/post/return-addresses\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &PostReturnAddressesGetReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*PostReturnAddressesGetOK), nil\n\n}", "func makeAddress(keyPair *keypair.KeyPair, testnet bool) *account.Account {\n\n\treturn &account.Account{\n\t\tAccountInterface: &account.ED25519Account{\n\t\t\tTest: testnet,\n\t\t\tPublicKey: keyPair.PublicKey[:],\n\t\t},\n\t}\n}", "func (ns *NetworkServer) newDevAddr(context.Context, *ttnpb.EndDevice) types.DevAddr {\n\tvar devAddr types.DevAddr\n\trandom.Read(devAddr[:])\n\tprefix := ns.devAddrPrefixes[random.Intn(len(ns.devAddrPrefixes))]\n\treturn devAddr.WithPrefix(prefix)\n}", "func CreateAddress(address models.RequestAddress) (bool, models.ResponseAddress, error) {\n\n\t//Create request\n\trequest := models.Request{}\n\trequest.AddBody(address)\n\trequest.SetUri(\"https://api.easypost.com/v2/addresses\")\n\trequest.SetMethod(\"POST\")\n\n\t//Send request\n\tresponseBody, err := SendRequest(request)\n\n\t//Initialize response address\n\tresponseAddress := models.ResponseAddress{}\n\n\terr = json.Unmarshal(responseBody, &responseAddress)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false, responseAddress, fmt.Errorf(\"Unrecognized response from easypost %s\", err.Error())\n\t}\n\n\treturn responseAddress.Verifications.Delivery.Success, responseAddress, err\n}", "func NewAddress(path, addr string, net Network, change, addrIndex uint32) *Address {\n\treturn &Address{path: path, addr: addr, net: net, change: change, addrIndex: addrIndex}\n}", "func syncNewPeer(nodeMessage NodeMessage) NodeMessage {\n\tlog.Printf(\"Received new peer %v:%v\", nodeMessage.IpAddress, nodeMessage.Port)\n\tnewPeer := repository.Peer {\n\t\tIpAddress: nodeMessage.IpAddress,\n\t\tPort: nodeMessage.Port,\n\t}\n\tsavePeer(newPeer)\n\treturn nodeMessage\n}", "func (mock *ClientConnMock) NewAddressCalls() []struct {\n\tAddresses []resolver.Address\n} {\n\tvar calls []struct {\n\t\tAddresses []resolver.Address\n\t}\n\tmock.lockNewAddress.RLock()\n\tcalls = mock.calls.NewAddress\n\tmock.lockNewAddress.RUnlock()\n\treturn calls\n}", "func newClient(addr string) (discovery.DiscoveryClient, *grpc.ClientConn, error) {\n\tconn, err := grpc.Dial(addr, grpc.WithInsecure())\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn discovery.NewDiscoveryClient(conn), conn, nil\n}", "func (w *Wallet) NewAddress(account uint32,\n\tscope waddrmgr.KeyScope) (btcutil.Address, er.R) {\n\n\tchainClient, err := w.requireChainClient()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar (\n\t\taddr btcutil.Address\n\t\tprops *waddrmgr.AccountProperties\n\t)\n\terr = walletdb.Update(w.db, func(tx walletdb.ReadWriteTx) er.R {\n\t\taddrmgrNs := tx.ReadWriteBucket(waddrmgrNamespaceKey)\n\t\tvar err er.R\n\t\taddr, props, err = w.newAddress(addrmgrNs, account, scope)\n\t\treturn err\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Notify the rpc server about the newly created address.\n\terr = chainClient.NotifyReceived([]btcutil.Address{addr})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tw.NtfnServer.notifyAccountProperties(props)\n\n\treturn addr, nil\n}", "func CreateAddress(amount int) (string, []Wallet) {\n\n\twallets := []Wallet{}\n\tfor i := 0; i < amount; i++ {\n\t\twif, _ := network.CreatePrivateKey()\n\t\taddress, _ := network.GetAddress(wif)\n\t\tvar wallet = Wallet{ADDRESS: address.EncodeAddress(), PRIVKEY: wif.String()}\n\t\twallets = append(wallets, wallet)\n\t}\n\n\tjson := ConvertToJSON(&wallets)\n\n\tlog.Println(\"Generated\", amount, \"addresses\")\n\n\treturn json, wallets\n\n}", "func (a *Account) NewChangeAddress() (btcutil.Address, error) {\n\t// Get current block's height and hash.\n\tbs, err := GetCurBlock()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Get next chained change address from wallet.\n\taddr, err := a.Wallet.ChangeAddress(&bs, cfg.KeypoolSize)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Immediately write updated wallet to disk.\n\tAcctMgr.ds.ScheduleWalletWrite(a)\n\tif err := AcctMgr.ds.FlushAccount(a); err != nil {\n\t\treturn nil, fmt.Errorf(\"account write failed: %v\", err)\n\t}\n\n\t// Mark this new address as belonging to this account.\n\tAcctMgr.MarkAddressForAccount(addr, a)\n\n\t// Request updates from btcd for new transactions sent to this address.\n\ta.ReqNewTxsForAddress(addr)\n\n\treturn addr, nil\n}", "func (a *addrBook) NeedNewAddresses() bool {\n\ta.mtx.Lock()\n\tif a.nNew < a.nTried && a.nNew < needAddressThreshold/2 {\n\t\ta.mtx.Unlock()\n\t\treturn true\n\t}\n\ta.mtx.Unlock()\n\n\treturn false\n}", "func (a *addrBook) updateAddress(netAddr, srcAddr *node.Info) {\n\n\tif a.IsLocalAddress(netAddr) {\n\t\ta.logger.Debug(\"skipping adding a local address %v\", netAddr.String())\n\t\treturn\n\t}\n\t//Filter out non-routable addresses. Note that non-routable\n\t//also includes invalid and localNode addresses.\n\tif !IsRoutable(netAddr.IP) && IsRoutable(srcAddr.IP) {\n\t\ta.logger.Debug(\"skipping adding non routable address%v\", netAddr.String())\n\t\t// XXX: this makes tests work with unroutable addresses(loopback)\n\t\treturn\n\t}\n\n\tka := a.lookup(netAddr.PublicKey())\n\tif ka != nil {\n\t\t// TODO: only update addresses periodically.\n\t\t// Update the last seen time and services.\n\t\t// note that to prevent causing excess garbage on getaddr\n\t\t// messages the netaddresses in addrmaanger are *immutable*,\n\t\t// if we need to change them then we replace the pointer with a\n\t\t// new copy so that we don't have to copy every na for getaddr.\n\t\tka.lastSeen = time.Now()\n\n\t\t// If already in tried, we have nothing to do here.\n\t\tif ka.tried {\n\t\t\treturn\n\t\t}\n\n\t\t// Already at our max?\n\t\tif ka.refs == newBucketsPerAddress {\n\t\t\treturn\n\t\t}\n\n\t\t// The more entries we have, the less likely we are to add more.\n\t\t// likelihood is 2N.\n\t\t//factor := int32(2 * ka.refs)\n\t\t//if a.rand.Int31n(factor) != 0 {\n\t\treturn\n\t\t//}\n\t}\n\t// Make a copy of the net address to avoid races since it is\n\t// updated elsewhere in the addrmanager code and would otherwise\n\t// change the actual netaddress on the peer.\n\tka = &KnownAddress{na: netAddr, srcAddr: srcAddr, lastSeen: time.Now()}\n\ta.addrIndex[netAddr.ID] = ka\n\ta.nNew++\n\t// XXX time penalty?\n\n\tbucket := a.getNewBucket(netAddr.IP, srcAddr.IP)\n\n\t// Already exists?\n\tif _, ok := a.addrNew[bucket][netAddr.ID]; ok {\n\t\treturn\n\t}\n\n\t// Enforce max addresses.\n\tif len(a.addrNew[bucket]) > newBucketSize {\n\t\ta.logger.Debug(\"new bucket is full, expiring old\")\n\t\ta.expireNew(bucket)\n\t}\n\n\t// Add to new bucket.\n\tka.refs++\n\ta.addrNew[bucket][netAddr.ID] = ka\n\n\ta.logger.Debug(\"Added new address %s for a total of %d addresses\", netAddr.String(), a.nTried+a.nNew)\n}", "func (r FutureGetNewAddressAndKeyResult) Receive() (string, string, error) {\n\tres, err := receiveFuture(r)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\ttype AddrKey struct {\n\t\tAddress string\n\t\tSecret string\n\t}\n\t// Unmarshal result as a AddrKey.\n\tvar addrKey AddrKey\n\terr = json.Unmarshal(res, &addrKey)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\treturn addrKey.Address, addrKey.Secret, nil\n}", "func createAddress(creator *Account) Word256 {\n\tnonce := creator.Nonce\n\tcreator.Nonce += 1\n\ttemp := make([]byte, 32+8)\n\tcopy(temp, creator.Address[:])\n\tPutUint64BE(temp[32:], nonce)\n\treturn LeftPadWord256(sha3.Sha3(temp)[:20])\n}", "func NewAddress(pk ctypes.PubKey) *Address {\n\ta := Address{pk}\n\treturn &a\n}", "func (x *fastReflection_AddressBytesToStringResponse) New() protoreflect.Message {\n\treturn new(fastReflection_AddressBytesToStringResponse)\n}", "func (trcn *TestRetrievalClientNode) GetKnownAddresses(ctx context.Context, p retrievalmarket.RetrievalPeer, tok shared.TipSetToken) ([]ma.Multiaddr, error) {\n\ttrcn.receivedKnownAddresses[p] = struct{}{}\n\taddrs, ok := trcn.knownAddreses[p]\n\tif !ok {\n\t\treturn nil, errors.New(\"Provider not found\")\n\t}\n\treturn addrs, nil\n}", "func ValidateAddress(property db.Property, apiKey string) (*LobAddress, error) {\n\n\taddressRequestURL := fmt.Sprintf(\"%sv1/us_verifications/\", lobEndpoint)\n\trequestBody, err := json.Marshal(map[string]string{\n\t\t\"primary_line\": property.AddressOne,\n\t\t\"city\": property.City,\n\t\t\"state\": property.State,\n\t\t\"zip_code\": property.ZipCode,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", addressRequestURL, bytes.NewBuffer(requestBody))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.SetBasicAuth(apiKey, \"\")\n\n\tclient := &http.Client{}\n resp, err := client.Do(req)\n\n\tdefer resp.Body.Close()\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar lobResponse LobResponse \n\terr = json.Unmarshal(body, &lobResponse)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar addressOne, addressTwo, city, state, zip string\n\tif lobResponse.PrimaryLine != \"\" {\n\t\taddressOne = lobResponse.PrimaryLine\n\t} else {\n\t\taddressOne = property.AddressOne\n\t}\n\n\tif lobResponse.SecondaryLine != \"\" {\n\t\taddressTwo = lobResponse.SecondaryLine\n\t} else {\n\t\taddressTwo = property.AddressTwo\n\t}\n\n\tif lobResponse.Components != nil {\n\t\tif lobResponse.Components.City != \"\" {\n\t\t\tcity = lobResponse.Components.City\n\t\t} else {\n\t\t\tcity = property.City\n\t\t}\n\t\tif lobResponse.Components.State != \"\" {\n\t\t\tstate = lobResponse.Components.State\n\t\t} else {\n\t\t\tstate = property.State\n\t\t}\n\t\tif lobResponse.Components.ZipCode != \"\" && lobResponse.Components.ZipCodePlusFour != \"\" {\n\t\t\tzip = lobResponse.Components.ZipCode + \" \" + lobResponse.Components.ZipCodePlusFour\n\t\t} else {\n\t\t\tzip = property.ZipCode\n\t\t}\n\t}\n\n\treturn &LobAddress{\n\t\tAddressLineOne: addressOne,\n\t\tAddressLineTwo: addressTwo,\n\t\tAddressCity: city,\n\t\tAddressState: state,\n\t\tAddressZip: zip,\n\t}, nil\n\t\n}", "func newPeerClientConnection(block bool) (*grpc.ClientConn, error) {\n\treturn newPeerClientConnectionWithAddress(block, viper.GetString(\"service.cliaddress\"))\n}", "func NewFromString(addr string) (*Address, error) {\n\tlegaddr, err := legacy.Decode(addr)\n\tif err == nil {\n\t\taddr, err := NewFromLegacy(legaddr)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn addr, nil\n\t}\n\n\tcashaddr, err := cashaddress.Decode(addr, cashaddress.MainNet)\n\tif err == nil {\n\t\taddr, err := NewFromCashAddress(cashaddr)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn addr, nil\n\t}\n\n\treturn nil, errors.New(\"unable to decode address\")\n}", "func GeocodeAnAddress() {\n\tgeocodingService := geocoding.NewGeocodingService(\"YOUR_MICRO_TOKEN_HERE\")\n\trsp, _ := geocodingService.Lookup(geocoding.LookupRequest{\n\t\tAddress: \"10 russell st\",\n\t\tCity: \"london\",\n\t\tCountry: \"uk\",\n\t\tPostcode: \"wc2b\",\n\t})\n\tfmt.Println(rsp)\n}", "func (s) TestPickFirst_NewAddressWhileBlocking(t *testing.T) {\n\tcc, r, backends := setupPickFirst(t, 2)\n\taddrs := stubBackendsToResolverAddrs(backends)\n\tr.UpdateState(resolver.State{Addresses: addrs})\n\n\tctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)\n\tdefer cancel()\n\tif err := checkPickFirst(ctx, cc, addrs[0].Addr); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Send a resolver update with no addresses. This should push the channel into\n\t// TransientFailure.\n\tr.UpdateState(resolver.State{})\n\tfor state := cc.GetState(); state != connectivity.TransientFailure; state = cc.GetState() {\n\t\tif !cc.WaitForStateChange(ctx, state) {\n\t\t\tt.Fatalf(\"timeout waiting for state change. got %v; want %v\", state, connectivity.TransientFailure)\n\t\t}\n\t}\n\n\tdoneCh := make(chan struct{})\n\tclient := testpb.NewTestServiceClient(cc)\n\tgo func() {\n\t\t// The channel is currently in TransientFailure and this RPC will block\n\t\t// until the channel becomes Ready, which will only happen when we push a\n\t\t// resolver update with a valid backend address.\n\t\tif _, err := client.EmptyCall(ctx, &testpb.Empty{}, grpc.WaitForReady(true)); err != nil {\n\t\t\tt.Errorf(\"EmptyCall() = %v, want <nil>\", err)\n\t\t}\n\t\tclose(doneCh)\n\t}()\n\n\t// Make sure that there is one pending RPC on the ClientConn before attempting\n\t// to push new addresses through the name resolver. If we don't do this, the\n\t// resolver update can happen before the above goroutine gets to make the RPC.\n\tfor {\n\t\tif err := ctx.Err(); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\ttcs, _ := channelz.GetTopChannels(0, 0)\n\t\tif len(tcs) != 1 {\n\t\t\tt.Fatalf(\"there should only be one top channel, not %d\", len(tcs))\n\t\t}\n\t\tstarted := tcs[0].ChannelData.CallsStarted\n\t\tcompleted := tcs[0].ChannelData.CallsSucceeded + tcs[0].ChannelData.CallsFailed\n\t\tif (started - completed) == 1 {\n\t\t\tbreak\n\t\t}\n\t\ttime.Sleep(defaultTestShortTimeout)\n\t}\n\n\t// Send a resolver update with a valid backend to push the channel to Ready\n\t// and unblock the above RPC.\n\tr.UpdateState(resolver.State{Addresses: []resolver.Address{{Addr: backends[0].Address}}})\n\n\tselect {\n\tcase <-ctx.Done():\n\t\tt.Fatal(\"Timeout when waiting for blocked RPC to complete\")\n\tcase <-doneCh:\n\t}\n}", "func createRPCClient(serverIPPort string) *rpc.Client {\n\t// parse given string address\n\traddr, err := net.ResolveTCPAddr(\"tcp\", serverIPPort)\n\tif err != nil {\n\t\tlogger.Println(err)\n return nil\n\t}\n\t// dial rpc address\n\tconn, err := net.DialTCP(\"tcp\", nil, raddr)\n\tif err != nil {\n\t\tlogger.Println(err)\n return nil\n\t}\n\t// instantiate rpc client\n\tclient := rpc.NewClient(conn)\n\n\treturn client\n}", "func NewAddress(i, ii int) *Address {\n\tn := strconv.Itoa(i)\n\treturn &Address{\n\t\tId: time.Now().UnixNano(),\n\t\tStreet: \"10\" + n + \" Somewhere Lane\",\n\t\tCity: \"Awesome City \" + n,\n\t\tState: func() string {\n\t\t\tif i%2 == 0 {\n\t\t\t\treturn \"PA\"\n\t\t\t}\n\t\t\treturn \"CA\"\n\t\t}(),\n\t\tZip: ii,\n\t}\n}", "func newReconciler(mgr manager.Manager) reconcile.Reconciler {\n\tgo setupAddressObserver(mgr, C)\n\treturn &ReconcileActiveMQArtemisAddress{client: mgr.GetClient(), scheme: mgr.GetScheme()}\n}", "func genAddress(ip string, port int) string {\n\treturn fmt.Sprintf(\"%s:%d\", ip, port)\n}", "func (a *StartupConfigurationApiService) GenerateNewNodeId(ctx _context.Context) ApiGenerateNewNodeIdRequest {\n\treturn ApiGenerateNewNodeIdRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t}\n}", "func updateAddr(newaddr string) error {\n\trec, err := getRec()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error getting DNS record: %v\", err)\n\t}\n\tif rec.Content == newaddr {\n\t\tlog.Printf(\"DNS record matches current IP\\n\")\n\t\treturn nil\n\t}\n\targs := url.Values{}\n\targs.Set(\"a\", \"rec_edit\")\n\targs.Set(\"tkn\", TKN)\n\targs.Set(\"email\", EMAIL)\n\targs.Set(\"z\", ZONE)\n\targs.Set(\"type\", \"A\")\n\targs.Set(\"id\", rec.Rec_id)\n\targs.Set(\"name\", rec.Name)\n\targs.Set(\"content\", newaddr)\n\targs.Set(\"ttl\", \"1\") // 1=Automatic, otherwise set between 120 and 4,294,967,295 seconds\n\targs.Set(\"service_mode\", \"1\") // 1 = orange cloud, 0 = grey cloud\n\tresp, err := http.PostForm(APIURL, args)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error posting request: %v\", err)\n\t}\n\tdefer resp.Body.Close()\n\tdec := json.NewDecoder(resp.Body)\n\t// not exactly right, but ApiRecLoadAll will get us the result and msg\n\tvar m ApiRecLoadAll\n\terr = dec.Decode(&m)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error decoding response: %v\", err)\n\t}\n\tif m.Result != \"success\" {\n\t\treturn fmt.Errorf(\"API call returned error: %v\", m.Msg)\n\t}\n\tlog.Printf(\"Successfully updated DNS record.\\n\")\n\treturn nil\n}", "func (o *PartnerCustomerCreateRequest) GetAddressOk() (*PartnerEndCustomerAddress, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.Address, true\n}", "func (client *PublicIPAddressesClient) getCreateRequest(ctx context.Context, resourceGroupName string, publicIPAddressName string, options *PublicIPAddressesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif publicIPAddressName == \"\" {\n\t\treturn nil, errors.New(\"parameter publicIPAddressName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{publicIpAddressName}\", url.PathEscape(publicIPAddressName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\tif options != nil && options.Expand != nil {\n\t\treqQP.Set(\"$expand\", *options.Expand)\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func newManagedAddressWithoutPrivKey(m *Manager, account uint32, pubKey chainec.PublicKey, compressed bool) (*managedAddress, error) {\n\t// Create a pay-to-pubkey-hash address from the public key.\n\tvar pubKeyHash []byte\n\tif compressed {\n\t\tpubKeyHash = abcutil.Hash160(pubKey.SerializeCompressed())\n\t} else {\n\t\tpubKeyHash = abcutil.Hash160(pubKey.SerializeUncompressed())\n\t}\n\taddress, err := abcutil.NewAddressPubKeyHash(pubKeyHash, m.chainParams,\n\t\tchainec.ECTypeSecp256k1)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &managedAddress{\n\t\tmanager: m,\n\t\taddress: address,\n\t\taccount: account,\n\t\timported: false,\n\t\tinternal: false,\n\t\tmultisig: false,\n\t\tcompressed: compressed,\n\t\tpubKey: pubKey,\n\t}, nil\n}", "func (a *addrBook) updateAddress(addr, src *addrInfo) {\n\tif !IsRoutable(addr.IP) && IsRoutable(src.IP) {\n\t\ta.logger.Debug(\"skipped non routable address received from routable ip\",\n\t\t\tlog.String(\"received\", addr.IP.String()),\n\t\t\tlog.String(\"from\", src.IP.String()),\n\t\t)\n\t\treturn\n\t}\n\tka := a.lookup(addr.ID)\n\tif ka != nil {\n\t\t// TODO: only update addresses periodically.\n\t\t// Update the last seen time and services.\n\t\t// note that to prevent causing excess garbage on getaddr\n\t\t// messages the netaddresses in addrmaanger are *immutable*,\n\t\t// if we need to change them then we replace the pointer with a\n\t\t// new copy so that we don't have to copy every na for getaddr.\n\t\tka.LastSeen = time.Now()\n\n\t\t// If already in tried, we have nothing to do here.\n\t\tif ka.tried {\n\t\t\treturn\n\t\t}\n\n\t\t// Already at our max?\n\t\tif ka.refs == newBucketsPerAddress {\n\t\t\treturn\n\t\t}\n\n\t\t// The more entries we have, the less likely we are to add more.\n\t\t// likelihood is 2N.\n\t\t// factor := int32(2 * ka.refs)\n\t\t// if a.rand.Int31n(factor) != 0 {\n\t\treturn\n\t\t//}\n\t}\n\t// Make a copy of the net address to avoid races since it is\n\t// updated elsewhere in the addrmanager code and would otherwise\n\t// change the actual netaddress on the peer.\n\tka = &knownAddress{Addr: addr, SrcAddr: src, LastSeen: time.Now()}\n\ta.addrIndex[addr.ID] = ka\n\ta.nNew++\n\t// XXX time penalty?\n\n\tbucket := a.getNewBucket(addr.IP, src.IP)\n\n\t// Already exists?\n\tif _, ok := a.addrNew[bucket][addr.ID]; ok {\n\t\treturn\n\t}\n\n\t// Enforce max addresses.\n\tif len(a.addrNew[bucket]) > newBucketSize {\n\t\ta.logger.Debug(\"new bucket is full, expiring old\")\n\t\ta.expireNew(bucket)\n\t}\n\n\t// Add to new bucket.\n\tka.refs++\n\ta.addrNew[bucket][addr.ID] = ka\n\n\ta.logger.Debug(\"added new address %s for a total of %d addresses\", addr.RawAddr, a.nTried+a.nNew)\n}", "func (handler *Handler) CreateAddress(ctx context.Context, in *candyland_grpc.CreateAddressRequest) (*candyland_grpc.CreateAddressReply, error) {\n\terr := handler.CreateAddressUsecase.Create(in.UserId, in.CountryId, in.StateId, in.CityId, in.StreetId, in.Number, in.Complement.String())\n\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\treturn nil, err\n\t}\n\n\tres := &candyland_grpc.CreateAddressReply{\n\t\tWasCreated: true,\n\t}\n\n\treturn res, nil\n}", "func (c *Client) newRequest(method, path string) (*request, error) {\n\tbase, _ := url.Parse(c.config.Address)\n\tu, err := url.Parse(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tr := &request{\n\t\tconfig: &c.config,\n\t\tmethod: method,\n\t\turl: &url.URL{\n\t\t\tScheme: base.Scheme,\n\t\t\tUser: base.User,\n\t\t\tHost: base.Host,\n\t\t\tPath: u.Path,\n\t\t\tRawPath: u.RawPath,\n\t\t},\n\t\theader: make(http.Header),\n\t\tparams: make(map[string][]string),\n\t}\n\tif c.config.Region != \"\" {\n\t\tr.params.Set(\"region\", c.config.Region)\n\t}\n\tif c.config.Namespace != \"\" {\n\t\tr.params.Set(\"namespace\", c.config.Namespace)\n\t}\n\tif c.config.WaitTime != 0 {\n\t\tr.params.Set(\"wait\", durToMsec(r.config.WaitTime))\n\t}\n\tif c.config.SecretID != \"\" {\n\t\tr.token = r.config.SecretID\n\t}\n\n\t// Add in the query parameters, if any\n\tfor key, values := range u.Query() {\n\t\tfor _, value := range values {\n\t\t\tr.params.Add(key, value)\n\t\t}\n\t}\n\n\tfor key, values := range c.config.Headers {\n\t\tr.header[key] = values\n\t}\n\n\treturn r, nil\n}", "func (x *fastReflection_MsgSetWithdrawAddressResponse) New() protoreflect.Message {\n\treturn new(fastReflection_MsgSetWithdrawAddressResponse)\n}", "func (as *AddressService) Create(name string) (*Address, error) {\n\tif isEmptyStr(as.assetCode) {\n\t\treturn nil, errAssetCode\n\t}\n\n\tvar (\n\t\taddresses []*Address\n\t\tbody struct {\n\t\t\tAddress struct {\n\t\t\t\tName string `json:\"name\"`\n\t\t\t} `json:\"address\"`\n\t\t}\n\t)\n\tbody.Address.Name = name\n\n\tif err := as.client.Post(buildString(\"address/deposit/\", as.assetCode), &body, &addresses); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn addresses[0], nil\n}", "func (n *PeernotifyNode) getNextAddress() []byte {\n\treturn []byte{}\n}", "func NewAddress(address common.Address, backend bind.ContractBackend) (*Address, error) {\n\tcontract, err := bindAddress(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Address{AddressCaller: AddressCaller{contract: contract}, AddressTransactor: AddressTransactor{contract: contract}, AddressFilterer: AddressFilterer{contract: contract}}, nil\n}", "func NewAddress(address common.Address, backend bind.ContractBackend) (*Address, error) {\n\tcontract, err := bindAddress(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Address{AddressCaller: AddressCaller{contract: contract}, AddressTransactor: AddressTransactor{contract: contract}, AddressFilterer: AddressFilterer{contract: contract}}, nil\n}", "func NewAddress(address common.Address, backend bind.ContractBackend) (*Address, error) {\n\tcontract, err := bindAddress(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Address{AddressCaller: AddressCaller{contract: contract}, AddressTransactor: AddressTransactor{contract: contract}, AddressFilterer: AddressFilterer{contract: contract}}, nil\n}", "func NewAddress(address common.Address, backend bind.ContractBackend) (*Address, error) {\n\tcontract, err := bindAddress(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Address{AddressCaller: AddressCaller{contract: contract}, AddressTransactor: AddressTransactor{contract: contract}, AddressFilterer: AddressFilterer{contract: contract}}, nil\n}", "func NewAddress(address common.Address, backend bind.ContractBackend) (*Address, error) {\n\tcontract, err := bindAddress(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Address{AddressCaller: AddressCaller{contract: contract}, AddressTransactor: AddressTransactor{contract: contract}, AddressFilterer: AddressFilterer{contract: contract}}, nil\n}", "func (s *Server) handleGetAddrCmd(p Peer) error {\n\taddrs := s.discovery.GoodPeers()\n\tif len(addrs) > payload.MaxAddrsCount {\n\t\taddrs = addrs[:payload.MaxAddrsCount]\n\t}\n\talist := payload.NewAddressList(len(addrs))\n\tts := time.Now()\n\tfor i, addr := range addrs {\n\t\t// we know it's a good address, so it can't fail\n\t\tnetaddr, _ := net.ResolveTCPAddr(\"tcp\", addr.Address)\n\t\talist.Addrs[i] = payload.NewAddressAndTime(netaddr, ts, addr.Capabilities)\n\t}\n\treturn p.EnqueueP2PMessage(NewMessage(CMDAddr, alist))\n}", "func (_Crowdsale *CrowdsaleCaller) RoyaltyCrowdsaleAddress(opts *bind.CallOpts) (common.Address, error) {\n\tvar (\n\t\tret0 = new(common.Address)\n\t)\n\tout := ret0\n\terr := _Crowdsale.contract.Call(opts, out, \"royaltyCrowdsaleAddress\")\n\treturn *ret0, err\n}", "func getAddress(mn string) string {\n\tsk, err := mnemonic.ToPrivateKey(mn)\n\tif err != nil {\n\t\tfmt.Printf(\"error recovering account: %s\\n\", err)\n\t\treturn \"\"\n\t}\n\tpk := sk.Public()\n\tvar a types.Address\n\tcpk := pk.(ed25519.PublicKey)\n\tcopy(a[:], cpk[:])\n\tfmt.Printf(\"Address: %s\\n\", a.String())\n\taddress := a.String()\n\treturn address\n}", "func createListeningAddress(network, address string) string {\n\treturn strings.Join([]string{network, address}, \"/\")\n}", "func newCreateClientTunnelReply(cidr *net.IPNet, tid int64) (f linkFrame) {\n f.method = CLIENT_TUN_NEW\n f.param = map[string]interface{} { K_CIDR : cidr.String() }\n f.response = tid\n return\n}", "func rstPopulateContract(w http.ResponseWriter, r *http.Request) {\n\n\terr := r.ParseMultipartForm(32 << 20)\n\tif err != nil {\n\t\tfmt.Printf(\"No change data: Parsing multipart form: %v\\n\", err.Error())\n\t\treturn\n\t}\n\n\t//isCurl = r.MultipartForm.Value[\"Curl\"]\n\tif len(r.MultipartForm.Value[\"ContrAddr\"]) == 0 {\n\t\thttp.Error(w, GeneralError{\"No contrAddr is provided\"}.Error(),\n\t\t\thttp.StatusInternalServerError)\n\t\treturn\n\t}\n\tcontrAddrStr := r.MultipartForm.Value[\"ContrAddr\"][0]\n\tif common.IsHexAddress(contrAddrStr) == false {\n\t\thttp.Error(w, GeneralError{\"Contract address is incorrect\"}.Error(),\n\t\t\thttp.StatusInternalServerError)\n\t\treturn\n\t}\n\tcontrAddr := common.HexToAddress(contrAddrStr)\n\n\t/*\n\t parentAddr := common.Address{}\n\t if len(r.MultipartForm.Value[\"ParentAddr\"])!=0 {\n\t parentAddrStr := r.MultipartForm.Value[\"ParentAddr\"][0]\n\t if (common.IsHexAddress(parentAddrStr) == false) {\n\t http.Error(w, GeneralError{\"Parent contract address is incorrect\"}.Error(),\n\t http.StatusInternalServerError)\n\t return\n\t }\n\t parentAddr = common.HexToAddress(parentAddrStr)\n\t }\n\t*/\n\n\tnewUserAddr := common.Address{}\n\tif len(r.MultipartForm.Value[\"NewUserAddr\"]) != 0 {\n\t\tuserAddrStr := r.MultipartForm.Value[\"NewUserAddr\"][0]\n\t\tif common.IsHexAddress(userAddrStr) == false {\n\t\t\thttp.Error(w, GeneralError{\"New User address is incorrect\"}.Error(),\n\t\t\t\thttp.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tnewUserAddr = common.HexToAddress(userAddrStr)\n\t} /*else {\n\t\thttp.Error(w, \"New User address is not available in params\", http.StatusInternalServerError)\n\t\treturn\n\t}*/\n\n\tcurUserAddr := common.Address{}\n\tif len(r.MultipartForm.Value[\"CurrentUserAddr\"]) != 0 {\n\t\tuserAddrStr := r.MultipartForm.Value[\"CurrentUserAddr\"][0]\n\t\tif common.IsHexAddress(userAddrStr) == false {\n\t\t\thttp.Error(w, GeneralError{\"Current User address is incorrect\"}.Error(),\n\t\t\t\thttp.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tcurUserAddr = common.HexToAddress(userAddrStr)\n\t} /*else {\n\t\thttp.Error(w, \"Current User address is not available in params\", http.StatusInternalServerError)\n\t\treturn\n\t}*/\n\n\thashCert, _, dataCert, cerr := UploadFile(w, r, \"UplFiles\", true)\n\tif cerr.errCode != 0 {\n\t\tfmt.Printf(fmt.Sprintf(\"Populate Uploadfile: %v\\n\", cerr.Error()))\n\t\thttp.Error(w, cerr.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\t/*\n\t dataCert, err := GenerateCert(contrAddr, parentAddr, true, \"Mother Nature CA\")\n\t if err != nil {\n\t http.Error(w, err.Error(), http.StatusInternalServerError)\n\t return\n\t }\n\n\t hashCert, err := CalcHash(dataCert)\n\t if err != nil {\n\t http.Error(w, err.Error(), http.StatusInternalServerError)\n\t return\n\t }\n\t*/\n\n\tclient, err := ethclient.Dial(gConfig.IPCpath)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Instantiate the contract, the address is taken from eth at the moment of contract initiation\n\t// kyc, err := NewLuxUni_KYC(common.HexToAddress(gContractHash), backends.NewRPCBackend(conn))\n\tpkiContract, err := NewLuxUni_PKI(contrAddr, client)\n\tif err != nil {\n\t\thttp.Error(w, GeneralError{\n\t\t\tfmt.Sprintf(\"Failed to instantiate a smart contract: %v\", err)}.Error(),\n\t\t\thttp.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Logging into Ethereum as a user\n\tif (curUserAddr == common.Address{}) {\n\t\tfmt.Printf(\"Attention! Populate contract: user address is zero, default config account is used\\n\")\n\t\tcurUserAddr = common.HexToAddress(gConfig.AccountAddr)\n\t}\n\tkeyFile, err := FindKeyFile(curUserAddr)\n\tif err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Failed to find key file for account %v. %v \",\n\t\t\tcurUserAddr.String(), err), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tkey, e := ioutil.ReadFile(gConfig.KeyDir + keyFile)\n\tif e != nil {\n\t\tfmt.Printf(\"Key File error: %v\\n\", e)\n\t\tos.Exit(1)\n\t}\n\tfmt.Printf(\"Found Ethereum Key File \\n\")\n\n\tauth, err := bind.NewTransactor(strings.NewReader(string(key)), gConfig.Pswd)\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to create authorized transactor: %v\", err)\n\t}\n\n\tsess := &LuxUni_PKISession{\n\t\tContract: pkiContract,\n\t\tCallOpts: bind.CallOpts{\n\t\t\tPending: true,\n\t\t},\n\t\tTransactOpts: bind.TransactOpts{},\n\t}\n\tsess.TransactOpts = *auth\n\tsess.TransactOpts.GasLimit = big.NewInt(50000000)\n\n\t_, err = sess.PopulateCertificate(dataCert)\n\tif err != nil {\n\t\tfmt.Printf(fmt.Sprintf(\"Failed to populate blockchain: %v.\\n\", err))\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tif (newUserAddr != common.Address{}) {\n\t\t_, err := sess.SetOwner(newUserAddr)\n\t\tif err != nil {\n\t\t\tfmt.Printf(fmt.Sprintf(\"Failed to update owner addr: %v.\\n\", err))\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tnewOwner, err := sess.GetOwner()\n\t\tif err != nil {\n\t\t\tfmt.Printf(fmt.Sprintf(\"Failed to check new owner addr: %v.\\n\", err))\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tif newOwner != newUserAddr {\n\t\t\thttp.Error(w, fmt.Sprintf(\"OwnerAddr (%v) does not equal to newUserAddr (%v) despite SetOwner - probably lack of permissions\",\n\t\t\t\tnewOwner.String(), newUserAddr.String()), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t} /*else {\n\t\thttp.Error(w, \"New User addr is null\", http.StatusInternalServerError)\n\t\treturn\n\t}*/\n\n\t//fmt.Printf(\"Debug Hash Populate: %s, arr:%v \\n\", hex.EncodeToString(hashCert), []byte(hex.EncodeToString(hashCert)))\n\tw.WriteHeader(http.StatusOK)\n\tw.Write([]byte(hex.EncodeToString(hashCert)))\n}", "func (x *fastReflection_AddressBytesToStringRequest) New() protoreflect.Message {\n\treturn new(fastReflection_AddressBytesToStringRequest)\n}", "func (w *Wallet) NewAddress(s *aklib.DBConfig, pwd []byte, isPublic bool) (*address.Address, error) {\n\tadrmap := w.AddressPublic\n\tvar idx uint32\n\tif !isPublic {\n\t\tadrmap = w.AddressChange\n\t\tidx = 1\n\t}\n\tmaster, err := address.DecryptSeed(w.EncSeed, pwd)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tseed := address.HDseed(master, idx, uint32(len(adrmap)))\n\ta, err := address.New(s.Config, seed)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tadr := &Address{\n\t\tAddress: a,\n\t\tAdrstr: a.Address58(s.Config),\n\t\tNo: len(adrmap),\n\t}\n\tif err := w.PutAddress(s, pwd, adr, true); err != nil {\n\t\treturn nil, err\n\t}\n\tadrmap[a.Address58(s.Config)] = struct{}{}\n\treturn a, w.put(s)\n}", "func NewRandomAddress(rng *rand.Rand) common.Address {\n\treturn common.Address(wtest.NewRandomAddress(rng))\n}" ]
[ "0.7285334", "0.7254116", "0.7206184", "0.7199894", "0.71601254", "0.7149224", "0.66494334", "0.6274284", "0.6202237", "0.61646694", "0.608202", "0.5939763", "0.58696765", "0.58615035", "0.5792989", "0.57605034", "0.57210624", "0.5708498", "0.5630859", "0.56129843", "0.5611596", "0.55982834", "0.55370736", "0.5478587", "0.5469931", "0.5468681", "0.54640573", "0.5407431", "0.5398442", "0.5398356", "0.535769", "0.535769", "0.5343541", "0.5343425", "0.53365636", "0.5327208", "0.532574", "0.5323628", "0.53235143", "0.53174925", "0.52913904", "0.5274156", "0.5272926", "0.52478945", "0.5229344", "0.52268475", "0.5213539", "0.52111834", "0.5188356", "0.5184529", "0.51829004", "0.5177956", "0.5177697", "0.5167108", "0.51534355", "0.5148527", "0.5141576", "0.5141161", "0.5120872", "0.51040703", "0.50927824", "0.5091678", "0.5088829", "0.5086931", "0.5078229", "0.50773436", "0.5076747", "0.50729203", "0.50695753", "0.5064026", "0.5063408", "0.50626427", "0.50517046", "0.5051578", "0.5050484", "0.5046947", "0.5030114", "0.5023051", "0.5017013", "0.50061476", "0.4995924", "0.49949446", "0.49847135", "0.49833596", "0.4978958", "0.49699348", "0.49678037", "0.49678037", "0.49678037", "0.49678037", "0.49678037", "0.49613404", "0.4954236", "0.49471286", "0.49470606", "0.4946713", "0.49451956", "0.49444267", "0.4933029", "0.4929508" ]
0.77015626
0
btc send raw transaction
btc отправить сырую транзакцию
func (client *BtcClient)BtcSendRawTrans(serial string , tx []byte)(string,error ){ var redeemTx wire.MsgTx err := json.Unmarshal(tx,&redeemTx) if err != nil { return "",err } sendResult,err := client.rpcClient.SendRawTransaction(&redeemTx,false) //sendResult,err := btcClient.SendRawTransactionAsync(&redeemTx,false).Receive() if err != nil { return "",err } return sendResult.String(),nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func sendRawTx(eth *thereum.Thereum, msg *rpcMessage) (*rpcMessage, error) {\n\t// unmarshal into temp data structs (passed via json as a slice of a single hex string)\n\tvar hexTx []string\n\terr := json.Unmarshal(msg.Params, &hexTx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// ensure that some data was passed throught the rpc msg\n\tif len(hexTx) == 0 {\n\t\treturn nil, errors.New(\"no parameters provided for raw transaction\")\n\t}\n\t// unmarshal the hex bytes into a transaction\n\tvar tx types.Transaction\n\ttxBytes, err := hex.DecodeString(strings.Replace(hexTx[0], \"0x\", \"\", 1))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = rlp.DecodeBytes(txBytes, &tx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// add the transaction to thereum\n\terr = eth.AddTx(&tx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tout := &rpcMessage{\n\t\tVersion: \"2.0\",\n\t\tID: 1,\n\t\tResult: tx.Hash().Hex(),\n\t}\n\n\treturn out, nil\n}", "func bitcoinSendRawTransaction(tx []byte, reply *string) error {\n\tglobalBitcoinData.Lock()\n\tdefer globalBitcoinData.Unlock()\n\n\tif !globalBitcoinData.initialised {\n\t\treturn fault.ErrNotInitialised\n\t}\n\n\t// need to be in hex for bitcoind\n\targuments := []interface{}{\n\t\thex.EncodeToString(tx),\n\t}\n\treturn bitcoinCall(\"sendrawtransaction\", arguments, reply)\n}", "func sendRawTransaction(_privateKey string, recipientAddress string, methodName string, value int64, argAmount string) {\n\t//connect to ropsten through infura\n\tec, err := ethclient.Dial(\"https://ropsten.infura.io/\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tchainID := big.NewInt(3) //Ropsten\n\n\t//private key of sender\n\t//TODO: hide key when actual system is implemented\n\tprivateKey, err := crypto.HexToECDSA(_privateKey)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t//get Public Key of sender\n\tpublicKey := privateKey.Public()\n\tpublicKey_ECDSA, valid := publicKey.(*ecdsa.PublicKey)\n\tif !valid {\n\t\tlog.Fatal(\"error casting public key to ECDSA\")\n\t}\n\n\t//get address of sender\n\tfromAddress := crypto.PubkeyToAddress(*publicKey_ECDSA)\n\n\t//get nonce of address\n\tnonce, err := ec.PendingNonceAt(context.Background(), fromAddress)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t//get recipient address\n\trecipient := common.HexToAddress(recipientAddress)\n\n\tamount := big.NewInt(value) // 0 ether\n\tgasLimit := uint64(2000000)\n\tgasPrice, err := ec.SuggestGasPrice(context.Background())\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\ttransferFnSignature := []byte(methodName)\n\thash := sha3.NewLegacyKeccak256()\n\thash.Write(transferFnSignature)\n\tmethodID := hash.Sum(nil)[:4]\n\t//fmt.Println(hexutil.Encode(methodID)) // 0xa9059cbb\n\n\targumentAmount := new(big.Int)\n\targumentAmount.SetString(argAmount, 10) //\n\tpaddedAmount := common.LeftPadBytes(argumentAmount.Bytes(), 32)\n\t//fmt.Println(hexutil.Encode(paddedAmount)) // 0x00000000000000000000000000000000000000000000003635c9adc5dea00000\n\n\tvar data []byte\n\tdata = append(data, methodID...)\n\tdata = append(data, paddedAmount...)\n\t//data := []byte(\"0x5c22b6b60000000000000000000000000000000000000000000000000000000000000007\")\n\t// fmt.Printf(\"nonce: %i\\n\", nonce)\n\t// fmt.Printf(\"amount: %i\\n\", amount)\n\t// fmt.Printf(\"gasLimit: %s\\n\", gasLimit)\n\t// fmt.Printf(\"gasPrice: %s\\n\", gasPrice)\n\tfmt.Printf(\"data: %x\\n\", data)\n\n\t//create raw transaction\n\ttransaction := types.NewTransaction(nonce, recipient, amount, gasLimit, gasPrice, data)\n\n\t//sign transaction for ropsten network\n\tsigner := types.NewEIP155Signer(chainID)\n\tsignedTx, err := types.SignTx(transaction, signer, privateKey)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// var buff bytes.Buffer\n\t// signedTx.EncodeRLP(&buff)\n\t// fmt.Printf(\"0x%x\\n\", buff.Bytes())\n\n\t//fmt.Println(signedTx)\n\t//broadcast transaction\n\terr = ec.SendTransaction(context.Background(), signedTx)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfmt.Printf(\"tx sent: %s\\n\", signedTx.Hash().Hex())\n\n\t// jsonData := fmt.Sprintf(` {\"jsonrpc\":\"2.0\", \"method\":\"eth_sendRawTransaction\", \"params\": [\"0x%x\"], \"id\":4}`, buff.Bytes())\n\t// //params := buff.String()\n\t// fmt.Printf(\"%s\\n\", jsonData)\n\t// response, err := http.Post(\"https://rinkeby.infura.io/gnNuNKvHFmjf9xkJ0StE\", \"application/json\", strings.NewReader(jsonData))\n\t// if err != nil {\n\n\t// \tfmt.Printf(\"Request to INFURA failed with an error: %s\\n\", err)\n\t// \tfmt.Println()\n\n\t// } else {\n\t// \tdata, _ := ioutil.ReadAll(response.Body)\n\n\t// \tfmt.Println(\"INFURA response:\")\n\t// \tfmt.Println(string(data))\n\t// }\n}", "func (a API) SendRawTransaction(cmd *btcjson.SendRawTransactionCmd) (e error) {\n\tRPCHandlers[\"sendrawtransaction\"].Call <-API{a.Ch, cmd, nil}\n\treturn\n}", "func (pgb *ChainDBRPC) SendRawTransaction(txhex string) (string, error) {\n\tmsg, err := txhelpers.MsgTxFromHex(txhex)\n\tif err != nil {\n\t\tlog.Errorf(\"SendRawTransaction failed: could not decode hex\")\n\t\treturn \"\", err\n\t}\n\thash, err := pgb.Client.SendRawTransaction(msg, true)\n\tif err != nil {\n\t\tlog.Errorf(\"SendRawTransaction failed: %v\", err)\n\t\treturn \"\", err\n\t}\n\treturn hash.String(), err\n}", "func (c BitcoinCoreChain) RawTx(cxt context.Context, from, to, amount, memo, asset string) (string, error) {\n if configure.ChainAssets[asset] != Bitcoin {\n return \"\", fmt.Errorf(\"Unsupport %s in bitcoincore\", asset)\n }\n amountF, err := strconv.ParseFloat(amount, 64)\n if err != nil {\n return \"\", err\n }\n txAmountSatoshi, err := btcutil.NewAmount(amountF)\n if err != nil {\n return \"\", err\n }\n\n fromPkScript, err := BitcoincoreAddressP2AS(from, c.Mode)\n if err != nil {\n return \"\", err\n }\n toPkScript, err := BitcoincoreAddressP2AS(to, c.Mode)\n if err != nil {\n return \"\", err\n }\n\n // query bitcoin chain info\n chaininfo, err := c.Client.GetBlockChainInfo()\n if err != nil {\n return \"\", err\n }\n // feeKB, err := c.Client.EstimateFee(int64(6))\n feeKB, err := c.Client.EstimateSmartFee(int64(6))\n if err != nil {\n return \"\", err\n }\n feeRate := mempool.SatoshiPerByte(feeKB.FeeRate)\n\n if feeKB.FeeRate <= 0 {\n feeRate = mempool.SatoshiPerByte(100)\n }\n\n var (\n selectedutxos, unselectedutxos []db.UTXO\n selectedCoins coinset.Coins\n )\n\n // Coin Select\n if strings.ToLower(configure.ChainsInfo[Bitcoin].Coin) == strings.ToLower(asset) {\n // select coins for BTC transfer\n if selectedutxos, unselectedutxos, selectedCoins, err = CoinSelect(int64(chaininfo.Headers), txAmountSatoshi, c.Wallet.Address.UTXOs); err != nil {\n return \"\", fmt.Errorf(\"Select UTXO for tx %s\", err)\n }\n }else {\n // select coins for Token transfer\n // 300: https://bitcoin.stackexchange.com/questions/1195/how-to-calculate-transaction-size-before-sending-legacy-non-segwit-p2pkh-p2sh\n inputAmount := feeRate.Fee(uint32(300))\n if selectedutxos, unselectedutxos, selectedCoins, err = CoinSelect(int64(chaininfo.Headers), inputAmount, c.Wallet.Address.UTXOs); err != nil {\n return \"\", fmt.Errorf(\"Select UTXO for tx %s\", err)\n }\n }\n\n var vinAmount int64\n for _, coin := range selectedCoins.Coins() {\n vinAmount += int64(coin.Value())\n }\n msgTx := coinset.NewMsgTxWithInputCoins(wire.TxVersion, selectedCoins)\n\n token := configure.ChainsInfo[Bitcoin].Tokens[strings.ToLower(asset)]\n if token != \"\" && strings.ToLower(asset) != strings.ToLower(configure.ChainsInfo[Bitcoin].Coin) {\n // OmniToken transfer\n b := txscript.NewScriptBuilder()\n b.AddOp(txscript.OP_RETURN)\n\n omniVersion := util.Int2byte(uint64(0), 2)\t// omnicore version\n txType := util.Int2byte(uint64(0), 2)\t// omnicore tx type: simple send\n propertyID := configure.ChainsInfo[Bitcoin].Tokens[asset]\n tokenPropertyid, err := strconv.Atoi(propertyID)\n if err != nil {\n return \"\", fmt.Errorf(\"tokenPropertyid to int %s\", err)\n }\n // tokenPropertyid := configure.Config.OmniToken[\"omni_first_token\"].(int)\n tokenIdentifier := util.Int2byte(uint64(tokenPropertyid), 4)\t// omni token identifier\n tokenAmount := util.Int2byte(uint64(txAmountSatoshi), 8)\t// omni token transfer amount\n\n b.AddData([]byte(\"omni\"))\t// transaction maker\n b.AddData(omniVersion)\n b.AddData(txType)\n b.AddData(tokenIdentifier)\n b.AddData(tokenAmount)\n pkScript, err := b.Script()\n if err != nil {\n return \"\", fmt.Errorf(\"Bitcoin Token pkScript %s\", err)\n }\n msgTx.AddTxOut(wire.NewTxOut(0, pkScript))\n txOutReference := wire.NewTxOut(0, toPkScript)\n msgTx.AddTxOut(txOutReference)\n }else {\n // BTC transfer\n txOutTo := wire.NewTxOut(int64(txAmountSatoshi), toPkScript)\n msgTx.AddTxOut(txOutTo)\n\n // recharge\n // 181, 34: https://bitcoin.stackexchange.com/questions/1195/how-to-calculate-transaction-size-before-sending-legacy-non-segwit-p2pkh-p2sh\n fee := feeRate.Fee(uint32(msgTx.SerializeSize() + 181 + 34))\n if (vinAmount - int64(txAmountSatoshi) - int64(fee)) > 0 {\n txOutReCharge := wire.NewTxOut((vinAmount-int64(txAmountSatoshi) - int64(fee)), fromPkScript)\n msgTx.AddTxOut(txOutReCharge)\n }else {\n selectedutxoForFee, _, selectedCoinsForFee, err := CoinSelect(int64(chaininfo.Headers), fee, unselectedutxos)\n if err != nil {\n return \"\", fmt.Errorf(\"Select UTXO for fee %s\", err)\n }\n for _, coin := range selectedCoinsForFee.Coins() {\n vinAmount += int64(coin.Value())\n }\n txOutReCharge := wire.NewTxOut((vinAmount - int64(txAmountSatoshi) - int64(fee)), fromPkScript)\n msgTx.AddTxOut(txOutReCharge)\n selectedutxos = append(selectedutxos, selectedutxoForFee...)\n }\n }\n\n buf := bytes.NewBuffer(make([]byte, 0, msgTx.SerializeSize()))\n msgTx.Serialize(buf)\n rawTxHex := hex.EncodeToString(buf.Bytes())\n c.Wallet.SelectedUTXO = selectedutxos\n return rawTxHex, nil\n}", "func sendTransaction(scid string, entry string, to string, amount int64, id string) {\n\t\n\twalletURL:= \"http://127.0.0.1:30309/json_rpc\"\n\tvar amountString string\t\n\tif amount == 0 {\n\t\tamountString = \"\"\n\t} else {\t\n\t\tamountString = strconv.FormatInt(amount, 10)\n\t}\n\tdata:= PayloadGeneral{\n\t\tJsonrpc: \"2.0\", \n\t\tID: \"0\",\n\t\tMethod: \"transfer_split\",\n\t\tParams: Params2{\n\t\t\tMixin: 5,\n\t\t\tGetTxKey: true,\n\t\t\tScTx: ScTx2{\n\t\t\t\tEntrypoint: entry,\n\t\t\t\tScid: scid,\n\t\t\t\tValue: 0,\n\t\t\t\tParams: Params3{\n\t\t\t\t\t\tTo: to,\n\t\t\t\t\t\tAmount: amountString,\n\t\t\t\t\t\tID: id,\n\t\t\t\t},\n\t\t\t}, \n\t\t},\n\t}\n\n\t\n\tpayloadBytes, err := json.Marshal(data)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tbody := bytes.NewReader(payloadBytes)\n\t\n\t_, err=rpcPost(body, walletURL)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\t\n\t//println(result)\t\n\tfmt.Println(\"Transaction sent to wallet!\")\n\t\n}", "func (w *rpcWallet) SendRawTransaction(ctx context.Context, tx *wire.MsgTx, allowHighFees bool) (*chainhash.Hash, error) {\n\thash, err := w.client().SendRawTransaction(ctx, tx, allowHighFees)\n\treturn hash, translateRPCCancelErr(err)\n}", "func (eth *EthClient) SendRawTx(hex string) (common.Hash, error) {\n\tresult := common.Hash{}\n\terr := eth.Call(&result, \"eth_sendRawTransaction\", hex)\n\treturn result, err\n}", "func (h *TransactionHandler) sendTransaction(userbank_id int, transaction_id int, totalAmount int) error {\r\n\tjsonW := &SendTransaction{\r\n\t\tUserBankID: userbank_id,\r\n\t\tTransactionID: transaction_id,\r\n\t\tAmount: totalAmount,\r\n\t}\r\n\r\n\tjsonR, _ := json.Marshal(jsonW)\r\n\tjsonStr := []byte(string(jsonR))\r\n\r\n\treq, _ := http.NewRequest(\"POST\", h.Config.BankAPIUrl+\"/transaction\", bytes.NewBuffer(jsonStr))\r\n\treq.Header.Set(\"Content-Type\", \"application/json\")\r\n\r\n\tclient := &http.Client{}\r\n\t_, err2 := client.Do(req)\r\n\r\n\tif err2 != nil {\r\n\t\treturn errors.New(\"Gagal menghubungkan ke server 2\")\r\n\t}\r\n\r\n\treturn nil\r\n}", "func (api *PublicEthereumAPI) SendRawTransaction(data hexutil.Bytes) (common.Hash, error) {\n\tapi.logger.Debug(\"eth_sendRawTransaction\", \"data\", data)\n\ttx := new(evmtypes.MsgEthereumTx)\n\n\t// RLP decode raw transaction bytes\n\tif err := rlp.DecodeBytes(data, tx); err != nil {\n\t\t// Return nil is for when gasLimit overflows uint64\n\t\treturn common.Hash{}, nil\n\t}\n\n\t// Encode transaction by default Tx encoder\n\ttxEncoder := authclient.GetTxEncoder(api.clientCtx.Codec)\n\ttxBytes, err := txEncoder(tx)\n\tif err != nil {\n\t\treturn common.Hash{}, err\n\t}\n\n\t// TODO: Possibly log the contract creation address (if recipient address is nil) or tx data\n\t// If error is encountered on the node, the broadcast will not return an error\n\tres, err := api.clientCtx.BroadcastTx(txBytes)\n\tif err != nil {\n\t\treturn common.Hash{}, err\n\t}\n\n\tif res.Code != abci.CodeTypeOK {\n\t\treturn common.Hash{}, fmt.Errorf(res.RawLog)\n\t}\n\t// Return transaction hash\n\treturn common.HexToHash(res.TxHash), nil\n}", "func SendRawTx(rawTx []byte) (common.Hash, error) {\n\thash := new(common.Hash)\n\terr := ClientCall(\"ft_sendRawTransaction\", hash, hexutil.Bytes(rawTx))\n\treturn *hash, err\n}", "func broadcastTransaction(tx transaction) error {\n\tjsonTx, _ := json.Marshal(&tx)\n\tresp, err := http.Post(fmt.Sprintf(\"%s/transaction/send\", proxyHost), \"\",\n\t\tstrings.NewReader(string(jsonTx)))\n\tif err != nil {\n\t\tlog.Println(errSendingTx)\n\t\treturn err\n\t}\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tdefer func() {\n\t\t_ = resp.Body.Close()\n\t}()\n\tif err != nil {\n\t\tlog.Println(errSendingTx)\n\t\treturn err\n\t}\n\tres := string(body)\n\tfmt.Printf(\"Result: %s\\n\\r\", res)\n\treturn nil\n}", "func (c Client) SendTransaction(t txn.Transaction) (string, error) {\n\tvar result string\n\terr := c.Call(&result, \"eth_sendRawTransaction\", \"0x\"+hex.EncodeToString(t.Encode()))\n\treturn result, err\n}", "func handleWalletSendRawTransaction(s *rpcServer, cmd btcjson.Cmd, wallet walletChan) error {\n\tresult, err := handleSendRawTransaction(s, cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// The result is already guaranteed to be a valid hash string if no\n\t// error was returned above, so it's safe to ignore the error here.\n\ttxSha, _ := btcwire.NewShaHashFromStr(result.(string))\n\n\t// Request to be notified when the transaction is mined.\n\ts.ws.AddMinedTxRequest(wallet, txSha)\n\treturn nil\n}", "func handleSendRawTransaction(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {\n\tc := cmd.(*rpcmodel.SendRawTransactionCmd)\n\t// Deserialize and send off to tx relay\n\thexStr := c.HexTx\n\tif len(hexStr)%2 != 0 {\n\t\thexStr = \"0\" + hexStr\n\t}\n\tserializedTx, err := hex.DecodeString(hexStr)\n\tif err != nil {\n\t\treturn nil, rpcDecodeHexError(hexStr)\n\t}\n\tvar msgTx wire.MsgTx\n\terr = msgTx.Deserialize(bytes.NewReader(serializedTx))\n\tif err != nil {\n\t\treturn nil, &rpcmodel.RPCError{\n\t\t\tCode: rpcmodel.ErrRPCDeserialization,\n\t\t\tMessage: \"TX decode failed: \" + err.Error(),\n\t\t}\n\t}\n\n\t// Use 0 for the tag to represent local node.\n\ttx := util.NewTx(&msgTx)\n\tacceptedTxs, err := s.cfg.TxMemPool.ProcessTransaction(tx, false, 0)\n\tif err != nil {\n\t\t// When the error is a rule error, it means the transaction was\n\t\t// simply rejected as opposed to something actually going wrong,\n\t\t// so log it as such. Otherwise, something really did go wrong,\n\t\t// so log it as an actual error. In both cases, a JSON-RPC\n\t\t// error is returned to the client with the deserialization\n\t\t// error code\n\t\tif errors.As(err, &mempool.RuleError{}) {\n\t\t\tlog.Debugf(\"Rejected transaction %s: %s\", tx.ID(),\n\t\t\t\terr)\n\t\t} else {\n\t\t\tlog.Errorf(\"Failed to process transaction %s: %s\",\n\t\t\t\ttx.ID(), err)\n\t\t}\n\t\treturn nil, &rpcmodel.RPCError{\n\t\t\tCode: rpcmodel.ErrRPCVerify,\n\t\t\tMessage: \"TX rejected: \" + err.Error(),\n\t\t}\n\t}\n\n\t// When the transaction was accepted it should be the first item in the\n\t// returned array of accepted transactions. The only way this will not\n\t// be true is if the API for ProcessTransaction changes and this code is\n\t// not properly updated, but ensure the condition holds as a safeguard.\n\t//\n\t// Also, since an error is being returned to the caller, ensure the\n\t// transaction is removed from the memory pool.\n\tif len(acceptedTxs) == 0 || !acceptedTxs[0].Tx.ID().IsEqual(tx.ID()) {\n\t\terr := s.cfg.TxMemPool.RemoveTransaction(tx, true, true)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\terrStr := fmt.Sprintf(\"transaction %s is not in accepted list\",\n\t\t\ttx.ID())\n\t\treturn nil, internalRPCError(errStr, \"\")\n\t}\n\n\t// Generate and relay inventory vectors for all newly accepted\n\t// transactions into the memory pool due to the original being\n\t// accepted.\n\ts.cfg.ConnMgr.RelayTransactions(acceptedTxs)\n\n\t// Notify both websocket and getBlockTemplate long poll clients of all\n\t// newly accepted transactions.\n\ts.NotifyNewTransactions(acceptedTxs)\n\n\t// Keep track of all the sendRawTransaction request txns so that they\n\t// can be rebroadcast if they don't make their way into a block.\n\ttxD := acceptedTxs[0]\n\tiv := wire.NewInvVect(wire.InvTypeTx, (*daghash.Hash)(txD.Tx.ID()))\n\ts.cfg.ConnMgr.AddRebroadcastInventory(iv, txD)\n\n\treturn tx.ID().String(), nil\n}", "func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) error {\n\tdata, err := rlp.EncodeToBytes(tx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ec.c.CallContext(ctx, nil, \"siot_sendRawTransaction\", helper.ToHex(data))\n}", "func (cli *CommandLine) send(from, to string, amount int) {\n\tchain := blockchain.ContinueBlockChain(from)\n\tdefer chain.Database.Close()\n\n\ttx := blockchain.NewTransaction(from, to, amount, chain)\n\tchain.AddBlock([]*blockchain.Transaction{tx})\n\tfmt.Println(\"Success send token\")\n}", "func (client *Client) CommitTx(data string) (string, error) {\n\n\tresponse := &rawTxResp{}\n\terrorResp := &errorResponse{}\n\n\tresp, err := client.client.Post(\"/eth/sendRawTransaction\").BodyJSON(&rawTx{\n\t\tData: data,\n\t}).Receive(response, errorResp)\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif code := resp.StatusCode; 200 < code || code > 299 {\n\t\treturn \"\", fmt.Errorf(\"(%s) %s\", resp.Status, errorResp.Message)\n\t}\n\n\tjsontext, _ := json.Marshal(response)\n\n\tclient.DebugF(\"response(%d) :%s\", resp.StatusCode, string(jsontext))\n\n\treturn response.TxHash, nil\n}", "func (c *client) PostTx(hexTx []byte, param map[string]string) ([]TxCommitResult, error) {\n\tif len(hexTx) == 0 {\n\t\treturn nil, fmt.Errorf(\"Invalid tx %s\", hexTx)\n\t}\n\n\tbody := hexTx\n\tresp, err := c.Post(\"/broadcast\", body, param)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ttxResult := make([]TxCommitResult, 0)\n\tif err := json.Unmarshal(resp, &txResult); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn txResult, nil\n}", "func (c *Client) SendRawTransactionT(txHex string, allowHighFees bool) (string, error) {\n\treturn c.SendRawTransactionAsyncT(txHex, allowHighFees).ReceiveT()\n}", "func SendTransaction(from, to common.Address,\n\tprivKey *ecdsa.PrivateKey,\n\tethclient ComponentConfig,\n\tdata []byte) ([]byte, error) {\n\n\t// Set the parameters of the transaction\n\tvalue := big.NewInt(0)\n\tgasLimit := uint64(400000)\n\tgasPrice := big.NewInt(0)\n\n\tnonce, err := ethclient.EthereumClient.PendingNonceAt(context.Background(), from)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Create the transaction\n\ttx := types.NewTransaction(nonce, to, value, gasLimit, gasPrice, data)\n\n\t// Sign the transaction with the private key of the sender\n\tchainID, err := ethclient.EthereumClient.NetworkID(context.Background())\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn nil, err\n\t}\n\n\tsignedTx, err := types.SignTx(tx, types.NewEIP155Signer(chainID), privKey)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn nil, err\n\t}\n\n\t// Send the transaction\n\terr = ethclient.EthereumClient.SendTransaction(context.Background(), signedTx)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn nil, err\n\t}\n\n\treturn signedTx.Hash().Bytes(), nil\n}", "func (api *PublicEthereumAPI) SendTransaction(args rpctypes.SendTxArgs) (common.Hash, error) {\n\tapi.logger.Debug(\"eth_sendTransaction\", \"args\", args)\n\t// TODO: Change this functionality to find an unlocked account by address\n\n\tkey, exist := rpctypes.GetKeyByAddress(api.keys, args.From)\n\tif !exist {\n\t\tapi.logger.Debug(\"failed to find key in keyring\", \"key\", args.From)\n\t\treturn common.Hash{}, keystore.ErrLocked\n\t}\n\n\t// Mutex lock the address' nonce to avoid assigning it to multiple requests\n\tif args.Nonce == nil {\n\t\tapi.nonceLock.LockAddr(args.From)\n\t\tdefer api.nonceLock.UnlockAddr(args.From)\n\t}\n\n\t// Assemble transaction from fields\n\ttx, err := api.generateFromArgs(args)\n\tif err != nil {\n\t\tapi.logger.Debug(\"failed to generate tx\", \"error\", err)\n\t\treturn common.Hash{}, err\n\t}\n\n\tif err := tx.ValidateBasic(); err != nil {\n\t\tapi.logger.Debug(\"tx failed basic validation\", \"error\", err)\n\t\treturn common.Hash{}, err\n\t}\n\n\t// Sign transaction\n\tif err := tx.Sign(api.chainIDEpoch, key.ToECDSA()); err != nil {\n\t\tapi.logger.Debug(\"failed to sign tx\", \"error\", err)\n\t\treturn common.Hash{}, err\n\t}\n\n\t// Encode transaction by default Tx encoder\n\ttxEncoder := authclient.GetTxEncoder(api.clientCtx.Codec)\n\ttxBytes, err := txEncoder(tx)\n\tif err != nil {\n\t\treturn common.Hash{}, err\n\t}\n\n\t// Broadcast transaction in sync mode (default)\n\t// NOTE: If error is encountered on the node, the broadcast will not return an error\n\tres, err := api.clientCtx.BroadcastTx(txBytes)\n\tif err != nil {\n\t\treturn common.Hash{}, err\n\t}\n\n\tif res.Code != abci.CodeTypeOK {\n\t\treturn common.Hash{}, fmt.Errorf(res.RawLog)\n\t}\n\t// Return transaction hash\n\treturn common.HexToHash(res.TxHash), nil\n}", "func (c *Client) SendTransaction(tx *Transaction) (*HashResponse, error) {\n\trequest := c.newRequest(EthTransaction)\n\n\trequest.Params = []interface{}{\n\t\ttx,\n\t}\n\n\tresponse := &HashResponse{}\n\n\treturn response, c.send(request, response)\n}", "func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) error {\n\tdata, err := rlp.EncodeToBytes(tx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ec.c.CallContext(ctx, nil, \"eth_sendRawTransaction\", common.ToHex(data))\n}", "func (mc *MoacChain) sendTransaction(fromAddr, contractAddr, toAddr, tradePassword string, gasTotal, value float64, precision int) (tradeHash string, err error) {\n\n\tdefer func() {\n\t\tif re := recover(); re != nil {\n\t\t\terr = re.(error)\n\t\t}\n\t}()\n\n\tif precision > 4 {\n\t\treturn \"\", errors.New(\"\")\n\t}\n\n\thexStr := hex.EncodeToString(new(big.Int).Mul(big.NewInt(int64(value*10000)), big.NewInt(int64(math.Pow10(precision-4)))).Bytes())\n\n\tvar dict map[string]interface{}\n\tif contractAddr == \"\" {\n\n\t\tdict = map[string]interface{}{\n\t\t\t\"from\": fromAddr,\n\t\t\t\"to\": toAddr,\n\t\t\t\"gas\": \"0x\" + strconv.FormatInt(int64(gasTotal*50000000), 16),\n\t\t\t\"gasPrice\": \"0x4a817c800\", //20000000000\n\t\t\t\"value\": \"0x\" + hexStr,\n\t\t\t\"data\": \"0x\",\n\t\t}\n\t} else {\n\t\tplaceholderStr := \"0000000000000000000000000000000000000000000000000000000000000000\"\n\t\tnumberStr := hexStr\n\n\t\tdict = map[string]interface{}{\n\t\t\t\"from\": fromAddr,\n\t\t\t\"to\": contractAddr,\n\t\t\t\"gas\": \"0x\" + strconv.FormatInt(int64(gasTotal*50000000), 16),\n\t\t\t\"gasPrice\": \"0x4a817c800\", //20000000000\n\t\t\t\"value\": \"0x0\",\n\t\t\t\"data\": \"0xa9059cbb\" + placeholderStr[:(64-len(toAddr[2:len(toAddr)]))] + toAddr[2:len(toAddr)] + placeholderStr[:(64-len(numberStr))] + numberStr,\n\t\t}\n\t}\n\n\terr = rpcClient.Call(&tradeHash, \"personal_sendTransaction\", dict, tradePassword)\n\n\treturn tradeHash, err\n}", "func (h *Handler) SendTransaction(\n route string,\n transaction []byte,\n) (*entityApi.TransactionStatus, error) {\n\n apiResponse, err := h.apiClient.Post(route, nil, transaction)\n if err != nil {\n return nil, err\n }\n var transactionStatus entityApi.TransactionStatus\n if err := unmarshalApiResponse(apiResponse, &transactionStatus); err != nil {\n return nil, err\n }\n return &transactionStatus, nil\n}", "func (_BtlCoin *BtlCoinRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {\n\treturn _BtlCoin.Contract.BtlCoinTransactor.contract.Transact(opts, method, params...)\n}", "func sendRegisterTx(cdc *wire.Codec) client.CommandTxCallback {\n\treturn func(cmd *cobra.Command, args []string) error {\n\t\tctx := client.NewCoreContextFromViper()\n\t\tname := viper.GetString(client.FlagUser)\n\t\treferrer := viper.GetString(client.FlagReferrer)\n\t\tamount := viper.GetString(client.FlagAmount)\n\n\t\tresetPriv := secp256k1.GenPrivKey()\n\t\ttransactionPriv := secp256k1.GenPrivKey()\n\t\tappPriv := secp256k1.GenPrivKey()\n\n\t\tfmt.Println(\"reset private key is:\", strings.ToUpper(hex.EncodeToString(resetPriv.Bytes())))\n\t\tfmt.Println(\"transaction private key is:\", strings.ToUpper(hex.EncodeToString(transactionPriv.Bytes())))\n\t\tfmt.Println(\"app private key is:\", strings.ToUpper(hex.EncodeToString(appPriv.Bytes())))\n\n\t\t// // create the message\n\t\tmsg := acc.NewRegisterMsg(\n\t\t\treferrer, name, types.LNO(amount),\n\t\t\tresetPriv.PubKey(), transactionPriv.PubKey(), appPriv.PubKey())\n\n\t\t// build and sign the transaction, then broadcast to Tendermint\n\t\tres, err := ctx.SignBuildBroadcast([]sdk.Msg{msg}, cdc)\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfmt.Printf(\"Committed at block %d. Hash: %s\\n\", res.Height, res.Hash.String())\n\t\treturn nil\n\t}\n}", "func (c *CoinTest) sendTransfer(stub shim.ChaincodeStubInterface, args []string) pb.Response {\r\n\tvar A, B string // Entities\r\n\tvar Aval, Bval int // Asset holdings\r\n\tvar X int // Transaction value\r\n\tvar err error\r\n\r\n\tif len(args) != 3 {\r\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 3\")\r\n\t}\r\n\r\n\tA = args[0]\r\n\tB = args[1]\r\n\r\n\t// Get the state from the ledger\r\n\t// TODO: will be nice to have a GetAllState call to ledger\r\n\tAvalbytes, err := stub.GetState(A)\r\n\tif err != nil {\r\n\t\treturn shim.Error(\"Failed to get state\")\r\n\t}\r\n\tif Avalbytes == nil {\r\n\t\treturn shim.Error(\"Entity not found\")\r\n\t}\r\n\tAval, _ = strconv.Atoi(string(Avalbytes))\r\n\r\n\tBvalbytes, err := stub.GetState(B)\r\n\tif err != nil {\r\n\t\treturn shim.Error(\"Failed to get state\")\r\n\t}\r\n\tif Bvalbytes == nil {\r\n\t\treturn shim.Error(\"Entity not found\")\r\n\t}\r\n\tBval, _ = strconv.Atoi(string(Bvalbytes))\r\n\r\n\t// Perform the execution\r\n\tX, err = strconv.Atoi(args[2])\r\n\tif err != nil {\r\n\t\treturn shim.Error(\"Invalid transaction amount, expecting a integer value\")\r\n\t}\r\n\tAval = Aval - X\r\n\tBval = Bval + X\r\n\tfmt.Printf(\"Aval = %d, Bval = %d\\n\", Aval, Bval)\r\n\r\n\t// Write the state back to the ledger\r\n\terr = stub.PutState(A, []byte(strconv.Itoa(Aval)))\r\n\tif err != nil {\r\n\t\treturn shim.Error(err.Error())\r\n\t}\r\n\r\n\terr = stub.PutState(B, []byte(strconv.Itoa(Bval)))\r\n\tif err != nil {\r\n\t\treturn shim.Error(err.Error())\r\n\t}\r\n\r\n\t//TODO: make a transfer to update token out-of-ledger balance\r\n\r\n\treturn shim.Success(nil)\r\n}", "func SignRawTransaction(cmd *SignRawTransactionCmd, chainCfg *chaincfg.Params) (*btcjson.SignRawTransactionResult, error) {\n\tserializedTx, err := DecodeHexStr(cmd.RawTx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar tx wire.MsgTx\n\terr = tx.Deserialize(bytes.NewBuffer(serializedTx))\n\tif err != nil {\n\t\te := errors.New(\"TX decode failed\")\n\t\treturn nil, e\n\t}\n\n\tvar hashType txscript.SigHashType\n\tswitch *cmd.Flags {\n\tcase \"ALL\":\n\t\thashType = txscript.SigHashAll\n\tcase \"NONE\":\n\t\thashType = txscript.SigHashNone\n\tcase \"SINGLE\":\n\t\thashType = txscript.SigHashSingle\n\tcase \"ALL|ANYONECANPAY\":\n\t\thashType = txscript.SigHashAll | txscript.SigHashAnyOneCanPay\n\tcase \"NONE|ANYONECANPAY\":\n\t\thashType = txscript.SigHashNone | txscript.SigHashAnyOneCanPay\n\tcase \"SINGLE|ANYONECANPAY\":\n\t\thashType = txscript.SigHashSingle | txscript.SigHashAnyOneCanPay\n\tdefault:\n\t\te := errors.New(\"Invalid sighash parameter\")\n\t\treturn nil, e\n\t}\n\n\t// TODO: really we probably should look these up with btcd anyway to\n\t// make sure that they match the blockchain if present.\n\tinputs := make(map[wire.OutPoint][]byte)\n\tscripts := make(map[string][]byte)\n\tvar cmdInputs []RawTxInput\n\tif cmd.Inputs != nil {\n\t\tcmdInputs = *cmd.Inputs\n\t}\n\tfor _, rti := range cmdInputs {\n\t\tinputHash, err := chainhash.NewHashFromStr(rti.Txid)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tscript, err := DecodeHexStr(rti.ScriptPubKey)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// redeemScript is only actually used iff the user provided\n\t\t// private keys. In which case, it is used to get the scripts\n\t\t// for signing. If the user did not provide keys then we always\n\t\t// get scripts from the wallet.\n\t\t// Empty strings are ok for this one and hex.DecodeString will\n\t\t// DTRT.\n\t\tif cmd.PrivKeys != nil && len(*cmd.PrivKeys) != 0 {\n\t\t\tredeemScript, err := DecodeHexStr(rti.RedeemScript)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\taddr, err := btcutil.NewAddressScriptHash(redeemScript, chainCfg)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tscripts[addr.String()] = redeemScript\n\t\t}\n\t\tinputs[wire.OutPoint{\n\t\t\tHash: *inputHash,\n\t\t\tIndex: rti.Vout,\n\t\t}] = script\n\t}\n\n\t// Parse list of private keys, if present. If there are any keys here\n\t// they are the keys that we may use for signing. If empty we will\n\t// use any keys known to us already.\n\tvar keys map[string]*btcutil.WIF\n\tif cmd.PrivKeys != nil {\n\t\tkeys = make(map[string]*btcutil.WIF)\n\n\t\tfor _, key := range *cmd.PrivKeys {\n\t\t\twif, err := btcutil.DecodeWIF(key)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tif !wif.IsForNet(chainCfg) {\n\t\t\t\ts := \"key network doesn't match wallet's\"\n\t\t\t\treturn nil, errors.New(s)\n\t\t\t}\n\n\t\t\taddr, err := btcutil.NewAddressPubKey(wif.SerializePubKey(), chainCfg)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tkeys[addr.EncodeAddress()] = wif\n\n\t\t\tbechAddr, err := btcutil.NewAddressWitnessPubKeyHash(btcutil.Hash160(wif.PrivKey.PubKey().SerializeCompressed()), chainCfg)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrap(err, \"new bech addr err\")\n\t\t\t}\n\t\t\tkeys[bechAddr.EncodeAddress()] = wif\n\n\t\t\tfor _, rti := range cmdInputs {\n\t\t\t\tredeemScript, err := DecodeHexStr(rti.RedeemScript)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\n\t\t\t\taddr, err := btcutil.NewAddressScriptHash(redeemScript, chainCfg)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tkeys[addr.EncodeAddress()] = wif\n\t\t\t}\n\t\t}\n\n\t}\n\n\tgetScriptPubKey := func(txID string) (scriptPubKey []byte, err error) {\n\t\tfor i := range *cmd.Inputs {\n\t\t\tif (*cmd.Inputs)[i].Txid == txID {\n\t\t\t\treturn hex.DecodeString((*cmd.Inputs)[i].ScriptPubKey)\n\t\t\t}\n\t\t}\n\t\terr = errors.Errorf(\"not fund scriptPubKey: %s\", txID)\n\t\treturn\n\t}\n\tfor i := range tx.TxIn {\n\t\tvar scriptPubKey []byte\n\t\tscriptPubKey, err = getScriptPubKey(tx.TxIn[i].PreviousOutPoint.Hash.String())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tinputs[tx.TxIn[i].PreviousOutPoint] = scriptPubKey\n\t}\n\n\tfnFindTxInAmount := func(op wire.OutPoint) int64 {\n\t\tfor _, in := range *cmd.Inputs {\n\t\t\tif in.Txid == op.Hash.String() && in.Vout == op.Index {\n\t\t\t\treturn decimal.NewFromFloat(in.Amount).Shift(8).IntPart()\n\t\t\t}\n\t\t}\n\t\treturn -1\n\t}\n\n\t// All args collected. Now we can sign all the inputs that we can.\n\t// `complete' denotes that we successfully signed all outputs and that\n\t// all scripts will run to completion. This is returned as part of the\n\t// reply.\n\tsignErrs, err := signTransaction(&tx, hashType, inputs, keys, scripts, chainCfg, fnFindTxInAmount)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(signErrs) > 0 {\n\t\terrMsgs := []string{}\n\t\tfor _, e := range signErrs {\n\t\t\tif !strings.Contains(e.Error.Error(), \"not all signatures empty on failed checkmultisig\") { //忽略多重签名未完成的错误\n\t\t\t\terrMsgs = append(errMsgs, e.Error.Error())\n\t\t\t}\n\t\t}\n\t\tif len(errMsgs) > 0 {\n\t\t\treturn nil, errors.New(strings.Join(errMsgs, \",\"))\n\t\t}\n\t}\n\n\tvar buf bytes.Buffer\n\tbuf.Grow(tx.SerializeSize())\n\n\t// All returned errors (not OOM, which panics) encounted during\n\t// bytes.Buffer writes are unexpected.\n\tif err = tx.Serialize(&buf); err != nil {\n\t\treturn nil, err\n\t}\n\n\tsignErrors := make([]btcjson.SignRawTransactionError, 0, len(signErrs))\n\tfor _, e := range signErrs {\n\t\tinput := tx.TxIn[e.InputIndex]\n\t\tsignErrors = append(signErrors, btcjson.SignRawTransactionError{\n\t\t\tTxID: input.PreviousOutPoint.Hash.String(),\n\t\t\tVout: input.PreviousOutPoint.Index,\n\t\t\tScriptSig: hex.EncodeToString(input.SignatureScript),\n\t\t\tSequence: input.Sequence,\n\t\t\tError: e.Error.Error(),\n\t\t})\n\t}\n\n\treturn &btcjson.SignRawTransactionResult{\n\t\tHex: hex.EncodeToString(buf.Bytes()),\n\t\tComplete: len(signErrors) == 0,\n\t\tErrors: signErrors,\n\t}, nil\n}", "func (tr *Transactor) SendTransaction(ctx context.Context, tx *Transaction) (string, error) {\n\tif len(tx.Signature()) == 0 {\n\t\treturn \"\", errors.New(\"transaction is missing signature\")\n\t}\n\tserialised, err := json.Marshal(tx)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn tr.Client.Commit(ctx, serialised)\n}", "func (a API) CreateRawTransaction(cmd *btcjson.CreateRawTransactionCmd) (e error) {\n\tRPCHandlers[\"createrawtransaction\"].Call <-API{a.Ch, cmd, nil}\n\treturn\n}", "func (c *Jrpc) CreateRawTransaction(in *pty.ReqCreatePrivacyTx, result *interface{}) error {\n\treply, err := c.cli.CreateRawTransaction(context.Background(), in)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*result = hex.EncodeToString(types.Encode(reply))\n\treturn err\n}", "func (c *Client) SendTransaction(ctx context.Context, transaction *transactions.Transaction) (*TransactionSendResponse, error) {\n\treq := c.restClient.R().SetContext(ctx)\n\n\t//posts := make([]*transactions.Transaction, 0)\n\t//posts = append(posts, transaction)\n\n\t//resultByte,_ := transaction.Serialize()\n\tresult,err := json.Marshal(transaction)\n\t//fmt.Println(hex.EncodeToString(resultByte))\n\n\n\ttransactionResult := `{\"transaction\":` + string(result) + `}`\n\tfmt.Println(transactionResult)\n\treq.SetBody(transactionResult)\n\n\n\n\treq.SetResult(&TransactionSendResponse{})\n\treq.SetError(Error{})\n\treq.SetHeader(\"Content-Type\",\"application/json\")\n\tres, err := req.Put(\"api/transactions\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfmt.Println(string(res.Body()))\n\tif res.IsError() {\n\t\treturn res.Result().(*TransactionSendResponse), res.Error().(error)\n\t}\n\n\tif !res.Result().(*TransactionSendResponse).Success {\n\t\treturn nil, errors.New(\"SendTransaction not success\")\n\t}\n\treturn res.Result().(*TransactionSendResponse), nil\n}", "func SendTx(rpcURL string, fromSK string, toAddr string, value uint64, data []byte, gasPrice uint64, gasLimit uint64) (common.Hash, error) {\n\tclient, err := dial(rpcURL)\n\tif err != nil {\n\t\treturn common.Hash{}, err\n\t}\n\tdefer client.Close()\n\n\tprivK, _, fromAddress, err := HexToAccount(fromSK)\n\tif err != nil {\n\t\tlogrus.Errorf(\"convert hex sk to ECDSA error: %v\", err)\n\t\treturn common.Hash{}, err\n\t}\n\tvar toAddress common.Address\n\tif toAddr != \"\" {\n\t\ttoAddress = common.HexToAddress(toAddr)\n\t}\n\t//nonce\n\tnonce, err := client.PendingNonceAt(context.Background(), fromAddress)\n\tif err != nil {\n\t\treturn common.Hash{}, fmt.Errorf(\"PendingNonceAt() error: %s\", err.Error())\n\t}\n\n\t//gas price\n\tif gasPrice == 0 {\n\t\tsuggestGasPrice, err := client.SuggestGasPrice(context.Background())\n\t\tif err != nil {\n\t\t\treturn common.Hash{}, fmt.Errorf(\"SuggestGasPrice() error: %s\", err.Error())\n\t\t}\n\t\tgasPrice = suggestGasPrice.Uint64()\n\t}\n\tprice := new(big.Int)\n\tprice.SetUint64(gasPrice)\n\n\t// value\n\tval := new(big.Int)\n\tval.SetUint64(value)\n\n\tvar tx *types.Transaction\n\tif toAddr != \"\" {\n\t\ttx = types.NewTransaction(nonce, toAddress, val, gasLimit, price, data)\n\t} else {\n\t\ttx = types.NewContractCreation(nonce, val, gasLimit, price, data)\n\t}\n\tsignedTx, err := types.SignTx(tx, types.HomesteadSigner{}, privK)\n\treturn signedTx.Hash(), client.SendTransaction(context.Background(), signedTx)\n}", "func (c *GethClient) SendTransaction(ctx context.Context,\n\tfrom, to common.Address, amount *big.Int) (result *string, err error) {\n\tgas := uint64(34000)\n\n\tgasPrice, err := c.ethCli.SuggestGasPrice(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\targs := SendTxArgs{\n\t\tFrom: from.Hex(),\n\t\tTo: to.Hex(),\n\t\tGas: hexutil.EncodeUint64(gas),\n\t\tGasPrice: hexutil.EncodeBig(gasPrice),\n\t\tValue: hexutil.EncodeBig(amount),\n\t}\n\n\terr = c.rpcCli.CallContext(ctx, &result,\n\t\t\"eth_sendTransaction\", args)\n\treturn result, err\n}", "func testRawTransactionVerbose(msgTx *wire.MsgTx, txid, blockHash *chainhash.Hash,\n\tconfirmations int64) *btcjson.TxRawResult {\n\n\tvar hash string\n\tif blockHash != nil {\n\t\thash = blockHash.String()\n\t}\n\tw := bytes.NewBuffer(make([]byte, 0))\n\terr := msgTx.Serialize(w)\n\tif err != nil {\n\t\tfmt.Printf(\"error encoding MsgTx\\n\")\n\t}\n\thexTx := w.Bytes()\n\treturn &btcjson.TxRawResult{\n\t\tHex: hex.EncodeToString(hexTx),\n\t\tTxid: txid.String(),\n\t\tBlockHash: hash,\n\t\tConfirmations: uint64(confirmations),\n\t}\n\n}", "func (_BtlCoin *BtlCoinTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {\n\treturn _BtlCoin.Contract.contract.Transact(opts, method, params...)\n}", "func send(\n\tclient *http.Client,\n\tappservice config.ApplicationService,\n\ttxnID int,\n\ttransaction []byte,\n) (err error) {\n\t// PUT a transaction to our AS\n\t// https://matrix.org/docs/spec/application_service/r0.1.2#put-matrix-app-v1-transactions-txnid\n\taddress := fmt.Sprintf(\"%s/transactions/%d?access_token=%s\", appservice.URL, txnID, url.QueryEscape(appservice.HSToken))\n\treq, err := http.NewRequest(\"PUT\", address, bytes.NewBuffer(transaction))\n\tif err != nil {\n\t\treturn err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer checkNamedErr(resp.Body.Close, &err)\n\n\t// Check the AS received the events correctly\n\tif resp.StatusCode != http.StatusOK {\n\t\t// TODO: Handle non-200 error codes from application services\n\t\treturn fmt.Errorf(\"non-OK status code %d returned from AS\", resp.StatusCode)\n\t}\n\n\treturn nil\n}", "func (_BtlCoin *BtlCoinRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _BtlCoin.Contract.BtlCoinTransactor.contract.Transfer(opts)\n}", "func SendSmartContract() {\n\t// mainKeyStore := convertToKeystore(mainPrivateKey)\n\t// SendTransaction(mainKeyStore, nil, , data string, nonce uint64)\n}", "func (w *rpcWallet) SignRawTransaction(ctx context.Context, inTx *wire.MsgTx) (*wire.MsgTx, error) {\n\tbaseTx := inTx.Copy()\n\ttxHex, err := msgTxToHex(baseTx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to encode MsgTx: %w\", err)\n\t}\n\tvar res walletjson.SignRawTransactionResult\n\terr = w.rpcClientRawRequest(ctx, methodSignRawTransaction, anylist{txHex}, &res)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor i := range res.Errors {\n\t\tsigErr := &res.Errors[i]\n\t\treturn nil, fmt.Errorf(\"signing %v:%d, seq = %d, sigScript = %v, failed: %v (is wallet locked?)\",\n\t\t\tsigErr.TxID, sigErr.Vout, sigErr.Sequence, sigErr.ScriptSig, sigErr.Error)\n\t\t// Will be incomplete below, so log each SignRawTransactionError and move on.\n\t}\n\n\tif !res.Complete {\n\t\tbaseTxB, _ := baseTx.Bytes()\n\t\tw.log.Errorf(\"Incomplete raw transaction signatures (input tx: %x / incomplete signed tx: %s)\",\n\t\t\tbaseTxB, res.Hex)\n\t\treturn nil, fmt.Errorf(\"incomplete raw tx signatures (is wallet locked?)\")\n\t}\n\n\treturn msgTxFromHex(res.Hex)\n}", "func CoinbaseTX(to, data string) *Transaction {\n\tif data == \"\" {\n\t\tdata = fmt.Sprintf(\"Coin to %s\", to)\n\t}\n\ttxinput := TXInput{[]byte{}, -1, nil, []byte(data)}\n\ttxoutput := NewTXOutput(100, to)\n\ttransaction := Transaction{nil, []TXOutput{*txoutput}, []TXInput{txinput}}\n\ttransaction.SetID()\n\n\treturn &transaction\n}", "func CoinbaseTx(r, d string) *Transaction {\n\t// If the data is empty then assign data to default string\n\tif d == \"\" {\n\t\td = fmt.Sprintf(\"Coins to %s\", r)\n\t}\n\n\t// Create a transaction input and output with the given data and recepient\n\ttIn := TxInput{[]byte{}, -1, d}\n\ttOut := TxOutput{100, r}\n\n\t// Use the above to construct a new transaction\n\tt := Transaction{nil, []TxInput{tIn}, []TxOutput{tOut}}\n\n\t// Call the SetID method\n\tt.SetID()\n\n\t// Return the transaction\n\treturn &t\n}", "func (s *Socket) sendTradeTxSuccess(p *TxSuccessPayload) error {\n\tm := &Message{MessageType: TRADE_TX_SUCCESS, Payload: p}\n\n\tif err := s.connection.WriteJSON(&m); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func TestHttpBrToChain(t *testing.T) {\n\tfromStr := \"address1vpszt2jp2j8m5l3mutvqserzuu9uylmzydqaj9\"\n\ttoStr := \"address1eep59h9ez4thymept8nxl0padlrc6r78fsjmp3\"\n\tcoinstr := \"2qos\"\n\t//generate singed Tx\n\tchainid := \"capricorn-2000\"\n\tnonce := int64(1)\n\t//gas := NewBigInt(int64(0))\n\t//PrivKey output\n\tprivkey := \"sV5sRbwnR8DddL5e4UC1ntKPiOtGEaOFAqvePTfhJFI9GcC28zmPURSUI6C1oBlnk2ykBcAtIbYUazuCexWyqg==\"\n\n\tjasonpayload := LocalTxGen(fromStr, toStr, coinstr, chainid, privkey, nonce)\n\n\t//tbt := new(types.Tx)\n\t//err := Cdc.UnmarshalJSON(jasonpayload, tbt)\n\t//if err != nil {\n\t//\tfmt.Println(err)\n\t//}\n\t//\n\t//txBytes, err := Cdc.MarshalBinaryBare(jasonpayload)\n\t//if err != nil {\n\t//\tpanic(\"use cdc encode object fail\")\n\t//}\n\n\tclient := client.NewHTTP(\"tcp://192.168.1.183:26657\", \"/websocket\")\n\tresult, err := client.BroadcastTxCommit(jasonpayload)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\tt.Log(result)\n}", "func CreateRawTransaction(amount_s string, fee_s string, from_ucs_s string, to_ucs_s string, refund_ucs_s string, spendingTxs_s string) (string, error) {\n\tamount, ok := scanAmount(amount_s)\n\tif !ok {\n\t\treturn \"\", errors.New(\"could not read amount from '\" + amount_s + \"'\")\n\t}\n\tfee, ok := scanAmount(fee_s)\n\tif !ok {\n\t\treturn \"\", errors.New(\"could not read fee from '\" + fee_s + \"'\")\n\t}\n\n\tvar spendingTx []SpendingTransaction\n\terr := json.Unmarshal([]byte(spendingTxs_s), &spendingTx)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvar from_ucs types.UnlockConditions\n\terr = json.Unmarshal([]byte(from_ucs_s), &from_ucs)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tvar to_ucs types.UnlockConditions\n\terr = json.Unmarshal([]byte(to_ucs_s), &to_ucs)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tvar refund_ucs *types.UnlockConditions = nil\n\tif len(refund_ucs_s) != 0 {\n\t\trefund_ucs = &types.UnlockConditions{}\n\t\terr = json.Unmarshal([]byte(refund_ucs_s), &refund_ucs)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\toutput := types.SiacoinOutput{\n\t\tValue: amount,\n\t\tUnlockHash: to_ucs.UnlockHash(),\n\t}\n\n\ttxnBuilder, err := startTransaction()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\terr = txnBuilder.FundSiacoins(amount.Add(fee), spendingTx, from_ucs, refund_ucs)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\ttxnBuilder.AddMinerFee(fee)\n\ttxnBuilder.AddSiacoinOutput(output)\n\n\tresult, err := json.Marshal(txnBuilder)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(result), nil\n}", "func (w *xcWallet) SendTransaction(tx []byte) ([]byte, error) {\n\tbonder, ok := w.Wallet.(asset.Broadcaster)\n\tif !ok {\n\t\treturn nil, errors.New(\"wallet is not a Broadcaster\")\n\t}\n\treturn bonder.SendTransaction(tx)\n}", "func submitTx(r *http.Request, pb transactionPb.TransactionService) (proto.Message, error) {\n\t// Parse incoming JSON\n\tif err := r.ParseForm(); err != nil {\n\t\tfmt.Println(err)\n\t}\n\t// Marshall JSON request\n\tvar newTransaction Transaction\n\terr := json.Unmarshal([]byte(r.FormValue(\"transaction\")), &newTransaction)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar txProducts []*transactionPb.Product\n\tfor _, product := range newTransaction.Products {\n\t\ttxProducts = append(txProducts, &transactionPb.Product{\n\t\t\tProductName: product.ProductName,\n\t\t\tPrice: product.Price,\n\t\t})\n\t}\n\t// Create protobuf request\n\tpbRequest := transactionPb.Transaction{\n\t\tTotalPrice: newTransaction.TotalPrice,\n\t\tMerchantUuid: newTransaction.MerchantUUID,\n\t\tRecipientCryptoId: newTransaction.RecipientCryptoID,\n\t\tProducts: txProducts,\n\t}\n\t// Call RPC function and get protobuf response\n\tpbResponse, err := pb.SubmitTx(context.Background(), &transactionPb.SubmitTxReq{\n\t\tTransaction: &pbRequest,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfmt.Println(pbResponse)\n\treturn pbResponse, nil\n}", "func (c *Client) SendTransaction(ctx context.Context, tx types.Transaction) (string, error) {\n\trawTx, err := tx.Serialize()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to serialize tx, err: %v\", err)\n\t}\n\tres, err := c.RpcClient.SendTransactionWithConfig(\n\t\tctx,\n\t\tbase64.StdEncoding.EncodeToString(rawTx),\n\t\trpc.SendTransactionConfig{\n\t\t\tEncoding: rpc.SendTransactionConfigEncodingBase64,\n\t\t},\n\t)\n\terr = checkRpcResult(res.GeneralResponse, err)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn res.Result, nil\n}", "func (e Endpoints) SendBTCTx(ctx context.Context, signedTxHex string) (txID string, err error) {\n\trequest := SendBTCTxRequest{SignedTxHex: signedTxHex}\n\tresponse, err := e.SendBTCTxEndpoint(ctx, request)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn response.(SendBTCTxResponse).TxID, nil\n}", "func (s *Sudt) Send(client rpc.Client) (*types.Hash, error) {\n\treturn client.SendTransaction(context.Background(), s.tx)\n}", "func SendRaw(client ioctl.Client, cmd *cobra.Command, selp *iotextypes.Action) error {\n\tcli, err := client.APIServiceClient()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to connect to endpoint\")\n\t}\n\n\tctx := context.Background()\n\tif jwtMD, err := util.JwtAuth(); err == nil {\n\t\tctx = metautils.NiceMD(jwtMD).ToOutgoing(ctx)\n\t}\n\n\t_, err = cli.SendAction(ctx, &iotexapi.SendActionRequest{Action: selp})\n\tif err != nil {\n\t\treturn handleClientRequestError(err, \"SendAction\")\n\t}\n\n\tshash := hash.Hash256b(byteutil.Must(proto.Marshal(selp)))\n\ttxhash := hex.EncodeToString(shash[:])\n\tURL := \"https://\"\n\tendpoint := client.Config().Endpoint\n\texplorer := client.Config().Explorer\n\tswitch explorer {\n\tcase \"iotexscan\":\n\t\tif strings.Contains(endpoint, \"testnet\") {\n\t\t\tURL += \"testnet.\"\n\t\t}\n\t\tURL += \"iotexscan.io/action/\" + txhash\n\tcase \"iotxplorer\":\n\t\tURL = \"iotxplorer.io/actions/\" + txhash\n\tdefault:\n\t\tURL = explorer + txhash\n\t}\n\tcmd.Printf(\"Action has been sent to blockchain.\\nWait for several seconds and query this action by hash: %s\\n\", URL)\n\treturn nil\n}", "func (b *Backend) SendTransaction(ctx context.Context, tx sdk.Transaction) error {\n\terr := b.emulator.AddTransaction(tx)\n\tif err != nil {\n\t\tswitch t := err.(type) {\n\t\tcase *emulator.DuplicateTransactionError:\n\t\t\treturn status.Error(codes.InvalidArgument, err.Error())\n\t\tcase *types.FlowError:\n\t\t\t// TODO - confirm these\n\t\t\tswitch t.FlowError.(type) {\n\t\t\tcase *fvmerrors.AccountAuthorizationError,\n\t\t\t\t*fvmerrors.InvalidEnvelopeSignatureError,\n\t\t\t\t*fvmerrors.InvalidPayloadSignatureError,\n\t\t\t\t*fvmerrors.InvalidProposalSignatureError,\n\t\t\t\t*fvmerrors.AccountNotFoundError,\n\t\t\t\t*fvmerrors.AccountPublicKeyNotFoundError,\n\t\t\t\t*fvmerrors.InvalidProposalSeqNumberError,\n\t\t\t\t*fvmerrors.InvalidAddressError:\n\n\t\t\t\treturn status.Error(codes.InvalidArgument, err.Error())\n\t\t\tdefault:\n\t\t\t\treturn status.Error(codes.Internal, err.Error())\n\t\t\t}\n\t\tdefault:\n\t\t\treturn status.Error(codes.Internal, err.Error())\n\t\t}\n\t} else {\n\t\tb.logger.\n\t\t\tWithField(\"txID\", tx.ID().String()).\n\t\t\tDebug(\"️✉️ Transaction submitted\")\n\t}\n\n\tif b.automine {\n\t\tb.CommitBlock()\n\t}\n\n\treturn nil\n}", "func (n *nodeEOS) pushTransaction(contract, from, to, memo, symbol string, isMain bool, amount, fee string) (string, error) {\n\tapi := n.api\n\n\tapi.WalletUnlock(\"default\", n.coin.Password)\n\tdefer func() {\n\t\tapi.WalletLock(\"default\")\n\t}()\n\n\tquantity, err := eos.NewAsset(amount + \" \" + symbol)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\taction := eostoken.NewTransferCommon(eos.AN(contract), eos.AN(from), eos.AN(to), quantity, memo)\n\tpushed, err := api.SignPushActions(action)\n\tutils.Logger.Info(\"pushed action:%v, error:%v\", pushed, err)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn pushed.TransactionID, nil\n}", "func (_Aggregator *AggregatorTransactor) Transmit(opts *bind.TransactOpts, _report []byte, _rs [][32]byte, _ss [][32]byte, _rawVs [32]byte) (*types.Transaction, error) {\n\treturn _Aggregator.contract.Transact(opts, \"transmit\", _report, _rs, _ss, _rawVs)\n}", "func bitcoinGetRawTransaction(hash string, reply *bitcoinTransaction) error {\n\tglobalBitcoinData.Lock()\n\tdefer globalBitcoinData.Unlock()\n\n\tif !globalBitcoinData.initialised {\n\t\treturn fault.ErrNotInitialised\n\t}\n\n\targuments := []interface{}{\n\t\thash,\n\t\t1,\n\t}\n\treturn bitcoinCall(\"getrawtransaction\", arguments, reply)\n}", "func (t *SimpleChaincode) submitTransaction(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) {\n\n\tvar err error\n\tfmt.Println(\"Running submitTransaction\")\n\n\tif len(args) != 10 {\n\t\tfmt.Println(\"Incorrect number of arguments. Expecting 10 - MT103 format\")\n\t\treturn nil, errors.New(\"Incorrect number of arguments. Expecting 10 - MT103 format\")\n\t}\n\n\tvar tx Transaction\n\ttx.RefNumber = args[0]\n\ttx.OpCode = args[1]\n\ttx.VDate = args[2]\n\ttx.Currency = args[3]\n\ttx.Sender = args[5]\n\ttx.Receiver = args[6]\n\ttx.OrdCust = args[7]\n\ttx.BenefCust = args[8]\n\ttx.DetCharges = args[9]\n\ttx.StatusCode = 1\n\ttx.StatusMsg = \"Transaction Completed\"\n\n\tamountValue, err := strconv.ParseFloat(args[4], 64)\n\tif err != nil {\n\t\ttx.StatusCode = 0\n\t\ttx.StatusMsg = \"Invalid Amount\"\n\t} else {\n\t\ttx.Amount = amountValue\n\t}\n\n\t// Check Nostro Account\n\trfidBytes, err := stub.GetState(tx.Receiver)\n\tif err != nil {\n\t\treturn nil, errors.New(\"submitTransaction Failed to get Financial Institution\")\n\t}\n\tvar rfid FinancialInst\n\tfmt.Println(\"submitTransaction Unmarshalling Financial Institution\")\n\terr = json.Unmarshal(rfidBytes, &rfid)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfound := false\n\tamountSent := 0.0\n\tfor i := range rfid.Accounts {\n\n\t\tif rfid.Accounts[i].Holder == tx.Sender {\n\t\t\tfmt.Println(\"submitTransaction Find Sender Nostro Account\")\n\t\t\tfound = true\n\t\t\tfxRate, err := getFXRate(tx.Currency, rfid.Accounts[i].Currency)\n\t\t\tfmt.Println(\"submitTransaction Get FX Rate \" + FloatToString(fxRate))\n\t\t\t//Transaction currency invalid\n\t\t\tif err != nil {\n\t\t\t\ttx.StatusCode = 0\n\t\t\t\ttx.StatusMsg = \"Invalid Currency\"\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tamountSent = tx.Amount * fxRate\n\t\t\tfmt.Println(\"submitTransaction Amount To Send \" + FloatToString(amountSent))\n\t\t\tif rfid.Accounts[i].CashBalance-amountSent < 0 {\n\t\t\t\ttx.StatusCode = 0\n\t\t\t\ttx.StatusMsg = \"Insufficient funds on Nostro Account\"\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tif !found {\n\t\ttx.StatusCode = 0\n\t\ttx.StatusMsg = \"Nostro Account for \" + tx.Sender + \" doesn't exist in \" + tx.Receiver\n\t}\n\n\t//Check Vostro Account\n\tsfidBytes, err := stub.GetState(tx.Sender)\n\tif err != nil {\n\t\treturn nil, errors.New(\"submitTransaction Failed to get Financial Institution\")\n\t}\n\tvar sfid FinancialInst\n\tfmt.Println(\"submitTransaction Unmarshalling Financial Institution\")\n\terr = json.Unmarshal(sfidBytes, &sfid)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfound = false\n\tfor i := range sfid.Accounts {\n\n\t\tif sfid.Accounts[i].Holder == tx.Receiver {\n\t\t\tfmt.Println(\"submitTransaction Find Vostro Account\")\n\t\t\tfound = true\n\n\t\t\tif sfid.Accounts[i].Currency != tx.Currency {\n\t\t\t\ttx.StatusCode = 0\n\t\t\t\ttx.StatusMsg = tx.Receiver + \" doesn't have an account in \" + tx.Currency + \" with \" + tx.Sender\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tif !found {\n\t\ttx.StatusCode = 0\n\t\ttx.StatusMsg = \"Vostro Account for \" + tx.Receiver + \" doesn't exist in \" + tx.Sender\n\t}\n\n\tif tx.StatusCode == 1 {\n\t\t//Credit and debit Accounts\n\t\tfmt.Println(\"submitTransaction Credit Vostro Account\")\n\t\t_, err = t.creditVostroAccount(stub, tx.Sender, tx.Receiver, tx.Amount)\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"submitTransaction Failed to Credit Vostro Account\")\n\t\t}\n\n\t\tfmt.Println(\"submitTransaction Debit Nostro Account\")\n\t\t_, err = t.debitNostroAccount(stub, tx.Sender, tx.Receiver, amountSent)\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"submitTransaction Failed to Debit Nostro Account\")\n\t\t}\n\t}\n\n\t//get the AllTransactions index\n\tallTxAsBytes, err := stub.GetState(\"allTx\")\n\tif err != nil {\n\t\treturn nil, errors.New(\"submitTransaction Failed to get all Transactions\")\n\t}\n\n\t//Commit transaction to ledger\n\tfmt.Println(\"submitTransaction Commit Transaction To Ledger\")\n\tvar txs AllTransactions\n\tjson.Unmarshal(allTxAsBytes, &txs)\n\t// txs.Transactions = append(txs.Transactions, tx)\n\ttxs.Transactions = append([]Transaction{tx}, txs.Transactions...)\n\ttxsAsBytes, _ := json.Marshal(txs)\n\terr = stub.PutState(\"allTx\", txsAsBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn nil, nil\n}", "func (as *AddrServer) HandleTransactionSend(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tvar tx TxPost\n\n\t// Read post body\n\tb, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tw.WriteHeader(400)\n\t\tw.Write(NewPostError(\"unable to read post body\", err))\n\t\treturn\n\t}\n\n\t// Unmarshal\n\terr = json.Unmarshal(b, &tx)\n\tif err != nil {\n\t\tw.WriteHeader(400)\n\t\tw.Write(NewPostError(\"unable to unmarshall body\", err))\n\t\treturn\n\t}\n\n\t// Convert hex to string\n\tdec, err := hex.DecodeString(tx.Tx)\n\tif err != nil {\n\t\tw.WriteHeader(400)\n\t\tw.Write(NewPostError(\"unable to decode hex string\", err))\n\t\treturn\n\t}\n\n\t// Convert tansaction to send format\n\ttxn, err := btcutil.NewTxFromBytes(dec)\n\tif err != nil {\n\t\tw.WriteHeader(400)\n\t\tw.Write(NewPostError(\"unable to parse transaction\", err))\n\t\treturn\n\t}\n\n\tret, err := as.Client.SendRawTransaction(txn.MsgTx(), true)\n\tif err != nil {\n\t\tw.WriteHeader(400)\n\t\tw.Write(NewPostError(\"unable to post transaction to node\", err))\n\t\treturn\n\t}\n\n\tout, _ := json.Marshal(ret)\n\tw.Write(out)\n}", "func (wm *WalletManager) BroadcastTransaction(txHex string) (string, error) {\n\t//txBytes, err := hex.DecodeString(txHex)\n\t//if err != nil {\n\t//\treturn \"\", fmt.Errorf(\"transaction decode failed, unexpected error: %v\", err)\n\t//}\n\t//signedEncodedTx := aeternity.Encode(aeternity.PrefixTransaction, txBytes)\n\t// calculate the hash of the decoded txRLP\n\t//rlpTxHashRaw := owcrypt.Hash(txBytes, 32, owcrypt.HASH_ALG_BLAKE2B)\n\t//// base58/64 encode the hash with the th_ prefix\n\t//signedEncodedTxHash := aeternity.Encode(aeternity.PrefixTransactionHash, rlpTxHashRaw)\n\n\t// send it to the network\n\t//return postTransaction(wm.Api.Node, signedEncodedTx)\n\treturn \"\", nil\n}", "func CoinbaseTx(to, data string) *Transaction {\n\tif data == \"\" {\n\t\trandData := make([]byte, 24)\n\t\t_, err := rand.Read(randData)\n\t\t// Handle(err)\n\t\tfmt.Println(err)\n\t\tdata = fmt.Sprintf(\"%x\", randData)\n\t}\n\n\ttxin := TxInput{[]byte{}, -1, nil, []byte(data)}\n\ttxout := NewTxOutput(100, to)\n\ttx := Transaction{nil, []TxInput{txin}, []TxOutput{*txout}}\n\ttx.ID = tx.Hash()\n\n\treturn &tx\n}", "func (b backend) SendTransaction(ctx context.Context, tx *types.Transaction) error {\n\tdefer b.Commit()\n\treturn b.SimulatedBackend.SendTransaction(ctx, tx)\n}", "func (_m *CommMock) SendTransaction(targetID uint64, request []byte) {\n\t_m.Called(targetID, request)\n}", "func (c BitcoinCoreChain) SignedTx(rawTxHex, wif string, options *ChainsOptions) (string, error) {\n // https://www.experts-exchange.com/questions/29108851/How-to-correctly-create-and-sign-a-Bitcoin-raw-transaction-using-Btcutil-library.html\n tx, err := DecodeBtcTxHex(rawTxHex)\n if err != nil {\n return \"\", fmt.Errorf(\"Fail to decode raw tx %s\", err)\n }\n\n ecPriv, err := btcutil.DecodeWIF(wif)\n if err != nil {\n return \"\", fmt.Errorf(\"Fail to decode wif %s\", err)\n }\n fromAddress, _ := btcutil.DecodeAddress(options.From, c.Mode)\n subscript, _ := txscript.PayToAddrScript(fromAddress)\n for i, txIn := range tx.MsgTx().TxIn {\n if txIn.SignatureScript, err = txscript.SignatureScript(tx.MsgTx(), i, subscript, txscript.SigHashAll, ecPriv.PrivKey, true); err != nil{\n return \"\", fmt.Errorf(\"SignatureScript %s\", err)\n }\n }\n\n //Validate signature\n flags := txscript.StandardVerifyFlags\n vm, err := txscript.NewEngine(subscript, tx.MsgTx(), 0, flags, nil, nil, options.VinAmount)\n if err != nil {\n return \"\", fmt.Errorf(\"Txscript.NewEngine %s\", err)\n }\n if err := vm.Execute(); err != nil {\n return \"\", fmt.Errorf(\"Fail to sign tx %s\", err)\n }\n\n // txToHex\n buf := bytes.NewBuffer(make([]byte, 0, tx.MsgTx().SerializeSize()))\n tx.MsgTx().Serialize(buf)\n txHex := hex.EncodeToString(buf.Bytes())\n return txHex, nil\n}", "func (_Lelecoin *LelecoinRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {\n\treturn _Lelecoin.Contract.LelecoinTransactor.contract.Transact(opts, method, params...)\n}", "func (_BtlCoin *BtlCoinTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _BtlCoin.Contract.contract.Transfer(opts)\n}", "func (a API) SendRawTransactionChk() (isNew bool) {\n\tselect {\n\tcase o := <-a.Ch.(chan SendRawTransactionRes):\n\t\tif o.Err != nil {\n\t\t\ta.Result = o.Err\n\t\t} else {\n\t\t\ta.Result = o.Res\n\t\t}\n\t\tisNew = true\n\tdefault:\n\t}\n\treturn\n}", "func (c *Client) SendRowTransaction(tx Data) (*HashResponse, error) {\n\trequest := c.newRequest(EthSendRawTransaction)\n\n\trequest.Params = []interface{}{\n\t\ttx,\n\t}\n\n\tresponse := &HashResponse{}\n\n\treturn response, c.send(request, response)\n}", "func (tx *EthereumTx) ToRawTransaction() (string, error) {\n\n\t// Decode Address from hex\n\t// TODO: should be specialized type on EthereumTx so i don't need to always do this\n\tto := tx.Recipient\n\tif strings.HasPrefix(to, \"0x\") || strings.HasPrefix(to, \"0X\") {\n\t\tto = to[2:]\n\t}\n\taddrBytes := make([]byte, 20)\n\tif _, err := hex.Decode(addrBytes, []byte(to)); err != nil {\n\t\treturn \"\", errors.New(\"malformed to address:\" + err.Error())\n\t}\n\n\t// Prepare tx data to be encoded. Fields must be in the following order\n\t// nonce, gasPrice, gasLimit, to, value, data, sig v, sig r, sig s\n\tbuf := new(bytes.Buffer)\n\tvar arr []interface{}\n\tarr = append(arr, tx.Nonce)\n\tarr = append(arr, tx.GasPrice)\n\tarr = append(arr, tx.GasLimit)\n\tarr = append(arr, addrBytes)\n\tarr = append(arr, tx.Amount)\n\tarr = append(arr, tx.Data)\n\tarr = append(arr, tx.V)\n\tarr = append(arr, tx.R)\n\tarr = append(arr, tx.S)\n\n\tif err := rlp.Encode(buf, arr); err != nil {\n\t\treturn \"\", errors.New(\"malformed tx:\" + err.Error())\n\t}\n\n\treturn \"0x\" + hex.EncodeToString(buf.Bytes()), nil\n}", "func genStdSendTx(cdc *amino.Codec, sendTx txs.ITx, priKey ed25519.PrivKeyEd25519, tochainid string, fromchainid string, nonce int64) *txs.TxStd {\n\tgas := qbasetypes.NewInt(int64(config.MaxGas))\n\tstx := txs.NewTxStd(sendTx, tochainid, gas)\n\tsignature, _ := stx.SignTx(priKey, nonce, fromchainid, tochainid)\n\tstx.Signature = []txs.Signature{txs.Signature{\n\t\tPubkey: priKey.PubKey(),\n\t\tSignature: signature,\n\t\tNonce: nonce,\n\t}}\n\n\treturn stx\n}", "func (_WandappETH *WandappETHRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {\n\treturn _WandappETH.Contract.WandappETHTransactor.contract.Transact(opts, method, params...)\n}", "func (t *TxAPI) Send(data map[string]interface{}) (*api.ResultHash, error) {\n\tout, statusCode, err := t.c.call(\"tx_sendPayload\", data)\n\tif err != nil {\n\t\treturn nil, makeReqErrFromCallErr(statusCode, err)\n\t}\n\n\tvar result api.ResultHash\n\tif err = util.DecodeMap(out, &result); err != nil {\n\t\treturn nil, errors.ReqErr(500, ErrCodeDecodeFailed, \"\", err.Error())\n\t}\n\n\treturn &result, nil\n}", "func (a API) SendRawTransactionGetRes() (out *None, e error) {\n\tout, _ = a.Result.(*None)\n\te, _ = a.Result.(error)\n\treturn \n}", "func (s *Socket) sendOrderTxSuccess(p *TxSuccessPayload) error {\n\tm := &Message{MessageType: ORDER_TX_SUCCESS, Payload: p}\n\n\tif err := s.connection.WriteJSON(&m); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (service *Stainless) ExecuteTransaction(\n\treq *proto.TransactionRequest) (network.Message, error) {\n\tabi, err := abi.JSON(strings.NewReader(req.Abi))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\targs, err := bevm.DecodeEvmArgs(req.Args, abi.Methods[req.Method].Inputs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcallData, err := abi.Pack(req.Method, args...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttx := types.NewTransaction(req.Nonce,\n\t\tcommon.BytesToAddress(req.ContractAddress),\n\t\tbig.NewInt(int64(req.Amount)),\n\t\treq.GasLimit, big.NewInt(int64(req.GasPrice)), callData)\n\n\tsigner := types.HomesteadSigner{}\n\thashedTx := signer.Hash(tx)\n\n\tunsignedBuffer, err := tx.MarshalJSON()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlog.Lvl4(\"Returning\", unsignedBuffer, hashedTx)\n\n\treturn &proto.TransactionHashResponse{Transaction: unsignedBuffer,\n\t\tTransactionHash: hashedTx[:]}, nil\n}", "func (_Lelecoin *LelecoinTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {\n\treturn _Lelecoin.Contract.contract.Transact(opts, method, params...)\n}", "func (_Ethdkg *EthdkgRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {\n\treturn _Ethdkg.Contract.EthdkgTransactor.contract.Transact(opts, method, params...)\n}", "func (pool *TxPool) processTransaction(tx *ethutil.Transaction) error {\n\t// Get the last block so we can retrieve the sender and receiver from\n\t// the merkle trie\n\tblock := pool.server.blockManager.bc.LastBlock\n\t// Something has gone horribly wrong if this happens\n\tif block == nil {\n\t\treturn errors.New(\"No last block on the block chain\")\n\t}\n\n\tvar sender, receiver *ethutil.Ether\n\n\t// Get the sender\n\tdata := block.State().Get(string(tx.Sender()))\n\t// If it doesn't exist create a new account. Of course trying to send funds\n\t// from this account will fail since it will hold 0 Wei\n\tif data == \"\" {\n\t\tsender = ethutil.NewEther(big.NewInt(0))\n\t} else {\n\t\tsender = ethutil.NewEtherFromData([]byte(data))\n\t}\n\t// Defer the update. Whatever happens it should be persisted\n\tdefer block.State().Update(string(tx.Sender()), string(sender.RlpEncode()))\n\n\t// Make sure there's enough in the sender's account. Having insufficient\n\t// funds won't invalidate this transaction but simple ignores it.\n\tif sender.Amount.Cmp(tx.Value) < 0 {\n\t\treturn errors.New(\"Insufficient amount in sender's account\")\n\t}\n\n\t// Subtract the amount from the senders account\n\tsender.Amount.Sub(sender.Amount, tx.Value)\n\t// Increment the nonce making each tx valid only once to prevent replay\n\t// attacks\n\tsender.Nonce += 1\n\n\t// Get the receiver\n\tdata = block.State().Get(tx.Recipient)\n\t// If the receiver doesn't exist yet, create a new account to which the\n\t// funds will be send.\n\tif data == \"\" {\n\t\treceiver = ethutil.NewEther(big.NewInt(0))\n\t} else {\n\t\treceiver = ethutil.NewEtherFromData([]byte(data))\n\t}\n\t// Defer the update\n\tdefer block.State().Update(tx.Recipient, string(receiver.RlpEncode()))\n\n\t// Add the amount to receivers account which should conclude this transaction\n\treceiver.Amount.Add(receiver.Amount, tx.Value)\n\n\treturn nil\n}", "func convertRawTransaction(rawTx string) (*bitcoin.Transaction, error) {\n\tt, err := decodeTransaction(rawTx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode a transaction: [%w]\", err)\n\t}\n\n\tresult := &bitcoin.Transaction{\n\t\tVersion: int32(t.Version),\n\t\tLocktime: t.LockTime,\n\t}\n\n\tfor _, vin := range t.TxIn {\n\t\tinput := &bitcoin.TransactionInput{\n\t\t\tOutpoint: &bitcoin.TransactionOutpoint{\n\t\t\t\tTransactionHash: bitcoin.Hash(vin.PreviousOutPoint.Hash),\n\t\t\t\tOutputIndex: vin.PreviousOutPoint.Index,\n\t\t\t},\n\t\t\tSignatureScript: vin.SignatureScript,\n\t\t\tWitness: vin.Witness,\n\t\t\tSequence: vin.Sequence,\n\t\t}\n\n\t\tresult.Inputs = append(result.Inputs, input)\n\t}\n\n\tfor _, vout := range t.TxOut {\n\t\toutput := &bitcoin.TransactionOutput{\n\t\t\tValue: vout.Value,\n\t\t\tPublicKeyScript: vout.PkScript,\n\t\t}\n\n\t\tresult.Outputs = append(result.Outputs, output)\n\t}\n\n\treturn result, nil\n}", "func (_WandappETH *WandappETHTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {\n\treturn _WandappETH.Contract.contract.Transact(opts, method, params...)\n}", "func PostTx(tx core.Transaction, fluff bool) error {\n\tclient := RPCHTTPClient{URL: url}\n\tparams := []interface{}{tx, fluff}\n\tparamsBytes, err := json.Marshal(params)\n\tif err != nil {\n\t\treturn err\n\t}\n\tenvl, err := client.Request(\"post_tx\", paramsBytes)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif envl == nil {\n\t\treturn errors.New(\"OwnerAPI: Empty RPC Response from grin-wallet\")\n\t}\n\tif envl.Error != nil {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"code\": envl.Error.Code,\n\t\t\t\"message\": envl.Error.Message,\n\t\t}).Error(\"OwnerAPI: RPC Error during PostTx\")\n\t\treturn errors.New(string(envl.Error.Code) + \"\" + envl.Error.Message)\n\t}\n\tvar result Result\n\tif err = json.Unmarshal(envl.Result, &result); err != nil {\n\t\treturn err\n\t}\n\tif result.Err != nil {\n\t\treturn errors.New(string(result.Err))\n\t}\n\treturn nil\n}", "func sendTransaction(t *Transaction) {\n\ttransactionToSend := &Message{}\n\ttransactionToSend.Transaction = t\n\tfor _, conn := range connections{\n\t\tgo send(transactionToSend, conn)\n\t}\n\ttransactionIsUsed[t.Id] = true\n}", "func (c *Client) QuickSendTransaction(ctx context.Context, param QuickSendTransactionParam) (string, error) {\n\trecentBlockhashRes, err := c.GetRecentBlockhash(ctx)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get recent blockhash, err: %v\", err)\n\t}\n\ttx, err := types.NewTransaction(types.NewTransactionParam{\n\t\tMessage: types.NewMessage(types.NewMessageParam{\n\t\t\tInstructions: param.Instructions,\n\t\t\tFeePayer: param.FeePayer,\n\t\t\tRecentBlockhash: recentBlockhashRes.Blockhash,\n\t\t}),\n\t\tSigners: param.Signers,\n\t})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to create new tx, err: %v\", err)\n\t}\n\trawTx, err := tx.Serialize()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to serialize tx, err: %v\", err)\n\t}\n\tres, err := c.RpcClient.SendTransactionWithConfig(\n\t\tctx,\n\t\tbase64.StdEncoding.EncodeToString(rawTx),\n\t\trpc.SendTransactionConfig{Encoding: rpc.SendTransactionConfigEncodingBase64},\n\t)\n\terr = checkRpcResult(res.GeneralResponse, err)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn res.Result, nil\n}", "func (suite *Suite) SendTx(\n\tcontractAddr types.InternalEVMAddress,\n\tfrom common.Address,\n\tsignerKey *ethsecp256k1.PrivKey,\n\ttransferData []byte,\n) (*evmtypes.MsgEthereumTxResponse, error) {\n\tctx := sdk.WrapSDKContext(suite.Ctx)\n\tchainID := suite.App.GetEvmKeeper().ChainID()\n\n\targs, err := json.Marshal(&evmtypes.TransactionArgs{\n\t\tTo: &contractAddr.Address,\n\t\tFrom: &from,\n\t\tData: (*hexutil.Bytes)(&transferData),\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tgasRes, err := suite.QueryClientEvm.EstimateGas(ctx, &evmtypes.EthCallRequest{\n\t\tArgs: args,\n\t\tGasCap: config.DefaultGasCap,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tnonce := suite.App.GetEvmKeeper().GetNonce(suite.Ctx, suite.Address)\n\n\tbaseFee := suite.App.GetFeeMarketKeeper().GetBaseFee(suite.Ctx)\n\tsuite.Require().NotNil(baseFee, \"base fee is nil\")\n\n\t// Mint the max gas to the FeeCollector to ensure balance in case of refund\n\tsuite.MintFeeCollector(sdk.NewCoins(\n\t\tsdk.NewCoin(\n\t\t\t\"ukava\",\n\t\t\tsdkmath.NewInt(baseFee.Int64()*int64(gasRes.Gas*2)),\n\t\t)))\n\n\tercTransferTx := evmtypes.NewTx(\n\t\tchainID,\n\t\tnonce,\n\t\t&contractAddr.Address,\n\t\tnil, // amount\n\t\tgasRes.Gas*2, // gasLimit, TODO: runs out of gas with just res.Gas, ex: estimated was 21572 but used 24814\n\t\tnil, // gasPrice\n\t\tsuite.App.GetFeeMarketKeeper().GetBaseFee(suite.Ctx), // gasFeeCap\n\t\tbig.NewInt(1), // gasTipCap\n\t\ttransferData,\n\t\t&ethtypes.AccessList{}, // accesses\n\t)\n\n\tercTransferTx.From = hex.EncodeToString(signerKey.PubKey().Address())\n\terr = ercTransferTx.Sign(ethtypes.LatestSignerForChainID(chainID), etherminttests.NewSigner(signerKey))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trsp, err := suite.App.GetEvmKeeper().EthereumTx(ctx, ercTransferTx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// Do not check vm error here since we want to check for errors later\n\n\treturn rsp, nil\n}", "func SubmitTransaction(peers []*peer.Connection, o *orderer.Connection, channel, chaincode, function string, args ...string) ([]byte, error) {\n\tbyteArgs := [][]byte{}\n\tfor _, arg := range args {\n\t\tbyteArgs = append(byteArgs, []byte(arg))\n\t}\n\tproposal, responses, endorsements, err := executeTransaction(peers, o, channel, chaincode, function, byteArgs...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = orderTransaction(peers, o, channel, proposal, responses, endorsements)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn responses[0].Response.Payload, nil\n}", "func MakeTransactionBTC(from, to string, amount, fee uint64, unspent []Unspent) ([]byte, error) {\n\tcoins, err := ToUTXO(unspent, from)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn nil, err\n\t}\n\t//prepare send addresses and its amount.\n\t//last address must be refund address and its amount must be 0.\n\tsend := []*tx.Send{\n\t\t&tx.Send{\n\t\t\tAddr: to,\n\t\t\tAmount: amount,\n\t\t},\n\t\t&tx.Send{\n\t\t\tAddr: \"\",\n\t\t\tAmount: 0,\n\t\t},\n\t}\n\tlocktime := uint32(0)\n\ttx, err := tx.NewP2PK(fee, coins, locktime, send...)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn nil, err\n\t}\n\treturn tx.Pack()\n}", "func (s *Server) GenericSendCoin(gscp GenericSendCoinParams, _ *struct{}) (err error) {\n\t// Get the wallet associated with the id.\n\tgw, err := s.genericWallet(gscp.GWID)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Get the current height of the quorum, for setting the deadline on\n\t// the script input.\n\tinput := state.ScriptInput{\n\t\tWalletID: gw.WalletID,\n\t\tInput: delta.SendCoinInput(gscp.Destination, gscp.Amount),\n\t\tDeadline: s.metadata.Height + state.MaxDeadline,\n\t}\n\terr = delta.SignScriptInput(&input, gw.SecretKey)\n\tif err != nil {\n\t\treturn\n\t}\n\n\ts.broadcast(network.Message{\n\t\tProc: \"Participant.AddScriptInput\",\n\t\tArgs: input,\n\t\tResp: nil,\n\t})\n\treturn\n}", "func (_EthCrossChain *EthCrossChainTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {\n\treturn _EthCrossChain.Contract.contract.Transact(opts, method, params...)\n}", "func (owner *WalletOwnerAPI) PostTx(slate slateversions.SlateV4, fluff bool) error {\n\tparams := struct {\n\t\tToken string `json:\"token\"`\n\t\tSlate slateversions.SlateV4 `json:\"slate\"`\n\t\tFluff bool `json:\"fluff\"`\n\t}{\n\t\tToken: owner.token,\n\t\tSlate: slate,\n\t\tFluff: fluff,\n\t}\n\tparamsBytes, err := json.Marshal(params)\n\tif err != nil {\n\t\treturn err\n\t}\n\tenvl, err := owner.client.EncryptedRequest(\"post_tx\", paramsBytes, owner.sharedSecret)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif envl == nil {\n\t\treturn errors.New(\"WalletOwnerAPI: Empty RPC Response from grin-wallet\")\n\t}\n\tif envl.Error != nil {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"code\": envl.Error.Code,\n\t\t\t\"message\": envl.Error.Message,\n\t\t}).Error(\"WalletOwnerAPI: RPC Error during PostTx\")\n\t\treturn errors.New(string(envl.Error.Code) + \"\" + envl.Error.Message)\n\t}\n\tvar result Result\n\tif err = json.Unmarshal(envl.Result, &result); err != nil {\n\t\treturn err\n\t}\n\tif result.Err != nil {\n\t\treturn errors.New(string(result.Err))\n\t}\n\treturn nil\n}", "func (dcr *ExchangeWallet) signTx(baseTx *wire.MsgTx) (*wire.MsgTx, error) {\n\ttxHex, err := msgTxToHex(baseTx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to encode MsgTx: %w\", err)\n\t}\n\tvar res walletjson.SignRawTransactionResult\n\terr = dcr.nodeRawRequest(methodSignRawTransaction, anylist{txHex}, &res)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"rawrequest error: %w\", err)\n\t}\n\n\tfor i := range res.Errors {\n\t\tsigErr := &res.Errors[i]\n\t\tdcr.log.Errorf(\"Signing %v:%d, seq = %d, sigScript = %v, failed: %v (is wallet locked?)\",\n\t\t\tsigErr.TxID, sigErr.Vout, sigErr.Sequence, sigErr.ScriptSig, sigErr.Error)\n\t\t// Will be incomplete below, so log each SignRawTransactionError and move on.\n\t}\n\n\tsignedTx, err := msgTxFromHex(res.Hex)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to deserialize signed MsgTx: %w\", err)\n\t}\n\n\tif !res.Complete {\n\t\tdcr.log.Errorf(\"Incomplete raw transaction signatures (input tx: %x / incomplete signed tx: %x): \",\n\t\t\tdcr.wireBytes(baseTx), dcr.wireBytes(signedTx))\n\t\treturn nil, fmt.Errorf(\"incomplete raw tx signatures (is wallet locked?)\")\n\t}\n\n\treturn signedTx, nil\n}", "func (a API) GetRawTransaction(cmd *btcjson.GetRawTransactionCmd) (e error) {\n\tRPCHandlers[\"getrawtransaction\"].Call <-API{a.Ch, cmd, nil}\n\treturn\n}", "func (_EthCrossChain *EthCrossChainRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {\n\treturn _EthCrossChain.Contract.EthCrossChainTransactor.contract.Transact(opts, method, params...)\n}", "func (t *TxCreate) CreateTransferTx(sender, receiver account.AccountType, floatValue float64) (string, string, error) {\n\ttargetAction := action.ActionTypeTransfer\n\n\t// validation account\n\tif receiver == account.AccountTypeClient || receiver == account.AccountTypeAuthorization {\n\t\treturn \"\", \"\", errors.New(\"invalid receiver account. client, authorization account is not allowed as receiver\")\n\t}\n\tif sender == receiver {\n\t\treturn \"\", \"\", errors.New(\"invalid account. sender and receiver is same\")\n\t}\n\n\t// check sernder's balance\n\tsenderAddr, err := t.addrRepo.GetOneUnAllocated(sender)\n\tif err != nil {\n\t\treturn \"\", \"\", errors.Wrap(err, \"fail to call addrRepo.GetOneUnAllocated(sender)\")\n\t}\n\tsenderBalance, err := t.xrp.GetBalance(senderAddr.WalletAddress)\n\tif err != nil {\n\t\treturn \"\", \"\", errors.Wrap(err, \"fail to call xrp.GetAccountInfo()\")\n\t}\n\tif senderBalance <= 20 {\n\t\treturn \"\", \"\", errors.New(\"sender balance is insufficient to send\")\n\t}\n\tif floatValue != 0 && senderBalance <= floatValue {\n\t\treturn \"\", \"\", errors.New(\"sender balance is insufficient to send\")\n\t}\n\n\tt.logger.Debug(\"amount\",\n\t\tzap.Float64(\"floatValue\", floatValue),\n\t\tzap.Float64(\"senderBalance\", senderBalance),\n\t)\n\n\t// get receiver address\n\treceiverAddr, err := t.addrRepo.GetOneUnAllocated(receiver)\n\tif err != nil {\n\t\treturn \"\", \"\", errors.Wrap(err, \"fail to call addrRepo.GetOneUnAllocated(receiver)\")\n\t}\n\n\t// call CreateRawTransaction\n\tinstructions := &pb.Instructions{\n\t\tMaxLedgerVersionOffset: xrp.MaxLedgerVersionOffset,\n\t}\n\ttxJSON, rawTxString, err := t.xrp.CreateRawTransaction(senderAddr.WalletAddress, receiverAddr.WalletAddress, floatValue, instructions)\n\tif err != nil {\n\t\treturn \"\", \"\", errors.Wrapf(err, \"fail to call xrp.CreateRawTransaction(), sender address: %s\", senderAddr.WalletAddress)\n\t}\n\tt.logger.Debug(\"txJSON\", zap.Any(\"txJSON\", txJSON))\n\tgrok.Value(txJSON)\n\n\t// generate UUID to trace transaction because unsignedTx is not unique\n\tuid := uuid.NewV4().String()\n\n\tserializedTxs := []string{fmt.Sprintf(\"%s,%s\", uid, rawTxString)}\n\n\t// create insert data for eth_detail_tx\n\ttxDetailItem := &models.XRPDetailTX{\n\t\tUUID: uid,\n\t\tCurrentTXType: tx.TxTypeUnsigned.Int8(),\n\t\tSenderAccount: sender.String(),\n\t\tSenderAddress: senderAddr.WalletAddress,\n\t\tReceiverAccount: receiver.String(),\n\t\tReceiverAddress: receiverAddr.WalletAddress,\n\t\tAmount: txJSON.Amount,\n\t\tXRPTXType: txJSON.TransactionType,\n\t\tFee: txJSON.Fee,\n\t\tFlags: txJSON.Flags,\n\t\tLastLedgerSequence: txJSON.LastLedgerSequence,\n\t\tSequence: txJSON.Sequence,\n\t\t// SigningPubkey: txJSON.SigningPubKey,\n\t\t// TXNSignature: txJSON.TxnSignature,\n\t\t// Hash: txJSON.Hash,\n\t}\n\ttxDetailItems := []*models.XRPDetailTX{txDetailItem}\n\n\treturn t.afterTxCreation(targetAction, sender, serializedTxs, txDetailItems, nil)\n}", "func (f *HubTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {\n\treturn f.Contract.contract.Transact(opts, method, params...)\n}", "func test_sendEth(t *testing.T) {\n\tt.Skip(nil)\n\teth_gateway.RunOnTestNet()\n\t// transfer\n\ttransferValue := big.NewInt(1)\n\ttransferValueInWei := new(big.Int).Mul(transferValue, oneWei)\n\t// Send ether to test account\n\ttxs, _, _, err := eth_gateway.EthWrapper.SendETH(eth_gateway.MainWalletAddress, eth_gateway.MainWalletPrivateKey, ethAddress02, transferValueInWei)\n\tif err != nil {\n\t\tt.Logf(\"failed to send ether to %v ether to %v\\n\", transferValue, ethAddress02.Hex())\n\t\tt.Fatalf(\"transaction error: %v\\n\", err)\n\t}\n\tfor tx := range txs {\n\t\ttransaction := txs[tx]\n\t\t// Store For Next Test\n\t\tlastTransaction = *transaction\n\t\tprintTx(transaction)\n\n\t\t// wait for confirmation\n\t\tconfirmed := eth_gateway.EthWrapper.WaitForConfirmation(lastTransaction.Hash(), 3)\n\t\tif confirmed == 1 {\n\t\t\tt.Logf(\"confirmed ether was sent to : %v\", ethAddress02.Hex())\n\t\t} else if confirmed == 0 {\n\t\t\tt.Logf(\"failed to confirm sending ether\")\n\t\t}\n\t}\n}", "func (w Wallet) Send(to string, amount uint, utxoSetPath string) error {\n\treturn nil\n}", "func (s *ethereumPaymentObligation) sendMintTransaction(contract ethereumPaymentObligationContract, opts *bind.TransactOpts, requestData *MintRequest) error {\n\ttx, err := s.ethClient.SubmitTransactionWithRetries(contract.Mint, opts, requestData.To, requestData.TokenID, requestData.TokenURI, requestData.AnchorID,\n\t\trequestData.MerkleRoot, requestData.Values, requestData.Salts, requestData.Proofs)\n\tif err != nil {\n\t\treturn err\n\t}\n\tlog.Infof(\"Sent off tx to mint [tokenID: %x, anchor: %x, registry: %x] to payment obligation contract. Ethereum transaction hash [%x] and Nonce [%v] and Check [%v]\",\n\t\trequestData.TokenID, requestData.AnchorID, requestData.To, tx.Hash(), tx.Nonce(), tx.CheckNonce())\n\tlog.Infof(\"Transfer pending: 0x%x\\n\", tx.Hash())\n\treturn nil\n}", "func (_Ethdkg *EthdkgTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {\n\treturn _Ethdkg.Contract.contract.Transact(opts, method, params...)\n}", "func sendEth(t *testing.T, key ethkey.KeyV2, ec *backends.SimulatedBackend, to common.Address, eth int) {\n\tnonce, err := ec.PendingNonceAt(context.Background(), key.Address.Address())\n\trequire.NoError(t, err)\n\ttx := gethtypes.NewTx(&gethtypes.DynamicFeeTx{\n\t\tChainID: big.NewInt(1337),\n\t\tNonce: nonce,\n\t\tGasTipCap: big.NewInt(1),\n\t\tGasFeeCap: big.NewInt(10e9), // block base fee in sim\n\t\tGas: uint64(21_000),\n\t\tTo: &to,\n\t\tValue: big.NewInt(0).Mul(big.NewInt(int64(eth)), big.NewInt(1e18)),\n\t\tData: nil,\n\t})\n\tsignedTx, err := gethtypes.SignTx(tx, gethtypes.NewLondonSigner(big.NewInt(1337)), key.ToEcdsaPrivKey())\n\trequire.NoError(t, err)\n\terr = ec.SendTransaction(context.Background(), signedTx)\n\trequire.NoError(t, err)\n\tec.Commit()\n}" ]
[ "0.75618804", "0.7431252", "0.7406614", "0.700521", "0.6965261", "0.69638187", "0.69369", "0.6910495", "0.68955934", "0.6840324", "0.682656", "0.6720636", "0.66406167", "0.6629154", "0.6592851", "0.6590758", "0.6585054", "0.6555446", "0.65178925", "0.65044934", "0.6460261", "0.64488757", "0.6354232", "0.63469374", "0.63329935", "0.63038963", "0.62897146", "0.62554526", "0.62386715", "0.6230905", "0.62217903", "0.6221673", "0.62089884", "0.620776", "0.6197475", "0.61825436", "0.6154928", "0.615453", "0.6152728", "0.6125781", "0.6122733", "0.6121612", "0.60953087", "0.6088089", "0.60817504", "0.6078506", "0.60686946", "0.60653245", "0.60646266", "0.606323", "0.6062763", "0.6060692", "0.60576946", "0.6052397", "0.6050347", "0.6049683", "0.60372853", "0.6010448", "0.60035855", "0.5988572", "0.59756607", "0.5968163", "0.5963495", "0.5950229", "0.5947508", "0.5945446", "0.5925241", "0.5906344", "0.59057313", "0.5903546", "0.59003377", "0.58963627", "0.58929145", "0.58779174", "0.58749497", "0.5859731", "0.5858618", "0.5857922", "0.5856246", "0.5855804", "0.5852371", "0.58495533", "0.5845252", "0.5843605", "0.5842381", "0.584228", "0.58422196", "0.5841203", "0.58363473", "0.5825594", "0.5820359", "0.581968", "0.58024687", "0.5797459", "0.5796405", "0.5795427", "0.579308", "0.5785863", "0.5784584", "0.5782744" ]
0.7520837
1
decodeAddress from string to decodedAddress
decodeAddress из строки в decodedAddress
func decodeAddress(address string, cfg *chaincfg.Params) (btcutil.Address, error) { decodedAddress, err := btcutil.DecodeAddress(address, cfg) if err != nil { return nil, err } return decodedAddress, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func DecodeString(addr string) (Address, error) {\n\t// Remove any leading slashes.\n\tif strings.HasPrefix(addr, \"/\") {\n\t\taddr = addr[1:]\n\t}\n\n\taddrParts := strings.Split(addr, \"/\")\n\tif len(addrParts) != 4 {\n\t\treturn Address{}, fmt.Errorf(\"invalid format %v\", addr)\n\t}\n\tvar protocol Protocol\n\tswitch addrParts[0] {\n\tcase \"tcp\":\n\t\tprotocol = TCP\n\tcase \"udp\":\n\t\tprotocol = UDP\n\tcase \"ws\":\n\t\tprotocol = WebSocket\n\tdefault:\n\t\treturn Address{}, fmt.Errorf(\"invalid protocol %v\", addrParts[0])\n\t}\n\tvalue := addrParts[1]\n\tnonce, err := strconv.ParseUint(addrParts[2], 10, 64)\n\tif err != nil {\n\t\treturn Address{}, err\n\t}\n\tvar sig id.Signature\n\tsigBytes, err := base64.RawURLEncoding.DecodeString(addrParts[3])\n\tif err != nil {\n\t\treturn Address{}, err\n\t}\n\tif len(sigBytes) != 65 {\n\t\treturn Address{}, fmt.Errorf(\"invalid signature %v\", addrParts[3])\n\t}\n\tcopy(sig[:], sigBytes)\n\treturn Address{\n\t\tProtocol: protocol,\n\t\tValue: value,\n\t\tNonce: nonce,\n\t\tSignature: sig,\n\t}, nil\n}", "func DecodeAddress(raw string) (res Address, err error) {\n\tvar rbytes []byte\n\tvar prefix string\n\n\tif strings.HasPrefix(raw, B32Prefix) || strings.HasPrefix(raw, StakePrefix) {\n\t\tprefix, rbytes, err = bech32.Decode(raw)\n\t} else {\n\t\trbytes, err = base58.Decode(raw)\n\t}\n\n\tif err != nil {\n\t\treturn\n\t}\n\n\tres, err = DecodeRawAddress(rbytes)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif p := res.Prefix(); p != prefix {\n\t\terr = errors.New(\"invalid address prefix\")\n\t}\n\n\treturn\n}", "func DecodeAddress(r stdio.Reader) (Address, error) {\n\treturn wallet.DecodeAddress(r)\n}", "func (c *Client) DecodeAddress(resp *http.Response) (*Address, error) {\n\tvar decoded Address\n\terr := c.Decoder.Decode(&decoded, resp.Body, resp.Header.Get(\"Content-Type\"))\n\treturn &decoded, err\n}", "func DecodePeerAddress(x string) string {\n\treturn nettools.BinaryToDottedPort(x)\n}", "func DecodeAddress(b []byte) (net.IP, []byte, error) {\n\tif len(b) < 6 {\n\t\treturn nil, nil, errors.New(\"too short\")\n\t}\n\n\t// IPv4\n\tif b[0] == 4 && b[1] == 4 {\n\t\treturn net.IP(b[2:6]), b[6:], nil\n\t}\n\n\t// IPv6\n\tif len(b) < 18 {\n\t\treturn nil, nil, errors.New(\"too short\")\n\t}\n\tif b[0] == 6 && b[1] == 16 {\n\t\treturn net.IP(b[2:18]), b[18:], nil\n\t}\n\n\treturn nil, nil, errors.New(\"unrecognized format\")\n}", "func (cdc AddressCodec) Decode(b []byte) (v interface{}, s string, err error) {\n\tip := net.IP(b)\n\treturn ip, ip.String(), nil\n\n}", "func DecodeAddr(address []byte) string {\n\tvar stringAddr string\n\tvar ip []byte\n\tvar port []byte\n\n\tip = address[:4]\n\tport = address[4:]\n\n\t// Decode IP\n\tfor index, octet := range ip {\n\t\tstringAddr = stringAddr + strconv.Itoa(int(octet))\n\t\tif index != 3 {\n\t\t\tstringAddr += \".\"\n\t\t}\n\t}\n\tstringAddr += \":\"\n\n\t// Decode Port\n\tb := make([]byte, 8)\n\tfor i := 0; i < 6; i++ {\n\t\tb[i] = byte(0)\n\t}\n\tb[6] = port[0]\n\tb[7] = port[1]\n\tp := binary.BigEndian.Uint64(b)\n\tstringAddr += strconv.FormatUint(p, 10)\n\t//fmt.Println(\"Complete IP:\", stringAddr)\n\treturn stringAddr\n}", "func DecodeAddress(addr string, params AddressParams) (Address, error) {\n\t// Parsing code for future address/script versions should be added as the\n\t// most recent case in the switch statement. The expectation is that newer\n\t// version addresses will become more common, so they should be checked\n\t// first.\n\tswitch {\n\tcase probablyV0Base58Addr(addr):\n\t\treturn DecodeAddressV0(addr, params)\n\t}\n\n\tstr := fmt.Sprintf(\"address %q is not a supported type\", addr)\n\treturn nil, makeError(ErrUnsupportedAddress, str)\n}", "func DecodeAddress(address string) (*Address, error) {\n\t// if address[:3] == \"BM-\" { // Clients should accept addresses without BM-\n\t//\taddress = address[3:]\n\t// }\n\t//\n\t// decodeAddress says this but then UI checks for a missingbm status from\n\t// decodeAddress, which doesn't exist. So I choose NOT to accept addresses\n\t// without the initial \"BM-\"\n\n\ti, err := base58.DecodeToBig([]byte(address[3:]))\n\tif err != nil {\n\t\treturn nil, errors.New(\"input address not valid base58 string\")\n\t}\n\tdata := i.Bytes()\n\n\thashData := data[:len(data)-4]\n\tchecksum := data[len(data)-4:]\n\n\t// Take two rounds of SHA512 hashes\n\tsha := sha512.New()\n\tsha.Write(hashData)\n\tcurrentHash := sha.Sum(nil)\n\tsha.Reset()\n\tsha.Write(currentHash)\n\n\tif !bytes.Equal(checksum, sha.Sum(nil)[0:4]) {\n\t\treturn nil, errors.New(\"checksum failed\")\n\t}\n\t// create the address\n\taddr := new(Address)\n\n\tbuf := bytes.NewReader(data)\n\n\terr = addr.Version.DeserializeReader(buf) // get the version\n\tif err != nil {\n\t\treturn nil, types.DeserializeFailedError(\"version: \" + err.Error())\n\t}\n\n\terr = addr.Stream.DeserializeReader(buf)\n\tif err != nil {\n\t\treturn nil, types.DeserializeFailedError(\"stream: \" + err.Error())\n\t}\n\n\tripe := make([]byte, buf.Len()-4) // exclude bytes already read and checksum\n\tn, err := buf.Read(ripe)\n\tif n != len(ripe) || err != nil {\n\t\treturn nil, types.DeserializeFailedError(\"ripe: \" + err.Error())\n\t}\n\n\tswitch addr.Version {\n\tcase 2:\n\t\tfallthrough\n\tcase 3:\n\t\tif len(ripe) > 20 || len(ripe) < 18 { // improper size\n\t\t\treturn nil, errors.New(\"version 3, the ripe length is invalid\")\n\t\t}\n\tcase 4:\n\t\t// encoded ripe data MUST have null bytes removed from front\n\t\tif ripe[0] == 0x00 {\n\t\t\treturn nil, errors.New(\"version 4, ripe data has null bytes in\" +\n\t\t\t\t\" the beginning, not properly encoded\")\n\t\t}\n\t\tif len(ripe) > 20 || len(ripe) < 4 { // improper size\n\t\t\treturn nil, errors.New(\"version 4, the ripe length is invalid\")\n\t\t}\n\tdefault:\n\t\treturn nil, errors.New(\"unsupported address version\")\n\t}\n\n\t// prepend null bytes to make sure that the total ripe length is 20\n\tnumPadding := 20 - len(ripe)\n\tripe = append(make([]byte, numPadding), ripe...)\n\tcopy(addr.Ripe[:], ripe)\n\n\treturn addr, nil\n}", "func decodePeerAddress(chunk string) string {\n\tip := net.IPv4(chunk[0], chunk[1], chunk[2], chunk[3])\n\tremotePort := 256*int(chunk[4]) + int(chunk[5]) // Port is given in network encoding.\n\treturn fmt.Sprintf(\"%s:%d\", ip.String(), remotePort)\n}", "func decodeAddress(address string) (uint32, error) {\n\tsplit := strings.Split(address, \".\")\n\tif len(split) != 4 {\n\t\treturn 0, errors.New(\"Error decoding IPv4 address: wrong amount of octets\")\n\t}\n\tvar IPaddress uint32\n\tfor i, octetstr := range split {\n\t\tsegment, err := strconv.Atoi(octetstr)\n\t\tif err != nil {\n\t\t\treturn 0, errors.Wrap(err, \"Error decoding IPv4 address\")\n\t\t}\n\t\tif segment > math.MaxUint8 {\n\t\t\treturn 0, errors.New(\"Error decoding IPv4 address: value overflow\")\n\t\t}\n\t\t// Shift octets by determined amount of bits.\n\t\tswitch i {\n\t\tcase 0:\n\t\t\tsegment = segment << 24\n\t\tcase 1:\n\t\t\tsegment = segment << 16\n\t\tcase 2:\n\t\t\tsegment = segment << 8\n\t\t}\n\t\tIPaddress += uint32(segment)\n\t}\n\treturn IPaddress, nil\n}", "func HexToAddress(s string) Address { return BytesToAddress(FromHex(s)) }", "func decodeAddresses(val []byte) ([]common.Address, error) {\n\ts := string(val)\n\tvar res []common.Address\n\tif s == \"\" {\n\t\treturn res, nil\n\t}\n\tfor _, a := range strings.Split(s, \",\") {\n\t\tif !common.IsHexAddress(a) {\n\t\t\treturn nil, errors.Errorf(\"malformed address: %q\", s)\n\t\t}\n\n\t\tres = append(res, common.HexToAddress(a))\n\t}\n\treturn res, nil\n}", "func (c *Client) DecodeEasypostAddress(resp *http.Response) (*EasypostAddress, error) {\n\tvar decoded EasypostAddress\n\terr := c.Decoder.Decode(&decoded, resp.Body, resp.Header.Get(\"Content-Type\"))\n\treturn &decoded, err\n}", "func DecodePeerAddress(encoded bencoding.String) (addr net.TCPAddr, err error) {\n\tif len(encoded) != 6 {\n\t\terr = errors.New(\"encoded address has wrong length (should be 6)\")\n\t} else {\n\t\taddr = net.TCPAddr{\n\t\t\tIP: net.IPv4(encoded[0], encoded[1], encoded[2], encoded[3]),\n\t\t\tPort: int(encoded[4])<<8 + int(encoded[5]),\n\t\t}\n\t}\n\n\treturn\n}", "func HexToAddress(s string) types.Address { return BytesToAddress(FromHex(s)) }", "func dnsDecodeString(raw string) ([]byte, error) {\n\tpad := 8 - (len(raw) % 8)\n\tnb := []byte(raw)\n\tif pad != 8 {\n\t\tnb = make([]byte, len(raw)+pad)\n\t\tcopy(nb, raw)\n\t\tfor index := 0; index < pad; index++ {\n\t\t\tnb[len(raw)+index] = '='\n\t\t}\n\t}\n\treturn sliverBase32.DecodeString(string(nb))\n}", "func DecodeAddress(address string) (*Address, error) {\n\tif address[:3] == \"BM-\" { // Clients should accept addresses without BM-\n\t\taddress = address[3:]\n\t}\n\n\tdata := base58.Decode(address)\n\tif len(data) <= 12 { // rough lower bound, also don't want it to be empty\n\t\treturn nil, ErrUnknownAddressType\n\t}\n\n\thashData := data[:len(data)-4]\n\tchecksum := data[len(data)-4:]\n\n\tif !bytes.Equal(checksum, DoubleSha512(hashData)[0:4]) {\n\t\treturn nil, ErrChecksumMismatch\n\t}\n\t// create the address\n\taddr := new(Address)\n\n\tbuf := bytes.NewReader(data)\n\tvar err error\n\n\taddr.Version, err = ReadVarInt(buf) // read version\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\taddr.Stream, err = ReadVarInt(buf) // read stream\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tripe := make([]byte, buf.Len()-4) // exclude bytes already read and checksum\n\tbuf.Read(ripe) // this can never cause an error\n\n\tswitch addr.Version {\n\tcase 2:\n\t\tfallthrough\n\tcase 3:\n\t\tif len(ripe) > 19 || len(ripe) < 18 { // improper size\n\t\t\treturn nil, errors.New(\"version 3, the ripe length is invalid\")\n\t\t}\n\tcase 4:\n\t\t// encoded ripe data MUST have null bytes removed from front\n\t\tif ripe[0] == 0x00 {\n\t\t\treturn nil, errors.New(\"version 4, ripe data has null bytes in\" +\n\t\t\t\t\" the beginning, not properly encoded\")\n\t\t}\n\t\tif len(ripe) > 19 || len(ripe) < 4 { // improper size\n\t\t\treturn nil, errors.New(\"version 4, the ripe length is invalid\")\n\t\t}\n\tdefault:\n\t\treturn nil, ErrUnknownAddressType\n\t}\n\n\t// prepend null bytes to make sure that the total ripe length is 20\n\tnumPadding := 20 - len(ripe)\n\tripe = append(make([]byte, numPadding), ripe...)\n\tcopy(addr.Ripe[:], ripe)\n\n\treturn addr, nil\n}", "func (a *Address) Decode(r io.Reader) error {\n\tvar b []byte\n\terr := cio.ReadBytesUint16(r, &b)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reading byte stream: %w\", err)\n\t}\n\n\tpk := secp256k1.PubKey{\n\t\tKey: b,\n\t}\n\t*a = *NewAddress(&pk)\n\treturn nil\n}", "func NewFromString(addr string) (*Address, error) {\n\tlegaddr, err := legacy.Decode(addr)\n\tif err == nil {\n\t\taddr, err := NewFromLegacy(legaddr)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn addr, nil\n\t}\n\n\tcashaddr, err := cashaddress.Decode(addr, cashaddress.MainNet)\n\tif err == nil {\n\t\taddr, err := NewFromCashAddress(cashaddr)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn addr, nil\n\t}\n\n\treturn nil, errors.New(\"unable to decode address\")\n}", "func AddressDecode(dec *WasmDecoder) ScAddress {\n\taddr := ScAddress{}\n\tcopy(addr.id[:], dec.FixedBytes(ScAddressLength))\n\treturn addr\n}", "func ConvertUserStrToAddress(userFAddr string) []byte {\n\tv := base58.Decode(userFAddr)\n\treturn v[2:34]\n}", "func DecodeRawAddress(s []byte) (Address, error) {\n\tif len(s) == 0 {\n\t\treturn nil, errors.New(\"empty address\")\n\t}\n\n\theader := s[0]\n\tnetwork := Network(header & 0x0f)\n\n\treadAddrCred := func(bit byte, pos int) StakeCredential {\n\t\thashBytes := s[pos : pos+Hash28Size]\n\t\tif header&(1<<bit) == 0 {\n\t\t\treturn StakeCredential{Kind: KeyStakeCredentialType, Data: hashBytes}\n\t\t}\n\t\treturn StakeCredential{Kind: ScriptStakeCredentialype, Data: hashBytes}\n\t}\n\n\tswitch (header & 0xf0) >> 4 {\n\t// Base type\n\tcase 0b0000, 0b0001, 0b0010, 0b0011:\n\t\t// header + keyhash\n\t\tif len(s) != 57 {\n\t\t\treturn nil, errors.New(\"Invalid length for base address\")\n\t\t}\n\t\treturn &BaseAddress{Network: network, Payment: readAddrCred(4, 1),\n\t\t\tStake: readAddrCred(5, Hash28Size+1)}, nil\n\t// Pointer type\n\tcase 0b0100, 0b0101:\n\t\t// header + keyhash + 3 natural numbers (min 1 byte each)\n\t\tif len(s) < 32 {\n\t\t\treturn nil, errors.New(\"Invalid length for pointer address\")\n\t\t}\n\t\tbyteIndex := 1\n\t\tpaymentCred := readAddrCred(4, 1)\n\t\tslot, slotBytes, ok := VariableNatDecode(s[byteIndex:])\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"slot variable decode failed\")\n\t\t}\n\t\tbyteIndex += slotBytes\n\n\t\ttxIndex, txBytes, ok := VariableNatDecode(s[byteIndex:])\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"txIndex variable decode failed\")\n\t\t}\n\t\tbyteIndex += txBytes\n\n\t\tcertIndex, certBytes, ok := VariableNatDecode(s[byteIndex:])\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"certIndex variable decode failed\")\n\t\t}\n\t\tbyteIndex += certBytes\n\n\t\tif byteIndex > len(s) {\n\t\t\treturn nil, errors.New(\"byte index is out range of pointer lenght\")\n\t\t}\n\n\t\treturn &PointerAddress{\n\t\t\tNetwork: network, Payment: paymentCred,\n\t\t\tStake: StakePoint{Slot: slot, TxIndex: txIndex, CertIndex: certIndex},\n\t\t}, nil\n\t// Enterprise type\n\tcase 0b0110, 0b0111:\n\t\t// header + keyhash\n\t\tif len(s) != 29 {\n\t\t\treturn nil, errors.New(\"invalid length for enterprise address\")\n\t\t}\n\t\treturn &EnterpriseAddress{Network: network, Payment: readAddrCred(4, 1)}, nil\n\t// Reward type\n\tcase 0b1110, 0b1111:\n\t\tif len(s) != 29 {\n\t\t\treturn nil, errors.New(\"invalid length for reward address\")\n\t\t}\n\t\treturn &Reward{Network: network, Payment: readAddrCred(4, 1)}, nil\n\t// Legacy byron type\n\tcase 0b1000:\n\t\tvar byron LegacyAddress\n\t\tif err := cbor.Unmarshal(s, &byron); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &byron, nil\n\t}\n\treturn nil, errors.New(\"unsupports address type\")\n}", "func decodeAddr(addr []uint8) (fidlnet.SocketAddress, bool, error) {\n\tvar sockaddrStorage C.struct_sockaddr_storage\n\tif err := sockaddrStorage.Unmarshal(addr); err != nil {\n\t\treturn fidlnet.SocketAddress{}, false, err\n\t}\n\treturn sockaddrStorage.Decode()\n}", "func DecodeBase58Address(addr string) (Address, error) {\n\tb, err := base58.Base582Hex(addr)\n\tif err != nil {\n\t\treturn Address{}, err\n\t}\n\treturn addressFromBytes(b)\n}", "func extractAddress(str string) string {\n\tvar addr string\n\n\tswitch {\n\tcase strings.Contains(str, `]`):\n\t\t// IPv6 address [2001:db8::1%lo0]:48467\n\t\taddr = strings.Split(str, `]`)[0]\n\t\taddr = strings.Split(addr, `%`)[0]\n\t\taddr = strings.TrimLeft(addr, `[`)\n\tdefault:\n\t\t// IPv4 address 192.0.2.1:48467\n\t\taddr = strings.Split(str, `:`)[0]\n\t}\n\treturn addr\n}", "func extractAddress(str string) string {\n\tvar addr string\n\n\tswitch {\n\tcase strings.Contains(str, `]`):\n\t\t// IPv6 address [2001:db8::1%lo0]:48467\n\t\taddr = strings.Split(str, `]`)[0]\n\t\taddr = strings.Split(addr, `%`)[0]\n\t\taddr = strings.TrimLeft(addr, `[`)\n\tdefault:\n\t\t// IPv4 address 192.0.2.1:48467\n\t\taddr = strings.Split(str, `:`)[0]\n\t}\n\treturn addr\n}", "func ParseAddress(addr string) (*Address, error) {\n\taddr = strings.ToUpper(addr)\n\tl := len(addr)\n\tif l < 50 {\n\t\treturn nil, InvalidAccountAddrError{reason: \"length\"}\n\t}\n\ti := l - 50 // start index of hex\n\n\tidh, err := hex.DecodeString(addr[i:])\n\tif err != nil {\n\t\treturn nil, InvalidAccountAddrError{reason: \"hex\"}\n\t}\n\n\t_addr := &Address{}\n\t_addr.Code = addr[0:i]\n\t_addr.Type = AccountType(idh[0])\n\t_addr.Hash = idh[1:]\n\n\tif err = _addr.Validate(); err != nil {\n\t\treturn nil, err\n\t}\n\treturn _addr, nil\n}", "func addressFromString(s string) (WavesAddress, error) {\n\tab, err := base58.Decode(s)\n\tif err != nil {\n\t\treturn WavesAddress{}, err\n\t}\n\ta := WavesAddress{}\n\tcopy(a[:], ab)\n\treturn a, nil\n}", "func (addr *Address) UnmarshalString(s string) error {\n\terr := json.Unmarshal([]byte(s), addr)\n\tif nil == err && stringutil.IsWhiteSpace(addr.Host) && addr.Port < 1 {\n\t\terr = errors.New(\"Invalid Address JSON '%s'\", s)\n\t}\n\treturn err\n}", "func addressFromBytes(b []byte) (Address, error) {\n\ta := Address{}\n\tkeyLen := len(a.Key)\n\tif len(b) != keyLen+len(a.Checksum)+1 {\n\t\treturn a, errors.New(\"Invalid address bytes\")\n\t}\n\tcopy(a.Key[:], b[:keyLen])\n\ta.Version = b[keyLen]\n\tcopy(a.Checksum[:], b[keyLen+1:])\n\tif !a.HasValidChecksum() {\n\t\treturn a, errors.New(\"Invalid checksum\")\n\t} else {\n\t\treturn a, nil\n\t}\n}", "func (addr *Address) Unmarshal(buf []byte, rem int) ([]byte, int, error) {\n\tvar err error\n\tbuf, rem, err = surge.UnmarshalU8((*uint8)(&addr.Protocol), buf, rem)\n\tif err != nil {\n\t\treturn buf, rem, err\n\t}\n\tbuf, rem, err = surge.UnmarshalString(&addr.Value, buf, rem)\n\tif err != nil {\n\t\treturn buf, rem, err\n\t}\n\tbuf, rem, err = surge.UnmarshalU64(&addr.Nonce, buf, rem)\n\tif err != nil {\n\t\treturn buf, rem, err\n\t}\n\treturn addr.Signature.Unmarshal(buf, rem)\n}", "func (p *AddressParser) Parse(address string) (*Address, error)", "func ExtractAddressFromReverse(reverseName string) string {\n\tsearch := \"\"\n\n\tf := reverse\n\n\tswitch {\n\tcase strings.HasSuffix(reverseName, IP4arpa):\n\t\tsearch = strings.TrimSuffix(reverseName, IP4arpa)\n\tcase strings.HasSuffix(reverseName, IP6arpa):\n\t\tsearch = strings.TrimSuffix(reverseName, IP6arpa)\n\t\tf = reverse6\n\tdefault:\n\t\treturn \"\"\n\t}\n\n\t// Reverse the segments and then combine them.\n\treturn f(strings.Split(search, \".\"))\n}", "func (c *Client) DecodeAddressGeneral(resp *http.Response) (*AddressGeneral, error) {\n\tvar decoded AddressGeneral\n\terr := c.Decoder.Decode(&decoded, resp.Body, resp.Header.Get(\"Content-Type\"))\n\treturn &decoded, err\n}", "func (c *Client) DecodeEasypostAddressVerification(resp *http.Response) (*EasypostAddressVerification, error) {\n\tvar decoded EasypostAddressVerification\n\terr := c.Decoder.Decode(&decoded, resp.Body, resp.Header.Get(\"Content-Type\"))\n\treturn &decoded, err\n}", "func ParseAddress(s string) (Address, error) {\n\n\tvar family uint8\n\tvar sn uint64\n\tvar crcStr string\n\tcnt, err := fmt.Sscanf(s, \"%x.%x.%s\", &family, &sn, &crcStr)\n\n\tif (nil != err) || (3 != cnt) || (sn != (0xffffffffffff & sn)) {\n\t\treturn 0, errors.New(\"onewire: invalid address \" + s)\n\t}\n\ta := sn<<8 | (uint64(family) << 56)\n\n\tbuf := make([]byte, 8)\n\tbinary.LittleEndian.PutUint64(buf, sn<<8|(uint64(family)<<56))\n\n\tcrc := RevCrc8(buf[1:])\n\n\tif \"--\" != crcStr {\n\t\tvar c uint8\n\t\tcnt, err = fmt.Sscanf(crcStr, \"%x\", &c)\n\t\tif c != crc {\n\t\t\treturn 0, errors.New(\"onewire: invalid crc \" + s)\n\t\t}\n\t}\n\n\ta |= 0xff & uint64(crc)\n\n\treturn Address(a), nil\n}", "func DecodeFromHex(str string, target interface{}) error {\n\tbz, err := HexDecodeString(str)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn Decode(bz, target)\n}", "func (at *Address) Load() btcaddr.Address {\n\taddr, e := btcaddr.Decode(at.String.Load(), at.ForNet)\n\tif e != nil {\n\t\treturn nil\n\t}\n\treturn addr\n}", "func ParseAddress(address string) Address {\n\tif !TrackPositions {\n\t\treturn 0\n\t}\n\taddr, _ := strconv.ParseUint(address, 0, 64)\n\n\treturn Address(addr)\n}", "func ParseAddress(s string) (Address, error) {\n\tvar addr Address\n\terr := addr.parse(s)\n\treturn addr, err\n}", "func ParseAddress(address string) (common.Address, error) {\n\tif common.IsHexAddress(address) {\n\t\treturn common.HexToAddress(address), nil\n\t}\n\treturn common.Address{}, fmt.Errorf(\"invalid address: %v\", address)\n}", "func ParseAddress(address string) (*mail.Address, error)", "func decodeMulticastAnnounceBytes(bytes []byte) (string, []byte, error) {\n\tnameBytesLen := int(bytes[0])\n\n\tif nameBytesLen+1 > len(bytes) {\n\t\treturn \"\", nil, errors.New(\"Invalid multicast message received\")\n\t}\n\n\tnameBytes := bytes[1 : nameBytesLen+1]\n\tname := string(nameBytes)\n\tmsgBytes := bytes[nameBytesLen+1 : len(bytes)]\n\n\treturn name, msgBytes, nil\n}", "func DecodeString(s string) ([]byte, error) {\n\tb, err := hex.DecodeString(s)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn Reverse(b), nil\n}", "func readAddr(r io.Reader, b []byte) (Addr, error) {\n\tif len(b) < MaxAddrLen {\n\t\treturn nil, io.ErrShortBuffer\n\t}\n\t_, err := io.ReadFull(r, b[:1]) // read 1st byte for address type\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch b[0] {\n\tcase AtypIPv4:\n\t\t_, err = io.ReadFull(r, b[1:1+net.IPv4len+2])\n\t\treturn b[:1+net.IPv4len+2], err\n\tcase AtypDomainName:\n\t\t_, err = io.ReadFull(r, b[1:2]) // read 2nd byte for domain length\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\t_, err = io.ReadFull(r, b[2:2+int(b[1])+2])\n\t\treturn b[:1+1+int(b[1])+2], err\n\tcase AtypIPv6:\n\t\t_, err = io.ReadFull(r, b[1:1+net.IPv6len+2])\n\t\treturn b[:1+net.IPv6len+2], err\n\t}\n\n\treturn nil, ErrAddressNotSupported\n}", "func ParseAddress(addr string) Address {\n\t// Handle IPv6 address in form as \"[2001:4860:0:2001::68]\"\n\tlenAddr := len(addr)\n\tif lenAddr > 0 && addr[0] == '[' && addr[lenAddr-1] == ']' {\n\t\taddr = addr[1 : lenAddr-1]\n\t}\n\taddr = strings.TrimSpace(addr)\n\n\tip := net.ParseIP(addr)\n\tif ip != nil {\n\t\treturn IPAddress(ip)\n\t}\n\treturn DomainAddress(addr)\n}", "func Decode(input string) ([]byte, error) {\n\tif len(input) == 0 {\n\t\treturn nil, ErrEmptyString\n\t}\n\tif !has0xPrefix(input) {\n\t\treturn nil, ErrMissingPrefix\n\t}\n\tb, err := hex.DecodeString(input[2:])\n\tif err != nil {\n\t\terr = mapError(err)\n\t}\n\treturn b, err\n}", "func parseAddressesFromStr(s string) ([]cipher.Address, error) {\n\taddrsStr := splitCommaString(s)\n\n\tvar addrs []cipher.Address\n\tfor _, s := range addrsStr {\n\t\ta, err := cipher.DecodeBase58Address(s)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\taddrs = append(addrs, a)\n\t}\n\n\treturn addrs, nil\n}", "func ParseAddress(addr interface{}) (a Address, err error) {\n\t// handle the allowed types\n\tswitch addrVal := addr.(type) {\n\tcase string: // simple string value\n\t\tif addrVal == \"\" {\n\t\t\terr = errors.New(\"Recipient.Address may not be empty\")\n\t\t} else {\n\t\t\ta.Email = addrVal\n\t\t}\n\n\tcase Address:\n\t\ta = addr.(Address)\n\n\tcase map[string]interface{}:\n\t\t// auto-parsed nested json object\n\t\tfor k, v := range addrVal {\n\t\t\tswitch vVal := v.(type) {\n\t\t\tcase string:\n\t\t\t\tif strings.EqualFold(k, \"name\") {\n\t\t\t\t\ta.Name = vVal\n\t\t\t\t} else if strings.EqualFold(k, \"email\") {\n\t\t\t\t\ta.Email = vVal\n\t\t\t\t} else if strings.EqualFold(k, \"header_to\") {\n\t\t\t\t\ta.HeaderTo = vVal\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\terr = errors.New(\"strings are required for all Recipient.Address values\")\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\tcase map[string]string:\n\t\t// user-provided json literal (convenience)\n\t\tfor k, v := range addrVal {\n\t\t\tif strings.EqualFold(k, \"name\") {\n\t\t\t\ta.Name = v\n\t\t\t} else if strings.EqualFold(k, \"email\") {\n\t\t\t\ta.Email = v\n\t\t\t} else if strings.EqualFold(k, \"header_to\") {\n\t\t\t\ta.HeaderTo = v\n\t\t\t}\n\t\t}\n\n\tdefault:\n\t\terr = errors.Errorf(\"unsupported Recipient.Address value type [%T]\", addrVal)\n\t}\n\n\treturn\n}", "func NewMixedcaseAddressFromString(hexaddr string) (*MixedcaseAddress, error) {\n\tif !IsHexAddress(hexaddr) {\n\t\treturn nil, fmt.Errorf(\"Invalid address\")\n\t}\n\ta := FromHex(hexaddr)\n\treturn &MixedcaseAddress{addr: BytesToAddress(a), original: hexaddr}, nil\n}", "func BytesToAddress(bytes []byte) (Address, error) { return V1.BytesToAddress(bytes) }", "func unpackAddr(value nlgo.Binary, af Af) (net.IP, error) {\n\tbuf := ([]byte)(value)\n\tsize := 0\n\n\tswitch af {\n\tcase syscall.AF_INET:\n\t\tsize = 4\n\tcase syscall.AF_INET6:\n\t\tsize = 16\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"ipvs: unknown af=%d addr=%v\", af, buf)\n\t}\n\n\tif size > len(buf) {\n\t\treturn nil, fmt.Errorf(\"ipvs: short af=%d addr=%v\", af, buf)\n\t}\n\n\treturn (net.IP)(buf[:size]), nil\n}", "func Explode(address string) (*Address, error) {\n\tif client == nil {\n\t\terr := initClient()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Build the API request.\n\treq := &maps.GeocodingRequest{\n\t\tAddress: address,\n\t}\n\n\t// Execute the request.\n\tresp, err := client.Geocode(context.Background(), req)\n\tif len(resp) < 1 {\n\t\treturn nil, err\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Using the first/closest match in our response, grab the values we need.\n\tcomponents := resp[0].AddressComponents\n\tformattedAddress := resp[0].FormattedAddress\n\tlat := resp[0].Geometry.Location.Lat\n\tlng := resp[0].Geometry.Location.Lng\n\n\t// Construct the return *Address{}\n\tresponse := &Address{\n\t\tAddressLine1: compose(addressLine1Composition, \"\", components, false),\n\t\tAddressLine2: compose(addressLine2Composition, addressLineDelimeter, components, false),\n\t\tAddressCity: compose(addressCityComposition, addressLineDelimeter, components, false),\n\t\tAddressState: compose(addressStateComposition, addressLineDelimeter, components, false),\n\t\tAddressCountry: compose(addressCountryComposition, addressLineDelimeter, components, false),\n\t\tAddressCountryCode: compose(addressCountryCodeComposition, addressLineDelimeter, components, true),\n\t\tAddressZip: compose(addressPostalCodeComposition, addressLineDelimeter, components, false),\n\t\tAddressLat: &lat,\n\t\tAddressLng: &lng,\n\t\tFormattedAddress: &formattedAddress,\n\t}\n\n\treturn response, err\n}", "func (g *Getter) decodeA(buf []byte, res string) (int, error) {\n\t/* Parse as an IP address */\n\tip := net.ParseIP(res)\n\tif nil == ip {\n\t\treturn 0, fmt.Errorf(\"invalid IP address %q\", res)\n\t}\n\t/* Parse with the appropriate length */\n\tvar plen, start int\n\tswitch g.Type {\n\tcase TypeA:\n\t\tip = ip.To4()\n\t\tplen = 4\n\t\tstart = 1\n\tcase TypeAAAA:\n\t\tip = ip.To16()\n\t\tplen = 16\n\t\tstart = 8\n\t}\n\t/* If we didn't get an address of the right size, someone goofed */\n\tif nil == ip {\n\t\treturn 0, fmt.Errorf(\"unable to parse IP address %s\", res)\n\t}\n\t/* Make sure we have enough buffer */\n\tif plen > len(buf) {\n\t\treturn 0, fmt.Errorf(\n\t\t\t\"buffer too small for record of type %s\",\n\t\t\tg.Type,\n\t\t)\n\t}\n\t/* Extract the payload */\n\treturn copy(buf, ip[start:]), nil\n}", "func (a *Address) UnmarshalText(input []byte) error {\n\treturn hexutil.UnmarshalFixedText(\"Address\", input, a[:])\n}", "func (a *Address) UnmarshalText(input []byte) error {\n\treturn hexutil.UnmarshalFixedText(\"Address\", input, a[:])\n}", "func Bech32ToAddress(encodedAddr string) (Address, error) { return V1.Bech32ToAddress(encodedAddr) }", "func TestAddressString(t *testing.T) {\n\ttests := []struct {\n\t\taddr, want Address // If want==nil, want is set to addr.\n\t}{\n\t\t{addr: Dot},\n\t\t{addr: End},\n\t\t{addr: All},\n\t\t{addr: Rune(0)},\n\t\t{addr: Rune(100)},\n\t\t// Rune(-100) is the string -#100, when parsed, the implicit . is inserted: .-#100.\n\t\t{addr: Rune(-100), want: Dot.Minus(Rune(100))},\n\t\t{addr: Line(0)},\n\t\t{addr: Line(100)},\n\t\t// Line(-100) is the string -100, when parsed, the implicit . is inserted: .-100.\n\t\t{addr: Line(-100), want: Dot.Minus(Line(100))},\n\t\t{addr: Mark('a')},\n\t\t{addr: Mark('z')},\n\t\t{addr: Regexp(\"/☺☹\")},\n\t\t{addr: Regexp(\"/☺☹/\")},\n\t\t{addr: Regexp(\"?☺☹\")},\n\t\t{addr: Regexp(\"?☺☹?\")},\n\t\t{addr: Dot.Plus(Line(1))},\n\t\t{addr: Dot.Minus(Line(1))},\n\t\t{addr: Dot.Minus(Line(1)).Plus(Line(1))},\n\t\t{addr: Rune(1).To(Rune(2))},\n\t\t{addr: Rune(1).Then(Rune(2))},\n\t\t{addr: Regexp(\"/func\").Plus(Regexp(`/\\(`))},\n\t}\n\tfor _, test := range tests {\n\t\tif test.want == nil {\n\t\t\ttest.want = test.addr\n\t\t}\n\t\tstr := test.addr.String()\n\t\tgot, _, err := Addr([]rune(str))\n\t\tif err != nil || got != test.want {\n\t\t\tt.Errorf(\"Addr(%q)=%v,%v want %q,nil\", str, got.String(), err, test.want.String())\n\t\t}\n\t}\n}", "func (s *String) DecodeFromBytes(b []byte) error {\n\tif len(b) < 4 {\n\t\treturn errors.NewErrTooShortToDecode(s, \"should be longer than 4 bytes\")\n\t}\n\n\ts.Length = int32(binary.LittleEndian.Uint32(b[:4]))\n\tif s.Length <= 0 {\n\t\treturn nil\n\t}\n\ts.Value = b[4 : 4+s.Length]\n\treturn nil\n}", "func (a *Address) UnmarshalJSON(buf []byte) (err error) {\n\tstr := string(buf[1 : len(buf)-1])\n\t_, _, err = ParseAddrPort(str)\n\tif err == nil {\n\t\t*a = Address(str)\n\t}\n\treturn\n}", "func ParseAddress(addr string) (proto string, path string, err error) {\n\tm := netAddrRx.FindStringSubmatch(addr)\n\tif m == nil {\n\t\treturn \"\", \"\", goof.WithField(\"address\", addr, \"invalid address\")\n\t}\n\treturn m[1], m[2], nil\n}", "func BytesToAddress(b []byte) Address {\n\tvar a Address\n\tif len(b) > AddressLength {\n\t\tb = b[len(b)-AddressLength:]\n\t}\n\tcopy(a[AddressLength-len(b):], b)\n\treturn a\n}", "func ParseID(body string) (_ ID, err error) {\n\tif len(body) <= 1 {\n\t\terr = errors.New(\"address too short\")\n\t\treturn\n\t}\n\tif body[0] != 'b' {\n\t\terr = fmt.Errorf(\"invalid codec %x\", body[0])\n\t\treturn\n\t}\n\t// remove 'b' byte\n\tbody = body[1:]\n\ts, err := base32i.CheckDecodeString(body)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn DecodeID(s), nil\n}", "func (_BaseAccessWallet *BaseAccessWalletFilterer) ParseDbgAddress(log types.Log) (*BaseAccessWalletDbgAddress, error) {\n\tevent := new(BaseAccessWalletDbgAddress)\n\tif err := _BaseAccessWallet.contract.UnpackLog(event, \"dbgAddress\", log); err != nil {\n\t\treturn nil, err\n\t}\n\tevent.Raw = log\n\treturn event, nil\n}", "func DnsDecoder(urlStr string) (*string, *string, error) {\n\tu, err := url.Parse(urlStr)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\thostTmp := u.Host\n\tIP := Dns(u.Host)\n\tif IP != nil {\n\t\tu.Host = IP.String()\n\t\turlStr = u.String()\n\t\treturn &urlStr, &hostTmp, nil\n\t}\n\treturn nil, nil, fmt.Errorf(\"dnsDecoder fail\")\n}", "func (c *Client) DecodeEasypostAddressVerifications(resp *http.Response) (*EasypostAddressVerifications, error) {\n\tvar decoded EasypostAddressVerifications\n\terr := c.Decoder.Decode(&decoded, resp.Body, resp.Header.Get(\"Content-Type\"))\n\treturn &decoded, err\n}", "func ParseAddress(address string) (*Address, errors.TracerError) {\n\taddr := &Address{}\n\tif ValidateIPv6Address(address) {\n\t\tclean, testPort := cleanIPv6(address)\n\t\thasPort := false\n\t\tport := 0\n\t\tif testPort > 0 {\n\t\t\thasPort = true\n\t\t\tport = testPort\n\t\t}\n\t\treturn &Address{Host: clean, Port: port, IsIPv6: true, HasPort: hasPort}, nil\n\t}\n\tcolons := strings.Count(address, \":\")\n\tif colons > 1 {\n\t\treturn nil, errors.New(\"Invalid address: too many colons '%s'\", address)\n\t} else if colons == 0 {\n\t\treturn &Address{Host: address, HasPort: false}, nil\n\t}\n\tsplit := strings.Split(address, \":\")\n\taddr.Host = split[0]\n\tport, err := strconv.Atoi(split[1])\n\tif err != nil {\n\t\treturn nil, errors.New(\"address '%s' is invalid: could not parse port data, %s\", address, err)\n\t}\n\tif port <= 0 || port > math.MaxUint16 {\n\t\treturn nil, errors.New(\"port '%d' is not a valid port number, must be uint16\", port)\n\t}\n\taddr.Port = port\n\taddr.HasPort = true\n\treturn addr, nil\n}", "func ParseAddress(address []byte, options AddressParserOptions) *AddressParserResponse {\n\tcaddress, _ := (*C.char)(unsafe.Pointer((*sliceHeader)(unsafe.Pointer(&address)).Data)), cgoAllocsUnknown\n\tcoptions, _ := options.PassValue()\n\t__ret := C.parse_address(caddress, coptions)\n\t__v := NewAddressParserResponseRef(unsafe.Pointer(__ret))\n\treturn __v\n}", "func HexDecodeString(s string) ([]byte, error) {\n\ts = strings.TrimPrefix(s, \"0x\")\n\n\tif len(s)%2 != 0 {\n\t\ts = \"0\" + s\n\t}\n\n\tb, err := hex.DecodeString(s)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn b, nil\n}", "func BytesToAddress(b []byte) Address {\n\tvar a Address\n\ta.SetBytes(b)\n\treturn a\n}", "func StringToPeerInfo(addrStr string) (*peerstore.PeerInfo, error) {\n\taddr, err := iaddr.ParseString(addrStr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tpeerinfo, err := peerstore.InfoFromP2pAddr(addr.Multiaddr())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn peerinfo, nil\n}", "func parseEPRTtoAddr(line string) (string, string, error) {\n\taddr := strings.Split(line, \"|\")\n\n\tif len(addr) != 5 {\n\t\treturn \"\", \"\", fmt.Errorf(\"invalid data address\")\n\t}\n\n\tnetProtocol := addr[1]\n\tIP := addr[2]\n\n\t// check port is valid\n\tport := addr[3]\n\tif integerPort, err := strconv.Atoi(port); err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"invalid data address\")\n\t} else if integerPort <= 0 || integerPort > 65535 {\n\t\treturn \"\", \"\", fmt.Errorf(\"invalid data address\")\n\t}\n\n\tswitch netProtocol {\n\tcase \"1\", \"2\":\n\t\t// use protocol 1 means IPv4. 2 means IPv6\n\t\t// net.ParseIP for validate IP\n\t\tif net.ParseIP(IP) == nil {\n\t\t\treturn \"\", \"\", fmt.Errorf(\"invalid data address\")\n\t\t}\n\t\tbreak\n\tdefault:\n\t\t// wrong network protocol\n\t\treturn \"\", \"\", fmt.Errorf(\"unknown network protocol\")\n\t}\n\n\treturn IP, port, nil\n}", "func TestAddress(t *testing.T) {\n addr, err := StringAddress(m_pub2)\n if err != nil {\n t.Errorf(\"%s should have been nil\",err.Error())\n }\n expected_addr := \"1AEg9dFEw29kMgaN4BNHALu7AzX5XUfzSU\"\n if addr != expected_addr {\n t.Errorf(\"\\n%s\\nshould be\\n%s\",addr,expected_addr)\n }\n}", "func NewAddressFromBech32(data string) (a Address) {\n\terr := a.UnmarshalText([]byte(data))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn\n}", "func hexDecodeStr(s string) ([]byte, error) {\n\tsrc := []byte(s)\n\tdst := make([]byte, len(src)/2)\n\tif len(s)%2 != 0 {\n\t\treturn dst, errors.New(\"Not a valid hex string\")\n\t}\n\n\tfor i := range dst {\n\t\tfirst, ok := unhex(src[i*2])\n\t\tif !ok {\n\t\t\treturn dst, errors.New(\"Invalid hex char\") // Would def be nicer to have the byte in the message but w/e\n\t\t}\n\t\tsecond, ok := unhex(src[i*2+1])\n\t\tif !ok {\n\t\t\treturn dst, errors.New(\"Invalid hex char\")\n\t\t}\n\n\t\tdst[i] = first<<4 | second // equivalent to first * 16 + second\n\t}\n\n\treturn dst, nil\n}", "func ParseCode(addr string) (string, error) {\n\tl := len(addr)\n\tif l < 50 {\n\t\treturn \"\", InvalidAccountAddrError{reason: \"length\"}\n\t}\n\ti := l - 50 // start index of hex\n\treturn strings.ToUpper(addr[0:i]), nil\n}", "func (a *Address) UnmarshalJSON(input []byte) error {\n\treturn hexutil.UnmarshalFixedJSON(addressT, input, a[:])\n}", "func (a *Address) UnmarshalJSON(input []byte) error {\n\treturn hexutil.UnmarshalFixedJSON(addressT, input, a[:])\n}", "func decode(field reflect.Value, value string) error {\n\tif !canDecode(field) {\n\t\treturn errors.New(\"value cannot decode itself\")\n\t}\n\n\td, ok := field.Interface().(Decoder)\n\tif !ok && field.CanAddr() {\n\t\td, ok = field.Addr().Interface().(Decoder)\n\t}\n\n\tif ok {\n\t\treturn d.Decode(value)\n\t}\n\n\tt, ok := field.Interface().(encoding.TextUnmarshaler)\n\tif !ok && field.CanAddr() {\n\t\tt, ok = field.Addr().Interface().(encoding.TextUnmarshaler)\n\t}\n\n\tif ok {\n\t\treturn t.UnmarshalText([]byte(value))\n\t}\n\n\treturn errors.New(\"failed to find a decoding type\")\n}", "func DecodeAddressToPublicKey(in []byte) (*keys.StealthAddress, error) {\n\tpk := keys.NewStealthAddress()\n\tvar buf = &bytes.Buffer{}\n\t_, err := buf.Write(in)\n\tif err != nil {\n\t\treturn pk, err\n\t}\n\n\tpk.RG = new(common.JubJubCompressed)\n\tpk.PkR = new(common.JubJubCompressed)\n\tpk.RG.Data = make([]byte, 32)\n\tpk.PkR.Data = make([]byte, 32)\n\n\tif _, err = buf.Read(pk.RG.Data); err != nil {\n\t\treturn pk, err\n\t}\n\n\tif _, err = buf.Read(pk.PkR.Data); err != nil {\n\t\treturn pk, err\n\t}\n\n\treturn pk, nil\n}", "func ParseAddr(s string) (Addr, error) {\n\tcomma := strings.IndexByte(s, ',')\n\tif comma < 0 {\n\t\treturn Addr{}, serrors.New(\"invalid address: expected comma\", \"value\", s)\n\t}\n\tia, err := ParseIA(s[0:comma])\n\tif err != nil {\n\t\treturn Addr{}, err\n\t}\n\th, err := ParseHost(s[comma+1:])\n\tif err != nil {\n\t\treturn Addr{}, err\n\t}\n\treturn Addr{IA: ia, Host: h}, nil\n}", "func HexToAddress(h string) Address {\n\ttrimmed := strings.TrimPrefix(h, \"0x\")\n\tif len(trimmed)%2 == 1 {\n\t\ttrimmed = \"0\" + trimmed\n\t}\n\tb, _ := hex.DecodeString(trimmed)\n\treturn BytesToAddress(b)\n}", "func parseAddress(mailAddress string) (address *mail.Address, err error) {\n\tstrimmed := strings.TrimSpace(mailAddress)\n\n\tif address, err = mail.ParseAddress(strimmed); err == nil {\n\t\treturn address, nil\n\t}\n\n\tlog.Printf(\"[mail] parseAddress: %s\\n\", err)\n\treturn nil, err\n}", "func Fixed8DecodeString(s string) (Fixed8, error) {\n\tparts := strings.SplitN(s, \".\", 2)\n\tip, err := strconv.Atoi(parts[0])\n\tif err != nil {\n\t\treturn 0, errInvalidString\n\t} else if len(parts) == 1 {\n\t\treturn NewFixed8(ip), nil\n\t}\n\n\tfp, err := strconv.Atoi(parts[1])\n\tif err != nil || fp >= decimals {\n\t\treturn 0, errInvalidString\n\t}\n\tfor i := len(parts[1]); i < precision; i++ {\n\t\tfp *= 10\n\t}\n\treturn Fixed8(ip*decimals + fp), nil\n}", "func ParseAddress(address string) (string, string) {\n\tsplit := strings.Split(address, \":\")\n\tip := split[0]\n\tport := split[1]\n\n\treturn ip, port\n}", "func decode(id *ID, src []byte) {\n\tencoder.Decode(id[:], src)\n}", "func UserAddressFromAddress(a Address) *UserAddress {\n\tvar streetNum, streetName string\n\tparts := strings.Split(a.LineOne(), \" \")\n\n\tif _, err := strconv.Atoi(parts[0]); err == nil {\n\t\tstreetNum = parts[0]\n\t}\n\tstreetName = strings.Join(parts[1:], \" \")\n\n\tif addr, ok := a.(*UserAddress); ok {\n\t\tif len(addr.StreetNumber) == 0 {\n\t\t\taddr.StreetNumber = streetNum\n\t\t}\n\t\tif len(addr.StreetName) == 0 {\n\t\t\taddr.StreetName = streetName\n\t\t}\n\t\treturn addr\n\t}\n\n\treturn &UserAddress{\n\t\tStreet: a.LineOne(),\n\t\tStreetNumber: streetNum,\n\t\tStreetName: streetName,\n\t\tCityName: a.City(),\n\t\tPostalCode: a.Zip(),\n\t\tRegion: a.StateCode(),\n\t}\n}", "func DecodeBase58BitcoinAddress(addr string) (BitcoinAddress, error) {\n\tb, err := base58.Decode(addr)\n\tif err != nil {\n\t\treturn BitcoinAddress{}, err\n\t}\n\treturn BitcoinAddressFromBytes(b)\n}", "func ParseAddress(address string) (string, int) {\n\tmatch, err := gregex.MatchString(`^(.+):(\\d+)$`, address)\n\tif err == nil {\n\t\ti, _ := strconv.Atoi(match[2])\n\t\treturn match[1], i\n\t}\n\treturn \"\", 0\n}", "func Decode(b string) ([]byte, error) {\n\treturn DecodeAlphabet(b, BTCAlphabet)\n}", "func HashStringToAddress(str string) address.Address {\n\th := hash.Hash160b([]byte(str))\n\taddr, err := address.FromBytes(h[:])\n\tif err != nil {\n\t\tlog.L().Panic(\"Error when constructing the address of account protocol\", zap.Error(err))\n\t}\n\treturn addr\n}", "func BytesToAddress(b []byte) (Address, error) {\n\tif len(b) > AddressLength {\n\t\treturn Address{}, AddressOverflowError\n\t}\n\tvar a Address\n\ta.SetBytes(b)\n\treturn a, nil\n}", "func DecodeFromString(publicKey []byte, tokenString string, v interface{}) error {\n\tvar token Token\n\terr := json.Unmarshal([]byte(tokenString), &token)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn Decode(publicKey, token, v)\n}", "func IDHexDecode(s string) (core.ID, error) {\n\treturn core.IDHexDecode(s)\n}", "func HexToAddress(h string) (Address, error) {\n\ttrimmed := strings.TrimPrefix(h, \"0x\")\n\tif len(trimmed)%2 == 1 {\n\t\ttrimmed = \"0\" + trimmed\n\t}\n\tb, err := hex.DecodeString(trimmed)\n\tif err != nil {\n\t\treturn Address{}, InvalidHexAddressError\n\t}\n\treturn BytesToAddress(b)\n}", "func StrToAddr(x string) (uint32, error) {\n\tparts := strings.Split(x, \".\")\n\tif len(parts) != 4 {\n\t\treturn 0, fmt.Errorf(\"Invalid format\")\n\t}\n\n\tret := uint32(0)\n\tfor i := 0; i < 4; i++ {\n\t\ty, err := strconv.Atoi(parts[i])\n\t\tif err != nil {\n\t\t\treturn 0, fmt.Errorf(\"Unable to convert %q to int: %v\", parts[i], err)\n\t\t}\n\n\t\tif y > 255 {\n\t\t\treturn 0, fmt.Errorf(\"%d is too big for a uint8\", y)\n\t\t}\n\n\t\tret += uint32(math.Pow(256, float64(3-i))) * uint32(y)\n\t}\n\n\treturn ret, nil\n}", "func GetTestAddr(addr string, bech string) sdk.AccAddress {\n\n\tres, err := sdk.AccAddressFromHex(addr)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tbechexpected := res.String()\n\tif bech != bechexpected {\n\t\tpanic(\"Bech encoding doesn't match reference\")\n\t}\n\n\tbechres, err := sdk.AccAddressFromBech32(bech)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif !bytes.Equal(bechres, res) {\n\t\tpanic(\"Bech decode and hex decode don't match\")\n\t}\n\n\treturn res\n}", "func toStateAddress(prefix string, b []byte) string {\n\t// Make sure the address is padded correctly\n\tb = word256.RightPadBytes(b, 32)\n\n\treturn prefix + client.MustEncode(b)\n}" ]
[ "0.762846", "0.72298115", "0.72216547", "0.70370436", "0.7010531", "0.6963402", "0.69541156", "0.6823345", "0.68193984", "0.6794519", "0.67006904", "0.66820186", "0.6623264", "0.65907305", "0.65661985", "0.65495574", "0.648334", "0.6466039", "0.62854505", "0.6275847", "0.62742966", "0.62046146", "0.61446965", "0.6076108", "0.6075837", "0.599704", "0.5976486", "0.5976486", "0.5973362", "0.59251815", "0.5891787", "0.5886327", "0.58718926", "0.58702797", "0.57979697", "0.57799256", "0.57699615", "0.57505107", "0.57445985", "0.57423836", "0.57397014", "0.5726885", "0.5687597", "0.56556207", "0.562566", "0.55984384", "0.554593", "0.554385", "0.55356693", "0.55168426", "0.5501442", "0.54858553", "0.54709554", "0.5458618", "0.5430786", "0.54282814", "0.54172283", "0.54172283", "0.5407837", "0.5404417", "0.53878266", "0.53872204", "0.5362103", "0.5330295", "0.53186893", "0.5304509", "0.53025085", "0.52992696", "0.5285117", "0.5280775", "0.5262631", "0.5254506", "0.5251611", "0.524588", "0.52348226", "0.52179223", "0.5212351", "0.5209752", "0.52030134", "0.52030134", "0.52024984", "0.52016443", "0.5200561", "0.51984197", "0.5196811", "0.5196054", "0.5194987", "0.5191365", "0.5189248", "0.51742613", "0.51686865", "0.5166885", "0.51664615", "0.51497006", "0.5147992", "0.514426", "0.51427096", "0.5140523", "0.51320046", "0.5130498" ]
0.74612874
1
Test that Pool releases resources on GC.
Тест, проверяющий, что Pool освобождает ресурсы при сборке мусора.
func TestPoolRelease(t *testing.T) { testPool(t, false) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestPoolGC(t *testing.T) {\n\ttestPool(t, true)\n}", "func TestPool(t *testing.T) {\n\tdefer leaktest.Check(t)()\n\n\tgo func() {\n\t\tfor {\n\t\t\ttime.Sleep(time.Second)\n\t\t}\n\t}()\n}", "func (this *PoolTestSuite) TestInvalidateFreesCapacity() {\n\tthis.pool.Config.MaxTotal = 2\n\tthis.pool.Config.MaxWaitMillis = 500\n\tthis.pool.Config.BlockWhenExhausted = true\n\t// Borrow an instance and hold if for 5 seconds\n\tch1 := waitTestGoroutine(this.pool, 5000)\n\t// Borrow another instance\n\tobj := this.NoErrorWithResult(this.pool.BorrowObject())\n\t// Launch another goroutine - will block, but fail in 500 ms\n\tch2 := waitTestGoroutine(this.pool, 100)\n\t// Invalidate the object borrowed by this goroutine - should allow goroutine2 to create\n\tsleep(20)\n\tthis.NoError(this.pool.InvalidateObject(obj))\n\tsleep(600) // Wait for goroutine2 to timeout\n\tresult2 := <-ch2\n\tclose(ch2)\n\tif result2.error != nil {\n\t\tthis.Fail(result2.error.Error())\n\t}\n\t<-ch1\n\tclose(ch1)\n}", "func Test_Static_Pool_Destroy_And_Close(t *testing.T) {\n\tctx := context.Background()\n\tp, err := Initialize(\n\t\tctx,\n\t\tfunc() *exec.Cmd { return exec.Command(\"php\", \"../tests/client.php\", \"delay\", \"pipes\") },\n\t\tpipe.NewPipeFactory(),\n\t\t&Config{\n\t\t\tNumWorkers: 1,\n\t\t\tAllocateTimeout: time.Second,\n\t\t\tDestroyTimeout: time.Second,\n\t\t},\n\t)\n\n\tassert.NotNil(t, p)\n\tassert.NoError(t, err)\n\n\tp.Destroy(ctx)\n\t_, err = p.Exec(&payload.Payload{Body: []byte(\"100\")})\n\tassert.Error(t, err)\n}", "func TestPool(t *testing.T, p pool.Pool) {\n\tt.Helper()\n\tctx := context.Background()\n\toffers, err := p.Offers(ctx)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif got, want := len(offers), 1; got != want {\n\t\tt.Fatalf(\"got %v, want %v\", got, want)\n\t}\n\t// We accept half the memory and disk; we use 0 CPUs.\n\to := offers[0]\n\tr := o.Available()\n\tvar orig reflow.Resources\n\torig.Set(r)\n\tr[\"cpu\"] = 0\n\tr[\"mem\"] /= 2\n\tr[\"disk\"] /= 2\n\talloc, err := o.Accept(ctx, pool.AllocMeta{Want: r, Owner: \"test\", Labels: nil})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\toffers, err = p.Offers(ctx)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif got, want := len(offers), 1; got != want {\n\t\tt.Fatalf(\"got %v, want %v\", got, want)\n\t}\n\to = offers[0]\n\tlog.Printf(\"offer received %v\", o.Available())\n\tif got, want := o.Available()[\"mem\"], (orig[\"mem\"] - orig[\"mem\"]/2); got != want {\n\t\tt.Fatalf(\"got %v, want %v\", got, want)\n\t}\n\n\tid := reflow.Digester.FromString(\"alloctest\")\n\texec, err := alloc.Put(ctx, id, reflow.ExecConfig{\n\t\tType: \"exec\",\n\t\tImage: bashImage,\n\t\tCmd: \"echo logthis; echo foobar > $out\",\n\t})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\t// Give it some time to fetch the image, etc.\n\tctx, cancel := context.WithTimeout(ctx, 1*time.Minute)\n\tdefer cancel()\n\terr = exec.Wait(ctx)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tres, err := exec.Result(ctx)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif res.Err != nil {\n\t\tt.Fatal(res.Err)\n\t}\n\torigres := res\n\n\t// Now we force expiry to see that we can grab everything.\n\t// We grab a new alloc, and check that our old alloc died;\n\t// there should now be zero offers.\n\tintv := 1 * time.Nanosecond\n\td, err := alloc.Keepalive(ctx, intv)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif got, want := d, intv; got != want {\n\t\tt.Errorf(\"got %v, want %v\", got, want)\n\t}\n\ttime.Sleep(d)\n\toffers, err = p.Offers(ctx)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif got, want := len(offers), 1; got != want {\n\t\tt.Errorf(\"got %v, want %v\", got, want)\n\t}\n\to = offers[0]\n\tif got, want := o.Available(), orig; !got.Equal(want) {\n\t\tt.Errorf(\"got %v, want %v\", got, want)\n\t}\n\talloc1, err := o.Accept(ctx, pool.AllocMeta{Want: o.Available(), Owner: \"test\", Labels: nil})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif got, want := alloc1.Resources(), o.Available(); !got.Equal(want) {\n\t\tt.Errorf(\"got %v, want %v\", got, want)\n\t}\n\t// Look it up again to get its zombie.\n\t// Note: in client-server testing we're interacting directly with a client\n\t// not through a cluster implementation, so we'll need to strip off the\n\t// hostname ourselves.\n\tallocID := alloc.ID()\n\tif idx := strings.Index(allocID, \"/\"); idx > 0 {\n\t\tallocID = allocID[idx+1:]\n\t}\n\talloc, err = p.Alloc(ctx, allocID)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\texec, err = alloc.Get(ctx, id)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tres, err = exec.Result(ctx)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif got, want := res, origres; !reflect.DeepEqual(got, want) {\n\t\tt.Errorf(\"got %v, want %v\", got, want)\n\t}\n\trc, err := exec.Logs(ctx, true, false, false)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer rc.Close()\n\tb, err := ioutil.ReadAll(rc)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif got, want := string(b), \"logthis\\n\"; got != want {\n\t\tt.Errorf(\"got %q, want %q\", got, want)\n\t}\n\n\t// We shouldn't have any offers now.\n\toffers, err = p.Offers(ctx)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif got, want := len(offers), 0; got != want {\n\t\tt.Errorf(\"got %v, want %v\", got, want)\n\t}\n}", "func (p *Pool) Release(){\n if(p.availablePool != nil){\n for _,dbCon := range p.availablePool{\n dbCon.Close()\n }\n }else{\n p.availablePool=nil\n }\n}", "func TestCollectGarbage(t *testing.T) {\n\tCollectGarbage()\n}", "func Test_Static_Pool_Destroy_And_Close_While_Wait(t *testing.T) {\n\tctx := context.Background()\n\tp, err := Initialize(\n\t\tctx,\n\t\tfunc() *exec.Cmd { return exec.Command(\"php\", \"../tests/client.php\", \"delay\", \"pipes\") },\n\t\tpipe.NewPipeFactory(),\n\t\t&Config{\n\t\t\tNumWorkers: 1,\n\t\t\tAllocateTimeout: time.Second,\n\t\t\tDestroyTimeout: time.Second,\n\t\t},\n\t)\n\n\tassert.NotNil(t, p)\n\tassert.NoError(t, err)\n\n\tgo func() {\n\t\t_, errP := p.Exec(&payload.Payload{Body: []byte(\"100\")})\n\t\tif errP != nil {\n\t\t\tt.Errorf(\"error executing payload: error %v\", err)\n\t\t}\n\t}()\n\ttime.Sleep(time.Millisecond * 100)\n\n\tp.Destroy(ctx)\n\t_, err = p.Exec(&payload.Payload{Body: []byte(\"100\")})\n\tassert.Error(t, err)\n}", "func TestPoolTimeout(t *testing.T) {\n\tdefer leaktest.CheckTimeout(t, time.Second)()\n\n\tgo func() {\n\t\tfor {\n\t\t\ttime.Sleep(time.Second)\n\t\t}\n\t}()\n}", "func (p *Pool) Release() {\n\tp.once.Do(func() {\n\t\tatomic.StoreInt32(&p.release, 1)\n\t\tp.lock.Lock()\n\t\tp.workers.reset()\n\t\tp.lock.Unlock()\n\t\tdelete(PoolRecords, p.name)\n\t})\n}", "func (c *ChannelPool) Release() {\n\tc.mu.Lock()\n\tconns := c.conns\n\tc.conns = nil\n\tc.factory = nil\n\tcloseFun := c.close\n\tc.close = nil\n\tc.mu.Unlock()\n\n\tif conns == nil {\n\t\treturn\n\t}\n\n\tclose(conns)\n\tfor wrapConn := range conns {\n\t\tcloseFun(wrapConn.conn)\n\t}\n}", "func Release() {\n\tdefaultRoutinePool.Release()\n}", "func Test_Static_Pool_Handle_Dead(t *testing.T) {\n\tctx := context.Background()\n\tp, err := Initialize(\n\t\tcontext.Background(),\n\t\tfunc() *exec.Cmd { return exec.Command(\"php\", \"../tests/slow-destroy.php\", \"echo\", \"pipes\") },\n\t\tpipe.NewPipeFactory(),\n\t\t&Config{\n\t\t\tNumWorkers: 5,\n\t\t\tAllocateTimeout: time.Second * 100,\n\t\t\tDestroyTimeout: time.Second,\n\t\t},\n\t)\n\tassert.NoError(t, err)\n\tassert.NotNil(t, p)\n\n\ttime.Sleep(time.Second)\n\tfor i := range p.Workers() {\n\t\tp.Workers()[i].State().Set(worker.StateErrored)\n\t}\n\n\t_, err = p.Exec(&payload.Payload{Body: []byte(\"hello\")})\n\tassert.NoError(t, err)\n\tp.Destroy(ctx)\n}", "func (p *WorkerPool[T, R]) Release() {\n\tif p.resChan != nil {\n\t\tclose(p.resChan)\n\t}\n}", "func (p *connPool) gc() {\n\tp.openMu.Lock()\n\tdefer p.openMu.Unlock()\n\n\tp.mapMu.Lock()\n\tdefer p.mapMu.Unlock()\n\n\tvar activeRefs int64\n\tfor params, conn := range p.conns {\n\t\t// We hold the openMu write lock, so no one is trying to open a connection.\n\t\t// The only thing we might race with is callers decrementing the refCount,\n\t\t// which is fine. What matters is that no one will race to increment it,\n\t\t// which could reverse a decision we had already made to close the connection.\n\t\tconn.mu.Lock()\n\t\tactiveRefs += conn.refCount\n\t\tif conn.failed() {\n\t\t\t// The connection attempt failed, so remove it without trying to close it.\n\t\t\tdelete(p.conns, params)\n\t\t} else if conn.refCount <= 0 && time.Since(conn.lastOpened) > idleTTL {\n\t\t\tlog.WithFields(logrus.Fields{\n\t\t\t\t\"implementation\": params.Implementation,\n\t\t\t\t\"address\": params.Address,\n\t\t\t\t\"rootPath\": params.RootPath,\n\t\t\t}).Info(\"closing connection to Vitess topology server due to idle TTL\")\n\t\t\tdisconnects.WithLabelValues(reasonIdle).Inc()\n\n\t\t\tconn.Server.Close()\n\t\t\tdelete(p.conns, params)\n\t\t}\n\t\tconn.mu.Unlock()\n\t}\n\tconnCount.WithLabelValues(connStateActive).Set(float64(len(p.conns)))\n\tconnRefCount.WithLabelValues(connStateActive).Set(float64(activeRefs))\n\n\t// Clean up bad conns once they're no longer being used.\n\t// Make a list of bad conns that still have refs (we need to keep waiting).\n\tvar deadRefs int64\n\tstillUsed := make([]*Conn, 0, len(p.deadConns))\n\tfor _, conn := range p.deadConns {\n\t\tconn.mu.Lock()\n\t\tdeadRefs += conn.refCount\n\t\tif conn.refCount <= 0 {\n\t\t\tlog.WithFields(logrus.Fields{\n\t\t\t\t\"implementation\": conn.params.Implementation,\n\t\t\t\t\"address\": conn.params.Address,\n\t\t\t\t\"rootPath\": conn.params.RootPath,\n\t\t\t}).Info(\"closing connection to Vitess topology server due to liveness check failure\")\n\t\t\tdisconnects.WithLabelValues(reasonDead).Inc()\n\n\t\t\tconn.Server.Close()\n\t\t} else {\n\t\t\tlog.WithFields(logrus.Fields{\n\t\t\t\t\"implementation\": conn.params.Implementation,\n\t\t\t\t\"address\": conn.params.Address,\n\t\t\t\t\"rootPath\": conn.params.RootPath,\n\t\t\t}).Warning(\"cached connection to Vitess topology server failed liveness check but is still in use\")\n\n\t\t\tstillUsed = append(stillUsed, conn)\n\t\t}\n\t\tconn.mu.Unlock()\n\t}\n\tp.deadConns = stillUsed\n\tconnCount.WithLabelValues(connStateDead).Set(float64(len(p.deadConns)))\n\tconnRefCount.WithLabelValues(connStateDead).Set(float64(deadRefs))\n}", "func (p *Pool) Destroy() {\n\tp.Lock()\n\tdefer p.Unlock()\n\n\tp.factory = nil\n\tif p.conns == nil {\n\t\treturn\n\t}\n\n\tfor v := range p.conns {\n\t\tif v != nil {\n\t\t\tp.Close(v)\n\t\t}\n\t}\n\tp.conns = nil\n\n}", "func Test_Static_Pool_Slow_Destroy(t *testing.T) {\n\tp, err := Initialize(\n\t\tcontext.Background(),\n\t\tfunc() *exec.Cmd { return exec.Command(\"php\", \"../tests/slow-destroy.php\", \"echo\", \"pipes\") },\n\t\tpipe.NewPipeFactory(),\n\t\t&Config{\n\t\t\tNumWorkers: 5,\n\t\t\tAllocateTimeout: time.Second,\n\t\t\tDestroyTimeout: time.Second,\n\t\t},\n\t)\n\n\tassert.NoError(t, err)\n\tassert.NotNil(t, p)\n\n\tp.Destroy(context.Background())\n}", "func (pool *Pool) Close() {\n\tpool.mutex.Lock()\n\tpool.freelist = nil\n\tpool.mutex.Unlock()\n}", "func (p *Pool) Close(){\n p.availablePool[con]=p.usedPool[con]\n\tdelete(p.usedPool,con)\n}", "func (p *Pool) Release() {\n\tp.dispatcher.stop <- true\n\t<-p.dispatcher.stop\n}", "func registerPoolCleanup(cleanup func()) {\n\t// Ignore.\n}", "func (s *MockManagedThread) Release() {}", "func (c *channelPool) Release() {\n\tc.mu.Lock()\n\tfor _, servConn := range c.servConnsMap {\n\t\tfor ic := range servConn.idleConns {\n\t\t\tic.connWrap.CloseConnWrap()\n\t\t}\n\t\tclose(servConn.idleConns)\n\t\tservConn.openingConnNum = 0\n\t}\n\n\tc.servConnsMap = nil\n\tc.servAddrList = nil\n\n\tc.mu.Unlock()\n}", "func (p *connPool) Purge() {\n\tdpiPool := p.dpiPool\n\tp.dpiPool = nil\n\tif dpiPool != nil {\n\t\tC.dpiPool_close(dpiPool, C.DPI_MODE_POOL_CLOSE_FORCE)\n\t}\n}", "func TestFull(t *testing.T) {\n\tctx, cancel := context.WithCancel(context.Background())\n\tt.Cleanup(cancel)\n\tp := NewPool(ctx)\n\tvar wg sync.WaitGroup\n\t// signal channel to cause the first group of workers to\n\t// release their leases.\n\tg1done := make(chan struct{})\n\t// timeout channel indicating all of group one should\n\t// have acquired their leases.\n\tg1timeout := make(chan struct{})\n\tgo func() {\n\t\ttime.Sleep(time.Millisecond * 500)\n\t\tclose(g1timeout)\n\t}()\n\tp.Set(200)\n\t// spawn first group of workers.\n\tfor i := 0; i < 200; i++ {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tselect {\n\t\t\tcase l := <-p.Acquire():\n\t\t\t\t<-g1done\n\t\t\t\tl.Release()\n\t\t\tcase <-g1timeout:\n\t\t\t\tt.Errorf(\"Timeout waiting for lease\")\n\t\t\t}\n\t\t\twg.Done()\n\t\t}()\n\t}\n\t<-g1timeout\n\t// no additional leases should exist\n\tselect {\n\tcase l := <-p.Acquire():\n\t\tt.Errorf(\"unexpected lease: %+v\", l)\n\tdefault:\n\t}\n\t// spawn a second group of workers that won't be able to\n\t// acquire their leases until the first group is done.\n\tfor i := 0; i < 200; i++ {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tselect {\n\t\t\tcase <-p.Acquire():\n\t\t\t\t// leak deliberately\n\t\t\tcase <-time.After(time.Millisecond * 512):\n\t\t\t\tt.Errorf(\"Timeout waiting for lease\")\n\t\t\t}\n\t\t\twg.Done()\n\t\t}()\n\t}\n\t// signal first group is done\n\tclose(g1done)\n\t// wait for second group to acquire leases.\n\twg.Wait()\n\t// no additional leases should exist\n\tselect {\n\tcase l := <-p.Acquire():\n\t\tcounts := l.loadCounts()\n\t\tt.Errorf(\"unexpected lease grant: %+v, counts=%+v\", l, counts)\n\tcase <-time.After(time.Millisecond * 128):\n\t}\n\t// make one additional lease available\n\tp.Set(201)\n\tselect {\n\tcase l := <-p.Acquire():\n\t\tl.Release()\n\tcase <-time.After(time.Millisecond * 128):\n\t\tt.Errorf(\"timeout waiting for lease grant\")\n\t}\n}", "func (*waitForBoundPVCsMeasurement) Dispose() {}", "func TestTreeWalkPoolBasic(t *testing.T) {\n\t// Create a treeWalkPool\n\ttw := NewTreeWalkPool(1 * time.Second)\n\n\t// Create sample params\n\tparams := listParams{\n\t\tbucket: \"test-bucket\",\n\t}\n\n\t// Add a treeWalk to the pool\n\tresultCh := make(chan TreeWalkResult)\n\tendWalkCh := make(chan struct{})\n\ttw.Set(params, resultCh, endWalkCh)\n\n\t// Wait for treeWalkPool timeout to happen\n\t<-time.After(2 * time.Second)\n\tif c1, _ := tw.Release(params); c1 != nil {\n\t\tt.Error(\"treeWalk go-routine must have been freed\")\n\t}\n\n\t// Add the treeWalk back to the pool\n\ttw.Set(params, resultCh, endWalkCh)\n\n\t// Release the treeWalk before timeout\n\tselect {\n\tcase <-time.After(1 * time.Second):\n\t\tbreak\n\tdefault:\n\t\tif c1, _ := tw.Release(params); c1 == nil {\n\t\t\tt.Error(\"treeWalk go-routine got freed before timeout\")\n\t\t}\n\t}\n}", "func TestPool(t *testing.T) {\n\n\tvar res []WaitFunc\n\n\tpool := NewLimited(4)\n\tdefer pool.Close()\n\n\tnewFunc := func(d time.Duration) WorkFunc {\n\t\treturn func(context.Context) (interface{}, error) {\n\t\t\ttime.Sleep(d)\n\t\t\treturn nil, nil\n\t\t}\n\t}\n\n\treportCount := int64(0)\n\treport := func(v interface{}, err error) {\n\t\tatomic.AddInt64(&reportCount, 1)\n\t}\n\n\tfor i := 0; i < 4; i++ {\n\t\twu := pool.Queue(context.Background(), newFunc(time.Second*1), report)\n\t\tres = append(res, wu)\n\t}\n\n\tvar count int\n\n\tfor i, wu := range res {\n\t\tfmt.Println(i)\n\t\tv, e := wu()\n\t\trequire.Equal(t, e, nil)\n\t\trequire.Equal(t, v, nil)\n\t\tcount++\n\t}\n\n\trequire.Equal(t, count, 4)\n\trequire.Equal(t, reportCount, int64(4))\n\n\tpool.Close() // testing no error occurs as Close will be called twice once defer pool.Close() fires\n}", "func TestPoolDelete(t *testing.T) {\n\tinitDone := make(chan struct{})\n\tfixture := mkTestFixture([]*cilium_api_v2alpha1.CiliumLoadBalancerIPPool{\n\t\tmkPool(poolAUID, \"pool-a\", []string{\"10.0.10.0/24\"}),\n\t\tmkPool(poolBUID, \"pool-b\", []string{\"10.0.20.0/24\"}),\n\t}, true, true, func() {\n\t\tclose(initDone)\n\t})\n\n\tfixture.coreCS.Tracker().Add(\n\t\t&slim_core_v1.Service{\n\t\t\tObjectMeta: slim_meta_v1.ObjectMeta{\n\t\t\t\tName: \"service-a\",\n\t\t\t\tNamespace: \"default\",\n\t\t\t\tUID: serviceAUID,\n\t\t\t},\n\t\t\tSpec: slim_core_v1.ServiceSpec{\n\t\t\t\tType: slim_core_v1.ServiceTypeLoadBalancer,\n\t\t\t},\n\t\t},\n\t)\n\n\tvar allocPool string\n\n\tawait := fixture.AwaitService(func(action k8s_testing.Action) bool {\n\t\tif action.GetResource() != servicesResource || action.GetVerb() != \"patch\" {\n\t\t\treturn false\n\t\t}\n\n\t\tsvc := fixture.PatchedSvc(action)\n\n\t\tif len(svc.Status.LoadBalancer.Ingress) != 1 {\n\t\t\tt.Error(\"Expected service to receive exactly one ingress IP\")\n\t\t\treturn true\n\t\t}\n\n\t\tif strings.HasPrefix(svc.Status.LoadBalancer.Ingress[0].IP, \"10.0.10\") {\n\t\t\tallocPool = \"pool-a\"\n\t\t} else {\n\t\t\tallocPool = \"pool-b\"\n\t\t}\n\n\t\treturn true\n\t}, time.Second)\n\n\tgo fixture.hive.Start(context.Background())\n\tdefer fixture.hive.Stop(context.Background())\n\n\tif await.Block() {\n\t\tt.Fatal(\"Expected service status update\")\n\t}\n\t// If t.Error was called within the await\n\tif t.Failed() {\n\t\treturn\n\t}\n\n\t<-initDone\n\n\tawait = fixture.AwaitService(func(action k8s_testing.Action) bool {\n\t\tif action.GetResource() != servicesResource || action.GetVerb() != \"patch\" {\n\t\t\treturn false\n\t\t}\n\n\t\tsvc := fixture.PatchedSvc(action)\n\n\t\tif len(svc.Status.LoadBalancer.Ingress) != 1 {\n\t\t\tt.Error(\"Expected service to receive exactly one ingress IP\")\n\t\t\treturn true\n\t\t}\n\n\t\tif strings.HasPrefix(svc.Status.LoadBalancer.Ingress[0].IP, \"10.0.10\") {\n\t\t\tif allocPool == \"pool-a\" {\n\t\t\t\tt.Error(\"New IP was allocated from deleted pool\")\n\t\t\t\treturn true\n\t\t\t}\n\t\t} else {\n\t\t\tif allocPool == \"pool-b\" {\n\t\t\t\tt.Error(\"New IP was allocated from deleted pool\")\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\n\t\treturn true\n\t}, time.Second)\n\n\terr := fixture.poolClient.Delete(context.Background(), allocPool, meta_v1.DeleteOptions{})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif await.Block() {\n\t\tt.Fatal(\"Expected service status update\")\n\t}\n}", "func (rp *resourcePool) Close() {\n\trp.Lock()\n\tdefer rp.Unlock()\n\n\t// Clear the resources in the pool.\n\tfor ; rp.start != nil; rp.start = rp.start.next {\n\t\trp.closeFn(rp.start.value)\n\t\trp.totalSize--\n\t}\n\tatomic.StoreUint64(&rp.size, 0)\n\trp.end = nil\n\n\t// Stop the maintenance timer. If it's already fired, a call to Maintain might be waiting for the lock to be\n\t// released, so we set closed to make that call a no-op.\n\trp.closed = true\n\t_ = rp.maintainTimer.Stop()\n}", "func TestPools(t *testing.T) {\n\ttc := testutil.SystemTest(t)\n\tbuf := &bytes.Buffer{}\n\n\t// Tests\n\n\t// Get the pool.\n\ttestutil.Retry(t, 3, 2*time.Second, func(r *testutil.R) {\n\t\tpoolName := fmt.Sprintf(\"projects/%s/locations/%s/pools/%s\", tc.ProjectID, location, poolID)\n\t\tif err := getPool(buf, tc.ProjectID, location, poolID); err != nil {\n\t\t\tr.Errorf(\"getPool got err: %v\", err)\n\t\t}\n\t\tif got := buf.String(); !strings.Contains(got, poolName) {\n\t\t\tr.Errorf(\"getPool got\\n----\\n%v\\n----\\nWant to contain:\\n----\\n%v\\n----\\n\", got, poolName)\n\t\t}\n\t})\n\tbuf.Reset()\n\n\t// Update an existing pool. Set the updated peer network to \"\", which\n\t// is the same as the default otherwise the test will take a long time\n\t// to complete.\n\ttestutil.Retry(t, 3, 2*time.Second, func(r *testutil.R) {\n\t\tpoolName := fmt.Sprintf(\"projects/%s/locations/%s/pools/%s\", tc.ProjectID, location, poolID)\n\t\tif err := updatePool(buf, tc.ProjectID, location, poolID, \"\"); err != nil {\n\t\t\tr.Errorf(\"updatePool got err: %v\", err)\n\t\t}\n\t\tif got := buf.String(); !strings.Contains(got, poolName) {\n\t\t\tr.Errorf(\"updatePool got\\n----\\n%v\\n----\\nWant to contain:\\n----\\n%v\\n----\\n\", got, poolName)\n\t\t}\n\t})\n\tbuf.Reset()\n\tt.Logf(\"\\nTestPools() completed\\n\")\n}", "func (p *ResourcePool) destroy(wrapper *ResourceWrapper) {\n\n\t//you can destroy a resource if the pool is closed, no harm no foul\n\tp.resClose(wrapper.Resource)\n\tatomic.AddUint32(&p.open, ^uint32(0))\n\twrapper.p = nil\n}", "func (p *Pool) release() {\n\tif p.closed {\n\t\treturn\n\t}\n\tp.active--\n\tif p.cond != nil {\n\t\tp.cond.Signal()\n\t}\n\n}", "func TestPoolContext(t *testing.T) {\n\tctx, _ := context.WithTimeout(context.Background(), time.Second)\n\tdefer leaktest.CheckContext(ctx, t)()\n\n\tgo func() {\n\t\tfor {\n\t\t\ttime.Sleep(time.Second)\n\t\t}\n\t}()\n}", "func NewPool(t mockConstructorTestingTNewPool) *Pool {\n\tmock := &Pool{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func Close() {\n\tpool.Close()\n}", "func (i *Instance) dispose() {\n\ti.pool.Close()\n}", "func (p *Pool) Close() error {\n\treturn p.cleanup()\n}", "func (p *Pool) Cleanup() {\n\tp.Stop()\n\tp.lock.Lock()\n\tdefer p.lock.Unlock()\n\tp.baseCancel()\n}", "func (ft *FacadeUnitTest) Test_PoolCacheRemoveHost(c *C) {\n\tft.setupMockDFSLocking()\n\n\tpc := NewPoolCacheEnv()\n\n\tft.hostStore.On(\"FindHostsWithPoolID\", ft.ctx, pc.resourcePool.ID).\n\t\tReturn([]host.Host{pc.firstHost, pc.secondHost}, nil).Once()\n\n\tft.poolStore.On(\"GetResourcePools\", ft.ctx).\n\t\tReturn([]pool.ResourcePool{pc.resourcePool}, nil)\n\n\tft.serviceStore.On(\"GetServicesByPool\", ft.ctx, pc.resourcePool.ID).\n\t\tReturn([]service.Service{pc.firstService, pc.secondService}, nil)\n\n\tft.serviceStore.On(\"GetServiceDetails\", ft.ctx, pc.firstService.ID).\n\t\tReturn(&service.ServiceDetails{\n\t\t\tID: pc.firstService.ID,\n\t\t\tRAMCommitment: pc.firstService.RAMCommitment,\n\t\t}, nil)\n\n\tft.hostStore.On(\"Get\", ft.ctx, host.HostKey(pc.secondHost.ID), mock.AnythingOfType(\"*host.Host\")).\n\t\tReturn(nil).\n\t\tRun(func(args mock.Arguments) {\n\t\t\t*args.Get(2).(*host.Host) = pc.secondHost\n\t\t})\n\n\tft.zzk.On(\"RemoveHost\", &pc.secondHost).Return(nil)\n\tft.zzk.On(\"UnregisterDfsClients\", []host.Host{pc.secondHost}).Return(nil)\n\n\tft.hostkeyStore.On(\"Delete\", ft.ctx, pc.secondHost.ID).Return(nil)\n\tft.hostStore.On(\"Delete\", ft.ctx, host.HostKey(pc.secondHost.ID)).Return(nil)\n\n\tpools, err := ft.Facade.GetReadPools(ft.ctx)\n\tc.Assert(err, IsNil)\n\tc.Assert(pools, Not(IsNil))\n\tc.Assert(len(pools), Equals, 1)\n\n\tp := pools[0]\n\n\tc.Assert(p.ID, Equals, pc.resourcePool.ID)\n\tc.Assert(p.CoreCapacity, Equals, 14)\n\tc.Assert(p.MemoryCapacity, Equals, uint64(22000))\n\n\terr = ft.Facade.RemoveHost(ft.ctx, pc.secondHost.ID)\n\tc.Assert(err, IsNil)\n\n\tft.hostStore.On(\"FindHostsWithPoolID\", ft.ctx, pc.resourcePool.ID).\n\t\tReturn([]host.Host{pc.firstHost}, nil).Once()\n\n\tpools, err = ft.Facade.GetReadPools(ft.ctx)\n\tc.Assert(err, IsNil)\n\tc.Assert(pools, Not(IsNil))\n\tc.Assert(len(pools), Equals, 1)\n\n\tp = pools[0]\n\tc.Assert(p.ID, Equals, pc.resourcePool.ID)\n\tc.Assert(p.CoreCapacity, Equals, 6)\n\tc.Assert(p.MemoryCapacity, Equals, uint64(12000))\n}", "func ClosePool() error {\n\tif enable {\n\t\treturn pool.Close()\n\t}\n\treturn nil\n}", "func (s *WorkSuite) TestFull(c *check.C) {\n\tctx, cancel := context.WithCancel(context.TODO())\n\tdefer cancel()\n\tp := NewPool(ctx)\n\tkey := \"some-key\"\n\tvar wg sync.WaitGroup\n\t// signal channel to cause the first group of workers to\n\t// release their leases.\n\tg1done := make(chan struct{})\n\t// timeout channel indicating all of group one should\n\t// have acquired their leases.\n\tg1timeout := make(chan struct{})\n\tgo func() {\n\t\ttime.Sleep(time.Millisecond * 500)\n\t\tclose(g1timeout)\n\t}()\n\tp.Set(key, 200)\n\t// spawn first group of workers.\n\tfor i := 0; i < 200; i++ {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tselect {\n\t\t\tcase l := <-p.Acquire():\n\t\t\t\t<-g1done\n\t\t\t\tl.Release()\n\t\t\tcase <-g1timeout:\n\t\t\t\tc.Errorf(\"Timeout waiting for lease\")\n\t\t\t}\n\t\t\twg.Done()\n\t\t}()\n\t}\n\t<-g1timeout\n\t// no additional leases should exist\n\tselect {\n\tcase l := <-p.Acquire():\n\t\tc.Errorf(\"unexpected lease: %+v\", l)\n\tdefault:\n\t}\n\t// spawn a second group of workers that won't be able to\n\t// acquire their leases until the first group is done.\n\tfor i := 0; i < 200; i++ {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tselect {\n\t\t\tcase <-p.Acquire():\n\t\t\t\t// leak deliberately\n\t\t\tcase <-time.After(time.Millisecond * 512):\n\t\t\t\tc.Errorf(\"Timeout waiting for lease\")\n\t\t\t}\n\t\t\twg.Done()\n\t\t}()\n\t}\n\t// signal first group is done\n\tclose(g1done)\n\t// wait for second group to acquire leases.\n\twg.Wait()\n\t// no additional leases should exist\n\tselect {\n\tcase l := <-p.Acquire():\n\t\tcounts := l.loadCounts()\n\t\tc.Errorf(\"unexpected lease grant: %+v, counts=%+v\", l, counts)\n\tcase <-time.After(time.Millisecond * 128):\n\t}\n\t// make one additional lease available\n\tp.Set(key, 201)\n\tselect {\n\tcase l := <-p.Acquire():\n\t\tc.Assert(l.Key().(string), check.Equals, key)\n\t\tl.Release()\n\tcase <-time.After(time.Millisecond * 128):\n\t\tc.Errorf(\"timeout waiting for lease grant\")\n\t}\n}", "func TestPool(ctx context.Context, pool *redis.Pool) error {\n\tctx, cancel := context.WithCancel(ctx)\n\tconn, err := pool.GetContext(ctx)\n\tcancel()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"redis.TestPool: getting connection from pool failed\")\n\t}\n\n\t_, err = conn.Do(\"PING\")\n\t_ = conn.Close()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"redis.TestPool: performing PING failed\")\n\t}\n\n\treturn nil\n}", "func (t *tOps) close() {\n\tt.bpool.Close()\n\tt.cache.Close()\n\tif t.bcache != nil {\n\t\tt.bcache.CloseWeak()\n\t}\n}", "func (s WorkerSnapshot) Release() {}", "func (pool *Pool) Close() {\n\tif pool.list != nil {\n\t\tC.zpool_list_close(pool.list)\n\t\tpool.list = nil\n\t}\n}", "func (p *Pool) Close() {\n\t// fine to loop through the buckets unlocked\n\t// locking happens at the bucket level\n\tfor b, _ := range p.BucketMap {\n\n\t\t// MB-33208 defer closing connection pools until the bucket is no longer used\n\t\tbucket := p.BucketMap[b]\n\t\tbucket.Lock()\n\t\tbucket.closed = true\n\t\tbucket.Unlock()\n\t}\n}", "func cleanUp() {\n\tc := make(chan os.Signal, 1)\n\tsignal.Notify(c, os.Interrupt)\n\tsignal.Notify(c, syscall.SIGTERM)\n\tsignal.Notify(c, syscall.SIGKILL)\n\tgo func() {\n\t\t<-c\n\t\t_ = pool.Close()\n\t\tos.Exit(0)\n\t}()\n}", "func PoolCloseAll(pools []Pool) {\n\tfor _, p := range pools {\n\t\tp.Close()\n\t}\n}", "func (bcp *boltConnPool) Close() error {\n\tst := bcp.pool.Stats()\n\tif st.TotalConns != st.FreeConns {\n\n\t\tlog.Errorf(\n\t\t\t\"connection leaking detected: total_conns=%d free_conns=%d\",\n\t\t\tst.TotalConns, st.FreeConns,\n\t\t)\n\t}\n\treturn bcp.pool.Close()\n}", "func (p *connPool) Release(client *mcc.Client) {\n\t//reset connection deadlines\n\tconn := client.Hijack()\n\n\tconn.(net.Conn).SetReadDeadline(time.Date(1, time.January, 0, 0, 0, 0, 0, time.UTC))\n\tconn.(net.Conn).SetWriteDeadline(time.Date(1, time.January, 0, 0, 0, 0, 0, time.UTC))\n\n\tp.lock.RLock()\n\tdefer p.lock.RUnlock()\n\tif p.clients != nil {\n\t\tselect {\n\t\tcase p.clients <- client:\n\t\t\treturn\n\t\tdefault:\n\t\t\t//the pool reaches its capacity, drop the client on the floor\n\t\t\tclient.Close()\n\t\t\treturn\n\t\t}\n\t}\n}", "func (conductor *conductor) Release() {\n\tconductor.peersMutex.Lock()\n\tdefer conductor.peersMutex.Unlock()\n\tfor _, pc := range conductor.peers {\n\t\tglog.Infoln(\"Delete pc\")\n\t\tpc.Delete()\n\t\tdelete(conductor.peers, pc.(*peerConn).Pointer)\n\t}\n\tC.release_shared(conductor.shared)\n\tconductor.shared = nil\n}", "func (r *ResponsePool) Release(resp *Response) {\n\tresp.Reset()\n\tr.pool.Put(resp)\n}", "func (t *Tik) Release() {\n\tt.client.Close()\n}", "func TestPool(t *testing.T) {\n\n\t// All sub-tests to run. All of these tests will be run with a postgres\n\t// database and a bolt database.\n\ttests := map[string]func(*testing.T){\n\t\t\"testCSRFSecret\": testCSRFSecret,\n\t\t\"testLastPaymentInfo\": testLastPaymentInfo,\n\t\t\"testLastPaymentCreatedOn\": testLastPaymentCreatedOn,\n\t\t\"testPoolMode\": testPoolMode,\n\t\t\"testAcceptedWork\": testAcceptedWork,\n\t\t\"testAccount\": testAccount,\n\t\t\"testJob\": testJob,\n\t\t\"testDeleteJobsBeforeHeight\": testDeleteJobsBeforeHeight,\n\t\t\"testShares\": testShares,\n\t\t\"testPPSEligibleShares\": testPPSEligibleShares,\n\t\t\"testPPLNSEligibleShares\": testPPLNSEligibleShares,\n\t\t\"testPruneShares\": testPruneShares,\n\t\t\"testPayment\": testPayment,\n\t\t\"testPaymentAccessors\": testPaymentAccessors,\n\t\t\"testEndpoint\": testEndpoint,\n\t\t\"testClient\": testClient,\n\t\t\"testPaymentMgrPPS\": testPaymentMgrPPS,\n\t\t\"testPaymentMgrPPLNS\": testPaymentMgrPPLNS,\n\t\t\"testPaymentMgrMaturity\": testPaymentMgrMaturity,\n\t\t\"testPaymentMgrPayment\": testPaymentMgrPayment,\n\t\t\"testPaymentMgrDust\": testPaymentMgrDust,\n\t\t\"testChainState\": testChainState,\n\t\t\"testHub\": testHub,\n\t}\n\n\t// Run all tests with bolt DB.\n\tfor testName, test := range tests {\n\t\tboltDB, err := setupBoltDB()\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"setupBoltDB error: %v\", err)\n\t\t}\n\n\t\tdb = boltDB\n\n\t\tt.Run(testName+\"_Bolt\", test)\n\n\t\terr = teardownBoltDB(boltDB, testDB)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"bolt teardown error: %v\", err)\n\t\t}\n\t}\n\n\t// Run all tests with postgres DB.\n\tfor testName, test := range tests {\n\t\tpostgresDB, err := setupPostgresDB()\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"setupPostgresDB error: %v\", err)\n\t\t}\n\n\t\tdb = postgresDB\n\n\t\tt.Run(testName+\"_Postgres\", test)\n\n\t\terr = teardownPostgresDB(postgresDB)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"postgres teardown error: %v\", err)\n\t\t}\n\t}\n\n}", "func (p *DownloadPool) release(d *Downloader) {\n\tp.resource <- d // can never fail ...\n}", "func garbageCleaner() {\n\tfor _ = range time.Tick(1 * time.Minute) {\n\t\tstorage.Cleanup()\n\t}\n}", "func (pool Pool) Close() error {\n\treturn pool.Pool.Close()\n}", "func TestFreelist_release(t *testing.T) {\n\tf := newFreelist()\n\tf.free(100, &page{id: 12, overflow: 1})\n\tf.free(100, &page{id: 9})\n\tf.free(102, &page{id: 39})\n\tf.release(100)\n\tf.release(101)\n\tif exp := []pgid{9, 12, 13}; !reflect.DeepEqual(exp, f.ids) {\n\t\tt.Fatalf(\"exp=%v; got=%v\", exp, f.ids)\n\t}\n\n\tf.release(102)\n\tif exp := []pgid{9, 12, 13, 39}; !reflect.DeepEqual(exp, f.ids) {\n\t\tt.Fatalf(\"exp=%v; got=%v\", exp, f.ids)\n\t}\n}", "func (p *Pool) Close() {\n\tclose(p.tasks)\n}", "func TestFinalize(t *testing.T) {\n\tnumGRBefore := runtime.NumGoroutine()\n\t// Create a set of 100 agreement components, and finalize them immediately\n\tfor i := 0; i < 100; i++ {\n\t\tc, _ := agreement.WireAgreement(50)\n\t\tc.FinalizeRound()\n\t}\n\n\t// Ensure we have freed up all of the resources associated with these components\n\tnumGRAfter := runtime.NumGoroutine()\n\t// We should have roughly the same amount of goroutines\n\tassert.InDelta(t, numGRBefore, numGRAfter, 10.0)\n}", "func ClosePool() error {\n\tif cfg.Disable {\n\t\treturn nil\n\t}\n\n\treturn pool.Close()\n}", "func GC(maxAge int) {\n\tmemoryMutex.Lock()\n\tdefer memoryMutex.Unlock()\n\n\tif allocatedSlabs > 0 {\n\t\tfor s := range slabs {\n\t\t\t//if slabs[s] != nil {\n\t\t\t//\tfmt.Printf(\"slab %d, free %d, total %d, touched %.2f sec\\n\", s, slabs[s].free, len(slabs[s].next), time.Since(slabs[s].touched).Seconds())\n\t\t\t//}\n\t\t\tif slabs[s] != nil && slabs[s].free == len(slabs[s].next) && time.Since(slabs[s].touched).Seconds() >= float64(maxAge) {\n\t\t\t\tdeallocateSlab(uint16(s))\n\t\t\t\truntime.GC()\n\t\t\t}\n\t\t}\n\t}\n}", "func (p *request) Release() {\n\tp.ctx = nil\n\tp.Entry = nil\n\tp.read = false\n\trequestPool.Put(p)\n}", "func TestAllocRunner_Destroy(t *testing.T) {\n\tci.Parallel(t)\n\n\t// Ensure task takes some time\n\talloc := mock.BatchAlloc()\n\ttask := alloc.Job.TaskGroups[0].Tasks[0]\n\ttask.Config[\"run_for\"] = \"10s\"\n\n\tconf, cleanup := testAllocRunnerConfig(t, alloc)\n\tdefer cleanup()\n\n\t// Use a MemDB to assert alloc state gets cleaned up\n\tconf.StateDB = state.NewMemDB(conf.Logger)\n\n\tar, err := NewAllocRunner(conf)\n\trequire.NoError(t, err)\n\tgo ar.Run()\n\n\t// Wait for alloc to be running\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tstate := ar.AllocState()\n\n\t\treturn state.ClientStatus == structs.AllocClientStatusRunning,\n\t\t\tfmt.Errorf(\"got client status %v; want running\", state.ClientStatus)\n\t}, func(err error) {\n\t\trequire.NoError(t, err)\n\t})\n\n\t// Assert state was stored\n\tls, ts, err := conf.StateDB.GetTaskRunnerState(alloc.ID, task.Name)\n\trequire.NoError(t, err)\n\trequire.NotNil(t, ls)\n\trequire.NotNil(t, ts)\n\n\t// Now destroy\n\tar.Destroy()\n\n\tselect {\n\tcase <-ar.DestroyCh():\n\t\t// Destroyed properly!\n\tcase <-time.After(10 * time.Second):\n\t\trequire.Fail(t, \"timed out waiting for alloc to be destroyed\")\n\t}\n\n\t// Assert alloc is dead\n\tstate := ar.AllocState()\n\trequire.Equal(t, structs.AllocClientStatusComplete, state.ClientStatus)\n\n\t// Assert the state was cleaned\n\tls, ts, err = conf.StateDB.GetTaskRunnerState(alloc.ID, task.Name)\n\trequire.NoError(t, err)\n\trequire.Nil(t, ls)\n\trequire.Nil(t, ts)\n\n\t// Assert the alloc directory was cleaned\n\tif _, err := os.Stat(ar.allocDir.AllocDir); err == nil {\n\t\trequire.Fail(t, \"alloc dir still exists: %v\", ar.allocDir.AllocDir)\n\t} else if !os.IsNotExist(err) {\n\t\trequire.Failf(t, \"expected NotExist error\", \"found %v\", err)\n\t}\n}", "func TestDoubleFree(t *testing.T) {\n\tcl := NewTestClient(t)\n\tFreeTest(t, cl)\n\tFreeTest(t, cl)\n}", "func PoolDestroy(name string) error {\n\tcmd := &Cmd{}\n\treturn NvlistIoctl(zfsHandle.Fd(), ZFS_IOC_POOL_DESTROY, name, cmd, nil, nil, nil)\n}", "func (p *pool) close() {\n\tif p.closed {\n\t\treturn\n\t}\n\tp.mu.Lock()\n\tdefer p.mu.Unlock()\n\n\tp.closed = true\n\tclose(p.readyChannel)\n\n\tfor connIndex := range p.connList {\n\t\tp.connList[connIndex].close()\n\t}\n\tp.connList = nil\n}", "func PoolDestroy(ctx context.Context, rpcClient UnaryInvoker, req *PoolDestroyReq) error {\n\treq.setRPC(func(ctx context.Context, conn *grpc.ClientConn) (proto.Message, error) {\n\t\treturn mgmtpb.NewMgmtSvcClient(conn).PoolDestroy(ctx, &mgmtpb.PoolDestroyReq{\n\t\t\tSys: req.getSystem(rpcClient),\n\t\t\tId: req.ID,\n\t\t\tForce: req.Force,\n\t\t})\n\t})\n\n\trpcClient.Debugf(\"Destroy DAOS pool request: %v\\n\", req)\n\tur, err := rpcClient.InvokeUnaryRPC(ctx, req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmsResp, err := ur.getMSResponse()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"pool destroy failed\")\n\t}\n\trpcClient.Debugf(\"Destroy DAOS pool response: %s\\n\", msResp)\n\n\treturn nil\n}", "func (q *HTTP) Release() {\n\tq.HumanLabel = q.HumanLabel[:0]\n\tq.HumanDescription = q.HumanDescription[:0]\n\tq.id = 0\n\tq.Method = q.Method[:0]\n\tq.Path = q.Path[:0]\n\tq.Body = q.Body[:0]\n\tq.StartTimestamp = 0\n\tq.EndTimestamp = 0\n\n\tHTTPPool.Put(q)\n}", "func (cluster *mongoCluster) Release() {\n\tcluster.Lock()\n\tif cluster.references == 0 {\n\t\tpanic(\"cluster.Release() with references == 0\")\n\t}\n\tcluster.references--\n\tif cluster.references == 0 {\n\t\tfor _, server := range cluster.servers.Slice() {\n\t\t\tserver.Close()\n\t\t}\n\t}\n\tcluster.Unlock()\n}", "func (x *FzPool) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (c *ChannelPool) Close() {\n\tc.mu.Lock()\n\tconns := c.conns\n\tc.conns = nil\n\tc.factory = nil\n\tc.mu.Unlock()\n\n\tif conns == nil {\n\t\treturn\n\t}\n\n\tclose(conns)\n\tfor conn := range conns {\n\t\tconn.Close()\n\t}\n}", "func (p *Pool) Close() {\n\tp.SetSize(0)\n\tclose(p.reqChan)\n}", "func (cp *Pool) Close() {\n\tlog.Infof(\"connpool - started execution of Close\")\n\tp := cp.pool()\n\tlog.Infof(\"connpool - found the pool\")\n\tif p == nil {\n\t\tlog.Infof(\"connpool - pool is empty\")\n\t\treturn\n\t}\n\t// We should not hold the lock while calling Close\n\t// because it waits for connections to be returned.\n\tlog.Infof(\"connpool - calling close on the pool\")\n\tp.Close()\n\tlog.Infof(\"connpool - acquiring lock\")\n\tcp.mu.Lock()\n\tlog.Infof(\"connpool - acquired lock\")\n\tcp.connections.Close()\n\tcp.connections = nil\n\tcp.mu.Unlock()\n\tlog.Infof(\"connpool - closing dbaPool\")\n\tcp.dbaPool.Close()\n\tlog.Infof(\"connpool - finished execution of Close\")\n}", "func TestAllocGarbageCollector_MakeRoomFor_MaxAllocs(t *testing.T) {\n\tci.Parallel(t)\n\n\tconst maxAllocs = 6\n\trequire := require.New(t)\n\n\tserver, serverAddr, cleanupS := testServer(t, nil)\n\tdefer cleanupS()\n\ttestutil.WaitForLeader(t, server.RPC)\n\n\tclient, cleanup := TestClient(t, func(c *config.Config) {\n\t\tc.GCMaxAllocs = maxAllocs\n\t\tc.GCDiskUsageThreshold = 100\n\t\tc.GCInodeUsageThreshold = 100\n\t\tc.GCParallelDestroys = 1\n\t\tc.GCInterval = time.Hour\n\t\tc.RPCHandler = server\n\t\tc.Servers = []string{serverAddr}\n\t\tc.ConsulConfig.ClientAutoJoin = new(bool)\n\t})\n\tdefer cleanup()\n\twaitTilNodeReady(client, t)\n\n\tjob := mock.Job()\n\tjob.TaskGroups[0].Count = 1\n\tjob.TaskGroups[0].Tasks[0].Driver = \"mock_driver\"\n\tjob.TaskGroups[0].Tasks[0].Config = map[string]interface{}{\n\t\t\"run_for\": \"30s\",\n\t}\n\n\tindex := uint64(98)\n\tnextIndex := func() uint64 {\n\t\tindex++\n\t\treturn index\n\t}\n\n\tupsertJobFn := func(server *nomad.Server, j *structs.Job) {\n\t\tstate := server.State()\n\t\trequire.NoError(state.UpsertJob(structs.MsgTypeTestSetup, nextIndex(), j))\n\t\trequire.NoError(state.UpsertJobSummary(nextIndex(), mock.JobSummary(j.ID)))\n\t}\n\n\t// Insert the Job\n\tupsertJobFn(server, job)\n\n\tupsertAllocFn := func(server *nomad.Server, a *structs.Allocation) {\n\t\tstate := server.State()\n\t\trequire.NoError(state.UpsertAllocs(structs.MsgTypeTestSetup, nextIndex(), []*structs.Allocation{a}))\n\t}\n\n\tupsertNewAllocFn := func(server *nomad.Server, j *structs.Job) *structs.Allocation {\n\t\talloc := mock.Alloc()\n\t\talloc.Job = j\n\t\talloc.JobID = j.ID\n\t\talloc.NodeID = client.NodeID()\n\n\t\tupsertAllocFn(server, alloc)\n\n\t\treturn alloc.Copy()\n\t}\n\n\tvar allocations []*structs.Allocation\n\n\t// Fill the node with allocations\n\tfor i := 0; i < maxAllocs; i++ {\n\t\tallocations = append(allocations, upsertNewAllocFn(server, job))\n\t}\n\n\t// Wait until the allocations are ready\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := len(client.getAllocRunners())\n\n\t\treturn ar == maxAllocs, fmt.Errorf(\"Expected %d allocs, got %d\", maxAllocs, ar)\n\t}, func(err error) {\n\t\tt.Fatalf(\"Allocs did not start: %v\", err)\n\t})\n\n\t// Mark the first three as terminal\n\tfor i := 0; i < 3; i++ {\n\t\tallocations[i].DesiredStatus = structs.AllocDesiredStatusStop\n\t\tupsertAllocFn(server, allocations[i].Copy())\n\t}\n\n\t// Wait until the allocations are stopped\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := client.getAllocRunners()\n\t\tstopped := 0\n\t\tfor _, r := range ar {\n\t\t\tif r.Alloc().TerminalStatus() {\n\t\t\t\tstopped++\n\t\t\t}\n\t\t}\n\n\t\treturn stopped == 3, fmt.Errorf(\"Expected %d terminal allocs, got %d\", 3, stopped)\n\t}, func(err error) {\n\t\tt.Fatalf(\"Allocs did not terminate: %v\", err)\n\t})\n\n\t// Upsert a new allocation\n\t// This does not get appended to `allocations` as we do not use them again.\n\tupsertNewAllocFn(server, job)\n\n\t// A single allocation should be GC'd\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := client.getAllocRunners()\n\t\tdestroyed := 0\n\t\tfor _, r := range ar {\n\t\t\tif r.IsDestroyed() {\n\t\t\t\tdestroyed++\n\t\t\t}\n\t\t}\n\n\t\treturn destroyed == 1, fmt.Errorf(\"Expected %d gc'd ars, got %d\", 1, destroyed)\n\t}, func(err error) {\n\t\tt.Fatalf(\"Allocs did not get GC'd: %v\", err)\n\t})\n\n\t// Upsert a new allocation\n\t// This does not get appended to `allocations` as we do not use them again.\n\tupsertNewAllocFn(server, job)\n\n\t// 2 allocations should be GC'd\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := client.getAllocRunners()\n\t\tdestroyed := 0\n\t\tfor _, r := range ar {\n\t\t\tif r.IsDestroyed() {\n\t\t\t\tdestroyed++\n\t\t\t}\n\t\t}\n\n\t\treturn destroyed == 2, fmt.Errorf(\"Expected %d gc'd ars, got %d\", 2, destroyed)\n\t}, func(err error) {\n\t\tt.Fatalf(\"Allocs did not get GC'd: %v\", err)\n\t})\n\n\t// check that all 8 get run eventually\n\ttestutil.WaitForResult(func() (bool, error) {\n\t\tar := client.getAllocRunners()\n\t\tif len(ar) != 8 {\n\t\t\treturn false, fmt.Errorf(\"expected 8 ARs, found %d: %v\", len(ar), ar)\n\t\t}\n\t\treturn true, nil\n\t}, func(err error) {\n\t\trequire.NoError(err)\n\t})\n}", "func (m *MockPool) ReleaseAndWait() {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"ReleaseAndWait\")\n}", "func TestPoolDoDoesNotBlock(t *T) {\n\tsize := 10\n\trequestTimeout := 200 * time.Millisecond\n\tredialInterval := 100 * time.Millisecond\n\n\tconnFunc := PoolConnFunc(func(string, string) (Conn, error) {\n\t\treturn dial(DialTimeout(requestTimeout)), nil\n\t})\n\tpool := testPool(size,\n\t\tPoolOnEmptyCreateAfter(redialInterval),\n\t\tPoolPipelineWindow(0, 0),\n\t\tconnFunc,\n\t)\n\n\tassertPoolConns := func(exp int) {\n\t\tassert.Equal(t, exp, pool.NumAvailConns())\n\t}\n\tassertPoolConns(size)\n\n\tvar wg sync.WaitGroup\n\tvar timeExceeded uint32\n\n\t// here we try to imitate external requests which come one at a time\n\t// and exceed the number of connections in pool\n\tfor i := 0; i < 5*size; i++ {\n\t\twg.Add(1)\n\t\tgo func(i int) {\n\t\t\ttime.Sleep(time.Duration(i*10) * time.Millisecond)\n\n\t\t\ttimeStart := time.Now()\n\t\t\terr := pool.Do(WithConn(\"\", func(conn Conn) error {\n\t\t\t\ttime.Sleep(requestTimeout)\n\t\t\t\tconn.(*ioErrConn).lastIOErr = errors.New(\"i/o timeout\")\n\t\t\t\treturn nil\n\t\t\t}))\n\t\t\tassert.NoError(t, err)\n\n\t\t\tif time.Since(timeStart)-requestTimeout-redialInterval > 20*time.Millisecond {\n\t\t\t\tatomic.AddUint32(&timeExceeded, 1)\n\t\t\t}\n\t\t\twg.Done()\n\t\t}(i)\n\t}\n\n\twg.Wait()\n\tassert.True(t, timeExceeded == 0)\n}", "func TestPoolGet(t *T) {\n\tgetBlock := func(p *Pool) (time.Duration, error) {\n\t\tstart := time.Now()\n\t\t_, err := p.get()\n\t\treturn time.Since(start), err\n\t}\n\n\t// this one is a bit weird, cause it would block infinitely if we let it\n\tt.Run(\"onEmptyWait\", func(t *T) {\n\t\tpool := testPool(1, PoolOnEmptyWait())\n\t\tconn, err := pool.get()\n\t\tassert.NoError(t, err)\n\n\t\tgo func() {\n\t\t\ttime.Sleep(2 * time.Second)\n\t\t\tpool.put(conn)\n\t\t}()\n\t\ttook, err := getBlock(pool)\n\t\tassert.NoError(t, err)\n\t\tassert.True(t, took-2*time.Second < 20*time.Millisecond)\n\t})\n\n\t// the rest are pretty straightforward\n\tgen := func(mkOpt func(time.Duration) PoolOpt, d time.Duration, expErr error) func(*T) {\n\t\treturn func(t *T) {\n\t\t\tpool := testPool(0, PoolOnFullClose(), mkOpt(d))\n\t\t\ttook, err := getBlock(pool)\n\t\t\tassert.Equal(t, expErr, err)\n\t\t\tassert.True(t, took-d < 20*time.Millisecond)\n\t\t}\n\t}\n\n\tt.Run(\"onEmptyCreate\", gen(PoolOnEmptyCreateAfter, 0, nil))\n\tt.Run(\"onEmptyCreateAfter\", gen(PoolOnEmptyCreateAfter, 1*time.Second, nil))\n\tt.Run(\"onEmptyErr\", gen(PoolOnEmptyErrAfter, 0, ErrPoolEmpty))\n\tt.Run(\"onEmptyErrAfter\", gen(PoolOnEmptyErrAfter, 1*time.Second, ErrPoolEmpty))\n}", "func (p *Pools) Close() {\n\tfor _, pool := range p.pools {\n\t\tpool.close()\n\t}\n\tp.Flush(true)\n}", "func (p *unlimitedPool) Close() {\n\n\terr := &ErrPoolClosed{s: errClosed}\n\tp.closeWithError(err)\n}", "func TestSizedBufferPool(t *testing.T) {\n\tsize := 4\n\tcapacity := 1024\n\n\tbufPool := NewSizedBufferPool(size, capacity)\n\n\tb := bufPool.Get()\n\n\t// Check the cap before we use the buffer.\n\tif cap(b.Bytes()) != capacity {\n\t\tt.Fatalf(\"buffer capacity incorrect: got %v want %v\", cap(b.Bytes()),\n\t\t\tcapacity)\n\t}\n\n\t// Grow the buffer beyond our capacity and return it to the pool\n\tb.Grow(capacity * 3)\n\tbufPool.Put(b)\n\n\t// Add some additional buffers to fill up the pool.\n\tfor i := 0; i < size; i++ {\n\t\tbufPool.Put(bytes.NewBuffer(make([]byte, 0, bufPool.alloc*2)))\n\t}\n\n\t// Check that oversized buffers are being replaced.\n\tif len(bufPool.pool) < size {\n\t\tt.Fatalf(\"buffer pool too small: got %v want %v\", len(bufPool.pool), size)\n\t}\n\n\t// Close the channel so we can iterate over it.\n\tclose(bufPool.pool)\n\n\t// Check that there are buffers of the correct capacity in the pool.\n\tfor buffer := range bufPool.pool {\n\t\tif cap(buffer.Bytes()) != bufPool.alloc {\n\t\t\tt.Fatalf(\"returned buffers wrong capacity: got %v want %v\",\n\t\t\t\tcap(buffer.Bytes()), capacity)\n\t\t}\n\t}\n}", "func GC()", "func (cop *ConnPool) close() {\n\tif cop.closed {\n\t\treturn\n\t}\n\tcop.closed = true\n\n\t// wait for connection all closed\n\tclose(cop.connDelayCloseCh)\n\t<-cop.connDelayClosed\n\n\tfor i, cha := range cop.idleChas {\n\t\tcha.close()\n\t\tcop.idleChas[i] = nil\n\t}\n\tcop.idleChas = nil\n\n\tfor i, conn := range cop.conns {\n\t\tconn.close(true)\n\t\tcop.conns[i] = nil\n\t}\n\tcop.conns = nil\n}", "func (bp *BrokerPool) Close() {\n\tbp.lock.Lock()\n\tdefer bp.lock.Unlock()\n\n\t// Closing the shared chan will trigger a cascading teardown procedure for\n\t// brokers and their clients.\n\tclose(bp.ConnectionsChan)\n\tbp.ConnectionsChan = nil\n}", "func (p *ResourcePool) Close() {\n\n\tp.fMutex.Lock()\n\tdefer p.fMutex.Unlock()\n\n\tp.closed = true\n\n\tfor {\n\t\tselect {\n\t\tcase resource := <-p.resources:\n\t\t\tp.resClose(resource.Resource)\n\t\t\tatomic.AddUint32(&p.nAvailable, ^uint32(0))\n\t\t\tatomic.AddUint32(&p.open, ^uint32(0))\n\t\tdefault:\n\t\t\tclose(p.resources)\n\t\t\treturn\n\t\t}\n\t}\n}", "func (p *Pool) Close() {\n\tp.stopOnce.Do(func() {\n\t\tclose(p.stopCh)\n\n\t\tvar conn *redis.Client\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase conn = <-p.pool:\n\t\t\t\tconn.Close()\n\t\t\tdefault:\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t})\n}", "func (c *Ci) Close() {\n\tc.pool.Close()\n}", "func TestGoroutineLeaks_OnSystemShutdown(t *testing.T) {\n\n\tbefore, _ := os.Create(\"/tmp/gorou-shutdown-before.out\")\n\tdefer before.Close()\n\tafter, _ := os.Create(\"/tmp/gorou-shutdown-after.out\")\n\tdefer after.Close()\n\n\tnumGoroutineBefore := runtime.NumGoroutine()\n\tpprof.Lookup(\"goroutine\").WriteTo(before, 1)\n\n\tt.Run(\"TestCreateGazillionTransactionsWhileTransportIsDuplicatingRandomMessages\", TestCreateGazillionTransactionsWhileTransportIsDuplicatingRandomMessages)\n\tt.Run(\"TestCreateGazillionTransactionsWhileTransportIsDroppingRandomMessages\", TestCreateGazillionTransactionsWhileTransportIsDroppingRandomMessages)\n\tt.Run(\"TestCreateGazillionTransactionsWhileTransportIsDelayingRandomMessages\", TestCreateGazillionTransactionsWhileTransportIsDelayingRandomMessages)\n\n\ttime.Sleep(100 * time.Millisecond) // give goroutines time to terminate\n\truntime.GC()\n\ttime.Sleep(100 * time.Millisecond) // give goroutines time to terminate\n\n\tnumGoroutineAfter := runtime.NumGoroutine()\n\tpprof.Lookup(\"goroutine\").WriteTo(after, 1)\n\n\trequire.Equal(t, numGoroutineBefore, numGoroutineAfter, \"number of goroutines should be equal, compare /tmp/gorou-shutdown-before.out and /tmp/gorou-shutdown-after.out to see stack traces of the leaks\")\n}", "func (m *TrxMgr) shrinkPoolMemories() {\n\tif atomic.LoadUint64(&m.shrinkCounter) > sShrinkCountWaterMark {\n\t\tatomic.StoreUint64(&m.shrinkCounter, 0)\n\n\t\twaiting, fetched := make(map[string]*TrxEntry), make(map[string]*TrxEntry)\n\t\tfor k, e := range m.waiting {\n\t\t\twaiting[k] = e\n\t\t}\n\t\tfor k, e := range m.fetched {\n\t\t\tfetched[k] = e\n\t\t}\n\t\tm.waiting, m.fetched = waiting, fetched\n\t}\n}", "func (p *pool) release(ch *channel) error {\n\tif p.closed {\n\t\treturn errors.New(\"pool closed\")\n\t}\n\n\tselect {\n\tcase p.readyChannel <- ch:\n\t\treturn nil\n\tdefault:\n\t\treturn errors.New(\"ConnPool is full\")\n\t}\n}", "func (p *Pool) Close() error {\n\treturn <-p.close()\n}", "func (m *MultiConnPool) Close() {\n\tfor _, p := range m.Pools {\n\t\tp.Close()\n\t}\n}", "func (f *CPool) Close() error {\n\tif f.pool == nil {\n\t\treturn nil\n\t}\n\tC.fd_pool_free(f.pool)\n\tC.free(unsafe.Pointer(f.dialDomain))\n\tf.pool = nil\n\treturn nil\n}", "func (c *client) release(conn Conn, err error) {\n\tif err != nil {\n\t\tif err := conn.Close(); err != nil {\n\t\t\tc.logger.Printf(\"Could not close connection (%s)\", err.Error())\n\t\t}\n\n\t\tconn = nil\n\t}\n\n\tc.pool.Release(conn)\n}", "func (this *PoolTestSuite) TestNoInstanceOverlap() {\n\tmaxTotal := 5\n\tnumGoroutines := 100\n\tdelay := 1\n\titerations := 1000\n\tthis.pool.Config.MaxTotal = maxTotal\n\tthis.pool.Config.MaxIdle = maxTotal\n\tthis.pool.Config.TestOnBorrow = true\n\tthis.pool.Config.BlockWhenExhausted = true\n\tthis.pool.Config.MaxWaitMillis = int64(-1)\n\trunTestGoroutines(this.T(), numGoroutines, iterations, delay, this.pool)\n\tthis.Equal(0, this.pool.GetDestroyedByBorrowValidationCount())\n}", "func TestPackage(t *testing.T) {\n\tif testing.Short() {\n\t\treturn\n\t}\n\n\tss := servers{\n\t\t&server{address: \"127.0.0.1:28081\"},\n\t\t&server{address: \"127.0.0.1:28082\"},\n\t\t&server{address: \"127.0.0.1:28083\"},\n\t\t&server{address: \"127.0.0.1:28084\"},\n\t}\n\n\tc := &client{\n\t\td: &dialer{},\n\t\ts: (&scheduler{}).init(ss),\n\t\texit: make(chan struct{}),\n\t}\n\tc.pool, _ = connpool.New(c.d.dial, poolCapacity, poolCleanupPeriod)\n\n\tgo ss.run()\n\ttime.Sleep(time.Second) // Wait for servers have already been running.\n\tgo c.run()\n\n\ttimer := time.NewTimer(samplingPeriod)\n\n\tvar old = &stats{}\n\texec := func(old *stats) *stats {\n\t\ts := &stats{}\n\t\tss.sampling(s)\n\t\tc.sampling(s)\n\t\ts.assert(t)\n\n\t\tvar diff = &stats{}\n\t\t*diff = *s\n\n\t\tdiff.clientTotalReq -= old.clientTotalReq\n\t\tdiff.clientSuccReq -= old.clientSuccReq\n\t\tdiff.serverTotalReq -= old.serverTotalReq\n\t\tdiff.serverSuccReq -= old.serverSuccReq\n\n\t\tlogf(\"%s\\n%s\", \"statistics\", diff)\n\t\treturn s\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase <-timer.C:\n\t\t\told = exec(old)\n\t\t\ttimer.Reset(samplingPeriod)\n\t\tcase <-c.exit:\n\t\t\texec(old)\n\t\t\treturn\n\t\t}\n\t}\n}", "func (ft *FacadeUnitTest) Test_PoolCacheEditPool(c *C) {\n\tft.setupMockDFSLocking()\n\n\tpc := NewPoolCacheEnv()\n\n\tft.hostStore.On(\"FindHostsWithPoolID\", ft.ctx, pc.resourcePool.ID).\n\t\tReturn([]host.Host{pc.firstHost, pc.secondHost}, nil)\n\n\tft.poolStore.On(\"GetResourcePools\", ft.ctx).\n\t\tReturn([]pool.ResourcePool{pc.resourcePool}, nil).Once()\n\n\tft.serviceStore.On(\"GetServicesByPool\", ft.ctx, pc.resourcePool.ID).\n\t\tReturn([]service.Service{pc.firstService, pc.secondService}, nil)\n\n\tft.serviceStore.On(\"GetServiceDetails\", ft.ctx, pc.firstService.ID).\n\t\tReturn(&service.ServiceDetails{\n\t\t\tID: pc.firstService.ID,\n\t\t\tRAMCommitment: pc.firstService.RAMCommitment,\n\t\t}, nil)\n\n\tpools, err := ft.Facade.GetReadPools(ft.ctx)\n\tc.Assert(err, IsNil)\n\tc.Assert(pools, Not(IsNil))\n\tc.Assert(len(pools), Equals, 1)\n\n\tp := pools[0]\n\n\tc.Assert(p.ID, Equals, pc.resourcePool.ID)\n\tc.Assert(p.CreatedAt, TimeEqual, pc.resourcePool.CreatedAt)\n\tc.Assert(p.UpdatedAt, TimeEqual, pc.resourcePool.UpdatedAt)\n\tc.Assert(p.Permissions, Equals, pc.resourcePool.Permissions)\n\n\tpc.resourcePool.Permissions = pool.AdminAccess & pool.DFSAccess\n\n\tft.poolStore.On(\"GetResourcePools\", ft.ctx).\n\t\tReturn([]pool.ResourcePool{pc.resourcePool}, nil).Once()\n\n\tft.poolStore.On(\"Get\", ft.ctx, pool.Key(pc.resourcePool.ID), mock.AnythingOfType(\"*pool.ResourcePool\")).\n\t\tReturn(nil).\n\t\tRun(func(args mock.Arguments) {\n\t\t\t*args.Get(2).(*pool.ResourcePool) = pc.resourcePool\n\t\t})\n\n\tft.poolStore.On(\"Put\", ft.ctx, pool.Key(pc.resourcePool.ID), mock.AnythingOfType(\"*pool.ResourcePool\")).\n\t\tReturn(nil)\n\n\tft.zzk.On(\"UpdateResourcePool\", mock.AnythingOfType(\"*pool.ResourcePool\")).\n\t\tReturn(nil)\n\n\tft.Facade.UpdateResourcePool(ft.ctx, &pc.resourcePool)\n\n\t// GetReadPools should see that the cache is dirty, and update itself\n\tpools, err = ft.Facade.GetReadPools(ft.ctx)\n\tc.Assert(err, IsNil)\n\tc.Assert(pools, Not(IsNil))\n\tc.Assert(len(pools), Equals, 1)\n\n\tp = pools[0]\n\tc.Assert(p.ID, Equals, pc.resourcePool.ID)\n\tc.Assert(p.CreatedAt, TimeEqual, pc.resourcePool.CreatedAt)\n\tc.Assert(p.UpdatedAt, Not(TimeEqual), pc.resourcePool.UpdatedAt)\n\tc.Assert(p.Permissions, Equals, (pool.AdminAccess & pool.DFSAccess))\n}", "func (c *ClosablePool) Close(timeout time.Duration) error {\n\tstarted := time.Now()\n\n\ttiers := []int{}\n\tfor i := range c.closables {\n\t\ttiers = append(tiers, i)\n\t}\n\tsort.Ints(tiers)\n\n\tfor _, i := range tiers {\n\t\ttier := c.closables[i]\n\t\tfor j := range tier {\n\t\t\ttier[j].CloseAsync()\n\t\t}\n\t\tfor j := range tier {\n\t\t\tif err := tier[j].WaitForClose(timeout - time.Since(started)); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tdelete(c.closables, i)\n\t}\n\treturn nil\n}", "func (tester *TransportTesting) cleanup() {\n\tblocks := *tester.blocks\n\tfor i := int32(0); i < blocks; i++ {\n\t\ttester.manager.transportLock.RUnlock()\n\t}\n}" ]
[ "0.79037666", "0.77005196", "0.7212689", "0.69314015", "0.68882775", "0.6821975", "0.677085", "0.67185074", "0.67125475", "0.6660586", "0.66495705", "0.6595156", "0.65770125", "0.6570085", "0.65700454", "0.65200526", "0.651361", "0.64882994", "0.6450801", "0.6413368", "0.6399594", "0.6370763", "0.63699496", "0.6368809", "0.6365865", "0.6345376", "0.63409895", "0.63407534", "0.63335663", "0.6303237", "0.6298715", "0.62864655", "0.62493604", "0.62127525", "0.62121934", "0.61903596", "0.61883664", "0.6165552", "0.6164692", "0.6148403", "0.61335", "0.6129027", "0.61222845", "0.61008686", "0.6073688", "0.6053317", "0.6051559", "0.60291004", "0.60266197", "0.60251564", "0.60235405", "0.59949696", "0.59937626", "0.5981015", "0.5969678", "0.59667295", "0.5965934", "0.59504366", "0.59439445", "0.5942454", "0.5932583", "0.59277284", "0.58933467", "0.5891967", "0.5891965", "0.5885961", "0.58820105", "0.5880099", "0.58766454", "0.58762866", "0.58704513", "0.5866486", "0.5865959", "0.58626235", "0.5861138", "0.58589387", "0.5853028", "0.5832293", "0.5811559", "0.5799879", "0.5790201", "0.5789719", "0.57896644", "0.5776578", "0.57764167", "0.5775896", "0.5772976", "0.5752351", "0.5751464", "0.574949", "0.5747975", "0.573729", "0.5734764", "0.57326347", "0.57324016", "0.5731291", "0.5723381", "0.57228905", "0.572031", "0.5709607" ]
0.79534227
0
FetchLocalImage mocks base method
FetchLocalImage подделывает базовый метод
func (m *MockFetcher) FetchLocalImage(arg0 string) (image.Image, error) { ret := m.ctrl.Call(m, "FetchLocalImage", arg0) ret0, _ := ret[0].(image.Image) ret1, _ := ret[1].(error) return ret0, ret1 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *MockFetcher) FetchUpdatedLocalImage(arg0 context.Context, arg1 string, arg2 io.Writer) (image.Image, error) {\n\tret := m.ctrl.Call(m, \"FetchUpdatedLocalImage\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(image.Image)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockFetcher) FetchRemoteImage(arg0 string) (image.Image, error) {\n\tret := m.ctrl.Call(m, \"FetchRemoteImage\", arg0)\n\tret0, _ := ret[0].(image.Image)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func TestIsImageInLocalRegistry(t *testing.T) {\n\ttype testDef struct {\n\t\timageName string\n\t\tdocker test.FakeDockerClient\n\t\texpectedResult bool\n\t\texpectedError string\n\t}\n\ttests := map[string]testDef{\n\t\t\"ImageFound\": {\"a_test_image\", test.FakeDockerClient{}, true, \"\"},\n\t\t\"ImageNotFound\": {\"a_test_image:sometag\", test.FakeDockerClient{}, false, \"unable to get metadata for a_test_image:sometag\"},\n\t}\n\n\tfor test, def := range tests {\n\t\tdh := getDocker(&def.docker)\n\t\tfake := dh.kubeDockerClient.(*dockertools.FakeDockerClient)\n\t\tif def.expectedResult {\n\t\t\tfake.Image = &dockertypes.ImageInspect{ID: def.imageName}\n\t\t}\n\n\t\tresult, err := dh.IsImageInLocalRegistry(def.imageName)\n\n\t\tif e := fake.AssertCalls([]string{\"inspect_image\"}); e != nil {\n\t\t\tt.Errorf(\"%+v\", e)\n\t\t}\n\n\t\tif result != def.expectedResult {\n\t\t\tt.Errorf(\"Test - %s: Expected result: %v. Got: %v\", test, def.expectedResult, result)\n\t\t}\n\t\tif err != nil && len(def.expectedError) > 0 && !strings.Contains(err.Error(), def.expectedError) {\n\t\t\tt.Errorf(\"Test - %s: Expected error: Got: %+v\", test, err)\n\t\t}\n\t}\n}", "func (imp *Importer) fetchLocalImages() {\n items, err := ioutil.ReadDir(STORE_DIR)\n if err != nil {\n imp.sendErr(err)\n return\n }\n\n for _, info := range items {\n if info.IsDir() { continue }\n filename := info.Name()\n\n file, err := os.Open(fmt.Sprintf(\"%s/%s\", STORE_DIR, filename))\n if err != nil {\n imp.sendErr(err)\n return\n }\n\n img, err := jpeg.Decode(file)\n if err != nil {\n log.Printf(\"Error decoding image file %s to jpeg\\n\", filename)\n continue\n }\n\n ext := filepath.Ext(filename)\n id := filename[:len(filename)-len(ext)]\n\n imp.send(&imagedata.ImageData{Id: id, Data: &img})\n }\n}", "func (f *fetcher) fetchImageFrom(appName string, aciURL, ascURL, scheme string, ascFile *os.File, latest bool) (string, error) {\n\tvar rem *store.Remote\n\n\tif f.insecureSkipVerify {\n\t\tif f.ks != nil {\n\t\t\tstderr(\"rkt: warning: TLS verification and signature verification has been disabled\")\n\t\t}\n\t} else if scheme == \"docker\" {\n\t\treturn \"\", fmt.Errorf(\"signature verification for docker images is not supported (try --insecure-skip-verify)\")\n\t}\n\n\tif (f.local && scheme != \"file\") || (scheme != \"file\" && !latest) {\n\t\tvar err error\n\t\tok := false\n\t\trem, ok, err = f.s.GetRemote(aciURL)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif ok {\n\t\t\tif f.local {\n\t\t\t\tstderr(\"rkt: using image in local store for app %s\", appName)\n\t\t\t\treturn rem.BlobKey, nil\n\t\t\t}\n\t\t\tif useCached(rem.DownloadTime, rem.CacheMaxAge) {\n\t\t\t\tstderr(\"rkt: found image in local store, skipping fetching from %s\", aciURL)\n\t\t\t\treturn rem.BlobKey, nil\n\t\t\t}\n\t\t}\n\t\tif f.local {\n\t\t\treturn \"\", fmt.Errorf(\"url %s not available in local store\", aciURL)\n\t\t}\n\t}\n\n\tif scheme != \"file\" && f.debug {\n\t\tstderr(\"rkt: fetching image from %s\", aciURL)\n\t}\n\n\tvar etag string\n\tif rem != nil {\n\t\tetag = rem.ETag\n\t}\n\tentity, aciFile, cd, err := f.fetch(appName, aciURL, ascURL, ascFile, etag)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif cd != nil && cd.useCached {\n\t\tif rem != nil {\n\t\t\treturn rem.BlobKey, nil\n\t\t} else {\n\t\t\t// should never happen\n\t\t\tpanic(\"asked to use cached image but remote is nil\")\n\t\t}\n\t}\n\tif scheme != \"file\" {\n\t\tdefer os.Remove(aciFile.Name())\n\t}\n\n\tif entity != nil && !f.insecureSkipVerify {\n\t\tstderr(\"rkt: signature verified:\")\n\t\tfor _, v := range entity.Identities {\n\t\t\tstderr(\" %s\", v.Name)\n\t\t}\n\t}\n\tkey, err := f.s.WriteACI(aciFile, latest)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif scheme != \"file\" {\n\t\trem := store.NewRemote(aciURL, ascURL)\n\t\trem.BlobKey = key\n\t\trem.DownloadTime = time.Now()\n\t\tif cd != nil {\n\t\t\trem.ETag = cd.etag\n\t\t\trem.CacheMaxAge = cd.maxAge\n\t\t}\n\t\terr = f.s.WriteRemote(rem)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\treturn key, nil\n}", "func TestFetch(t *testing.T) {\n\timage := \"rkt-inspect-fetch.aci\"\n\n\tctx := newRktRunCtx()\n\tdefer ctx.cleanup()\n\n\t// Fetch the image for the first time, this should write the image to the\n\t// on-disk store.\n\toldHash := patchImportAndFetchHash(image, []string{\"--exec=/inspect --read-file\"}, t, ctx)\n\n\t// Fetch the image with the same name but different content, the expecting\n\t// result is that we should get a different hash since we are not fetching\n\t// from the on-disk store.\n\tnewHash := patchImportAndFetchHash(image, []string{\"--exec=/inspect --read-file --write-file\"}, t, ctx)\n\n\tif oldHash == newHash {\n\t\tt.Fatalf(\"ACI hash should be different as the image has changed\")\n\t}\n}", "func (f OriginalFetcher) Fetch(namespace string, sourceURL string, imageHash string) (info *info.ImageProperties, downloaded bool, err error) {\n\tif sourceURL == \"\" && imageHash == \"\" {\n\t\treturn nil, false, fmt.Errorf(\"Missing Hash & URL\")\n\t}\n\n\tif imageHash != \"\" {\n\t\tinfo, err = f.fetchFromStore(namespace, imageHash)\n\t}\n\n\tif sourceURL != \"\" && (err != nil || imageHash == \"\") {\n\t\tinfo, downloaded, err = f.fetchFromSource(namespace, sourceURL)\n\t}\n\n\treturn info, downloaded, err\n}", "func fetchLocal(f *File) error {\n\n\terr := validateLocal(f)\n\tif err != nil {\n\t\tf.Status.Type = status.ERROR\n\t\treturn err\n\t}\n\tf.path = f.Url\n\tf.Status.Type = status.FETCHED\n\treturn nil\n\n}", "func LoadLocalImage(app *AppData) error {\n\tapp.LocalImage = DockerImage{\n\t\tExists: false,\n\t}\n\tctx := context.Background()\n\tcli, err := client.NewClientWithOpts(client.FromEnv)\n\tcli.NegotiateAPIVersion(ctx)\n\tdefer cli.Close()\n\tif err != nil {\n\t\treturn err\n\t}\n\tinspect, _, err := cli.ImageInspectWithRaw(ctx, app.From)\n\tif err != nil {\n\t\tif err.Error() == \"Error: No such image: \"+app.From {\n\t\t\tfmt.Printf(\"Repo not exists in local docker\\n\")\n\t\t\treturn nil\n\t\t}\n\t\treturn err\n\t}\n\tfmt.Printf(\"Repo exists in local docker\\n\")\n\tapp.LocalImage.Exists = true\n\tif len(inspect.RepoDigests) > 0 {\n\t\tapp.LocalImage.DockerDigest = inspect.RepoDigests[0]\n\t} else {\n\t\tapp.LocalImage.DockerDigest = inspect.ID\n\t}\n\n\t//Setting Docker Config values\n\tconfigData, err := json.Marshal(inspect.Config)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = pvjson.Unmarshal(configData, &app.LocalImage.DockerConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func TestBaseImage(t *testing.T) {\n\tctx, err := controllerPrepare()\n\tif err != nil {\n\t\tt.Fatal(\"Fail in controller prepare: \", err)\n\t}\n\teveBaseRef := os.Getenv(\"EVE_BASE_REF\")\n\tif len(eveBaseRef) == 0 {\n\t\teveBaseRef = \"4.10.0\"\n\t}\n\tzArch := os.Getenv(\"ZARCH\")\n\tif len(eveBaseRef) == 0 {\n\t\tzArch = \"amd64\"\n\t}\n\tHV := os.Getenv(\"HV\")\n\tif HV == \"xen\" {\n\t\tHV = \"\"\n\t}\n\tvar baseImageTests = []struct {\n\t\tdataStoreID string\n\t\timageID string\n\t\tbaseID string\n\t\timageRelativePath string\n\t\timageFormat config.Format\n\t\teveBaseRef string\n\t\tzArch string\n\t\tHV string\n\t}{\n\t\t{eServerDataStoreID,\n\n\t\t\t\"1ab8761b-5f89-4e0b-b757-4b87a9fa93ec\",\n\n\t\t\t\"22b8761b-5f89-4e0b-b757-4b87a9fa93ec\",\n\n\t\t\t\"baseos.qcow2\",\n\t\t\tconfig.Format_QCOW2,\n\t\t\teveBaseRef,\n\t\t\tzArch,\n\t\t\tHV,\n\t\t},\n\t}\n\tfor _, tt := range baseImageTests {\n\t\tbaseOSVersion := fmt.Sprintf(\"%s-%s\", tt.eveBaseRef, tt.zArch)\n\t\tif tt.HV != \"\" {\n\t\t\tbaseOSVersion = fmt.Sprintf(\"%s-%s-%s\", tt.eveBaseRef, tt.zArch, tt.HV)\n\t\t}\n\t\tt.Run(baseOSVersion, func(t *testing.T) {\n\n\t\t\terr = prepareBaseImageLocal(ctx, tt.dataStoreID, tt.imageID, tt.baseID, tt.imageRelativePath, tt.imageFormat, baseOSVersion)\n\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(\"Fail in prepare base image from local file: \", err)\n\t\t\t}\n\t\t\tdeviceCtx, err := ctx.GetDeviceFirst()\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(\"Fail in get first device: \", err)\n\t\t\t}\n\t\t\tdeviceCtx.SetBaseOSConfig([]string{tt.baseID})\n\t\t\tdevUUID := deviceCtx.GetID()\n\t\t\terr = ctx.ConfigSync(deviceCtx)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(\"Fail in sync config with controller: \", err)\n\t\t\t}\n\t\t\tt.Run(\"Started\", func(t *testing.T) {\n\t\t\t\terr := ctx.InfoChecker(devUUID, map[string]string{\"devId\": devUUID.String(), \"shortVersion\": baseOSVersion}, einfo.ZInfoDevSW, 300)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(\"Fail in waiting for base image update init: \", err)\n\t\t\t\t}\n\t\t\t})\n\t\t\tt.Run(\"Downloaded\", func(t *testing.T) {\n\t\t\t\terr := ctx.InfoChecker(devUUID, map[string]string{\"devId\": devUUID.String(), \"shortVersion\": baseOSVersion, \"downloadProgress\": \"100\"}, einfo.ZInfoDevSW, 1500)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(\"Fail in waiting for base image download progress: \", err)\n\t\t\t\t}\n\t\t\t})\n\t\t\tt.Run(\"Logs\", func(t *testing.T) {\n\t\t\t\tif !checkLogs {\n\t\t\t\t\tt.Skip(\"no LOGS flag set - skipped\")\n\t\t\t\t}\n\t\t\t\terr = ctx.LogChecker(devUUID, map[string]string{\"devId\": devUUID.String(), \"eveVersion\": baseOSVersion}, 1200)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(\"Fail in waiting for base image logs: \", err)\n\t\t\t\t}\n\t\t\t})\n\t\t\ttimeout := time.Duration(1200)\n\n\t\t\tif !checkLogs {\n\t\t\t\ttimeout = 2400\n\t\t\t}\n\t\t\tt.Run(\"Active\", func(t *testing.T) {\n\t\t\t\terr = ctx.InfoChecker(devUUID, map[string]string{\"devId\": devUUID.String(), \"shortVersion\": baseOSVersion, \"status\": \"INSTALLED\", \"partitionState\": \"(inprogress|active)\"}, einfo.ZInfoDevSW, timeout)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(\"Fail in waiting for base image installed status: \", err)\n\t\t\t\t}\n\t\t\t})\n\t\t})\n\t}\n\n}", "func TestBaseImage(t *testing.T) {\n\t// test with 'original.png'\n\timgs := map[string][]byte{\n\t\t\"original.png\": []byte(\"image\"),\n\t}\n\t_, err := backend.baseImage(imgs)\n\tif err != nil {\n\t\tt.Errorf(\"Got error %s\", err)\n\t}\n\n\t// test with 'original.jpg'\n\timgs = map[string][]byte{\n\t\t\"original.jpg\": []byte(\"image\"),\n\t}\n\t_, err = backend.baseImage(imgs)\n\tif err != nil {\n\t\tt.Errorf(\"Got error %s\", err)\n\t}\n\n\t// without 'original.*' should get an error\n\timgs = map[string][]byte{\n\t\t\"127x127.png\": []byte(\"image\"),\n\t}\n\t_, err = backend.baseImage(imgs)\n\tif err == nil {\n\t\tt.Errorf(\"Should get an error, didn't pass original image.\")\n\t}\n}", "func TestImplicitFetch(t *testing.T) {\n\tfoundMsg := \"found image in local store\"\n\n\tctx := newRktRunCtx()\n\tdefer ctx.cleanup()\n\n\t// 1. Fetch the image.\n\t// TODO(yifan): Add other ACI with different schemes.\n\timportImageAndFetchHash(t, ctx, \"docker://busybox:ubuntu-12.04\")\n\timportImageAndFetchHash(t, ctx, \"docker://busybox:latest\")\n\n\t// 2. Try run/prepare with/without tag ':latest', should not get $foundMsg.\n\tcmds := []string{\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify run --mds-register=false docker://busybox\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify run --mds-register=false docker://busybox:latest\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify prepare docker://busybox\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify prepare docker://busybox:latest\", ctx.cmd()),\n\t}\n\n\tfor _, cmd := range cmds {\n\t\tt.Logf(\"Running test %v\", cmd)\n\n\t\tchild, err := gexpect.Spawn(cmd)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Cannot exec rkt: %v\", err)\n\t\t}\n\t\tif err := expectWithOutput(child, foundMsg); err == nil {\n\t\t\tt.Fatalf(\"%q should not be found\", foundMsg)\n\t\t}\n\t\tif err := child.Wait(); err != nil {\n\t\t\tt.Fatalf(\"rkt didn't terminate correctly: %v\", err)\n\t\t}\n\t}\n}", "func (f *Frontend) fetchImage(i *img.Image) (*img.Image, error) {\n\tvar err error\n\n\t// go through image proxy to resize and cache the image\n\tkey := hmacKey(i.ID)\n\tu := fmt.Sprintf(\"%v/image/225x,s%v/%v\", f.Host, key, i.ID)\n\tfmt.Println(u)\n\n\tresp, err := f.Images.Client.Get(u)\n\tif err != nil {\n\t\treturn i, err\n\t}\n\n\tdefer resp.Body.Close()\n\n\tbdy, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn i, err\n\t}\n\n\ti.Base64 = base64.StdEncoding.EncodeToString(bdy)\n\treturn i, err\n}", "func (m *MockRequester) Fetch(url string) (io.ReadCloser, error) {\n\tret := m.ctrl.Call(m, \"Fetch\", url)\n\tret0, _ := ret[0].(io.ReadCloser)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (f *fetcher) fetchImage(img string, asc string, discover bool) (string, error) {\n\tif f.withDeps && !discover {\n\t\treturn \"\", fmt.Errorf(\"cannot fetch image's dependencies with discovery disabled\")\n\t}\n\thash, err := f.fetchSingleImage(img, asc, discover)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif f.withDeps {\n\t\terr = f.fetchImageDeps(hash)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\treturn hash, nil\n}", "func ttrPullImageAsserting(ctx context.Context, t *testing.T, client apiclient.APIClient, image string) {\n\terr := ttrPullImage(ctx, client, image)\n\tassert.NilError(t, err)\n}", "func (ss *Sources) localFetch(spec v1.SourceSpec) (string, error) {\n\tp := ss.repoPath(spec)\n\terr := os.MkdirAll(p, 0750)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t//TODO prevent target directory from accumulating unused files\n\t// remove all files before copy\n\t// or\n\t// walk target dir and diff with source dir\n\n\t// Copy local dir to repo path.\n\t// Ignore .git directory.\n\terr = otia10copy.Copy(spec.URL, p, otia10copy.Options{Skip: func(src string) bool {\n\t\treturn filepath.Base(src) == \".git\"\n\t}})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"fetch: %w\", err)\n\t}\n\n\th, err := ss.hashAll(spec.URL) // TODO use hashAll(p) when dir is properly synced (see previous to do)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\ts := hex.EncodeToString(h.Sum(nil))\n\n\treturn s, err\n}", "func (f *SourceFetcher) Fetch(url string, namespace string) (*info.ImageProperties, bool, error) {\n\tc := make(chan FetchResult)\n\tgo f.uniqueFetchSource(c, url, namespace)\n\tr := <-c\n\treturn r.ImageDetails, r.Downloaded, r.Error\n}", "func TestRunPrepareLocal(t *testing.T) {\n\tnotAvailableMsg := \"not available in local store\"\n\tfoundMsg := \"using image in local store\"\n\n\tctx := newRktRunCtx()\n\tdefer ctx.cleanup()\n\n\tcmds := []string{\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify run --local --mds-register=false docker://busybox\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify run --local --mds-register=false docker://busybox:latest\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify prepare --local docker://busybox\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify prepare --local docker://busybox:latest\", ctx.cmd()),\n\t}\n\n\t// 1. Try run/prepare with the image not available in the store, should get $notAvailableMsg.\n\tfor _, cmd := range cmds {\n\t\tt.Logf(\"Running test %v\", cmd)\n\n\t\tchild, err := gexpect.Spawn(cmd)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Cannot exec rkt: %v\", err)\n\t\t}\n\t\tif err := expectWithOutput(child, notAvailableMsg); err != nil {\n\t\t\tt.Fatalf(\"%q should be found\", notAvailableMsg)\n\t\t}\n\t\tchild.Wait()\n\t}\n\n\t// 2. Fetch the image\n\timportImageAndFetchHash(t, ctx, \"docker://busybox\")\n\timportImageAndFetchHash(t, ctx, \"docker://busybox:latest\")\n\n\t// 3. Try run/prepare with the image available in the store, should get $foundMsg.\n\tfor _, cmd := range cmds {\n\t\tt.Logf(\"Running test %v\", cmd)\n\n\t\tchild, err := gexpect.Spawn(cmd)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Cannot exec rkt: %v\", err)\n\t\t}\n\t\tif err := expectWithOutput(child, foundMsg); err != nil {\n\t\t\tt.Fatalf(\"%q should be found\", foundMsg)\n\t\t}\n\t\tif err := child.Wait(); err != nil {\n\t\t\tt.Fatalf(\"rkt didn't terminate correctly: %v\", err)\n\t\t}\n\t}\n}", "func Fetch(imageURI string, labels map[types.ACIdentifier]string, insecure bool) (tempfile.ReadSeekCloser, error) {\n\tu, err := url.Parse(imageURI)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar puller remote.Puller\n\n\tswitch u.Scheme {\n\tcase \"file\":\n\t\tfilename := u.Path\n\t\tif u.Host != \"\" {\n\t\t\tfilename = filepath.Join(u.Host, u.Path)\n\t\t}\n\t\tf, err := os.Open(filename)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn tempfile.New(f)\n\tcase \"http\", \"https\":\n\t\tpuller = http.New()\n\tcase \"docker\":\n\t\tpuller = docker.New(insecure)\n\tcase \"aci\", \"\":\n\t\tpuller = aci.New(insecure, labels)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"%q scheme not supported\", u.Scheme)\n\t}\n\n\tr, err := puller.Pull(imageURI)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn tempfile.New(r)\n}", "func (m *MockManager) GetLoadedImageName() string {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetLoadedImageName\")\n\tret0, _ := ret[0].(string)\n\treturn ret0\n}", "func (f *MockingFetcher) Fetch(ctx context.Context, name string) (Function, error) {\n\tr, err := f.Fetcher.Fetch(ctx, name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn mockFunction(r), nil\n}", "func (c *TestClient) GetImage(project, name string) (*compute.Image, error) {\n\tif c.GetImageFn != nil {\n\t\treturn c.GetImageFn(project, name)\n\t}\n\treturn c.client.GetImage(project, name)\n}", "func (c *dockerClientMock) DownloadImage(imageSource, filePath string) (v1.Image, error) {\n\treturn &fake.FakeImage{}, nil // fmt.Errorf(\"%s\", filePath)\n}", "func (m *MockEnvironment) Fetch() map[string]interface{} {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Fetch\")\n\tret0, _ := ret[0].(map[string]interface{})\n\treturn ret0\n}", "func (m *MockUpstreamIntf) CachedRemoteDigestOfLocalHeight() blockdigest.Digest {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"CachedRemoteDigestOfLocalHeight\")\n\tret0, _ := ret[0].(blockdigest.Digest)\n\treturn ret0\n}", "func getLocalImage(s *Settings) ([]byte, error) {\n\tvar image []byte\n\tvar filePath string\n\tvar file *os.File\n\tvar err error\n\n\tif len(s.Directories) > 0 {\n\t\tfound := false\n\t\tfor _, dir := range s.Directories {\n\t\t\tfilePath = path.Join(\"/\", dir, s.Context.Path)\n\t\t\tfile, err = os.Open(filePath)\n\t\t\tif err == nil {\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tfile, err = os.Open(s.Local404Thumb)\n\t\t\tif err != nil {\n\t\t\t\treturn image, err\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfile, err = os.Open(path.Join(\"/\", s.Context.Path))\n\t\tif err != nil {\n\t\t\tfile, err = os.Open(s.Local404Thumb)\n\t\t\tif err != nil {\n\t\t\t\treturn image, err\n\t\t\t}\n\t\t}\n\t}\n\n\tinfo, _ := file.Stat()\n\timage = make([]byte, info.Size())\n\n\t_, err = file.Read(image)\n\tif err != nil {\n\t\treturn image, err\n\t}\n\n\treturn image, nil\n}", "func (m *MockSystem) FetchURL(ctx context.Context, url string) (semver.Tags, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"FetchURL\", ctx, url)\n\tret0, _ := ret[0].(semver.Tags)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func dirImageMock(t *testing.T, dir, dockerReference string) private.UnparsedImage {\n\tref, err := reference.ParseNormalizedNamed(dockerReference)\n\trequire.NoError(t, err)\n\treturn dirImageMockWithRef(t, dir, refImageReferenceMock{ref: ref})\n}", "func (m *MockRepository) Fetch(bucketName, name string, model db.Model) (bool, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Fetch\", bucketName, name, model)\n\tret0, _ := ret[0].(bool)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (mr *MockFetcherMockRecorder) FetchLocalImage(arg0 interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"FetchLocalImage\", reflect.TypeOf((*MockFetcher)(nil).FetchLocalImage), arg0)\n}", "func FetchRemoteFile() {\n\n}", "func TestRemote(t *testing.T) {\n\trnd, err := random.Image(1024, 3)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\ts, err := registry.TLS(\"gcr.io\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\ttr := s.Client().Transport\n\n\tsrc := \"gcr.io/test/compressed\"\n\tref, err := name.ParseReference(src)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif err := remote.Write(ref, rnd, remote.WithTransport(tr)); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\timg, err := remote.Image(ref, remote.WithTransport(tr))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif err := validate.Image(img); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tcf, err := img.ConfigFile()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tm, err := img.Manifest()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tlayer, err := img.LayerByDiffID(cf.RootFS.DiffIDs[0])\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\td, err := layer.Digest()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif diff := cmp.Diff(d, m.Layers[0].Digest); diff != \"\" {\n\t\tt.Errorf(\"mismatched digest: %v\", diff)\n\t}\n}", "func (m *MockImageTransferer) Download(arg0 string, arg1 core.Digest) (base.FileReader, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Download\", arg0, arg1)\n\tret0, _ := ret[0].(base.FileReader)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func TestExpectedImgRef(t *testing.T) {\n\n\tv, isSet := os.LookupEnv(\"DOCKERHUB_PROXY\")\n\tif isSet {\n\t\tdefer os.Setenv(\"DOCKERHUB_PROXY\", v)\n\t}\n\n\tos.Unsetenv(\"DOCKERHUB_PROXY\")\n\tassert.Equal(t,\n\t\t\"index.docker.io/library/hello-world@sha256:ebf526c198a14fa138634b9746c50ec38077ec9b3986227e79eb837d26f59dc6\",\n\t\tCompleteImageRef(\"library/hello-world@sha256:ebf526c198a14fa138634b9746c50ec38077ec9b3986227e79eb837d26f59dc6\"))\n\n\tos.Setenv(\"DOCKERHUB_PROXY\", \"my-dockerhub-proxy.tld/dockerhub-proxy\")\n\tassert.Equal(t,\n\t\t\"my-dockerhub-proxy.tld/dockerhub-proxy/library/hello-world@sha256:ebf526c198a14fa138634b9746c50ec38077ec9b3986227e79eb837d26f59dc6\",\n\t\tCompleteImageRef(\"library/hello-world@sha256:ebf526c198a14fa138634b9746c50ec38077ec9b3986227e79eb837d26f59dc6\"))\n\tos.Unsetenv(\"DOCKERHUB_PROXY\")\n}", "func (m *MockFetcher) Fetch(req utils.Request) (responseBody []byte, err error) {\n\targs := m.Called(req)\n\n\tif args.Get(0) != nil {\n\t\tresponseBody = args.Get(0).([]byte)\n\t}\n\n\terr = args.Error(1)\n\n\treturn responseBody, err\n}", "func (f *fetcher) fetchSingleImage(img string, asc string, discover bool) (string, error) {\n\tvar (\n\t\tascFile *os.File\n\t\terr error\n\t\tlatest bool\n\t)\n\tif asc != \"\" && f.ks != nil {\n\t\tascFile, err = os.Open(asc)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"unable to open signature file: %v\", err)\n\t\t}\n\t\tdefer ascFile.Close()\n\t}\n\n\tu, err := url.Parse(img)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"not a valid image reference (%s)\", img)\n\t}\n\n\t// if img refers to a local file, ensure the scheme is file:// and make the url path absolute\n\t_, err = os.Stat(u.Path)\n\tif err == nil {\n\t\tu.Path, err = filepath.Abs(u.Path)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"unable to get abs path: %v\", err)\n\t\t}\n\t\tu.Scheme = \"file\"\n\t} else if !os.IsNotExist(err) {\n\t\treturn \"\", fmt.Errorf(\"unable to access %q: %v\", img, err)\n\t}\n\n\tif discover && u.Scheme == \"\" {\n\t\tif app := newDiscoveryApp(img); app != nil {\n\t\t\tvar discoveryError error\n\t\t\tif !f.local {\n\t\t\t\tstderr(\"rkt: searching for app image %s\", img)\n\t\t\t\tep, err := discoverApp(app, true)\n\t\t\t\tif err != nil {\n\t\t\t\t\tdiscoveryError = err\n\t\t\t\t} else {\n\t\t\t\t\t// No specified version label, mark it as latest\n\t\t\t\t\tif _, ok := app.Labels[\"version\"]; !ok {\n\t\t\t\t\t\tlatest = true\n\t\t\t\t\t}\n\t\t\t\t\treturn f.fetchImageFromEndpoints(app.Name.String(), ep, ascFile, latest)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif discoveryError != nil {\n\t\t\t\tstderr(\"discovery failed for %q: %v. Trying to find image in the store.\", img, discoveryError)\n\t\t\t}\n\t\t\tif f.local || discoveryError != nil {\n\t\t\t\treturn f.fetchImageFromStore(img)\n\t\t\t}\n\t\t}\n\t}\n\n\tswitch u.Scheme {\n\tcase \"http\", \"https\", \"file\":\n\tcase \"docker\":\n\t\tdockerURL := common.ParseDockerURL(path.Join(u.Host, u.Path))\n\t\tif dockerURL.Tag == \"latest\" {\n\t\t\tlatest = true\n\t\t}\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"rkt only supports http, https, docker or file URLs (%s)\", img)\n\t}\n\treturn f.fetchImageFromURL(u.String(), u.Scheme, ascFile, latest)\n}", "func (m *MockManager) LoadImage(arg0 context.Context, arg1 *config.Config, arg2 dockerapi.DockerClient) (*types.ImageInspect, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"LoadImage\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(*types.ImageInspect)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func TestCannotExecuteStatusImage(t *testing.T) {\n\tbuf := setLogBuffer()\n\tdefer func() {\n\t\tif t.Failed() {\n\t\t\tt.Log(buf.String())\n\t\t}\n\t}()\n\n\tif StatusImage == \"\" {\n\t\tt.Skip(\"no status image defined\")\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\tdefer cancel()\n\n\tapp := &models.App{Name: id.New().String()}\n\tapp = ensureApp(t, app)\n\n\tfn := &models.Fn{\n\t\tAppID: app.ID,\n\t\tName: id.New().String(),\n\t\tImage: StatusImage,\n\t\tResourceConfig: models.ResourceConfig{\n\t\t\tMemory: memory,\n\t\t},\n\t}\n\tfn = ensureFn(t, fn)\n\n\tlb, err := LB()\n\tif err != nil {\n\t\tt.Fatalf(\"Got unexpected error: %v\", err)\n\t}\n\tu := url.URL{\n\t\tScheme: \"http\",\n\t\tHost: lb,\n\t}\n\tu.Path = path.Join(u.Path, \"invoke\", fn.ID)\n\n\tcontent := bytes.NewBuffer([]byte(`status`))\n\toutput := &bytes.Buffer{}\n\n\tresp, err := callFN(ctx, u.String(), content, output, models.TypeSync)\n\tif err != nil {\n\t\tt.Fatalf(\"Got unexpected error: %v\", err)\n\t}\n\n\tif resp.StatusCode != http.StatusBadRequest {\n\t\tt.Fatalf(\"StatusCode check failed on %v\", resp.StatusCode)\n\t}\n}", "func GetImg(fileName string) (*image.Image, error) {\n localFile := fmt.Sprintf(\"/data/edgebox/local/%s\", fileName)\n existingImageFile, err := os.Open(localFile)\n if err == nil {\n defer existingImageFile.Close()\n imageData, _, err := image.Decode(existingImageFile)\n if err != nil {\n return nil, err\n }\n return &imageData, nil\n }\n\n remoteFile := fmt.Sprintf(\"/data/edgebox/remote/%s\", fileName)\n existingImageFile, err = os.Open(remoteFile)\n if err == nil {\n defer existingImageFile.Close()\n imageData, _, err := image.Decode(existingImageFile)\n if err != nil {\n return nil, err\n }\n return &imageData, nil\n }\n return nil, err\n}", "func dirImageMockWithRef(t *testing.T, dir string, ref types.ImageReference) private.UnparsedImage {\n\tsrcRef, err := directory.NewReference(dir)\n\trequire.NoError(t, err)\n\tsrc, err := srcRef.NewImageSource(context.Background(), nil)\n\trequire.NoError(t, err)\n\tt.Cleanup(func() {\n\t\terr := src.Close()\n\t\trequire.NoError(t, err)\n\t})\n\treturn image.UnparsedInstance(&dirImageSourceMock{\n\t\tImageSource: imagesource.FromPublic(src),\n\t\tref: ref,\n\t}, nil)\n}", "func (m *MockCacheService) FetchFromCache(pagination model.Pagination) (model.Response, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"FetchFromCache\", pagination)\n\tret0, _ := ret[0].(model.Response)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockImageTransferer) Stat(arg0 string, arg1 core.Digest) (*core.BlobInfo, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Stat\", arg0, arg1)\n\tret0, _ := ret[0].(*core.BlobInfo)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (f *fetcher) fetch(appName string, aciURL, ascURL string, ascFile *os.File, etag string) (*openpgp.Entity, *os.File, *cacheData, error) {\n\tvar (\n\t\tentity *openpgp.Entity\n\t\tcd *cacheData\n\t)\n\n\tu, err := url.Parse(aciURL)\n\tif err != nil {\n\t\treturn nil, nil, nil, fmt.Errorf(\"error parsing ACI url: %v\", err)\n\t}\n\tif u.Scheme == \"docker\" {\n\t\tregistryURL := strings.TrimPrefix(aciURL, \"docker://\")\n\n\t\tstoreTmpDir, err := f.s.TmpDir()\n\t\tif err != nil {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"error creating temporary dir for docker to ACI conversion: %v\", err)\n\t\t}\n\t\ttmpDir, err := ioutil.TempDir(storeTmpDir, \"docker2aci-\")\n\t\tif err != nil {\n\t\t\treturn nil, nil, nil, err\n\t\t}\n\t\tdefer os.RemoveAll(tmpDir)\n\n\t\tindexName := docker2aci.GetIndexName(registryURL)\n\t\tuser := \"\"\n\t\tpassword := \"\"\n\t\tif creds, ok := f.dockerAuth[indexName]; ok {\n\t\t\tuser = creds.User\n\t\t\tpassword = creds.Password\n\t\t}\n\t\tacis, err := docker2aci.Convert(registryURL, true, tmpDir, tmpDir, user, password)\n\t\tif err != nil {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"error converting docker image to ACI: %v\", err)\n\t\t}\n\n\t\taciFile, err := os.Open(acis[0])\n\t\tif err != nil {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"error opening squashed ACI file: %v\", err)\n\t\t}\n\n\t\treturn nil, aciFile, nil, nil\n\t}\n\n\t// attempt to automatically fetch the public key in case it is available on a TLS connection.\n\tif globalFlags.TrustKeysFromHttps && !globalFlags.InsecureSkipVerify && appName != \"\" {\n\t\tpkls, err := getPubKeyLocations(appName, false, globalFlags.Debug)\n\t\tif err != nil {\n\t\t\tstderr(\"Error determining key location: %v\", err)\n\t\t} else {\n\t\t\t// no http, don't ask user for accepting the key, no overriding\n\t\t\tif err := addKeys(pkls, appName, false, true, false); err != nil {\n\t\t\t\tstderr(\"Error adding keys: %v\", err)\n\t\t\t}\n\t\t}\n\t}\n\n\tvar retrySignature bool\n\tif f.ks != nil && ascFile == nil {\n\t\tu, err := url.Parse(ascURL)\n\t\tif err != nil {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"error parsing ASC url: %v\", err)\n\t\t}\n\t\tif u.Scheme == \"file\" {\n\t\t\tascFile, err = os.Open(u.Path)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, nil, fmt.Errorf(\"error opening signature file: %v\", err)\n\t\t\t}\n\t\t} else {\n\t\t\tstderr(\"Downloading signature from %v\\n\", ascURL)\n\t\t\tascFile, err = f.s.TmpFile()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, nil, fmt.Errorf(\"error setting up temporary file: %v\", err)\n\t\t\t}\n\t\t\tdefer os.Remove(ascFile.Name())\n\n\t\t\terr = f.downloadSignatureFile(ascURL, ascFile)\n\t\t\tswitch err {\n\t\t\tcase errStatusAccepted:\n\t\t\t\tretrySignature = true\n\t\t\t\tstderr(\"rkt: server requested deferring the signature download\")\n\t\t\tcase nil:\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\treturn nil, nil, nil, fmt.Errorf(\"error downloading the signature file: %v\", err)\n\t\t\t}\n\t\t}\n\t\tdefer ascFile.Close()\n\t}\n\n\t// check if the identity used by the signature is in the store before a\n\t// possibly expensive download. This is only an optimization and it's\n\t// ok to skip the test if the signature will be downloaded later.\n\tif !retrySignature && f.ks != nil && appName != \"\" {\n\t\tif _, err := ascFile.Seek(0, 0); err != nil {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"error seeking signature file: %v\", err)\n\t\t}\n\t\tif entity, err = f.ks.CheckSignature(appName, bytes.NewReader([]byte{}), ascFile); err != nil {\n\t\t\tif _, ok := err.(pgperrors.SignatureError); !ok {\n\t\t\t\treturn nil, nil, nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\tvar aciFile *os.File\n\tif u.Scheme == \"file\" {\n\t\taciFile, err = os.Open(u.Path)\n\t\tif err != nil {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"error opening ACI file: %v\", err)\n\t\t}\n\t} else {\n\t\taciFile, err = f.s.TmpFile()\n\t\tif err != nil {\n\t\t\treturn nil, aciFile, nil, fmt.Errorf(\"error setting up temporary file: %v\", err)\n\t\t}\n\t\tdefer os.Remove(aciFile.Name())\n\n\t\tif cd, err = f.downloadACI(aciURL, aciFile, etag); err != nil {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"error downloading ACI: %v\", err)\n\t\t}\n\t\tif cd.useCached {\n\t\t\treturn nil, nil, cd, nil\n\t\t}\n\t}\n\n\tif retrySignature {\n\t\tif err = f.downloadSignatureFile(ascURL, ascFile); err != nil {\n\t\t\treturn nil, aciFile, nil, fmt.Errorf(\"error downloading the signature file: %v\", err)\n\t\t}\n\t}\n\n\tmanifest, err := aci.ManifestFromImage(aciFile)\n\tif err != nil {\n\t\treturn nil, aciFile, nil, err\n\t}\n\t// Check if the downloaded ACI has the correct app name.\n\t// The check is only performed when the aci is downloaded through the\n\t// discovery protocol, but not with local files or full URL.\n\tif appName != \"\" && manifest.Name.String() != appName {\n\t\treturn nil, aciFile, nil,\n\t\t\tfmt.Errorf(\"error when reading the app name: %q expected but %q found\",\n\t\t\t\tappName, manifest.Name.String())\n\t}\n\n\tif f.ks != nil {\n\t\tif _, err := aciFile.Seek(0, 0); err != nil {\n\t\t\treturn nil, aciFile, nil, fmt.Errorf(\"error seeking ACI file: %v\", err)\n\t\t}\n\t\tif _, err := ascFile.Seek(0, 0); err != nil {\n\t\t\treturn nil, aciFile, nil, fmt.Errorf(\"error seeking signature file: %v\", err)\n\t\t}\n\t\tif entity, err = f.ks.CheckSignature(manifest.Name.String(), aciFile, ascFile); err != nil {\n\t\t\treturn nil, aciFile, nil, err\n\t\t}\n\t}\n\n\tif _, err := aciFile.Seek(0, 0); err != nil {\n\t\treturn nil, aciFile, nil, fmt.Errorf(\"error seeking ACI file: %v\", err)\n\t}\n\treturn entity, aciFile, cd, nil\n}", "func testDownloadImages(ctx context.Context, t *testing.T, downloadCh chan<- downloadRequest, addr, ccvmDir string) {\n\twkld := &workload{\n\t\tspec: workloadSpec{\n\t\t\tBaseImageURL: \"http://\" + addr + \"/download/image\",\n\t\t\tBIOS: \"http://\" + addr + \"/download/bios\",\n\t\t},\n\t}\n\n\tresultCh := make(chan interface{})\n\tgo func() {\n\t\timg, bios, err := downloadImages(ctx, wkld, http.DefaultTransport.(*http.Transport),\n\t\t\tresultCh, downloadCh)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Failed to download images: %v\", err)\n\t\t}\n\t\tif len(img) == 0 || len(bios) == 0 {\n\t\t\tt.Errorf(\"One the paths is empty img=%s bios=%s\", img, bios)\n\t\t}\n\t\tclose(resultCh)\n\t}()\n\n\tfor range resultCh {\n\t}\n\n\twkld.spec.BIOS = \"ftp://\" + addr + \"/download/bios\"\n\tresultCh = make(chan interface{})\n\tgo func() {\n\t\t_, _, err := downloadImages(ctx, wkld, http.DefaultTransport.(*http.Transport),\n\t\t\tresultCh, downloadCh)\n\t\tif err == nil {\n\t\t\tt.Errorf(\"Expected downloadImages with bad BIOS URL to fail\")\n\t\t}\n\t\tclose(resultCh)\n\t}()\n\n\tfor range resultCh {\n\t}\n}", "func (m *MockModuleService) GetLatestModuleImage(arg0 string) (string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetLatestModuleImage\", arg0)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockRepoClient) LocalPath() (string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"LocalPath\")\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockUserUsecase) GetSpecialAvatar(name string) string {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetSpecialAvatar\", name)\n\tret0, _ := ret[0].(string)\n\treturn ret0\n}", "func (imp *Importer) fetchImages() {\n err := downloadImages(\n imp.idPath,\n func(id string, bodyRdr io.Reader) error {\n img, err := jpeg.Decode(bodyRdr)\n if err == nil {\n imp.send(&imagedata.ImageData{Id: id, Data: &img})\n } else {\n log.Printf(\"Error decoding image %s to jpeg\\n\", id)\n }\n return nil\n },\n )\n\n if err != nil { imp.sendErr(err) }\n}", "func (m *MockHandler) GetOsImage(arg0, arg1 string) (*models.OsImage, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetOsImage\", arg0, arg1)\n\tret0, _ := ret[0].(*models.OsImage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockClient) Fetch(keyword string) (*[]linebot.Response, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Fetch\", keyword)\n\tret0, _ := ret[0].(*[]linebot.Response)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func TestRunPrepareFromFile(t *testing.T) {\n\tfoundMsg := \"found image in local store\"\n\timage := \"rkt-inspect-implicit-fetch.aci\"\n\n\timagePath := patchTestACI(image, \"--exec=/inspect\")\n\tdefer os.Remove(imagePath)\n\n\ttests := []string{\n\t\timagePath,\n\t\t\"file://\" + imagePath,\n\t}\n\n\tctx := newRktRunCtx()\n\tdefer ctx.cleanup()\n\n\timportImageAndFetchHash(t, ctx, imagePath)\n\n\tfor _, tt := range tests {\n\n\t\t// 1. Try run/prepare with '--local', should not get the $foundMsg, since we will ignore the '--local' when\n\t\t// the image is a filepath.\n\t\tcmds := []string{\n\t\t\tfmt.Sprintf(\"%s --insecure-skip-verify run --mds-register=false --local %s\", ctx.cmd(), tt),\n\t\t\tfmt.Sprintf(\"%s --insecure-skip-verify prepare --local %s\", ctx.cmd(), tt),\n\t\t}\n\n\t\tfor _, cmd := range cmds {\n\t\t\tt.Logf(\"Running test %v\", cmd)\n\n\t\t\tchild, err := gexpect.Spawn(cmd)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"Cannot exec rkt: %v\", err)\n\t\t\t}\n\n\t\t\tif err := child.Expect(foundMsg); err == nil {\n\t\t\t\tt.Fatalf(\"%q should not be found\", foundMsg)\n\t\t\t}\n\n\t\t\tif err := child.Wait(); err != nil {\n\t\t\t\tt.Fatalf(\"rkt didn't terminate correctly: %v\", err)\n\t\t\t}\n\t\t}\n\n\t\t// 2. Try run/prepare without '--local', should not get $foundMsg either.\n\t\tcmds = []string{\n\t\t\tfmt.Sprintf(\"%s --insecure-skip-verify run --mds-register=false %s\", ctx.cmd(), tt),\n\t\t\tfmt.Sprintf(\"%s --insecure-skip-verify prepare %s\", ctx.cmd(), tt),\n\t\t}\n\n\t\tfor _, cmd := range cmds {\n\t\t\tt.Logf(\"Running test %v\", cmd)\n\n\t\t\tchild, err := gexpect.Spawn(cmd)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"Cannot exec rkt: %v\", err)\n\t\t\t}\n\t\t\tif err := child.Expect(foundMsg); err == nil {\n\t\t\t\tt.Fatalf(\"%q should not be found\", foundMsg)\n\t\t\t}\n\t\t\tif err := child.Wait(); err != nil {\n\t\t\t\tt.Fatalf(\"rkt didn't terminate correctly: %v\", err)\n\t\t\t}\n\t\t}\n\t}\n}", "func SampleImageForTest() (*SampleImage, error) {\n\t\n\t// Attempt to resolve the absolute path to the root directory for the sample image\n\trootDir, err := filepath.Abs(filepath.Join(\".\", \"testdata\", \"sample\"))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t\n\t// Return a populated SampleImage object\n\treturn &SampleImage{\n\t\tRootDir: rootDir,\n\t\tDockerfilesDir: filepath.Dir(rootDir),\n\t\tBlobsDir: filepath.Join(rootDir, \"blobs\", \"sha256\"),\n\t\tLayersDir: filepath.Join(rootDir, \"layers\"),\n\t}, nil\n}", "func handleLocalRequest(rw http.ResponseWriter, req *http.Request) {\n\tfn, err := etl.GetFilename(req.FormValue(\"filename\"))\n\tif err != nil {\n\t\trw.WriteHeader(http.StatusBadRequest)\n\t\tfmt.Fprintf(rw, \"failed to get valid filename= parameter from request\")\n\t\treturn\n\t}\n\n\tdp, err := etl.ValidateTestPath(fn)\n\tif err != nil {\n\t\trw.WriteHeader(http.StatusBadRequest)\n\t\tfmt.Fprintf(rw, \"failed to validate test path: %q\", fn)\n\t\treturn\n\t}\n\n\tc, err := storage.GetStorageClient(false)\n\tif err != nil {\n\t\trw.WriteHeader(http.StatusInternalServerError)\n\t\tfmt.Fprintf(rw, \"failed to get storage client\")\n\t\treturn\n\t}\n\n\tctx := context.Background()\n\tobj, err := c.Bucket(dp.Bucket).Object(dp.Path).Attrs(ctx)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\trw.WriteHeader(http.StatusInternalServerError)\n\t\tfmt.Fprintf(rw, \"failed to get object attrs for %s / %s\", dp.Bucket, dp.Path)\n\t\treturn\n\t}\n\n\tr := toRunnable(obj)\n\terr = r.Run(ctx)\n\tif err != nil {\n\t\trw.WriteHeader(http.StatusInternalServerError)\n\t\tfmt.Fprintf(rw, \"runnable failed to run on %s / %s\", dp.Bucket, dp.Path)\n\t\treturn\n\t}\n\n\tfmt.Fprintf(rw, \"no observed errors\")\n}", "func (reader reader) GetImageFromURLorLocalPath(url, localPath string) (img image.Image, err error) {\n\tswitch {\n\tcase url != \"\":\n\t\treturn reader.ReadFromURL(url)\n\n\tcase localPath != \"\":\n\t\treturn reader.ReadFromLocalPath(localPath)\n\t}\n\treturn nil, errors.New(\"Both url and local path was not provided\")\n}", "func (_m *Repository) Fetch(ctx context.Context, limit int, offset int) ([]*models.Host, error) {\n\tret := _m.Called(ctx, limit, offset)\n\n\tvar r0 []*models.Host\n\tif rf, ok := ret.Get(0).(func(context.Context, int, int) []*models.Host); ok {\n\t\tr0 = rf(ctx, limit, offset)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).([]*models.Host)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(context.Context, int, int) error); ok {\n\t\tr1 = rf(ctx, limit, offset)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func (b *ecrBase) runGetImage(ctx context.Context, batchGetImageInput ecr.BatchGetImageInput) (*ecr.Image, error) {\n\t// Allow only a single image to be fetched at a time.\n\tif len(batchGetImageInput.ImageIds) != 1 {\n\t\treturn nil, errGetImageUnhandled\n\t}\n\n\tbatchGetImageInput.RegistryId = aws.String(b.ecrSpec.Registry())\n\tbatchGetImageInput.RepositoryName = aws.String(b.ecrSpec.Repository)\n\n\tlog.G(ctx).WithField(\"batchGetImageInput\", batchGetImageInput).Trace(\"ecr.base.image: requesting images\")\n\n\tbatchGetImageOutput, err := b.client.BatchGetImageWithContext(ctx, &batchGetImageInput)\n\tif err != nil {\n\t\tlog.G(ctx).WithError(err).Error(\"ecr.base.image: failed to get image\")\n\t\treturn nil, err\n\t}\n\tlog.G(ctx).WithField(\"batchGetImageOutput\", batchGetImageOutput).Trace(\"ecr.base.image: api response\")\n\n\t// Summarize image request failures for handled errors. Only the first\n\t// failure is checked as only a single ImageIdentifier is allowed to be\n\t// queried for.\n\tif len(batchGetImageOutput.Failures) > 0 {\n\t\tfailure := batchGetImageOutput.Failures[0]\n\t\tswitch aws.StringValue(failure.FailureCode) {\n\t\t// Requested image with a corresponding tag and digest does not exist.\n\t\t// This failure will generally occur when pushing an updated (or new)\n\t\t// image with a tag.\n\t\tcase ecr.ImageFailureCodeImageTagDoesNotMatchDigest:\n\t\t\tlog.G(ctx).WithField(\"failure\", failure).Debug(\"ecr.base.image: no matching image with specified digest\")\n\t\t\treturn nil, errImageNotFound\n\t\t// Requested image doesn't resolve to a known image. A new image will\n\t\t// result in an ImageNotFound error when checked before push.\n\t\tcase ecr.ImageFailureCodeImageNotFound:\n\t\t\tlog.G(ctx).WithField(\"failure\", failure).Debug(\"ecr.base.image: no image found\")\n\t\t\treturn nil, errImageNotFound\n\t\t// Requested image identifiers are invalid.\n\t\tcase ecr.ImageFailureCodeInvalidImageDigest, ecr.ImageFailureCodeInvalidImageTag:\n\t\t\tlog.G(ctx).WithField(\"failure\", failure).Error(\"ecr.base.image: invalid image identifier\")\n\t\t\treturn nil, reference.ErrInvalid\n\t\t// Unhandled failure reported for image request made.\n\t\tdefault:\n\t\t\tlog.G(ctx).WithField(\"failure\", failure).Warn(\"ecr.base.image: unhandled image request failure\")\n\t\t\treturn nil, errGetImageUnhandled\n\t\t}\n\t}\n\n\treturn batchGetImageOutput.Images[0], nil\n}", "func (c MockDockerClient) ImagePull(ctx context.Context, imageName string) error {\n\tif c.ImagePullFn != nil {\n\t\tfmt.Println(\"[MockDockerClient] In \", utils.CurrentFunctionName())\n\t\tfmt.Println(\"[MockDockerClient] - ctx: \", ctx)\n\t\tfmt.Println(\"[MockDockerClient] - imageName: \", imageName)\n\t\treturn c.ImagePullFn(ctx, imageName)\n\t}\n\tpanic(fmt.Sprintf(\"No function defined for: %s\", utils.CurrentFunctionName()))\n}", "func (m *MockCEImpl) ImagePull(image string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ImagePull\", image)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (mr *MockFetcherMockRecorder) FetchUpdatedLocalImage(arg0, arg1, arg2 interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"FetchUpdatedLocalImage\", reflect.TypeOf((*MockFetcher)(nil).FetchUpdatedLocalImage), arg0, arg1, arg2)\n}", "func (m *MockCompute) ImageIDFromName(arg0 string) (string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ImageIDFromName\", arg0)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func getTestImage(image int) string {\n\treturn imageNames[image]\n}", "func fetchFile(filename string, url string, token string) (err error) {\n\tfmt.Printf(\"fetching file name=%s, url=%s\\n\", filename, url)\n\tlocalfile, err := os.Create(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer localfile.Close()\n\n\tvar user *httpclient.Auth\n\tif token != \"\" {\n\t\tuser = httpclient.GetUserByTokenAuth(token)\n\t}\n\n\t//download file from Shock\n\tres, err := httpclient.Get(url, httpclient.Header{}, nil, user)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer res.Body.Close()\n\n\tif res.StatusCode != 200 { //err in fetching data\n\t\tresbody, _ := ioutil.ReadAll(res.Body)\n\t\tmsg := fmt.Sprintf(\"op=fetchFile, url=%s, res=%s\", url, resbody)\n\t\treturn errors.New(msg)\n\t}\n\n\t_, err = io.Copy(localfile, res.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn\n}", "func (m *MockSystem) CanFetch(path string) bool {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"CanFetch\", path)\n\tret0, _ := ret[0].(bool)\n\treturn ret0\n}", "func (m *MockAgentSecureServer) TaggerFetchEntity(arg0 context.Context, arg1 *core.FetchEntityRequest) (*core.FetchEntityResponse, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"TaggerFetchEntity\", arg0, arg1)\n\tret0, _ := ret[0].(*core.FetchEntityResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockEcrClient) ImageListable(arg0, arg1, arg2, arg3 string) (bool, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ImageListable\", arg0, arg1, arg2, arg3)\n\tret0, _ := ret[0].(bool)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func retagLocalImageForRemotePush(localTag string, remoteUrl string) string {\n\tnewTag := fmt.Sprintf(\"%s/%s\", remoteUrl, localTag)\n\tdockerTag(localTag, newTag)\n\treturn newTag\n}", "func (f MockFetch) Fetch(targetServer Server) ServerStatus {\n\tif targetServer.ID == 196 {\n\t\treturn ServerStatus{targetServer.ID, false, \"404\", targetServer.URL, time.Now()}\n\t}\n\treturn ServerStatus{targetServer.ID, true, \"\", targetServer.URL, time.Now()}\n}", "func (m *MockLoggingClient) Fetch(arg0 context.Context, arg1 *logging.QueryRequest, arg2 ...grpc.CallOption) (*logging.QueryResponse, error) {\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"Fetch\", varargs...)\n\tret0, _ := ret[0].(*logging.QueryResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockHandler) GetLatestOsImage(arg0 string) (*models.OsImage, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetLatestOsImage\", arg0)\n\tret0, _ := ret[0].(*models.OsImage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func prepull(ctx context.Context, req types.FunctionDeployment, client *containerd.Client, alwaysPull bool) (containerd.Image, error) {\n\tstart := time.Now()\n\tr, err := reference.ParseNormalizedNamed(req.Image)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\timgRef := reference.TagNameOnly(r).String()\n\n\tsnapshotter := \"\"\n\tif val, ok := os.LookupEnv(\"snapshotter\"); ok {\n\t\tsnapshotter = val\n\t}\n\n\timage, err := service.PrepareImage(ctx, client, imgRef, snapshotter, alwaysPull)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to pull image %s\", imgRef)\n\t}\n\n\tsize, _ := image.Size(ctx)\n\tlog.Printf(\"Image for: %s size: %d, took: %fs\\n\", image.Name(), size, time.Since(start).Seconds())\n\n\treturn image, nil\n}", "func (is *ImageStoreLocal) InitRepo(name string) error {\n\tvar lockLatency time.Time\n\n\tis.Lock(&lockLatency)\n\tdefer is.Unlock(&lockLatency)\n\n\treturn is.initRepo(name)\n}", "func picturesMock(w http.ResponseWriter, r *http.Request) {\n\tjson := `{\"copyright\":\"Amir H. Abolfath\",\"date\":\"2019-12-06\",\"explanation\":\"This frame.\",\"hdurl\":\"https://apod.nasa.gov/apod/image/1912/TaurusAbolfath.jpg\",\"media_type\":\"image\",\"service_version\":\"v1\",\"title\":\"Pleiades to Hyades\",\"url\":\"https://apod.nasa.gov/apod/image/1912/TaurusAbolfath1024.jpg\"}`\n\tw.WriteHeader(200)\n\t_, _ = w.Write([]byte(json))\n}", "func (m *MockTChanCluster) Fetch(ctx thrift.Context, req *FetchRequest) (*FetchResult_, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Fetch\", ctx, req)\n\tret0, _ := ret[0].(*FetchResult_)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func PrepareBaseImage(ctx context.Context, ref string, output io.Writer) (err error) {\n\n\tcli, err := client.NewEnvClient()\n\tif err != nil {\n\t\treturn\n\t}\n\n\treader, err := cli.ImagePull(ctx, ref, types.ImagePullOptions{})\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer reader.Close()\n\n\tvar log pullLog\n\tstatus := make(map[string]string)\n\tscanner := bufio.NewScanner(reader)\n\tfor scanner.Scan() {\n\t\tjson.Unmarshal(scanner.Bytes(), &log)\n\t\tif log.ID != \"\" {\n\t\t\tcur := status[log.ID]\n\t\t\tif cur != log.Status {\n\t\t\t\tstatus[log.ID] = log.Status\n\t\t\t\tfmt.Fprintln(output, log.Status, log.ID)\n\t\t\t}\n\t\t} else {\n\t\t\tfmt.Fprintln(output, log.Status)\n\t\t}\n\t}\n\n\treturn\n\n}", "func (f FetchStruct) FetchFromRemote() *model.FetchResult {\n\trepo := f.Repo\n\tremoteURL := f.RemoteURL\n\tremoteBranch := f.RemoteBranch\n\trepoPath := f.RepoPath\n\n\tvar remoteDataObject RemoteDataInterface\n\tremoteDataObject = RemoteDataStruct{\n\t\tRepo: repo,\n\t\tRemoteURL: remoteURL,\n\t}\n\n\tremoteName := remoteDataObject.GetRemoteName()\n\tlogger := global.Logger{}\n\n\ttargetRefPsec := \"refs/heads/\" + remoteBranch + \":refs/remotes/\" + remoteBranch\n\tb := new(bytes.Buffer)\n\tvar fetchErr error\n\tgitSSHAuth, sshErr := ssh.NewSSHAgentAuth(\"git\")\n\tw, _ := repo.Worktree()\n\n\t// Check if repo path is empty and fetch path from worktree\n\tif repoPath == \"\" {\n\t\trepoPath = w.Filesystem.Root()\n\t}\n\n\tif sshErr != nil {\n\t\tlogger.Log(\"Authentication method failed -> \"+sshErr.Error(), global.StatusError)\n\t\tif w == nil {\n\t\t\treturn &model.FetchResult{\n\t\t\t\tStatus: global.FetchFromRemoteError,\n\t\t\t\tFetchedItems: nil,\n\t\t\t}\n\t\t}\n\t\tlogger.Log(\"Retrying fetch with fallback module using git client\", global.StatusWarning)\n\t\treturn f.windowsFetch()\n\t}\n\n\tlogger.Log(fmt.Sprintf(\"Fetching changes from -> %s : %s\", remoteURL, targetRefPsec), global.StatusInfo)\n\n\tif remoteURL != \"\" && remoteBranch != \"\" {\n\t\tif remoteName == \"\" {\n\t\t\treturn &model.FetchResult{\n\t\t\t\tStatus: global.FetchFromRemoteError,\n\t\t\t\tFetchedItems: nil,\n\t\t\t}\n\t\t}\n\n\t\tfetchErr = repo.Fetch(&git.FetchOptions{\n\t\t\tRemoteName: remoteName,\n\t\t\tAuth: gitSSHAuth,\n\t\t\tRefSpecs: []config.RefSpec{config.RefSpec(targetRefPsec)},\n\t\t\tProgress: sideband.Progress(func(f io.Writer) io.Writer {\n\t\t\t\treturn f\n\t\t\t}(b)),\n\t\t})\n\t} else {\n\t\tfetchErr = repo.Fetch(&git.FetchOptions{\n\t\t\tRemoteName: git.DefaultRemoteName,\n\t\t\tAuth: gitSSHAuth,\n\t\t\tProgress: sideband.Progress(func(f io.Writer) io.Writer {\n\t\t\t\treturn f\n\t\t\t}(b)),\n\t\t})\n\t}\n\n\tif fetchErr != nil {\n\t\tif fetchErr.Error() == \"already up-to-date\" {\n\t\t\tlogger.Log(fetchErr.Error(), global.StatusWarning)\n\t\t\treturn &model.FetchResult{\n\t\t\t\tStatus: global.FetchNoNewChanges,\n\t\t\t\tFetchedItems: nil,\n\t\t\t}\n\t\t} else {\n\t\t\tlogger.Log(fetchErr.Error(), global.StatusError)\n\t\t\tlogger.Log(\"Fetch failed. Retrying fetch with git client\", global.StatusWarning)\n\t\t\treturn f.windowsFetch()\n\t\t}\n\n\t} else {\n\t\tlogger.Log(b.String(), global.StatusInfo)\n\t\tlogger.Log(\"Changes fetched from remote\", global.StatusInfo)\n\n\t\tmsg := fmt.Sprintf(\"Changes fetched from remote %v\", remoteName)\n\t\treturn &model.FetchResult{\n\t\t\tStatus: global.FetchFromRemoteSuccess,\n\t\t\tFetchedItems: []*string{&msg},\n\t\t}\n\t}\n\n}", "func getRemoteImage(url string) ([]byte, error) {\n\tvar image []byte\n\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\treturn image, err\n\t}\n\tdefer resp.Body.Close()\n\n\timage, err = ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn image, err\n\t}\n\n\treturn image, nil\n}", "func (v *Virt) ImageLocalDigests(ctx context.Context, image string) (digests []string, err error) {\n\treturn\n}", "func LookupMyImage(connConfig string, myImageId string) (SpiderMyImageInfo, error) {\n\n\tif connConfig == \"\" {\n\t\terr := fmt.Errorf(\"LookupMyImage() called with empty connConfig.\")\n\t\tcommon.CBLog.Error(err)\n\t\treturn SpiderMyImageInfo{}, err\n\t} else if myImageId == \"\" {\n\t\terr := fmt.Errorf(\"LookupMyImage() called with empty myImageId.\")\n\t\tcommon.CBLog.Error(err)\n\t\treturn SpiderMyImageInfo{}, err\n\t}\n\n\turl := common.SpiderRestUrl + \"/myimage/\" + url.QueryEscape(myImageId)\n\n\t// Create Req body\n\ttempReq := common.SpiderConnectionName{}\n\ttempReq.ConnectionName = connConfig\n\n\tclient := resty.New().SetCloseConnection(true)\n\tclient.SetAllowGetMethodPayload(true)\n\n\tresp, err := client.R().\n\t\tSetHeader(\"Content-Type\", \"application/json\").\n\t\tSetBody(tempReq).\n\t\tSetResult(&SpiderMyImageInfo{}). // or SetResult(AuthSuccess{}).\n\t\t//SetError(&AuthError{}). // or SetError(AuthError{}).\n\t\tGet(url)\n\n\tif err != nil {\n\t\tcommon.CBLog.Error(err)\n\t\terr := fmt.Errorf(\"an error occurred while requesting to CB-Spider\")\n\t\treturn SpiderMyImageInfo{}, err\n\t}\n\n\tfmt.Println(string(resp.Body()))\n\n\tfmt.Println(\"HTTP Status code: \" + strconv.Itoa(resp.StatusCode()))\n\tswitch {\n\tcase resp.StatusCode() >= 400 || resp.StatusCode() < 200:\n\t\terr := fmt.Errorf(string(resp.Body()))\n\t\tcommon.CBLog.Error(err)\n\t\treturn SpiderMyImageInfo{}, err\n\t}\n\n\ttemp := resp.Result().(*SpiderMyImageInfo)\n\treturn *temp, nil\n\n}", "func GetImage(ctx context.Context, sharedDownload map[string]*DownloadState, params *Params) (io.Reader, error) {\n\tlogger := logging.FromContext(ctx)\n\ttimeout := params.Timeout\n\tURL := params.URL\n\tvar imageReader io.Reader\n\n\tif dnState, ok := sharedDownload[URL]; ok {\n\t\tlogger.WithField(\"url\", URL).Trace(\"is fetching by another client\")\n\t\terrCh := make(chan error, 1)\n\t\tdnState.Subs = append(dnState.Subs, errCh)\n\t\tif err := <-errCh; err != nil {\n\t\t\tlogger.WithError(err).WithField(\"url\", URL).Trace(\"fetch failed\")\n\t\t\tdelete(sharedDownload, URL)\n\t\t\treturn nil, err\n\t\t}\n\t\timageReader = bytes.NewReader(dnState.Data)\n\t\tlogger.WithField(\"url\", URL).Trace(\"fetched shared\")\n\t} else {\n\t\tsubscribers := make([]chan error, 0, 1)\n\t\tdownloadState := &DownloadState{\n\t\t\tData: nil,\n\t\t\tSubs: subscribers,\n\t\t}\n\t\tsharedDownload[URL] = downloadState\n\t\tdefer func(sd map[string]*DownloadState, url string) {\n\t\t\tdelete(sd, url)\n\t\t}(sharedDownload, URL)\n\t\thttpClient := httpclient.NewHTTPClient(timeout)\n\t\tresponse, err := httpClient.Get(ctx, URL)\n\t\tif err != nil {\n\t\t\tlogger.WithError(err).WithField(\"url\", URL).Error(\"fetch image failed\")\n\t\t\tfor _, subs := range downloadState.Subs {\n\t\t\t\tsubs <- err\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\n\t\tdownloadState.Data = response.RawBody\n\t\tfor _, subs := range downloadState.Subs {\n\t\t\tsubs <- nil\n\t\t}\n\t\timageReader = bytes.NewReader(response.RawBody)\n\t}\n\n\treturn imageReader, nil\n}", "func ttrPushImageAsserting(ctx context.Context, t *testing.T, client apiclient.APIClient, image string) {\n\trc, err := client.ImagePush(ctx, ttrImageName(image), types.ImagePushOptions{RegistryAuth: \"{}\"})\n\tassert.Assert(t, err)\n\tif rc != nil {\n\t\tbody, err := readAllAndClose(rc)\n\t\tassert.Assert(t, err)\n\t\tassert.Assert(t, strings.Contains(body, `\"status\":\"latest: digest: `))\n\t}\n}", "func (u Util) PrepareFetch(l *log.Logger, f types.File) *FetchOp {\n\tvar err error\n\tvar expectedSum []byte\n\n\t// explicitly ignoring the error here because the config should already be\n\t// validated by this point\n\turi, _ := url.Parse(f.Contents.Source)\n\n\thasher, err := GetHasher(f.Contents.Verification)\n\tif err != nil {\n\t\tl.Crit(\"Error verifying file %q: %v\", f.Path, err)\n\t\treturn nil\n\t}\n\n\tif hasher != nil {\n\t\t// explicitly ignoring the error here because the config should already\n\t\t// be validated by this point\n\t\t_, expectedSumString, _ := f.Contents.Verification.HashParts()\n\t\texpectedSum, err = hex.DecodeString(expectedSumString)\n\t\tif err != nil {\n\t\t\tl.Crit(\"Error parsing verification string %q: %v\", expectedSumString, err)\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tif f.User.Name != \"\" {\n\t\tuser, err := u.userLookup(f.User.Name)\n\t\tif err != nil {\n\t\t\tl.Crit(\"No such user %q: %v\", f.User.Name, err)\n\t\t\treturn nil\n\t\t}\n\t\tuid, err := strconv.ParseInt(user.Uid, 0, 0)\n\t\tif err != nil {\n\t\t\tl.Crit(\"Couldn't parse uid %q: %v\", user.Uid, err)\n\t\t\treturn nil\n\t\t}\n\t\ttmp := int(uid)\n\t\tf.User.ID = &tmp\n\t}\n\tif f.Group.Name != \"\" {\n\t\tg, err := u.groupLookup(f.Group.Name)\n\t\tif err != nil {\n\t\t\tl.Crit(\"No such group %q: %v\", f.Group.Name, err)\n\t\t\treturn nil\n\t\t}\n\t\tgid, err := strconv.ParseInt(g.Gid, 0, 0)\n\t\tif err != nil {\n\t\t\tl.Crit(\"Couldn't parse gid %q: %v\", g.Gid, err)\n\t\t\treturn nil\n\t\t}\n\t\ttmp := int(gid)\n\t\tf.Group.ID = &tmp\n\t}\n\n\treturn &FetchOp{\n\t\tPath: f.Path,\n\t\tHash: hasher,\n\t\tMode: os.FileMode(f.Mode),\n\t\tUid: *f.User.ID,\n\t\tGid: *f.Group.ID,\n\t\tUrl: *uri,\n\t\tFetchOptions: resource.FetchOptions{\n\t\t\tHash: hasher,\n\t\t\tCompression: f.Contents.Compression,\n\t\t\tExpectedSum: expectedSum,\n\t\t},\n\t}\n}", "func fetch(ctx context.Context, path string, repo *gogit.Repository, branch string, access repoAccess, impl string) error {\n\trefspec := fmt.Sprintf(\"refs/heads/%s:refs/heads/%s\", branch, branch)\n\tswitch impl {\n\tcase sourcev1.LibGit2Implementation:\n\t\tlg2repo, err := libgit2.OpenRepository(path)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn fetchLibgit2(lg2repo, refspec, access)\n\tcase sourcev1.GoGitImplementation:\n\t\treturn fetchGoGit(ctx, repo, refspec, access)\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown git implementation %q\", impl)\n\t}\n}", "func (suite *APIImageSaveLoadSuite) TestImageSaveLoadOk(c *check.C) {\n\tbefore, err := request.Get(\"/images/\" + busyboxImage125 + \"/json\")\n\tc.Assert(err, check.IsNil)\n\tCheckRespStatus(c, before, 200)\n\tgotBefore := types.ImageInfo{}\n\terr = request.DecodeBody(&gotBefore, before.Body)\n\tc.Assert(err, check.IsNil)\n\n\tq := url.Values{}\n\tq.Set(\"name\", busyboxImage125)\n\tquery := request.WithQuery(q)\n\tresp, err := request.Get(\"/images/save\", query)\n\tc.Assert(err, check.IsNil)\n\tdefer resp.Body.Close()\n\n\tdir, err := ioutil.TempDir(\"\", \"TestImageSaveLoadOk\")\n\tif err != nil {\n\t\tc.Errorf(\"failed to create a new temporary directory: %v\", err)\n\t}\n\tdefer os.RemoveAll(dir)\n\n\ttmpFile := filepath.Join(dir, \"busyboxImage.tar\")\n\tf, err := os.Create(tmpFile)\n\tif err != nil {\n\t\tc.Errorf(\"failed to create file: %v\", err)\n\t}\n\n\tif _, err := io.Copy(f, resp.Body); err != nil {\n\t\tc.Errorf(\"failed to save data to file: %v\", err)\n\t}\n\n\tdata, err := os.Open(tmpFile)\n\tif err != nil {\n\t\tc.Errorf(\"failed to load file's data: %v\", err)\n\t}\n\n\tloadImageName := \"load-busyboxImage\"\n\tq = url.Values{}\n\tq.Set(\"name\", loadImageName)\n\n\tquery = request.WithQuery(q)\n\treader := request.WithRawData(data)\n\theader := request.WithHeader(\"Content-Type\", \"application/x-tar\")\n\n\tresp, err = request.Post(\"/images/load\", query, reader, header)\n\tc.Assert(err, check.IsNil)\n\tCheckRespStatus(c, resp, 200)\n\n\tafter, err := request.Get(\"/images/\" + loadImageName + \":\" + environment.Busybox125Tag + \"/json\")\n\tc.Assert(err, check.IsNil)\n\tCheckRespStatus(c, after, 200)\n\tdefer request.Delete(\"/images/\" + loadImageName + \":\" + environment.Busybox125Tag)\n\n\tgotAfter := types.ImageInfo{}\n\terr = request.DecodeBody(&gotAfter, after.Body)\n\tc.Assert(err, check.IsNil)\n\n\tc.Assert(gotBefore.ID, check.Equals, gotAfter.ID)\n\tc.Assert(gotBefore.CreatedAt, check.Equals, gotAfter.CreatedAt)\n\tc.Assert(gotBefore.Size, check.Equals, gotAfter.Size)\n}", "func (m *MockLocalConfigProvider) GetURL(name string) (*LocalURL, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetURL\", name)\n\tret0, _ := ret[0].(*LocalURL)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockStorage) Get(ctx context.Context, id string) (*storage.ImageModel, error) {\n\tret := m.ctrl.Call(m, \"Get\", ctx, id)\n\tret0, _ := ret[0].(*storage.ImageModel)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (s *FileStore) PullImage(ctx context.Context, name string, translator Translator) (string, error) {\n\tname, specDigest := SplitImageName(name)\n\tep := translator(ctx, name)\n\tglog.V(1).Infof(\"Image translation: %q -> %q\", name, ep.URL)\n\tif err := os.MkdirAll(s.dataDir(), 0777); err != nil {\n\t\treturn \"\", fmt.Errorf(\"mkdir %q: %v\", s.dataDir(), err)\n\t}\n\ttempFile, err := ioutil.TempFile(s.dataDir(), \"part_\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to create a temporary file: %v\", err)\n\t}\n\tdefer func() {\n\t\tif tempFile != nil {\n\t\t\ttempFile.Close()\n\t\t}\n\t}()\n\tif err := s.downloader.DownloadFile(ctx, ep, tempFile); err != nil {\n\t\ttempFile.Close()\n\t\tif err := os.Remove(tempFile.Name()); err != nil {\n\t\t\tglog.Warningf(\"Error removing %q: %v\", tempFile.Name(), err)\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"error downloading %q: %v\", ep.URL, err)\n\t}\n\n\tif _, err := tempFile.Seek(0, os.SEEK_SET); err != nil {\n\t\treturn \"\", fmt.Errorf(\"can't get the digest for %q: Seek(): %v\", tempFile.Name(), err)\n\t}\n\n\td, err := digest.FromReader(tempFile)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif err := tempFile.Close(); err != nil {\n\t\treturn \"\", fmt.Errorf(\"closing %q: %v\", tempFile.Name(), err)\n\t}\n\tfileName := tempFile.Name()\n\ttempFile = nil\n\tif specDigest != \"\" && d != specDigest {\n\t\treturn \"\", fmt.Errorf(\"image digest mismatch: %s instead of %s\", d, specDigest)\n\t}\n\tif err := s.placeImage(fileName, d.Hex(), name); err != nil {\n\t\treturn \"\", err\n\t}\n\tnamed, err := reference.WithName(name)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\twithDigest, err := reference.WithDigest(named, d)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn withDigest.String(), nil\n}", "func NewLocalFetcher() *LocalFetcher {\n\treturn &LocalFetcher{\n\t\tdata: make(map[string]*asset.Asset),\n\t}\n}", "func Fetch(dir, target string, pool int, dynamic bool) error {\n\tlocal, err := GetOrigin(dir)\n\tif err != nil {\n\t\tlog.Error(\"bad local origin:\", err)\n\t\treturn err\n\t}\n\tlocalHashes, localSource, err := local.Scan()\n\tif target != \"\" {\n\t\tlocalSource = target\n\t}\n\tglobal, err := GetOrigin(localSource)\n\tif err != nil {\n\t\tlog.Error(\"bad global origin:\", err)\n\t\treturn err\n\t}\n\tglobalHashes, globalSource, err := global.Scan()\n\tif globalSource != localSource {\n\t\tlog.Warning(\"unverified origin:\", globalSource)\n\t} else {\n\t\tlog.Notice(\"verified origin:\", globalSource)\n\t}\n\n\tmissingHashes := Compare(localHashes, globalHashes)\n\tif pool < 2 {\n\t\terr = FetchSpecific(dir, global, missingHashes)\n\t} else {\n\t\tif dynamic {\n\t\t\tpool *= runtime.NumCPU()\n\t\t}\n\t\terr = FetchSpecificAsync(dir, global, missingHashes, pool)\n\t}\n\tif err != nil {\n\t\tlog.Error(\"failed to fetch files:\", err)\n\t\treturn err\n\t}\n\tlog.Notice(\"fetched\", len(missingHashes), \"files from origin\")\n\n\treturn Write(dir, globalSource, globalHashes)\n}", "func PullImage(image, cacheDir string) (v1.Image, error) {\n var options []crane.Option\n\n // options = append(options, crane.Insecure)\n\n // Use current built OS and architecture\n options = append(options, crane.WithPlatform(&v1.Platform{\n OS: runtime.GOOS,\n Architecture: runtime.GOARCH,\n }))\n\n // Grab the remote manifest\n manifest, err := crane.Manifest(image, options...)\n if err != nil {\n return nil, fmt.Errorf(\"failed fetching manifest for %s: %v\", image, err)\n }\n\n if !gjson.Valid(string(manifest)) {\n return nil, fmt.Errorf(\"Cannot parse manifest: %s\", string(manifest))\n }\n\n value := gjson.Get(string(manifest), \"config.digest\").Value().(string)\n if value == \"\" {\n return nil, fmt.Errorf(\"Malformed manifest: %s\", string(manifest))\n }\n \n digest := strings.Split(value, \":\")[1]\n tarball := fmt.Sprintf(\"%s/%s.tar.gz\", cacheDir, digest)\n\n // Download the tarball of the image if not available in the cache\n if _, err := os.Stat(tarball); os.IsNotExist(err) {\n // Create the cacheDir if it does not already exist\n if cacheDir != \"\" {\n if _, err := os.Stat(cacheDir); os.IsNotExist(err) {\n os.MkdirAll(cacheDir, os.ModePerm)\n }\n }\n \n // Pull the image\n img, err := crane.Pull(image, options...)\n if err != nil {\n return nil, fmt.Errorf(\"Could not pull image: %s\", err)\n }\n \n f, err := os.Create(tarball)\n if err != nil {\n return nil, fmt.Errorf(\"Failed to open %s: %v\", tarball, err)\n }\n \n defer f.Close()\n \n err = crane.Save(img, image, tarball)\n if err != nil {\n return nil, fmt.Errorf(\"Could not save image: %s\", err)\n }\n }\n\n img, err := crane.Load(tarball)\n if err != nil {\n return nil, fmt.Errorf(\"Could not load image: %s\", err)\n }\n\n return img, nil\n}", "func (i ImageFetcher) Fetch(path string) (image.Image, error) {\n\tresp, err := http.Get(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\treturn png.Decode(resp.Body)\n}", "func (m *MockTChanNode) Fetch(ctx thrift.Context, req *FetchRequest) (*FetchResult_, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Fetch\", ctx, req)\n\tret0, _ := ret[0].(*FetchResult_)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func pull(ctx context.Context, imgCache *cache.Handle, directTo, pullFrom string, noHTTPS bool) (imagePath string, err error) {\n\tshubURI, err := ParseReference(pullFrom)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to parse shub uri: %s\", err)\n\t}\n\n\t// Get the image manifest\n\tmanifest, err := GetManifest(shubURI, noHTTPS)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get manifest for: %s: %s\", pullFrom, err)\n\t}\n\n\tif directTo != \"\" {\n\t\tsylog.Infof(\"Downloading shub image\")\n\t\tif err := DownloadImage(ctx, manifest, directTo, pullFrom, true, noHTTPS); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\timagePath = directTo\n\t} else {\n\t\tcacheEntry, err := imgCache.GetEntry(cache.ShubCacheType, manifest.Commit)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"unable to check if %v exists in cache: %v\", manifest.Commit, err)\n\t\t}\n\t\tdefer cacheEntry.CleanTmp()\n\t\tif !cacheEntry.Exists {\n\t\t\tsylog.Infof(\"Downloading shub image\")\n\n\t\t\terr := DownloadImage(ctx, manifest, cacheEntry.TmpPath, pullFrom, true, noHTTPS)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\terr = cacheEntry.Finalize()\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\timagePath = cacheEntry.Path\n\t\t} else {\n\t\t\tsylog.Infof(\"Use cached image\")\n\t\t\timagePath = cacheEntry.Path\n\t\t}\n\n\t}\n\n\treturn imagePath, nil\n}", "func TestFetcher_Disk(t *testing.T) {\n\tfetcher := (&diskFetcher{\"../fixtures\"}).fetch\n\n\tfakeSites := []struct {\n\t\turl string\n\t\texpected string\n\t}{\n\t\t{\"https://www.404s.com/nope.txt\", \"\"},\n\t\t{\"https://www.404s.com/hello.txt\", \"Hello, world!\"},\n\t}\n\tfor _, site := range fakeSites {\n\t\tt.Run(site.url, func(t *testing.T) {\n\t\t\tactual := fetchAsString(t, fetcher, site.url)\n\t\t\trequire.Equal(t, site.expected, actual)\n\t\t})\n\t}\n}", "func (_m *MockECRAPI) BatchGetImageRequest(_param0 *ecr.BatchGetImageInput) (*request.Request, *ecr.BatchGetImageOutput) {\n\tret := _m.ctrl.Call(_m, \"BatchGetImageRequest\", _param0)\n\tret0, _ := ret[0].(*request.Request)\n\tret1, _ := ret[1].(*ecr.BatchGetImageOutput)\n\treturn ret0, ret1\n}", "func (m *MockPexeler) GetRandomImage(arg0 string) (int, []byte, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetRandomImage\", arg0)\n\tret0, _ := ret[0].(int)\n\tret1, _ := ret[1].([]byte)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "func _getMock(url string) (content []byte, err error) {\n\tvar idnum = crc32.ChecksumIEEE([]byte(url))%uint32(5) + 1\n\tvar response = fmt.Sprintf(mockResponseTemplate, idnum, idnum, \"no message\", 200)\n\treturn []byte(response), nil\n}", "func TestGetImages(t *testing.T) {\n\t// Test case 1: HTML with no image tags\n\thtml1 := `<html><body><h1>Hello, World!</h1></body></html>`\n\texpected1 := make(map[string]string)\n\tresult1, err1 := core.GetImages(html1)\n\tif err1 != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err1)\n\t}\n\tif len(result1) != len(expected1) {\n\t\tt.Errorf(\"Expected %d images, but got %d\", len(expected1), len(result1))\n\t}\n\n\t// Test case 2: HTML with one image tag\n\thtml2 := `<html><body><img src=\"image1.jpg\"></body></html>`\n\texpected2 := map[string]string{\"image1.jpg\": \"<img src=\\\"image1.jpg\\\">\"}\n\tresult2, err2 := core.GetImages(html2)\n\tif err2 != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err2)\n\t}\n\tif len(result2) != len(expected2) {\n\t\tt.Errorf(\"Expected %d images, but got %d\", len(expected2), len(result2))\n\t}\n\tfor key, value := range expected2 {\n\t\tif result2[key] != value {\n\t\t\tt.Errorf(\"Expected image URL %s with tag %s, but got %s\", key, value, result2[key])\n\t\t}\n\t}\n\n\t// Test case 3: HTML with multiple image tags\n\thtml3 := `<html><body><img src=\"image1.jpg\"><img src=\"image2.jpg\"></body></html>`\n\texpected3 := map[string]string{\n\t\t\"image1.jpg\": \"<img src=\\\"image1.jpg\\\">\",\n\t\t\"image2.jpg\": \"<img src=\\\"image2.jpg\\\">\",\n\t}\n\tresult3, err3 := core.GetImages(html3)\n\tif err3 != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err3)\n\t}\n\tif len(result3) != len(expected3) {\n\t\tt.Errorf(\"Expected %d images, but got %d\", len(expected3), len(result3))\n\t}\n\tfor key, value := range expected3 {\n\t\tif result3[key] != value {\n\t\t\tt.Errorf(\"Expected image URL %s with tag %s, but got %s\", key, value, result3[key])\n\t\t}\n\t}\n\t// Test case 4: HTML with multiple image tags with duplicayr\n\thtml4 := `<html><body><img src=\"image1.jpg\"><img src=\"image2.jpg\"><img src=\"image2.jpg\"></body></html>`\n\texpected4 := map[string]string{\n\t\t\"image1.jpg\": \"<img src=\\\"image1.jpg\\\">\",\n\t\t\"image2.jpg\": \"<img src=\\\"image2.jpg\\\">\",\n\t}\n\tresult4, err4 := core.GetImages(html4)\n\tif err4 != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err4)\n\t}\n\tif len(result4) != len(expected4) {\n\t\tt.Errorf(\"Expected %d images, but got %d\", len(expected4), len(result4))\n\t}\n\tfor key, value := range expected4 {\n\t\tif result4[key] != value {\n\t\t\tt.Errorf(\"Expected image URL %s with tag %s, but got %s\", key, value, result4[key])\n\t\t}\n\t}\n}", "func (m *MockRepository) FetchAll(bucketName string, modelFn func([]byte) (db.Model, error)) (interface{}, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"FetchAll\", bucketName, modelFn)\n\tret0, _ := ret[0].(interface{})\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockUnzipper) FetchAndExtract(arg0 context.Context, arg1 string) (map[string][]byte, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"FetchAndExtract\", arg0, arg1)\n\tret0, _ := ret[0].(map[string][]byte)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}" ]
[ "0.72084695", "0.6717672", "0.6187629", "0.60904604", "0.5996021", "0.58322525", "0.5825194", "0.5771793", "0.5758451", "0.57340926", "0.5726534", "0.5694318", "0.56871355", "0.5607126", "0.5600493", "0.55343837", "0.548785", "0.53960055", "0.537409", "0.53434074", "0.5329744", "0.52986526", "0.5295109", "0.5293138", "0.52815896", "0.52813476", "0.5259406", "0.5255973", "0.52421516", "0.5228599", "0.5224441", "0.52157396", "0.5198362", "0.517085", "0.51669323", "0.51479065", "0.51467085", "0.51284117", "0.51221454", "0.51214004", "0.50836855", "0.5074557", "0.5062827", "0.50473523", "0.50469536", "0.50334287", "0.50268346", "0.5014151", "0.49971282", "0.49901295", "0.4988306", "0.497935", "0.49741", "0.49739656", "0.49600983", "0.49597535", "0.4955469", "0.49510545", "0.49505162", "0.4942324", "0.4937981", "0.49214906", "0.49165148", "0.49111128", "0.4902524", "0.49006534", "0.48984995", "0.48971304", "0.48781705", "0.48768905", "0.48699847", "0.48598334", "0.48594522", "0.48341104", "0.4833799", "0.48335838", "0.48301634", "0.48243967", "0.48173138", "0.4816802", "0.4808415", "0.48032337", "0.48009023", "0.47943538", "0.47927514", "0.47924235", "0.47920927", "0.47912517", "0.47901776", "0.47867823", "0.4778739", "0.4778729", "0.47772896", "0.47749105", "0.47655374", "0.4764281", "0.4761982", "0.4756816", "0.47547153", "0.4753348" ]
0.78663063
0
FetchRemoteImage mocks base method
FetchRemoteImage имитирует базовый метод
func (m *MockFetcher) FetchRemoteImage(arg0 string) (image.Image, error) { ret := m.ctrl.Call(m, "FetchRemoteImage", arg0) ret0, _ := ret[0].(image.Image) ret1, _ := ret[1].(error) return ret0, ret1 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *MockFetcher) FetchLocalImage(arg0 string) (image.Image, error) {\n\tret := m.ctrl.Call(m, \"FetchLocalImage\", arg0)\n\tret0, _ := ret[0].(image.Image)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockFetcher) FetchUpdatedLocalImage(arg0 context.Context, arg1 string, arg2 io.Writer) (image.Image, error) {\n\tret := m.ctrl.Call(m, \"FetchUpdatedLocalImage\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(image.Image)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (f *Frontend) fetchImage(i *img.Image) (*img.Image, error) {\n\tvar err error\n\n\t// go through image proxy to resize and cache the image\n\tkey := hmacKey(i.ID)\n\tu := fmt.Sprintf(\"%v/image/225x,s%v/%v\", f.Host, key, i.ID)\n\tfmt.Println(u)\n\n\tresp, err := f.Images.Client.Get(u)\n\tif err != nil {\n\t\treturn i, err\n\t}\n\n\tdefer resp.Body.Close()\n\n\tbdy, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn i, err\n\t}\n\n\ti.Base64 = base64.StdEncoding.EncodeToString(bdy)\n\treturn i, err\n}", "func TestBaseImage(t *testing.T) {\n\tctx, err := controllerPrepare()\n\tif err != nil {\n\t\tt.Fatal(\"Fail in controller prepare: \", err)\n\t}\n\teveBaseRef := os.Getenv(\"EVE_BASE_REF\")\n\tif len(eveBaseRef) == 0 {\n\t\teveBaseRef = \"4.10.0\"\n\t}\n\tzArch := os.Getenv(\"ZARCH\")\n\tif len(eveBaseRef) == 0 {\n\t\tzArch = \"amd64\"\n\t}\n\tHV := os.Getenv(\"HV\")\n\tif HV == \"xen\" {\n\t\tHV = \"\"\n\t}\n\tvar baseImageTests = []struct {\n\t\tdataStoreID string\n\t\timageID string\n\t\tbaseID string\n\t\timageRelativePath string\n\t\timageFormat config.Format\n\t\teveBaseRef string\n\t\tzArch string\n\t\tHV string\n\t}{\n\t\t{eServerDataStoreID,\n\n\t\t\t\"1ab8761b-5f89-4e0b-b757-4b87a9fa93ec\",\n\n\t\t\t\"22b8761b-5f89-4e0b-b757-4b87a9fa93ec\",\n\n\t\t\t\"baseos.qcow2\",\n\t\t\tconfig.Format_QCOW2,\n\t\t\teveBaseRef,\n\t\t\tzArch,\n\t\t\tHV,\n\t\t},\n\t}\n\tfor _, tt := range baseImageTests {\n\t\tbaseOSVersion := fmt.Sprintf(\"%s-%s\", tt.eveBaseRef, tt.zArch)\n\t\tif tt.HV != \"\" {\n\t\t\tbaseOSVersion = fmt.Sprintf(\"%s-%s-%s\", tt.eveBaseRef, tt.zArch, tt.HV)\n\t\t}\n\t\tt.Run(baseOSVersion, func(t *testing.T) {\n\n\t\t\terr = prepareBaseImageLocal(ctx, tt.dataStoreID, tt.imageID, tt.baseID, tt.imageRelativePath, tt.imageFormat, baseOSVersion)\n\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(\"Fail in prepare base image from local file: \", err)\n\t\t\t}\n\t\t\tdeviceCtx, err := ctx.GetDeviceFirst()\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(\"Fail in get first device: \", err)\n\t\t\t}\n\t\t\tdeviceCtx.SetBaseOSConfig([]string{tt.baseID})\n\t\t\tdevUUID := deviceCtx.GetID()\n\t\t\terr = ctx.ConfigSync(deviceCtx)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(\"Fail in sync config with controller: \", err)\n\t\t\t}\n\t\t\tt.Run(\"Started\", func(t *testing.T) {\n\t\t\t\terr := ctx.InfoChecker(devUUID, map[string]string{\"devId\": devUUID.String(), \"shortVersion\": baseOSVersion}, einfo.ZInfoDevSW, 300)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(\"Fail in waiting for base image update init: \", err)\n\t\t\t\t}\n\t\t\t})\n\t\t\tt.Run(\"Downloaded\", func(t *testing.T) {\n\t\t\t\terr := ctx.InfoChecker(devUUID, map[string]string{\"devId\": devUUID.String(), \"shortVersion\": baseOSVersion, \"downloadProgress\": \"100\"}, einfo.ZInfoDevSW, 1500)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(\"Fail in waiting for base image download progress: \", err)\n\t\t\t\t}\n\t\t\t})\n\t\t\tt.Run(\"Logs\", func(t *testing.T) {\n\t\t\t\tif !checkLogs {\n\t\t\t\t\tt.Skip(\"no LOGS flag set - skipped\")\n\t\t\t\t}\n\t\t\t\terr = ctx.LogChecker(devUUID, map[string]string{\"devId\": devUUID.String(), \"eveVersion\": baseOSVersion}, 1200)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(\"Fail in waiting for base image logs: \", err)\n\t\t\t\t}\n\t\t\t})\n\t\t\ttimeout := time.Duration(1200)\n\n\t\t\tif !checkLogs {\n\t\t\t\ttimeout = 2400\n\t\t\t}\n\t\t\tt.Run(\"Active\", func(t *testing.T) {\n\t\t\t\terr = ctx.InfoChecker(devUUID, map[string]string{\"devId\": devUUID.String(), \"shortVersion\": baseOSVersion, \"status\": \"INSTALLED\", \"partitionState\": \"(inprogress|active)\"}, einfo.ZInfoDevSW, timeout)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(\"Fail in waiting for base image installed status: \", err)\n\t\t\t\t}\n\t\t\t})\n\t\t})\n\t}\n\n}", "func TestFetch(t *testing.T) {\n\timage := \"rkt-inspect-fetch.aci\"\n\n\tctx := newRktRunCtx()\n\tdefer ctx.cleanup()\n\n\t// Fetch the image for the first time, this should write the image to the\n\t// on-disk store.\n\toldHash := patchImportAndFetchHash(image, []string{\"--exec=/inspect --read-file\"}, t, ctx)\n\n\t// Fetch the image with the same name but different content, the expecting\n\t// result is that we should get a different hash since we are not fetching\n\t// from the on-disk store.\n\tnewHash := patchImportAndFetchHash(image, []string{\"--exec=/inspect --read-file --write-file\"}, t, ctx)\n\n\tif oldHash == newHash {\n\t\tt.Fatalf(\"ACI hash should be different as the image has changed\")\n\t}\n}", "func (m *MockCEImpl) ImagePull(image string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ImagePull\", image)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func ttrPullImageAsserting(ctx context.Context, t *testing.T, client apiclient.APIClient, image string) {\n\terr := ttrPullImage(ctx, client, image)\n\tassert.NilError(t, err)\n}", "func getRemoteImage(url string) ([]byte, error) {\n\tvar image []byte\n\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\treturn image, err\n\t}\n\tdefer resp.Body.Close()\n\n\timage, err = ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn image, err\n\t}\n\n\treturn image, nil\n}", "func (m *MockRequester) Fetch(url string) (io.ReadCloser, error) {\n\tret := m.ctrl.Call(m, \"Fetch\", url)\n\tret0, _ := ret[0].(io.ReadCloser)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (c *dockerClientMock) DownloadImage(imageSource, filePath string) (v1.Image, error) {\n\treturn &fake.FakeImage{}, nil // fmt.Errorf(\"%s\", filePath)\n}", "func TestImplicitFetch(t *testing.T) {\n\tfoundMsg := \"found image in local store\"\n\n\tctx := newRktRunCtx()\n\tdefer ctx.cleanup()\n\n\t// 1. Fetch the image.\n\t// TODO(yifan): Add other ACI with different schemes.\n\timportImageAndFetchHash(t, ctx, \"docker://busybox:ubuntu-12.04\")\n\timportImageAndFetchHash(t, ctx, \"docker://busybox:latest\")\n\n\t// 2. Try run/prepare with/without tag ':latest', should not get $foundMsg.\n\tcmds := []string{\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify run --mds-register=false docker://busybox\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify run --mds-register=false docker://busybox:latest\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify prepare docker://busybox\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify prepare docker://busybox:latest\", ctx.cmd()),\n\t}\n\n\tfor _, cmd := range cmds {\n\t\tt.Logf(\"Running test %v\", cmd)\n\n\t\tchild, err := gexpect.Spawn(cmd)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Cannot exec rkt: %v\", err)\n\t\t}\n\t\tif err := expectWithOutput(child, foundMsg); err == nil {\n\t\t\tt.Fatalf(\"%q should not be found\", foundMsg)\n\t\t}\n\t\tif err := child.Wait(); err != nil {\n\t\t\tt.Fatalf(\"rkt didn't terminate correctly: %v\", err)\n\t\t}\n\t}\n}", "func TestRemote(t *testing.T) {\n\trnd, err := random.Image(1024, 3)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\ts, err := registry.TLS(\"gcr.io\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\ttr := s.Client().Transport\n\n\tsrc := \"gcr.io/test/compressed\"\n\tref, err := name.ParseReference(src)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif err := remote.Write(ref, rnd, remote.WithTransport(tr)); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\timg, err := remote.Image(ref, remote.WithTransport(tr))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif err := validate.Image(img); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tcf, err := img.ConfigFile()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tm, err := img.Manifest()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tlayer, err := img.LayerByDiffID(cf.RootFS.DiffIDs[0])\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\td, err := layer.Digest()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif diff := cmp.Diff(d, m.Layers[0].Digest); diff != \"\" {\n\t\tt.Errorf(\"mismatched digest: %v\", diff)\n\t}\n}", "func (c *dockerClientMock) GetRemoteImageInfo(imageSoure string) (v1.Image, error) {\n\treturn &fake.FakeImage{}, nil\n}", "func (f *fetcher) fetchImage(img string, asc string, discover bool) (string, error) {\n\tif f.withDeps && !discover {\n\t\treturn \"\", fmt.Errorf(\"cannot fetch image's dependencies with discovery disabled\")\n\t}\n\thash, err := f.fetchSingleImage(img, asc, discover)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif f.withDeps {\n\t\terr = f.fetchImageDeps(hash)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\treturn hash, nil\n}", "func (f OriginalFetcher) Fetch(namespace string, sourceURL string, imageHash string) (info *info.ImageProperties, downloaded bool, err error) {\n\tif sourceURL == \"\" && imageHash == \"\" {\n\t\treturn nil, false, fmt.Errorf(\"Missing Hash & URL\")\n\t}\n\n\tif imageHash != \"\" {\n\t\tinfo, err = f.fetchFromStore(namespace, imageHash)\n\t}\n\n\tif sourceURL != \"\" && (err != nil || imageHash == \"\") {\n\t\tinfo, downloaded, err = f.fetchFromSource(namespace, sourceURL)\n\t}\n\n\treturn info, downloaded, err\n}", "func (f *fetcher) fetchImageFrom(appName string, aciURL, ascURL, scheme string, ascFile *os.File, latest bool) (string, error) {\n\tvar rem *store.Remote\n\n\tif f.insecureSkipVerify {\n\t\tif f.ks != nil {\n\t\t\tstderr(\"rkt: warning: TLS verification and signature verification has been disabled\")\n\t\t}\n\t} else if scheme == \"docker\" {\n\t\treturn \"\", fmt.Errorf(\"signature verification for docker images is not supported (try --insecure-skip-verify)\")\n\t}\n\n\tif (f.local && scheme != \"file\") || (scheme != \"file\" && !latest) {\n\t\tvar err error\n\t\tok := false\n\t\trem, ok, err = f.s.GetRemote(aciURL)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif ok {\n\t\t\tif f.local {\n\t\t\t\tstderr(\"rkt: using image in local store for app %s\", appName)\n\t\t\t\treturn rem.BlobKey, nil\n\t\t\t}\n\t\t\tif useCached(rem.DownloadTime, rem.CacheMaxAge) {\n\t\t\t\tstderr(\"rkt: found image in local store, skipping fetching from %s\", aciURL)\n\t\t\t\treturn rem.BlobKey, nil\n\t\t\t}\n\t\t}\n\t\tif f.local {\n\t\t\treturn \"\", fmt.Errorf(\"url %s not available in local store\", aciURL)\n\t\t}\n\t}\n\n\tif scheme != \"file\" && f.debug {\n\t\tstderr(\"rkt: fetching image from %s\", aciURL)\n\t}\n\n\tvar etag string\n\tif rem != nil {\n\t\tetag = rem.ETag\n\t}\n\tentity, aciFile, cd, err := f.fetch(appName, aciURL, ascURL, ascFile, etag)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif cd != nil && cd.useCached {\n\t\tif rem != nil {\n\t\t\treturn rem.BlobKey, nil\n\t\t} else {\n\t\t\t// should never happen\n\t\t\tpanic(\"asked to use cached image but remote is nil\")\n\t\t}\n\t}\n\tif scheme != \"file\" {\n\t\tdefer os.Remove(aciFile.Name())\n\t}\n\n\tif entity != nil && !f.insecureSkipVerify {\n\t\tstderr(\"rkt: signature verified:\")\n\t\tfor _, v := range entity.Identities {\n\t\t\tstderr(\" %s\", v.Name)\n\t\t}\n\t}\n\tkey, err := f.s.WriteACI(aciFile, latest)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif scheme != \"file\" {\n\t\trem := store.NewRemote(aciURL, ascURL)\n\t\trem.BlobKey = key\n\t\trem.DownloadTime = time.Now()\n\t\tif cd != nil {\n\t\t\trem.ETag = cd.etag\n\t\t\trem.CacheMaxAge = cd.maxAge\n\t\t}\n\t\terr = f.s.WriteRemote(rem)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\treturn key, nil\n}", "func (m *MockHandler) GetLatestOsImage(arg0 string) (*models.OsImage, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetLatestOsImage\", arg0)\n\tret0, _ := ret[0].(*models.OsImage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockModuleService) GetLatestModuleImage(arg0 string) (string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetLatestModuleImage\", arg0)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func PullImage(image, cacheDir string) (v1.Image, error) {\n var options []crane.Option\n\n // options = append(options, crane.Insecure)\n\n // Use current built OS and architecture\n options = append(options, crane.WithPlatform(&v1.Platform{\n OS: runtime.GOOS,\n Architecture: runtime.GOARCH,\n }))\n\n // Grab the remote manifest\n manifest, err := crane.Manifest(image, options...)\n if err != nil {\n return nil, fmt.Errorf(\"failed fetching manifest for %s: %v\", image, err)\n }\n\n if !gjson.Valid(string(manifest)) {\n return nil, fmt.Errorf(\"Cannot parse manifest: %s\", string(manifest))\n }\n\n value := gjson.Get(string(manifest), \"config.digest\").Value().(string)\n if value == \"\" {\n return nil, fmt.Errorf(\"Malformed manifest: %s\", string(manifest))\n }\n \n digest := strings.Split(value, \":\")[1]\n tarball := fmt.Sprintf(\"%s/%s.tar.gz\", cacheDir, digest)\n\n // Download the tarball of the image if not available in the cache\n if _, err := os.Stat(tarball); os.IsNotExist(err) {\n // Create the cacheDir if it does not already exist\n if cacheDir != \"\" {\n if _, err := os.Stat(cacheDir); os.IsNotExist(err) {\n os.MkdirAll(cacheDir, os.ModePerm)\n }\n }\n \n // Pull the image\n img, err := crane.Pull(image, options...)\n if err != nil {\n return nil, fmt.Errorf(\"Could not pull image: %s\", err)\n }\n \n f, err := os.Create(tarball)\n if err != nil {\n return nil, fmt.Errorf(\"Failed to open %s: %v\", tarball, err)\n }\n \n defer f.Close()\n \n err = crane.Save(img, image, tarball)\n if err != nil {\n return nil, fmt.Errorf(\"Could not save image: %s\", err)\n }\n }\n\n img, err := crane.Load(tarball)\n if err != nil {\n return nil, fmt.Errorf(\"Could not load image: %s\", err)\n }\n\n return img, nil\n}", "func (m *MockHandler) GetOsImage(arg0, arg1 string) (*models.OsImage, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetOsImage\", arg0, arg1)\n\tret0, _ := ret[0].(*models.OsImage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (b *ecrBase) runGetImage(ctx context.Context, batchGetImageInput ecr.BatchGetImageInput) (*ecr.Image, error) {\n\t// Allow only a single image to be fetched at a time.\n\tif len(batchGetImageInput.ImageIds) != 1 {\n\t\treturn nil, errGetImageUnhandled\n\t}\n\n\tbatchGetImageInput.RegistryId = aws.String(b.ecrSpec.Registry())\n\tbatchGetImageInput.RepositoryName = aws.String(b.ecrSpec.Repository)\n\n\tlog.G(ctx).WithField(\"batchGetImageInput\", batchGetImageInput).Trace(\"ecr.base.image: requesting images\")\n\n\tbatchGetImageOutput, err := b.client.BatchGetImageWithContext(ctx, &batchGetImageInput)\n\tif err != nil {\n\t\tlog.G(ctx).WithError(err).Error(\"ecr.base.image: failed to get image\")\n\t\treturn nil, err\n\t}\n\tlog.G(ctx).WithField(\"batchGetImageOutput\", batchGetImageOutput).Trace(\"ecr.base.image: api response\")\n\n\t// Summarize image request failures for handled errors. Only the first\n\t// failure is checked as only a single ImageIdentifier is allowed to be\n\t// queried for.\n\tif len(batchGetImageOutput.Failures) > 0 {\n\t\tfailure := batchGetImageOutput.Failures[0]\n\t\tswitch aws.StringValue(failure.FailureCode) {\n\t\t// Requested image with a corresponding tag and digest does not exist.\n\t\t// This failure will generally occur when pushing an updated (or new)\n\t\t// image with a tag.\n\t\tcase ecr.ImageFailureCodeImageTagDoesNotMatchDigest:\n\t\t\tlog.G(ctx).WithField(\"failure\", failure).Debug(\"ecr.base.image: no matching image with specified digest\")\n\t\t\treturn nil, errImageNotFound\n\t\t// Requested image doesn't resolve to a known image. A new image will\n\t\t// result in an ImageNotFound error when checked before push.\n\t\tcase ecr.ImageFailureCodeImageNotFound:\n\t\t\tlog.G(ctx).WithField(\"failure\", failure).Debug(\"ecr.base.image: no image found\")\n\t\t\treturn nil, errImageNotFound\n\t\t// Requested image identifiers are invalid.\n\t\tcase ecr.ImageFailureCodeInvalidImageDigest, ecr.ImageFailureCodeInvalidImageTag:\n\t\t\tlog.G(ctx).WithField(\"failure\", failure).Error(\"ecr.base.image: invalid image identifier\")\n\t\t\treturn nil, reference.ErrInvalid\n\t\t// Unhandled failure reported for image request made.\n\t\tdefault:\n\t\t\tlog.G(ctx).WithField(\"failure\", failure).Warn(\"ecr.base.image: unhandled image request failure\")\n\t\t\treturn nil, errGetImageUnhandled\n\t\t}\n\t}\n\n\treturn batchGetImageOutput.Images[0], nil\n}", "func TestExpectedImgRef(t *testing.T) {\n\n\tv, isSet := os.LookupEnv(\"DOCKERHUB_PROXY\")\n\tif isSet {\n\t\tdefer os.Setenv(\"DOCKERHUB_PROXY\", v)\n\t}\n\n\tos.Unsetenv(\"DOCKERHUB_PROXY\")\n\tassert.Equal(t,\n\t\t\"index.docker.io/library/hello-world@sha256:ebf526c198a14fa138634b9746c50ec38077ec9b3986227e79eb837d26f59dc6\",\n\t\tCompleteImageRef(\"library/hello-world@sha256:ebf526c198a14fa138634b9746c50ec38077ec9b3986227e79eb837d26f59dc6\"))\n\n\tos.Setenv(\"DOCKERHUB_PROXY\", \"my-dockerhub-proxy.tld/dockerhub-proxy\")\n\tassert.Equal(t,\n\t\t\"my-dockerhub-proxy.tld/dockerhub-proxy/library/hello-world@sha256:ebf526c198a14fa138634b9746c50ec38077ec9b3986227e79eb837d26f59dc6\",\n\t\tCompleteImageRef(\"library/hello-world@sha256:ebf526c198a14fa138634b9746c50ec38077ec9b3986227e79eb837d26f59dc6\"))\n\tos.Unsetenv(\"DOCKERHUB_PROXY\")\n}", "func (mc *MockContainer) ImagePull() error {\n\treturn mc.MockImagePull()\n}", "func testDownloadImages(ctx context.Context, t *testing.T, downloadCh chan<- downloadRequest, addr, ccvmDir string) {\n\twkld := &workload{\n\t\tspec: workloadSpec{\n\t\t\tBaseImageURL: \"http://\" + addr + \"/download/image\",\n\t\t\tBIOS: \"http://\" + addr + \"/download/bios\",\n\t\t},\n\t}\n\n\tresultCh := make(chan interface{})\n\tgo func() {\n\t\timg, bios, err := downloadImages(ctx, wkld, http.DefaultTransport.(*http.Transport),\n\t\t\tresultCh, downloadCh)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Failed to download images: %v\", err)\n\t\t}\n\t\tif len(img) == 0 || len(bios) == 0 {\n\t\t\tt.Errorf(\"One the paths is empty img=%s bios=%s\", img, bios)\n\t\t}\n\t\tclose(resultCh)\n\t}()\n\n\tfor range resultCh {\n\t}\n\n\twkld.spec.BIOS = \"ftp://\" + addr + \"/download/bios\"\n\tresultCh = make(chan interface{})\n\tgo func() {\n\t\t_, _, err := downloadImages(ctx, wkld, http.DefaultTransport.(*http.Transport),\n\t\t\tresultCh, downloadCh)\n\t\tif err == nil {\n\t\t\tt.Errorf(\"Expected downloadImages with bad BIOS URL to fail\")\n\t\t}\n\t\tclose(resultCh)\n\t}()\n\n\tfor range resultCh {\n\t}\n}", "func (c MockDockerClient) ImagePull(ctx context.Context, imageName string) error {\n\tif c.ImagePullFn != nil {\n\t\tfmt.Println(\"[MockDockerClient] In \", utils.CurrentFunctionName())\n\t\tfmt.Println(\"[MockDockerClient] - ctx: \", ctx)\n\t\tfmt.Println(\"[MockDockerClient] - imageName: \", imageName)\n\t\treturn c.ImagePullFn(ctx, imageName)\n\t}\n\tpanic(fmt.Sprintf(\"No function defined for: %s\", utils.CurrentFunctionName()))\n}", "func TestIsImageInLocalRegistry(t *testing.T) {\n\ttype testDef struct {\n\t\timageName string\n\t\tdocker test.FakeDockerClient\n\t\texpectedResult bool\n\t\texpectedError string\n\t}\n\ttests := map[string]testDef{\n\t\t\"ImageFound\": {\"a_test_image\", test.FakeDockerClient{}, true, \"\"},\n\t\t\"ImageNotFound\": {\"a_test_image:sometag\", test.FakeDockerClient{}, false, \"unable to get metadata for a_test_image:sometag\"},\n\t}\n\n\tfor test, def := range tests {\n\t\tdh := getDocker(&def.docker)\n\t\tfake := dh.kubeDockerClient.(*dockertools.FakeDockerClient)\n\t\tif def.expectedResult {\n\t\t\tfake.Image = &dockertypes.ImageInspect{ID: def.imageName}\n\t\t}\n\n\t\tresult, err := dh.IsImageInLocalRegistry(def.imageName)\n\n\t\tif e := fake.AssertCalls([]string{\"inspect_image\"}); e != nil {\n\t\t\tt.Errorf(\"%+v\", e)\n\t\t}\n\n\t\tif result != def.expectedResult {\n\t\t\tt.Errorf(\"Test - %s: Expected result: %v. Got: %v\", test, def.expectedResult, result)\n\t\t}\n\t\tif err != nil && len(def.expectedError) > 0 && !strings.Contains(err.Error(), def.expectedError) {\n\t\t\tt.Errorf(\"Test - %s: Expected error: Got: %+v\", test, err)\n\t\t}\n\t}\n}", "func (m *MockImageTransferer) Download(arg0 string, arg1 core.Digest) (base.FileReader, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Download\", arg0, arg1)\n\tret0, _ := ret[0].(base.FileReader)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (c *TestClient) GetImage(project, name string) (*compute.Image, error) {\n\tif c.GetImageFn != nil {\n\t\treturn c.GetImageFn(project, name)\n\t}\n\treturn c.client.GetImage(project, name)\n}", "func (m *MockMoby) ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) {\n\tret := m.ctrl.Call(m, \"ImageBuild\", ctx, buildContext, options)\n\tret0, _ := ret[0].(types.ImageBuildResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func TestBaseImage(t *testing.T) {\n\t// test with 'original.png'\n\timgs := map[string][]byte{\n\t\t\"original.png\": []byte(\"image\"),\n\t}\n\t_, err := backend.baseImage(imgs)\n\tif err != nil {\n\t\tt.Errorf(\"Got error %s\", err)\n\t}\n\n\t// test with 'original.jpg'\n\timgs = map[string][]byte{\n\t\t\"original.jpg\": []byte(\"image\"),\n\t}\n\t_, err = backend.baseImage(imgs)\n\tif err != nil {\n\t\tt.Errorf(\"Got error %s\", err)\n\t}\n\n\t// without 'original.*' should get an error\n\timgs = map[string][]byte{\n\t\t\"127x127.png\": []byte(\"image\"),\n\t}\n\t_, err = backend.baseImage(imgs)\n\tif err == nil {\n\t\tt.Errorf(\"Should get an error, didn't pass original image.\")\n\t}\n}", "func (a *AgentServer) PullImage(req PullImageRequest, image *string) error {\n\n\tlogger := plog.WithFields(logrus.Fields{\n\t\t\"image\": req.Image,\n\t\t\"registry\": req.Registry})\n\n\t// set up the connections\n\tdocker, err := docker.NewDockerClient()\n\tif err != nil {\n\t\tlogger.WithError(err).Error(\"Could not connect to docker client\")\n\t\treturn err\n\t}\n\tconn, err := zzk.GetLocalConnection(\"/\")\n\tif err != nil {\n\t\tlogger.WithError(err).Error(\"Could not acquire coordinator connection\")\n\t\treturn err\n\t}\n\n\t// pull the image from the registry\n\treg := registry.NewRegistryListener(docker, req.Registry, \"\")\n\treg.SetConnection(conn)\n\ttimer := time.NewTimer(req.Timeout)\n\tdefer timer.Stop()\n\tif err := reg.PullImage(timer.C, req.Image); err != nil {\n\t\tlogger.WithError(err).Error(\"Could not pull image from registry\")\n\t\treturn err\n\t}\n\n\t// get the tag of the image pulled\n\t*image, err = reg.ImagePath(req.Image)\n\tif err != nil {\n\t\tlogger.WithError(err).Error(\"Could not get image id for image from registry\")\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (m *MockPackClient) InspectImage(arg0 string, arg1 bool) (*client.ImageInfo, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"InspectImage\", arg0, arg1)\n\tret0, _ := ret[0].(*client.ImageInfo)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockSystem) FetchURL(ctx context.Context, url string) (semver.Tags, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"FetchURL\", ctx, url)\n\tret0, _ := ret[0].(semver.Tags)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockDockerClient) ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ImagePull\", ctx, refStr, options)\n\tret0, _ := ret[0].(io.ReadCloser)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func FetchRemoteFile() {\n\n}", "func (m *MockManager) LoadImage(arg0 context.Context, arg1 *config.Config, arg2 dockerapi.DockerClient) (*types.ImageInspect, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"LoadImage\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(*types.ImageInspect)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func GetImage(ctx context.Context, sharedDownload map[string]*DownloadState, params *Params) (io.Reader, error) {\n\tlogger := logging.FromContext(ctx)\n\ttimeout := params.Timeout\n\tURL := params.URL\n\tvar imageReader io.Reader\n\n\tif dnState, ok := sharedDownload[URL]; ok {\n\t\tlogger.WithField(\"url\", URL).Trace(\"is fetching by another client\")\n\t\terrCh := make(chan error, 1)\n\t\tdnState.Subs = append(dnState.Subs, errCh)\n\t\tif err := <-errCh; err != nil {\n\t\t\tlogger.WithError(err).WithField(\"url\", URL).Trace(\"fetch failed\")\n\t\t\tdelete(sharedDownload, URL)\n\t\t\treturn nil, err\n\t\t}\n\t\timageReader = bytes.NewReader(dnState.Data)\n\t\tlogger.WithField(\"url\", URL).Trace(\"fetched shared\")\n\t} else {\n\t\tsubscribers := make([]chan error, 0, 1)\n\t\tdownloadState := &DownloadState{\n\t\t\tData: nil,\n\t\t\tSubs: subscribers,\n\t\t}\n\t\tsharedDownload[URL] = downloadState\n\t\tdefer func(sd map[string]*DownloadState, url string) {\n\t\t\tdelete(sd, url)\n\t\t}(sharedDownload, URL)\n\t\thttpClient := httpclient.NewHTTPClient(timeout)\n\t\tresponse, err := httpClient.Get(ctx, URL)\n\t\tif err != nil {\n\t\t\tlogger.WithError(err).WithField(\"url\", URL).Error(\"fetch image failed\")\n\t\t\tfor _, subs := range downloadState.Subs {\n\t\t\t\tsubs <- err\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\n\t\tdownloadState.Data = response.RawBody\n\t\tfor _, subs := range downloadState.Subs {\n\t\t\tsubs <- nil\n\t\t}\n\t\timageReader = bytes.NewReader(response.RawBody)\n\t}\n\n\treturn imageReader, nil\n}", "func Fetch(imageURI string, labels map[types.ACIdentifier]string, insecure bool) (tempfile.ReadSeekCloser, error) {\n\tu, err := url.Parse(imageURI)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar puller remote.Puller\n\n\tswitch u.Scheme {\n\tcase \"file\":\n\t\tfilename := u.Path\n\t\tif u.Host != \"\" {\n\t\t\tfilename = filepath.Join(u.Host, u.Path)\n\t\t}\n\t\tf, err := os.Open(filename)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn tempfile.New(f)\n\tcase \"http\", \"https\":\n\t\tpuller = http.New()\n\tcase \"docker\":\n\t\tpuller = docker.New(insecure)\n\tcase \"aci\", \"\":\n\t\tpuller = aci.New(insecure, labels)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"%q scheme not supported\", u.Scheme)\n\t}\n\n\tr, err := puller.Pull(imageURI)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn tempfile.New(r)\n}", "func dirImageMock(t *testing.T, dir, dockerReference string) private.UnparsedImage {\n\tref, err := reference.ParseNormalizedNamed(dockerReference)\n\trequire.NoError(t, err)\n\treturn dirImageMockWithRef(t, dir, refImageReferenceMock{ref: ref})\n}", "func (m *MockUpstreamIntf) CachedRemoteDigestOfLocalHeight() blockdigest.Digest {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"CachedRemoteDigestOfLocalHeight\")\n\tret0, _ := ret[0].(blockdigest.Digest)\n\treturn ret0\n}", "func LookupMyImage(connConfig string, myImageId string) (SpiderMyImageInfo, error) {\n\n\tif connConfig == \"\" {\n\t\terr := fmt.Errorf(\"LookupMyImage() called with empty connConfig.\")\n\t\tcommon.CBLog.Error(err)\n\t\treturn SpiderMyImageInfo{}, err\n\t} else if myImageId == \"\" {\n\t\terr := fmt.Errorf(\"LookupMyImage() called with empty myImageId.\")\n\t\tcommon.CBLog.Error(err)\n\t\treturn SpiderMyImageInfo{}, err\n\t}\n\n\turl := common.SpiderRestUrl + \"/myimage/\" + url.QueryEscape(myImageId)\n\n\t// Create Req body\n\ttempReq := common.SpiderConnectionName{}\n\ttempReq.ConnectionName = connConfig\n\n\tclient := resty.New().SetCloseConnection(true)\n\tclient.SetAllowGetMethodPayload(true)\n\n\tresp, err := client.R().\n\t\tSetHeader(\"Content-Type\", \"application/json\").\n\t\tSetBody(tempReq).\n\t\tSetResult(&SpiderMyImageInfo{}). // or SetResult(AuthSuccess{}).\n\t\t//SetError(&AuthError{}). // or SetError(AuthError{}).\n\t\tGet(url)\n\n\tif err != nil {\n\t\tcommon.CBLog.Error(err)\n\t\terr := fmt.Errorf(\"an error occurred while requesting to CB-Spider\")\n\t\treturn SpiderMyImageInfo{}, err\n\t}\n\n\tfmt.Println(string(resp.Body()))\n\n\tfmt.Println(\"HTTP Status code: \" + strconv.Itoa(resp.StatusCode()))\n\tswitch {\n\tcase resp.StatusCode() >= 400 || resp.StatusCode() < 200:\n\t\terr := fmt.Errorf(string(resp.Body()))\n\t\tcommon.CBLog.Error(err)\n\t\treturn SpiderMyImageInfo{}, err\n\t}\n\n\ttemp := resp.Result().(*SpiderMyImageInfo)\n\treturn *temp, nil\n\n}", "func (c *Client) Pull(ctx context.Context, ref string, opts ...RemoteOpt) (_ Image, retErr error) {\n\tpullCtx := defaultRemoteContext()\n\tfor _, o := range opts {\n\t\tif err := o(c, pullCtx); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif pullCtx.PlatformMatcher == nil {\n\t\tif len(pullCtx.Platforms) > 1 {\n\t\t\treturn nil, errors.New(\"cannot pull multiplatform image locally, try Fetch\")\n\t\t} else if len(pullCtx.Platforms) == 0 {\n\t\t\tpullCtx.PlatformMatcher = c.platform\n\t\t} else {\n\t\t\tp, err := platforms.Parse(pullCtx.Platforms[0])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid platform %s: %w\", pullCtx.Platforms[0], err)\n\t\t\t}\n\n\t\t\tpullCtx.PlatformMatcher = platforms.Only(p)\n\t\t}\n\t}\n\n\tctx, done, err := c.WithLease(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer done(ctx)\n\n\tvar unpacks int32\n\tvar unpackEg *errgroup.Group\n\tvar unpackWrapper func(f images.Handler) images.Handler\n\n\tif pullCtx.Unpack {\n\t\t// unpacker only supports schema 2 image, for schema 1 this is noop.\n\t\tu, err := c.newUnpacker(ctx, pullCtx)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"create unpacker: %w\", err)\n\t\t}\n\t\tunpackWrapper, unpackEg = u.handlerWrapper(ctx, pullCtx, &unpacks)\n\t\tdefer func() {\n\t\t\tif err := unpackEg.Wait(); err != nil {\n\t\t\t\tif retErr == nil {\n\t\t\t\t\tretErr = fmt.Errorf(\"unpack: %w\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}()\n\t\twrapper := pullCtx.HandlerWrapper\n\t\tpullCtx.HandlerWrapper = func(h images.Handler) images.Handler {\n\t\t\tif wrapper == nil {\n\t\t\t\treturn unpackWrapper(h)\n\t\t\t}\n\t\t\treturn unpackWrapper(wrapper(h))\n\t\t}\n\t}\n\n\timg, err := c.fetch(ctx, pullCtx, ref, 1)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// NOTE(fuweid): unpacker defers blobs download. before create image\n\t// record in ImageService, should wait for unpacking(including blobs\n\t// download).\n\tif pullCtx.Unpack {\n\t\tif unpackEg != nil {\n\t\t\tif err := unpackEg.Wait(); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\n\timg, err = c.createNewImage(ctx, img)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ti := NewImageWithPlatform(c, img, pullCtx.PlatformMatcher)\n\n\tif pullCtx.Unpack {\n\t\tif unpacks == 0 {\n\t\t\t// Try to unpack is none is done previously.\n\t\t\t// This is at least required for schema 1 image.\n\t\t\tif err := i.Unpack(ctx, pullCtx.Snapshotter, pullCtx.UnpackOpts...); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to unpack image on snapshotter %s: %w\", pullCtx.Snapshotter, err)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn i, nil\n}", "func (m *MockHandler) GetReleaseImage(arg0, arg1 string) (*models.ReleaseImage, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetReleaseImage\", arg0, arg1)\n\tret0, _ := ret[0].(*models.ReleaseImage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockHandler) GetMustGatherImages(arg0, arg1, arg2 string) (MustGatherVersion, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetMustGatherImages\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(MustGatherVersion)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockImageTransferer) Stat(arg0 string, arg1 core.Digest) (*core.BlobInfo, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Stat\", arg0, arg1)\n\tret0, _ := ret[0].(*core.BlobInfo)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockEnvironment) Fetch() map[string]interface{} {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Fetch\")\n\tret0, _ := ret[0].(map[string]interface{})\n\treturn ret0\n}", "func (p *Pvr) LoadRemoteImage(app *AppData) error {\n\n\tvar dockerManifest *schema2.Manifest\n\n\tapp.RemoteImage = DockerImage{\n\t\tExists: false,\n\t}\n\timage, err := registry.ParseImage(app.From)\n\tif err != nil {\n\t\treturn err\n\t}\n\tauth, err := p.AuthConfig(app.Username, app.Password, image.Domain)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdockerRegistry, err := p.GetDockerRegistry(image, auth)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar repoDigest string\n\tvar dockerPlatform string\n\tvar platforms []interface{}\n\n\tif app.Platform == \"\" {\n\t\tdockerJsonI, ok := p.PristineJsonMap[\"_hostconfig/pvr/docker.json\"]\n\n\t\tif ok {\n\t\t\tdockerJson := dockerJsonI.(map[string]interface{})\n\t\t\tplatformsI, ok := dockerJson[\"platforms\"]\n\t\t\tif ok {\n\t\t\t\tplatforms = platformsI.([]interface{})\n\t\t\t}\n\t\t}\n\t} else {\n\t\tplatforms = append(platforms, app.Platform)\n\t}\n\n\t// we go down the multiarch path if we have seen a platform\n\t// restriction in pvr-docker.json\n\tif platforms != nil {\n\t\tmanifestList, err := dockerRegistry.ManifestList(context.Background(),\n\t\t\timage.Path, image.Reference())\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfor _, v := range manifestList.Manifests {\n\t\t\tfor _, v1 := range platforms {\n\t\t\t\tv1S := v1.(string)\n\t\t\t\tp := strings.SplitN(v1S, \"/\", 3)\n\t\t\t\tif v.Platform.Architecture == p[1] &&\n\t\t\t\t\t(len(p) < 3 || p[2] == v.Platform.Variant) {\n\t\t\t\t\trepoDigest = v.Digest.String()\n\t\t\t\t\tdockerPlatform = v1S\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif repoDigest != \"\" {\n\t\t\t\tdm, err := dockerRegistry.ManifestV2(context.Background(), image.Path, repoDigest)\n\t\t\t\tdockerManifest = &dm\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(os.Stderr, \"Found Manifest for platform %s\\n\",\n\t\t\t\t\tdockerPlatform)\n\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tdockerPlatform = \"\"\n\t\t\t}\n\t\t}\n\t}\n\n\tif dockerManifest == nil {\n\t\tdockerManifest, err = p.GetDockerManifest(image, auth)\n\t\tif err != nil {\n\t\t\tmanifestErr := ReportDockerManifestError(err, app.From)\n\t\t\tif err.Error() == \"image not found or you do not have access\" {\n\t\t\t\tfmt.Fprintf(os.Stderr, manifestErr.Error()+\"\\n\")\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn manifestErr\n\t\t}\n\t\tfmt.Fprintf(os.Stderr, \"Found Manifest for default platform.\\n\")\n\t}\n\n\tdockerConfig, err := p.GetDockerConfig(dockerManifest, image, auth)\n\tif err != nil {\n\t\terr = ReportDockerManifestError(err, app.From)\n\t\treturn err\n\t}\n\n\t// if we cannot find our arch we go the old direct way of retrieving repo\n\tif repoDigest == \"\" && app.RemoteImage.DockerPlatform != \"\" {\n\t\treturn errors.New(\"no docker image found for platform \" + app.RemoteImage.DockerPlatform)\n\t} else if repoDigest == \"\" {\n\t\trepoDigest, err = p.GetDockerImageRepoDigest(image, auth)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tli := strings.LastIndex(app.From, \":\")\n\tvar imageName string\n\tif li < 0 {\n\t\timageName = app.From\n\t} else {\n\t\tsplits := []string{app.From[:li], app.From[li+1:]}\n\t\timageName = splits[0]\n\t}\n\n\t//Extract image name from repo digest. eg: Extract \"busybox\" from \"busybox@sha256:afe605d272837ce1732f390966166c2afff5391208ddd57de10942748694049d\"\n\tif strings.Contains(imageName, \"@sha256\") {\n\t\tsplits := strings.Split(imageName, \"@\")\n\t\timageName = splits[0]\n\t}\n\n\tif !strings.Contains(repoDigest, \"@\") {\n\t\trepoDigest = imageName + \"@\" + repoDigest\n\t}\n\n\tapp.Username = auth.Username\n\tapp.Password = auth.Password\n\n\tapp.RemoteImage.Exists = true\n\tapp.RemoteImage.DockerDigest = repoDigest\n\tapp.RemoteImage.DockerConfig = dockerConfig\n\tapp.RemoteImage.DockerManifest = dockerManifest\n\tapp.RemoteImage.DockerRegistry = dockerRegistry\n\tapp.RemoteImage.DockerPlatform = dockerPlatform\n\tapp.RemoteImage.ImagePath = image.Path\n\n\treturn nil\n}", "func (suite *APIImageInspectSuite) TestImageInspectOk(c *check.C) {\n\tvar (\n\t\trepo = environment.BusyboxRepo\n\t\ttag = \"1.24\"\n\n\t\tid = \"sha256:ca3d7d608b8a8bbaaac2c350bd0f9588cce0509ada74108d5c4b2afb24c46125\"\n\t\tdig = \"sha256:840f2b98a2540ff1d265782c42543dbec7218d3ab0e73b296d7dac846f146e27\"\n\t)\n\n\trepoTag := fmt.Sprintf(\"%s:%s\", repo, tag)\n\trepoDigest := fmt.Sprintf(\"%s@%s\", repo, dig)\n\n\tfor _, image := range []string{\n\t\tid,\n\t\trepoTag,\n\t\trepoDigest,\n\t\tfmt.Sprintf(\"%s:whatever@%s\", repo, dig),\n\t} {\n\t\tresp, err := request.Get(\"/images/\" + image + \"/json\")\n\t\tc.Assert(err, check.IsNil)\n\t\tCheckRespStatus(c, resp, 200)\n\n\t\tgot := types.ImageInfo{}\n\t\terr = request.DecodeBody(&got, resp.Body)\n\t\tc.Assert(err, check.IsNil)\n\n\t\t// TODO: More specific check is needed\n\t\tc.Assert(got.Config, check.NotNil)\n\t\tc.Assert(got.ID, check.Equals, id)\n\t\tc.Assert(got.CreatedAt, check.NotNil)\n\t\tc.Assert(got.Size, check.NotNil)\n\t\tc.Assert(reflect.DeepEqual(got.RepoTags, []string{repoTag}), check.Equals, true)\n\t\tc.Assert(reflect.DeepEqual(got.RepoDigests, []string{repoDigest}), check.Equals, true)\n\t}\n}", "func MockOnGetManagerVirtualMedia(ctx context.Context, mockAPI *redfishMocks.RedfishAPI,\n\tmanagerID string, virtualMediaID string, virtualMedia redfishClient.VirtualMedia,\n\thttpResponse *http.Response, err error) {\n\tmediaRequest := redfishClient.ApiGetManagerVirtualMediaRequest{}\n\tmockAPI.On(\"GetManagerVirtualMedia\", ctx, managerID, virtualMediaID).Return(mediaRequest).Times(1)\n\tmockAPI.On(\"GetManagerVirtualMediaExecute\", mock.Anything).Return(virtualMedia, httpResponse, err).Times(1)\n}", "func (m *MockUserServer) GetRoleImage(arg0 context.Context, arg1 *pb.RoleRequest) (*pb.TextReply, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetRoleImage\", arg0, arg1)\n\tret0, _ := ret[0].(*pb.TextReply)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockUserClient) GetRoleImage(ctx context.Context, in *pb.RoleRequest, opts ...grpc.CallOption) (*pb.TextReply, error) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{ctx, in}\n\tfor _, a := range opts {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"GetRoleImage\", varargs...)\n\tret0, _ := ret[0].(*pb.TextReply)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func TestCannotExecuteStatusImage(t *testing.T) {\n\tbuf := setLogBuffer()\n\tdefer func() {\n\t\tif t.Failed() {\n\t\t\tt.Log(buf.String())\n\t\t}\n\t}()\n\n\tif StatusImage == \"\" {\n\t\tt.Skip(\"no status image defined\")\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\tdefer cancel()\n\n\tapp := &models.App{Name: id.New().String()}\n\tapp = ensureApp(t, app)\n\n\tfn := &models.Fn{\n\t\tAppID: app.ID,\n\t\tName: id.New().String(),\n\t\tImage: StatusImage,\n\t\tResourceConfig: models.ResourceConfig{\n\t\t\tMemory: memory,\n\t\t},\n\t}\n\tfn = ensureFn(t, fn)\n\n\tlb, err := LB()\n\tif err != nil {\n\t\tt.Fatalf(\"Got unexpected error: %v\", err)\n\t}\n\tu := url.URL{\n\t\tScheme: \"http\",\n\t\tHost: lb,\n\t}\n\tu.Path = path.Join(u.Path, \"invoke\", fn.ID)\n\n\tcontent := bytes.NewBuffer([]byte(`status`))\n\toutput := &bytes.Buffer{}\n\n\tresp, err := callFN(ctx, u.String(), content, output, models.TypeSync)\n\tif err != nil {\n\t\tt.Fatalf(\"Got unexpected error: %v\", err)\n\t}\n\n\tif resp.StatusCode != http.StatusBadRequest {\n\t\tt.Fatalf(\"StatusCode check failed on %v\", resp.StatusCode)\n\t}\n}", "func (imp *Importer) fetchImages() {\n err := downloadImages(\n imp.idPath,\n func(id string, bodyRdr io.Reader) error {\n img, err := jpeg.Decode(bodyRdr)\n if err == nil {\n imp.send(&imagedata.ImageData{Id: id, Data: &img})\n } else {\n log.Printf(\"Error decoding image %s to jpeg\\n\", id)\n }\n return nil\n },\n )\n\n if err != nil { imp.sendErr(err) }\n}", "func (f *SourceFetcher) Fetch(url string, namespace string) (*info.ImageProperties, bool, error) {\n\tc := make(chan FetchResult)\n\tgo f.uniqueFetchSource(c, url, namespace)\n\tr := <-c\n\treturn r.ImageDetails, r.Downloaded, r.Error\n}", "func (c *dockerClientMock) DownloadImageContent(imageSource, filePath string) (v1.Image, error) {\n\treturn &fake.FakeImage{}, nil // fmt.Errorf(\"%s\", filePath)\n}", "func (m *MockPexeler) GetRandomImage(arg0 string) (int, []byte, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetRandomImage\", arg0)\n\tret0, _ := ret[0].(int)\n\tret1, _ := ret[1].([]byte)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "func picturesMock(w http.ResponseWriter, r *http.Request) {\n\tjson := `{\"copyright\":\"Amir H. Abolfath\",\"date\":\"2019-12-06\",\"explanation\":\"This frame.\",\"hdurl\":\"https://apod.nasa.gov/apod/image/1912/TaurusAbolfath.jpg\",\"media_type\":\"image\",\"service_version\":\"v1\",\"title\":\"Pleiades to Hyades\",\"url\":\"https://apod.nasa.gov/apod/image/1912/TaurusAbolfath1024.jpg\"}`\n\tw.WriteHeader(200)\n\t_, _ = w.Write([]byte(json))\n}", "func ttrPullImage(ctx context.Context, client apiclient.APIClient, image string) error {\n\trc, err := client.ImagePull(ctx, ttrImageName(image), types.ImagePullOptions{RegistryAuth: \"{}\"})\n\tif err != nil {\n\t\treturn err\n\t}\n\tif rc != nil {\n\t\tbody, err := readAllAndClose(rc)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !strings.Contains(body, \"Status: Downloaded newer image\") {\n\t\t\treturn errors.New(\"image pull not successful\")\n\t\t}\n\t}\n\treturn nil\n}", "func (m *MockManager) GetLoadedImageName() string {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetLoadedImageName\")\n\tret0, _ := ret[0].(string)\n\treturn ret0\n}", "func pull(ctx context.Context, imgCache *cache.Handle, directTo, pullFrom string, noHTTPS bool) (imagePath string, err error) {\n\tshubURI, err := ParseReference(pullFrom)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to parse shub uri: %s\", err)\n\t}\n\n\t// Get the image manifest\n\tmanifest, err := GetManifest(shubURI, noHTTPS)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get manifest for: %s: %s\", pullFrom, err)\n\t}\n\n\tif directTo != \"\" {\n\t\tsylog.Infof(\"Downloading shub image\")\n\t\tif err := DownloadImage(ctx, manifest, directTo, pullFrom, true, noHTTPS); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\timagePath = directTo\n\t} else {\n\t\tcacheEntry, err := imgCache.GetEntry(cache.ShubCacheType, manifest.Commit)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"unable to check if %v exists in cache: %v\", manifest.Commit, err)\n\t\t}\n\t\tdefer cacheEntry.CleanTmp()\n\t\tif !cacheEntry.Exists {\n\t\t\tsylog.Infof(\"Downloading shub image\")\n\n\t\t\terr := DownloadImage(ctx, manifest, cacheEntry.TmpPath, pullFrom, true, noHTTPS)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\terr = cacheEntry.Finalize()\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\timagePath = cacheEntry.Path\n\t\t} else {\n\t\t\tsylog.Infof(\"Use cached image\")\n\t\t\timagePath = cacheEntry.Path\n\t\t}\n\n\t}\n\n\treturn imagePath, nil\n}", "func (m *MockGetRandomPexeler) GetRandomImage(arg0 string) ([]byte, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetRandomImage\", arg0)\n\tret0, _ := ret[0].([]byte)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func PrepareBaseImage(ctx context.Context, ref string, output io.Writer) (err error) {\n\n\tcli, err := client.NewEnvClient()\n\tif err != nil {\n\t\treturn\n\t}\n\n\treader, err := cli.ImagePull(ctx, ref, types.ImagePullOptions{})\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer reader.Close()\n\n\tvar log pullLog\n\tstatus := make(map[string]string)\n\tscanner := bufio.NewScanner(reader)\n\tfor scanner.Scan() {\n\t\tjson.Unmarshal(scanner.Bytes(), &log)\n\t\tif log.ID != \"\" {\n\t\t\tcur := status[log.ID]\n\t\t\tif cur != log.Status {\n\t\t\t\tstatus[log.ID] = log.Status\n\t\t\t\tfmt.Fprintln(output, log.Status, log.ID)\n\t\t\t}\n\t\t} else {\n\t\t\tfmt.Fprintln(output, log.Status)\n\t\t}\n\t}\n\n\treturn\n\n}", "func (v *Virt) ImageRemoteDigest(ctx context.Context, image string) (digest string, err error) {\n\treturn\n}", "func (m *MockInterface) AROOperatorImage() string {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"AROOperatorImage\")\n\tret0, _ := ret[0].(string)\n\treturn ret0\n}", "func (m *MockEcrClient) ImageListable(arg0, arg1, arg2, arg3 string) (bool, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ImageListable\", arg0, arg1, arg2, arg3)\n\tret0, _ := ret[0].(bool)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func ttrPushImageAsserting(ctx context.Context, t *testing.T, client apiclient.APIClient, image string) {\n\trc, err := client.ImagePush(ctx, ttrImageName(image), types.ImagePushOptions{RegistryAuth: \"{}\"})\n\tassert.Assert(t, err)\n\tif rc != nil {\n\t\tbody, err := readAllAndClose(rc)\n\t\tassert.Assert(t, err)\n\t\tassert.Assert(t, strings.Contains(body, `\"status\":\"latest: digest: `))\n\t}\n}", "func (v *Virt) ImagePull(ctx context.Context, ref string, all bool) (rc io.ReadCloser, err error) {\n\treturn\n}", "func _getMock(url string) (content []byte, err error) {\n\tvar idnum = crc32.ChecksumIEEE([]byte(url))%uint32(5) + 1\n\tvar response = fmt.Sprintf(mockResponseTemplate, idnum, idnum, \"no message\", 200)\n\treturn []byte(response), nil\n}", "func (m *MockSession) Remote() *iface.RemoteInfo {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Remote\")\n\tret0, _ := ret[0].(*iface.RemoteInfo)\n\treturn ret0\n}", "func (f FetchStruct) FetchFromRemote() *model.FetchResult {\n\trepo := f.Repo\n\tremoteURL := f.RemoteURL\n\tremoteBranch := f.RemoteBranch\n\trepoPath := f.RepoPath\n\n\tvar remoteDataObject RemoteDataInterface\n\tremoteDataObject = RemoteDataStruct{\n\t\tRepo: repo,\n\t\tRemoteURL: remoteURL,\n\t}\n\n\tremoteName := remoteDataObject.GetRemoteName()\n\tlogger := global.Logger{}\n\n\ttargetRefPsec := \"refs/heads/\" + remoteBranch + \":refs/remotes/\" + remoteBranch\n\tb := new(bytes.Buffer)\n\tvar fetchErr error\n\tgitSSHAuth, sshErr := ssh.NewSSHAgentAuth(\"git\")\n\tw, _ := repo.Worktree()\n\n\t// Check if repo path is empty and fetch path from worktree\n\tif repoPath == \"\" {\n\t\trepoPath = w.Filesystem.Root()\n\t}\n\n\tif sshErr != nil {\n\t\tlogger.Log(\"Authentication method failed -> \"+sshErr.Error(), global.StatusError)\n\t\tif w == nil {\n\t\t\treturn &model.FetchResult{\n\t\t\t\tStatus: global.FetchFromRemoteError,\n\t\t\t\tFetchedItems: nil,\n\t\t\t}\n\t\t}\n\t\tlogger.Log(\"Retrying fetch with fallback module using git client\", global.StatusWarning)\n\t\treturn f.windowsFetch()\n\t}\n\n\tlogger.Log(fmt.Sprintf(\"Fetching changes from -> %s : %s\", remoteURL, targetRefPsec), global.StatusInfo)\n\n\tif remoteURL != \"\" && remoteBranch != \"\" {\n\t\tif remoteName == \"\" {\n\t\t\treturn &model.FetchResult{\n\t\t\t\tStatus: global.FetchFromRemoteError,\n\t\t\t\tFetchedItems: nil,\n\t\t\t}\n\t\t}\n\n\t\tfetchErr = repo.Fetch(&git.FetchOptions{\n\t\t\tRemoteName: remoteName,\n\t\t\tAuth: gitSSHAuth,\n\t\t\tRefSpecs: []config.RefSpec{config.RefSpec(targetRefPsec)},\n\t\t\tProgress: sideband.Progress(func(f io.Writer) io.Writer {\n\t\t\t\treturn f\n\t\t\t}(b)),\n\t\t})\n\t} else {\n\t\tfetchErr = repo.Fetch(&git.FetchOptions{\n\t\t\tRemoteName: git.DefaultRemoteName,\n\t\t\tAuth: gitSSHAuth,\n\t\t\tProgress: sideband.Progress(func(f io.Writer) io.Writer {\n\t\t\t\treturn f\n\t\t\t}(b)),\n\t\t})\n\t}\n\n\tif fetchErr != nil {\n\t\tif fetchErr.Error() == \"already up-to-date\" {\n\t\t\tlogger.Log(fetchErr.Error(), global.StatusWarning)\n\t\t\treturn &model.FetchResult{\n\t\t\t\tStatus: global.FetchNoNewChanges,\n\t\t\t\tFetchedItems: nil,\n\t\t\t}\n\t\t} else {\n\t\t\tlogger.Log(fetchErr.Error(), global.StatusError)\n\t\t\tlogger.Log(\"Fetch failed. Retrying fetch with git client\", global.StatusWarning)\n\t\t\treturn f.windowsFetch()\n\t\t}\n\n\t} else {\n\t\tlogger.Log(b.String(), global.StatusInfo)\n\t\tlogger.Log(\"Changes fetched from remote\", global.StatusInfo)\n\n\t\tmsg := fmt.Sprintf(\"Changes fetched from remote %v\", remoteName)\n\t\treturn &model.FetchResult{\n\t\t\tStatus: global.FetchFromRemoteSuccess,\n\t\t\tFetchedItems: []*string{&msg},\n\t\t}\n\t}\n\n}", "func (m *MockRepository) Fetch(bucketName, name string, model db.Model) (bool, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Fetch\", bucketName, name, model)\n\tret0, _ := ret[0].(bool)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (_m *MockECRAPI) ListImages(_param0 *ecr.ListImagesInput) (*ecr.ListImagesOutput, error) {\n\tret := _m.ctrl.Call(_m, \"ListImages\", _param0)\n\tret0, _ := ret[0].(*ecr.ListImagesOutput)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockFetcher) Fetch(req utils.Request) (responseBody []byte, err error) {\n\targs := m.Called(req)\n\n\tif args.Get(0) != nil {\n\t\tresponseBody = args.Get(0).([]byte)\n\t}\n\n\terr = args.Error(1)\n\n\treturn responseBody, err\n}", "func (_m *MockECRAPI) BatchGetImage(_param0 *ecr.BatchGetImageInput) (*ecr.BatchGetImageOutput, error) {\n\tret := _m.ctrl.Call(_m, \"BatchGetImage\", _param0)\n\tret0, _ := ret[0].(*ecr.BatchGetImageOutput)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockHandler) GetProfileAvatar(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"GetProfileAvatar\", arg0, arg1)\n}", "func (a *UserServiceApiService) GetAvatarsExecute(r ApiGetAvatarsRequest) (*os.File, *_nethttp.Response, GenericOpenAPIError) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\texecutionError GenericOpenAPIError\n\t\tlocalVarReturnValue *os.File\n\t)\n\n\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \"UserServiceApiService.GetAvatars\")\n\tif err != nil {\n\t\texecutionError.error = err.Error()\n\t\treturn localVarReturnValue, nil, executionError\n\t}\n\n\tlocalVarPath := localBasePath + \"/users/{username}/avatars\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"username\"+\"}\", _neturl.PathEscape(parameterToString(r.username, \"\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\treq, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\texecutionError.error = err.Error()\n\t\treturn localVarReturnValue, nil, executionError\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(req)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\texecutionError.error = err.Error()\n\t\treturn localVarReturnValue, localVarHTTPResponse, executionError\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tlocalVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody))\n\tif err != nil {\n\t\texecutionError.error = err.Error()\n\t\treturn localVarReturnValue, localVarHTTPResponse, executionError\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\tif err != nil {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: err.Error(),\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHTTPResponse, executionError\n}", "func (m *MockLoggingClient) Fetch(arg0 context.Context, arg1 *logging.QueryRequest, arg2 ...grpc.CallOption) (*logging.QueryResponse, error) {\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"Fetch\", varargs...)\n\tret0, _ := ret[0].(*logging.QueryResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockClient) Fetch(keyword string) (*[]linebot.Response, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Fetch\", keyword)\n\tret0, _ := ret[0].(*[]linebot.Response)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (f *FakeImagesClient) Get(ctx context.Context, getOpts *images.GetRequest, opts ...grpc.CallOption) (*images.GetResponse, error) {\n\tf.Lock()\n\tdefer f.Unlock()\n\tf.appendCalled(\"get\", getOpts)\n\tif err := f.getError(\"get\"); err != nil {\n\t\treturn nil, err\n\t}\n\timage, ok := f.ImageList[getOpts.Name]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"image does not exist\")\n\t}\n\treturn &images.GetResponse{\n\t\tImage: &image,\n\t}, nil\n}", "func PullImage(c *check.C, image string) {\n\tresp, err := request.Get(\"/images/\" + image + \"/json\")\n\tc.Assert(err, check.IsNil)\n\n\tif resp.StatusCode == http.StatusOK {\n\t\tresp.Body.Close()\n\t\treturn\n\t}\n\n\tq := url.Values{}\n\tq.Add(\"fromImage\", image)\n\tresp, err = request.Post(\"/images/create\", request.WithQuery(q))\n\tc.Assert(err, check.IsNil)\n\tc.Assert(resp.StatusCode, check.Equals, 200)\n\n\tdefer resp.Body.Close()\n\tc.Assert(fetchPullStatus(resp.Body), check.IsNil)\n}", "func (a *ImagesApiService) GetImageExecute(r ApiGetImageRequest) ([]AnchoreImage, *http.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = http.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tformFiles []formFile\n\t\tlocalVarReturnValue []AnchoreImage\n\t)\n\n\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \"ImagesApiService.GetImage\")\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/images/{imageDigest}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"imageDigest\"+\"}\", url.PathEscape(parameterToString(r.imageDigest, \"\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\tif r.xAnchoreAccount != nil {\n\t\tlocalVarHeaderParams[\"x-anchore-account\"] = parameterToString(*r.xAnchoreAccount, \"\")\n\t}\n\treq, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(req)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tlocalVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := &GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 500 {\n\t\t\tvar v ApiErrorResponse\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\tif err != nil {\n\t\tnewErr := &GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: err.Error(),\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHTTPResponse, nil\n}", "func (m *MockUpstreamIntf) CachedRemoteHeight() uint64 {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"CachedRemoteHeight\")\n\tret0, _ := ret[0].(uint64)\n\treturn ret0\n}", "func GetImg(fileName string) (*image.Image, error) {\n localFile := fmt.Sprintf(\"/data/edgebox/local/%s\", fileName)\n existingImageFile, err := os.Open(localFile)\n if err == nil {\n defer existingImageFile.Close()\n imageData, _, err := image.Decode(existingImageFile)\n if err != nil {\n return nil, err\n }\n return &imageData, nil\n }\n\n remoteFile := fmt.Sprintf(\"/data/edgebox/remote/%s\", fileName)\n existingImageFile, err = os.Open(remoteFile)\n if err == nil {\n defer existingImageFile.Close()\n imageData, _, err := image.Decode(existingImageFile)\n if err != nil {\n return nil, err\n }\n return &imageData, nil\n }\n return nil, err\n}", "func (a *ImageApiService) GetPersonImage(ctx _context.Context, name string, imageType ImageType, imageIndex int32, localVarOptionals *GetPersonImageOpts) (*os.File, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = _nethttp.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue *os.File\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/Persons/{name}/Images/{imageType}/{imageIndex}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"name\"+\"}\", _neturl.QueryEscape(parameterToString(name, \"\")) , -1)\n\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"imageType\"+\"}\", _neturl.QueryEscape(parameterToString(imageType, \"\")) , -1)\n\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"imageIndex\"+\"}\", _neturl.QueryEscape(parameterToString(imageIndex, \"\")) , -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\tif localVarOptionals != nil && localVarOptionals.Tag.IsSet() {\n\t\tlocalVarQueryParams.Add(\"tag\", parameterToString(localVarOptionals.Tag.Value(), \"\"))\n\t}\n\tif localVarOptionals != nil && localVarOptionals.Format.IsSet() {\n\t\tlocalVarQueryParams.Add(\"format\", parameterToString(localVarOptionals.Format.Value(), \"\"))\n\t}\n\tif localVarOptionals != nil && localVarOptionals.MaxWidth.IsSet() {\n\t\tlocalVarQueryParams.Add(\"maxWidth\", parameterToString(localVarOptionals.MaxWidth.Value(), \"\"))\n\t}\n\tif localVarOptionals != nil && localVarOptionals.MaxHeight.IsSet() {\n\t\tlocalVarQueryParams.Add(\"maxHeight\", parameterToString(localVarOptionals.MaxHeight.Value(), \"\"))\n\t}\n\tif localVarOptionals != nil && localVarOptionals.PercentPlayed.IsSet() {\n\t\tlocalVarQueryParams.Add(\"percentPlayed\", parameterToString(localVarOptionals.PercentPlayed.Value(), \"\"))\n\t}\n\tif localVarOptionals != nil && localVarOptionals.UnplayedCount.IsSet() {\n\t\tlocalVarQueryParams.Add(\"unplayedCount\", parameterToString(localVarOptionals.UnplayedCount.Value(), \"\"))\n\t}\n\tif localVarOptionals != nil && localVarOptionals.Width.IsSet() {\n\t\tlocalVarQueryParams.Add(\"width\", parameterToString(localVarOptionals.Width.Value(), \"\"))\n\t}\n\tif localVarOptionals != nil && localVarOptionals.Height.IsSet() {\n\t\tlocalVarQueryParams.Add(\"height\", parameterToString(localVarOptionals.Height.Value(), \"\"))\n\t}\n\tif localVarOptionals != nil && localVarOptionals.Quality.IsSet() {\n\t\tlocalVarQueryParams.Add(\"quality\", parameterToString(localVarOptionals.Quality.Value(), \"\"))\n\t}\n\tif localVarOptionals != nil && localVarOptionals.CropWhitespace.IsSet() {\n\t\tlocalVarQueryParams.Add(\"cropWhitespace\", parameterToString(localVarOptionals.CropWhitespace.Value(), \"\"))\n\t}\n\tif localVarOptionals != nil && localVarOptionals.AddPlayedIndicator.IsSet() {\n\t\tlocalVarQueryParams.Add(\"addPlayedIndicator\", parameterToString(localVarOptionals.AddPlayedIndicator.Value(), \"\"))\n\t}\n\tif localVarOptionals != nil && localVarOptionals.Blur.IsSet() {\n\t\tlocalVarQueryParams.Add(\"blur\", parameterToString(localVarOptionals.Blur.Value(), \"\"))\n\t}\n\tif localVarOptionals != nil && localVarOptionals.BackgroundColor.IsSet() {\n\t\tlocalVarQueryParams.Add(\"backgroundColor\", parameterToString(localVarOptionals.BackgroundColor.Value(), \"\"))\n\t}\n\tif localVarOptionals != nil && localVarOptionals.ForegroundLayer.IsSet() {\n\t\tlocalVarQueryParams.Add(\"foregroundLayer\", parameterToString(localVarOptionals.ForegroundLayer.Value(), \"\"))\n\t}\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{\"image/_*\", \"application/json\", \"application/json; profile=CamelCase\", \"application/json; profile=PascalCase\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\tif ctx != nil {\n\t\t// API Key Authentication\n\t\tif auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {\n\t\t\tvar key string\n\t\t\tif auth.Prefix != \"\" {\n\t\t\t\tkey = auth.Prefix + \" \" + auth.Key\n\t\t\t} else {\n\t\t\t\tkey = auth.Key\n\t\t\t}\n\t\t\tlocalVarHeaderParams[\"X-Emby-Authorization\"] = key\n\t\t}\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 404 {\n\t\t\tvar v ProblemDetails\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\tif err != nil {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: err.Error(),\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHTTPResponse, nil\n}", "func TestRemoteFactory_CreateForDockerHub(t *testing.T) {\n\t// No credentials required for public Image\n\tfact := NewRemoteClientFactory(Credentials{}, log.NewNopLogger(), nil, time.Second)\n\timg, err := flux.ParseImage(\"alpine:latest\", nil)\n\ttestRepository = RepositoryFromImage(img)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tr, err := fact.CreateFor(testRepository.Host())\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tres, err := r.Manifest(testRepository, img.Tag)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\texpected := \"index.docker.io/library/alpine:latest\"\n\tif res.FullID() != expected {\n\t\tt.Fatal(\"Expected %q. Got %q\", expected, res.FullID())\n\t}\n}", "func (c MockDockerClient) ImageInspect(ctx context.Context, imageName string) (dockertypes.ImageInspect, error) {\n\tif c.ImageInspectFn != nil {\n\t\tfmt.Println(\"[MockDockerClient] In \", utils.CurrentFunctionName())\n\t\tfmt.Println(\"[MockDockerClient] - ctx: \", ctx)\n\t\tfmt.Println(\"[MockDockerClient] - imageName: \", imageName)\n\t\treturn c.ImageInspectFn(ctx, imageName)\n\t}\n\tpanic(fmt.Sprintf(\"No function defined for: %s\", utils.CurrentFunctionName()))\n}", "func (cli *FakeDatabaseClient) FetchServiceImageMetaData(ctx context.Context, in *dbdpb.FetchServiceImageMetaDataRequest, opts ...grpc.CallOption) (*dbdpb.FetchServiceImageMetaDataResponse, error) {\n\tatomic.AddInt32(&cli.fetchServiceImageMetaDataCnt, 1)\n\tif cli.methodToResp == nil {\n\t\treturn nil, nil\n\t}\n\tmethod := \"FetchServiceImageMetaData\"\n\tif resp, ok := cli.methodToResp[method]; ok {\n\t\treturn resp.(*dbdpb.FetchServiceImageMetaDataResponse), nil\n\t}\n\treturn nil, nil\n\n}", "func getImages(hostBase string, organization string, application string) (*http.Response, []*server.Image, error) {\n\n\turl := getImagesURL(hostBase, organization, application)\n\n\tkiln.LogInfo.Printf(\"Invoking get at URL %s\", url)\n\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\treq.Header.Add(\"Accept\", \"application/json\")\n\treq.Header.Set(\"Authorization\", fmt.Sprintf(\"Bearer %s\", \"e30K.e30K.e30K\"))\n\tclient := &http.Client{}\n\tresponse, err := client.Do(req)\n\n\timages := []*server.Image{}\n\n\tbytes, err := ioutil.ReadAll(response.Body)\n\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tbody := string(bytes)\n\n\tkiln.LogInfo.Printf(\"Response is %s\", body)\n\n\tjson.Unmarshal(bytes, &images)\n\n\treturn response, images, err\n\n}", "func pullMissingImage(ctx context.Context, apiClient client.CommonAPIClient, image string, force bool) error {\n\tif !force {\n\t\t_, inspectError := apiClient.ImageInspect(ctx, image)\n\t\tif inspectError == nil {\n\t\t\treturn nil\n\t\t}\n\t\tif err, ok := inspectError.(client.RespError); !ok {\n\t\t\treturn inspectError\n\t\t} else if err.Code() != http.StatusNotFound {\n\t\t\treturn inspectError\n\t\t}\n\t}\n\n\tnamedRef, err := reference.Parse(image)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tnamedRef = reference.TrimTagForDigest(reference.WithDefaultTagIfMissing(namedRef))\n\n\tvar name, tag string\n\tif reference.IsNameTagged(namedRef) {\n\t\tname, tag = namedRef.Name(), namedRef.(reference.Tagged).Tag()\n\t} else {\n\t\tname = namedRef.String()\n\t}\n\n\tresponseBody, err := apiClient.ImagePull(ctx, name, tag, fetchRegistryAuth(namedRef.Name()))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to pull image: %v\", err)\n\t}\n\tdefer responseBody.Close()\n\n\treturn showProgress(responseBody)\n}", "func (s *Client) Image(fileID string, page int) (file []byte, err error) {\n\tif page <= 0 {\n\t\tpage = 1\n\t}\n\tqueryParam := fmt.Sprintf(\"?page=%d\", page)\n\turl := strings.Join([]string{s.config.apiBaseURL, \"/result/image/\", fileID, queryParam}, \"\")\n\n\tlog.Printf(\"get image url %s\", url)\n\treq, err := http.NewRequest(\"GET\", url, strings.NewReader(\"\"))\n\tif err != nil {\n\t\treturn\n\t}\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\treq.Header.Add(\"Authorization\", strings.Join([]string{\"Bearer \", s.getToken()}, \"\"))\n\n\tres, err := s.httpClient.Do(req)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer res.Body.Close()\n\tfile, err = ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn\n}", "func (m *MockUpstreamIntf) RemoteDigestOfHeight(arg0 uint64) (blockdigest.Digest, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"RemoteDigestOfHeight\", arg0)\n\tret0, _ := ret[0].(blockdigest.Digest)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (mr *MockFetcherMockRecorder) FetchRemoteImage(arg0 interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"FetchRemoteImage\", reflect.TypeOf((*MockFetcher)(nil).FetchRemoteImage), arg0)\n}", "func dirImageMockWithRef(t *testing.T, dir string, ref types.ImageReference) private.UnparsedImage {\n\tsrcRef, err := directory.NewReference(dir)\n\trequire.NoError(t, err)\n\tsrc, err := srcRef.NewImageSource(context.Background(), nil)\n\trequire.NoError(t, err)\n\tt.Cleanup(func() {\n\t\terr := src.Close()\n\t\trequire.NoError(t, err)\n\t})\n\treturn image.UnparsedInstance(&dirImageSourceMock{\n\t\tImageSource: imagesource.FromPublic(src),\n\t\tref: ref,\n\t}, nil)\n}", "func (o *Options) fetchBlob(ctx context.Context, restctx *registryclient.Context, resource, layerDigest string, dstPaths []string) error {\n\n\trefStr := path.Join(o.ToMirror, resource)\n\tref, err := reference.Parse(refStr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parse ref %s: %v\", refStr, err)\n\t}\n\n\tlogrus.Debugf(\"copying blob %s from %s\", layerDigest, ref.Exact())\n\n\trepo, err := restctx.RepositoryForRef(ctx, ref, o.SkipTLS)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create repo for %s: %v\", ref, err)\n\t}\n\tdgst, err := digest.Parse(layerDigest)\n\tif err != nil {\n\t\treturn err\n\t}\n\trc, err := repo.Blobs(ctx).Open(ctx, dgst)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"open blob: %v\", err)\n\t}\n\tdefer rc.Close()\n\tfor _, dstPath := range dstPaths {\n\t\tif err := copyBlobFile(rc, dstPath); err != nil {\n\t\t\treturn fmt.Errorf(\"copy blob: %v\", err)\n\t\t}\n\t\tif _, err := rc.Seek(0, 0); err != nil {\n\t\t\treturn fmt.Errorf(\"seek to start of blob: %v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func createImageMirrorForInternalImages(prefix string, ref reference.DockerImageReference, mirrored bool) ([]string, error) {\n\tsource := ref.Exact()\n\n\tinitialDefaults := k8simage.GetOriginalImageConfigs()\n\texceptions := image.Exceptions.List()\n\tdefaults := map[k8simage.ImageID]k8simage.Config{}\n\nimageLoop:\n\tfor i, config := range initialDefaults {\n\t\tfor _, exception := range exceptions {\n\t\t\tif strings.Contains(config.GetE2EImage(), exception) {\n\t\t\t\tcontinue imageLoop\n\t\t\t}\n\t\t}\n\t\tdefaults[i] = config\n\t}\n\n\tupdated := k8simage.GetMappedImageConfigs(defaults, ref.Exact())\n\topenshiftDefaults := image.OriginalImages()\n\topenshiftUpdated := image.GetMappedImages(openshiftDefaults, imagesetup.DefaultTestImageMirrorLocation)\n\n\t// if we've mirrored, then the source is going to be our repo, not upstream's\n\tif mirrored {\n\t\tbaseRef, err := reference.Parse(imagesetup.DefaultTestImageMirrorLocation)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid default mirror location: %v\", err)\n\t\t}\n\n\t\t// calculate the mapping of upstream images by setting defaults to baseRef\n\t\tcovered := sets.NewString()\n\t\tfor i, config := range updated {\n\t\t\tdefaultConfig := defaults[i]\n\t\t\tpullSpec := config.GetE2EImage()\n\t\t\tif pullSpec == defaultConfig.GetE2EImage() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif covered.Has(pullSpec) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tcovered.Insert(pullSpec)\n\t\t\te2eRef, err := reference.Parse(pullSpec)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid test image: %s: %v\", pullSpec, err)\n\t\t\t}\n\t\t\tif len(e2eRef.Tag) == 0 {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid test image: %s: no tag\", pullSpec)\n\t\t\t}\n\t\t\tconfig.SetRegistry(baseRef.Registry)\n\t\t\tconfig.SetName(baseRef.RepositoryName())\n\t\t\tconfig.SetVersion(e2eRef.Tag)\n\t\t\tdefaults[i] = config\n\t\t}\n\n\t\t// calculate the mapping for openshift images by populating openshiftUpdated\n\t\topenshiftUpdated = make(map[string]string)\n\t\tsourceMappings := image.GetMappedImages(openshiftDefaults, imagesetup.DefaultTestImageMirrorLocation)\n\t\ttargetMappings := image.GetMappedImages(openshiftDefaults, source)\n\n\t\tfor from, to := range targetMappings {\n\t\t\tif from == to {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif covered.Has(to) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tcovered.Insert(to)\n\t\t\tfrom := sourceMappings[from]\n\t\t\topenshiftUpdated[from] = to\n\t\t}\n\t}\n\n\tcovered := sets.NewString()\n\tvar lines []string\n\tfor i := range updated {\n\t\ta, b := defaults[i], updated[i]\n\t\tfrom, to := a.GetE2EImage(), b.GetE2EImage()\n\t\tif from == to {\n\t\t\tcontinue\n\t\t}\n\t\tif covered.Has(from) {\n\t\t\tcontinue\n\t\t}\n\t\tcovered.Insert(from)\n\t\tlines = append(lines, fmt.Sprintf(\"%s %s%s\", from, prefix, to))\n\t}\n\n\tfor from, to := range openshiftUpdated {\n\t\tif from == to {\n\t\t\tcontinue\n\t\t}\n\t\tif covered.Has(from) {\n\t\t\tcontinue\n\t\t}\n\t\tcovered.Insert(from)\n\t\tlines = append(lines, fmt.Sprintf(\"%s %s%s\", from, prefix, to))\n\t}\n\n\tsort.Strings(lines)\n\treturn lines, nil\n}", "func (l *RegistryListener) FindImage(rImg *registry.Image) (*dockerclient.Image, error) {\n\tregaddr := path.Join(l.address, rImg.String())\n\tglog.V(1).Infof(\"Searching for image %s\", regaddr)\n\n\t// check for UUID\n\tif img, err := l.docker.FindImage(rImg.UUID); err == nil {\n\t\treturn img, nil\n\t}\n\n\t// check by repo and tag, and compare hashes\n\tglog.V(1).Infof(\"UUID %s not found locally, searching by registry address for %s\", rImg.UUID, regaddr)\n\tif img, err := l.docker.FindImage(regaddr); err == nil {\n\t\tif localHash, err := l.docker.GetImageHash(img.ID); err != nil {\n\t\t\tglog.Warningf(\"Error building hash of image: %s: %s\", img.ID, err)\n\t\t} else {\n\t\t\tif localHash == rImg.Hash {\n\t\t\t\treturn img, nil\n\t\t\t}\n\t\t\tglog.V(1).Infof(\"Found %s locally, but hashes do not match\", regaddr)\n\t\t}\n\t}\n\n\t// attempt to pull the image, then compare hashes\n\tglog.V(0).Infof(\"Image address %s not found locally, attempting pull\", regaddr)\n\tif err := l.docker.PullImage(regaddr); err == nil {\n\t\tglog.V(1).Infof(\"Successfully pulled image %s from registry, checking for match\", regaddr)\n\t\tif img, err := l.docker.FindImage(regaddr); err == nil {\n\t\t\tif img.ID == rImg.UUID {\n\t\t\t\tglog.V(1).Infof(\"Found image %s in registry with correct UUID\", regaddr)\n\t\t\t\treturn img, nil\n\t\t\t}\n\t\t\tif localHash, err := l.docker.GetImageHash(img.ID); err != nil {\n\t\t\t\tglog.Warningf(\"Error building hash of image: %s: %s\", img.ID, err)\n\t\t\t} else {\n\t\t\t\tif localHash == rImg.Hash {\n\t\t\t\t\tglog.V(1).Infof(\"Found image %s in registry with correct Hash\", regaddr)\n\t\t\t\t\treturn img, nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// search all images for a matching hash\n\t// First just check top-level layers\n\tglog.V(0).Infof(\"Image %s not found in registry, searching local images by hash\", regaddr)\n\tif img, err := l.docker.FindImageByHash(rImg.Hash, false); err == nil {\n\t\treturn img, nil\n\t}\n\n\t// Now check all layers\n\tglog.V(0).Infof(\"Hash for Image %s not found in top-level layers, searching all layers\", regaddr)\n\treturn l.docker.FindImageByHash(rImg.Hash, true)\n}", "func downloadImage(data *ImageData) (io.ReadCloser, error) {\n\ttimeout := time.Duration(10 * time.Second)\n\tclient := http.Client{\n\t\tTimeout: timeout,\n\t}\n\tresponse, err := client.Get(data.Url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer client.CloseIdleConnections()\n\treturn response.Body, err\n}", "func (suite *APIImageSaveLoadSuite) TestImageSaveLoadOk(c *check.C) {\n\tbefore, err := request.Get(\"/images/\" + busyboxImage125 + \"/json\")\n\tc.Assert(err, check.IsNil)\n\tCheckRespStatus(c, before, 200)\n\tgotBefore := types.ImageInfo{}\n\terr = request.DecodeBody(&gotBefore, before.Body)\n\tc.Assert(err, check.IsNil)\n\n\tq := url.Values{}\n\tq.Set(\"name\", busyboxImage125)\n\tquery := request.WithQuery(q)\n\tresp, err := request.Get(\"/images/save\", query)\n\tc.Assert(err, check.IsNil)\n\tdefer resp.Body.Close()\n\n\tdir, err := ioutil.TempDir(\"\", \"TestImageSaveLoadOk\")\n\tif err != nil {\n\t\tc.Errorf(\"failed to create a new temporary directory: %v\", err)\n\t}\n\tdefer os.RemoveAll(dir)\n\n\ttmpFile := filepath.Join(dir, \"busyboxImage.tar\")\n\tf, err := os.Create(tmpFile)\n\tif err != nil {\n\t\tc.Errorf(\"failed to create file: %v\", err)\n\t}\n\n\tif _, err := io.Copy(f, resp.Body); err != nil {\n\t\tc.Errorf(\"failed to save data to file: %v\", err)\n\t}\n\n\tdata, err := os.Open(tmpFile)\n\tif err != nil {\n\t\tc.Errorf(\"failed to load file's data: %v\", err)\n\t}\n\n\tloadImageName := \"load-busyboxImage\"\n\tq = url.Values{}\n\tq.Set(\"name\", loadImageName)\n\n\tquery = request.WithQuery(q)\n\treader := request.WithRawData(data)\n\theader := request.WithHeader(\"Content-Type\", \"application/x-tar\")\n\n\tresp, err = request.Post(\"/images/load\", query, reader, header)\n\tc.Assert(err, check.IsNil)\n\tCheckRespStatus(c, resp, 200)\n\n\tafter, err := request.Get(\"/images/\" + loadImageName + \":\" + environment.Busybox125Tag + \"/json\")\n\tc.Assert(err, check.IsNil)\n\tCheckRespStatus(c, after, 200)\n\tdefer request.Delete(\"/images/\" + loadImageName + \":\" + environment.Busybox125Tag)\n\n\tgotAfter := types.ImageInfo{}\n\terr = request.DecodeBody(&gotAfter, after.Body)\n\tc.Assert(err, check.IsNil)\n\n\tc.Assert(gotBefore.ID, check.Equals, gotAfter.ID)\n\tc.Assert(gotBefore.CreatedAt, check.Equals, gotAfter.CreatedAt)\n\tc.Assert(gotBefore.Size, check.Equals, gotAfter.Size)\n}", "func (c *Client) Image(ctx context.Context, number int) (io.Reader, string, error) {\n\tcomic, err := c.Get(ctx, number)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\n\treq, err := http.NewRequest(\"GET\", comic.ImageURL, nil)\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"failed to build image request: %s\", err)\n\t}\n\treq = req.WithContext(ctx)\n\n\trsp, err := c.HTTPClient.Do(req)\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"failed to do image request: %s\", err)\n\t}\n\tdefer drainAndClose(rsp.Body)\n\n\tif rsp.StatusCode != 200 {\n\t\treturn nil, \"\", StatusError{Code: rsp.StatusCode}\n\t}\n\n\tvar buf bytes.Buffer\n\tif _, err := io.Copy(&buf, rsp.Body); err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"failed to do copy image: %s\", err)\n\t}\n\n\treturn &buf, rsp.Header.Get(\"Content-Type\"), nil\n}", "func (f *fetcher) fetchSingleImage(img string, asc string, discover bool) (string, error) {\n\tvar (\n\t\tascFile *os.File\n\t\terr error\n\t\tlatest bool\n\t)\n\tif asc != \"\" && f.ks != nil {\n\t\tascFile, err = os.Open(asc)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"unable to open signature file: %v\", err)\n\t\t}\n\t\tdefer ascFile.Close()\n\t}\n\n\tu, err := url.Parse(img)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"not a valid image reference (%s)\", img)\n\t}\n\n\t// if img refers to a local file, ensure the scheme is file:// and make the url path absolute\n\t_, err = os.Stat(u.Path)\n\tif err == nil {\n\t\tu.Path, err = filepath.Abs(u.Path)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"unable to get abs path: %v\", err)\n\t\t}\n\t\tu.Scheme = \"file\"\n\t} else if !os.IsNotExist(err) {\n\t\treturn \"\", fmt.Errorf(\"unable to access %q: %v\", img, err)\n\t}\n\n\tif discover && u.Scheme == \"\" {\n\t\tif app := newDiscoveryApp(img); app != nil {\n\t\t\tvar discoveryError error\n\t\t\tif !f.local {\n\t\t\t\tstderr(\"rkt: searching for app image %s\", img)\n\t\t\t\tep, err := discoverApp(app, true)\n\t\t\t\tif err != nil {\n\t\t\t\t\tdiscoveryError = err\n\t\t\t\t} else {\n\t\t\t\t\t// No specified version label, mark it as latest\n\t\t\t\t\tif _, ok := app.Labels[\"version\"]; !ok {\n\t\t\t\t\t\tlatest = true\n\t\t\t\t\t}\n\t\t\t\t\treturn f.fetchImageFromEndpoints(app.Name.String(), ep, ascFile, latest)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif discoveryError != nil {\n\t\t\t\tstderr(\"discovery failed for %q: %v. Trying to find image in the store.\", img, discoveryError)\n\t\t\t}\n\t\t\tif f.local || discoveryError != nil {\n\t\t\t\treturn f.fetchImageFromStore(img)\n\t\t\t}\n\t\t}\n\t}\n\n\tswitch u.Scheme {\n\tcase \"http\", \"https\", \"file\":\n\tcase \"docker\":\n\t\tdockerURL := common.ParseDockerURL(path.Join(u.Host, u.Path))\n\t\tif dockerURL.Tag == \"latest\" {\n\t\t\tlatest = true\n\t\t}\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"rkt only supports http, https, docker or file URLs (%s)\", img)\n\t}\n\treturn f.fetchImageFromURL(u.String(), u.Scheme, ascFile, latest)\n}" ]
[ "0.6551211", "0.63521427", "0.6168074", "0.5930461", "0.59249926", "0.59170794", "0.5911446", "0.5879098", "0.58760864", "0.5863561", "0.5850105", "0.5846192", "0.5763224", "0.5747897", "0.57216996", "0.57001495", "0.56998503", "0.56664616", "0.5652397", "0.56486833", "0.5608164", "0.55508506", "0.55447334", "0.5544553", "0.554286", "0.55327886", "0.5531382", "0.55122125", "0.55034727", "0.547106", "0.5470628", "0.5446105", "0.54407465", "0.54257965", "0.5415677", "0.54127294", "0.5409883", "0.53736585", "0.5358621", "0.53525597", "0.53125477", "0.53016263", "0.52929175", "0.52440464", "0.5233386", "0.5233321", "0.5219589", "0.52150685", "0.5210427", "0.5205058", "0.51979446", "0.51978713", "0.51880497", "0.51875573", "0.5180496", "0.51732975", "0.5169877", "0.5166297", "0.5163226", "0.51618034", "0.5153659", "0.5137862", "0.51335543", "0.5122026", "0.51157886", "0.5112688", "0.51124614", "0.51122326", "0.5111514", "0.5106319", "0.5104134", "0.51031154", "0.51028633", "0.5098946", "0.509732", "0.5093791", "0.50923604", "0.5087019", "0.5081302", "0.50709915", "0.506233", "0.5055836", "0.50467163", "0.5044104", "0.5039415", "0.5038196", "0.50360453", "0.5033169", "0.5026312", "0.5019462", "0.50011015", "0.49955928", "0.49870035", "0.49788576", "0.49710044", "0.49621484", "0.49602234", "0.49601215", "0.4958254", "0.49581626" ]
0.75892
0
FetchUpdatedLocalImage mocks base method
FetchUpdatedLocalImage имитирует базовый метод
func (m *MockFetcher) FetchUpdatedLocalImage(arg0 context.Context, arg1 string, arg2 io.Writer) (image.Image, error) { ret := m.ctrl.Call(m, "FetchUpdatedLocalImage", arg0, arg1, arg2) ret0, _ := ret[0].(image.Image) ret1, _ := ret[1].(error) return ret0, ret1 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *MockFetcher) FetchLocalImage(arg0 string) (image.Image, error) {\n\tret := m.ctrl.Call(m, \"FetchLocalImage\", arg0)\n\tret0, _ := ret[0].(image.Image)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockFetcher) FetchRemoteImage(arg0 string) (image.Image, error) {\n\tret := m.ctrl.Call(m, \"FetchRemoteImage\", arg0)\n\tret0, _ := ret[0].(image.Image)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockAPI) UpdateImageStatus(arg0 context.Context, arg1 *models.Host, arg2 *models.ContainerImageAvailability, arg3 *gorm.DB) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"UpdateImageStatus\", arg0, arg1, arg2, arg3)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func TestIsImageInLocalRegistry(t *testing.T) {\n\ttype testDef struct {\n\t\timageName string\n\t\tdocker test.FakeDockerClient\n\t\texpectedResult bool\n\t\texpectedError string\n\t}\n\ttests := map[string]testDef{\n\t\t\"ImageFound\": {\"a_test_image\", test.FakeDockerClient{}, true, \"\"},\n\t\t\"ImageNotFound\": {\"a_test_image:sometag\", test.FakeDockerClient{}, false, \"unable to get metadata for a_test_image:sometag\"},\n\t}\n\n\tfor test, def := range tests {\n\t\tdh := getDocker(&def.docker)\n\t\tfake := dh.kubeDockerClient.(*dockertools.FakeDockerClient)\n\t\tif def.expectedResult {\n\t\t\tfake.Image = &dockertypes.ImageInspect{ID: def.imageName}\n\t\t}\n\n\t\tresult, err := dh.IsImageInLocalRegistry(def.imageName)\n\n\t\tif e := fake.AssertCalls([]string{\"inspect_image\"}); e != nil {\n\t\t\tt.Errorf(\"%+v\", e)\n\t\t}\n\n\t\tif result != def.expectedResult {\n\t\t\tt.Errorf(\"Test - %s: Expected result: %v. Got: %v\", test, def.expectedResult, result)\n\t\t}\n\t\tif err != nil && len(def.expectedError) > 0 && !strings.Contains(err.Error(), def.expectedError) {\n\t\t\tt.Errorf(\"Test - %s: Expected error: Got: %+v\", test, err)\n\t\t}\n\t}\n}", "func TestFetch(t *testing.T) {\n\timage := \"rkt-inspect-fetch.aci\"\n\n\tctx := newRktRunCtx()\n\tdefer ctx.cleanup()\n\n\t// Fetch the image for the first time, this should write the image to the\n\t// on-disk store.\n\toldHash := patchImportAndFetchHash(image, []string{\"--exec=/inspect --read-file\"}, t, ctx)\n\n\t// Fetch the image with the same name but different content, the expecting\n\t// result is that we should get a different hash since we are not fetching\n\t// from the on-disk store.\n\tnewHash := patchImportAndFetchHash(image, []string{\"--exec=/inspect --read-file --write-file\"}, t, ctx)\n\n\tif oldHash == newHash {\n\t\tt.Fatalf(\"ACI hash should be different as the image has changed\")\n\t}\n}", "func ttrPullImageAsserting(ctx context.Context, t *testing.T, client apiclient.APIClient, image string) {\n\terr := ttrPullImage(ctx, client, image)\n\tassert.NilError(t, err)\n}", "func (r *MockRepoManager) mockUpdate() {\n\tr.mtx.Lock()\n\tdefer r.mtx.Unlock()\n\tr.updateCount++\n}", "func (m *MockUpstreamIntf) CachedRemoteDigestOfLocalHeight() blockdigest.Digest {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"CachedRemoteDigestOfLocalHeight\")\n\tret0, _ := ret[0].(blockdigest.Digest)\n\treturn ret0\n}", "func fetchLocal(f *File) error {\n\n\terr := validateLocal(f)\n\tif err != nil {\n\t\tf.Status.Type = status.ERROR\n\t\treturn err\n\t}\n\tf.path = f.Url\n\tf.Status.Type = status.FETCHED\n\treturn nil\n\n}", "func (m *MockUsecase) UpdateAvatar(arg0 string, arg1 multipart.File, arg2 string) (string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"UpdateAvatar\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (mr *MockFetcherMockRecorder) FetchUpdatedLocalImage(arg0, arg1, arg2 interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"FetchUpdatedLocalImage\", reflect.TypeOf((*MockFetcher)(nil).FetchUpdatedLocalImage), arg0, arg1, arg2)\n}", "func TestBaseImage(t *testing.T) {\n\tctx, err := controllerPrepare()\n\tif err != nil {\n\t\tt.Fatal(\"Fail in controller prepare: \", err)\n\t}\n\teveBaseRef := os.Getenv(\"EVE_BASE_REF\")\n\tif len(eveBaseRef) == 0 {\n\t\teveBaseRef = \"4.10.0\"\n\t}\n\tzArch := os.Getenv(\"ZARCH\")\n\tif len(eveBaseRef) == 0 {\n\t\tzArch = \"amd64\"\n\t}\n\tHV := os.Getenv(\"HV\")\n\tif HV == \"xen\" {\n\t\tHV = \"\"\n\t}\n\tvar baseImageTests = []struct {\n\t\tdataStoreID string\n\t\timageID string\n\t\tbaseID string\n\t\timageRelativePath string\n\t\timageFormat config.Format\n\t\teveBaseRef string\n\t\tzArch string\n\t\tHV string\n\t}{\n\t\t{eServerDataStoreID,\n\n\t\t\t\"1ab8761b-5f89-4e0b-b757-4b87a9fa93ec\",\n\n\t\t\t\"22b8761b-5f89-4e0b-b757-4b87a9fa93ec\",\n\n\t\t\t\"baseos.qcow2\",\n\t\t\tconfig.Format_QCOW2,\n\t\t\teveBaseRef,\n\t\t\tzArch,\n\t\t\tHV,\n\t\t},\n\t}\n\tfor _, tt := range baseImageTests {\n\t\tbaseOSVersion := fmt.Sprintf(\"%s-%s\", tt.eveBaseRef, tt.zArch)\n\t\tif tt.HV != \"\" {\n\t\t\tbaseOSVersion = fmt.Sprintf(\"%s-%s-%s\", tt.eveBaseRef, tt.zArch, tt.HV)\n\t\t}\n\t\tt.Run(baseOSVersion, func(t *testing.T) {\n\n\t\t\terr = prepareBaseImageLocal(ctx, tt.dataStoreID, tt.imageID, tt.baseID, tt.imageRelativePath, tt.imageFormat, baseOSVersion)\n\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(\"Fail in prepare base image from local file: \", err)\n\t\t\t}\n\t\t\tdeviceCtx, err := ctx.GetDeviceFirst()\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(\"Fail in get first device: \", err)\n\t\t\t}\n\t\t\tdeviceCtx.SetBaseOSConfig([]string{tt.baseID})\n\t\t\tdevUUID := deviceCtx.GetID()\n\t\t\terr = ctx.ConfigSync(deviceCtx)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatal(\"Fail in sync config with controller: \", err)\n\t\t\t}\n\t\t\tt.Run(\"Started\", func(t *testing.T) {\n\t\t\t\terr := ctx.InfoChecker(devUUID, map[string]string{\"devId\": devUUID.String(), \"shortVersion\": baseOSVersion}, einfo.ZInfoDevSW, 300)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(\"Fail in waiting for base image update init: \", err)\n\t\t\t\t}\n\t\t\t})\n\t\t\tt.Run(\"Downloaded\", func(t *testing.T) {\n\t\t\t\terr := ctx.InfoChecker(devUUID, map[string]string{\"devId\": devUUID.String(), \"shortVersion\": baseOSVersion, \"downloadProgress\": \"100\"}, einfo.ZInfoDevSW, 1500)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(\"Fail in waiting for base image download progress: \", err)\n\t\t\t\t}\n\t\t\t})\n\t\t\tt.Run(\"Logs\", func(t *testing.T) {\n\t\t\t\tif !checkLogs {\n\t\t\t\t\tt.Skip(\"no LOGS flag set - skipped\")\n\t\t\t\t}\n\t\t\t\terr = ctx.LogChecker(devUUID, map[string]string{\"devId\": devUUID.String(), \"eveVersion\": baseOSVersion}, 1200)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(\"Fail in waiting for base image logs: \", err)\n\t\t\t\t}\n\t\t\t})\n\t\t\ttimeout := time.Duration(1200)\n\n\t\t\tif !checkLogs {\n\t\t\t\ttimeout = 2400\n\t\t\t}\n\t\t\tt.Run(\"Active\", func(t *testing.T) {\n\t\t\t\terr = ctx.InfoChecker(devUUID, map[string]string{\"devId\": devUUID.String(), \"shortVersion\": baseOSVersion, \"status\": \"INSTALLED\", \"partitionState\": \"(inprogress|active)\"}, einfo.ZInfoDevSW, timeout)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatal(\"Fail in waiting for base image installed status: \", err)\n\t\t\t\t}\n\t\t\t})\n\t\t})\n\t}\n\n}", "func (m *MockCEImpl) ImagePull(image string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ImagePull\", image)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (f OriginalFetcher) Fetch(namespace string, sourceURL string, imageHash string) (info *info.ImageProperties, downloaded bool, err error) {\n\tif sourceURL == \"\" && imageHash == \"\" {\n\t\treturn nil, false, fmt.Errorf(\"Missing Hash & URL\")\n\t}\n\n\tif imageHash != \"\" {\n\t\tinfo, err = f.fetchFromStore(namespace, imageHash)\n\t}\n\n\tif sourceURL != \"\" && (err != nil || imageHash == \"\") {\n\t\tinfo, downloaded, err = f.fetchFromSource(namespace, sourceURL)\n\t}\n\n\treturn info, downloaded, err\n}", "func (m *MockModuleService) GetLatestModuleImage(arg0 string) (string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetLatestModuleImage\", arg0)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockImageTransferer) Stat(arg0 string, arg1 core.Digest) (*core.BlobInfo, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Stat\", arg0, arg1)\n\tret0, _ := ret[0].(*core.BlobInfo)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func fetchUpdatableImageRepos(registry registry.Registry, updateable []*WorkloadUpdate, logger log.Logger) (ImageRepos, error) {\n\treturn FetchImageRepos(registry, workloadContainers(updateable), logger)\n}", "func (m *MockHandler) UpdateProfileAvatar(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"UpdateProfileAvatar\", arg0, arg1)\n}", "func (f *fetcher) fetchImageFrom(appName string, aciURL, ascURL, scheme string, ascFile *os.File, latest bool) (string, error) {\n\tvar rem *store.Remote\n\n\tif f.insecureSkipVerify {\n\t\tif f.ks != nil {\n\t\t\tstderr(\"rkt: warning: TLS verification and signature verification has been disabled\")\n\t\t}\n\t} else if scheme == \"docker\" {\n\t\treturn \"\", fmt.Errorf(\"signature verification for docker images is not supported (try --insecure-skip-verify)\")\n\t}\n\n\tif (f.local && scheme != \"file\") || (scheme != \"file\" && !latest) {\n\t\tvar err error\n\t\tok := false\n\t\trem, ok, err = f.s.GetRemote(aciURL)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif ok {\n\t\t\tif f.local {\n\t\t\t\tstderr(\"rkt: using image in local store for app %s\", appName)\n\t\t\t\treturn rem.BlobKey, nil\n\t\t\t}\n\t\t\tif useCached(rem.DownloadTime, rem.CacheMaxAge) {\n\t\t\t\tstderr(\"rkt: found image in local store, skipping fetching from %s\", aciURL)\n\t\t\t\treturn rem.BlobKey, nil\n\t\t\t}\n\t\t}\n\t\tif f.local {\n\t\t\treturn \"\", fmt.Errorf(\"url %s not available in local store\", aciURL)\n\t\t}\n\t}\n\n\tif scheme != \"file\" && f.debug {\n\t\tstderr(\"rkt: fetching image from %s\", aciURL)\n\t}\n\n\tvar etag string\n\tif rem != nil {\n\t\tetag = rem.ETag\n\t}\n\tentity, aciFile, cd, err := f.fetch(appName, aciURL, ascURL, ascFile, etag)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif cd != nil && cd.useCached {\n\t\tif rem != nil {\n\t\t\treturn rem.BlobKey, nil\n\t\t} else {\n\t\t\t// should never happen\n\t\t\tpanic(\"asked to use cached image but remote is nil\")\n\t\t}\n\t}\n\tif scheme != \"file\" {\n\t\tdefer os.Remove(aciFile.Name())\n\t}\n\n\tif entity != nil && !f.insecureSkipVerify {\n\t\tstderr(\"rkt: signature verified:\")\n\t\tfor _, v := range entity.Identities {\n\t\t\tstderr(\" %s\", v.Name)\n\t\t}\n\t}\n\tkey, err := f.s.WriteACI(aciFile, latest)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif scheme != \"file\" {\n\t\trem := store.NewRemote(aciURL, ascURL)\n\t\trem.BlobKey = key\n\t\trem.DownloadTime = time.Now()\n\t\tif cd != nil {\n\t\t\trem.ETag = cd.etag\n\t\t\trem.CacheMaxAge = cd.maxAge\n\t\t}\n\t\terr = f.s.WriteRemote(rem)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\treturn key, nil\n}", "func ttrPushImageAsserting(ctx context.Context, t *testing.T, client apiclient.APIClient, image string) {\n\trc, err := client.ImagePush(ctx, ttrImageName(image), types.ImagePushOptions{RegistryAuth: \"{}\"})\n\tassert.Assert(t, err)\n\tif rc != nil {\n\t\tbody, err := readAllAndClose(rc)\n\t\tassert.Assert(t, err)\n\t\tassert.Assert(t, strings.Contains(body, `\"status\":\"latest: digest: `))\n\t}\n}", "func (imp *Importer) fetchLocalImages() {\n items, err := ioutil.ReadDir(STORE_DIR)\n if err != nil {\n imp.sendErr(err)\n return\n }\n\n for _, info := range items {\n if info.IsDir() { continue }\n filename := info.Name()\n\n file, err := os.Open(fmt.Sprintf(\"%s/%s\", STORE_DIR, filename))\n if err != nil {\n imp.sendErr(err)\n return\n }\n\n img, err := jpeg.Decode(file)\n if err != nil {\n log.Printf(\"Error decoding image file %s to jpeg\\n\", filename)\n continue\n }\n\n ext := filepath.Ext(filename)\n id := filename[:len(filename)-len(ext)]\n\n imp.send(&imagedata.ImageData{Id: id, Data: &img})\n }\n}", "func (m *MockRepository) Update(arg0 int, arg1 entity.FeiraLivre) (*entity.FeiraLivre, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Update\", arg0, arg1)\n\tret0, _ := ret[0].(*entity.FeiraLivre)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockManager) GetLoadedImageName() string {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetLoadedImageName\")\n\tret0, _ := ret[0].(string)\n\treturn ret0\n}", "func TestBaseImage(t *testing.T) {\n\t// test with 'original.png'\n\timgs := map[string][]byte{\n\t\t\"original.png\": []byte(\"image\"),\n\t}\n\t_, err := backend.baseImage(imgs)\n\tif err != nil {\n\t\tt.Errorf(\"Got error %s\", err)\n\t}\n\n\t// test with 'original.jpg'\n\timgs = map[string][]byte{\n\t\t\"original.jpg\": []byte(\"image\"),\n\t}\n\t_, err = backend.baseImage(imgs)\n\tif err != nil {\n\t\tt.Errorf(\"Got error %s\", err)\n\t}\n\n\t// without 'original.*' should get an error\n\timgs = map[string][]byte{\n\t\t\"127x127.png\": []byte(\"image\"),\n\t}\n\t_, err = backend.baseImage(imgs)\n\tif err == nil {\n\t\tt.Errorf(\"Should get an error, didn't pass original image.\")\n\t}\n}", "func (m *MockRepository) Fetch(bucketName, name string, model db.Model) (bool, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Fetch\", bucketName, name, model)\n\tret0, _ := ret[0].(bool)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (_m *TeamStore) UpdateLastTeamIconUpdate(teamID string, curTime int64) error {\n\tret := _m.Called(teamID, curTime)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(string, int64) error); ok {\n\t\tr0 = rf(teamID, curTime)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func (m *MockRequester) Fetch(url string) (io.ReadCloser, error) {\n\tret := m.ctrl.Call(m, \"Fetch\", url)\n\tret0, _ := ret[0].(io.ReadCloser)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func LoadLocalImage(app *AppData) error {\n\tapp.LocalImage = DockerImage{\n\t\tExists: false,\n\t}\n\tctx := context.Background()\n\tcli, err := client.NewClientWithOpts(client.FromEnv)\n\tcli.NegotiateAPIVersion(ctx)\n\tdefer cli.Close()\n\tif err != nil {\n\t\treturn err\n\t}\n\tinspect, _, err := cli.ImageInspectWithRaw(ctx, app.From)\n\tif err != nil {\n\t\tif err.Error() == \"Error: No such image: \"+app.From {\n\t\t\tfmt.Printf(\"Repo not exists in local docker\\n\")\n\t\t\treturn nil\n\t\t}\n\t\treturn err\n\t}\n\tfmt.Printf(\"Repo exists in local docker\\n\")\n\tapp.LocalImage.Exists = true\n\tif len(inspect.RepoDigests) > 0 {\n\t\tapp.LocalImage.DockerDigest = inspect.RepoDigests[0]\n\t} else {\n\t\tapp.LocalImage.DockerDigest = inspect.ID\n\t}\n\n\t//Setting Docker Config values\n\tconfigData, err := json.Marshal(inspect.Config)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = pvjson.Unmarshal(configData, &app.LocalImage.DockerConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (f *Frontend) fetchImage(i *img.Image) (*img.Image, error) {\n\tvar err error\n\n\t// go through image proxy to resize and cache the image\n\tkey := hmacKey(i.ID)\n\tu := fmt.Sprintf(\"%v/image/225x,s%v/%v\", f.Host, key, i.ID)\n\tfmt.Println(u)\n\n\tresp, err := f.Images.Client.Get(u)\n\tif err != nil {\n\t\treturn i, err\n\t}\n\n\tdefer resp.Body.Close()\n\n\tbdy, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn i, err\n\t}\n\n\ti.Base64 = base64.StdEncoding.EncodeToString(bdy)\n\treturn i, err\n}", "func TestImplicitFetch(t *testing.T) {\n\tfoundMsg := \"found image in local store\"\n\n\tctx := newRktRunCtx()\n\tdefer ctx.cleanup()\n\n\t// 1. Fetch the image.\n\t// TODO(yifan): Add other ACI with different schemes.\n\timportImageAndFetchHash(t, ctx, \"docker://busybox:ubuntu-12.04\")\n\timportImageAndFetchHash(t, ctx, \"docker://busybox:latest\")\n\n\t// 2. Try run/prepare with/without tag ':latest', should not get $foundMsg.\n\tcmds := []string{\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify run --mds-register=false docker://busybox\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify run --mds-register=false docker://busybox:latest\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify prepare docker://busybox\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify prepare docker://busybox:latest\", ctx.cmd()),\n\t}\n\n\tfor _, cmd := range cmds {\n\t\tt.Logf(\"Running test %v\", cmd)\n\n\t\tchild, err := gexpect.Spawn(cmd)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Cannot exec rkt: %v\", err)\n\t\t}\n\t\tif err := expectWithOutput(child, foundMsg); err == nil {\n\t\t\tt.Fatalf(\"%q should not be found\", foundMsg)\n\t\t}\n\t\tif err := child.Wait(); err != nil {\n\t\t\tt.Fatalf(\"rkt didn't terminate correctly: %v\", err)\n\t\t}\n\t}\n}", "func (m *MockRepository) UpdateCache() (map[string]float32, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"UpdateCache\")\n\tret0, _ := ret[0].(map[string]float32)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (_m *MockRepository) UpdateCCLFFileImportStatus(ctx context.Context, fileID uint, importStatus string) error {\n\tret := _m.Called(ctx, fileID, importStatus)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(context.Context, uint, string) error); ok {\n\t\tr0 = rf(ctx, fileID, importStatus)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func (m *MockEnvironment) Fetch() map[string]interface{} {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Fetch\")\n\tret0, _ := ret[0].(map[string]interface{})\n\treturn ret0\n}", "func TestCannotExecuteStatusImage(t *testing.T) {\n\tbuf := setLogBuffer()\n\tdefer func() {\n\t\tif t.Failed() {\n\t\t\tt.Log(buf.String())\n\t\t}\n\t}()\n\n\tif StatusImage == \"\" {\n\t\tt.Skip(\"no status image defined\")\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\tdefer cancel()\n\n\tapp := &models.App{Name: id.New().String()}\n\tapp = ensureApp(t, app)\n\n\tfn := &models.Fn{\n\t\tAppID: app.ID,\n\t\tName: id.New().String(),\n\t\tImage: StatusImage,\n\t\tResourceConfig: models.ResourceConfig{\n\t\t\tMemory: memory,\n\t\t},\n\t}\n\tfn = ensureFn(t, fn)\n\n\tlb, err := LB()\n\tif err != nil {\n\t\tt.Fatalf(\"Got unexpected error: %v\", err)\n\t}\n\tu := url.URL{\n\t\tScheme: \"http\",\n\t\tHost: lb,\n\t}\n\tu.Path = path.Join(u.Path, \"invoke\", fn.ID)\n\n\tcontent := bytes.NewBuffer([]byte(`status`))\n\toutput := &bytes.Buffer{}\n\n\tresp, err := callFN(ctx, u.String(), content, output, models.TypeSync)\n\tif err != nil {\n\t\tt.Fatalf(\"Got unexpected error: %v\", err)\n\t}\n\n\tif resp.StatusCode != http.StatusBadRequest {\n\t\tt.Fatalf(\"StatusCode check failed on %v\", resp.StatusCode)\n\t}\n}", "func (m *MockHandler) GetLatestOsImage(arg0 string) (*models.OsImage, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetLatestOsImage\", arg0)\n\tret0, _ := ret[0].(*models.OsImage)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockSystem) FetchURL(ctx context.Context, url string) (semver.Tags, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"FetchURL\", ctx, url)\n\tret0, _ := ret[0].(semver.Tags)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func ttrPullImage(ctx context.Context, client apiclient.APIClient, image string) error {\n\trc, err := client.ImagePull(ctx, ttrImageName(image), types.ImagePullOptions{RegistryAuth: \"{}\"})\n\tif err != nil {\n\t\treturn err\n\t}\n\tif rc != nil {\n\t\tbody, err := readAllAndClose(rc)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !strings.Contains(body, \"Status: Downloaded newer image\") {\n\t\t\treturn errors.New(\"image pull not successful\")\n\t\t}\n\t}\n\treturn nil\n}", "func (m *MockUserUsecase) UpdateAvatar(id int, avatarPath string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"UpdateAvatar\", id, avatarPath)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (c MockDockerClient) ImagePull(ctx context.Context, imageName string) error {\n\tif c.ImagePullFn != nil {\n\t\tfmt.Println(\"[MockDockerClient] In \", utils.CurrentFunctionName())\n\t\tfmt.Println(\"[MockDockerClient] - ctx: \", ctx)\n\t\tfmt.Println(\"[MockDockerClient] - imageName: \", imageName)\n\t\treturn c.ImagePullFn(ctx, imageName)\n\t}\n\tpanic(fmt.Sprintf(\"No function defined for: %s\", utils.CurrentFunctionName()))\n}", "func (c *repoCacheManager) fetchImages(tags []string) (fetchImagesResult, error) {\n\timages := map[string]image.Info{}\n\n\t// Create a list of images that need updating\n\tvar toUpdate []imageToUpdate\n\n\t// Counters for reporting what happened\n\tvar missing, refresh int\n\tfor _, tag := range tags {\n\t\tif tag == \"\" {\n\t\t\treturn fetchImagesResult{}, fmt.Errorf(\"empty tag in fetched tags\")\n\t\t}\n\n\t\t// See if we have the manifest already cached\n\t\tnewID := c.repoID.ToRef(tag)\n\t\tkey := NewManifestKey(newID.CanonicalRef())\n\t\tbytes, deadline, err := c.cacheClient.GetKey(key)\n\t\t// If err, then we don't have it yet. Update.\n\t\tswitch {\n\t\tcase err != nil: // by and large these are cache misses, but any error shall count as \"not found\"\n\t\t\tif err != ErrNotCached {\n\t\t\t\tc.logger.Log(\"warning\", \"error from cache\", \"err\", err, \"ref\", newID)\n\t\t\t}\n\t\t\tmissing++\n\t\t\ttoUpdate = append(toUpdate, imageToUpdate{ref: newID, previousRefresh: initialRefresh})\n\t\tcase len(bytes) == 0:\n\t\t\tc.logger.Log(\"warning\", \"empty result from cache\", \"ref\", newID)\n\t\t\tmissing++\n\t\t\ttoUpdate = append(toUpdate, imageToUpdate{ref: newID, previousRefresh: initialRefresh})\n\t\tdefault:\n\t\t\tvar entry registry.ImageEntry\n\t\t\tif err := json.Unmarshal(bytes, &entry); err == nil {\n\t\t\t\tif c.trace {\n\t\t\t\t\tc.logger.Log(\"trace\", \"found cached manifest\", \"ref\", newID, \"last_fetched\", entry.LastFetched.Format(time.RFC3339), \"deadline\", deadline.Format(time.RFC3339))\n\t\t\t\t}\n\n\t\t\t\tif entry.ExcludedReason == \"\" {\n\t\t\t\t\timages[tag] = entry.Info\n\t\t\t\t\tif c.now.After(deadline) {\n\t\t\t\t\t\tpreviousRefresh := minRefresh\n\t\t\t\t\t\tlastFetched := entry.Info.LastFetched\n\t\t\t\t\t\tif !lastFetched.IsZero() {\n\t\t\t\t\t\t\tpreviousRefresh = deadline.Sub(lastFetched)\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttoUpdate = append(toUpdate, imageToUpdate{ref: newID, previousRefresh: previousRefresh, previousDigest: entry.Info.Digest})\n\t\t\t\t\t\trefresh++\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif c.trace {\n\t\t\t\t\t\tc.logger.Log(\"trace\", \"excluded in cache\", \"ref\", newID, \"reason\", entry.ExcludedReason)\n\t\t\t\t\t}\n\t\t\t\t\tif c.now.After(deadline) {\n\t\t\t\t\t\ttoUpdate = append(toUpdate, imageToUpdate{ref: newID, previousRefresh: excludedRefresh})\n\t\t\t\t\t\trefresh++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tresult := fetchImagesResult{\n\t\timagesFound: images,\n\t\timagesToUpdate: toUpdate,\n\t\timagesToUpdateRefreshCount: refresh,\n\t\timagesToUpdateMissingCount: missing,\n\t}\n\n\treturn result, nil\n}", "func TestGetStatusByHostnameAtTimestamp2(t *testing.T) {\n\n\tbefore(t, dbStorage, dbSchema)\n\n\tprivateIPs := []string{\"44.33.22.11\"}\n\tpublicIPs := []string{\"88.77.66.55\"} // nolint\n\thostnames := []string{\"yahoo.com\"} // nolint\n\ttimestamp, _ := time.Parse(time.RFC3339, \"2019-08-09T08:29:35+00:00\")\n\n\tfakeCloudAssetChange := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames, timestamp, `arn`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\t// just reuse the existing struct\n\tfakeCloudAssetChange.ARN = \"arn2\"\n\ttimestamp2, _ := time.Parse(time.RFC3339, \"2019-08-11T08:29:35+00:00\") // August 11\n\tfakeCloudAssetChange.ChangeTime = timestamp2\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\thostname := \"yahoo.com\" // nolint\n\tat, _ := time.Parse(time.RFC3339, \"2019-08-10T08:29:35+00:00\") // query is for status on August 10\n\tnetworkChangeEvents, err := dbStorage.FetchByHostname(ctx, at, hostname)\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tassert.Equal(t, 1, len(networkChangeEvents))\n\n\texpected := []domain.CloudAssetDetails{{nil, []string{\"88.77.66.55\"}, []string{\"yahoo.com\"}, \"rtype\", \"aid\", \"region\", \"arn\", nil, domain.AccountOwner{}}} // nolint\n\n\tassertArrayEqualIgnoreOrder(t, expected, networkChangeEvents)\n\n}", "func (ss *Sources) localFetch(spec v1.SourceSpec) (string, error) {\n\tp := ss.repoPath(spec)\n\terr := os.MkdirAll(p, 0750)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t//TODO prevent target directory from accumulating unused files\n\t// remove all files before copy\n\t// or\n\t// walk target dir and diff with source dir\n\n\t// Copy local dir to repo path.\n\t// Ignore .git directory.\n\terr = otia10copy.Copy(spec.URL, p, otia10copy.Options{Skip: func(src string) bool {\n\t\treturn filepath.Base(src) == \".git\"\n\t}})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"fetch: %w\", err)\n\t}\n\n\th, err := ss.hashAll(spec.URL) // TODO use hashAll(p) when dir is properly synced (see previous to do)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\ts := hex.EncodeToString(h.Sum(nil))\n\n\treturn s, err\n}", "func TestExpectedImgRef(t *testing.T) {\n\n\tv, isSet := os.LookupEnv(\"DOCKERHUB_PROXY\")\n\tif isSet {\n\t\tdefer os.Setenv(\"DOCKERHUB_PROXY\", v)\n\t}\n\n\tos.Unsetenv(\"DOCKERHUB_PROXY\")\n\tassert.Equal(t,\n\t\t\"index.docker.io/library/hello-world@sha256:ebf526c198a14fa138634b9746c50ec38077ec9b3986227e79eb837d26f59dc6\",\n\t\tCompleteImageRef(\"library/hello-world@sha256:ebf526c198a14fa138634b9746c50ec38077ec9b3986227e79eb837d26f59dc6\"))\n\n\tos.Setenv(\"DOCKERHUB_PROXY\", \"my-dockerhub-proxy.tld/dockerhub-proxy\")\n\tassert.Equal(t,\n\t\t\"my-dockerhub-proxy.tld/dockerhub-proxy/library/hello-world@sha256:ebf526c198a14fa138634b9746c50ec38077ec9b3986227e79eb837d26f59dc6\",\n\t\tCompleteImageRef(\"library/hello-world@sha256:ebf526c198a14fa138634b9746c50ec38077ec9b3986227e79eb837d26f59dc6\"))\n\tos.Unsetenv(\"DOCKERHUB_PROXY\")\n}", "func TestRemote(t *testing.T) {\n\trnd, err := random.Image(1024, 3)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\ts, err := registry.TLS(\"gcr.io\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\ttr := s.Client().Transport\n\n\tsrc := \"gcr.io/test/compressed\"\n\tref, err := name.ParseReference(src)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif err := remote.Write(ref, rnd, remote.WithTransport(tr)); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\timg, err := remote.Image(ref, remote.WithTransport(tr))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif err := validate.Image(img); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tcf, err := img.ConfigFile()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tm, err := img.Manifest()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tlayer, err := img.LayerByDiffID(cf.RootFS.DiffIDs[0])\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\td, err := layer.Digest()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif diff := cmp.Diff(d, m.Layers[0].Digest); diff != \"\" {\n\t\tt.Errorf(\"mismatched digest: %v\", diff)\n\t}\n}", "func (m *MockAPI) UpdateMediaConnected(arg0 context.Context, arg1 *models.Host) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"UpdateMediaConnected\", arg0, arg1)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func dirImageMock(t *testing.T, dir, dockerReference string) private.UnparsedImage {\n\tref, err := reference.ParseNormalizedNamed(dockerReference)\n\trequire.NoError(t, err)\n\treturn dirImageMockWithRef(t, dir, refImageReferenceMock{ref: ref})\n}", "func retagLocalImageForRemotePush(localTag string, remoteUrl string) string {\n\tnewTag := fmt.Sprintf(\"%s/%s\", remoteUrl, localTag)\n\tdockerTag(localTag, newTag)\n\treturn newTag\n}", "func TestGetStatusByIPAddressAtTimestamp2(t *testing.T) {\n\n\tbefore(t, dbStorage, dbSchema)\n\n\tprivateIPs := []string{\"44.33.22.11\"}\n\tpublicIPs := []string{\"88.77.66.55\"}\n\thostnames := []string{\"yahoo.com\"} // nolint\n\ttimestamp, _ := time.Parse(time.RFC3339, \"2019-08-09T08:29:35+00:00\")\n\n\tfakeCloudAssetChange := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames, timestamp, `arn`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\t// just reuse the existing struct\n\tfakeCloudAssetChange.ARN = \"arn2\"\n\ttimestamp2, _ := time.Parse(time.RFC3339, \"2019-08-11T08:29:35+00:00\") // August 11\n\tfakeCloudAssetChange.ChangeTime = timestamp2\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tipAddress := \"88.77.66.55\"\n\tat, _ := time.Parse(time.RFC3339, \"2019-08-10T08:29:35+00:00\") // query is for status on August 10\n\tnetworkChangeEvents, err := dbStorage.FetchByIP(ctx, at, ipAddress)\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tassert.Equal(t, 1, len(networkChangeEvents))\n\n\texpected := []domain.CloudAssetDetails{\n\t\tdomain.CloudAssetDetails{nil, []string{\"88.77.66.55\"}, []string{\"yahoo.com\"}, \"rtype\", \"aid\", \"region\", \"arn\", nil, domain.AccountOwner{}}, // nolint\n\t}\n\n\tassertArrayEqualIgnoreOrder(t, expected, networkChangeEvents)\n\n}", "func TestRunPrepareLocal(t *testing.T) {\n\tnotAvailableMsg := \"not available in local store\"\n\tfoundMsg := \"using image in local store\"\n\n\tctx := newRktRunCtx()\n\tdefer ctx.cleanup()\n\n\tcmds := []string{\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify run --local --mds-register=false docker://busybox\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify run --local --mds-register=false docker://busybox:latest\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify prepare --local docker://busybox\", ctx.cmd()),\n\t\tfmt.Sprintf(\"%s --insecure-skip-verify prepare --local docker://busybox:latest\", ctx.cmd()),\n\t}\n\n\t// 1. Try run/prepare with the image not available in the store, should get $notAvailableMsg.\n\tfor _, cmd := range cmds {\n\t\tt.Logf(\"Running test %v\", cmd)\n\n\t\tchild, err := gexpect.Spawn(cmd)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Cannot exec rkt: %v\", err)\n\t\t}\n\t\tif err := expectWithOutput(child, notAvailableMsg); err != nil {\n\t\t\tt.Fatalf(\"%q should be found\", notAvailableMsg)\n\t\t}\n\t\tchild.Wait()\n\t}\n\n\t// 2. Fetch the image\n\timportImageAndFetchHash(t, ctx, \"docker://busybox\")\n\timportImageAndFetchHash(t, ctx, \"docker://busybox:latest\")\n\n\t// 3. Try run/prepare with the image available in the store, should get $foundMsg.\n\tfor _, cmd := range cmds {\n\t\tt.Logf(\"Running test %v\", cmd)\n\n\t\tchild, err := gexpect.Spawn(cmd)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Cannot exec rkt: %v\", err)\n\t\t}\n\t\tif err := expectWithOutput(child, foundMsg); err != nil {\n\t\t\tt.Fatalf(\"%q should be found\", foundMsg)\n\t\t}\n\t\tif err := child.Wait(); err != nil {\n\t\t\tt.Fatalf(\"rkt didn't terminate correctly: %v\", err)\n\t\t}\n\t}\n}", "func (m *VirtualMachinesClientMock) Update(ctx context.Context, resourceGroupName string, VMName string, parameters compute.VirtualMachineUpdate, source string) *retry.Error {\n\treturn nil\n}", "func (m *MockRepository) Update(ctx context.Context, asset *model.Asset) (*model.Asset, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Update\", ctx, asset)\n\tret0, _ := ret[0].(*model.Asset)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func TestGetStatusByIPAddressAtTimestamp1(t *testing.T) {\n\n\tbefore(t, dbStorage, dbSchema)\n\n\tprivateIPs := []string{\"44.33.22.11\"}\n\tpublicIPs := []string{\"88.77.66.55\"} // nolint\n\thostnames := []string{\"yahoo.com\"} // nolint\n\ttimestamp, _ := time.Parse(time.RFC3339, \"2019-08-09T08:29:35+00:00\")\n\n\tfakeCloudAssetChange := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames, timestamp, `arn`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tipAddress := \"88.77.66.55\" // nolint\n\tat, _ := time.Parse(time.RFC3339, \"2019-08-10T08:29:35+00:00\")\n\tnetworkChangeEvents, err := dbStorage.FetchByIP(ctx, at, ipAddress)\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tassert.Equal(t, 1, len(networkChangeEvents))\n\n\texpected := []domain.CloudAssetDetails{\n\t\tdomain.CloudAssetDetails{nil, []string{\"88.77.66.55\"}, []string{\"yahoo.com\"}, \"rtype\", \"aid\", \"region\", \"arn\", nil, domain.AccountOwner{}}, // nolint\n\t}\n\n\tassertArrayEqualIgnoreOrder(t, expected, networkChangeEvents)\n\n}", "func TestGetStatusByHostnameAtTimestamp1(t *testing.T) {\n\n\tbefore(t, dbStorage, dbSchema)\n\n\tprivateIPs := []string{\"44.33.22.11\"}\n\tpublicIPs := []string{\"88.77.66.55\"}\n\thostnames := []string{\"yahoo.com\"} // nolint\n\ttimestamp, _ := time.Parse(time.RFC3339, \"2019-08-09T08:29:35+00:00\")\n\n\tfakeCloudAssetChange := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames, timestamp, `arn`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\thostname := \"yahoo.com\" // nolint\n\tat, _ := time.Parse(time.RFC3339, \"2019-08-10T08:29:35+00:00\")\n\tnetworkChangeEvents, err := dbStorage.FetchByHostname(ctx, at, hostname)\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tassert.Equal(t, 1, len(networkChangeEvents))\n\n\texpected := []domain.CloudAssetDetails{\n\t\tdomain.CloudAssetDetails{ //nolint\n\t\t\tnil,\n\t\t\t[]string{\"88.77.66.55\"},\n\t\t\t[]string{\"yahoo.com\"},\n\t\t\t\"rtype\",\n\t\t\t\"aid\",\n\t\t\t\"region\",\n\t\t\t\"arn\",\n\t\t\tnil,\n\t\t\tdomain.AccountOwner{},\n\t\t},\n\t}\n\n\tassertArrayEqualIgnoreOrder(t, expected, networkChangeEvents)\n\n}", "func (m *MockStorage) Update(arg0 model.Car) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Update\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (_m *AWSResourceDescriptor) UpdateCRStatus(_a0 types.AWSResource) (bool, error) {\n\tret := _m.Called(_a0)\n\n\tvar r0 bool\n\tif rf, ok := ret.Get(0).(func(types.AWSResource) bool); ok {\n\t\tr0 = rf(_a0)\n\t} else {\n\t\tr0 = ret.Get(0).(bool)\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(types.AWSResource) error); ok {\n\t\tr1 = rf(_a0)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func (m *MockHandler) Update(ctx context.Context, exactType string, tasks []models.Task) error {\n\tret := m.ctrl.Call(m, \"Update\", ctx, exactType, tasks)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockRepository) Update(tag *models.RestTag) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Update\", tag)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (f MockFetch) Fetch(targetServer Server) ServerStatus {\n\tif targetServer.ID == 196 {\n\t\treturn ServerStatus{targetServer.ID, false, \"404\", targetServer.URL, time.Now()}\n\t}\n\treturn ServerStatus{targetServer.ID, true, \"\", targetServer.URL, time.Now()}\n}", "func (m *MockManager) LoadImage(arg0 context.Context, arg1 *config.Config, arg2 dockerapi.DockerClient) (*types.ImageInspect, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"LoadImage\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(*types.ImageInspect)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockRepoClient) LocalPath() (string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"LocalPath\")\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (_m *MockBookingStorage) Update(_a0 interface{}) {\n\t_m.Called(_a0)\n}", "func (_m *Repository) Update(ctx context.Context, _a1 *models.Host) error {\n\tret := _m.Called(ctx, _a1)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(context.Context, *models.Host) error); ok {\n\t\tr0 = rf(ctx, _a1)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func prepull(ctx context.Context, req types.FunctionDeployment, client *containerd.Client, alwaysPull bool) (containerd.Image, error) {\n\tstart := time.Now()\n\tr, err := reference.ParseNormalizedNamed(req.Image)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\timgRef := reference.TagNameOnly(r).String()\n\n\tsnapshotter := \"\"\n\tif val, ok := os.LookupEnv(\"snapshotter\"); ok {\n\t\tsnapshotter = val\n\t}\n\n\timage, err := service.PrepareImage(ctx, client, imgRef, snapshotter, alwaysPull)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to pull image %s\", imgRef)\n\t}\n\n\tsize, _ := image.Size(ctx)\n\tlog.Printf(\"Image for: %s size: %d, took: %fs\\n\", image.Name(), size, time.Since(start).Seconds())\n\n\treturn image, nil\n}", "func (suite *APIImageSaveLoadSuite) TestImageSaveLoadOk(c *check.C) {\n\tbefore, err := request.Get(\"/images/\" + busyboxImage125 + \"/json\")\n\tc.Assert(err, check.IsNil)\n\tCheckRespStatus(c, before, 200)\n\tgotBefore := types.ImageInfo{}\n\terr = request.DecodeBody(&gotBefore, before.Body)\n\tc.Assert(err, check.IsNil)\n\n\tq := url.Values{}\n\tq.Set(\"name\", busyboxImage125)\n\tquery := request.WithQuery(q)\n\tresp, err := request.Get(\"/images/save\", query)\n\tc.Assert(err, check.IsNil)\n\tdefer resp.Body.Close()\n\n\tdir, err := ioutil.TempDir(\"\", \"TestImageSaveLoadOk\")\n\tif err != nil {\n\t\tc.Errorf(\"failed to create a new temporary directory: %v\", err)\n\t}\n\tdefer os.RemoveAll(dir)\n\n\ttmpFile := filepath.Join(dir, \"busyboxImage.tar\")\n\tf, err := os.Create(tmpFile)\n\tif err != nil {\n\t\tc.Errorf(\"failed to create file: %v\", err)\n\t}\n\n\tif _, err := io.Copy(f, resp.Body); err != nil {\n\t\tc.Errorf(\"failed to save data to file: %v\", err)\n\t}\n\n\tdata, err := os.Open(tmpFile)\n\tif err != nil {\n\t\tc.Errorf(\"failed to load file's data: %v\", err)\n\t}\n\n\tloadImageName := \"load-busyboxImage\"\n\tq = url.Values{}\n\tq.Set(\"name\", loadImageName)\n\n\tquery = request.WithQuery(q)\n\treader := request.WithRawData(data)\n\theader := request.WithHeader(\"Content-Type\", \"application/x-tar\")\n\n\tresp, err = request.Post(\"/images/load\", query, reader, header)\n\tc.Assert(err, check.IsNil)\n\tCheckRespStatus(c, resp, 200)\n\n\tafter, err := request.Get(\"/images/\" + loadImageName + \":\" + environment.Busybox125Tag + \"/json\")\n\tc.Assert(err, check.IsNil)\n\tCheckRespStatus(c, after, 200)\n\tdefer request.Delete(\"/images/\" + loadImageName + \":\" + environment.Busybox125Tag)\n\n\tgotAfter := types.ImageInfo{}\n\terr = request.DecodeBody(&gotAfter, after.Body)\n\tc.Assert(err, check.IsNil)\n\n\tc.Assert(gotBefore.ID, check.Equals, gotAfter.ID)\n\tc.Assert(gotBefore.CreatedAt, check.Equals, gotAfter.CreatedAt)\n\tc.Assert(gotBefore.Size, check.Equals, gotAfter.Size)\n}", "func (m *MockInterface) UpdateStatus(ctx context.Context, persistentVolume *v1.PersistentVolume, opts metav1.UpdateOptions) (*v1.PersistentVolume, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"UpdateStatus\", ctx, persistentVolume, opts)\n\tret0, _ := ret[0].(*v1.PersistentVolume)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockFeiraStore) Update(ctx context.Context, id string, feira model.FeiraRequest) (string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Update\", ctx, id, feira)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (mc *MockContainer) ImagePull() error {\n\treturn mc.MockImagePull()\n}", "func PrepareBaseImage(ctx context.Context, ref string, output io.Writer) (err error) {\n\n\tcli, err := client.NewEnvClient()\n\tif err != nil {\n\t\treturn\n\t}\n\n\treader, err := cli.ImagePull(ctx, ref, types.ImagePullOptions{})\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer reader.Close()\n\n\tvar log pullLog\n\tstatus := make(map[string]string)\n\tscanner := bufio.NewScanner(reader)\n\tfor scanner.Scan() {\n\t\tjson.Unmarshal(scanner.Bytes(), &log)\n\t\tif log.ID != \"\" {\n\t\t\tcur := status[log.ID]\n\t\t\tif cur != log.Status {\n\t\t\t\tstatus[log.ID] = log.Status\n\t\t\t\tfmt.Fprintln(output, log.Status, log.ID)\n\t\t\t}\n\t\t} else {\n\t\t\tfmt.Fprintln(output, log.Status)\n\t\t}\n\t}\n\n\treturn\n\n}", "func (_m *CacheManager) Update(key string, o *objects.Object) bool {\n\tret := _m.Called(key, o)\n\n\tvar r0 bool\n\tif rf, ok := ret.Get(0).(func(string, *objects.Object) bool); ok {\n\t\tr0 = rf(key, o)\n\t} else {\n\t\tr0 = ret.Get(0).(bool)\n\t}\n\n\treturn r0\n}", "func fetch(hash string, endpoint string, original []byte, ruid string, tuid string) error {\n\tctx, sp := spancontext.StartSpan(context.Background(), \"upload-and-sync.fetch\")\n\tdefer sp.Finish()\n\n\tlog.Info(\"http get request\", \"tuid\", tuid, \"ruid\", ruid, \"endpoint\", endpoint, \"hash\", hash)\n\n\tvar tn time.Time\n\treqUri := endpoint + \"/bzz:/\" + hash + \"/\"\n\treq, _ := http.NewRequest(\"GET\", reqUri, nil)\n\n\topentracing.GlobalTracer().Inject(\n\t\tsp.Context(),\n\t\topentracing.HTTPHeaders,\n\t\topentracing.HTTPHeadersCarrier(req.Header))\n\n\ttrace := client.GetClientTrace(commandName+\" - http get\", commandName, ruid, &tn)\n\n\treq = req.WithContext(httptrace.WithClientTrace(ctx, trace))\n\ttransport := http.DefaultTransport\n\n\t//transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}\n\n\ttn = time.Now()\n\tres, err := transport.RoundTrip(req)\n\tif err != nil {\n\t\tlog.Error(err.Error(), \"ruid\", ruid)\n\t\treturn err\n\t}\n\tlog.Info(\"http get response\", \"tuid\", tuid, \"ruid\", ruid, \"endpoint\", endpoint, \"hash\", hash, \"code\", res.StatusCode, \"len\", res.ContentLength)\n\n\tif res.StatusCode != 200 {\n\t\terr := fmt.Errorf(\"expected status code %d, got %v\", 200, res.StatusCode)\n\t\tlog.Warn(err.Error(), \"ruid\", ruid)\n\t\treturn err\n\t}\n\n\tdefer res.Body.Close()\n\n\trdigest, err := digest(res.Body)\n\tif err != nil {\n\t\tlog.Warn(err.Error(), \"ruid\", ruid)\n\t\treturn err\n\t}\n\n\tif !bytes.Equal(rdigest, original) {\n\t\terr := fmt.Errorf(\"downloaded imported file md5=%x is not the same as the generated one=%x\", rdigest, original)\n\t\tlog.Warn(err.Error(), \"ruid\", ruid)\n\t\treturn err\n\t}\n\n\tlog.Trace(\"downloaded file matches random file\", \"ruid\", ruid, \"len\", res.ContentLength)\n\n\treturn nil\n}", "func (m *MockClientInterface) UpdateCustomResource(item *unstructured.Unstructured) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"UpdateCustomResource\", item)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (f FetchStruct) FetchFromRemote() *model.FetchResult {\n\trepo := f.Repo\n\tremoteURL := f.RemoteURL\n\tremoteBranch := f.RemoteBranch\n\trepoPath := f.RepoPath\n\n\tvar remoteDataObject RemoteDataInterface\n\tremoteDataObject = RemoteDataStruct{\n\t\tRepo: repo,\n\t\tRemoteURL: remoteURL,\n\t}\n\n\tremoteName := remoteDataObject.GetRemoteName()\n\tlogger := global.Logger{}\n\n\ttargetRefPsec := \"refs/heads/\" + remoteBranch + \":refs/remotes/\" + remoteBranch\n\tb := new(bytes.Buffer)\n\tvar fetchErr error\n\tgitSSHAuth, sshErr := ssh.NewSSHAgentAuth(\"git\")\n\tw, _ := repo.Worktree()\n\n\t// Check if repo path is empty and fetch path from worktree\n\tif repoPath == \"\" {\n\t\trepoPath = w.Filesystem.Root()\n\t}\n\n\tif sshErr != nil {\n\t\tlogger.Log(\"Authentication method failed -> \"+sshErr.Error(), global.StatusError)\n\t\tif w == nil {\n\t\t\treturn &model.FetchResult{\n\t\t\t\tStatus: global.FetchFromRemoteError,\n\t\t\t\tFetchedItems: nil,\n\t\t\t}\n\t\t}\n\t\tlogger.Log(\"Retrying fetch with fallback module using git client\", global.StatusWarning)\n\t\treturn f.windowsFetch()\n\t}\n\n\tlogger.Log(fmt.Sprintf(\"Fetching changes from -> %s : %s\", remoteURL, targetRefPsec), global.StatusInfo)\n\n\tif remoteURL != \"\" && remoteBranch != \"\" {\n\t\tif remoteName == \"\" {\n\t\t\treturn &model.FetchResult{\n\t\t\t\tStatus: global.FetchFromRemoteError,\n\t\t\t\tFetchedItems: nil,\n\t\t\t}\n\t\t}\n\n\t\tfetchErr = repo.Fetch(&git.FetchOptions{\n\t\t\tRemoteName: remoteName,\n\t\t\tAuth: gitSSHAuth,\n\t\t\tRefSpecs: []config.RefSpec{config.RefSpec(targetRefPsec)},\n\t\t\tProgress: sideband.Progress(func(f io.Writer) io.Writer {\n\t\t\t\treturn f\n\t\t\t}(b)),\n\t\t})\n\t} else {\n\t\tfetchErr = repo.Fetch(&git.FetchOptions{\n\t\t\tRemoteName: git.DefaultRemoteName,\n\t\t\tAuth: gitSSHAuth,\n\t\t\tProgress: sideband.Progress(func(f io.Writer) io.Writer {\n\t\t\t\treturn f\n\t\t\t}(b)),\n\t\t})\n\t}\n\n\tif fetchErr != nil {\n\t\tif fetchErr.Error() == \"already up-to-date\" {\n\t\t\tlogger.Log(fetchErr.Error(), global.StatusWarning)\n\t\t\treturn &model.FetchResult{\n\t\t\t\tStatus: global.FetchNoNewChanges,\n\t\t\t\tFetchedItems: nil,\n\t\t\t}\n\t\t} else {\n\t\t\tlogger.Log(fetchErr.Error(), global.StatusError)\n\t\t\tlogger.Log(\"Fetch failed. Retrying fetch with git client\", global.StatusWarning)\n\t\t\treturn f.windowsFetch()\n\t\t}\n\n\t} else {\n\t\tlogger.Log(b.String(), global.StatusInfo)\n\t\tlogger.Log(\"Changes fetched from remote\", global.StatusInfo)\n\n\t\tmsg := fmt.Sprintf(\"Changes fetched from remote %v\", remoteName)\n\t\treturn &model.FetchResult{\n\t\t\tStatus: global.FetchFromRemoteSuccess,\n\t\t\tFetchedItems: []*string{&msg},\n\t\t}\n\t}\n\n}", "func updateImageResource(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {\n\t// Warning or errors can be collected in a slice type\n\tvar diags diag.Diagnostics\n\n\tclient := (meta.(Client)).Client\n\tname := rdEntryStr(d, \"name\")\n\tid := rdEntryStr(d, \"id\")\n\terrMsgPrefix := getErrMsgPrefix(\"Image\", name, id, \"Update\")\n\tif client == nil {\n\t\treturn diag.Errorf(\"%s nil Client\", errMsgPrefix)\n\t}\n\tcfg, err := getImage(client, name, id)\n\tif err != nil {\n\t\treturn diag.Errorf(\"%s err: %s\", errMsgPrefix, err.Error())\n\t}\n\tlog.Printf(\"[INFO] Updating Image: %s (ID: %s)\", name, cfg.ID)\n\terr = updateImageCfgFromResourceData(cfg, d)\n\tif err != nil {\n\t\treturn diag.Errorf(\"%s err: %s\", errMsgPrefix, err.Error())\n\t}\n\tclient.XRequestIdPrefix = \"TF-image-update\"\n\turlExtension := getImageUrl(name, id, \"update\")\n\trspData := &swagger_models.ZsrvResponse{}\n\t_, err = client.SendReq(\"PUT\", urlExtension, cfg, rspData)\n\tif err != nil {\n\t\treturn diag.Errorf(\"%s Request Failed. err: %s\", errMsgPrefix, err.Error())\n\t}\n\treturn diags\n}", "func (m *MockStorage) Get(ctx context.Context, id string) (*storage.ImageModel, error) {\n\tret := m.ctrl.Call(m, \"Get\", ctx, id)\n\tret0, _ := ret[0].(*storage.ImageModel)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockClientInterface) UpdateCustomResourceRaw(apiGroup, version, namespace, resourceKind, resourceName string, data []byte) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"UpdateCustomResourceRaw\", apiGroup, version, namespace, resourceKind, resourceName, data)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockCompute) ImageIDFromName(arg0 string) (string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ImageIDFromName\", arg0)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func createImageMirrorForInternalImages(prefix string, ref reference.DockerImageReference, mirrored bool) ([]string, error) {\n\tsource := ref.Exact()\n\n\tinitialDefaults := k8simage.GetOriginalImageConfigs()\n\texceptions := image.Exceptions.List()\n\tdefaults := map[k8simage.ImageID]k8simage.Config{}\n\nimageLoop:\n\tfor i, config := range initialDefaults {\n\t\tfor _, exception := range exceptions {\n\t\t\tif strings.Contains(config.GetE2EImage(), exception) {\n\t\t\t\tcontinue imageLoop\n\t\t\t}\n\t\t}\n\t\tdefaults[i] = config\n\t}\n\n\tupdated := k8simage.GetMappedImageConfigs(defaults, ref.Exact())\n\topenshiftDefaults := image.OriginalImages()\n\topenshiftUpdated := image.GetMappedImages(openshiftDefaults, imagesetup.DefaultTestImageMirrorLocation)\n\n\t// if we've mirrored, then the source is going to be our repo, not upstream's\n\tif mirrored {\n\t\tbaseRef, err := reference.Parse(imagesetup.DefaultTestImageMirrorLocation)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid default mirror location: %v\", err)\n\t\t}\n\n\t\t// calculate the mapping of upstream images by setting defaults to baseRef\n\t\tcovered := sets.NewString()\n\t\tfor i, config := range updated {\n\t\t\tdefaultConfig := defaults[i]\n\t\t\tpullSpec := config.GetE2EImage()\n\t\t\tif pullSpec == defaultConfig.GetE2EImage() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif covered.Has(pullSpec) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tcovered.Insert(pullSpec)\n\t\t\te2eRef, err := reference.Parse(pullSpec)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid test image: %s: %v\", pullSpec, err)\n\t\t\t}\n\t\t\tif len(e2eRef.Tag) == 0 {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid test image: %s: no tag\", pullSpec)\n\t\t\t}\n\t\t\tconfig.SetRegistry(baseRef.Registry)\n\t\t\tconfig.SetName(baseRef.RepositoryName())\n\t\t\tconfig.SetVersion(e2eRef.Tag)\n\t\t\tdefaults[i] = config\n\t\t}\n\n\t\t// calculate the mapping for openshift images by populating openshiftUpdated\n\t\topenshiftUpdated = make(map[string]string)\n\t\tsourceMappings := image.GetMappedImages(openshiftDefaults, imagesetup.DefaultTestImageMirrorLocation)\n\t\ttargetMappings := image.GetMappedImages(openshiftDefaults, source)\n\n\t\tfor from, to := range targetMappings {\n\t\t\tif from == to {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif covered.Has(to) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tcovered.Insert(to)\n\t\t\tfrom := sourceMappings[from]\n\t\t\topenshiftUpdated[from] = to\n\t\t}\n\t}\n\n\tcovered := sets.NewString()\n\tvar lines []string\n\tfor i := range updated {\n\t\ta, b := defaults[i], updated[i]\n\t\tfrom, to := a.GetE2EImage(), b.GetE2EImage()\n\t\tif from == to {\n\t\t\tcontinue\n\t\t}\n\t\tif covered.Has(from) {\n\t\t\tcontinue\n\t\t}\n\t\tcovered.Insert(from)\n\t\tlines = append(lines, fmt.Sprintf(\"%s %s%s\", from, prefix, to))\n\t}\n\n\tfor from, to := range openshiftUpdated {\n\t\tif from == to {\n\t\t\tcontinue\n\t\t}\n\t\tif covered.Has(from) {\n\t\t\tcontinue\n\t\t}\n\t\tcovered.Insert(from)\n\t\tlines = append(lines, fmt.Sprintf(\"%s %s%s\", from, prefix, to))\n\t}\n\n\tsort.Strings(lines)\n\treturn lines, nil\n}", "func notifyNewImage(basePath, imageUrl string) error {\n\thook := os.Getenv(\"WEB_HOOK\")\n\tif hook == \"\" {\n\t\treturn nil\n\t}\n\n\ttype photo struct {\n\t\tUrl string `json:\"remote_url\"`\n\t}\n\n\ttype payload struct {\n\t\tPhoto *photo `json:\"photo\"`\n\t}\n\n\tbody := &payload{&photo{Url: imageUrl}}\n\tb, err := json.Marshal(body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfullURL := fmt.Sprintf(\"%s/buckets/%s/photos.json\", hook, basePath)\n\n\tlog.Infof(\"Notifying hook at %s\", fullURL)\n\n\treq, err := http.NewRequest(\"POST\", fullURL, bytes.NewBuffer(b))\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode < 200 || resp.StatusCode > 299 {\n\t\treturn fmt.Errorf(\"expecting status code in 200 .. 299 got %d\", resp.StatusCode)\n\t}\n\tlog.Infof(\"Notification sent to %s\", hook)\n\treturn nil\n}", "func (c *repoCacheManager) updateImages(ctx context.Context, images []imageToUpdate) (map[string]image.Info, int, int) {\n\t// The upper bound for concurrent fetches against a single host is\n\t// w.Burst, so limit the number of fetching goroutines to that.\n\tfetchers := make(chan struct{}, c.burst)\n\tawaitFetchers := &sync.WaitGroup{}\n\n\tctxc, cancel := context.WithCancel(ctx)\n\tdefer cancel()\n\n\tvar successCount int\n\tvar manifestUnknownCount int\n\tvar result = map[string]image.Info{}\n\tvar warnAboutRateLimit sync.Once\nupdates:\n\tfor _, up := range images {\n\t\t// to avoid race condition, when accessing it in the go routine\n\t\tupCopy := up\n\t\tselect {\n\t\tcase <-ctxc.Done():\n\t\t\tbreak updates\n\t\tcase fetchers <- struct{}{}:\n\t\t}\n\t\tawaitFetchers.Add(1)\n\t\tgo func() {\n\t\t\tdefer func() { awaitFetchers.Done(); <-fetchers }()\n\t\t\tctxcc, cancel := context.WithTimeout(ctxc, c.clientTimeout)\n\t\t\tdefer cancel()\n\t\t\tentry, err := c.updateImage(ctxcc, upCopy)\n\t\t\tif err != nil {\n\t\t\t\tif err, ok := errors.Cause(err).(net.Error); (ok && err.Timeout()) || ctxcc.Err() == context.DeadlineExceeded {\n\t\t\t\t\t// This was due to a context timeout, don't bother logging\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tswitch {\n\t\t\t\tcase strings.Contains(err.Error(), \"429\"), strings.Contains(err.Error(), \"toomanyrequests\"):\n\t\t\t\t\t// abort the image tags fetching if we've been rate limited\n\t\t\t\t\twarnAboutRateLimit.Do(func() {\n\t\t\t\t\t\tc.logger.Log(\"warn\", \"aborting image tag fetching due to rate limiting, will try again later\")\n\t\t\t\t\t\tcancel()\n\t\t\t\t\t})\n\t\t\t\tcase strings.Contains(err.Error(), \"manifest unknown\"):\n\t\t\t\t\t// Registry is corrupted, keep going, this manifest may not be relevant for automatic updates\n\t\t\t\t\tc.Lock()\n\t\t\t\t\tmanifestUnknownCount++\n\t\t\t\t\tc.Unlock()\n\t\t\t\t\tc.logger.Log(\"warn\", fmt.Sprintf(\"manifest for tag %s missing in repository %s\", up.ref.Tag, up.ref.Name),\n\t\t\t\t\t\t\"impact\", \"flux will fail to auto-release workloads with matching images, ask the repository administrator to fix the inconsistency\")\n\t\t\t\tdefault:\n\t\t\t\t\tc.logger.Log(\"err\", err, \"ref\", up.ref)\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t\tc.Lock()\n\t\t\tsuccessCount++\n\t\t\tif entry.ExcludedReason == \"\" {\n\t\t\t\tresult[upCopy.ref.Tag] = entry.Info\n\t\t\t}\n\t\t\tc.Unlock()\n\t\t}()\n\t}\n\tawaitFetchers.Wait()\n\treturn result, successCount, manifestUnknownCount\n}", "func (m *MockRepository) Update(e *entity.StreetMarket) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Update\", e)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockCustomResourceClient) UpdateCustomResourceRaw(apiGroup, version, namespace, resourceKind, resourceName string, data []byte) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"UpdateCustomResourceRaw\", apiGroup, version, namespace, resourceKind, resourceName, data)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockCacheService) FetchFromCache(pagination model.Pagination) (model.Response, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"FetchFromCache\", pagination)\n\tret0, _ := ret[0].(model.Response)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func testDownloadImages(ctx context.Context, t *testing.T, downloadCh chan<- downloadRequest, addr, ccvmDir string) {\n\twkld := &workload{\n\t\tspec: workloadSpec{\n\t\t\tBaseImageURL: \"http://\" + addr + \"/download/image\",\n\t\t\tBIOS: \"http://\" + addr + \"/download/bios\",\n\t\t},\n\t}\n\n\tresultCh := make(chan interface{})\n\tgo func() {\n\t\timg, bios, err := downloadImages(ctx, wkld, http.DefaultTransport.(*http.Transport),\n\t\t\tresultCh, downloadCh)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Failed to download images: %v\", err)\n\t\t}\n\t\tif len(img) == 0 || len(bios) == 0 {\n\t\t\tt.Errorf(\"One the paths is empty img=%s bios=%s\", img, bios)\n\t\t}\n\t\tclose(resultCh)\n\t}()\n\n\tfor range resultCh {\n\t}\n\n\twkld.spec.BIOS = \"ftp://\" + addr + \"/download/bios\"\n\tresultCh = make(chan interface{})\n\tgo func() {\n\t\t_, _, err := downloadImages(ctx, wkld, http.DefaultTransport.(*http.Transport),\n\t\t\tresultCh, downloadCh)\n\t\tif err == nil {\n\t\t\tt.Errorf(\"Expected downloadImages with bad BIOS URL to fail\")\n\t\t}\n\t\tclose(resultCh)\n\t}()\n\n\tfor range resultCh {\n\t}\n}", "func (m *MockFoldersRepo) Update(arg0 domain.Folder) (domain.Folder, error) {\n\tret := m.ctrl.Call(m, \"Update\", arg0)\n\tret0, _ := ret[0].(domain.Folder)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func testUpdateOperationHandlerGet(t *testing.T) {\n\tt.Parallel()\n\n\tid := uuid.New()\n\tidStr := \"\\\"\" + id.String() + \"\\\"\"\n\tvar called bool\n\tvar latestCalled bool\n\th := UpdateOperationHandler(&matcher.Mock{\n\t\tLatestUpdateOperation_: func(context.Context, driver.UpdateKind) (uuid.UUID, error) {\n\t\t\treturn id, nil\n\t\t},\n\t\tLatestUpdateOperations_: func(context.Context, driver.UpdateKind) (map[string][]driver.UpdateOperation, error) {\n\t\t\tlatestCalled = true\n\t\t\treturn nil, nil\n\t\t},\n\t\tUpdateOperations_: func(context.Context, driver.UpdateKind, ...string) (map[string][]driver.UpdateOperation, error) {\n\t\t\tcalled = true\n\t\t\treturn nil, nil\n\t\t},\n\t})\n\tsrv := httptest.NewServer(h)\n\tdefer srv.Close()\n\tc := srv.Client()\n\n\t// get without latest param\n\treq, err := http.NewRequest(http.MethodGet, srv.URL, nil)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to create request: %v\", err)\n\t}\n\tresp, err := c.Do(req)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to make request: %v\", err)\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\tt.Fatalf(\"got: %v, want: %v\", resp.StatusCode, http.StatusOK)\n\t}\n\tif !called {\n\t\tt.Fatalf(\"got: %v, want: %v\", called, true)\n\t}\n\tetag := resp.Header.Get(\"etag\")\n\tif etag != idStr {\n\t\tt.Fatalf(\"got: %v, want: %v\", etag, id.String())\n\t}\n\n\t// get with latest param\n\tu, _ := url.Parse(srv.URL)\n\tq := u.Query()\n\tq.Add(\"latest\", \"true\")\n\tu.RawQuery = q.Encode()\n\treq = &http.Request{\n\t\tURL: u,\n\t\tMethod: http.MethodGet,\n\t}\n\tresp, err = c.Do(req)\n\tif err != nil {\n\t\tt.Fatalf(\"failed to make request: %v\", err)\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\tt.Fatalf(\"got: %v, want: %v\", resp.StatusCode, http.StatusOK)\n\t}\n\tif !latestCalled {\n\t\tt.Fatalf(\"got: %v, want: %v\", latestCalled, true)\n\t}\n\tetag = resp.Header.Get(\"etag\")\n\tif etag != idStr {\n\t\tt.Fatalf(\"got: %v, want: %v\", etag, id.String())\n\t}\n}", "func (m *MockImageTransferer) Download(arg0 string, arg1 core.Digest) (base.FileReader, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Download\", arg0, arg1)\n\tret0, _ := ret[0].(base.FileReader)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func dirImageMockWithRef(t *testing.T, dir string, ref types.ImageReference) private.UnparsedImage {\n\tsrcRef, err := directory.NewReference(dir)\n\trequire.NoError(t, err)\n\tsrc, err := srcRef.NewImageSource(context.Background(), nil)\n\trequire.NoError(t, err)\n\tt.Cleanup(func() {\n\t\terr := src.Close()\n\t\trequire.NoError(t, err)\n\t})\n\treturn image.UnparsedInstance(&dirImageSourceMock{\n\t\tImageSource: imagesource.FromPublic(src),\n\t\tref: ref,\n\t}, nil)\n}", "func MockRoundUpdate(round uint64, p *user.Provisioners) RoundUpdate {\n\tprovisioners := p\n\tif p == nil {\n\t\tprovisioners, _ = MockProvisioners(1)\n\t}\n\n\tseed, _ := crypto.RandEntropy(33)\n\thash, _ := crypto.RandEntropy(32)\n\n\treturn RoundUpdate{\n\t\tRound: round,\n\t\tP: *provisioners,\n\t\tSeed: seed,\n\t\tHash: hash,\n\t\tLastCertificate: block.EmptyCertificate(),\n\t}\n}", "func (m *MockFamilyRepo) Update(arg0 models.Family) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Update\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockRepositoryClient) UpdateRepoLabel(org, repo, label, newName, description, color string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"UpdateRepoLabel\", org, repo, label, newName, description, color)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (mr *MockFetcherMockRecorder) FetchLocalImage(arg0 interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"FetchLocalImage\", reflect.TypeOf((*MockFetcher)(nil).FetchLocalImage), arg0)\n}", "func ServerTestBattery(t *testing.T, wrap func(mock api.Server) api.Server) {\n\t// set up\n\tnamespace := \"the-space-of-names\"\n\tserviceID := resource.MustParseID(namespace + \"/service\")\n\tserviceList := []resource.ID{serviceID}\n\tservices := resource.IDSet{}\n\tservices.Add(serviceList)\n\n\tnow := time.Now().UTC()\n\n\timageID, _ := image.ParseRef(\"quay.io/example.com/frob:v0.4.5\")\n\tserviceAnswer := []v6.ControllerStatus{\n\t\tv6.ControllerStatus{\n\t\t\tID: resource.MustParseID(\"foobar/hello\"),\n\t\t\tStatus: \"ok\",\n\t\t\tContainers: []v6.Container{\n\t\t\t\tv6.Container{\n\t\t\t\t\tName: \"frobnicator\",\n\t\t\t\t\tCurrent: image.Info{\n\t\t\t\t\t\tID: imageID,\n\t\t\t\t\t\tCreatedAt: now,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tv6.ControllerStatus{},\n\t}\n\n\timagesAnswer := []v6.ImageStatus{\n\t\tv6.ImageStatus{\n\t\t\tID: resource.MustParseID(\"barfoo/yello\"),\n\t\t\tContainers: []v6.Container{\n\t\t\t\t{\n\t\t\t\t\tName: \"flubnicator\",\n\t\t\t\t\tCurrent: image.Info{\n\t\t\t\t\t\tID: imageID,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tsyncStatusAnswer := []string{\n\t\t\"commit 1\",\n\t\t\"commit 2\",\n\t\t\"commit 3\",\n\t}\n\n\tupdateSpec := update.Spec{\n\t\tType: update.Images,\n\t\tSpec: update.ReleaseImageSpec{\n\t\t\tServiceSpecs: []update.ResourceSpec{\n\t\t\t\tupdate.ResourceSpecAll,\n\t\t\t},\n\t\t\tImageSpec: update.ImageSpecLatest,\n\t\t},\n\t}\n\tcheckUpdateSpec := func(s update.Spec) error {\n\t\tif !reflect.DeepEqual(updateSpec, s) {\n\t\t\treturn errors.New(\"expected != actual\")\n\t\t}\n\t\treturn nil\n\t}\n\n\tmock := &MockServer{\n\t\tListServicesAnswer: serviceAnswer,\n\t\tListImagesAnswer: imagesAnswer,\n\t\tUpdateManifestsArgTest: checkUpdateSpec,\n\t\tUpdateManifestsAnswer: job.ID(guid.New()),\n\t\tSyncStatusAnswer: syncStatusAnswer,\n\t}\n\n\tctx := context.Background()\n\n\t// OK, here we go\n\tclient := wrap(mock)\n\n\tif err := client.Ping(ctx); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tss, err := client.ListServices(ctx, namespace)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif !reflect.DeepEqual(ss, mock.ListServicesAnswer) {\n\t\tt.Error(fmt.Errorf(\"expected:\\n%#v\\ngot:\\n%#v\", mock.ListServicesAnswer, ss))\n\t}\n\tmock.ListServicesError = fmt.Errorf(\"list services query failure\")\n\tss, err = client.ListServices(ctx, namespace)\n\tif err == nil {\n\t\tt.Error(\"expected error from ListServices, got nil\")\n\t}\n\n\tims, err := client.ListImagesWithOptions(ctx, v10.ListImagesOptions{\n\t\tSpec: update.ResourceSpecAll,\n\t})\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif !reflect.DeepEqual(ims, mock.ListImagesAnswer) {\n\t\tt.Error(fmt.Errorf(\"expected:\\n%#v\\ngot:\\n%#v\", mock.ListImagesAnswer, ims))\n\t}\n\tmock.ListImagesError = fmt.Errorf(\"list images error\")\n\tif _, err = client.ListImagesWithOptions(ctx, v10.ListImagesOptions{\n\t\tSpec: update.ResourceSpecAll,\n\t}); err == nil {\n\t\tt.Error(\"expected error from ListImages, got nil\")\n\t}\n\n\tjobid, err := mock.UpdateManifests(ctx, updateSpec)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif jobid != mock.UpdateManifestsAnswer {\n\t\tt.Error(fmt.Errorf(\"expected %q, got %q\", mock.UpdateManifestsAnswer, jobid))\n\t}\n\tmock.UpdateManifestsError = fmt.Errorf(\"update manifests error\")\n\tif _, err = client.UpdateManifests(ctx, updateSpec); err == nil {\n\t\tt.Error(\"expected error from UpdateManifests, got nil\")\n\t}\n\n\tchange := v9.Change{Kind: v9.GitChange, Source: v9.GitUpdate{URL: \"git@example.com:foo/bar\"}}\n\tif err := client.NotifyChange(ctx, change); err != nil {\n\t\tt.Error(err)\n\t}\n\n\tsyncSt, err := client.SyncStatus(ctx, \"HEAD\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif !reflect.DeepEqual(mock.SyncStatusAnswer, syncSt) {\n\t\tt.Errorf(\"expected: %#v\\ngot: %#v\", mock.SyncStatusAnswer, syncSt)\n\t}\n}", "func (f *SourceFetcher) Fetch(url string, namespace string) (*info.ImageProperties, bool, error) {\n\tc := make(chan FetchResult)\n\tgo f.uniqueFetchSource(c, url, namespace)\n\tr := <-c\n\treturn r.ImageDetails, r.Downloaded, r.Error\n}", "func TestGetStatusByHostnameAtTimestamp4(t *testing.T) {\n\n\tbefore(t, dbStorage, dbSchema)\n\n\tprivateIPs := []string{\"44.33.22.11\"}\n\tpublicIPs := []string{\"88.77.66.55\"} // nolint\n\thostnames := []string{\"yahoo.com\"} // nolint\n\ttimestamp, _ := time.Parse(time.RFC3339, \"2019-08-09T08:29:35+00:00\")\n\n\tfakeCloudAssetChange := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames, timestamp, `arn`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\ttimestamp2, _ := time.Parse(time.RFC3339, \"2019-08-12T08:29:35+00:00\") // August 12\n\tprivateIPs2 := []string{\"4.3.2.1\"}\n\tpublicIPs2 := []string{\"8.7.6.5\"}\n\tfakeCloudAssetChange2 := newFakeCloudAssetChange(privateIPs2, publicIPs2, hostnames, timestamp2, `arn2`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange2); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\thostname := \"yahoo.com\" // nolint\n\tat, _ := time.Parse(time.RFC3339, \"2019-08-11T08:29:35+00:00\") // query is for status on August 11\n\tnetworkChangeEvents, err := dbStorage.FetchByHostname(ctx, at, hostname)\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tassert.Equal(t, 1, len(networkChangeEvents))\n\n\texpected := []domain.CloudAssetDetails{\n\t\tdomain.CloudAssetDetails{nil, []string{\"88.77.66.55\"}, []string{\"yahoo.com\"}, \"rtype\", \"aid\", \"region\", \"arn\", nil, domain.AccountOwner{}}, // nolint\n\t}\n\n\tassertArrayEqualIgnoreOrder(t, expected, networkChangeEvents)\n\n}", "func (f *fetcher) fetchImage(img string, asc string, discover bool) (string, error) {\n\tif f.withDeps && !discover {\n\t\treturn \"\", fmt.Errorf(\"cannot fetch image's dependencies with discovery disabled\")\n\t}\n\thash, err := f.fetchSingleImage(img, asc, discover)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif f.withDeps {\n\t\terr = f.fetchImageDeps(hash)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\treturn hash, nil\n}", "func TestUpdate(t *testing.T) {\n\n\t// Test Data\n\tk8sNamespace1 := \"TestK8SNamespace1\"\n\tk8sNamespace2 := \"TestK8SNamespace2\"\n\n\tkafkaSecretName1 := \"TestKafkaSecretName1\"\n\tkafkaSecretName2 := \"TestKafkaSecretName2\"\n\tkafkaSecretName3 := \"TestKafkaSecretName3\"\n\n\tkafkaSecretBrokers1 := \"TestKafkaSecretBrokers1\"\n\tkafkaSecretBrokers2 := \"TestKafkaSecretBrokers2\"\n\tkafkaSecretBrokers3 := \"TestKafkaSecretBrokers3\"\n\n\tkafkaSecretUsername1 := \"TestKafkaSecretUsername1\"\n\tkafkaSecretUsername2 := \"TestKafkaSecretUsername2\"\n\tkafkaSecretUsername3 := \"TestKafkaSecretUsername3\"\n\n\tkafkaSecretPassword1 := \"TestKafkaSecretPassword1\"\n\tkafkaSecretPassword2 := \"TestKafkaSecretPassword2\"\n\tkafkaSecretPassword3 := \"TestKafkaSecretPassword3\"\n\n\tkafkaSecretNamespace1 := \"TestKafkaSecretNamespace1\"\n\tkafkaSecretNamespace2 := \"TestKafkaSecretNamespace2\"\n\tkafkaSecretNamespace3 := \"TestKafkaSecretNamespace3\"\n\n\tkafkaSecret1 := createKafkaSecret(kafkaSecretName1, k8sNamespace1, kafkaSecretBrokers1, kafkaSecretUsername1, kafkaSecretPassword1, kafkaSecretNamespace1)\n\tkafkaSecret2 := createKafkaSecret(kafkaSecretName2, k8sNamespace1, kafkaSecretBrokers2, kafkaSecretUsername2, kafkaSecretPassword2, kafkaSecretNamespace2)\n\tkafkaSecret3 := createKafkaSecret(kafkaSecretName3, k8sNamespace2, kafkaSecretBrokers3, kafkaSecretUsername3, kafkaSecretPassword3, kafkaSecretNamespace3)\n\n\tHubEntityName1 := \"TestHubEntityName1\"\n\tHubEntityName2 := \"TestHubEntityName2\"\n\tHubEntityName3 := \"TestHubEntityName3\"\n\n\thubEntity1 := createEventHubEntity(HubEntityName1)\n\thubEntity2 := createEventHubEntity(HubEntityName2)\n\thubEntity3 := createEventHubEntity(HubEntityName3)\n\n\t// Create A Test Logger\n\tlogger := logtesting.TestLogger(t).Desugar()\n\n\t// Create A Cache To Test\n\tcache := &Cache{\n\t\tlogger: logger,\n\t\tk8sClient: fake.NewSimpleClientset(kafkaSecret1, kafkaSecret2, kafkaSecret3),\n\t\tk8sNamespace: k8sNamespace1,\n\t\tnamespaceMap: make(map[string]*Namespace),\n\t\teventhubMap: make(map[string]*Namespace),\n\t}\n\n\t// Create Some Mock HubManagers To Return EventHubs For Azure Namespace List Queries\n\tmockHubManager1 := &MockHubManager{ListHubEntities: []*eventhub.HubEntity{hubEntity1, hubEntity2}}\n\tmockHubManager2 := &MockHubManager{ListHubEntities: []*eventhub.HubEntity{hubEntity3}}\n\n\t// Replace The NewHubManagerFromConnectionString Wrapper To Provide Mock Implementation & Defer Reset\n\tnewHubManagerFromConnectionStringWrapperPlaceholder := NewHubManagerFromConnectionStringWrapper\n\tNewHubManagerFromConnectionStringWrapper = func(connectionString string) (managerInterface HubManagerInterface, e error) {\n\t\tif strings.Contains(connectionString, kafkaSecretPassword1) {\n\t\t\treturn mockHubManager1, nil\n\t\t} else if strings.Contains(connectionString, kafkaSecretPassword2) {\n\t\t\treturn mockHubManager2, nil\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"unexpected test connectionString '%s'\", connectionString)\n\t\t}\n\t}\n\tdefer func() { NewHubManagerFromConnectionStringWrapper = newHubManagerFromConnectionStringWrapperPlaceholder }()\n\n\t// Perform The Test\n\terr := cache.Update(context.TODO())\n\n\t// Verify Results\n\tassert.Nil(t, err)\n\tassert.Len(t, cache.eventhubMap, 3) // The Number Of HubEntities Returned From List\n\tcacheEventHubNamespace1 := cache.eventhubMap[hubEntity1.Name]\n\tcacheEventHubNamespace2 := cache.eventhubMap[hubEntity2.Name]\n\tcacheEventHubNamespace3 := cache.eventhubMap[hubEntity3.Name]\n\tassert.NotNil(t, cacheEventHubNamespace1)\n\tassert.NotNil(t, cacheEventHubNamespace2)\n\tassert.NotNil(t, cacheEventHubNamespace3)\n\tassert.Equal(t, kafkaSecretNamespace1, cacheEventHubNamespace1.Name)\n\tassert.Equal(t, kafkaSecretNamespace1, cacheEventHubNamespace2.Name)\n\tassert.Equal(t, kafkaSecretNamespace2, cacheEventHubNamespace3.Name)\n}", "func (m *MockRepository) FetchAll(bucketName string, modelFn func([]byte) (db.Model, error)) (interface{}, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"FetchAll\", bucketName, modelFn)\n\tret0, _ := ret[0].(interface{})\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func TestGetStatusByHostnameAtTimestamp3(t *testing.T) {\n\n\tbefore(t, dbStorage, dbSchema)\n\n\tprivateIPs := []string{\"44.33.22.11\"}\n\tpublicIPs := []string{\"88.77.66.55\"} // nolint\n\thostnames := []string{\"yahoo.com\"} // nolint\n\ttimestamp, _ := time.Parse(time.RFC3339, \"2019-08-09T08:29:35+00:00\")\n\n\tfakeCloudAssetChange := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames, timestamp, `arn`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\ttimestamp2, _ := time.Parse(time.RFC3339, \"2019-08-11T08:29:35+00:00\") // August 11\n\tprivateIPs2 := []string{\"4.3.2.1\"}\n\tpublicIPs2 := []string{\"8.7.6.5\"}\n\tfakeCloudAssetChange2 := newFakeCloudAssetChange(privateIPs2, publicIPs2, hostnames, timestamp2, `arn2`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange2); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\thostname := \"yahoo.com\" // nolint\n\tat, _ := time.Parse(time.RFC3339, \"2019-08-12T08:29:35+00:00\") // query is for status on August 12\n\tnetworkChangeEvents, err := dbStorage.FetchByHostname(ctx, at, hostname)\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tassert.Equal(t, 2, len(networkChangeEvents))\n\n\texpected := []domain.CloudAssetDetails{\n\t\tdomain.CloudAssetDetails{nil, []string{\"88.77.66.55\"}, []string{\"yahoo.com\"}, \"rtype\", \"aid\", \"region\", \"arn\", nil, domain.AccountOwner{}}, // nolint\n\t\tdomain.CloudAssetDetails{nil, []string{\"8.7.6.5\"}, []string{\"yahoo.com\"}, \"rtype\", \"aid\", \"region\", \"arn2\", nil, domain.AccountOwner{}}, // nolint\n\t}\n\n\tassertArrayEqualIgnoreOrder(t, expected, networkChangeEvents)\n\n}", "func (m *MockService) Update(arg0 interface{}) error {\n\tret := m.ctrl.Call(m, \"Update\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockAPI) RefreshStatus(arg0 context.Context, arg1 *models.Host, arg2 *gorm.DB) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"RefreshStatus\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}" ]
[ "0.7315873", "0.6466252", "0.621011", "0.58941764", "0.5832389", "0.5714767", "0.57144743", "0.5696898", "0.56600785", "0.5652856", "0.5563077", "0.5445605", "0.54443705", "0.5374082", "0.53736216", "0.5362618", "0.5343925", "0.533864", "0.532144", "0.53188276", "0.5303848", "0.5292312", "0.5290114", "0.5281899", "0.52689815", "0.5256937", "0.5243443", "0.51999325", "0.51975834", "0.5187384", "0.51852524", "0.5174279", "0.5172064", "0.5162931", "0.51595217", "0.51483405", "0.5134183", "0.5121002", "0.5106018", "0.5079694", "0.5070232", "0.50697476", "0.506625", "0.50638455", "0.50460374", "0.50445884", "0.50182384", "0.5012236", "0.50102895", "0.5002038", "0.49830067", "0.49820563", "0.49805045", "0.4973599", "0.49644107", "0.4958075", "0.49558002", "0.4953657", "0.49455148", "0.4937509", "0.49309063", "0.492474", "0.4921105", "0.49199718", "0.4910066", "0.49026412", "0.490193", "0.4897672", "0.4892741", "0.48926032", "0.48921138", "0.4889113", "0.48882192", "0.48837382", "0.48828596", "0.48774096", "0.48751155", "0.48744744", "0.4873111", "0.48719501", "0.48701808", "0.48655865", "0.48641217", "0.48626474", "0.4857851", "0.48533094", "0.48415402", "0.4840228", "0.4840204", "0.48379937", "0.48353893", "0.48313665", "0.48291758", "0.4828443", "0.48241717", "0.48183075", "0.4814759", "0.48138478", "0.480723", "0.48052147" ]
0.805092
0
getRewardHistory reads reward history
getRewardHistory читает историю вознаграждений
func (p *Protocol) getRewardHistory(actionHash string) ([]*RewardHistory, error) { db := p.Store.GetDB() getQuery := fmt.Sprintf(selectRewardHistory, RewardHistoryTableName) stmt, err := db.Prepare(getQuery) if err != nil { return nil, errors.Wrap(err, "failed to prepare get query") } defer stmt.Close() rows, err := stmt.Query(actionHash) if err != nil { return nil, errors.Wrap(err, "failed to execute get query") } var rewardHistory RewardHistory parsedRows, err := s.ParseSQLRows(rows, &rewardHistory) if err != nil { return nil, errors.Wrap(err, "failed to parse results") } if len(parsedRows) == 0 { return nil, indexprotocol.ErrNotExist } var rewardHistoryList []*RewardHistory for _, parsedRow := range parsedRows { rewards := parsedRow.(*RewardHistory) rewardHistoryList = append(rewardHistoryList, rewards) } return rewardHistoryList, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (as AccountStorage) GetRewardHistory(\n\tctx sdk.Context, me types.AccountKey, bucketSlot int64) (*RewardHistory, sdk.Error) {\n\tstore := ctx.KVStore(as.key)\n\trewardHistoryBytes := store.Get(getRewardHistoryKey(me, bucketSlot))\n\tif rewardHistoryBytes == nil {\n\t\treturn nil, nil\n\t}\n\thistory := new(RewardHistory)\n\tif err := as.cdc.UnmarshalJSON(rewardHistoryBytes, history); err != nil {\n\t\treturn nil, ErrFailedToUnmarshalRewardHistory(err)\n\t}\n\treturn history, nil\n}", "func (_Token *TokenSession) BaseRewardHistory(index *big.Int) (*big.Int, *big.Int, *big.Int, *big.Int, error) {\n\treturn _Token.Contract.BaseRewardHistory(&_Token.CallOpts, index)\n}", "func (_Token *TokenCallerSession) BaseRewardHistory(index *big.Int) (*big.Int, *big.Int, *big.Int, *big.Int, error) {\n\treturn _Token.Contract.BaseRewardHistory(&_Token.CallOpts, index)\n}", "func (_Token *TokenCaller) BaseRewardHistory(opts *bind.CallOpts, index *big.Int) (*big.Int, *big.Int, *big.Int, *big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t\tret1 = new(*big.Int)\n\t\tret2 = new(*big.Int)\n\t\tret3 = new(*big.Int)\n\t)\n\tout := &[]interface{}{\n\t\tret0,\n\t\tret1,\n\t\tret2,\n\t\tret3,\n\t}\n\terr := _Token.contract.Call(opts, out, \"baseRewardHistory\", index)\n\treturn *ret0, *ret1, *ret2, *ret3, err\n}", "func getHistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\ttype AuditHistory struct {\n\t\tTxId string `json:\"txId\"`\n\t\tValue Marble `json:\"value\"`\n\t}\n\tvar history []AuditHistory;\n\tvar marble Marble\n\n\tif len(args) != 1 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 1\")\n\t}\n\n\tmarbleId := args[0]\n\tfmt.Printf(\"- start getHistoryForMarble: %s\\n\", marbleId)\n\n\t// Get History\n\tresultsIterator, err := stub.GetHistoryForKey(marbleId)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tfor resultsIterator.HasNext() {\n\t\thistoryData, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\n\t\tvar tx AuditHistory\n\t\ttx.TxId = historyData.TxId //copy transaction id over\n\t\tjson.Unmarshal(historyData.Value, &marble) //un stringify it aka JSON.parse()\n\t\tif historyData.Value == nil { //marble has been deleted\n\t\t\tvar emptyMarble Marble\n\t\t\ttx.Value = emptyMarble //copy nil marble\n\t\t} else {\n\t\t\tjson.Unmarshal(historyData.Value, &marble) //un stringify it aka JSON.parse()\n\t\t\ttx.Value = marble //copy marble over\n\t\t}\n\t\thistory = append(history, tx) //add this tx to the list\n\t}\n\tfmt.Printf(\"- getHistoryForMarble returning:\\n%s\", history)\n\n\t//change to array of bytes\n\thistoryAsBytes, _ := json.Marshal(history) //convert to array of bytes\n\treturn shim.Success(historyAsBytes)\n}", "func ViewReward(rw http.ResponseWriter, r *http.Request) {\n\t// get the token\n\treqToken := r.Header.Get(\"Authorization\")\n\t\n\t// get the claims\n\tclaims, isNotValid := GetClaims(reqToken, rw)\n\tif isNotValid {\n\t\treturn\n\t}\n\n\tdt, err := db.GetUserRewards(claims.Roll)\n\tif err != nil {\n\t\trw.WriteHeader(http.StatusInternalServerError)\n\t\trw.Write(Rsp(err.Error(), \"Server Error\"))\n\t\treturn\n\t}\n\trw.WriteHeader(http.StatusOK)\n\tres := c.RespData{\n\t\tMessage: \"All data\",\n\t\tData: dt,\n\t}\n\tjson.NewEncoder(rw).Encode(res)\n}", "func (_IStakingRewards *IStakingRewardsTransactor) GetReward(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _IStakingRewards.contract.Transact(opts, \"getReward\")\n}", "func get_history(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tif len(args) != 1 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 1\")\n\t}\n\n\tkey := args[0]\n\tfmt.Printf(\"- start getHistory: %s\\n\", key)\n\n\t// Get History\n\tresultsIterator, err := stub.GetHistoryForKey(key)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tresults, err := ConvHistoryResult(resultsIterator)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tfmt.Println(\"end getHistory\")\n\n\treturn shim.Success(results)\n}", "func getHistory(source string) ([]TransferData, error) {\n\turl := fmt.Sprintf(\"%s/history?duration=%s\", source, url.QueryEscape(AgentRouter.CronInterval))\n\tresp := utils.FetchResponse(url, []byte{})\n\tif resp.Error != nil {\n\t\treturn nil, resp.Error\n\t}\n\tvar transferRecords []TransferData\n\terr := json.Unmarshal(resp.Data, &transferRecords)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn transferRecords, nil\n}", "func (_XStaking *XStakingTransactor) GetReward(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _XStaking.contract.Transact(opts, \"getReward\")\n}", "func (s *HeroesServiceChaincode) gethistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tif len(args) < 2 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 3\")\n\t}\n\n\tvegKey := args[1]\n\tfmt.Printf(\"##### start History of Record: %s\\n\", vegKey)\n\n\tresultsIterator, err := stub.GetHistoryForKey(vegKey)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\t// buffer is a JSON array containing historic values for the marble\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tresponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(response.TxId)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\t// if it was a delete operation on given key, then we need to set the\n\t\t//corresponding value null. Else, we will write the response.Value\n\t\t//as-is (as the Value itself a JSON marble)\n\t\tif response.IsDelete {\n\t\t\tbuffer.WriteString(\"null\")\n\t\t} else {\n\t\t\tbuffer.WriteString(string(response.Value))\n\t\t}\n\n\t\tbuffer.WriteString(\", \\\"Timestamp\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\tfmt.Printf(\"- getHistoryForVegetable returning:\\n%s\\n\", buffer.String())\n\n\treturn shim.Success(buffer.Bytes())\n}", "func (_IStakingRewards *IStakingRewardsTransactorSession) GetReward() (*types.Transaction, error) {\n\treturn _IStakingRewards.Contract.GetReward(&_IStakingRewards.TransactOpts)\n}", "func (_IStakingRewards *IStakingRewardsSession) GetReward() (*types.Transaction, error) {\n\treturn _IStakingRewards.Contract.GetReward(&_IStakingRewards.TransactOpts)\n}", "func GetRewardEventsInfo(fromBlock *big.Int, toBlock *big.Int) []*RewardInfo {\n\n\tvar logEpochRewardSig = []byte(\"EpochRewardsDistributedToVoters(address,uint256)\")\n\tvar logEpochRewardSigHash = crypto.Keccak256Hash(logEpochRewardSig)\n\tvar TopicsFilter = [][]common.Hash{{logEpochRewardSigHash}}\n\n\tcontractAddress := common.HexToAddress(WrapperContractDeploymentAddress[NetActive][Election])\n\n\tquery := ethereum.FilterQuery{\n\t\tFromBlock: fromBlock,\n\t\tToBlock: toBlock,\n\t\tTopics: TopicsFilter,\n\n\t\tAddresses: []common.Address{\n\t\t\tcontractAddress,\n\t\t},\n\t}\n\n\tlogs, err := atlasEthClient.FilterLogs(context.Background(), query)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\trewards_info := make([]*RewardInfo, 0, len(logs))\n\n\tcontractAbi, err := abi.JSON(strings.NewReader(string(binding.ElectionABI)))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfor _, vLog := range logs {\n\n\t\tvar epochRewardEvent EpochRewardEvent\n\t\terr := contractAbi.Unpack(&epochRewardEvent, \"EpochRewardsDistributedToVoters\", vLog.Data)\n\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tri := &RewardInfo{Group: common.HexToAddress(vLog.Topics[1].Hex()).String(),\n\t\t\tGroupHash: vLog.Topics[1],\n\t\t\tRewardValue: epochRewardEvent.Value,\n\t\t\tBlockNumber: new(big.Int).SetUint64(vLog.BlockNumber)}\n\n\t\tAddAtlasToRewardInfo(ri)\n\n\t\trewards_info = append(rewards_info, ri)\n\t}\n\n\treturn rewards_info\n}", "func (_TrialRulesAbstract *TrialRulesAbstractCaller) GetReward(opts *bind.CallOpts) (*big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t)\n\tout := ret0\n\terr := _TrialRulesAbstract.contract.Call(opts, out, \"getReward\")\n\treturn *ret0, err\n}", "func (as AccountStorage) GetReward(ctx sdk.Context, accKey types.AccountKey) (*Reward, sdk.Error) {\n\tstore := ctx.KVStore(as.key)\n\trewardByte := store.Get(getRewardKey(accKey))\n\tif rewardByte == nil {\n\t\treturn nil, ErrRewardNotFound()\n\t}\n\treward := new(Reward)\n\tif err := as.cdc.UnmarshalJSON(rewardByte, reward); err != nil {\n\t\treturn nil, ErrFailedToUnmarshalReward(err)\n\t}\n\treturn reward, nil\n}", "func (t *SupplyChaincode) getTradeHistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\n\tif len(args) < 1 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 1\")\n\t}\n\n\tmarbleName := args[0]\n\n\tfmt.Printf(\"- start getHistoryForMarble: %s\\n\", marbleName)\n\n/*\n// TODO: not implemented in current stable version. Waiting for v1.0 beta release.\n\tresultsIterator, err := stub.GetHistoryForKey(marbleName)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\t// buffer is a JSON array containing historic values for the marble\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\ttxID, historicValue, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(txID)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\t// historicValue is a JSON marble, so we write as-is\n\t\tbuffer.WriteString(string(historicValue))\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\tfmt.Printf(\"- getHistoryForMarble returning:\\n%s\\n\", buffer.String())\n\n\treturn shim.Success(buffer.Bytes())\n*/\n\n\tqueryString := args[0]\n\tqueryResults, err := stub.GetState(queryString)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\t\n\treturn shim.Success(queryResults)\t\n}", "func (room *RoomRecorder) history() []*action_.PlayerAction {\n\troom.historyM.RLock()\n\tv := room._history\n\troom.historyM.RUnlock()\n\treturn v\n}", "func (s *Client) GetHistory(ctx context.Context, scripthash string) ([]*GetMempoolResult, error) {\n\tvar resp GetMempoolResp\n\n\terr := s.request(ctx, \"blockchain.scripthash.get_history\", []interface{}{scripthash}, &resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resp.Result, err\n}", "func (_Lmc *LmcSession) GetUserAccumulatedReward(_userAddress common.Address, tokenIndex *big.Int) (*big.Int, error) {\n\treturn _Lmc.Contract.GetUserAccumulatedReward(&_Lmc.CallOpts, _userAddress, tokenIndex)\n}", "func (_Lmc *LmcCallerSession) GetUserAccumulatedReward(_userAddress common.Address, tokenIndex *big.Int) (*big.Int, error) {\n\treturn _Lmc.Contract.GetUserAccumulatedReward(&_Lmc.CallOpts, _userAddress, tokenIndex)\n}", "func (c RewardsController) GetRewards(page int) revel.Result {\n\n\tif !c.GetCurrentUser() {\n\t\treturn c.ForbiddenResponse()\n\t}\n\n\t//ChangeRewardsModel() // Remove when finish production\n\n\tvar reward models.Reward\n\tif Reward, ok := app.Mapper.GetModel(&reward); ok {\n\t\tvar rewards = []models.Reward{}\n\t\tvar match = bson.M{\"$and\": []bson.M{\n\t\t\tbson.M{\"$or\": []bson.M{\n\t\t\t\tbson.M{\"user_id\": c.CurrentUser.GetID().Hex()},\n\t\t\t\tbson.M{\"users\": bson.M{\"$elemMatch\": bson.M{\"$eq\": c.CurrentUser.GetID().Hex()}}},\n\t\t\t}},\n\t\t\tbson.M{\"is_visible\": true},\n\t\t\tbson.M{\"resource_type\": bson.M{\"$ne\": core.ModelTypeChallenge}},\n\t\t}}\n\t\tif page <= 1 {\n\t\t\tpage = 1\n\t\t}\n\t\tvar pipe = mgomap.Aggregate{}.Match(match).Sort(bson.M{\"updated_at\": -1}).Skip((page - 1) * core.LimitRewards).Limit(core.LimitRewards)\n\n\t\tif err := Reward.Pipe(pipe, &rewards); err != nil {\n\t\t\treturn c.ErrorResponse(c.Message(\"error.notFound\", \"Rewards\"), \"No rewards Found\", 400)\n\t\t}\n\t\treturn c.SuccessResponse(rewards, \"success\", core.ModelsType[core.ModelReward], serializers.RewardSerializer{Lang: c.Request.Locale})\n\n\t}\n\treturn c.ServerErrorResponse()\n}", "func getHistory(stub shim.ChaincodeStubInterface, args []string) (string, error) {\n\tif len(args) != 1 {\n\t\treturn \"\", fmt.Errorf(\"Incorrect arguments. Expecting a key\")\n\t}\n\n\tresultsIterator, err := stub.GetHistoryForKey(args[0])\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Failed to get asset: %s with error: %s\", args[0], err)\n\t}\n\tif resultsIterator == nil {\n\t\treturn \"\", fmt.Errorf(\"history not found: %s\", args[0])\n\t}\n\n\tdefer resultsIterator.Close()\n\n\t// buffer is a JSON array containing historic values for the marble\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tresponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn \"iterating error\", err\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(response.TxId)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\t// if it was a delete operation on given key, then we need to set the\n\t\t//corresponding value null. Else, we will write the response.Value\n\t\t//as-is (as the Value itself a JSON marble)\n\t\tif response.IsDelete {\n\t\t\tbuffer.WriteString(\"null\")\n\t\t} else {\n\t\t\tbuffer.WriteString(string(response.Value))\n\t\t}\n\n\t\tbuffer.WriteString(\", \\\"Timestamp\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\tfmt.Printf(\"- getHistoryForMarble returning:\\n%s\\n\", buffer.String())\n\n\treturn buffer.String(), nil\n}", "func getAccumulatedRewards(ctx sdk.Context, distKeeper types.DistributionKeeper, delegation stakingtypes.Delegation) ([]wasmvmtypes.Coin, error) {\n\t// Try to get *delegator* reward info!\n\tparams := distributiontypes.QueryDelegationRewardsRequest{\n\t\tDelegatorAddress: delegation.DelegatorAddress,\n\t\tValidatorAddress: delegation.ValidatorAddress,\n\t}\n\tcache, _ := ctx.CacheContext()\n\tqres, err := distKeeper.DelegationRewards(sdk.WrapSDKContext(cache), &params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// now we have it, convert it into wasmvm types\n\trewards := make([]wasmvmtypes.Coin, len(qres.Rewards))\n\tfor i, r := range qres.Rewards {\n\t\trewards[i] = wasmvmtypes.Coin{\n\t\t\tDenom: r.Denom,\n\t\t\tAmount: r.Amount.TruncateInt().String(),\n\t\t}\n\t}\n\treturn rewards, nil\n}", "func (_XStaking *XStakingSession) GetReward() (*types.Transaction, error) {\n\treturn _XStaking.Contract.GetReward(&_XStaking.TransactOpts)\n}", "func (_TrialRulesAbstract *TrialRulesAbstractCallerSession) GetReward() (*big.Int, error) {\n\treturn _TrialRulesAbstract.Contract.GetReward(&_TrialRulesAbstract.CallOpts)\n}", "func (_XStaking *XStakingTransactorSession) GetReward() (*types.Transaction, error) {\n\treturn _XStaking.Contract.GetReward(&_XStaking.TransactOpts)\n}", "func (_Lmc *LmcCaller) GetUserAccumulatedReward(opts *bind.CallOpts, _userAddress common.Address, tokenIndex *big.Int) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _Lmc.contract.Call(opts, &out, \"getUserAccumulatedReward\", _userAddress, tokenIndex)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (_TrialRulesAbstract *TrialRulesAbstractSession) GetReward() (*big.Int, error) {\n\treturn _TrialRulesAbstract.Contract.GetReward(&_TrialRulesAbstract.CallOpts)\n}", "func (l *Linenoise) historyList() []string {\n\treturn l.history\n}", "func (t *MedChain) getHistory(stub shim.ChaincodeStubInterface, recordKey string) []byte {\n\n\t\tfmt.Printf(\"- start getHistory: %s\\n\", recordKey)\n\n\t\tresultsIterator, err := stub.GetHistoryForKey(recordKey)\n\t\tif err != nil {\n\t\t\terrors.New(err.Error())\n\t\t//\treturn shim.Error(err.Error())\n\t\t}\n\t\tdefer resultsIterator.Close()\n\n\t\t// buffer is a JSON array containing historic values for the key/value pair\n\t\tvar buffer bytes.Buffer\n\t\tbuffer.WriteString(\"[\")\n\n\t\tbArrayMemberAlreadyWritten := false\n\t\tfor resultsIterator.HasNext() {\n\t\t\tresponse, err := resultsIterator.Next()\n\t\t\tif err != nil {\n\t\t\t\terrors.New(err.Error())\n\t\t\t\t//return shim.Error(err.Error())\n\t\t\t}\n\t\t\t// Add a comma before array members, suppress it for the first array member\n\t\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\t\tbuffer.WriteString(\",\")\n\t\t\t}\n\t\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\t\tbuffer.WriteString(\"\\\"\")\n\t\t\tbuffer.WriteString(response.TxId)\n\t\t\tbuffer.WriteString(\"\\\"\")\n\n\t\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\t\t// if it was a delete operation on given key, then we need to set the\n\t\t\t//corresponding value null. Else, we will write the response.Value\n\t\t\t//as-is (as the Value itself a JSON vehiclePart)\n\t\t\tif response.IsDelete {\n\t\t\t\tbuffer.WriteString(\"null\")\n\t\t\t} else {\n\t\t\t\tbuffer.WriteString(string(response.Value))\n\t\t\t}\n\n\t\t\tbuffer.WriteString(\", \\\"Timestamp\\\":\")\n\t\t\tbuffer.WriteString(\"\\\"\")\n\t\t\tbuffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())\n\t\t\tbuffer.WriteString(\"\\\"\")\n\n\t\t\tbuffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\t\tbuffer.WriteString(\"\\\"\")\n\t\t\tbuffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\t\tbuffer.WriteString(\"\\\"\")\n\n\t\t\tbuffer.WriteString(\"}\")\n\t\t\tbArrayMemberAlreadyWritten = true\n\t\t}\n\t\tbuffer.WriteString(\"]\")\n\n\t\tfmt.Printf(\"- getHistoryForRecord returning:\\n%s\\n\", buffer.String())\n\n\t\treturn buffer.Bytes()\n\t}", "func (i *historyItem) getHistory() ([]*historyRow, error) {\n\trows := []*historyRow{}\n\n\tfi, err := os.Open(i.path)\n\tif err != nil {\n\t\treturn rows, err\n\t}\n\tdefer fi.Close()\n\n\tbr := bufio.NewReader(fi)\n\tfor {\n\t\ta, _, c := br.ReadLine()\n\t\tif c == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tr := &historyRow{}\n\t\t// ignore\n\t\terr := json.Unmarshal(a, r)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\trows = append(rows, r)\n\t}\n\n\treturn rows, nil\n}", "func (p *Protocol) getAccountReward(epochNumber uint64, candidateName string) (*AccountReward, error) {\n\tdb := p.Store.GetDB()\n\n\tgetQuery := fmt.Sprintf(selectAccountReward,\n\t\tAccountRewardTableName)\n\tstmt, err := db.Prepare(getQuery)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to prepare get query\")\n\t}\n\tdefer stmt.Close()\n\n\trows, err := stmt.Query(epochNumber, candidateName)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to execute get query\")\n\t}\n\n\tvar accountReward AccountReward\n\tparsedRows, err := s.ParseSQLRows(rows, &accountReward)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to parse results\")\n\t}\n\n\tif len(parsedRows) == 0 {\n\t\treturn nil, indexprotocol.ErrNotExist\n\t}\n\n\tif len(parsedRows) > 1 {\n\t\treturn nil, errors.New(\"only one row is expected\")\n\t}\n\n\treturn parsedRows[0].(*AccountReward), nil\n}", "func (cc CoinCap) GetHistory(baseID, interval string, timeFrom, timeTo int64) (history []CCHistoryItem, err error) {\n\tbaseID = strings.ToLower(strings.Join(strings.Split(baseID, \" \"), \"-\"))\n\turl := fmt.Sprintf(\"%s/assets/%s/history?interval=%s&start=%d&end=%d\",\n\t\tcc.BaseURL, baseID, interval, timeFrom, timeTo)\n\tresponse, err := http.Get(url)\n\tif err != nil {\n\t\treturn\n\t}\n\tresult := struct {\n\t\tError string `json:\"error\"`\n\t\tData []CCHistoryItem `json:\"Data\"`\n\t}{}\n\terr = json.NewDecoder(response.Body).Decode(&result)\n\tif err != nil {\n\t\treturn\n\t}\n\tif result.Error != \"\" {\n\t\terr = errors.New(result.Error)\n\t\treturn\n\t}\n\thistory = result.Data\n\treturn\n}", "func (b *BinanceWorker) GetHistoryTrades(symbol string, start, end int64, number int) {\n\ttrades, err := b.Cli.NewAggTradesService().\n\t\tSymbol(symbol).StartTime(start).EndTime(end).\n\t\tDo(context.Background())\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n\tvar sum int = 0\n\tvar qul float64 = 0.\n\tvar allQul float64 = 0.\n\tfor _, t := range trades {\n\t\ti, _ := strconv.ParseFloat(t.Quantity, 64)\n\t\tallQul += i\n\t\tif t.IsBuyerMaker {\n\t\t\tsum++\n\t\t\tqul += i\n\t\t}\n\n\t}\n\n\tfmt.Println(float64(float64(sum)/float64(len(trades)))*100, float64(float64(qul)/float64(allQul))*100)\n\t// err = json.Unmarshal(jsonBlob, &rankings)\n\t// if err != nil {\n\t// \t// nozzle.printError(\"opening config file\", err.Error())\n\t// }\n\torders, err := json.Marshal(trades)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\t//fmt.Println(string(orders))\n\t// rankingsJson, _ := json.Marshal(rankings)\n\terr = ioutil.WriteFile(fmt.Sprintf(\"%d.json\", number), orders, 0644)\n\t// fmt.Printf(\"%+v\", rankings)\n}", "func (p *Protocol) updateRewardHistory(tx *sql.Tx, epochNumber uint64, actionHash string, rewardInfoMap map[string]*RewardInfo) error {\n\tvalStrs := make([]string, 0, len(rewardInfoMap))\n\tvalArgs := make([]interface{}, 0, len(rewardInfoMap)*7)\n\tfor rewardAddress, rewards := range rewardInfoMap {\n\t\tblockReward := rewards.BlockReward.String()\n\t\tepochReward := rewards.EpochReward.String()\n\t\tfoundationBonus := rewards.FoundationBonus.String()\n\n\t\tvar candidateName string\n\t\t// If more than one candidates share the same reward address, just use the first candidate as their delegate\n\t\tif len(p.RewardAddrToName[rewardAddress]) > 0 {\n\t\t\tcandidateName = p.RewardAddrToName[rewardAddress][0]\n\t\t}\n\n\t\tvalStrs = append(valStrs, \"(?, ?, ?, ?, CAST(? as DECIMAL(65, 0)), CAST(? as DECIMAL(65, 0)), CAST(? as DECIMAL(65, 0)))\")\n\t\tvalArgs = append(valArgs, epochNumber, actionHash, rewardAddress, candidateName, blockReward, epochReward, foundationBonus)\n\t}\n\tinsertQuery := fmt.Sprintf(insertRewardHistory, RewardHistoryTableName, strings.Join(valStrs, \",\"))\n\n\tif _, err := tx.Exec(insertQuery, valArgs...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (_Lmc *LmcCallerSession) GetUserRewardDebt(_userAddress common.Address, _index *big.Int) (*big.Int, error) {\n\treturn _Lmc.Contract.GetUserRewardDebt(&_Lmc.CallOpts, _userAddress, _index)\n}", "func GetRideHistory(w http.ResponseWriter, r *http.Request) {\n\n\tw.Header().Set(\"Content-type\", \"application/json\")\n\tparams := mux.Vars(r)\n\tstrVar := params[\"id\"]\n\tCustomerid, _ := strconv.Atoi(strVar)\n\tvar customer models.Customer\n\tvar db1 *gorm.DB = db.Init()\n\tif err := db1.Where(\"customerid =? \", Customerid).Find(&customer).Error; err != nil {\n\t\thttp.Error(w, \"Customer has not registered!\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tvar customerhistory []models.Customerhistory\n\n\tif err := db1.Where(\"customerid= ? \", Customerid).Find(&customerhistory).Error; err != nil {\n\t\thttp.Error(w, \"Customer has not taken a ride yet!\", http.StatusBadRequest)\n\t\treturn\n\n\t}\n\tjson.NewEncoder(w).Encode(customerhistory)\n}", "func (i *Inspector) History(qname string, n int) ([]*DailyStats, error) {\n\tif err := base.ValidateQueueName(qname); err != nil {\n\t\treturn nil, err\n\t}\n\tstats, err := i.rdb.HistoricalStats(qname, n)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar res []*DailyStats\n\tfor _, s := range stats {\n\t\tres = append(res, &DailyStats{\n\t\t\tQueue: s.Queue,\n\t\t\tProcessed: s.Processed,\n\t\t\tFailed: s.Failed,\n\t\t\tDate: s.Time,\n\t\t})\n\t}\n\treturn res, nil\n}", "func (_Lmc *LmcSession) GetUserRewardDebt(_userAddress common.Address, _index *big.Int) (*big.Int, error) {\n\treturn _Lmc.Contract.GetUserRewardDebt(&_Lmc.CallOpts, _userAddress, _index)\n}", "func accumulateRewards(config *params.ChainConfig, state *state.DB, header *types.Header) {\n\t// TODO: implement mining rewards\n}", "func (k Querier) Rewards(c context.Context, req *types.QueryRewardsRequest) (*types.QueryRewardsResponse, error) {\n\tif req == nil {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"invalid request\")\n\t}\n\n\tif req.StakingCoinDenom != \"\" {\n\t\tif err := sdk.ValidateDenom(req.StakingCoinDenom); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tctx := sdk.UnwrapSDKContext(c)\n\tstore := ctx.KVStore(k.storeKey)\n\tvar rewards []types.Reward\n\tvar pageRes *query.PageResponse\n\tvar err error\n\n\tif req.Farmer != \"\" {\n\t\tvar farmerAcc sdk.AccAddress\n\t\tfarmerAcc, err = sdk.AccAddressFromBech32(req.Farmer)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tstorePrefix := types.GetRewardsByFarmerIndexKey(farmerAcc)\n\t\tindexStore := prefix.NewStore(store, storePrefix)\n\t\tpageRes, err = query.FilteredPaginate(indexStore, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) {\n\t\t\t_, stakingCoinDenom := types.ParseRewardsByFarmerIndexKey(append(storePrefix, key...))\n\t\t\tif req.StakingCoinDenom != \"\" {\n\t\t\t\tif stakingCoinDenom != req.StakingCoinDenom {\n\t\t\t\t\treturn false, nil\n\t\t\t\t}\n\t\t\t}\n\t\t\treward, found := k.GetReward(ctx, stakingCoinDenom, farmerAcc)\n\t\t\tif !found { // TODO: remove this check\n\t\t\t\treturn false, fmt.Errorf(\"reward not found\")\n\t\t\t}\n\t\t\tif accumulate {\n\t\t\t\trewards = append(rewards, reward)\n\t\t\t}\n\t\t\treturn true, nil\n\t\t})\n\t} else {\n\t\tvar storePrefix []byte\n\t\tif req.StakingCoinDenom != \"\" {\n\t\t\tstorePrefix = types.GetRewardsByStakingCoinDenomKey(req.StakingCoinDenom)\n\t\t} else {\n\t\t\tstorePrefix = types.RewardKeyPrefix\n\t\t}\n\t\trewardStore := prefix.NewStore(store, storePrefix)\n\n\t\tpageRes, err = query.Paginate(rewardStore, req.Pagination, func(key, value []byte) error {\n\t\t\tstakingCoinDenom, farmerAcc := types.ParseRewardKey(append(storePrefix, key...))\n\t\t\trewardCoins, err := k.UnmarshalRewardCoins(value)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\trewards = append(rewards, types.Reward{\n\t\t\t\tFarmer: farmerAcc.String(),\n\t\t\t\tStakingCoinDenom: stakingCoinDenom,\n\t\t\t\tRewardCoins: rewardCoins.RewardCoins,\n\t\t\t})\n\t\t\treturn nil\n\t\t})\n\t}\n\tif err != nil {\n\t\treturn nil, status.Error(codes.Internal, err.Error())\n\t}\n\n\treturn &types.QueryRewardsResponse{Rewards: rewards, Pagination: pageRes}, nil\n}", "func (l *Linenoise) historyGet(idx int) string {\n\treturn l.history[len(l.history)-1-idx]\n}", "func (s *SmartContract) getLCHistory(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {\n \n\t lcId := args[0];\n \n\t resultsIterator, err := APIstub.GetHistoryForKey(lcId)\n\t if err != nil {\n\t\t return shim.Error(\"Error retrieving LC history.\")\n\t }\n\t defer resultsIterator.Close()\n \n\t // buffer is a JSON array containing historic values for the marble\n\t var buffer bytes.Buffer\n\t buffer.WriteString(\"[\")\n \n\t bArrayMemberAlreadyWritten := false\n\t for resultsIterator.HasNext() {\n\t\t response, err := resultsIterator.Next()\n\t\t if err != nil {\n\t\t\t return shim.Error(\"Error retrieving LC history.\")\n\t\t }\n\t\t // Add a comma before array members, suppress it for the first array member\n\t\t if bArrayMemberAlreadyWritten == true {\n\t\t\t buffer.WriteString(\",\")\n\t\t }\n\t\t buffer.WriteString(\"{\\\"TxId\\\":\")\n\t\t buffer.WriteString(\"\\\"\")\n\t\t buffer.WriteString(response.TxId)\n\t\t buffer.WriteString(\"\\\"\")\n \n\t\t buffer.WriteString(\", \\\"Value\\\":\")\n\t\t // if it was a delete operation on given key, then we need to set the\n\t\t //corresponding value null. Else, we will write the response.Value\n\t\t //as-is (as the Value itself a JSON marble)\n\t\t if response.IsDelete {\n\t\t\t buffer.WriteString(\"null\")\n\t\t } else {\n\t\t\t buffer.WriteString(string(response.Value))\n\t\t }\n \n\t\t buffer.WriteString(\", \\\"Timestamp\\\":\")\n\t\t buffer.WriteString(\"\\\"\")\n\t\t buffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())\n\t\t buffer.WriteString(\"\\\"\")\n \n\t\t buffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\t buffer.WriteString(\"\\\"\")\n\t\t buffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\t buffer.WriteString(\"\\\"\")\n \n\t\t buffer.WriteString(\"}\")\n\t\t bArrayMemberAlreadyWritten = true\n\t }\n\t buffer.WriteString(\"]\")\n \n\t fmt.Printf(\"- getLCHistory returning:\\n%s\\n\", buffer.String())\n \n\t return shim.Success(buffer.Bytes())\n }", "func GetReward(a Action, feedback Action) float64 {\n\tif a == feedback {\n\t\treturn 1\n\t}\n\treturn -1\n}", "func (s *Client) GetHistory(username string) (*sessions.History, error) {\n\tdata := &sessions.History{\n\t\tInput: []string{},\n\t\tReply: []string{},\n\t}\n\n\tfor i := 0; i < sessions.HistorySize; i++ {\n\t\tdata.Input = append(data.Input, \"undefined\")\n\t\tdata.Reply = append(data.Reply, \"undefined\")\n\t}\n\n\trows, err := s.db.Query(\"SELECT input,reply FROM history WHERE user_id = (SELECT id FROM users WHERE username = ?) ORDER BY timestamp ASC LIMIT 10;\", username)\n\tif err != nil {\n\t\treturn data, err\n\t}\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\tvar input, reply string\n\t\terr := rows.Scan(&input, &reply)\n\t\tif err != nil {\n\t\t\tlog.Println(\"[ERROR]\", err)\n\t\t\tcontinue\n\t\t}\n\t\tdata.Input = data.Input[:len(data.Input)-1] // Pop\n\t\tdata.Input = append([]string{strings.TrimSpace(input)}, data.Input...) // Unshift\n\t\tdata.Reply = data.Reply[:len(data.Reply)-1] // Pop\n\t\tdata.Reply = append([]string{strings.TrimSpace(reply)}, data.Reply...) // Unshift\n\n\t}\n\n\treturn data, nil\n}", "func (path *Path) Rewards() map[*Reward]int {\n\treturn path.rewards\n}", "func (o *Convergence) AccessHistory() *History {\n\treturn o.Hist\n}", "func getHistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\ttype AuditHistory struct {\n\t\tTxId string `json:\"txId\"`\n\t\tValue Listing `json:\"value\"`\n\t}\n\tvar history []AuditHistory\n\tvar listing Listing\n\n\tif len(args) != 1 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 1\")\n\t}\n\n\tlistingId := args[0]\n\tfmt.Printf(\"- start getHistoryForListing: %s\\n\", listingId)\n\n\t// Get History\n\tresultsIterator, err := stub.GetHistoryForKey(listingId)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tfor resultsIterator.HasNext() {\n\t\thistoryData, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\n\t\tvar tx AuditHistory\n\t\ttx.TxId = historyData.TxId //copy transaction id over\n\t\tjson.Unmarshal(historyData.Value, &listing) //un stringify it aka JSON.parse()\n\t\tif historyData.Value == nil { //listing has been deleted\n\t\t\tvar emptyListing Listing\n\t\t\ttx.Value = emptyListing //copy nil listing\n\t\t} else {\n\t\t\tjson.Unmarshal(historyData.Value, &listing) //un stringify it aka JSON.parse()\n\t\t\ttx.Value = listing //copy listing over\n\t\t}\n\t\thistory = append(history, tx) //add this tx to the list\n\t}\n\tfmt.Printf(\"- getHistoryForListing returning:\\n%s\", history)\n\n\t//change to array of bytes\n\thistoryAsBytes, _ := json.Marshal(history) //convert to array of bytes\n\treturn shim.Success(historyAsBytes)\n}", "func (t *BenchmarkerChaincode) GetHistoryForKey(stub shim.ChaincodeStubInterface, seed, keySizeLo, keySizeHi int) pb.Response {\n\tvar (\n\t\tkm NoopKeyMapper\n\t)\n\n\tkey := km.GetKeys(seed, 1, keySizeLo, keySizeHi)[0]\n\n\tresultsIterator, err := stub.GetHistoryForKey(key)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tfmt.Printf(\"GetHistoryForKey: Getting history for key '%s'\\n\", key)\n\n\t// buffer is a JSON array containing historic values for the marble\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tresponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(response.TxId)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\t// if it was a delete operation on given key, then we need to set the\n\t\t//corresponding value null. Else, we will write the response.Value\n\t\t//as-is (as the Value itself a JSON marble)\n\t\tif response.IsDelete {\n\t\t\tbuffer.WriteString(\"null\")\n\t\t} else {\n\t\t\tbuffer.WriteString(string(response.Value))\n\t\t}\n\n\t\tbuffer.WriteString(\", \\\"Timestamp\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\treturn shim.Success(buffer.Bytes())\n}", "func (h *MethodCallHistory) GetHistory() []*MethodCall {\n\tdefer h.RUnlock()\n\th.RLock()\n\treturn h.history\n}", "func (s *SimpleChaincode) pat_gethistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tif len(args) < 2 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 3\")\n\t}\n\n\tpatKey := args[1]\n\tfmt.Printf(\"##### start History of Record: %s\\n\", patKey)\n\n\tresultsIterator, err := stub.GetHistoryForKey(patKey)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\t// buffer is a JSON array containing historic values for the marble\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tresponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(response.TxId)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\t// if it was a delete operation on given key, then we need to set the\n\t\t//corresponding value null. Else, we will write the response.Value\n\t\t//as-is (as the Value itself a JSON marble)\n\t\tif response.IsDelete {\n\t\t\tbuffer.WriteString(\"null\")\n\t\t} else {\n\t\t\tbuffer.WriteString(string(response.Value))\n\t\t}\n\n\t\tbuffer.WriteString(\", \\\"Timestamp\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\tfmt.Printf(\"- getHistoryForPatient returning:\\n%s\\n\", buffer.String())\n\n\treturn shim.Success(buffer.Bytes())\n}", "func (m *MemoryRewardStorage) GetAll() []rewards.Reward {\n\treturn m.rewards\n}", "func (c *BalanceClient) History() (*BalanceTransactionListResponse, error) {\n\treturn c.HistoryWithFilters(Filters{})\n}", "func GetHistory(s *aklib.DBConfig) ([]*History, error) {\n\tvar hist []*History\n\treturn hist, s.DB.View(func(txn *badger.Txn) error {\n\t\terr := db.Get(txn, nil, &hist, db.HeaderWalletHistory)\n\t\tif err == badger.ErrKeyNotFound {\n\t\t\treturn nil\n\t\t}\n\t\treturn err\n\t})\n}", "func (s *Server) History(w http.ResponseWriter, r *http.Request) {\n\tteam, err := s.currentTeam(w, r)\n\tif err != nil {\n\t\ts.unauthorized(w, err)\n\t\treturn\n\t}\n\n\tscores, err := models.NewScore().History(team.ID)\n\tif err != nil {\n\t\tError(w, http.StatusNotFound, err, \"failed to get history\")\n\t}\n\tJSON(w, http.StatusOK, scores)\n}", "func (f *PolicyServiceGetRetentionPolicyOverviewFunc) History() []PolicyServiceGetRetentionPolicyOverviewFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]PolicyServiceGetRetentionPolicyOverviewFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (s *server) GetHistory(ctx context.Context, req *transactionpb.GetHistoryRequest) (*transactionpb.GetHistoryResponse, error) {\n\tlog := logrus.WithFields(logrus.Fields{\n\t\t\"method\": \"GetHistory\",\n\t\t\"account\": base64.StdEncoding.EncodeToString(req.AccountId.Value),\n\t})\n\n\titems, err := s.loader.getItems(ctx, req.AccountId.Value, req.Cursor, req.Direction)\n\tif err != nil {\n\t\tlog.WithError(err).Warn(\"failed to get history transactions\")\n\t\treturn nil, status.Error(codes.Internal, \"failed to get transactions\")\n\t}\n\n\treturn &transactionpb.GetHistoryResponse{\n\t\tResult: transactionpb.GetHistoryResponse_OK,\n\t\tItems: items,\n\t}, nil\n}", "func (s *State) GetHistory(height uint32) (*StateKeyFrame, error) {\n\ts.mtx.RLock()\n\tdefer s.mtx.RUnlock()\n\n\t// Seek to state to target height.\n\tif err := s.history.SeekTo(height); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Take a snapshot of the history.\n\treturn s.snapshot(), nil\n}", "func (m *MemoryRewardStorage) Get(id int) (rewards.Reward, error) {\n\tvar reward rewards.Reward\n\n\tfor _, r := range m.rewards {\n\t\tif r.ID == id {\n\t\t\treturn r, nil\n\t\t}\n\t}\n\n\treturn reward, rewards.ErrNotFound\n}", "func (g *Generator) History() []ispec.History {\n\tcopy := []ispec.History{}\n\tfor _, v := range g.image.History {\n\t\tcopy = append(copy, v)\n\t}\n\treturn copy\n}", "func (f *AutoIndexingServiceNumRepositoriesWithCodeIntelligenceFunc) History() []AutoIndexingServiceNumRepositoriesWithCodeIntelligenceFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]AutoIndexingServiceNumRepositoriesWithCodeIntelligenceFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func GetHistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\ttype KeyModificationWrapper struct {\n\t\tRealValue interface{} `json:\"InterfaceValue\"`\n\t\tTx queryresult.KeyModification\n\t}\n\tvar sliceReal []KeyModificationWrapper\n\n\tvar history []queryresult.KeyModification\n\tvar value interface{}\n\n\tif len(args) != 1 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 1\")\n\t}\n\n\tkey := args[0]\n\tfmt.Printf(\"- start GetHistory: %s\\n\", key)\n\n\t// Get History\n\tresultsIterator, err := stub.GetHistoryForKey(key)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tfor resultsIterator.HasNext() {\n\t\thistoryData, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\n\t\tvar singleReal KeyModificationWrapper\n\t\tvar tx queryresult.KeyModification\n\t\tsingleReal.Tx.TxId = historyData.TxId //copy transaction id over\n\t\tjson.Unmarshal(historyData.Value, &value) //un stringify it aka JSON.parse()\n\t\tif historyData.Value == nil { //value has been deleted\n\t\t\tvar emptyBytes []byte\n\t\t\tsingleReal.Tx.Value = emptyBytes //copy nil value\n\t\t} else {\n\t\t\tjson.Unmarshal(historyData.Value, &value) //un stringify it aka JSON.parse()\n\t\t\tsingleReal.Tx.Value = historyData.Value //copy value over\n\t\t\tsingleReal.Tx.Timestamp = historyData.Timestamp\n\t\t\tsingleReal.Tx.IsDelete = historyData.IsDelete\n\t\t\tsingleReal.RealValue = value\n\t\t}\n\t\thistory = append(history, tx) //add this Tx to the list\n\t\tsliceReal = append(sliceReal, singleReal)\n\t}\n\t// fmt.Printf(\"- getHistoryForService returning:\\n%s\", history)\n\tPrettyPrintHistory(history)\n\n\t//change to array of bytes\n\t// historyAsBytes, _ := json.Marshal(history) //convert to array of bytes\n\n\trealAsBytes, _ := json.Marshal(sliceReal)\n\treturn shim.Success(realAsBytes)\n}", "func getLiftHistory(c *echo.Context) error {\n\tid, err := strconv.ParseUint(c.Param(\"ID\"), 10, 64)\n\tif err != nil {\n\t\treturn jsonResp(c, err.Error())\n\t}\n\tlift := LiftHistory{DeviceID: c.Param(\"DeviceID\"), ID: id}\n\n\thas, err := g_engine.Get(&lift)\n\tif err != nil {\n\t\treturn jsonResp(c, err.Error())\n\t}\n\tif !has {\n\t\treturn jsonResp(c, \"not exists\")\n\t}\n\n\treturn c.JSON(http.StatusOK, lift)\n}", "func (k Keeper) GetReward(ctx sdk.Context, stakingCoinDenom string, farmerAcc sdk.AccAddress) (reward types.Reward, found bool) {\n\tstore := ctx.KVStore(k.storeKey)\n\tbz := store.Get(types.GetRewardKey(stakingCoinDenom, farmerAcc))\n\tif bz == nil {\n\t\treturn reward, false\n\t}\n\tvar rewardCoins types.RewardCoins\n\tk.cdc.MustUnmarshal(bz, &rewardCoins)\n\treturn types.Reward{\n\t\tFarmer: farmerAcc.String(),\n\t\tStakingCoinDenom: stakingCoinDenom,\n\t\tRewardCoins: rewardCoins.RewardCoins,\n\t}, true\n}", "func (f *ReleaseStoreGetLatestBatchFunc) History() []ReleaseStoreGetLatestBatchFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ReleaseStoreGetLatestBatchFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *PipelineRunFunc) History() []PipelineRunFuncCall {\n\treturn f.history\n}", "func (_Token *TokenCallerSession) BaseRewardHistoryLength() (*big.Int, error) {\n\treturn _Token.Contract.BaseRewardHistoryLength(&_Token.CallOpts)\n}", "func (sc *LoanMarketShareContract) History(ctx contractapi.TransactionContextInterface, key string) ([]LoanMarketShareHistory, error) {\n\n\titer, err := ctx.GetStub().GetHistoryForKey(key)\n\tif err != nil {\n return nil, err\n\t}\n\tdefer func() { _ = iter.Close() }()\n\n\tvar results []LoanMarketShareHistory\n\tfor iter.HasNext() {\n\t\tstate, err := iter.Next()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tentryObj := new(LoanMarketShareObj)\n\t\tif errNew := json.Unmarshal(state.Value, entryObj); errNew != nil {\n\t\t\treturn nil, errNew\n\t\t}\n\n\t\tentry := LoanMarketShareHistory{\n\t\t\tTxID:\t\tstate.GetTxId(),\n\t\t\tTimestamp:\ttime.Unix(state.GetTimestamp().GetSeconds(), 0),\n\t\t\tLoanMarketShare:\tentryObj,\n\t\t}\n\n\t\tresults = append(results, entry)\n\t}\n\treturn results, nil\n}", "func (s *BlocksService) Reward(ctx context.Context) (*BlocksReward, *http.Response, error) {\n\tvar responseStruct *BlocksReward\n\tresp, err := s.client.SendRequest(ctx, \"GET\", \"blocks/getReward\", nil, &responseStruct)\n\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn responseStruct, resp, err\n}", "func (c4 *Connect4) GetReward() int {\n\tif c4.Winner == nil {\n\t\treturn 0\n\t} else if *c4.Winner == 1 {\n\t\treturn 1\n\t}\n\treturn -1\n}", "func (f *ReleaseStoreGetArtifactsFunc) History() []ReleaseStoreGetArtifactsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ReleaseStoreGetArtifactsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (c *gRPCClient) AccountRewards(address gosmtypes.Address, offset uint32, maxResults uint32) ([]*apitypes.Reward, uint32, error) {\n\tgsc := c.getGlobalStateServiceClient()\n\tresp, err := gsc.AccountDataQuery(context.Background(), &apitypes.AccountDataQueryRequest{\n\t\tFilter: &apitypes.AccountDataFilter{\n\t\t\tAccountId: &apitypes.AccountId{Address: address.Bytes()},\n\t\t\tAccountDataFlags: uint32(apitypes.AccountDataFlag_ACCOUNT_DATA_FLAG_REWARD),\n\t\t},\n\n\t\tMaxResults: maxResults,\n\t\tOffset: offset,\n\t})\n\n\tif err != nil {\n\t\treturn nil, 0, err\n\t}\n\n\trewards := make([]*apitypes.Reward, 0)\n\n\tfor _, data := range resp.AccountItem {\n\t\tr := data.GetReward()\n\t\tif r != nil {\n\t\t\trewards = append(rewards, r)\n\t\t}\n\t}\n\n\treturn rewards, resp.TotalResults, nil\n}", "func getHistory(ctx context.Context, args *map[string]interface{}) error {\n\tvar resultRows []Operation\n\n\tha, ok := (*args)[\"historyArgs\"].(historyArgs)\n\tif !ok {\n\t\treturn fmt.Errorf(\"unable to cast arguments to type historyArgs\")\n\t}\n\n\texportType := ha.exportType\n\n\t// Get everything from the fhir_endpoints_info_history table for the given URL\n\n\tvar selectHistory string\n\tif exportType == \"month\" {\n\t\tselectHistory = `\n\t\tSELECT fhir_endpoints_info_history.url, fhir_endpoints_metadata.http_response, fhir_endpoints_metadata.response_time_seconds, fhir_endpoints_metadata.errors,\n\t\tcapability_statement, tls_version, mime_types, operation_resource,\n\t\tfhir_endpoints_metadata.smart_http_response, smart_response, fhir_endpoints_info_history.updated_at, capability_fhir_version\n\t\tFROM fhir_endpoints_info_history, fhir_endpoints_metadata\n\t\tWHERE fhir_endpoints_info_history.metadata_id = fhir_endpoints_metadata.id AND fhir_endpoints_info_history.url=$1 AND (date_trunc('month', fhir_endpoints_info_history.updated_at) = date_trunc('month', current_date - INTERVAL '1 month'))\n\t\tORDER BY fhir_endpoints_info_history.updated_at DESC;`\n\t} else if exportType == \"30days\" {\n\t\tselectHistory = `\n\t\tSELECT fhir_endpoints_info_history.url, fhir_endpoints_metadata.http_response, fhir_endpoints_metadata.response_time_seconds, fhir_endpoints_metadata.errors,\n\t\tcapability_statement, tls_version, mime_types, operation_resource,\n\t\tfhir_endpoints_metadata.smart_http_response, smart_response, fhir_endpoints_info_history.updated_at, capability_fhir_version\n\t\tFROM fhir_endpoints_info_history, fhir_endpoints_metadata\n\t\tWHERE fhir_endpoints_info_history.metadata_id = fhir_endpoints_metadata.id AND fhir_endpoints_info_history.url=$1 AND (date_trunc('day', fhir_endpoints_info_history.updated_at) >= date_trunc('day', current_date - INTERVAL '30 day'))\n\t\tORDER BY fhir_endpoints_info_history.updated_at DESC;`\n\t} else if exportType == \"all\" {\n\t\tselectHistory = `\n\t\tSELECT fhir_endpoints_info_history.url, fhir_endpoints_metadata.http_response, fhir_endpoints_metadata.response_time_seconds, fhir_endpoints_metadata.errors,\n\t\tcapability_statement, tls_version, mime_types, operation_resource,\n\t\tfhir_endpoints_metadata.smart_http_response, smart_response, fhir_endpoints_info_history.updated_at, capability_fhir_version\n\t\tFROM fhir_endpoints_info_history, fhir_endpoints_metadata\n\t\tWHERE fhir_endpoints_info_history.metadata_id = fhir_endpoints_metadata.id AND fhir_endpoints_info_history.url=$1\n\t\tORDER BY fhir_endpoints_info_history.updated_at DESC;`\n\t}\n\n\thistoryRows, err := ha.store.DB.QueryContext(ctx, selectHistory, ha.fhirURL)\n\tif err != nil {\n\t\tlog.Warnf(\"Failed getting the history rows for URL %s. Error: %s\", ha.fhirURL, err)\n\t\tresult := Result{\n\t\t\tURL: ha.fhirURL,\n\t\t\tRows: resultRows,\n\t\t}\n\t\tha.result <- result\n\t\treturn nil\n\t}\n\n\t// Puts the rows in an array and sends it back on the channel to be processed\n\tdefer historyRows.Close()\n\tfor historyRows.Next() {\n\t\tvar op Operation\n\t\tvar url string\n\t\tvar capStat []byte\n\t\tvar smartRsp []byte\n\t\tvar opRes []byte\n\t\terr = historyRows.Scan(\n\t\t\t&url,\n\t\t\t&op.HTTPResponse,\n\t\t\t&op.HTTPResponseTimeSecond,\n\t\t\t&op.Errors,\n\t\t\t&capStat,\n\t\t\t&op.TLSVersion,\n\t\t\tpq.Array(&op.MIMETypes),\n\t\t\t&opRes,\n\t\t\t&op.SMARTHTTPResponse,\n\t\t\t&smartRsp,\n\t\t\t&op.UpdatedAt,\n\t\t\t&op.FHIRVersion)\n\t\tif err != nil {\n\t\t\tlog.Warnf(\"Error while scanning the rows of the history table for URL %s. Error: %s\", ha.fhirURL, err)\n\t\t\tresult := Result{\n\t\t\t\tURL: ha.fhirURL,\n\t\t\t\tRows: resultRows,\n\t\t\t}\n\t\t\tha.result <- result\n\t\t\treturn nil\n\t\t}\n\n\t\top.SMARTResponse = getSMARTResponse(smartRsp)\n\t\top.SupportedResources = getSupportedResources(opRes)\n\n\t\tresultRows = append(resultRows, op)\n\t}\n\tresult := Result{\n\t\tURL: ha.fhirURL,\n\t\tRows: resultRows,\n\t}\n\tha.result <- result\n\treturn nil\n}", "func getHistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\nfmt.Println(\"************************ READ HISTORY ************************* \")\nfmt.Printf(\"- args value: %s\\n\", args)\nfmt.Printf(\"- len(args) value: %s\\n\", len(args))\n\n\ttype AuditHistory struct {\n\t\tTxId string `json:\"txId\"`\n\t\tValue mystruct `json:\"value\"`\n\t}\n\tvar history []AuditHistory;\n\tvar mys mystruct\n\n\t\t\n\tmode1serial := strings.Join(args,\"\")\n\tfmt.Printf(\"- start getHistoryForModel_SerialNumber Combination: %s\\n\", mode1serial)\n\n\t// Get History\n\tresultsIterator, err := stub.GetHistoryForKey(mode1serial)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\nfmt.Printf(\"resultsIterator.HasNext()\\n%s\", resultsIterator.HasNext())\n\n\tfor resultsIterator.HasNext() {\n\tfmt.Printf(\"Inside loop\\n%s\")\n\t\thistoryData, err := resultsIterator.Next()\n\t\tfmt.Printf(\"Inside loop : \\n%s\", historyData)\n\t\t\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\n\t\tvar tx AuditHistory\n\t\ttx.TxId = historyData.TxId //copy transaction id over\n\t\t\tfmt.Printf(\"Inside loop historyData.TxId : \\n%s\", historyData.TxId )\n\t\tjson.Unmarshal(historyData.Value, &mys) //un stringify it aka JSON.parse()\n\t\tif historyData.Value == nil { //product has been deleted\n\t\t\tvar emptymys mystruct\n\t\t\ttx.Value = emptymys //copy nil product\n\t\t} else {\n\t\t\tjson.Unmarshal(historyData.Value, &mys) //un stringify it aka JSON.parse()\n\t\t\ttx.Value = mys //copy product over\n\t\t}\n\t\thistory = append(history, tx) //add this tx to the list\n\t}\n\tfmt.Printf(\"- getHistoryForProduct returning:\\n%s\", history)\n\n\t//change to array of bytes\n\thistoryAsBytes, _ := json.Marshal(history) //convert to array of bytes\n\tfmt.Printf(\"- getHistoryForProduct returning historyAsBytes:\\n%s\", historyAsBytes)\n\treturn shim.Success(historyAsBytes)\n}", "func (f *ResolverQueryResolverFunc) History() []ResolverQueryResolverFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverQueryResolverFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (_Lmc *LmcCaller) GetUserRewardDebt(opts *bind.CallOpts, _userAddress common.Address, _index *big.Int) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _Lmc.contract.Call(opts, &out, \"getUserRewardDebt\", _userAddress, _index)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func GetHistory(store Store, datatype, realm, user, id string, r *http.Request) (*cpb.History, int, error) {\n\thlist := make([]proto.Message, 0)\n\tif err := store.ReadHistory(datatype, realm, user, id, &hlist); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\t// TODO: perhaps this should be the empty list?\n\t\t\treturn nil, http.StatusBadRequest, fmt.Errorf(\"no config history available\")\n\t\t}\n\t\treturn nil, http.StatusBadRequest, fmt.Errorf(\"service storage unavailable: %v, retry later\", err)\n\t}\n\the := make([]*cpb.HistoryEntry, len(hlist))\n\tvar ok bool\n\tfor i, e := range hlist {\n\t\the[i], ok = e.(*cpb.HistoryEntry)\n\t\tif !ok {\n\t\t\treturn nil, http.StatusInternalServerError, fmt.Errorf(\"cannot load history entry %d\", i)\n\t\t}\n\t}\n\thistory := &cpb.History{\n\t\tHistory: he,\n\t}\n\tpageToken := r.URL.Query().Get(\"pageToken\")\n\tstart, err := strconv.ParseInt(pageToken, 10, 64)\n\tif err != nil {\n\t\tstart = 0\n\t}\n\n\tpageSize := r.URL.Query().Get(\"pageSize\")\n\tsize, err := strconv.ParseInt(pageSize, 10, 64)\n\tif err != nil || size < 1 {\n\t\tsize = 50\n\t}\n\tif size > 1000 {\n\t\tsize = 1000\n\t}\n\t// Reverse order\n\ta := history.History\n\tfor i := len(a)/2 - 1; i >= 0; i-- {\n\t\topp := len(a) - 1 - i\n\t\ta[i], a[opp] = a[opp], a[i]\n\t}\n\n\tfor i, entry := range history.History {\n\t\tif entry.Revision <= start {\n\t\t\thistory.History = history.History[i:]\n\t\t\tbreak\n\t\t}\n\t}\n\tif len(history.History) > int(size) {\n\t\thistory.NextPageToken = fmt.Sprintf(\"%d\", history.History[size].Revision)\n\t\thistory.History = history.History[:size]\n\t}\n\treturn history, http.StatusOK, nil\n}", "func (_Token *TokenSession) BaseRewardHistoryLength() (*big.Int, error) {\n\treturn _Token.Contract.BaseRewardHistoryLength(&_Token.CallOpts)\n}", "func (th *translationHandler) GetHistory(w http.ResponseWriter, r *http.Request) {\n\t// All and all this part could have been done better\n\t// with TreeMap but I decided to stick with this custom solution\n\tsort.Strings(th.history.englishWordKeys)\n\tresultArray := []map[string]string{}\n\n\tfor _, key := range th.history.englishWordKeys {\n\t\tresultArray = append(resultArray, th.history.db[key])\n\t}\n\n\tth.history.WordHistory = resultArray\n\tth.codec.Encode(w, th.history)\n}", "func (l *Linenoise) historyNext(ls *linestate) string {\n\tif len(l.history) == 0 {\n\t\treturn \"\"\n\t}\n\t// update the current history entry with the line buffer\n\tl.historySet(ls.historyIndex, ls.String())\n\tls.historyIndex--\n\t// next history item\n\tif ls.historyIndex < 0 {\n\t\tls.historyIndex = 0\n\t}\n\treturn l.historyGet(ls.historyIndex)\n}", "func (f *ReleaseStoreTransactFunc) History() []ReleaseStoreTransactFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ReleaseStoreTransactFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (sc *LoanDocContract) History(ctx contractapi.TransactionContextInterface, key string) ([]LoanDocHistory, error) {\n\n\titer, err := ctx.GetStub().GetHistoryForKey(key)\n\tif err != nil {\n return nil, err\n\t}\n\tdefer func() { _ = iter.Close() }()\n\n\tvar results []LoanDocHistory\n\tfor iter.HasNext() {\n\t\tstate, err := iter.Next()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tentryObj := new(LoanDocObj)\n\t\tif errNew := json.Unmarshal(state.Value, entryObj); errNew != nil {\n\t\t\treturn nil, errNew\n\t\t}\n\n\t\tentry := LoanDocHistory{\n\t\t\tTxID:\t\tstate.GetTxId(),\n\t\t\tTimestamp:\ttime.Unix(state.GetTimestamp().GetSeconds(), 0),\n\t\t\tLoanDoc:\tentryObj,\n\t\t}\n\n\t\tresults = append(results, entry)\n\t}\n\treturn results, nil\n}", "func History(ctx context.Context, nameOrID string, options *HistoryOptions) ([]*types.HistoryResponse, error) {\n\tif options == nil {\n\t\toptions = new(HistoryOptions)\n\t}\n\t_ = options\n\tvar history []*types.HistoryResponse\n\tconn, err := bindings.GetClient(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresponse, err := conn.DoRequest(ctx, nil, http.MethodGet, \"/images/%s/history\", nil, nil, nameOrID)\n\tif err != nil {\n\t\treturn history, err\n\t}\n\tdefer response.Body.Close()\n\n\treturn history, response.Process(&history)\n}", "func GetHistoryRecords() ([]string, error) {\n\trecords := []string{}\n\n\t// \tGet bash history records\n\tbashRecords, err := getBashHistoryRecords()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trecords = append(records, bashRecords...)\n\n\t//Get zsh history records\n\tzshRecords, err := getZshHistoryRecords()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trecords = append(records, zshRecords...)\n\treturn records, nil\n}", "func (f *ReleaseStoreGetLatestFunc) History() []ReleaseStoreGetLatestFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ReleaseStoreGetLatestFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *PipelineAddFunc) History() []PipelineAddFuncCall {\n\treturn f.history\n}", "func (f *AutoIndexingServiceGetUnsafeDBFunc) History() []AutoIndexingServiceGetUnsafeDBFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]AutoIndexingServiceGetUnsafeDBFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (client SmartGroupsClient) GetHistoryResponder(resp *http.Response) (result SmartGroupModification, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (self* userRestAPI) flightHistory(w http.ResponseWriter, r *http.Request) {\n\n\t// Read arguments\n\tband,number,err := self.extractBandAndNumber(r)\n\tif err != nil {\n\t\tlogError(err)\n\t\thttp.Error(w, fmt.Sprintf(\"\\nFailed to parse arguments '%s'\\n\",err), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Retrieve history for specified traveller\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t_,history,err := self.engine.TripHistoryAsJSON(band,number)\n\tif err != nil {\n\t\tlogError(err)\n\t\thttp.Error(w, fmt.Sprintf(\"\\nFailed to retrieve flight history with error '%s'\\n\",err), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tio.WriteString(w,history)\n\n}", "func (rl *readline) ReadHistory() error {\n\tf, err := os.Open(rl.historyFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\t_, err = rl.State.ReadHistory(f)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func ExampleSmartGroupsClient_GetHistory() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclient, err := armalertsmanagement.NewSmartGroupsClient(\"9e261de7-c804-4b9d-9ebf-6f50fe350a9a\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := client.GetHistory(ctx,\n\t\t\"a808445e-bb38-4751-85c2-1b109ccc1059\",\n\t\tnil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// TODO: use response item\n\t_ = res\n}", "func viewHistory(board *chess.Board, includeEval bool, resultString string) {\n\tvar input rune\n\tindex := len(board.History) - 1\n\ttempBoard := board\n\treader := bufio.NewReader(os.Stdin)\n\tfor {\n\t\t//fmt.Print(\"\\033[1;1H\")\n\t\t//fmt.Print(\"\\033[0J\")\n\t\ttempBoard.PrintBoard(false)\n\t\tif includeEval {\n\t\t\tfmt.Println(\"Basic: \", eval.EvaluateBasic(tempBoard), \" With tables: \", eval.EvaluateWithTables(tempBoard))\n\t\t}\n\t\tfmt.Println(\"Options: a: move back one ply, d: move backward one ply, q: quit\")\n\t\tif index == -1 {\n\t\t\tfmt.Println(\"Beginning of game!\")\n\t\t} else if index == len(board.History)-1 {\n\t\t\tfmt.Println(\"End of game!\")\n\t\t\tfmt.Println(resultString)\n\t\t}\n\t\tinput, _, _ = reader.ReadRune()\n\t\tif input == 'q' {\n\t\t\tquit(board)\n\t\t} else if input == 'a' {\n\t\t\tif index == -1 { //reset index so doesn't run of end of History at first of game\n\t\t\t\tindex++\n\t\t\t}\n\t\t\tindex-- //adjust index\n\t\t\tif index == -1 {\n\t\t\t\ttempBoard, _ = chess.ParseFen(\"\") //index of -1 means initial position (not recorded in History)\n\t\t\t} else {\n\t\t\t\ttempBoard, _ = chess.ParseFen(board.History[index])\n\t\t\t}\n\n\t\t} else if input == 'd' {\n\t\t\tif index == len(board.History)-1 { //reset index\n\t\t\t\tindex--\n\t\t\t}\n\t\t\tindex++ //adjust index\n\t\t\tif index == -1 {\n\t\t\t\ttempBoard, _ = chess.ParseFen(board.History[index+1])\n\t\t\t} else {\n\t\t\t\ttempBoard, _ = chess.ParseFen(board.History[index])\n\t\t\t}\n\n\t\t}\n\t}\n}", "func (a *Agent) GetReleaseHistory(\n\tctx context.Context,\n\tname string,\n) ([]*release.Release, error) {\n\tctx, span := telemetry.NewSpan(ctx, \"helm-get-release-history\")\n\tdefer span.End()\n\n\ttelemetry.WithAttributes(span,\n\t\ttelemetry.AttributeKV{Key: \"name\", Value: name},\n\t)\n\n\tcmd := action.NewHistory(a.ActionConfig)\n\n\treturn cmd.Run(name)\n}", "func (c *FakeClient) ReleaseHistory(rlsName string, max int) ([]*release.Release, error) {\n\treturn c.Rels, nil\n}", "func (s *PublicSfcAPI) GetRewardWeights(ctx context.Context, stakerID hexutil.Uint) (map[string]interface{}, error) {\n\tbaseRewardWeight, txRewardWeight, err := s.b.GetRewardWeights(ctx, idx.StakerID(stakerID))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif baseRewardWeight == nil || txRewardWeight == nil {\n\t\treturn nil, nil\n\t}\n\treturn map[string]interface{}{\n\t\t\"baseRewardWeight\": (*hexutil.Big)(baseRewardWeight),\n\t\t\"txRewardWeight\": (*hexutil.Big)(txRewardWeight),\n\t}, nil\n}", "func GetHistoryById(historyId int , o orm.Ormer) (*models.History){\n\thistory :=models.History{Id: historyId}\n\terr:= o.Read(&history)\n\tif err == orm.ErrNoRows {\n\t\tfmt.Println(\"error: can`t find the battle\")\n\t} else if err == orm.ErrMissPK {\n\t\tfmt.Println(\"error: can`t find the primary key\")\n\t} else {\n\t\tfmt.Println(\"query finished\")\n\t}\n\treturn &history\n}", "func (f *ResolverQueueAutoIndexJobForRepoFunc) History() []ResolverQueueAutoIndexJobForRepoFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverQueueAutoIndexJobForRepoFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreTransactFunc) History() []DBStoreTransactFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreTransactFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreTransactFunc) History() []DBStoreTransactFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreTransactFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}" ]
[ "0.70522064", "0.6610849", "0.65936154", "0.6502668", "0.62767226", "0.62686336", "0.6237844", "0.6173763", "0.61523086", "0.61413825", "0.6135928", "0.6079403", "0.60785544", "0.60713136", "0.6067368", "0.60503054", "0.60456854", "0.6004538", "0.5992135", "0.59637904", "0.5960176", "0.59577703", "0.5940309", "0.5892393", "0.5877412", "0.5869292", "0.5859112", "0.5783713", "0.57722867", "0.5762689", "0.5754149", "0.57406163", "0.5732412", "0.571898", "0.5703646", "0.5695654", "0.56875676", "0.56840485", "0.56830466", "0.5674662", "0.5664659", "0.5661029", "0.5655857", "0.5646383", "0.55848265", "0.5576183", "0.5573958", "0.55723053", "0.5544371", "0.55428356", "0.55341303", "0.55338186", "0.5524111", "0.5522361", "0.5518108", "0.5512582", "0.54970104", "0.5484693", "0.5478161", "0.5465441", "0.54402965", "0.543739", "0.54235834", "0.5421337", "0.54176515", "0.54094607", "0.5395599", "0.53942937", "0.53825", "0.53705156", "0.5365871", "0.53654987", "0.5335602", "0.5323334", "0.5317307", "0.5315489", "0.5311832", "0.5310902", "0.53043246", "0.53024405", "0.5297823", "0.52961564", "0.5293678", "0.5289329", "0.5267921", "0.52647203", "0.5257755", "0.5254853", "0.5254517", "0.52516633", "0.5244258", "0.52403545", "0.5238519", "0.5234922", "0.5232974", "0.52171755", "0.52116746", "0.5208818", "0.52086145", "0.52086145" ]
0.7648041
0
getAccountReward reads account reward details
getAccountReward читает детали награды по аккаунту
func (p *Protocol) getAccountReward(epochNumber uint64, candidateName string) (*AccountReward, error) { db := p.Store.GetDB() getQuery := fmt.Sprintf(selectAccountReward, AccountRewardTableName) stmt, err := db.Prepare(getQuery) if err != nil { return nil, errors.Wrap(err, "failed to prepare get query") } defer stmt.Close() rows, err := stmt.Query(epochNumber, candidateName) if err != nil { return nil, errors.Wrap(err, "failed to execute get query") } var accountReward AccountReward parsedRows, err := s.ParseSQLRows(rows, &accountReward) if err != nil { return nil, errors.Wrap(err, "failed to parse results") } if len(parsedRows) == 0 { return nil, indexprotocol.ErrNotExist } if len(parsedRows) > 1 { return nil, errors.New("only one row is expected") } return parsedRows[0].(*AccountReward), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (as AccountStorage) GetReward(ctx sdk.Context, accKey types.AccountKey) (*Reward, sdk.Error) {\n\tstore := ctx.KVStore(as.key)\n\trewardByte := store.Get(getRewardKey(accKey))\n\tif rewardByte == nil {\n\t\treturn nil, ErrRewardNotFound()\n\t}\n\treward := new(Reward)\n\tif err := as.cdc.UnmarshalJSON(rewardByte, reward); err != nil {\n\t\treturn nil, ErrFailedToUnmarshalReward(err)\n\t}\n\treturn reward, nil\n}", "func (_TrialRulesAbstract *TrialRulesAbstractCaller) GetReward(opts *bind.CallOpts) (*big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t)\n\tout := ret0\n\terr := _TrialRulesAbstract.contract.Call(opts, out, \"getReward\")\n\treturn *ret0, err\n}", "func (_IStakingRewards *IStakingRewardsTransactor) GetReward(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _IStakingRewards.contract.Transact(opts, \"getReward\")\n}", "func (_TrialRulesAbstract *TrialRulesAbstractCallerSession) GetReward() (*big.Int, error) {\n\treturn _TrialRulesAbstract.Contract.GetReward(&_TrialRulesAbstract.CallOpts)\n}", "func (_XStaking *XStakingTransactor) GetReward(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _XStaking.contract.Transact(opts, \"getReward\")\n}", "func (_TrialRulesAbstract *TrialRulesAbstractSession) GetReward() (*big.Int, error) {\n\treturn _TrialRulesAbstract.Contract.GetReward(&_TrialRulesAbstract.CallOpts)\n}", "func (_Lmc *LmcCallerSession) GetUserAccumulatedReward(_userAddress common.Address, tokenIndex *big.Int) (*big.Int, error) {\n\treturn _Lmc.Contract.GetUserAccumulatedReward(&_Lmc.CallOpts, _userAddress, tokenIndex)\n}", "func (_Lmc *LmcSession) GetUserAccumulatedReward(_userAddress common.Address, tokenIndex *big.Int) (*big.Int, error) {\n\treturn _Lmc.Contract.GetUserAccumulatedReward(&_Lmc.CallOpts, _userAddress, tokenIndex)\n}", "func (_IStakingRewards *IStakingRewardsTransactorSession) GetReward() (*types.Transaction, error) {\n\treturn _IStakingRewards.Contract.GetReward(&_IStakingRewards.TransactOpts)\n}", "func (_IStakingRewards *IStakingRewardsSession) GetReward() (*types.Transaction, error) {\n\treturn _IStakingRewards.Contract.GetReward(&_IStakingRewards.TransactOpts)\n}", "func (_Lmc *LmcCallerSession) GetUserRewardDebt(_userAddress common.Address, _index *big.Int) (*big.Int, error) {\n\treturn _Lmc.Contract.GetUserRewardDebt(&_Lmc.CallOpts, _userAddress, _index)\n}", "func (_Lmc *LmcSession) GetUserRewardDebt(_userAddress common.Address, _index *big.Int) (*big.Int, error) {\n\treturn _Lmc.Contract.GetUserRewardDebt(&_Lmc.CallOpts, _userAddress, _index)\n}", "func (_XStaking *XStakingTransactorSession) GetReward() (*types.Transaction, error) {\n\treturn _XStaking.Contract.GetReward(&_XStaking.TransactOpts)\n}", "func (_XStaking *XStakingSession) GetReward() (*types.Transaction, error) {\n\treturn _XStaking.Contract.GetReward(&_XStaking.TransactOpts)\n}", "func (_Lmc *LmcCaller) GetUserAccumulatedReward(opts *bind.CallOpts, _userAddress common.Address, tokenIndex *big.Int) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _Lmc.contract.Call(opts, &out, \"getUserAccumulatedReward\", _userAddress, tokenIndex)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (k Keeper) GetReward(ctx sdk.Context, stakingCoinDenom string, farmerAcc sdk.AccAddress) (reward types.Reward, found bool) {\n\tstore := ctx.KVStore(k.storeKey)\n\tbz := store.Get(types.GetRewardKey(stakingCoinDenom, farmerAcc))\n\tif bz == nil {\n\t\treturn reward, false\n\t}\n\tvar rewardCoins types.RewardCoins\n\tk.cdc.MustUnmarshal(bz, &rewardCoins)\n\treturn types.Reward{\n\t\tFarmer: farmerAcc.String(),\n\t\tStakingCoinDenom: stakingCoinDenom,\n\t\tRewardCoins: rewardCoins.RewardCoins,\n\t}, true\n}", "func (c4 *Connect4) GetReward() int {\n\tif c4.Winner == nil {\n\t\treturn 0\n\t} else if *c4.Winner == 1 {\n\t\treturn 1\n\t}\n\treturn -1\n}", "func (_Lmc *LmcCaller) GetUserRewardDebt(opts *bind.CallOpts, _userAddress common.Address, _index *big.Int) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _Lmc.contract.Call(opts, &out, \"getUserRewardDebt\", _userAddress, _index)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func GetReward(a Action, feedback Action) float64 {\n\tif a == feedback {\n\t\treturn 1\n\t}\n\treturn -1\n}", "func ViewReward(rw http.ResponseWriter, r *http.Request) {\n\t// get the token\n\treqToken := r.Header.Get(\"Authorization\")\n\t\n\t// get the claims\n\tclaims, isNotValid := GetClaims(reqToken, rw)\n\tif isNotValid {\n\t\treturn\n\t}\n\n\tdt, err := db.GetUserRewards(claims.Roll)\n\tif err != nil {\n\t\trw.WriteHeader(http.StatusInternalServerError)\n\t\trw.Write(Rsp(err.Error(), \"Server Error\"))\n\t\treturn\n\t}\n\trw.WriteHeader(http.StatusOK)\n\tres := c.RespData{\n\t\tMessage: \"All data\",\n\t\tData: dt,\n\t}\n\tjson.NewEncoder(rw).Encode(res)\n}", "func (_IStakingRewards *IStakingRewardsCallerSession) GetRewardForDuration() (*big.Int, error) {\n\treturn _IStakingRewards.Contract.GetRewardForDuration(&_IStakingRewards.CallOpts)\n}", "func (_IStakingRewards *IStakingRewardsSession) GetRewardForDuration() (*big.Int, error) {\n\treturn _IStakingRewards.Contract.GetRewardForDuration(&_IStakingRewards.CallOpts)\n}", "func (_XStaking *XStakingCallerSession) GetRewardForDuration() (*big.Int, error) {\n\treturn _XStaking.Contract.GetRewardForDuration(&_XStaking.CallOpts)\n}", "func (_IStakingRewards *IStakingRewardsCaller) GetRewardForDuration(opts *bind.CallOpts) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _IStakingRewards.contract.Call(opts, &out, \"getRewardForDuration\")\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (_XStaking *XStakingSession) GetRewardForDuration() (*big.Int, error) {\n\treturn _XStaking.Contract.GetRewardForDuration(&_XStaking.CallOpts)\n}", "func (_Token *TokenCaller) CurrentReward(opts *bind.CallOpts, account common.Address) (struct {\n\tInitialDeposit *big.Int\n\tReward *big.Int\n}, error) {\n\tret := new(struct {\n\t\tInitialDeposit *big.Int\n\t\tReward *big.Int\n\t})\n\tout := ret\n\terr := _Token.contract.Call(opts, out, \"currentReward\", account)\n\treturn *ret, err\n}", "func (c *gRPCClient) AccountRewards(address gosmtypes.Address, offset uint32, maxResults uint32) ([]*apitypes.Reward, uint32, error) {\n\tgsc := c.getGlobalStateServiceClient()\n\tresp, err := gsc.AccountDataQuery(context.Background(), &apitypes.AccountDataQueryRequest{\n\t\tFilter: &apitypes.AccountDataFilter{\n\t\t\tAccountId: &apitypes.AccountId{Address: address.Bytes()},\n\t\t\tAccountDataFlags: uint32(apitypes.AccountDataFlag_ACCOUNT_DATA_FLAG_REWARD),\n\t\t},\n\n\t\tMaxResults: maxResults,\n\t\tOffset: offset,\n\t})\n\n\tif err != nil {\n\t\treturn nil, 0, err\n\t}\n\n\trewards := make([]*apitypes.Reward, 0)\n\n\tfor _, data := range resp.AccountItem {\n\t\tr := data.GetReward()\n\t\tif r != nil {\n\t\t\trewards = append(rewards, r)\n\t\t}\n\t}\n\n\treturn rewards, resp.TotalResults, nil\n}", "func (_Token *TokenCaller) BaseReward(opts *bind.CallOpts, index *big.Int) (*big.Int, *big.Int, *big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t\tret1 = new(*big.Int)\n\t\tret2 = new(*big.Int)\n\t)\n\tout := &[]interface{}{\n\t\tret0,\n\t\tret1,\n\t\tret2,\n\t}\n\terr := _Token.contract.Call(opts, out, \"baseReward\", index)\n\treturn *ret0, *ret1, *ret2, err\n}", "func (_XStaking *XStakingCaller) GetRewardForDuration(opts *bind.CallOpts) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _XStaking.contract.Call(opts, &out, \"getRewardForDuration\")\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (_Token *TokenSession) CurrentReward(account common.Address) (struct {\n\tInitialDeposit *big.Int\n\tReward *big.Int\n}, error) {\n\treturn _Token.Contract.CurrentReward(&_Token.CallOpts, account)\n}", "func (_Token *TokenCallerSession) BaseReward(index *big.Int) (*big.Int, *big.Int, *big.Int, error) {\n\treturn _Token.Contract.BaseReward(&_Token.CallOpts, index)\n}", "func (as AccountStorage) GetRewardHistory(\n\tctx sdk.Context, me types.AccountKey, bucketSlot int64) (*RewardHistory, sdk.Error) {\n\tstore := ctx.KVStore(as.key)\n\trewardHistoryBytes := store.Get(getRewardHistoryKey(me, bucketSlot))\n\tif rewardHistoryBytes == nil {\n\t\treturn nil, nil\n\t}\n\thistory := new(RewardHistory)\n\tif err := as.cdc.UnmarshalJSON(rewardHistoryBytes, history); err != nil {\n\t\treturn nil, ErrFailedToUnmarshalRewardHistory(err)\n\t}\n\treturn history, nil\n}", "func (_Token *TokenCallerSession) CurrentReward(account common.Address) (struct {\n\tInitialDeposit *big.Int\n\tReward *big.Int\n}, error) {\n\treturn _Token.Contract.CurrentReward(&_Token.CallOpts, account)\n}", "func (_Token *TokenSession) BaseReward(index *big.Int) (*big.Int, *big.Int, *big.Int, error) {\n\treturn _Token.Contract.BaseReward(&_Token.CallOpts, index)\n}", "func (s *BlocksService) Reward(ctx context.Context) (*BlocksReward, *http.Response, error) {\n\tvar responseStruct *BlocksReward\n\tresp, err := s.client.SendRequest(ctx, \"GET\", \"blocks/getReward\", nil, &responseStruct)\n\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn responseStruct, resp, err\n}", "func GenerateGetRewardBalanceScript(env Environment) []byte {\n\tcode := assets.MustAssetString(rewardBalanceFilename)\n\n\treturn []byte(replaceAddresses(code, env))\n}", "func (c RewardsController) GetRewards(page int) revel.Result {\n\n\tif !c.GetCurrentUser() {\n\t\treturn c.ForbiddenResponse()\n\t}\n\n\t//ChangeRewardsModel() // Remove when finish production\n\n\tvar reward models.Reward\n\tif Reward, ok := app.Mapper.GetModel(&reward); ok {\n\t\tvar rewards = []models.Reward{}\n\t\tvar match = bson.M{\"$and\": []bson.M{\n\t\t\tbson.M{\"$or\": []bson.M{\n\t\t\t\tbson.M{\"user_id\": c.CurrentUser.GetID().Hex()},\n\t\t\t\tbson.M{\"users\": bson.M{\"$elemMatch\": bson.M{\"$eq\": c.CurrentUser.GetID().Hex()}}},\n\t\t\t}},\n\t\t\tbson.M{\"is_visible\": true},\n\t\t\tbson.M{\"resource_type\": bson.M{\"$ne\": core.ModelTypeChallenge}},\n\t\t}}\n\t\tif page <= 1 {\n\t\t\tpage = 1\n\t\t}\n\t\tvar pipe = mgomap.Aggregate{}.Match(match).Sort(bson.M{\"updated_at\": -1}).Skip((page - 1) * core.LimitRewards).Limit(core.LimitRewards)\n\n\t\tif err := Reward.Pipe(pipe, &rewards); err != nil {\n\t\t\treturn c.ErrorResponse(c.Message(\"error.notFound\", \"Rewards\"), \"No rewards Found\", 400)\n\t\t}\n\t\treturn c.SuccessResponse(rewards, \"success\", core.ModelsType[core.ModelReward], serializers.RewardSerializer{Lang: c.Request.Locale})\n\n\t}\n\treturn c.ServerErrorResponse()\n}", "func getAccumulatedRewards(ctx sdk.Context, distKeeper types.DistributionKeeper, delegation stakingtypes.Delegation) ([]wasmvmtypes.Coin, error) {\n\t// Try to get *delegator* reward info!\n\tparams := distributiontypes.QueryDelegationRewardsRequest{\n\t\tDelegatorAddress: delegation.DelegatorAddress,\n\t\tValidatorAddress: delegation.ValidatorAddress,\n\t}\n\tcache, _ := ctx.CacheContext()\n\tqres, err := distKeeper.DelegationRewards(sdk.WrapSDKContext(cache), &params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// now we have it, convert it into wasmvm types\n\trewards := make([]wasmvmtypes.Coin, len(qres.Rewards))\n\tfor i, r := range qres.Rewards {\n\t\trewards[i] = wasmvmtypes.Coin{\n\t\t\tDenom: r.Denom,\n\t\t\tAmount: r.Amount.TruncateInt().String(),\n\t\t}\n\t}\n\treturn rewards, nil\n}", "func MiningRewardBalance(block consensus.Block, account []byte) *RTU {\n//\tif bytes, err := block.Lookup([]byte(bytesToHexString(account))); err == nil {\n\tif bytes, err := block.Lookup(account); err == nil {\n\t\treturn BytesToRtu(bytes)\n\t}\n\treturn BytesToRtu(nil)\n}", "func (t *Transaction) Reward() string {\n\treturn t.reward\n}", "func (a Actor) AwardBlockReward(rt vmr.Runtime, params *AwardBlockRewardParams) *adt.EmptyValue {\n\trt.ValidateImmediateCallerIs(builtin.SystemActorAddr)\n\tAssertMsg(rt.CurrentBalance().GreaterThanEqual(params.GasReward),\n\t\t\"actor current balance %v insufficient to pay gas reward %v\", rt.CurrentBalance(), params.GasReward)\n\n\tAssertMsg(params.TicketCount > 0, \"cannot give block reward for zero tickets\")\n\n\tminer, ok := rt.ResolveAddress(params.Miner)\n\tif !ok {\n\t\trt.Abortf(exitcode.ErrIllegalState, \"failed to resolve given owner address\")\n\t}\n\n\tpriorBalance := rt.CurrentBalance()\n\n\tvar penalty abi.TokenAmount\n\tvar st State\n\trt.State().Transaction(&st, func() interface{} {\n\t\tblockReward := a.computeBlockReward(&st, big.Sub(priorBalance, params.GasReward), params.TicketCount)\n\t\ttotalReward := big.Add(blockReward, params.GasReward)\n\n\t\t// Cap the penalty at the total reward value.\n\t\tpenalty = big.Min(params.Penalty, totalReward)\n\n\t\t// Reduce the payable reward by the penalty.\n\t\trewardPayable := big.Sub(totalReward, penalty)\n\n\t\tAssertMsg(big.Add(rewardPayable, penalty).LessThanEqual(priorBalance),\n\t\t\t\"reward payable %v + penalty %v exceeds balance %v\", rewardPayable, penalty, priorBalance)\n\n\t\t// Record new reward into reward map.\n\t\tif rewardPayable.GreaterThan(abi.NewTokenAmount(0)) {\n\t\t\tnewReward := Reward{\n\t\t\t\tStartEpoch: rt.CurrEpoch(),\n\t\t\t\tEndEpoch: rt.CurrEpoch() + rewardVestingPeriod,\n\t\t\t\tValue: rewardPayable,\n\t\t\t\tAmountWithdrawn: abi.NewTokenAmount(0),\n\t\t\t\tVestingFunction: rewardVestingFunction,\n\t\t\t}\n\t\t\tif err := st.addReward(adt.AsStore(rt), miner, &newReward); err != nil {\n\t\t\t\trt.Abortf(exitcode.ErrIllegalState, \"failed to add reward to rewards map: %w\", err)\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\n\t// Burn the penalty amount.\n\t_, code := rt.Send(builtin.BurntFundsActorAddr, builtin.MethodSend, nil, penalty)\n\tbuiltin.RequireSuccess(rt, code, \"failed to send penalty to BurntFundsActor\")\n\n\treturn nil\n}", "func (m *MemoryRewardStorage) Get(id int) (rewards.Reward, error) {\n\tvar reward rewards.Reward\n\n\tfor _, r := range m.rewards {\n\t\tif r.ID == id {\n\t\t\treturn r, nil\n\t\t}\n\t}\n\n\treturn reward, rewards.ErrNotFound\n}", "func (mgr *MiningMgr) currentReward() (*big.Int, error) {\n\ttimeOfLastNewValue, err := mgr.contractInstance.GetUintVar(nil, rpc.Keccak256([]byte(\"_TIME_OF_LAST_NEW_VALUE\")))\n\tif err != nil {\n\t\treturn nil, errors.New(\"getting _TIME_OF_LAST_NEW_VALUE\")\n\t}\n\ttotalTips, err := mgr.contractInstance.GetUintVar(nil, rpc.Keccak256([]byte(\"_CURRENT_TOTAL_TIPS\")))\n\tif err != nil {\n\t\treturn nil, errors.New(\"getting _CURRENT_TOTAL_TIPS\")\n\t}\n\n\ttimeDiff := big.NewInt(time.Now().Unix() - timeOfLastNewValue.Int64())\n\ttrb := big.NewInt(1e18)\n\trewardPerSec := big.NewInt(0).Div(trb, big.NewInt(300)) // 1 TRB every 5 minutes so total reward is timeDiff multiplied by reward per second.\n\trewardTRB := big.NewInt(0).Mul(rewardPerSec, timeDiff)\n\n\tsingleMinerTip := big.NewInt(0).Div(totalTips, big.NewInt(10)) // Half of the tips are burned(remain in the contract) to reduce inflation.\n\trewardWithTips := big.NewInt(0).Add(singleMinerTip, rewardTRB)\n\n\tif rewardWithTips == big.NewInt(0) {\n\t\treturn big.NewInt(0), nil\n\t}\n\n\treturn mgr.convertTRBtoETH(rewardWithTips)\n}", "func getRewardForValidator(totalPower *big.Int, validatorPower *big.Int, totalRewards *balance.Amount) *balance.Amount {\n\tnumerator := big.NewInt(0).Mul(totalRewards.BigInt(), validatorPower)\n\treward := balance.NewAmountFromBigInt(big.NewInt(0).Div(numerator, totalPower))\n\treturn reward\n}", "func EstimateReward(reward, pr, gamma float64) float64 {\n\tret := reward / (pr + gamma)\n\tlog.Logf(MABLogLevel, \"MAB Estimate Reward: %v / (%v + %v) = %v\\n\",\n\t\treward, pr, gamma, ret)\n\treturn ret\n}", "func (c *Coinbase) AddReward(output *Output) {\n\toutput.EncryptedMask = make([]byte, 1)\n\tc.Rewards = append(c.Rewards, output)\n}", "func (k Querier) Rewards(c context.Context, req *types.QueryRewardsRequest) (*types.QueryRewardsResponse, error) {\n\tif req == nil {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"invalid request\")\n\t}\n\n\tif req.StakingCoinDenom != \"\" {\n\t\tif err := sdk.ValidateDenom(req.StakingCoinDenom); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tctx := sdk.UnwrapSDKContext(c)\n\tstore := ctx.KVStore(k.storeKey)\n\tvar rewards []types.Reward\n\tvar pageRes *query.PageResponse\n\tvar err error\n\n\tif req.Farmer != \"\" {\n\t\tvar farmerAcc sdk.AccAddress\n\t\tfarmerAcc, err = sdk.AccAddressFromBech32(req.Farmer)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tstorePrefix := types.GetRewardsByFarmerIndexKey(farmerAcc)\n\t\tindexStore := prefix.NewStore(store, storePrefix)\n\t\tpageRes, err = query.FilteredPaginate(indexStore, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) {\n\t\t\t_, stakingCoinDenom := types.ParseRewardsByFarmerIndexKey(append(storePrefix, key...))\n\t\t\tif req.StakingCoinDenom != \"\" {\n\t\t\t\tif stakingCoinDenom != req.StakingCoinDenom {\n\t\t\t\t\treturn false, nil\n\t\t\t\t}\n\t\t\t}\n\t\t\treward, found := k.GetReward(ctx, stakingCoinDenom, farmerAcc)\n\t\t\tif !found { // TODO: remove this check\n\t\t\t\treturn false, fmt.Errorf(\"reward not found\")\n\t\t\t}\n\t\t\tif accumulate {\n\t\t\t\trewards = append(rewards, reward)\n\t\t\t}\n\t\t\treturn true, nil\n\t\t})\n\t} else {\n\t\tvar storePrefix []byte\n\t\tif req.StakingCoinDenom != \"\" {\n\t\t\tstorePrefix = types.GetRewardsByStakingCoinDenomKey(req.StakingCoinDenom)\n\t\t} else {\n\t\t\tstorePrefix = types.RewardKeyPrefix\n\t\t}\n\t\trewardStore := prefix.NewStore(store, storePrefix)\n\n\t\tpageRes, err = query.Paginate(rewardStore, req.Pagination, func(key, value []byte) error {\n\t\t\tstakingCoinDenom, farmerAcc := types.ParseRewardKey(append(storePrefix, key...))\n\t\t\trewardCoins, err := k.UnmarshalRewardCoins(value)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\trewards = append(rewards, types.Reward{\n\t\t\t\tFarmer: farmerAcc.String(),\n\t\t\t\tStakingCoinDenom: stakingCoinDenom,\n\t\t\t\tRewardCoins: rewardCoins.RewardCoins,\n\t\t\t})\n\t\t\treturn nil\n\t\t})\n\t}\n\tif err != nil {\n\t\treturn nil, status.Error(codes.Internal, err.Error())\n\t}\n\n\treturn &types.QueryRewardsResponse{Rewards: rewards, Pagination: pageRes}, nil\n}", "func (n Network) ChainReward(ctx context.Context, launchID uint64) (rewardtypes.RewardPool, error) {\n\tres, err := n.rewardQuery.\n\t\tRewardPool(ctx,\n\t\t\t&rewardtypes.QueryGetRewardPoolRequest{\n\t\t\t\tLaunchID: launchID,\n\t\t\t},\n\t\t)\n\n\tif cosmoserror.Unwrap(err) == cosmoserror.ErrNotFound {\n\t\treturn rewardtypes.RewardPool{}, ErrObjectNotFound\n\t} else if err != nil {\n\t\treturn rewardtypes.RewardPool{}, err\n\t}\n\treturn res.RewardPool, nil\n}", "func computeReward(epoch abi.ChainEpoch, prevTheta, currTheta, simpleTotal, baselineTotal big.Int) abi.TokenAmount {\n\tsimpleReward := big.Mul(simpleTotal, ExpLamSubOne) //Q.0 * Q.128 => Q.128\n\tepochLam := big.Mul(big.NewInt(int64(epoch)), Lambda) // Q.0 * Q.128 => Q.128\n\n\tsimpleReward = big.Mul(simpleReward, big.NewFromGo(math.ExpNeg(epochLam.Int))) // Q.128 * Q.128 => Q.256\n\tsimpleReward = big.Rsh(simpleReward, math.Precision128) // Q.256 >> 128 => Q.128\n\n\tbaselineReward := big.Sub(computeBaselineSupply(currTheta, baselineTotal), computeBaselineSupply(prevTheta, baselineTotal)) // Q.128\n\n\treward := big.Add(simpleReward, baselineReward) // Q.128\n\n\treturn big.Rsh(reward, math.Precision128) // Q.128 => Q.0\n}", "func (c RewardsController) CollectReward(id string) revel.Result {\n\tif !c.GetCurrentUser() {\n\t\treturn c.ForbiddenResponse()\n\t}\n\n\tif !bson.IsObjectIdHex(id) {\n\t\treturn c.ErrorResponse(nil, c.Message(\"error.invalid\", \"\"), core.ModelStatus[core.StatusInvalidID])\n\t}\n\n\tvar selector = []bson.M{\n\t\tbson.M{\"user_id\": c.CurrentUser.GetID().Hex()},\n\t\tbson.M{\"_id\": id},\n\t\tbson.M{\"multi\": false},\n\t}\n\tvar query = bson.M{\"$set\": []bson.M{\n\t\tbson.M{\"status.name\": core.StatusObtained},\n\t\tbson.M{\"status.code\": core.ValidationStatus[core.StatusObtained]},\n\t}}\n\n\t// Get pending Rewards for the user\n\tif Reward, ok := app.Mapper.GetModel(&models.Reward{}); ok {\n\t\tif err := Reward.UpdateQuery(selector, query, false); err != nil {\n\t\t\trevel.ERROR.Print(\"ERROR Find\")\n\t\t\treturn c.ErrorResponse(err, err.Error(), 400)\n\t\t}\n\t\treturn c.SuccessResponse(bson.M{\"data\": \"Reward collected successfully\"}, \"success\", core.ModelsType[core.ModelSimpleResponse], nil)\n\t}\n\n\treturn c.ServerErrorResponse()\n}", "func (_BondedECDSAKeep *BondedECDSAKeepTransactorSession) DistributeETHReward() (*types.Transaction, error) {\n\treturn _BondedECDSAKeep.Contract.DistributeETHReward(&_BondedECDSAKeep.TransactOpts)\n}", "func (s *PublicSfcAPI) GetRewardWeights(ctx context.Context, stakerID hexutil.Uint) (map[string]interface{}, error) {\n\tbaseRewardWeight, txRewardWeight, err := s.b.GetRewardWeights(ctx, idx.StakerID(stakerID))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif baseRewardWeight == nil || txRewardWeight == nil {\n\t\treturn nil, nil\n\t}\n\treturn map[string]interface{}{\n\t\t\"baseRewardWeight\": (*hexutil.Big)(baseRewardWeight),\n\t\t\"txRewardWeight\": (*hexutil.Big)(txRewardWeight),\n\t}, nil\n}", "func (_BondedECDSAKeep *BondedECDSAKeepSession) DistributeETHReward() (*types.Transaction, error) {\n\treturn _BondedECDSAKeep.Contract.DistributeETHReward(&_BondedECDSAKeep.TransactOpts)\n}", "func (vi *votedInfo) CalculateReward(multiplier, divider *big.Int, period int) {\n\tif multiplier.Sign() == 0 || period == 0 {\n\t\treturn\n\t}\n\tif divider.Sign() == 0 || vi.totalBondedDelegation.Sign() == 0 {\n\t\treturn\n\t}\n\t// reward = multiplier * period * bondedDelegation / (divider * totalBondedDelegation)\n\tbase := new(big.Int).Mul(multiplier, big.NewInt(int64(period)))\n\treward := new(big.Int)\n\tfor i, addrKey := range vi.rank {\n\t\tif i == vi.maxRankForReward {\n\t\t\tbreak\n\t\t}\n\t\tprep := vi.preps[addrKey]\n\t\tif prep.Enable() == false {\n\t\t\tcontinue\n\t\t}\n\n\t\treward.Mul(base, prep.GetBondedDelegation())\n\t\treward.Div(reward, divider)\n\t\treward.Div(reward, vi.totalBondedDelegation)\n\n\t\tlog.Tracef(\"VOTED REWARD %d = %d * %d * %d / (%d * %d)\",\n\t\t\treward, multiplier, period, prep.GetBondedDelegation(), divider, vi.totalBondedDelegation)\n\n\t\tprep.SetIScore(new(big.Int).Add(prep.IScore(), reward))\n\t}\n}", "func (_BondedECDSAKeep *BondedECDSAKeepTransactor) DistributeETHReward(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _BondedECDSAKeep.contract.Transact(opts, \"distributeETHReward\")\n}", "func (_Lmc *LmcCallerSession) GetUserRewardDebtLength(_userAddress common.Address) (*big.Int, error) {\n\treturn _Lmc.Contract.GetUserRewardDebtLength(&_Lmc.CallOpts, _userAddress)\n}", "func (p *Protocol) getRewardHistory(actionHash string) ([]*RewardHistory, error) {\n\tdb := p.Store.GetDB()\n\n\tgetQuery := fmt.Sprintf(selectRewardHistory,\n\t\tRewardHistoryTableName)\n\tstmt, err := db.Prepare(getQuery)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to prepare get query\")\n\t}\n\tdefer stmt.Close()\n\n\trows, err := stmt.Query(actionHash)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to execute get query\")\n\t}\n\n\tvar rewardHistory RewardHistory\n\tparsedRows, err := s.ParseSQLRows(rows, &rewardHistory)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to parse results\")\n\t}\n\n\tif len(parsedRows) == 0 {\n\t\treturn nil, indexprotocol.ErrNotExist\n\t}\n\n\tvar rewardHistoryList []*RewardHistory\n\tfor _, parsedRow := range parsedRows {\n\t\trewards := parsedRow.(*RewardHistory)\n\t\trewardHistoryList = append(rewardHistoryList, rewards)\n\t}\n\treturn rewardHistoryList, nil\n}", "func (t *SimpleChaincode) getBalance(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tvar sourceAccountName, destinationAccountName string // Entities\n\tvar err error\n\n\tif len(args) != 2 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting name of the person to query\")\n\t}\n\n\tsourceAccountName = args[0]\n\tdestinationAccountName = args[1]\n\n\t// Get the state from the ledger\n\taccountValBytes, err := stub.GetState(sourceAccountName + \".\" + destinationAccountName)\n\tif err != nil {\n\t\tjsonResp := \"{\\\"Error\\\":\\\"Failed to get state for \" + sourceAccountName + \".\" + destinationAccountName + \"\\\"}\"\n\t\treturn shim.Error(jsonResp)\n\t}\n\n\tif accountValBytes == nil {\n\t\taccountValBytes = []byte(\"0\")\n\t}\n\n\tjsonResp := \"{\\\"Source\\\":\\\"\" + sourceAccountName + \"\\\",\" +\n\t\t\"\\\"Destination\\\":\\\"\" + destinationAccountName + \"\\\",\\\"\" +\n\t\t\"Amount\\\":\\\"\" + string(accountValBytes) + \"\\\"}\"\n\tfmt.Printf(\"Query Response:%s\\n\", jsonResp)\n\treturn shim.Success(accountValBytes)\n}", "func (r *Rewarding) BlockReward() *big.Int {\n\tval, ok := new(big.Int).SetString(r.BlockRewardStr, 10)\n\tif !ok {\n\t\tlog.S().Panicf(\"Error when casting block reward string %s into big int\", r.BlockRewardStr)\n\t}\n\treturn val\n}", "func (va ClawbackVestingAccount) distributeReward(ctx sdk.Context, ak AccountKeeper, bondDenom string, reward sdk.Coins) {\n\tnow := ctx.BlockTime().Unix()\n\tt := va.StartTime\n\tfirstUnvestedPeriod := 0\n\tunvestedTokens := sdk.ZeroInt()\n\tfor i, period := range va.VestingPeriods {\n\t\tt += period.Length\n\t\tif t <= now {\n\t\t\tfirstUnvestedPeriod = i + 1\n\t\t\tcontinue\n\t\t}\n\t\tunvestedTokens = unvestedTokens.Add(period.Amount.AmountOf(bondDenom))\n\t}\n\n\trunningTotReward := sdk.NewCoins()\n\trunningTotStaking := sdk.ZeroInt()\n\tfor i := firstUnvestedPeriod; i < len(va.VestingPeriods); i++ {\n\t\tperiod := va.VestingPeriods[i]\n\t\trunningTotStaking = runningTotStaking.Add(period.Amount.AmountOf(bondDenom))\n\t\trunningTotRatio := runningTotStaking.ToDec().Quo(unvestedTokens.ToDec())\n\t\ttargetCoins := scaleCoins(reward, runningTotRatio)\n\t\tthisReward := targetCoins.Sub(runningTotReward)\n\t\trunningTotReward = targetCoins\n\t\tperiod.Amount = period.Amount.Add(thisReward...)\n\t\tva.VestingPeriods[i] = period\n\t}\n\n\tva.OriginalVesting = va.OriginalVesting.Add(reward...)\n\tak.SetAccount(ctx, &va)\n}", "func (del Delegation) ClaimedReward() (hexutil.Big, error) {\n\tval, err := repository.R().RewardsClaimed(&del.Address, (*big.Int)(del.Delegation.ToStakerId), nil, nil)\n\tif err != nil {\n\t\treturn hexutil.Big{}, err\n\t}\n\treturn (hexutil.Big)(*val), nil\n}", "func (_Lmc *LmcSession) GetUserRewardDebtLength(_userAddress common.Address) (*big.Int, error) {\n\treturn _Lmc.Contract.GetUserRewardDebtLength(&_Lmc.CallOpts, _userAddress)\n}", "func GetRewardEventsInfo(fromBlock *big.Int, toBlock *big.Int) []*RewardInfo {\n\n\tvar logEpochRewardSig = []byte(\"EpochRewardsDistributedToVoters(address,uint256)\")\n\tvar logEpochRewardSigHash = crypto.Keccak256Hash(logEpochRewardSig)\n\tvar TopicsFilter = [][]common.Hash{{logEpochRewardSigHash}}\n\n\tcontractAddress := common.HexToAddress(WrapperContractDeploymentAddress[NetActive][Election])\n\n\tquery := ethereum.FilterQuery{\n\t\tFromBlock: fromBlock,\n\t\tToBlock: toBlock,\n\t\tTopics: TopicsFilter,\n\n\t\tAddresses: []common.Address{\n\t\t\tcontractAddress,\n\t\t},\n\t}\n\n\tlogs, err := atlasEthClient.FilterLogs(context.Background(), query)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\trewards_info := make([]*RewardInfo, 0, len(logs))\n\n\tcontractAbi, err := abi.JSON(strings.NewReader(string(binding.ElectionABI)))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfor _, vLog := range logs {\n\n\t\tvar epochRewardEvent EpochRewardEvent\n\t\terr := contractAbi.Unpack(&epochRewardEvent, \"EpochRewardsDistributedToVoters\", vLog.Data)\n\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tri := &RewardInfo{Group: common.HexToAddress(vLog.Topics[1].Hex()).String(),\n\t\t\tGroupHash: vLog.Topics[1],\n\t\t\tRewardValue: epochRewardEvent.Value,\n\t\t\tBlockNumber: new(big.Int).SetUint64(vLog.BlockNumber)}\n\n\t\tAddAtlasToRewardInfo(ri)\n\n\t\trewards_info = append(rewards_info, ri)\n\t}\n\n\treturn rewards_info\n}", "func (_IStakingRewards *IStakingRewardsCaller) LastTimeRewardApplicable(opts *bind.CallOpts) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _IStakingRewards.contract.Call(opts, &out, \"lastTimeRewardApplicable\")\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (cra clawbackRewardAction) ProcessReward(ctx sdk.Context, reward sdk.Coins, rawAccount exported.VestingAccount) error {\n\tcva, ok := rawAccount.(*ClawbackVestingAccount)\n\tif !ok {\n\t\treturn sdkerrors.Wrapf(sdkerrors.ErrNotSupported, \"expected *ClawbackVestingAccount, got %T\", rawAccount)\n\t}\n\tcva.postReward(ctx, reward, cra.ak, cra.bk, cra.sk)\n\treturn nil\n}", "func (_Smartchef *SmartchefCallerSession) PendingReward(_user common.Address) (*big.Int, error) {\n\treturn _Smartchef.Contract.PendingReward(&_Smartchef.CallOpts, _user)\n}", "func (s *MutableState) AddRewards(time epochtime.EpochTime, factor *quantity.Quantity, accounts []signature.PublicKey) error {\n\tsteps, err := s.RewardSchedule()\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar activeStep *staking.RewardStep\n\tfor _, step := range steps {\n\t\tif time < step.Until {\n\t\t\tactiveStep = &step\n\t\t\tbreak\n\t\t}\n\t}\n\tif activeStep == nil {\n\t\t// We're past the end of the schedule.\n\t\treturn nil\n\t}\n\n\tcommonPool, err := s.CommonPool()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"loading common pool\")\n\t}\n\n\tfor _, id := range accounts {\n\t\tent := s.Account(id)\n\n\t\tq := ent.Escrow.Active.Balance.Clone()\n\t\t// Multiply first.\n\t\tif err := q.Mul(factor); err != nil {\n\t\t\treturn errors.Wrap(err, \"multiplying by reward factor\")\n\t\t}\n\t\tif err := q.Mul(&activeStep.Scale); err != nil {\n\t\t\treturn errors.Wrap(err, \"multiplying by reward step scale\")\n\t\t}\n\t\tif err := q.Quo(staking.RewardAmountDenominator); err != nil {\n\t\t\treturn errors.Wrap(err, \"dividing by reward amount denominator\")\n\t\t}\n\n\t\tif q.IsZero() {\n\t\t\tcontinue\n\t\t}\n\n\t\tvar com *quantity.Quantity\n\t\trate := ent.Escrow.CommissionSchedule.CurrentRate(time)\n\t\tif rate != nil {\n\t\t\tcom = q.Clone()\n\t\t\t// Multiply first.\n\t\t\tif err := com.Mul(rate); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"multiplying by commission rate\")\n\t\t\t}\n\t\t\tif err := com.Quo(staking.CommissionRateDenominator); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"dividing by commission rate denominator\")\n\t\t\t}\n\n\t\t\tif err := q.Sub(com); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"subtracting commission\")\n\t\t\t}\n\t\t}\n\n\t\tif !q.IsZero() {\n\t\t\tif err := quantity.Move(&ent.Escrow.Active.Balance, commonPool, q); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"transferring to active escrow balance from common pool\")\n\t\t\t}\n\t\t}\n\n\t\tif com != nil && !com.IsZero() {\n\t\t\tdelegation := s.Delegation(id, id)\n\n\t\t\tif err := ent.Escrow.Active.Deposit(&delegation.Shares, commonPool, com); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"depositing commission\")\n\t\t\t}\n\n\t\t\ts.SetDelegation(id, id, delegation)\n\t\t}\n\n\t\ts.SetAccount(id, ent)\n\t}\n\n\ts.SetCommonPool(commonPool)\n\n\treturn nil\n}", "func (_Contract *ContractCaller) TaskHandlingReward(opts *bind.CallOpts) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _Contract.contract.Call(opts, &out, \"taskHandlingReward\")\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (s *MutableState) AddRewardSingleAttenuated(time epochtime.EpochTime, factor *quantity.Quantity, attenuationNumerator, attenuationDenominator int, account signature.PublicKey) error {\n\tsteps, err := s.RewardSchedule()\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar activeStep *staking.RewardStep\n\tfor _, step := range steps {\n\t\tif time < step.Until {\n\t\t\tactiveStep = &step\n\t\t\tbreak\n\t\t}\n\t}\n\tif activeStep == nil {\n\t\t// We're past the end of the schedule.\n\t\treturn nil\n\t}\n\n\tvar numQ, denQ quantity.Quantity\n\tif err = numQ.FromInt64(int64(attenuationNumerator)); err != nil {\n\t\treturn errors.Wrapf(err, \"importing attenuation numerator %d\", attenuationNumerator)\n\t}\n\tif err = denQ.FromInt64(int64(attenuationDenominator)); err != nil {\n\t\treturn errors.Wrapf(err, \"importing attenuation denominator %d\", attenuationDenominator)\n\t}\n\n\tcommonPool, err := s.CommonPool()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"loading common pool\")\n\t}\n\n\tent := s.Account(account)\n\n\tq := ent.Escrow.Active.Balance.Clone()\n\t// Multiply first.\n\tif err := q.Mul(factor); err != nil {\n\t\treturn errors.Wrap(err, \"multiplying by reward factor\")\n\t}\n\tif err := q.Mul(&activeStep.Scale); err != nil {\n\t\treturn errors.Wrap(err, \"multiplying by reward step scale\")\n\t}\n\tif err := q.Mul(&numQ); err != nil {\n\t\treturn errors.Wrap(err, \"multiplying by attenuation numerator\")\n\t}\n\tif err := q.Quo(staking.RewardAmountDenominator); err != nil {\n\t\treturn errors.Wrap(err, \"dividing by reward amount denominator\")\n\t}\n\tif err := q.Quo(&denQ); err != nil {\n\t\treturn errors.Wrap(err, \"dividing by attenuation denominator\")\n\t}\n\n\tif q.IsZero() {\n\t\treturn nil\n\t}\n\n\tvar com *quantity.Quantity\n\trate := ent.Escrow.CommissionSchedule.CurrentRate(time)\n\tif rate != nil {\n\t\tcom = q.Clone()\n\t\t// Multiply first.\n\t\tif err := com.Mul(rate); err != nil {\n\t\t\treturn errors.Wrap(err, \"multiplying by commission rate\")\n\t\t}\n\t\tif err := com.Quo(staking.CommissionRateDenominator); err != nil {\n\t\t\treturn errors.Wrap(err, \"dividing by commission rate denominator\")\n\t\t}\n\n\t\tif err := q.Sub(com); err != nil {\n\t\t\treturn errors.Wrap(err, \"subtracting commission\")\n\t\t}\n\t}\n\n\tif !q.IsZero() {\n\t\tif err := quantity.Move(&ent.Escrow.Active.Balance, commonPool, q); err != nil {\n\t\t\treturn errors.Wrap(err, \"transferring to active escrow balance from common pool\")\n\t\t}\n\t}\n\n\tif com != nil && !com.IsZero() {\n\t\tdelegation := s.Delegation(account, account)\n\n\t\tif err := ent.Escrow.Active.Deposit(&delegation.Shares, commonPool, com); err != nil {\n\t\t\treturn errors.Wrap(err, \"depositing commission\")\n\t\t}\n\n\t\ts.SetDelegation(account, account, delegation)\n\t}\n\n\ts.SetAccount(account, ent)\n\n\ts.SetCommonPool(commonPool)\n\n\treturn nil\n}", "func (_Smartchef *SmartchefCaller) PendingReward(opts *bind.CallOpts, _user common.Address) (*big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t)\n\tout := ret0\n\terr := _Smartchef.contract.Call(opts, out, \"pendingReward\", _user)\n\treturn *ret0, err\n}", "func (d *Dao) UseReward(id int64, usePlat string) (rst bool, err error) {\n\tif err := d.orm.\n\t\tModel(&model.AnchorReward{}).\n\t\tWhere(\"id=?\", id).\n\t\tUpdate(map[string]interface{}{\"status\": model.RewardUsed, \"use_plat\": usePlat, \"use_time\": xtime.Time(time.Now().Unix())}).Error; err != nil {\n\t\tlog.Error(\"useReward (%v) error(%v)\", id, err)\n\t\treturn rst, err\n\t}\n\trst = true\n\treturn\n}", "func (_Lmc *LmcCallerSession) LastRewardBlock() (*big.Int, error) {\n\treturn _Lmc.Contract.LastRewardBlock(&_Lmc.CallOpts)\n}", "func (r *Reward) GetRewardForBlock(blockHeight uint64) *big.Int {\n\tblockHeight += r.startHeight\n\n\tif blockHeight > lastBlock {\n\t\treturn big.NewInt(0)\n\t}\n\n\tif blockHeight == lastBlock {\n\t\treturn helpers.BipToPip(big.NewInt(lastReward))\n\t}\n\n\treward := big.NewInt(firstReward)\n\treward.Sub(reward, big.NewInt(int64(blockHeight/200000)))\n\n\tif reward.Sign() < 1 {\n\t\treturn helpers.BipToPip(big.NewInt(1))\n\t}\n\n\treturn helpers.BipToPip(reward)\n}", "func (_Smartchef *SmartchefSession) PendingReward(_user common.Address) (*big.Int, error) {\n\treturn _Smartchef.Contract.PendingReward(&_Smartchef.CallOpts, _user)\n}", "func accumulateRewards(config *params.ChainConfig, state *state.DB, header *types.Header) {\n\t// TODO: implement mining rewards\n}", "func (_Lmc *LmcSession) LastRewardBlock() (*big.Int, error) {\n\treturn _Lmc.Contract.LastRewardBlock(&_Lmc.CallOpts)\n}", "func (_Contract *ContractCallerSession) TaskHandlingReward() (*big.Int, error) {\n\treturn _Contract.Contract.TaskHandlingReward(&_Contract.CallOpts)\n}", "func (_BondedECDSAKeep *BondedECDSAKeepTransactorSession) DistributeERC20Reward(_tokenAddress common.Address, _value *big.Int) (*types.Transaction, error) {\n\treturn _BondedECDSAKeep.Contract.DistributeERC20Reward(&_BondedECDSAKeep.TransactOpts, _tokenAddress, _value)\n}", "func (d *Dao) AddReward(c context.Context, iRewardID int64, uid int64, iSource int64, iRoomid int64, iLifespan int64) (err error) {\n\t//aReward, _ := getRewardConfByLid(iRewardID)\n\n\tm, _ := time.ParseDuration(fmt.Sprintf(\"+%dh\", iLifespan))\n\n\targ := &AnchorTaskModel.AnchorReward{\n\t\tUid: uid,\n\t\tRewardId: iRewardID,\n\t\tRoomid: iRoomid,\n\t\tSource: iSource,\n\t\tAchieveTime: xtime.Time(time.Now().Unix()),\n\t\tExpireTime: xtime.Time(time.Now().Add(m).Unix()),\n\t\tStatus: model.RewardUnUsed,\n\t}\n\n\t//spew.Dump\n\t// (arg)\n\tif err := d.orm.Create(arg).Error; err != nil {\n\t\tlog.Error(\"addReward(%v) error(%v)\", arg, err)\n\t\treturn err\n\t}\n\n\tif err := d.SetNewReward(c, uid, int64(1)); err != nil {\n\t\tlog.Error(\"addRewardMc(%v) error(%v)\", uid, err)\n\t}\n\n\tif err := d.SetHasReward(c, uid, int64(1)); err != nil {\n\t\tlog.Error(\"SetHasReward(%v) error(%v)\", uid, err)\n\t}\n\n\tlog.Info(\"addReward (%v) succ\", arg)\n\n\treturn\n}", "func (_Lmc *LmcCallerSession) UserAccruedRewards(arg0 common.Address) (*big.Int, error) {\n\treturn _Lmc.Contract.UserAccruedRewards(&_Lmc.CallOpts, arg0)\n}", "func (_Lmc *LmcSession) UserAccruedRewards(arg0 common.Address) (*big.Int, error) {\n\treturn _Lmc.Contract.UserAccruedRewards(&_Lmc.CallOpts, arg0)\n}", "func (path *Path) Rewards() map[*Reward]int {\n\treturn path.rewards\n}", "func (d *Dao) HasReward(c context.Context, uid int64) (r int64, err error) {\n\trst, err := d.GetHasReward(c, uid)\n\tif err != nil {\n\t\tif err == memcache.ErrNotFound {\n\t\t\treward, err2 := d.findByUid(uid, true)\n\t\t\tif err2 != nil {\n\t\t\t\treturn rst, err2\n\t\t\t}\n\t\t\tif reward != nil {\n\t\t\t\trst = int64(1)\n\t\t\t\td.SetHasReward(c, uid, rst)\n\t\t\t} else {\n\t\t\t\trst = int64(0)\n\t\t\t\td.SetHasReward(c, uid, rst)\n\t\t\t}\n\t\t\treturn rst, err\n\t\t}\n\t\tlog.Error(\"HasReward(%v) error(%v)\", uid, err)\n\t\treturn rst, err\n\t}\n\treturn rst, err\n}", "func (_Lmc *LmcCaller) GetUserRewardDebtLength(opts *bind.CallOpts, _userAddress common.Address) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _Lmc.contract.Call(opts, &out, \"getUserRewardDebtLength\", _userAddress)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func GetCmdQueryMiningRewardWeight(queryRoute string, cdc *codec.Codec) *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: treasury.QueryMiningRewardWeight,\n\t\tShort: \"Query the mining reward weight\",\n\t\tLong: strings.TrimSpace(`\nQuery the mining reward rate at the specified epoch.\n\n$ terracli query treasury reward-weight --epoch=14\n`),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tcliCtx := context.NewCLIContext().WithCodec(cdc)\n\n\t\t\tepoch := viper.GetInt(flagEpoch)\n\t\t\tres, err := cliCtx.QueryWithData(fmt.Sprintf(\"custom/%s/%s/%d\", queryRoute, treasury.QueryMiningRewardWeight, epoch), nil)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tvar rewardWeight sdk.Dec\n\t\t\tcdc.MustUnmarshalBinaryLengthPrefixed(res, &rewardWeight)\n\t\t\treturn cliCtx.PrintOutput(rewardWeight)\n\t\t},\n\t}\n\n\treturn cmd\n}", "func (_IStakingRewards *IStakingRewardsSession) LastTimeRewardApplicable() (*big.Int, error) {\n\treturn _IStakingRewards.Contract.LastTimeRewardApplicable(&_IStakingRewards.CallOpts)\n}", "func (_IStakingRewards *IStakingRewardsCallerSession) LastTimeRewardApplicable() (*big.Int, error) {\n\treturn _IStakingRewards.Contract.LastTimeRewardApplicable(&_IStakingRewards.CallOpts)\n}", "func ValidateRewardTx(tx *types.Transaction, header *types.BlockHeader) error {\n\tif tx.Data.Type != types.TxTypeReward || !tx.Data.From.IsEmpty() || tx.Data.AccountNonce != 0 || tx.Data.GasPrice.Cmp(common.Big0) != 0 || tx.Data.GasLimit != 0 || len(tx.Data.Payload) != 0 {\n\t\treturn errInvalidReward\n\t}\n\n\t// validate to address\n\tto := tx.Data.To\n\tif to.IsEmpty() {\n\t\treturn errEmptyToAddress\n\t}\n\n\tif !to.Equal(header.Creator) {\n\t\treturn errCoinbaseMismatch\n\t}\n\n\t// validate reward\n\tamount := tx.Data.Amount\n\tif err := validateReward(amount); err != nil {\n\t\treturn err\n\t}\n\n\treward := consensus.GetReward(header.Height)\n\tif reward == nil || reward.Cmp(amount) != 0 {\n\t\treturn fmt.Errorf(\"invalid reward Amount, block height %d, want %s, got %s\", header.Height, reward, amount)\n\t}\n\n\t// validate timestamp\n\tif tx.Data.Timestamp != header.CreateTimestamp.Uint64() {\n\t\treturn errTimestampMismatch\n\t}\n\n\treturn nil\n}", "func (_XStaking *XStakingCaller) RewardRate(opts *bind.CallOpts) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _XStaking.contract.Call(opts, &out, \"rewardRate\")\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (_Lmc *LmcCaller) UserAccruedRewards(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _Lmc.contract.Call(opts, &out, \"userAccruedRewards\", arg0)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (_BondedECDSAKeep *BondedECDSAKeepSession) DistributeERC20Reward(_tokenAddress common.Address, _value *big.Int) (*types.Transaction, error) {\n\treturn _BondedECDSAKeep.Contract.DistributeERC20Reward(&_BondedECDSAKeep.TransactOpts, _tokenAddress, _value)\n}", "func (_Contract *ContractSession) TaskHandlingReward() (*big.Int, error) {\n\treturn _Contract.Contract.TaskHandlingReward(&_Contract.CallOpts)\n}", "func (k Keeper) ClaimEarnReward(ctx sdk.Context, owner, receiver sdk.AccAddress, denom string, multiplierName string) error {\n\tmultiplier, found := k.GetMultiplierByDenom(ctx, denom, multiplierName)\n\tif !found {\n\t\treturn errorsmod.Wrapf(types.ErrInvalidMultiplier, \"denom '%s' has no multiplier '%s'\", denom, multiplierName)\n\t}\n\n\tclaimEnd := k.GetClaimEnd(ctx)\n\n\tif ctx.BlockTime().After(claimEnd) {\n\t\treturn errorsmod.Wrapf(types.ErrClaimExpired, \"block time %s > claim end time %s\", ctx.BlockTime(), claimEnd)\n\t}\n\n\tsyncedClaim, found := k.GetSynchronizedEarnClaim(ctx, owner)\n\tif !found {\n\t\treturn errorsmod.Wrapf(types.ErrClaimNotFound, \"address: %s\", owner)\n\t}\n\n\tamt := syncedClaim.Reward.AmountOf(denom)\n\n\tclaimingCoins := sdk.NewCoins(sdk.NewCoin(denom, amt))\n\trewardCoins := sdk.NewCoins(sdk.NewCoin(denom, sdk.NewDecFromInt(amt).Mul(multiplier.Factor).RoundInt()))\n\tif rewardCoins.IsZero() {\n\t\treturn types.ErrZeroClaim\n\t}\n\tlength := k.GetPeriodLength(ctx.BlockTime(), multiplier.MonthsLockup)\n\n\terr := k.SendTimeLockedCoinsToAccount(ctx, types.IncentiveMacc, receiver, rewardCoins, length)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// remove claimed coins (NOT reward coins)\n\tsyncedClaim.Reward = syncedClaim.Reward.Sub(claimingCoins...)\n\tk.SetEarnClaim(ctx, syncedClaim)\n\n\tctx.EventManager().EmitEvent(\n\t\tsdk.NewEvent(\n\t\t\ttypes.EventTypeClaim,\n\t\t\tsdk.NewAttribute(types.AttributeKeyClaimedBy, owner.String()),\n\t\t\tsdk.NewAttribute(types.AttributeKeyClaimAmount, claimingCoins.String()),\n\t\t\tsdk.NewAttribute(types.AttributeKeyClaimType, syncedClaim.GetType()),\n\t\t),\n\t)\n\treturn nil\n}", "func (gm GlobalManager) GetRewardAndPopFromWindow(\n\tctx sdk.Context, evaluate types.Coin, penaltyScore sdk.Rat) (types.Coin, sdk.Error) {\n\tif evaluate.IsZero() {\n\t\treturn types.NewCoinFromInt64(0), nil\n\t}\n\n\tconsumptionMeta, err := gm.storage.GetConsumptionMeta(ctx)\n\tif err != nil {\n\t\treturn types.NewCoinFromInt64(0), err\n\t}\n\n\t// consumptionRatio = (this consumption * penalty score) / (total consumption in 7 days window)\n\tconsumptionRatio :=\n\t\tevaluate.ToRat().Mul(sdk.OneRat().Sub(penaltyScore)).Quo(\n\t\t\tconsumptionMeta.ConsumptionWindow.ToRat())\n\t// reward = (consumption reward pool) * (consumptionRatio)\n\treward := types.RatToCoin(\n\t\tconsumptionMeta.ConsumptionRewardPool.ToRat().Mul(consumptionRatio))\n\tconsumptionMeta.ConsumptionRewardPool = consumptionMeta.ConsumptionRewardPool.Minus(reward)\n\tconsumptionMeta.ConsumptionWindow = consumptionMeta.ConsumptionWindow.Minus(evaluate)\n\tif err := gm.addTotalLinoCoin(ctx, reward); err != nil {\n\t\treturn types.NewCoinFromInt64(0), err\n\t}\n\tif err := gm.storage.SetConsumptionMeta(ctx, consumptionMeta); err != nil {\n\t\treturn types.NewCoinFromInt64(0), err\n\t}\n\treturn reward, nil\n}", "func GenerateGetRewardRatioScript(env Environment) []byte {\n\tcode := assets.MustAssetString(rewardRatioFilename)\n\n\treturn []byte(replaceAddresses(code, env))\n}", "func (d *Dao) GetById(id int64) (reward *model.AnchorReward, err error) {\n\trewards := []*model.AnchorReward{}\n\tif err := d.orm.Model(&model.AnchorReward{}).Find(&rewards, \"id=?\", id).Error; err != nil {\n\t\tlog.Error(\"getRewardById (%v) error(%v)\", id, err)\n\t\treturn reward, err\n\t}\n\tif len(rewards) != 0 {\n\t\treward = rewards[0]\n\t}\n\n\treturn\n}", "func (_RandomBeacon *RandomBeaconCaller) AvailableRewards(opts *bind.CallOpts, stakingProvider common.Address) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _RandomBeacon.contract.Call(opts, &out, \"availableRewards\", stakingProvider)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (_XStaking *XStakingCaller) LastTimeRewardApplicable(opts *bind.CallOpts) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _XStaking.contract.Call(opts, &out, \"lastTimeRewardApplicable\")\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func EstimatedRewards(request []string) (float64, error) {\n\tcoinId, err := strconv.ParseUint(request[0], 10, 64)\n\tif err != nil {\n\t\treturn 0.00, errors.New(\"Invalid coinid format\")\n\t}\n\n\twtmClient := NewWhatToMineClient(nil, BASE, userAgent)\n\twtmClient.SetDebug(debug)\n\tstatus, err := wtmClient.GetCoin(coinId, 1000000, 0, 0)\n\tif err != nil {\n\t\treturn 0.00, err\n\t}\n\treturn status.EstimatedRewards, nil\n}", "func (_XStaking *XStakingCaller) Rewards(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _XStaking.contract.Call(opts, &out, \"rewards\", arg0)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}" ]
[ "0.7359368", "0.7301453", "0.7164745", "0.71411335", "0.7125285", "0.7048926", "0.7008327", "0.69872797", "0.69602764", "0.6954469", "0.690628", "0.6885635", "0.6868693", "0.68661374", "0.6859745", "0.67821544", "0.66738814", "0.6654499", "0.6475623", "0.64529395", "0.6261458", "0.6246468", "0.62242985", "0.6195933", "0.6158053", "0.61578", "0.6118841", "0.60365266", "0.6016429", "0.6001463", "0.59719723", "0.594712", "0.594583", "0.5936152", "0.58616644", "0.5839224", "0.5821445", "0.57871443", "0.5748447", "0.5716853", "0.56978446", "0.5695439", "0.56791675", "0.56055015", "0.55523235", "0.5459567", "0.54541695", "0.5434743", "0.540461", "0.54011714", "0.5380912", "0.53638774", "0.5348907", "0.5340571", "0.5326437", "0.52942514", "0.52936494", "0.528707", "0.52851385", "0.5278455", "0.5271794", "0.5271559", "0.5236288", "0.5235212", "0.52292746", "0.5227996", "0.52249175", "0.52187693", "0.521759", "0.5208392", "0.51973426", "0.5195461", "0.5185917", "0.51845515", "0.51736575", "0.5168641", "0.5138485", "0.51206106", "0.5099771", "0.5086932", "0.5081647", "0.507968", "0.5079229", "0.50727415", "0.50620556", "0.5061022", "0.5053968", "0.5036312", "0.50357723", "0.5032823", "0.50285256", "0.5027033", "0.502235", "0.5017938", "0.501224", "0.50000733", "0.4992881", "0.49908218", "0.4987382", "0.49841532" ]
0.75374323
0
updateRewardHistory stores reward information into reward history table
updateRewardHistory сохраняет информацию о награде в таблицу истории наград
func (p *Protocol) updateRewardHistory(tx *sql.Tx, epochNumber uint64, actionHash string, rewardInfoMap map[string]*RewardInfo) error { valStrs := make([]string, 0, len(rewardInfoMap)) valArgs := make([]interface{}, 0, len(rewardInfoMap)*7) for rewardAddress, rewards := range rewardInfoMap { blockReward := rewards.BlockReward.String() epochReward := rewards.EpochReward.String() foundationBonus := rewards.FoundationBonus.String() var candidateName string // If more than one candidates share the same reward address, just use the first candidate as their delegate if len(p.RewardAddrToName[rewardAddress]) > 0 { candidateName = p.RewardAddrToName[rewardAddress][0] } valStrs = append(valStrs, "(?, ?, ?, ?, CAST(? as DECIMAL(65, 0)), CAST(? as DECIMAL(65, 0)), CAST(? as DECIMAL(65, 0)))") valArgs = append(valArgs, epochNumber, actionHash, rewardAddress, candidateName, blockReward, epochReward, foundationBonus) } insertQuery := fmt.Sprintf(insertRewardHistory, RewardHistoryTableName, strings.Join(valStrs, ",")) if _, err := tx.Exec(insertQuery, valArgs...); err != nil { return err } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *MemoryRewardStorage) Update(reward rewards.Reward) {\n\tfor index, r := range m.rewards {\n\t\tif r.ID == reward.ID {\n\t\t\tm.rewards[index] = reward\n\t\t}\n\t}\n}", "func (_Token *TokenSession) BaseRewardHistory(index *big.Int) (*big.Int, *big.Int, *big.Int, *big.Int, error) {\n\treturn _Token.Contract.BaseRewardHistory(&_Token.CallOpts, index)\n}", "func (as AccountStorage) SetRewardHistory(\n\tctx sdk.Context, me types.AccountKey, bucketSlot int64, history *RewardHistory) sdk.Error {\n\tstore := ctx.KVStore(as.key)\n\thistoryBytes, err := as.cdc.MarshalJSON(*history)\n\tif err != nil {\n\t\treturn ErrFailedToMarshalRewardHistory(err)\n\t}\n\tstore.Set(getRewardHistoryKey(me, bucketSlot), historyBytes)\n\treturn nil\n}", "func (d *Dao) AddReward(c context.Context, iRewardID int64, uid int64, iSource int64, iRoomid int64, iLifespan int64) (err error) {\n\t//aReward, _ := getRewardConfByLid(iRewardID)\n\n\tm, _ := time.ParseDuration(fmt.Sprintf(\"+%dh\", iLifespan))\n\n\targ := &AnchorTaskModel.AnchorReward{\n\t\tUid: uid,\n\t\tRewardId: iRewardID,\n\t\tRoomid: iRoomid,\n\t\tSource: iSource,\n\t\tAchieveTime: xtime.Time(time.Now().Unix()),\n\t\tExpireTime: xtime.Time(time.Now().Add(m).Unix()),\n\t\tStatus: model.RewardUnUsed,\n\t}\n\n\t//spew.Dump\n\t// (arg)\n\tif err := d.orm.Create(arg).Error; err != nil {\n\t\tlog.Error(\"addReward(%v) error(%v)\", arg, err)\n\t\treturn err\n\t}\n\n\tif err := d.SetNewReward(c, uid, int64(1)); err != nil {\n\t\tlog.Error(\"addRewardMc(%v) error(%v)\", uid, err)\n\t}\n\n\tif err := d.SetHasReward(c, uid, int64(1)); err != nil {\n\t\tlog.Error(\"SetHasReward(%v) error(%v)\", uid, err)\n\t}\n\n\tlog.Info(\"addReward (%v) succ\", arg)\n\n\treturn\n}", "func (_Token *TokenCallerSession) BaseRewardHistory(index *big.Int) (*big.Int, *big.Int, *big.Int, *big.Int, error) {\n\treturn _Token.Contract.BaseRewardHistory(&_Token.CallOpts, index)\n}", "func accumulateRewards(config *params.ChainConfig, state *state.DB, header *types.Header) {\n\t// TODO: implement mining rewards\n}", "func (_Token *TokenCaller) BaseRewardHistory(opts *bind.CallOpts, index *big.Int) (*big.Int, *big.Int, *big.Int, *big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t\tret1 = new(*big.Int)\n\t\tret2 = new(*big.Int)\n\t\tret3 = new(*big.Int)\n\t)\n\tout := &[]interface{}{\n\t\tret0,\n\t\tret1,\n\t\tret2,\n\t\tret3,\n\t}\n\terr := _Token.contract.Call(opts, out, \"baseRewardHistory\", index)\n\treturn *ret0, *ret1, *ret2, *ret3, err\n}", "func (as AccountStorage) SetReward(ctx sdk.Context, accKey types.AccountKey, reward *Reward) sdk.Error {\n\tstore := ctx.KVStore(as.key)\n\trewardByte, err := as.cdc.MarshalJSON(*reward)\n\tif err != nil {\n\t\treturn ErrFailedToMarshalReward(err)\n\t}\n\tstore.Set(getRewardKey(accKey), rewardByte)\n\treturn nil\n}", "func (s *MutableState) AddRewards(time epochtime.EpochTime, factor *quantity.Quantity, accounts []signature.PublicKey) error {\n\tsteps, err := s.RewardSchedule()\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar activeStep *staking.RewardStep\n\tfor _, step := range steps {\n\t\tif time < step.Until {\n\t\t\tactiveStep = &step\n\t\t\tbreak\n\t\t}\n\t}\n\tif activeStep == nil {\n\t\t// We're past the end of the schedule.\n\t\treturn nil\n\t}\n\n\tcommonPool, err := s.CommonPool()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"loading common pool\")\n\t}\n\n\tfor _, id := range accounts {\n\t\tent := s.Account(id)\n\n\t\tq := ent.Escrow.Active.Balance.Clone()\n\t\t// Multiply first.\n\t\tif err := q.Mul(factor); err != nil {\n\t\t\treturn errors.Wrap(err, \"multiplying by reward factor\")\n\t\t}\n\t\tif err := q.Mul(&activeStep.Scale); err != nil {\n\t\t\treturn errors.Wrap(err, \"multiplying by reward step scale\")\n\t\t}\n\t\tif err := q.Quo(staking.RewardAmountDenominator); err != nil {\n\t\t\treturn errors.Wrap(err, \"dividing by reward amount denominator\")\n\t\t}\n\n\t\tif q.IsZero() {\n\t\t\tcontinue\n\t\t}\n\n\t\tvar com *quantity.Quantity\n\t\trate := ent.Escrow.CommissionSchedule.CurrentRate(time)\n\t\tif rate != nil {\n\t\t\tcom = q.Clone()\n\t\t\t// Multiply first.\n\t\t\tif err := com.Mul(rate); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"multiplying by commission rate\")\n\t\t\t}\n\t\t\tif err := com.Quo(staking.CommissionRateDenominator); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"dividing by commission rate denominator\")\n\t\t\t}\n\n\t\t\tif err := q.Sub(com); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"subtracting commission\")\n\t\t\t}\n\t\t}\n\n\t\tif !q.IsZero() {\n\t\t\tif err := quantity.Move(&ent.Escrow.Active.Balance, commonPool, q); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"transferring to active escrow balance from common pool\")\n\t\t\t}\n\t\t}\n\n\t\tif com != nil && !com.IsZero() {\n\t\t\tdelegation := s.Delegation(id, id)\n\n\t\t\tif err := ent.Escrow.Active.Deposit(&delegation.Shares, commonPool, com); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"depositing commission\")\n\t\t\t}\n\n\t\t\ts.SetDelegation(id, id, delegation)\n\t\t}\n\n\t\ts.SetAccount(id, ent)\n\t}\n\n\ts.SetCommonPool(commonPool)\n\n\treturn nil\n}", "func (p *Protocol) getRewardHistory(actionHash string) ([]*RewardHistory, error) {\n\tdb := p.Store.GetDB()\n\n\tgetQuery := fmt.Sprintf(selectRewardHistory,\n\t\tRewardHistoryTableName)\n\tstmt, err := db.Prepare(getQuery)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to prepare get query\")\n\t}\n\tdefer stmt.Close()\n\n\trows, err := stmt.Query(actionHash)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to execute get query\")\n\t}\n\n\tvar rewardHistory RewardHistory\n\tparsedRows, err := s.ParseSQLRows(rows, &rewardHistory)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to parse results\")\n\t}\n\n\tif len(parsedRows) == 0 {\n\t\treturn nil, indexprotocol.ErrNotExist\n\t}\n\n\tvar rewardHistoryList []*RewardHistory\n\tfor _, parsedRow := range parsedRows {\n\t\trewards := parsedRow.(*RewardHistory)\n\t\trewardHistoryList = append(rewardHistoryList, rewards)\n\t}\n\treturn rewardHistoryList, nil\n}", "func ViewReward(rw http.ResponseWriter, r *http.Request) {\n\t// get the token\n\treqToken := r.Header.Get(\"Authorization\")\n\t\n\t// get the claims\n\tclaims, isNotValid := GetClaims(reqToken, rw)\n\tif isNotValid {\n\t\treturn\n\t}\n\n\tdt, err := db.GetUserRewards(claims.Roll)\n\tif err != nil {\n\t\trw.WriteHeader(http.StatusInternalServerError)\n\t\trw.Write(Rsp(err.Error(), \"Server Error\"))\n\t\treturn\n\t}\n\trw.WriteHeader(http.StatusOK)\n\tres := c.RespData{\n\t\tMessage: \"All data\",\n\t\tData: dt,\n\t}\n\tjson.NewEncoder(rw).Encode(res)\n}", "func m7RewardsAndDatesPart2UpdateAccounts(db *IndexerDb, accountData []addressAccountData, assetDataMap map[uint32]createClose, txnID txnID, state *MigrationState) error {\n\t// Make sure round accounting doesn't interfere with updating these accounts.\n\tdb.accountingLock.Lock()\n\tdefer db.accountingLock.Unlock()\n\n\t// Open a postgres transaction and submit results for each account.\n\ttx, err := db.db.BeginTx(context.Background(), &serializable)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"m7: tx begin: %v\", err)\n\t}\n\tdefer tx.Rollback() // ignored if .Commit() first\n\n\t// 1. updateTotalRewards - conditionally update the total rewards if the account wasn't closed during iteration.\n\t// $3 is the round after which new blocks will have the closed_at field set.\n\t// We only set rewards_total when closed_at was set before that round.\n\tupdateTotalRewards, err := tx.Prepare(`UPDATE account SET rewards_total = coalesce(rewards_total, 0) + $2 WHERE addr = $1 AND coalesce(closed_at, 0) < $3`)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"m7: set rewards prepare: %v\", err)\n\t}\n\tdefer updateTotalRewards.Close()\n\n\t// 2. setCreateCloseAccount - set the accounts create/close rounds.\n\t// We always set the created_at field because it will never change.\n\t// closed_at may already be set by the time the migration runs, or it might need to be cleared out.\n\tsetCreateCloseAccount, err := tx.Prepare(`UPDATE account SET created_at = $2, closed_at = coalesce(closed_at, $3), deleted = coalesce(deleted, $4) WHERE addr = $1`)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"m7: set create close prepare: %v\", err)\n\t}\n\tdefer setCreateCloseAccount.Close()\n\n\t// 3. setCreateCloseAsset - set the accounts created assets create/close rounds.\n\tsetCreateCloseAsset, err := tx.Prepare(`UPDATE asset SET created_at = $3, closed_at = coalesce(closed_at, $4), deleted = coalesce(deleted, $5) WHERE creator_addr = $1 AND index=$2`)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"m7: set create close asset prepare: %v\", err)\n\t}\n\tdefer setCreateCloseAsset.Close()\n\n\t// 4. setCreateCloseAssetHolding - (upsert) set the accounts asset holding create/close rounds.\n\tsetCreateCloseAssetHolding, err := tx.Prepare(`INSERT INTO account_asset(addr, assetid, amount, frozen, created_at, closed_at, deleted) VALUES ($1, $2, 0, false, $3, $4, $5) ON CONFLICT (addr, assetid) DO UPDATE SET created_at = EXCLUDED.created_at, closed_at = coalesce(account_asset.closed_at, EXCLUDED.closed_at), deleted = coalesce(account_asset.deleted, EXCLUDED.deleted)`)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"m7: set create close asset holding prepare: %v\", err)\n\t}\n\tdefer setCreateCloseAssetHolding.Close()\n\n\t// 5. setCreateCloseApp - set the accounts created apps create/close rounds.\n\tsetCreateCloseApp, err := tx.Prepare(`UPDATE app SET created_at = $3, closed_at = coalesce(closed_at, $4), deleted = coalesce(deleted, $5) WHERE creator = $1 AND index=$2`)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"m7: set create close app prepare: %v\", err)\n\t}\n\tdefer setCreateCloseApp.Close()\n\n\t// 6. setCreateCloseAppLocal - (upsert) set the accounts local apps create/close rounds.\n\tsetCreateCloseAppLocal, err := tx.Prepare(`INSERT INTO account_app (addr, app, created_at, closed_at, deleted) VALUES ($1, $2, $3, $4, $5) ON CONFLICT (addr, app) DO UPDATE SET created_at = EXCLUDED.created_at, closed_at = coalesce(account_app.closed_at, EXCLUDED.closed_at), deleted = coalesce(account_app.deleted, EXCLUDED.deleted)`)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"m7: set create close app local prepare: %v\", err)\n\t}\n\tdefer setCreateCloseAppLocal.Close()\n\n\t// loop through all of the accounts.\n\tfor _, ad := range accountData {\n\t\taddressStr := ad.address.String()\n\n\t\t// 1. updateTotalRewards - conditionally update the total rewards if the account wasn't closed during iteration.\n\t\t_, err = updateTotalRewards.Exec(\n\t\t\tad.address[:], ad.accountData.cumulativeRewards, state.NextRound)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"m7: failed to update %s with rewards %d: %v\",\n\t\t\t\taddressStr, ad.accountData.cumulativeRewards, err)\n\t\t}\n\n\t\t// 2. setCreateCloseAccount - set the accounts create/close rounds.\n\t\t{\n\t\t\tdeleted := sql.NullBool{\n\t\t\t\tBool: ad.accountData.account.deleted,\n\t\t\t\tValid: ad.accountData.account.deletedValid,\n\t\t\t}\n\t\t\tcreated := sql.NullInt64{\n\t\t\t\tInt64: int64(ad.accountData.account.created),\n\t\t\t\tValid: ad.accountData.account.createdValid,\n\t\t\t}\n\t\t\tclosed := sql.NullInt64{\n\t\t\t\tInt64: int64(ad.accountData.account.closed),\n\t\t\t\tValid: ad.accountData.account.closedValid,\n\t\t\t}\n\t\t\t_, err = setCreateCloseAccount.Exec(ad.address[:], created, closed, deleted)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"m7: failed to update %s with create/close: %v\", addressStr, err)\n\t\t\t}\n\t\t}\n\n\t\t// 4. setCreateCloseAssetHolding - (upsert) set the accounts asset holding create/close rounds.\n\t\terr = executeForEachCreatable(setCreateCloseAssetHolding, ad.address,\n\t\t\tad.accountData.assetHolding)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"m7: failed to update %s with asset holding create/close: %v\",\n\t\t\t\taddressStr, err)\n\t\t}\n\n\t\tif ad.accountData.additional != nil {\n\t\t\t// 3. setCreateCloseAsset - set the accounts created assets create/close rounds.\n\t\t\tfor index := range ad.accountData.additional.asset {\n\t\t\t\tcc, ok := assetDataMap[index]\n\t\t\t\tif !ok {\n\t\t\t\t\treturn fmt.Errorf(\"m7: asset index %d created by %s is not in assetDataMap\",\n\t\t\t\t\t\tindex, addressStr)\n\t\t\t\t}\n\t\t\t\terr := executeCreatableCC(setCreateCloseAsset, ad.address, index, cc)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"m7: failed to update %s with asset index %d create/close: %v\",\n\t\t\t\t\t\taddressStr, index, err)\n\t\t\t\t}\n\t\t\t\tdelete(assetDataMap, index)\n\t\t\t}\n\n\t\t\t// 5. setCreateCloseApp - set the accounts created apps create/close rounds.\n\t\t\terr = executeForEachCreatable(setCreateCloseApp, ad.address, ad.accountData.additional.app)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"m7: failed to update %s with app create/close: %v\", addressStr, err)\n\t\t\t}\n\n\t\t\t// 6. setCreateCloseAppLocal - (upsert) set the accounts local apps create/close rounds.\n\t\t\terr = executeForEachCreatable(setCreateCloseAppLocal, ad.address,\n\t\t\t\tad.accountData.additional.appLocal)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"m7: failed to update %s with app local create/close: %v\",\n\t\t\t\t\taddressStr, err)\n\t\t\t}\n\t\t}\n\t}\n\n\t{\n\t\tround := int64(txnID.round)\n\t\tintra := int64(txnID.intra)\n\t\tstate.PointerRound = &round\n\t\tstate.PointerIntra = &intra\n\t}\n\tmigrationStateJSON := encoding.EncodeJSON(state)\n\t_, err = db.db.Exec(setMetastateUpsert, migrationMetastateKey, migrationStateJSON)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"m7: failed to update migration checkpoint: %v\", err)\n\t}\n\n\t// Commit transactions.\n\terr = tx.Commit()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"m7: failed to commit changes: %v\", err)\n\t}\n\n\treturn nil\n}", "func (s *MutableState) AddRewardSingleAttenuated(time epochtime.EpochTime, factor *quantity.Quantity, attenuationNumerator, attenuationDenominator int, account signature.PublicKey) error {\n\tsteps, err := s.RewardSchedule()\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar activeStep *staking.RewardStep\n\tfor _, step := range steps {\n\t\tif time < step.Until {\n\t\t\tactiveStep = &step\n\t\t\tbreak\n\t\t}\n\t}\n\tif activeStep == nil {\n\t\t// We're past the end of the schedule.\n\t\treturn nil\n\t}\n\n\tvar numQ, denQ quantity.Quantity\n\tif err = numQ.FromInt64(int64(attenuationNumerator)); err != nil {\n\t\treturn errors.Wrapf(err, \"importing attenuation numerator %d\", attenuationNumerator)\n\t}\n\tif err = denQ.FromInt64(int64(attenuationDenominator)); err != nil {\n\t\treturn errors.Wrapf(err, \"importing attenuation denominator %d\", attenuationDenominator)\n\t}\n\n\tcommonPool, err := s.CommonPool()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"loading common pool\")\n\t}\n\n\tent := s.Account(account)\n\n\tq := ent.Escrow.Active.Balance.Clone()\n\t// Multiply first.\n\tif err := q.Mul(factor); err != nil {\n\t\treturn errors.Wrap(err, \"multiplying by reward factor\")\n\t}\n\tif err := q.Mul(&activeStep.Scale); err != nil {\n\t\treturn errors.Wrap(err, \"multiplying by reward step scale\")\n\t}\n\tif err := q.Mul(&numQ); err != nil {\n\t\treturn errors.Wrap(err, \"multiplying by attenuation numerator\")\n\t}\n\tif err := q.Quo(staking.RewardAmountDenominator); err != nil {\n\t\treturn errors.Wrap(err, \"dividing by reward amount denominator\")\n\t}\n\tif err := q.Quo(&denQ); err != nil {\n\t\treturn errors.Wrap(err, \"dividing by attenuation denominator\")\n\t}\n\n\tif q.IsZero() {\n\t\treturn nil\n\t}\n\n\tvar com *quantity.Quantity\n\trate := ent.Escrow.CommissionSchedule.CurrentRate(time)\n\tif rate != nil {\n\t\tcom = q.Clone()\n\t\t// Multiply first.\n\t\tif err := com.Mul(rate); err != nil {\n\t\t\treturn errors.Wrap(err, \"multiplying by commission rate\")\n\t\t}\n\t\tif err := com.Quo(staking.CommissionRateDenominator); err != nil {\n\t\t\treturn errors.Wrap(err, \"dividing by commission rate denominator\")\n\t\t}\n\n\t\tif err := q.Sub(com); err != nil {\n\t\t\treturn errors.Wrap(err, \"subtracting commission\")\n\t\t}\n\t}\n\n\tif !q.IsZero() {\n\t\tif err := quantity.Move(&ent.Escrow.Active.Balance, commonPool, q); err != nil {\n\t\t\treturn errors.Wrap(err, \"transferring to active escrow balance from common pool\")\n\t\t}\n\t}\n\n\tif com != nil && !com.IsZero() {\n\t\tdelegation := s.Delegation(account, account)\n\n\t\tif err := ent.Escrow.Active.Deposit(&delegation.Shares, commonPool, com); err != nil {\n\t\t\treturn errors.Wrap(err, \"depositing commission\")\n\t\t}\n\n\t\ts.SetDelegation(account, account, delegation)\n\t}\n\n\ts.SetAccount(account, ent)\n\n\ts.SetCommonPool(commonPool)\n\n\treturn nil\n}", "func (c *Coinbase) AddReward(output *Output) {\n\toutput.EncryptedMask = make([]byte, 1)\n\tc.Rewards = append(c.Rewards, output)\n}", "func (room *RoomRecorder) setHistory(history []*action_.PlayerAction) {\n\troom.historyM.Lock()\n\troom._history = history\n\troom.historyM.Unlock()\n}", "func (genA *GeneticAlgorithm) UpdateHistory(maxFitness, averageFitness float64) {\n\tgenA.AverageFitnessHistory = append(genA.AverageFitnessHistory, averageFitness)\n\tgenA.MaxFitnessHistory = append(genA.MaxFitnessHistory, maxFitness)\n}", "func (path *Path) AddRewards(rewards map[*Reward]int) {\n\tfor key, value := range rewards {\n\t\tpath.rewards[key] += value\n\t}\n}", "func (_RandomBeacon *RandomBeaconTransactor) UpdateRewardParameters(opts *bind.TransactOpts, sortitionPoolRewardsBanDuration *big.Int, relayEntryTimeoutNotificationRewardMultiplier *big.Int, unauthorizedSigningNotificationRewardMultiplier *big.Int, dkgMaliciousResultNotificationRewardMultiplier *big.Int) (*types.Transaction, error) {\n\treturn _RandomBeacon.contract.Transact(opts, \"updateRewardParameters\", sortitionPoolRewardsBanDuration, relayEntryTimeoutNotificationRewardMultiplier, unauthorizedSigningNotificationRewardMultiplier, dkgMaliciousResultNotificationRewardMultiplier)\n}", "func m7RewardsAndDatesPart2(db *IndexerDb, state *MigrationState) error {\n\tdb.log.Print(\"m7 account cumulative rewards migration starting\")\n\n\t// Skip the work if all accounts have previously been updated.\n\tif (state.PointerRound == nil) || (*state.PointerRound != 0) || (*state.PointerIntra != 0) {\n\t\tmaxRound := uint32(state.NextRound)\n\n\t\t// Get the number of accounts to potentially warn the user about high memory usage.\n\t\terr := warnUser(db, maxRound)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Get special accounts, so that we can ignore them throughout the migration. A later migration\n\t\t// handles them.\n\t\tspecialAccounts, err := db.GetSpecialAccounts()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"m7: unable to get special accounts: %v\", err)\n\t\t}\n\t\t// Get the transaction id that created each account. This function simple loops over all\n\t\t// transactions from rounds <= `maxRound` in arbitrary order.\n\t\taccountsFirstUsed, err := getAccountsFirstUsed(db, maxRound, specialAccounts)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Get account data for accounts without transactions such as genesis accounts.\n\t\t// This function reads the `account` table but only considers accounts created before or at\n\t\t// `maxRound`.\n\t\treadyAccountData, err := getAccountsWithoutTxnData(\n\t\t\tdb, maxRound, specialAccounts, accountsFirstUsed)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Finally, read all transactions from most recent to oldest, update rewards and create/close dates,\n\t\t// and write this account data to the database. To save memory, this function removes account's\n\t\t// data as soon as we reach the transaction that created this account at which point older\n\t\t// transactions cannot update its state. It writes account data to the database in batches.\n\t\terr = updateAccounts(db, specialAccounts, accountsFirstUsed, readyAccountData, state)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Update migration state.\n\tstate.NextMigration++\n\tstate.NextRound = 0\n\tstate.PointerRound = nil\n\tstate.PointerIntra = nil\n\tmigrationStateJSON := encoding.EncodeJSON(state)\n\t_, err := db.db.Exec(setMetastateUpsert, migrationMetastateKey, migrationStateJSON)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"m7: failed to write final migration state: %v\", err)\n\t}\n\n\treturn nil\n}", "func (_RandomBeacon *RandomBeaconTransactorSession) UpdateRewardParameters(sortitionPoolRewardsBanDuration *big.Int, relayEntryTimeoutNotificationRewardMultiplier *big.Int, unauthorizedSigningNotificationRewardMultiplier *big.Int, dkgMaliciousResultNotificationRewardMultiplier *big.Int) (*types.Transaction, error) {\n\treturn _RandomBeacon.Contract.UpdateRewardParameters(&_RandomBeacon.TransactOpts, sortitionPoolRewardsBanDuration, relayEntryTimeoutNotificationRewardMultiplier, unauthorizedSigningNotificationRewardMultiplier, dkgMaliciousResultNotificationRewardMultiplier)\n}", "func (_Lmc *LmcSession) UpdateRewardMultipliers() (*types.Transaction, error) {\n\treturn _Lmc.Contract.UpdateRewardMultipliers(&_Lmc.TransactOpts)\n}", "func (_RandomBeacon *RandomBeaconSession) UpdateRewardParameters(sortitionPoolRewardsBanDuration *big.Int, relayEntryTimeoutNotificationRewardMultiplier *big.Int, unauthorizedSigningNotificationRewardMultiplier *big.Int, dkgMaliciousResultNotificationRewardMultiplier *big.Int) (*types.Transaction, error) {\n\treturn _RandomBeacon.Contract.UpdateRewardParameters(&_RandomBeacon.TransactOpts, sortitionPoolRewardsBanDuration, relayEntryTimeoutNotificationRewardMultiplier, unauthorizedSigningNotificationRewardMultiplier, dkgMaliciousResultNotificationRewardMultiplier)\n}", "func (k Querier) Rewards(c context.Context, req *types.QueryRewardsRequest) (*types.QueryRewardsResponse, error) {\n\tif req == nil {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"invalid request\")\n\t}\n\n\tif req.StakingCoinDenom != \"\" {\n\t\tif err := sdk.ValidateDenom(req.StakingCoinDenom); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tctx := sdk.UnwrapSDKContext(c)\n\tstore := ctx.KVStore(k.storeKey)\n\tvar rewards []types.Reward\n\tvar pageRes *query.PageResponse\n\tvar err error\n\n\tif req.Farmer != \"\" {\n\t\tvar farmerAcc sdk.AccAddress\n\t\tfarmerAcc, err = sdk.AccAddressFromBech32(req.Farmer)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tstorePrefix := types.GetRewardsByFarmerIndexKey(farmerAcc)\n\t\tindexStore := prefix.NewStore(store, storePrefix)\n\t\tpageRes, err = query.FilteredPaginate(indexStore, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) {\n\t\t\t_, stakingCoinDenom := types.ParseRewardsByFarmerIndexKey(append(storePrefix, key...))\n\t\t\tif req.StakingCoinDenom != \"\" {\n\t\t\t\tif stakingCoinDenom != req.StakingCoinDenom {\n\t\t\t\t\treturn false, nil\n\t\t\t\t}\n\t\t\t}\n\t\t\treward, found := k.GetReward(ctx, stakingCoinDenom, farmerAcc)\n\t\t\tif !found { // TODO: remove this check\n\t\t\t\treturn false, fmt.Errorf(\"reward not found\")\n\t\t\t}\n\t\t\tif accumulate {\n\t\t\t\trewards = append(rewards, reward)\n\t\t\t}\n\t\t\treturn true, nil\n\t\t})\n\t} else {\n\t\tvar storePrefix []byte\n\t\tif req.StakingCoinDenom != \"\" {\n\t\t\tstorePrefix = types.GetRewardsByStakingCoinDenomKey(req.StakingCoinDenom)\n\t\t} else {\n\t\t\tstorePrefix = types.RewardKeyPrefix\n\t\t}\n\t\trewardStore := prefix.NewStore(store, storePrefix)\n\n\t\tpageRes, err = query.Paginate(rewardStore, req.Pagination, func(key, value []byte) error {\n\t\t\tstakingCoinDenom, farmerAcc := types.ParseRewardKey(append(storePrefix, key...))\n\t\t\trewardCoins, err := k.UnmarshalRewardCoins(value)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\trewards = append(rewards, types.Reward{\n\t\t\t\tFarmer: farmerAcc.String(),\n\t\t\t\tStakingCoinDenom: stakingCoinDenom,\n\t\t\t\tRewardCoins: rewardCoins.RewardCoins,\n\t\t\t})\n\t\t\treturn nil\n\t\t})\n\t}\n\tif err != nil {\n\t\treturn nil, status.Error(codes.Internal, err.Error())\n\t}\n\n\treturn &types.QueryRewardsResponse{Rewards: rewards, Pagination: pageRes}, nil\n}", "func (vi *votedInfo) CalculateReward(multiplier, divider *big.Int, period int) {\n\tif multiplier.Sign() == 0 || period == 0 {\n\t\treturn\n\t}\n\tif divider.Sign() == 0 || vi.totalBondedDelegation.Sign() == 0 {\n\t\treturn\n\t}\n\t// reward = multiplier * period * bondedDelegation / (divider * totalBondedDelegation)\n\tbase := new(big.Int).Mul(multiplier, big.NewInt(int64(period)))\n\treward := new(big.Int)\n\tfor i, addrKey := range vi.rank {\n\t\tif i == vi.maxRankForReward {\n\t\t\tbreak\n\t\t}\n\t\tprep := vi.preps[addrKey]\n\t\tif prep.Enable() == false {\n\t\t\tcontinue\n\t\t}\n\n\t\treward.Mul(base, prep.GetBondedDelegation())\n\t\treward.Div(reward, divider)\n\t\treward.Div(reward, vi.totalBondedDelegation)\n\n\t\tlog.Tracef(\"VOTED REWARD %d = %d * %d * %d / (%d * %d)\",\n\t\t\treward, multiplier, period, prep.GetBondedDelegation(), divider, vi.totalBondedDelegation)\n\n\t\tprep.SetIScore(new(big.Int).Add(prep.IScore(), reward))\n\t}\n}", "func (db *Db) SaveAccountBalanceHistory(entry types.AccountBalanceHistory) error {\n\tstmt := `\nINSERT INTO account_balance_history (address, balance, delegated, unbonding, redelegating, commission, reward, timestamp) \nVALUES ($1, $2, $3, $4, $5, $6, $7, $8)\nON CONFLICT ON CONSTRAINT unique_balance_for_height DO UPDATE \n SET balance = excluded.balance,\n delegated = excluded.delegated,\n unbonding = excluded.unbonding,\n redelegating = excluded.redelegating,\n commission = excluded.commission, \n reward = excluded.reward`\n\n\t_, err := db.Sql.Exec(stmt,\n\t\tentry.Account,\n\t\tpq.Array(dbtypes.NewDbCoins(entry.Balance)),\n\t\tpq.Array(dbtypes.NewDbCoins(entry.Delegations)),\n\t\tpq.Array(dbtypes.NewDbCoins(entry.Unbonding)),\n\t\tpq.Array(dbtypes.NewDbCoins(entry.Redelegations)),\n\t\tpq.Array(dbtypes.NewDbDecCoins(entry.Commission)),\n\t\tpq.Array(dbtypes.NewDbDecCoins(entry.Reward)),\n\t\tentry.Timestamp,\n\t)\n\treturn err\n}", "func (node *TreeNode) backpropagateReward(scores [2]float64) {\n\tcurrentNode := node\n\tfor currentNode.Parent != nil {\n\t\tcurrentNode.VisitCount += 1.0\n\t\tcurrentNode.CumulativeScore[0] += scores[0]\n\t\tcurrentNode.CumulativeScore[1] += scores[1]\n\t\tcurrentNode = currentNode.Parent\n\t}\n\t//Increment root node counter\n\tcurrentNode.VisitCount += 1.0\n}", "func (_Lmc *LmcTransactorSession) UpdateRewardMultipliers() (*types.Transaction, error) {\n\treturn _Lmc.Contract.UpdateRewardMultipliers(&_Lmc.TransactOpts)\n}", "func (_Lmc *LmcTransactor) UpdateRewardMultipliers(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _Lmc.contract.Transact(opts, \"updateRewardMultipliers\")\n}", "func UpdatePriceHistory(w http.ResponseWriter, r *http.Request) {\n\ttype request struct {\n\t\tUrl string `json:\"url\"`\n\t}\n\n\ttype response struct {\n\t\tName string `josn:\"name\"`\n\t\tPrice float32 `json:\"price\"`\n\t}\n\n\t// get id\n\tvars := mux.Vars(r)\n\tkey, _ := strconv.Atoi(vars[\"item_id\"])\n\n\t// get item from database\n\tvar item entity.Item\n\tdatabase.Connector.First(&item, key)\n\n\t// create request\n\treq := request{\n\t\tUrl: item.Url,\n\t}\n\n\tjsonReq, err := json.Marshal(req)\n\n\t// post to scrapper api\n\tresp, err := http.Post(os.Getenv(\"SCRAPPER_HOST\"), \"application/json\", bytes.NewBuffer(jsonReq))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tdefer resp.Body.Close()\n\tbodyBytes, _ := ioutil.ReadAll(resp.Body)\n\n\t// crate new Price History\n\tvar res response\n\tjson.Unmarshal(bodyBytes, &res)\n\n\tprice := entity.PriceHistory{\n\t\tItem_ID: item.ID,\n\t\tPrice: uint(res.Price),\n\t}\n\n\tdatabase.Connector.Create(&price)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusCreated)\n\tjson.NewEncoder(w).Encode(price)\n}", "func (d *Dao) UseReward(id int64, usePlat string) (rst bool, err error) {\n\tif err := d.orm.\n\t\tModel(&model.AnchorReward{}).\n\t\tWhere(\"id=?\", id).\n\t\tUpdate(map[string]interface{}{\"status\": model.RewardUsed, \"use_plat\": usePlat, \"use_time\": xtime.Time(time.Now().Unix())}).Error; err != nil {\n\t\tlog.Error(\"useReward (%v) error(%v)\", id, err)\n\t\treturn rst, err\n\t}\n\trst = true\n\treturn\n}", "func AppendHistory(db *gorm.DB, id int, newHistory []History) {\n\tvar lastMatch History\n\tdb.Where(\"player_id = ?\", id).Order(\"match_date desc\").First(&lastMatch)\n\n\tfor i := 0; i < len(newHistory); i++ {\n\t\tif newHistory[i].MatchDate.After(lastMatch.MatchDate) {\n\t\t\tdb.Create(&newHistory[i])\n\t\t}\n\t}\n}", "func m6RewardsAndDatesPart1(db *IndexerDb, state *MigrationState) error {\n\t// Cache the round in the migration metastate\n\tround, err := db.GetMaxRoundAccounted()\n\tif err == idb.ErrorNotInitialized {\n\t\t// Shouldn't end up in the migration if this were the case.\n\t\tround = 0\n\t} else if err != nil {\n\t\tdb.log.WithError(err).Errorf(\"m6: problem caching max round: %v\", err)\n\t\treturn err\n\t}\n\n\t// state is updated in the DB when calling 'sqlMigration'\n\tstate.NextRound = int64(round)\n\n\t// update metastate\n\tsqlLines := []string{\n\t\t// rewards\n\t\t`ALTER TABLE account ADD COLUMN rewards_total bigint NOT NULL DEFAULT 0`,\n\n\t\t// created/closed round\n\t\t`ALTER TABLE account ADD COLUMN deleted boolean DEFAULT NULL`,\n\t\t`ALTER TABLE account ADD COLUMN created_at bigint DEFAULT NULL`,\n\t\t`ALTER TABLE account ADD COLUMN closed_at bigint DEFAULT NULL`,\n\t\t`ALTER TABLE app ADD COLUMN deleted boolean DEFAULT NULL`,\n\t\t`ALTER TABLE app ADD COLUMN created_at bigint DEFAULT NULL`,\n\t\t`ALTER TABLE app ADD COLUMN closed_at bigint DEFAULT NULL`,\n\t\t`ALTER TABLE account_app ADD COLUMN deleted boolean DEFAULT NULL`,\n\t\t`ALTER TABLE account_app ADD COLUMN created_at bigint DEFAULT NULL`,\n\t\t`ALTER TABLE account_app ADD COLUMN closed_at bigint DEFAULT NULL`,\n\t\t`ALTER TABLE account_asset ADD COLUMN deleted boolean DEFAULT NULL`,\n\t\t`ALTER TABLE account_asset ADD COLUMN created_at bigint DEFAULT NULL`,\n\t\t`ALTER TABLE account_asset ADD COLUMN closed_at bigint DEFAULT NULL`,\n\t\t`ALTER TABLE asset ADD COLUMN deleted boolean DEFAULT NULL`,\n\t\t`ALTER TABLE asset ADD COLUMN created_at bigint DEFAULT NULL`,\n\t\t`ALTER TABLE asset ADD COLUMN closed_at bigint DEFAULT NULL`,\n\t}\n\treturn sqlMigration(db, state, sqlLines)\n}", "func (_Token *TokenSession) BaseReward(index *big.Int) (*big.Int, *big.Int, *big.Int, error) {\n\treturn _Token.Contract.BaseReward(&_Token.CallOpts, index)\n}", "func (s *Client) AddHistory(username, input, reply string) {\n\ts.Init(username)\n\n\ts.lock.Lock()\n\tdefer s.lock.Unlock()\n\n\ttx, _ := s.db.Begin()\n\tstmt, _ := tx.Prepare(`INSERT INTO history (user_id, input,reply)VALUES((SELECT id FROM users WHERE username = ?),?,?);`)\n\tdefer stmt.Close()\n\tstmt.Exec(username, input, reply)\n\ttx.Commit()\n}", "func (a Actor) AwardBlockReward(rt vmr.Runtime, params *AwardBlockRewardParams) *adt.EmptyValue {\n\trt.ValidateImmediateCallerIs(builtin.SystemActorAddr)\n\tAssertMsg(rt.CurrentBalance().GreaterThanEqual(params.GasReward),\n\t\t\"actor current balance %v insufficient to pay gas reward %v\", rt.CurrentBalance(), params.GasReward)\n\n\tAssertMsg(params.TicketCount > 0, \"cannot give block reward for zero tickets\")\n\n\tminer, ok := rt.ResolveAddress(params.Miner)\n\tif !ok {\n\t\trt.Abortf(exitcode.ErrIllegalState, \"failed to resolve given owner address\")\n\t}\n\n\tpriorBalance := rt.CurrentBalance()\n\n\tvar penalty abi.TokenAmount\n\tvar st State\n\trt.State().Transaction(&st, func() interface{} {\n\t\tblockReward := a.computeBlockReward(&st, big.Sub(priorBalance, params.GasReward), params.TicketCount)\n\t\ttotalReward := big.Add(blockReward, params.GasReward)\n\n\t\t// Cap the penalty at the total reward value.\n\t\tpenalty = big.Min(params.Penalty, totalReward)\n\n\t\t// Reduce the payable reward by the penalty.\n\t\trewardPayable := big.Sub(totalReward, penalty)\n\n\t\tAssertMsg(big.Add(rewardPayable, penalty).LessThanEqual(priorBalance),\n\t\t\t\"reward payable %v + penalty %v exceeds balance %v\", rewardPayable, penalty, priorBalance)\n\n\t\t// Record new reward into reward map.\n\t\tif rewardPayable.GreaterThan(abi.NewTokenAmount(0)) {\n\t\t\tnewReward := Reward{\n\t\t\t\tStartEpoch: rt.CurrEpoch(),\n\t\t\t\tEndEpoch: rt.CurrEpoch() + rewardVestingPeriod,\n\t\t\t\tValue: rewardPayable,\n\t\t\t\tAmountWithdrawn: abi.NewTokenAmount(0),\n\t\t\t\tVestingFunction: rewardVestingFunction,\n\t\t\t}\n\t\t\tif err := st.addReward(adt.AsStore(rt), miner, &newReward); err != nil {\n\t\t\t\trt.Abortf(exitcode.ErrIllegalState, \"failed to add reward to rewards map: %w\", err)\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\n\t// Burn the penalty amount.\n\t_, code := rt.Send(builtin.BurntFundsActorAddr, builtin.MethodSend, nil, penalty)\n\tbuiltin.RequireSuccess(rt, code, \"failed to send penalty to BurntFundsActor\")\n\n\treturn nil\n}", "func (_Token *TokenCallerSession) BaseReward(index *big.Int) (*big.Int, *big.Int, *big.Int, error) {\n\treturn _Token.Contract.BaseReward(&_Token.CallOpts, index)\n}", "func rewardAndSlash(ctx contract.Context, cachedDelegations *CachedDposStorage, state *State) ([]*DelegationResult, error) {\n\tformerValidatorTotals := make(map[string]loom.BigUInt)\n\tdelegatorRewards := make(map[string]*loom.BigUInt)\n\tdistributedRewards := common.BigZero()\n\n\tdelegations, err := cachedDelegations.loadDelegationList(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, validator := range state.Validators {\n\t\tcandidate := GetCandidateByPubKey(ctx, validator.PubKey)\n\n\t\tif candidate == nil {\n\t\t\tctx.Logger().Info(\"Attempted to reward validator no longer on candidates list.\", \"validator\", validator)\n\t\t\tcontinue\n\t\t}\n\n\t\tcandidateAddress := loom.UnmarshalAddressPB(candidate.Address)\n\t\tvalidatorKey := candidateAddress.String()\n\t\tstatistic, _ := GetStatistic(ctx, candidateAddress)\n\n\t\tif statistic == nil {\n\t\t\tdelegatorRewards[validatorKey] = common.BigZero()\n\t\t\tformerValidatorTotals[validatorKey] = *common.BigZero()\n\t\t} else {\n\t\t\t// If a validator is jailed, don't calculate and distribute rewards\n\t\t\tif ctx.FeatureEnabled(features.DPOSVersion3_3, false) {\n\t\t\t\tif statistic.Jailed {\n\t\t\t\t\tdelegatorRewards[validatorKey] = common.BigZero()\n\t\t\t\t\tformerValidatorTotals[validatorKey] = *common.BigZero()\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If a validator's SlashPercentage is 0, the validator is\n\t\t\t// rewarded for avoiding faults during the last slashing period\n\t\t\tif common.IsZero(statistic.SlashPercentage.Value) {\n\t\t\t\tdistributionTotal := calculateRewards(statistic.DelegationTotal.Value, state.Params, state.TotalValidatorDelegations.Value)\n\n\t\t\t\t// The validator share, equal to validator_fee * total_validotor_reward\n\t\t\t\t// is to be split between the referrers and the validator\n\t\t\t\tvalidatorShare := CalculateFraction(loom.BigUInt{big.NewInt(int64(candidate.Fee))}, distributionTotal)\n\n\t\t\t\t// delegatorsShare is what fraction of the total rewards will be\n\t\t\t\t// distributed to delegators\n\t\t\t\tdelegatorsShare := common.BigZero()\n\t\t\t\tdelegatorsShare.Sub(&distributionTotal, &validatorShare)\n\t\t\t\tdelegatorRewards[validatorKey] = delegatorsShare\n\n\t\t\t\t// Distribute rewards to referrers\n\t\t\t\tfor _, d := range delegations {\n\t\t\t\t\tif loom.UnmarshalAddressPB(d.Validator).Compare(loom.UnmarshalAddressPB(candidate.Address)) == 0 {\n\t\t\t\t\t\tdelegation, err := GetDelegation(ctx, d.Index, *d.Validator, *d.Delegator)\n\t\t\t\t\t\t// if the delegation is not found OR if the delegation\n\t\t\t\t\t\t// has no referrer, we do not need to attempt to\n\t\t\t\t\t\t// distribute the referrer rewards\n\t\t\t\t\t\tif err == contract.ErrNotFound || len(delegation.Referrer) == 0 {\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t} else if err != nil {\n\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// if referrer is not found, do not distribute the reward\n\t\t\t\t\t\treferrerAddress := getReferrer(ctx, delegation.Referrer)\n\t\t\t\t\t\tif referrerAddress == nil {\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// calculate referrerReward\n\t\t\t\t\t\treferrerReward := calculateRewards(delegation.Amount.Value, state.Params, state.TotalValidatorDelegations.Value)\n\t\t\t\t\t\treferrerReward = CalculateFraction(loom.BigUInt{big.NewInt(int64(candidate.Fee))}, referrerReward)\n\t\t\t\t\t\treferrerReward = CalculateFraction(defaultReferrerFee, referrerReward)\n\n\t\t\t\t\t\t// referrer fees are delegater to limbo validator\n\t\t\t\t\t\tdistributedRewards.Add(distributedRewards, &referrerReward)\n\t\t\t\t\t\tcachedDelegations.IncreaseRewardDelegation(ctx, LimboValidatorAddress(ctx).MarshalPB(), referrerAddress, referrerReward)\n\n\t\t\t\t\t\t// any referrer bonus amount is subtracted from the validatorShare\n\t\t\t\t\t\tvalidatorShare.Sub(&validatorShare, &referrerReward)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tdistributedRewards.Add(distributedRewards, &validatorShare)\n\t\t\t\tcachedDelegations.IncreaseRewardDelegation(ctx, candidate.Address, candidate.Address, validatorShare)\n\n\t\t\t\t// If a validator has some non-zero WhitelistAmount,\n\t\t\t\t// calculate the validator's reward based on whitelist amount\n\t\t\t\tif !common.IsZero(statistic.WhitelistAmount.Value) {\n\t\t\t\t\tamount := calculateWeightedWhitelistAmount(*statistic)\n\t\t\t\t\twhitelistDistribution := calculateShare(amount, statistic.DelegationTotal.Value, *delegatorsShare)\n\t\t\t\t\t// increase a delegator's distribution\n\t\t\t\t\tdistributedRewards.Add(distributedRewards, &whitelistDistribution)\n\t\t\t\t\tcachedDelegations.IncreaseRewardDelegation(ctx, candidate.Address, candidate.Address, whitelistDistribution)\n\t\t\t\t}\n\n\t\t\t\t// Keeping track of cumulative distributed rewards by adding\n\t\t\t\t// every validator's total rewards to\n\t\t\t\t// `state.TotalRewardDistribution`\n\t\t\t\t// NOTE: because we round down in every `calculateRewards` call,\n\t\t\t\t// we expect `state.TotalRewardDistribution` to be a slight\n\t\t\t\t// overestimate of what was actually distributed. We could be\n\t\t\t\t// exact with our record keeping by incrementing\n\t\t\t\t// `state.TotalRewardDistribution` each time\n\t\t\t\t// `IncreaseRewardDelegation` is called, but because we will not\n\t\t\t\t// use `state.TotalRewardDistributions` as part of any invariants,\n\t\t\t\t// we will live with this situation.\n\t\t\t\tif !ctx.FeatureEnabled(features.DPOSVersion3_1, false) {\n\t\t\t\t\tstate.TotalRewardDistribution.Value.Add(&state.TotalRewardDistribution.Value, &distributionTotal)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif err := slashValidatorDelegations(ctx, cachedDelegations, statistic, candidateAddress); err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif err := SetStatistic(ctx, statistic); err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tformerValidatorTotals[validatorKey] = statistic.DelegationTotal.Value\n\t\t}\n\t}\n\n\tnewDelegationTotals, err := distributeDelegatorRewards(ctx, cachedDelegations, formerValidatorTotals, delegatorRewards, distributedRewards)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif ctx.FeatureEnabled(features.DPOSVersion3_1, false) {\n\t\tstate.TotalRewardDistribution.Value.Add(&state.TotalRewardDistribution.Value, distributedRewards)\n\t}\n\n\tdelegationResults := make([]*DelegationResult, 0, len(newDelegationTotals))\n\tfor validator := range newDelegationTotals {\n\t\tdelegationResults = append(delegationResults, &DelegationResult{\n\t\t\tValidatorAddress: loom.MustParseAddress(validator),\n\t\t\tDelegationTotal: *newDelegationTotals[validator],\n\t\t})\n\t}\n\tsort.Sort(byDelegationTotal(delegationResults))\n\n\treturn delegationResults, nil\n}", "func HistoryRecord(env *Environment, command []string, date time.Time, code int) error {\n\tif env == nil {\n\t\treturn nil\n\t}\n\n\thistoryPath := env.LocalPath(HistoryDir)\n\tif utils.IsNotExist(historyPath) {\n\t\terr := utils.MkdirAll(historyPath, 0755)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\th := &historyRow{\n\t\tCommand: strings.Join(command, \" \"),\n\t\tDate: date,\n\t\tCode: code,\n\t}\n\n\treturn h.save(historyPath)\n}", "func (db *Db) SaveTokenPricesHistory(prices []types.TokenPrice) error {\n\tif len(prices) == 0 {\n\t\treturn nil\n\t}\n\n\tquery := `INSERT INTO token_price_history (unit_name, price, market_cap, timestamp) VALUES`\n\tvar param []interface{}\n\n\tfor i, ticker := range prices {\n\t\tvi := i * 4\n\t\tquery += fmt.Sprintf(\"($%d,$%d,$%d,$%d),\", vi+1, vi+2, vi+3, vi+4)\n\t\tparam = append(param, ticker.UnitName, ticker.Price, ticker.MarketCap, ticker.Timestamp)\n\t}\n\n\tquery = query[:len(query)-1] // Remove trailing \",\"\n\tquery += `\nON CONFLICT ON CONSTRAINT unique_price_for_timestamp DO UPDATE \n\tSET price = excluded.price,\n\t market_cap = excluded.market_cap`\n\n\t_, err := db.Sql.Exec(query, param...)\n\treturn err\n}", "func (as AccountStorage) DeleteRewardHistory(ctx sdk.Context, me types.AccountKey, bucketSlot int64) {\n\tstore := ctx.KVStore(as.key)\n\tstore.Delete(getRewardHistoryKey(me, bucketSlot))\n\treturn\n}", "func (s *HeroesServiceChaincode) gethistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tif len(args) < 2 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 3\")\n\t}\n\n\tvegKey := args[1]\n\tfmt.Printf(\"##### start History of Record: %s\\n\", vegKey)\n\n\tresultsIterator, err := stub.GetHistoryForKey(vegKey)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\t// buffer is a JSON array containing historic values for the marble\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tresponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(response.TxId)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\t// if it was a delete operation on given key, then we need to set the\n\t\t//corresponding value null. Else, we will write the response.Value\n\t\t//as-is (as the Value itself a JSON marble)\n\t\tif response.IsDelete {\n\t\t\tbuffer.WriteString(\"null\")\n\t\t} else {\n\t\t\tbuffer.WriteString(string(response.Value))\n\t\t}\n\n\t\tbuffer.WriteString(\", \\\"Timestamp\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\tfmt.Printf(\"- getHistoryForVegetable returning:\\n%s\\n\", buffer.String())\n\n\treturn shim.Success(buffer.Bytes())\n}", "func (m *MemoryRewardStorage) Add(reward rewards.Reward) int {\n\treward.ID = len(m.rewards) + 1\n\tm.rewards = append(m.rewards, reward)\n\n\treturn reward.ID\n}", "func PurchasedRewardsAPIHandler(response http.ResponseWriter, request *http.Request) {\n\tt := time.Now()\n\tlogRequest := t.Format(\"2006/01/02 15:04:05\") + \" | Request:\" + request.Method + \" | Endpoint: purchasedrewards | \" //Connect to database\n\tfmt.Println(logRequest)\n\tdb, e := sql.Open(\"mysql\", dbConnectionURL)\n\tif e != nil {\n\t\tfmt.Print(e)\n\t}\n\n\t//set mime type to JSON\n\tresponse.Header().Set(\"Content-type\", \"application/json\")\n\n\terr := request.ParseForm()\n\tif err != nil {\n\t\thttp.Error(response, fmt.Sprintf(\"error parsing url %v\", err), 500)\n\t}\n\n\t//can't define dynamic slice in golang\n\tvar result = make([]string, 1000)\n\n\tswitch request.Method {\n\tcase GET:\n\t\tGroupId := strings.Replace(request.URL.Path, \"/api/purchasedrewards/\", \"\", -1)\n\n\t\t//fmt.Println(GroupId)\n\t\tst, getErr := db.Prepare(\"select * from PurchasedRewards where GroupId=?\")\n\t\tif err != nil {\n\t\t\tfmt.Print(getErr)\n\t\t}\n\t\trows, getErr := st.Query(GroupId)\n\t\tif getErr != nil {\n\t\t\tfmt.Print(getErr)\n\t\t}\n\t\ti := 0\n\t\tfor rows.Next() {\n\t\t\tvar RequestId int\n\t\t\tvar GroupId int\n\t\t\tvar RewardName string\n\t\t\tvar PointCost int\n\t\t\tvar RewardDescription string\n\t\t\tvar RewardedUser string\n\n\t\t\tgetErr := rows.Scan(&RequestId, &GroupId, &RewardName, &PointCost, &RewardDescription, &RewardedUser)\n\t\t\treward := &PurchasedReward{RequestId: RequestId, GroupId: GroupId, RewardName: RewardName, PointCost: PointCost, RewardDescription: RewardDescription, RewardedUser: RewardedUser}\n\t\t\tb, getErr := json.Marshal(reward)\n\t\t\tif getErr != nil {\n\t\t\t\tfmt.Println(getErr)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tresult[i] = fmt.Sprintf(\"%s\", string(b))\n\t\t\ti++\n\t\t}\n\t\tresult = result[:i]\n\n\tcase POST:\n\n\t\tGroupId := request.PostFormValue(\"GroupId\")\n\t\tRewardName := request.PostFormValue(\"RewardName\")\n\t\tPointCost := request.PostFormValue(\"PointCost\")\n\t\tRewardDescription := request.PostFormValue(\"RewardDescription\")\n\t\tRewardedUser := request.PostFormValue(\"RewardedUser\")\n\n\t\tvar UserBalance int\n\t\tuserBalanceQueryErr := db.QueryRow(\"SELECT TotalPoints FROM `Points` WHERE `EmailAddress`=? AND `GroupId`=?\", RewardedUser, GroupId).Scan(&UserBalance)\n\t\tswitch {\n\t\tcase userBalanceQueryErr == sql.ErrNoRows:\n\t\t\tlog.Printf(logRequest, \"Unable to find user and group: \\n\", RewardedUser, GroupId)\n\t\tcase userBalanceQueryErr != nil:\n\t\t\tlog.Fatal(userBalanceQueryErr)\n\t\tdefault:\n\t\t}\n\t\tcostInt, err := strconv.Atoi(PointCost)\n\t\tif UserBalance > costInt {\n\t\t\t// Update user's points\n\t\t\tUserBalance -= costInt\n\n\t\t\t// Update database row\n\t\t\tstBalanceUpdate, postBalanceUpdateErr := db.Prepare(\"UPDATE Points SET `totalpoints`=?, `emailaddress`=? WHERE `groupid`=?\")\n\t\t\tif err != nil {\n\t\t\t\tfmt.Print(err)\n\t\t\t}\n\t\t\tresBalanceUpdate, postBalanceUpdateErr := stBalanceUpdate.Exec(UserBalance, RewardedUser, GroupId)\n\t\t\tif postBalanceUpdateErr != nil {\n\t\t\t\tfmt.Print(postBalanceUpdateErr)\n\t\t\t}\n\t\t\tif resBalanceUpdate != nil {\n\t\t\t\tresult[0] = \"Points Subtracted\"\n\t\t\t}\n\t\t\tresult = result[:1]\n\n\t\t\t// Add purchase to record\n\t\t\tstPurchase, postPurchaseErr := db.Prepare(\"INSERT INTO PurchasedRewards(`requestid`, `groupid`, `rewardname`, `pointcost`, `rewarddescription`, `rewardeduser`) VALUES(NULL,?,?,?,?,?)\")\n\t\t\tif postPurchaseErr != nil {\n\t\t\t\tfmt.Print(postPurchaseErr)\n\t\t\t}\n\t\t\tresPurchase, postPurchaseErr := stPurchase.Exec(GroupId, RewardName, PointCost, RewardDescription, RewardedUser)\n\t\t\tif postPurchaseErr != nil {\n\t\t\t\tfmt.Print(postPurchaseErr)\n\t\t\t}\n\n\t\t\tif resPurchase != nil {\n\t\t\t\tresult[0] = \"Purchase Added\"\n\t\t\t}\n\n\t\t\tresult = result[:1]\n\t\t} else {\n\t\t\tresult[0] = \"Purchase Rejected\"\n\t\t\tresult = result[:1]\n\t\t}\n\n\tcase PUT:\n\t\tRequestId := request.PostFormValue(\"RequestId\")\n\t\tGroupId := request.PostFormValue(\"GroupId\")\n\t\tRewardName := request.PostFormValue(\"RewardName\")\n\t\tPointCost := request.PostFormValue(\"PointCost\")\n\t\tRewardDescription := request.PostFormValue(\"RewardDescription\")\n\t\tRewardedUser := request.PostFormValue(\"RewardedUser\")\n\n\t\tst, putErr := db.Prepare(\"UPDATE PurchasedRewards SET GroupId=?, RewardName=?, PointCost=?, RewardDescription=?, RewardedUser=? WHERE RequestId=?\")\n\t\tif err != nil {\n\t\t\tfmt.Print(putErr)\n\t\t}\n\t\tres, putErr := st.Exec(GroupId, RewardName, PointCost, RewardDescription, RewardedUser, RequestId)\n\t\tif putErr != nil {\n\t\t\tfmt.Print(putErr)\n\t\t}\n\n\t\tif res != nil {\n\t\t\tresult[0] = \"Reward Modified\"\n\t\t}\n\t\tresult = result[:1]\n\n\tcase DELETE:\n\t\tRequestId := strings.Replace(request.URL.Path, \"/api/purchasedrewards/\", \"\", -1)\n\t\tst, deleteErr := db.Prepare(\"DELETE FROM PurchasedRewards where RequestId=?\")\n\t\tif deleteErr != nil {\n\t\t\tfmt.Print(deleteErr)\n\t\t}\n\t\tres, deleteErr := st.Exec(RequestId)\n\t\tif deleteErr != nil {\n\t\t\tfmt.Print(deleteErr)\n\t\t}\n\n\t\tif res != nil {\n\t\t\tresult[0] = \"Reward Deleted\"\n\t\t}\n\t\tresult = result[:1]\n\n\tdefault:\n\t}\n\n\tjson, err := json.Marshal(result)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n\t// Send the text diagnostics to the client. Clean backslashes from json\n\tfmt.Fprintf(response, \"%v\", CleanJSON(string(json)))\n\t//fmt.Fprintf(response, \" request.URL.Path '%v'\\n\", request.Method)\n\tdb.Close()\n}", "func ApplyRewardTx(tx *types.Transaction, statedb *state.Statedb) (*types.Receipt, error) {\n\tstatedb.CreateAccount(tx.Data.To)\n\tstatedb.AddBalance(tx.Data.To, tx.Data.Amount)\n\n\thash, err := statedb.Hash()\n\tif err != nil {\n\t\treturn nil, errors.NewStackedError(err, \"failed to get statedb root hash\")\n\t}\n\n\treceipt := &types.Receipt{\n\t\tTxHash: tx.Hash,\n\t\tPostState: hash,\n\t}\n\n\treturn receipt, nil\n}", "func ValidateRewardTx(tx *types.Transaction, header *types.BlockHeader) error {\n\tif tx.Data.Type != types.TxTypeReward || !tx.Data.From.IsEmpty() || tx.Data.AccountNonce != 0 || tx.Data.GasPrice.Cmp(common.Big0) != 0 || tx.Data.GasLimit != 0 || len(tx.Data.Payload) != 0 {\n\t\treturn errInvalidReward\n\t}\n\n\t// validate to address\n\tto := tx.Data.To\n\tif to.IsEmpty() {\n\t\treturn errEmptyToAddress\n\t}\n\n\tif !to.Equal(header.Creator) {\n\t\treturn errCoinbaseMismatch\n\t}\n\n\t// validate reward\n\tamount := tx.Data.Amount\n\tif err := validateReward(amount); err != nil {\n\t\treturn err\n\t}\n\n\treward := consensus.GetReward(header.Height)\n\tif reward == nil || reward.Cmp(amount) != 0 {\n\t\treturn fmt.Errorf(\"invalid reward Amount, block height %d, want %s, got %s\", header.Height, reward, amount)\n\t}\n\n\t// validate timestamp\n\tif tx.Data.Timestamp != header.CreateTimestamp.Uint64() {\n\t\treturn errTimestampMismatch\n\t}\n\n\treturn nil\n}", "func (_RandomBeacon *RandomBeaconFilterer) WatchRewardParametersUpdated(opts *bind.WatchOpts, sink chan<- *RandomBeaconRewardParametersUpdated) (event.Subscription, error) {\n\n\tlogs, sub, err := _RandomBeacon.contract.WatchLogs(opts, \"RewardParametersUpdated\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn event.NewSubscription(func(quit <-chan struct{}) error {\n\t\tdefer sub.Unsubscribe()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase log := <-logs:\n\t\t\t\t// New log arrived, parse the event and forward to the user\n\t\t\t\tevent := new(RandomBeaconRewardParametersUpdated)\n\t\t\t\tif err := _RandomBeacon.contract.UnpackLog(event, \"RewardParametersUpdated\", log); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tevent.Raw = log\n\n\t\t\t\tselect {\n\t\t\t\tcase sink <- event:\n\t\t\t\tcase err := <-sub.Err():\n\t\t\t\t\treturn err\n\t\t\t\tcase <-quit:\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\tcase err := <-sub.Err():\n\t\t\t\treturn err\n\t\t\tcase <-quit:\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}), nil\n}", "func saveAddHistoryTime(w http.ResponseWriter, r *http.Request, t map[string]interface{}) {\n\tf := firego.NewGAE(appengine.NewContext(r), FIRE_URL)\n\tf.Auth(FIRE_AUTH)\n\tif e := f.Update(t); e == nil {\n\t\tif _, e := f.Push(nil); e == nil {\n\t\t\tstatus(w, fmt.Sprintf(\"updated history: %v\", t[\"lastSave\"]), 200)\n\t\t} else {\n\t\t\ts := fmt.Sprintf(\"Firebase push error: %v\", e)\n\t\t\tstatus(w, s, 303)\n\t\t}\n\t} else {\n\t\ts := fmt.Sprintf(\"Firebase update command error: %v\", e)\n\t\tstatus(w, s, 304)\n\t}\n}", "func EstimateReward(reward, pr, gamma float64) float64 {\n\tret := reward / (pr + gamma)\n\tlog.Logf(MABLogLevel, \"MAB Estimate Reward: %v / (%v + %v) = %v\\n\",\n\t\treward, pr, gamma, ret)\n\treturn ret\n}", "func (m *RestaurantMutation) AddHistoryIDs(ids ...int) {\n\tif m.histories == nil {\n\t\tm.histories = make(map[int]struct{})\n\t}\n\tfor i := range ids {\n\t\tm.histories[ids[i]] = struct{}{}\n\t}\n}", "func (_Token *TokenCaller) BaseReward(opts *bind.CallOpts, index *big.Int) (*big.Int, *big.Int, *big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t\tret1 = new(*big.Int)\n\t\tret2 = new(*big.Int)\n\t)\n\tout := &[]interface{}{\n\t\tret0,\n\t\tret1,\n\t\tret2,\n\t}\n\terr := _Token.contract.Call(opts, out, \"baseReward\", index)\n\treturn *ret0, *ret1, *ret2, err\n}", "func (cra clawbackRewardAction) ProcessReward(ctx sdk.Context, reward sdk.Coins, rawAccount exported.VestingAccount) error {\n\tcva, ok := rawAccount.(*ClawbackVestingAccount)\n\tif !ok {\n\t\treturn sdkerrors.Wrapf(sdkerrors.ErrNotSupported, \"expected *ClawbackVestingAccount, got %T\", rawAccount)\n\t}\n\tcva.postReward(ctx, reward, cra.ak, cra.bk, cra.sk)\n\treturn nil\n}", "func (va ClawbackVestingAccount) distributeReward(ctx sdk.Context, ak AccountKeeper, bondDenom string, reward sdk.Coins) {\n\tnow := ctx.BlockTime().Unix()\n\tt := va.StartTime\n\tfirstUnvestedPeriod := 0\n\tunvestedTokens := sdk.ZeroInt()\n\tfor i, period := range va.VestingPeriods {\n\t\tt += period.Length\n\t\tif t <= now {\n\t\t\tfirstUnvestedPeriod = i + 1\n\t\t\tcontinue\n\t\t}\n\t\tunvestedTokens = unvestedTokens.Add(period.Amount.AmountOf(bondDenom))\n\t}\n\n\trunningTotReward := sdk.NewCoins()\n\trunningTotStaking := sdk.ZeroInt()\n\tfor i := firstUnvestedPeriod; i < len(va.VestingPeriods); i++ {\n\t\tperiod := va.VestingPeriods[i]\n\t\trunningTotStaking = runningTotStaking.Add(period.Amount.AmountOf(bondDenom))\n\t\trunningTotRatio := runningTotStaking.ToDec().Quo(unvestedTokens.ToDec())\n\t\ttargetCoins := scaleCoins(reward, runningTotRatio)\n\t\tthisReward := targetCoins.Sub(runningTotReward)\n\t\trunningTotReward = targetCoins\n\t\tperiod.Amount = period.Amount.Add(thisReward...)\n\t\tva.VestingPeriods[i] = period\n\t}\n\n\tva.OriginalVesting = va.OriginalVesting.Add(reward...)\n\tak.SetAccount(ctx, &va)\n}", "func (_Token *TokenSession) BaseRewardHistoryLength() (*big.Int, error) {\n\treturn _Token.Contract.BaseRewardHistoryLength(&_Token.CallOpts)\n}", "func (brutx *BotRecordUpdateTransaction) RevertBotRecordUpdate(record *BotRecord) error {\n\t// update the record expiration time in the most simple way possible,\n\t// should there have been a time jump, the caller might have to correct expiration time\n\trecord.Expiration -= BotMonth * CompactTimestamp(brutx.NrOfMonths)\n\n\t// remove all addresses that were added\n\terr := record.RemoveNetworkAddresses(brutx.Addresses.Add...) // passing a nil slice is valid\n\tif err != nil {\n\t\treturn err\n\t}\n\t// add all adderesses that were removed\n\terr = record.AddNetworkAddresses(brutx.Addresses.Remove...) // passing a nil slice is valid\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// remove all names that were added\n\terr = record.RemoveNames(brutx.Names.Add...) // passing a nil slice is valid\n\tif err != nil {\n\t\treturn err\n\t}\n\t// add all names that were removed\n\terr = record.AddNames(brutx.Names.Remove...) // passing a nil slice is valid\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// all good\n\treturn nil\n}", "func (h *changepointHeuristic) addToHistory(positionCounts counts) {\n\tif positionCounts.Runs > 0 {\n\t\th.addedUnexpectedRuns = positionCounts.HasUnexpected > 0\n\t\th.addedExpectedRuns = (positionCounts.Runs - positionCounts.HasUnexpected) > 0\n\t}\n\tif positionCounts.Retried > 0 {\n\t\th.addedUnexpectedAfterRetry = positionCounts.UnexpectedAfterRetry > 0\n\t\th.addedExpectedAfterRetry = (positionCounts.Retried - positionCounts.UnexpectedAfterRetry) > 0\n\t}\n}", "func (c RewardsController) CollectReward(id string) revel.Result {\n\tif !c.GetCurrentUser() {\n\t\treturn c.ForbiddenResponse()\n\t}\n\n\tif !bson.IsObjectIdHex(id) {\n\t\treturn c.ErrorResponse(nil, c.Message(\"error.invalid\", \"\"), core.ModelStatus[core.StatusInvalidID])\n\t}\n\n\tvar selector = []bson.M{\n\t\tbson.M{\"user_id\": c.CurrentUser.GetID().Hex()},\n\t\tbson.M{\"_id\": id},\n\t\tbson.M{\"multi\": false},\n\t}\n\tvar query = bson.M{\"$set\": []bson.M{\n\t\tbson.M{\"status.name\": core.StatusObtained},\n\t\tbson.M{\"status.code\": core.ValidationStatus[core.StatusObtained]},\n\t}}\n\n\t// Get pending Rewards for the user\n\tif Reward, ok := app.Mapper.GetModel(&models.Reward{}); ok {\n\t\tif err := Reward.UpdateQuery(selector, query, false); err != nil {\n\t\t\trevel.ERROR.Print(\"ERROR Find\")\n\t\t\treturn c.ErrorResponse(err, err.Error(), 400)\n\t\t}\n\t\treturn c.SuccessResponse(bson.M{\"data\": \"Reward collected successfully\"}, \"success\", core.ModelsType[core.ModelSimpleResponse], nil)\n\t}\n\n\treturn c.ServerErrorResponse()\n}", "func computeReward(epoch abi.ChainEpoch, prevTheta, currTheta, simpleTotal, baselineTotal big.Int) abi.TokenAmount {\n\tsimpleReward := big.Mul(simpleTotal, ExpLamSubOne) //Q.0 * Q.128 => Q.128\n\tepochLam := big.Mul(big.NewInt(int64(epoch)), Lambda) // Q.0 * Q.128 => Q.128\n\n\tsimpleReward = big.Mul(simpleReward, big.NewFromGo(math.ExpNeg(epochLam.Int))) // Q.128 * Q.128 => Q.256\n\tsimpleReward = big.Rsh(simpleReward, math.Precision128) // Q.256 >> 128 => Q.128\n\n\tbaselineReward := big.Sub(computeBaselineSupply(currTheta, baselineTotal), computeBaselineSupply(prevTheta, baselineTotal)) // Q.128\n\n\treward := big.Add(simpleReward, baselineReward) // Q.128\n\n\treturn big.Rsh(reward, math.Precision128) // Q.128 => Q.0\n}", "func (httpServer *HttpServer) handleListRewardAmount(params interface{}, closeChan <-chan struct{}) (interface{}, *rpcservice.RPCError) {\n\tresult := httpServer.databaseService.ListRewardAmount()\n\treturn result, nil\n}", "func InsertHistory(history *models.History , o orm.Ormer) (bool){\n\tnum , err:= o.Insert(history)\n\tif (err ==nil){\n\t\tfmt.Println(\"mysql row affected nums: \" , num)\n\t\treturn true\n\t}\n\treturn false;\n}", "func (s *BlocksService) Reward(ctx context.Context) (*BlocksReward, *http.Response, error) {\n\tvar responseStruct *BlocksReward\n\tresp, err := s.client.SendRequest(ctx, \"GET\", \"blocks/getReward\", nil, &responseStruct)\n\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn responseStruct, resp, err\n}", "func (_Token *TokenCallerSession) BaseRewardHistoryLength() (*big.Int, error) {\n\treturn _Token.Contract.BaseRewardHistoryLength(&_Token.CallOpts)\n}", "func (as AccountStorage) GetRewardHistory(\n\tctx sdk.Context, me types.AccountKey, bucketSlot int64) (*RewardHistory, sdk.Error) {\n\tstore := ctx.KVStore(as.key)\n\trewardHistoryBytes := store.Get(getRewardHistoryKey(me, bucketSlot))\n\tif rewardHistoryBytes == nil {\n\t\treturn nil, nil\n\t}\n\thistory := new(RewardHistory)\n\tif err := as.cdc.UnmarshalJSON(rewardHistoryBytes, history); err != nil {\n\t\treturn nil, ErrFailedToUnmarshalRewardHistory(err)\n\t}\n\treturn history, nil\n}", "func updateStoriesRank() error {\n\tsql := \"update stories set rank = 100 * points / POWER((select max(id) from stories) - id + 1,1.2)\"\n\t_, err := query.Exec(sql)\n\treturn err\n}", "func GetRewardEventsInfo(fromBlock *big.Int, toBlock *big.Int) []*RewardInfo {\n\n\tvar logEpochRewardSig = []byte(\"EpochRewardsDistributedToVoters(address,uint256)\")\n\tvar logEpochRewardSigHash = crypto.Keccak256Hash(logEpochRewardSig)\n\tvar TopicsFilter = [][]common.Hash{{logEpochRewardSigHash}}\n\n\tcontractAddress := common.HexToAddress(WrapperContractDeploymentAddress[NetActive][Election])\n\n\tquery := ethereum.FilterQuery{\n\t\tFromBlock: fromBlock,\n\t\tToBlock: toBlock,\n\t\tTopics: TopicsFilter,\n\n\t\tAddresses: []common.Address{\n\t\t\tcontractAddress,\n\t\t},\n\t}\n\n\tlogs, err := atlasEthClient.FilterLogs(context.Background(), query)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\trewards_info := make([]*RewardInfo, 0, len(logs))\n\n\tcontractAbi, err := abi.JSON(strings.NewReader(string(binding.ElectionABI)))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfor _, vLog := range logs {\n\n\t\tvar epochRewardEvent EpochRewardEvent\n\t\terr := contractAbi.Unpack(&epochRewardEvent, \"EpochRewardsDistributedToVoters\", vLog.Data)\n\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tri := &RewardInfo{Group: common.HexToAddress(vLog.Topics[1].Hex()).String(),\n\t\t\tGroupHash: vLog.Topics[1],\n\t\t\tRewardValue: epochRewardEvent.Value,\n\t\t\tBlockNumber: new(big.Int).SetUint64(vLog.BlockNumber)}\n\n\t\tAddAtlasToRewardInfo(ri)\n\n\t\trewards_info = append(rewards_info, ri)\n\t}\n\n\treturn rewards_info\n}", "func (ht *historyTable) add(m Move, delta int32) {\n\th := historyHash(m)\n\tif ht[h].move != m {\n\t\tht[h] = historyEntry{stat: delta, move: m}\n\t} else {\n\t\tht[h].stat += delta\n\t}\n}", "func (_RewardsDistributionRecipient *RewardsDistributionRecipientSession) NotifyRewardAmount(reward *big.Int) (*types.Transaction, error) {\n\treturn _RewardsDistributionRecipient.Contract.NotifyRewardAmount(&_RewardsDistributionRecipient.TransactOpts, reward)\n}", "func (x *XmpMM) AppendVersionHistory(action ActionType, modifier, changed string, date xmp.Date) {\n\t// append change to last version\n\tv := x.GetLastVersion()\n\n\t// make new version if none exists or if list does not contain\n\t// entry for the current version\n\tif v == nil || v.Version != x.VersionID {\n\t\tv = &StVersion{\n\t\t\tEvent: ResourceEvent{\n\t\t\t\tAction: action,\n\t\t\t\tChanged: xmpdm.NewPartList(changed),\n\t\t\t\tInstanceID: x.InstanceID,\n\t\t\t\tSoftwareAgent: xmp.Agent,\n\t\t\t\tWhen: date,\n\t\t\t},\n\t\t\tModifier: modifier,\n\t\t\tModifyDate: date,\n\t\t\tVersion: x.VersionID,\n\t\t}\n\t\tx.AddVersion(v)\n\t\treturn\n\t}\n\tv.Event.Changed.Add(changed)\n}", "func (pu *PatientrecordUpdate) AddHistorytaking(h ...*Historytaking) *PatientrecordUpdate {\n\tids := make([]int, len(h))\n\tfor i := range h {\n\t\tids[i] = h[i].ID\n\t}\n\treturn pu.AddHistorytakingIDs(ids...)\n}", "func (q querier) RewardWeight(c context.Context, req *types.QueryRewardWeightRequest) (*types.QueryRewardWeightResponse, error) {\n\tctx := sdk.UnwrapSDKContext(c)\n\treturn &types.QueryRewardWeightResponse{RewardWeight: q.GetRewardWeight(ctx)}, nil\n}", "func (mw *ShardedRDB) SaveRaftState(updates []pb.Update,\n\tctx raftio.IContext) error {\n\tif len(updates) == 0 {\n\t\treturn nil\n\t}\n\tpid := mw.getParititionID(updates)\n\treturn mw.shards[pid].saveRaftState(updates, ctx)\n}", "func (_XStaking *XStakingSession) Rewards(arg0 common.Address) (*big.Int, error) {\n\treturn _XStaking.Contract.Rewards(&_XStaking.CallOpts, arg0)\n}", "func (r *Raft) AppendToLog_Follower(request AppendEntriesReq) {\n\tterm := request.term\n\tcmd := request.entries\n\tindex := request.prevLogIndex + 1\n\tlogVal := LogVal{term, cmd, 0} //make object for log's value field\n\n\tif len(r.myLog) == index {\n\t\tr.myLog = append(r.myLog, logVal) //when trying to add a new entry\n\t} else {\n\t\tr.myLog[index] = logVal //overwriting in case of log repair\n\t\t//fmt.Println(\"Overwiriting!!\")\n\t}\n\t//fmt.Println(r.myId(), \"Append to log\", string(cmd))\n\t//modify metadata after appending\n\t//r.myMetaData.lastLogIndex = r.myMetaData.lastLogIndex + 1\n\t//r.myMetaData.prevLogIndex = r.myMetaData.lastLogIndex\n\t//\tif len(r.myLog) == 1 {\n\t//\t\tr.myMetaData.prevLogTerm = r.myMetaData.prevLogTerm + 1\n\t//\t} else if len(r.myLog) > 1 {\n\t//\t\tr.myMetaData.prevLogTerm = r.myLog[r.myMetaData.prevLogIndex].Term\n\t//\t}\n\n\t//Changed on 4th april, above is wrong in case of overwriting of log\n\tr.myMetaData.lastLogIndex = index\n\tr.myMetaData.prevLogIndex = index - 1\n\tif index == 0 {\n\t\tr.myMetaData.prevLogTerm = r.myMetaData.prevLogTerm + 1 //or simple -1\n\t} else if index >= 1 {\n\t\tr.myMetaData.prevLogTerm = r.myLog[index-1].Term\n\t}\n\n\t//Update commit index\n\tleaderCI := float64(request.leaderCommitIndex)\n\tmyLI := float64(r.myMetaData.lastLogIndex)\n\tif request.leaderCommitIndex > r.myMetaData.commitIndex {\n\t\tif myLI == -1 { //REDUNDANT since Append to log will make sure it is never -1,also must not copy higher CI if self LI is -1\n\t\t\tr.myMetaData.commitIndex = int(leaderCI)\n\t\t} else {\n\t\t\tr.myMetaData.commitIndex = int(math.Min(leaderCI, myLI))\n\t\t}\n\t}\n\t//fmt.Println(r.myId(), \"My CI is:\", r.myMetaData.commitIndex)\n\tr.WriteLogToDisk()\n}", "func (_XStaking *XStakingCaller) Rewards(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _XStaking.contract.Call(opts, &out, \"rewards\", arg0)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (_Lmc *LmcSession) GetUserAccumulatedReward(_userAddress common.Address, tokenIndex *big.Int) (*big.Int, error) {\n\treturn _Lmc.Contract.GetUserAccumulatedReward(&_Lmc.CallOpts, _userAddress, tokenIndex)\n}", "func (k Keeper) ClaimSwapReward(ctx sdk.Context, owner, receiver sdk.AccAddress, denom string, multiplierName string) error {\n\tmultiplier, found := k.GetMultiplierByDenom(ctx, denom, multiplierName)\n\tif !found {\n\t\treturn errorsmod.Wrapf(types.ErrInvalidMultiplier, \"denom '%s' has no multiplier '%s'\", denom, multiplierName)\n\t}\n\n\tclaimEnd := k.GetClaimEnd(ctx)\n\n\tif ctx.BlockTime().After(claimEnd) {\n\t\treturn errorsmod.Wrapf(types.ErrClaimExpired, \"block time %s > claim end time %s\", ctx.BlockTime(), claimEnd)\n\t}\n\n\tsyncedClaim, found := k.GetSynchronizedSwapClaim(ctx, owner)\n\tif !found {\n\t\treturn errorsmod.Wrapf(types.ErrClaimNotFound, \"address: %s\", owner)\n\t}\n\n\tamt := syncedClaim.Reward.AmountOf(denom)\n\n\tclaimingCoins := sdk.NewCoins(sdk.NewCoin(denom, amt))\n\trewardCoins := sdk.NewCoins(sdk.NewCoin(denom, sdk.NewDecFromInt(amt).Mul(multiplier.Factor).RoundInt()))\n\tif rewardCoins.IsZero() {\n\t\treturn types.ErrZeroClaim\n\t}\n\tlength := k.GetPeriodLength(ctx.BlockTime(), multiplier.MonthsLockup)\n\n\terr := k.SendTimeLockedCoinsToAccount(ctx, types.IncentiveMacc, receiver, rewardCoins, length)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// remove claimed coins (NOT reward coins)\n\tsyncedClaim.Reward = syncedClaim.Reward.Sub(claimingCoins...)\n\tk.SetSwapClaim(ctx, syncedClaim)\n\n\tctx.EventManager().EmitEvent(\n\t\tsdk.NewEvent(\n\t\t\ttypes.EventTypeClaim,\n\t\t\tsdk.NewAttribute(types.AttributeKeyClaimedBy, owner.String()),\n\t\t\tsdk.NewAttribute(types.AttributeKeyClaimAmount, claimingCoins.String()),\n\t\t\tsdk.NewAttribute(types.AttributeKeyClaimType, syncedClaim.GetType()),\n\t\t),\n\t)\n\treturn nil\n}", "func (t *truth) updateRedoRule(n *node) error {\n\tqid := n.event.QueryID\n\tbyQuery := t.byQuery[n.event.ParentID]\n\tbyQuery[len(byQuery)-1].AddEdge(n)\n\tt.byTime = n\n\tt.byQuery[qid] = append(t.byQuery[qid], n)\n\treturn nil\n}", "func (va ClawbackVestingAccount) postReward(ctx sdk.Context, reward sdk.Coins, ak AccountKeeper, bk BankKeeper, sk StakingKeeper) {\n\t// Find the scheduled amount of vested and unvested staking tokens\n\tbondDenom := sk.BondDenom(ctx)\n\tvested := ReadSchedule(va.StartTime, va.EndTime, va.VestingPeriods, va.OriginalVesting, ctx.BlockTime().Unix()).AmountOf(bondDenom)\n\tunvested := va.OriginalVesting.AmountOf(bondDenom).Sub(vested)\n\n\tif unvested.IsZero() {\n\t\t// no need to adjust the vesting schedule\n\t\treturn\n\t}\n\n\tif vested.IsZero() {\n\t\t// all staked tokens must be unvested\n\t\tva.distributeReward(ctx, ak, bondDenom, reward)\n\t\treturn\n\t}\n\n\t// Find current split of account balance on staking axis\n\tbonded := sk.GetDelegatorBonded(ctx, va.GetAddress())\n\tunbonding := sk.GetDelegatorUnbonding(ctx, va.GetAddress())\n\tdelegated := bonded.Add(unbonding)\n\n\t// discover what has been slashed and remove from delegated amount\n\toldDelegated := va.DelegatedVesting.AmountOf(bondDenom).Add(va.DelegatedFree.AmountOf(bondDenom))\n\tslashed := oldDelegated.Sub(intMin(oldDelegated, delegated))\n\tdelegated = delegated.Sub(intMin(delegated, slashed))\n\n\t// Prefer delegated tokens to be unvested\n\tunvested = intMin(unvested, delegated)\n\tvested = delegated.Sub(unvested)\n\n\t// Compute the unvested amount of reward and add to vesting schedule\n\tif unvested.IsZero() {\n\t\treturn\n\t}\n\tif vested.IsZero() {\n\t\tva.distributeReward(ctx, ak, bondDenom, reward)\n\t\treturn\n\t}\n\tunvestedRatio := unvested.ToDec().QuoTruncate(bonded.ToDec()) // round down\n\tunvestedReward := scaleCoins(reward, unvestedRatio)\n\tva.distributeReward(ctx, ak, bondDenom, unvestedReward)\n}", "func (e *TarantoolEngine) addHistory(chID ChannelID, message Message, size, lifetime int64) (err error) {\n\t// not implemented\n\treturn\n}", "func (d *Dao) HasReward(c context.Context, uid int64) (r int64, err error) {\n\trst, err := d.GetHasReward(c, uid)\n\tif err != nil {\n\t\tif err == memcache.ErrNotFound {\n\t\t\treward, err2 := d.findByUid(uid, true)\n\t\t\tif err2 != nil {\n\t\t\t\treturn rst, err2\n\t\t\t}\n\t\t\tif reward != nil {\n\t\t\t\trst = int64(1)\n\t\t\t\td.SetHasReward(c, uid, rst)\n\t\t\t} else {\n\t\t\t\trst = int64(0)\n\t\t\t\td.SetHasReward(c, uid, rst)\n\t\t\t}\n\t\t\treturn rst, err\n\t\t}\n\t\tlog.Error(\"HasReward(%v) error(%v)\", uid, err)\n\t\treturn rst, err\n\t}\n\treturn rst, err\n}", "func (o *Post) AddPostHistories(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*PostHistory) error {\n\tvar err error\n\tfor _, rel := range related {\n\t\tif insert {\n\t\t\trel.PostID = o.ID\n\t\t\tif err = rel.Insert(ctx, exec, boil.Infer()); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"failed to insert into foreign table\")\n\t\t\t}\n\t\t} else {\n\t\t\tupdateQuery := fmt.Sprintf(\n\t\t\t\t\"UPDATE \\\"post_histories\\\" SET %s WHERE %s\",\n\t\t\t\tstrmangle.SetParamNames(\"\\\"\", \"\\\"\", 1, []string{\"post_id\"}),\n\t\t\t\tstrmangle.WhereClause(\"\\\"\", \"\\\"\", 2, postHistoryPrimaryKeyColumns),\n\t\t\t)\n\t\t\tvalues := []interface{}{o.ID, rel.ID}\n\n\t\t\tif boil.DebugMode {\n\t\t\t\tfmt.Fprintln(boil.DebugWriter, updateQuery)\n\t\t\t\tfmt.Fprintln(boil.DebugWriter, values)\n\t\t\t}\n\n\t\t\tif _, err = exec.ExecContext(ctx, updateQuery, values...); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"failed to update foreign table\")\n\t\t\t}\n\n\t\t\trel.PostID = o.ID\n\t\t}\n\t}\n\n\tif o.R == nil {\n\t\to.R = &postR{\n\t\t\tPostHistories: related,\n\t\t}\n\t} else {\n\t\to.R.PostHistories = append(o.R.PostHistories, related...)\n\t}\n\n\tfor _, rel := range related {\n\t\tif rel.R == nil {\n\t\t\trel.R = &postHistoryR{\n\t\t\t\tPost: o,\n\t\t\t}\n\t\t} else {\n\t\t\trel.R.Post = o\n\t\t}\n\t}\n\treturn nil\n}", "func (bbo *TabularBBO) LastUpdate(s []float64, a int, r float64, rng *mathlib.Random) {\n\t// If ready to update, update and wipe the states, actions, and rewards.\n\tif bbo.ep.LastUpdate(s, a, r) {\n\t\tbbo.episodeLimitReached(rng)\n\t}\n}", "func (brutx *BotRecordUpdateTransaction) UpdateBotRecord(blockTime types.Timestamp, record *BotRecord) error {\n\tvar err error\n\n\t// if the record indicate the bot is expired, we ensure to reset the names,\n\t// and also make sure the NrOfMonths is greater than 0\n\tif record.IsExpired(blockTime) {\n\t\tif brutx.NrOfMonths == 0 {\n\t\t\treturn errors.New(\"record update Tx does not make bot active, while bot is already expired\")\n\t\t}\n\t\trecord.ResetNames()\n\t}\n\n\t// update the expiration time\n\tif brutx.NrOfMonths != 0 {\n\t\terr = record.ExtendExpirationDate(blockTime, brutx.NrOfMonths)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// remove all addresses first, afterwards add the new addresses.\n\t// By removing first we ensure that we can add addresses that were removed by this Tx,\n\t// but more importantly it ensures that we don't invalidly report that an overflow has happened.\n\terr = record.RemoveNetworkAddresses(brutx.Addresses.Remove...) // passing a nil slice is valid\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = record.AddNetworkAddresses(brutx.Addresses.Add...) // passing a nil slice is valid\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// remove all names first, afterwards add the new names.\n\t// By removing first we ensure that we can add names that were removed by this Tx,\n\t// but more importantly it ensures that we don't invalidly report that an overflow has happened.\n\terr = record.RemoveNames(brutx.Names.Remove...) // passing a nil slice is valid\n\tif err != nil {\n\t\t// an error will also occur here, in case names are removed from a bot that was previously inactive,\n\t\t// as our earlier logic has already reset the names of the revord, making this step implicitly invalid,\n\t\t// which is what we want, as an inative revord no longer owns any names, no matter what was last known about the record.\n\t\treturn err\n\t}\n\terr = record.AddNames(brutx.Names.Add...) // passing a nil slice is valid\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// all good\n\treturn nil\n}", "func MeanReward(r []*Rollout) float64 {\n\tvar sum float64\n\tfor _, x := range r {\n\t\tsum += x.Reward\n\t}\n\treturn sum / float64(len(r))\n}", "func (va *ClawbackVestingAccount) PostReward(ctx sdk.Context, reward sdk.Coins, action exported.RewardAction) error {\n\treturn action.ProcessReward(ctx, reward, va)\n}", "func (s *Server) History(w http.ResponseWriter, r *http.Request) {\n\tteam, err := s.currentTeam(w, r)\n\tif err != nil {\n\t\ts.unauthorized(w, err)\n\t\treturn\n\t}\n\n\tscores, err := models.NewScore().History(team.ID)\n\tif err != nil {\n\t\tError(w, http.StatusNotFound, err, \"failed to get history\")\n\t}\n\tJSON(w, http.StatusOK, scores)\n}", "func (_RewardsDistributionRecipient *RewardsDistributionRecipientTransactorSession) NotifyRewardAmount(reward *big.Int) (*types.Transaction, error) {\n\treturn _RewardsDistributionRecipient.Contract.NotifyRewardAmount(&_RewardsDistributionRecipient.TransactOpts, reward)\n}", "func (_XStaking *XStakingFilterer) WatchRewardAdded(opts *bind.WatchOpts, sink chan<- *XStakingRewardAdded) (event.Subscription, error) {\n\n\tlogs, sub, err := _XStaking.contract.WatchLogs(opts, \"RewardAdded\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn event.NewSubscription(func(quit <-chan struct{}) error {\n\t\tdefer sub.Unsubscribe()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase log := <-logs:\n\t\t\t\t// New log arrived, parse the event and forward to the user\n\t\t\t\tevent := new(XStakingRewardAdded)\n\t\t\t\tif err := _XStaking.contract.UnpackLog(event, \"RewardAdded\", log); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tevent.Raw = log\n\n\t\t\t\tselect {\n\t\t\t\tcase sink <- event:\n\t\t\t\tcase err := <-sub.Err():\n\t\t\t\t\treturn err\n\t\t\t\tcase <-quit:\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\tcase err := <-sub.Err():\n\t\t\t\treturn err\n\t\t\tcase <-quit:\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}), nil\n}", "func (path *Path) Rewards() map[*Reward]int {\n\treturn path.rewards\n}", "func (w *Wallet) applyHistory(cc modules.ConsensusChange) {\n\tfor _, block := range cc.AppliedBlocks {\n\t\tw.consensusSetHeight++\n\t\t// Apply the miner payout transaction if applicable.\n\t\tminerPT := modules.ProcessedTransaction{\n\t\t\tTransaction: types.Transaction{},\n\t\t\tTransactionID: types.TransactionID(block.ID()),\n\t\t\tConfirmationHeight: w.consensusSetHeight,\n\t\t\tConfirmationTimestamp: block.Timestamp,\n\t\t}\n\t\trelevant := false\n\t\tfor i, mp := range block.MinerPayouts {\n\t\t\t_, exists := w.keys[mp.UnlockHash]\n\t\t\tif exists {\n\t\t\t\trelevant = true\n\t\t\t}\n\t\t\tminerPT.Outputs = append(minerPT.Outputs, modules.ProcessedOutput{\n\t\t\t\tFundType: types.SpecifierMinerPayout,\n\t\t\t\tMaturityHeight: w.consensusSetHeight + w.chainCts.MaturityDelay,\n\t\t\t\tWalletAddress: exists,\n\t\t\t\tRelatedAddress: mp.UnlockHash,\n\t\t\t\tValue: mp.Value,\n\t\t\t})\n\t\t\tw.historicOutputs[types.OutputID(block.MinerPayoutID(uint64(i)))] = historicOutput{\n\t\t\t\tUnlockHash: mp.UnlockHash,\n\t\t\t\tValue: mp.Value,\n\t\t\t}\n\t\t}\n\t\tif relevant {\n\t\t\tw.processedTransactions = append(w.processedTransactions, minerPT)\n\t\t\tw.processedTransactionMap[minerPT.TransactionID] = &w.processedTransactions[len(w.processedTransactions)-1]\n\t\t}\n\n\t\tblockheight, blockexists := w.cs.BlockHeightOfBlock(block)\n\t\tif !blockexists {\n\t\t\tbuild.Critical(\"Block wherer ubs is used to respent, does not yet exist as processedblock\")\n\t\t}\n\n\t\tfor ti, txn := range block.Transactions {\n\t\t\trelevant := false\n\t\t\tpt := modules.ProcessedTransaction{\n\t\t\t\tTransaction: txn,\n\t\t\t\tTransactionID: txn.ID(),\n\t\t\t\tConfirmationHeight: w.consensusSetHeight,\n\t\t\t\tConfirmationTimestamp: block.Timestamp,\n\t\t\t}\n\t\t\tfor _, sci := range txn.CoinInputs {\n\t\t\t\toutput := w.historicOutputs[types.OutputID(sci.ParentID)]\n\t\t\t\t_, exists := w.keys[output.UnlockHash]\n\t\t\t\tif exists {\n\t\t\t\t\trelevant = true\n\t\t\t\t} else if _, exists = w.multiSigCoinOutputs[sci.ParentID]; exists {\n\t\t\t\t\t// Since we know about every multisig output that is still open and releated,\n\t\t\t\t\t// any relevant multisig input must have a parent ID present in the multisig\n\t\t\t\t\t// output map.\n\t\t\t\t\trelevant = true\n\t\t\t\t\t// set \"exists\" to false since the output is not owned by the wallet.\n\t\t\t\t\texists = false\n\t\t\t\t}\n\t\t\t\tpt.Inputs = append(pt.Inputs, modules.ProcessedInput{\n\t\t\t\t\tFundType: types.SpecifierCoinInput,\n\t\t\t\t\tWalletAddress: exists,\n\t\t\t\t\tRelatedAddress: output.UnlockHash,\n\t\t\t\t\tValue: output.Value,\n\t\t\t\t})\n\t\t\t}\n\t\t\tfor i, sco := range txn.CoinOutputs {\n\t\t\t\t_, exists := w.keys[sco.Condition.UnlockHash()]\n\t\t\t\tif exists {\n\t\t\t\t\trelevant = true\n\t\t\t\t} else if _, exists = w.multiSigCoinOutputs[txn.CoinOutputID(uint64(i))]; exists {\n\t\t\t\t\t// If the coin output is a relevant multisig output, it's ID will already\n\t\t\t\t\t// be present in the multisigCoinOutputs map\n\t\t\t\t\trelevant = true\n\t\t\t\t\t// set \"exists\" to false since the output is not owned by the wallet.\n\t\t\t\t\texists = false\n\t\t\t\t}\n\t\t\t\tuh := sco.Condition.UnlockHash()\n\t\t\t\tpt.Outputs = append(pt.Outputs, modules.ProcessedOutput{\n\t\t\t\t\tFundType: types.SpecifierCoinOutput,\n\t\t\t\t\tMaturityHeight: w.consensusSetHeight,\n\t\t\t\t\tWalletAddress: exists,\n\t\t\t\t\tRelatedAddress: uh,\n\t\t\t\t\tValue: sco.Value,\n\t\t\t\t})\n\t\t\t\tw.historicOutputs[types.OutputID(txn.CoinOutputID(uint64(i)))] = historicOutput{\n\t\t\t\t\tUnlockHash: uh,\n\t\t\t\t\tValue: sco.Value,\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor _, sfi := range txn.BlockStakeInputs {\n\t\t\t\toutput := w.historicOutputs[types.OutputID(sfi.ParentID)]\n\t\t\t\t_, exists := w.keys[output.UnlockHash]\n\t\t\t\tif exists {\n\t\t\t\t\trelevant = true\n\t\t\t\t} else if _, exists = w.multiSigBlockStakeOutputs[sfi.ParentID]; exists {\n\t\t\t\t\t// Since we know about every multisig output that is still open and releated,\n\t\t\t\t\t// any relevant multisig input must have a parent ID present in the multisig\n\t\t\t\t\t// output map.\n\t\t\t\t\trelevant = true\n\t\t\t\t\t// set \"exists\" to false since the output is not owned by the wallet.\n\t\t\t\t\texists = false\n\t\t\t\t}\n\t\t\t\tpt.Inputs = append(pt.Inputs, modules.ProcessedInput{\n\t\t\t\t\tFundType: types.SpecifierBlockStakeInput,\n\t\t\t\t\tWalletAddress: exists,\n\t\t\t\t\tRelatedAddress: output.UnlockHash,\n\t\t\t\t\tValue: output.Value,\n\t\t\t\t})\n\t\t\t}\n\t\t\tfor i, sfo := range txn.BlockStakeOutputs {\n\t\t\t\t_, exists := w.keys[sfo.Condition.UnlockHash()]\n\t\t\t\tif exists {\n\t\t\t\t\trelevant = true\n\t\t\t\t} else if _, exists = w.multiSigBlockStakeOutputs[txn.BlockStakeOutputID(uint64(i))]; exists {\n\t\t\t\t\t// If the block stake output is a relevant multisig output, it's ID will already\n\t\t\t\t\t// be present in the multisigBlockStakeOutputs map\n\t\t\t\t\trelevant = true\n\t\t\t\t\t// set \"exists\" to false since the output is not owned by the wallet.\n\t\t\t\t\texists = false\n\t\t\t\t}\n\t\t\t\tuh := sfo.Condition.UnlockHash()\n\t\t\t\tpt.Outputs = append(pt.Outputs, modules.ProcessedOutput{\n\t\t\t\t\tFundType: types.SpecifierBlockStakeOutput,\n\t\t\t\t\tMaturityHeight: w.consensusSetHeight,\n\t\t\t\t\tWalletAddress: exists,\n\t\t\t\t\tRelatedAddress: uh,\n\t\t\t\t\tValue: sfo.Value,\n\t\t\t\t})\n\t\t\t\tbsoid := txn.BlockStakeOutputID(uint64(i))\n\t\t\t\t_, exists = w.blockstakeOutputs[bsoid]\n\t\t\t\tif exists {\n\t\t\t\t\tw.unspentblockstakeoutputs[bsoid] = types.UnspentBlockStakeOutput{\n\t\t\t\t\t\tBlockStakeOutputID: bsoid,\n\t\t\t\t\t\tIndexes: types.BlockStakeOutputIndexes{\n\t\t\t\t\t\t\tBlockHeight: blockheight,\n\t\t\t\t\t\t\tTransactionIndex: uint64(ti),\n\t\t\t\t\t\t\tOutputIndex: uint64(i),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tValue: sfo.Value,\n\t\t\t\t\t\tCondition: sfo.Condition,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tw.historicOutputs[types.OutputID(bsoid)] = historicOutput{\n\t\t\t\t\tUnlockHash: uh,\n\t\t\t\t\tValue: sfo.Value,\n\t\t\t\t}\n\t\t\t}\n\t\t\tif relevant {\n\t\t\t\tw.processedTransactions = append(w.processedTransactions, pt)\n\t\t\t\tw.processedTransactionMap[pt.TransactionID] = &w.processedTransactions[len(w.processedTransactions)-1]\n\t\t\t}\n\t\t}\n\t}\n\t// Reset spent outputs map\n\tw.spentOutputs = make(map[types.OutputID]types.BlockHeight)\n}", "func (s *SimpleChaincode) pat_gethistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tif len(args) < 2 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 3\")\n\t}\n\n\tpatKey := args[1]\n\tfmt.Printf(\"##### start History of Record: %s\\n\", patKey)\n\n\tresultsIterator, err := stub.GetHistoryForKey(patKey)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\t// buffer is a JSON array containing historic values for the marble\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tresponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(response.TxId)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\t// if it was a delete operation on given key, then we need to set the\n\t\t//corresponding value null. Else, we will write the response.Value\n\t\t//as-is (as the Value itself a JSON marble)\n\t\tif response.IsDelete {\n\t\t\tbuffer.WriteString(\"null\")\n\t\t} else {\n\t\t\tbuffer.WriteString(string(response.Value))\n\t\t}\n\n\t\tbuffer.WriteString(\", \\\"Timestamp\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\tfmt.Printf(\"- getHistoryForPatient returning:\\n%s\\n\", buffer.String())\n\n\treturn shim.Success(buffer.Bytes())\n}", "func getAccumulatedRewards(ctx sdk.Context, distKeeper types.DistributionKeeper, delegation stakingtypes.Delegation) ([]wasmvmtypes.Coin, error) {\n\t// Try to get *delegator* reward info!\n\tparams := distributiontypes.QueryDelegationRewardsRequest{\n\t\tDelegatorAddress: delegation.DelegatorAddress,\n\t\tValidatorAddress: delegation.ValidatorAddress,\n\t}\n\tcache, _ := ctx.CacheContext()\n\tqres, err := distKeeper.DelegationRewards(sdk.WrapSDKContext(cache), &params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// now we have it, convert it into wasmvm types\n\trewards := make([]wasmvmtypes.Coin, len(qres.Rewards))\n\tfor i, r := range qres.Rewards {\n\t\trewards[i] = wasmvmtypes.Coin{\n\t\t\tDenom: r.Denom,\n\t\t\tAmount: r.Amount.TruncateInt().String(),\n\t\t}\n\t}\n\treturn rewards, nil\n}", "func (routingHandler *RoutingHandler) updateRoutingTable(whisperStatus *gossiper.WhisperStatus, address *net.UDPAddr) {\n\n\troutingHandler.mutex.Lock()\n\tdefer routingHandler.mutex.Unlock()\n\n\t// if new packet with higher id, updateEnvelopes table\n\tif routingHandler.updateLastOriginID(whisperStatus.Origin, whisperStatus.ID) {\n\n\t\tstatus, loaded := routingHandler.peerStatus[address.String()]\n\t\tif !loaded {\n\t\t\troutingHandler.peerStatus[address.String()] = &Status{}\n\t\t\tstatus, _ = routingHandler.peerStatus[address.String()]\n\t\t}\n\n\t\tif whisperStatus.Code == bloomFilterExCode || whisperStatus.Code == statusCode {\n\t\t\tif whisperStatus.Bloom != nil && len(whisperStatus.Bloom) == BloomFilterSize {\n\t\t\t\tif loaded {\n\t\t\t\t\tstatus.Bloom = AggregateBloom(whisperStatus.Bloom, status.Bloom)\n\t\t\t\t} else {\n\t\t\t\t\tstatus.Bloom = whisperStatus.Bloom\n\t\t\t\t}\n\t\t\t\t//fmt.Println(\"\\nWhisper: routing table updated for BloomFilter, peer entry \" + address.String())\n\t\t\t}\n\t\t}\n\n\t\tif whisperStatus.Code == powRequirementCode || whisperStatus.Code == statusCode {\n\t\t\tif !(math.IsInf(whisperStatus.Pow, 0) || math.IsNaN(whisperStatus.Pow) || whisperStatus.Pow < 0.0) {\n\t\t\t\tif loaded {\n\t\t\t\t\tstatus.Pow = math.Min(status.Pow, whisperStatus.Pow)\n\t\t\t\t} else {\n\t\t\t\t\tstatus.Pow = whisperStatus.Pow\n\t\t\t\t}\n\t\t\t\t//fmt.Println(\"\\nWhisper: routing table updated for PoW, peer entry \" + address.String())\n\t\t\t}\n\t\t}\n\t\t//fmt.Println(\"\\nWhisper: routing table updated, peer entry \" + address.String())\n\t}\n}", "func (o InstanceOutput) UpgradeHistory() UpgradeHistoryEntryResponseArrayOutput {\n\treturn o.ApplyT(func(v *Instance) UpgradeHistoryEntryResponseArrayOutput { return v.UpgradeHistory }).(UpgradeHistoryEntryResponseArrayOutput)\n}", "func appendUFATransactionHistory(stub shim.ChaincodeStubInterface, ufanumber string, payload string) error {\r\n\tvar recordList []string\r\n\r\n\tlogger.Info(\"Appending to transaction history \" + ufanumber)\r\n\trecBytes, _ := stub.GetState(UFA_TRXN_PREFIX + ufanumber)\r\n\r\n\tif recBytes == nil {\r\n\t\tlogger.Info(\"Updating the transaction history for the first time\")\r\n\t\trecordList = make([]string, 0)\r\n\t} else {\r\n\t\terr := json.Unmarshal(recBytes, &recordList)\r\n\t\tif err != nil {\r\n\t\t\treturn errors.New(\"Failed to unmarshal appendUFATransactionHistory \")\r\n\t\t}\r\n\t}\r\n\trecordList = append(recordList, payload)\r\n\tbytesToStore, _ := json.Marshal(recordList)\r\n\tlogger.Info(\"After updating the transaction history\" + string(bytesToStore))\r\n\tstub.PutState(UFA_TRXN_PREFIX+ufanumber, bytesToStore)\r\n\tlogger.Info(\"Appending to transaction history \" + ufanumber + \" Done!!\")\r\n\treturn nil\r\n}", "func rewardRate(pool sdk.Coins, blocks int64) sdk.Coins {\n\tcoins := make([]sdk.Coin, 0)\n\tif blocks > 0 {\n\t\tfor _, coin := range pool {\n\t\t\tif coin.IsZero() {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// divide by blocks, rounding fractions up\n\t\t\t// (coin.Amount - 1)/blocks + 1\n\t\t\trate := coin.Amount.SubRaw(1).QuoRaw(blocks).AddRaw(1)\n\t\t\tcoins = append(coins, sdk.NewCoin(coin.GetDenom(), rate))\n\t\t}\n\t}\n\treturn sdk.NewCoins(coins...)\n}", "func updateLoanState(ls *models.LoanState, db *gorm.DB) error {\n\tomitList := []string{\"id\", \"deleted_at\"}\n\terr := db.Model(ls).Omit(omitList...).Save(ls).Error\n\treturn err\n}", "func (t *Transaction) Reward() string {\n\treturn t.reward\n}", "func (s *PublicSfcAPI) GetRewardWeights(ctx context.Context, stakerID hexutil.Uint) (map[string]interface{}, error) {\n\tbaseRewardWeight, txRewardWeight, err := s.b.GetRewardWeights(ctx, idx.StakerID(stakerID))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif baseRewardWeight == nil || txRewardWeight == nil {\n\t\treturn nil, nil\n\t}\n\treturn map[string]interface{}{\n\t\t\"baseRewardWeight\": (*hexutil.Big)(baseRewardWeight),\n\t\t\"txRewardWeight\": (*hexutil.Big)(txRewardWeight),\n\t}, nil\n}", "func (puo *PatientrecordUpdateOne) AddHistorytaking(h ...*Historytaking) *PatientrecordUpdateOne {\n\tids := make([]int, len(h))\n\tfor i := range h {\n\t\tids[i] = h[i].ID\n\t}\n\treturn puo.AddHistorytakingIDs(ids...)\n}", "func (_Lmc *LmcCallerSession) GetUserAccumulatedReward(_userAddress common.Address, tokenIndex *big.Int) (*big.Int, error) {\n\treturn _Lmc.Contract.GetUserAccumulatedReward(&_Lmc.CallOpts, _userAddress, tokenIndex)\n}" ]
[ "0.60458004", "0.5921379", "0.5813828", "0.5810859", "0.5760177", "0.5708256", "0.55621254", "0.5539769", "0.5532216", "0.5519636", "0.54246104", "0.54080886", "0.53458893", "0.53254765", "0.53176856", "0.5306303", "0.527214", "0.52710384", "0.5270779", "0.52167344", "0.52020156", "0.519777", "0.5185662", "0.5153718", "0.5133926", "0.51125324", "0.5074409", "0.50686735", "0.50390923", "0.5005286", "0.49994683", "0.49931285", "0.49490663", "0.48490855", "0.48377857", "0.48355532", "0.4807257", "0.4791437", "0.4788366", "0.4766619", "0.4763956", "0.47606927", "0.47573155", "0.47008535", "0.46892628", "0.46884656", "0.46807548", "0.464973", "0.46467662", "0.46101218", "0.46069148", "0.460262", "0.45972082", "0.45884174", "0.45785868", "0.45712173", "0.4571051", "0.45468858", "0.454088", "0.45397553", "0.4518378", "0.45065743", "0.45047334", "0.4489074", "0.44792497", "0.4476978", "0.4462474", "0.44492346", "0.44427308", "0.4438635", "0.44327915", "0.44317624", "0.44269827", "0.4425374", "0.44243112", "0.44235653", "0.44193897", "0.4414898", "0.44132087", "0.4410489", "0.43958464", "0.43925664", "0.4391789", "0.4384897", "0.43841484", "0.43781507", "0.43696457", "0.4366985", "0.43651843", "0.43622646", "0.43598148", "0.43512934", "0.43504715", "0.4348658", "0.434649", "0.43428314", "0.43399417", "0.4332627", "0.4328184", "0.43269345" ]
0.8028916
0
stringToBigInt transforms a string to big int
stringToBigInt преобразует строку в больший целый числа
func stringToBigInt(estr string) (*big.Int, error) { ret, ok := big.NewInt(0).SetString(estr, 10) if !ok { return nil, errors.New("failed to parse string to big int") } return ret, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func stringToBigInt(stringValue string) *big.Int {\n\n\tintToReturn := big.NewInt(0)\n\tintToReturn.SetString(stringValue, 10)\n\n\treturn intToReturn\n}", "func HexStrToBigInt(s string) (*big.Int, error) {\n\tregstr := \"^0[xX][0-9a-fA-F]+$\"\n\tif matched, err := regexp.Match(regstr, []byte(s)); err != nil || !matched {\n\t\treturn nil, errors.New(\"Invalid hex string\")\n\t}\n\n\ti, b := new(big.Int).SetString(s[2:], 16)\n\tif !b {\n\t\treturn nil, errors.New(\"Invalid hex string\")\n\t}\n\n\treturn i, nil\n}", "func HexStrToBigInt(hexString string) (*big.Int, error) {\n\tvalue := new(big.Int)\n\t_, ok := value.SetString(Trim0x(hexString), 16)\n\tif !ok {\n\t\treturn value, fmt.Errorf(\"Could not transform hex string to big int: %s\", hexString)\n\t}\n\n\treturn value, nil\n}", "func ParseBigInt(s string, base int) (*big.Int, error) {\n\tif base < 0 || base > 16 {\n\t\treturn nil, errors.New(\"ParseBigInt: invalid base\")\n\t}\n\ts = strings.Replace(s, \"\\n\", \"\", -1)\n\tz, ok := new(big.Int).SetString(s, base)\n\tif !ok {\n\t\treturn nil, errors.New(\"ParseBigInt: invalid string\")\n\t}\n\treturn z, nil\n}", "func ParseBigInt(s string, base int) (*big.Int, error) {\n\tif base < 0 || base > 16 {\n\t\treturn nil, errors.New(\"ParseBigInt: invalid base\")\n\t}\n\ts = strings.Replace(s, \"\\n\", \"\", -1)\n\tz, ok := new(big.Int).SetString(s, base)\n\tif !ok {\n\t\treturn nil, errors.New(\"ParseBigInt: invalid string\")\n\t}\n\treturn z, nil\n}", "func ParseBigInt(str string) (_ *cells.BinaryCell, err error) {\n\tbytes, err := hex.DecodeString(str)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn cells.New(OpUint64, bytes), nil\n}", "func DecodeBigInt(txt string) (*big.Int, error) {\n\tif txt == \"\" {\n\t\treturn new(big.Int), nil // Defaults to 0\n\t}\n\tres, success := new(big.Int).SetString(txt, 10)\n\tif !success {\n\t\treturn nil, fmt.Errorf(\"cannot decode %v into big.Int\", txt)\n\t}\n\treturn res, nil\n}", "func B64ToBigInt(in string, b *big.Int) (err error) {\n\tlength := base64.StdEncoding.DecodedLen(len(in))\n\tbuff := make([]byte, length)\n\tn, err := base64.StdEncoding.Decode(buff, bytes.NewBufferString(in).Bytes())\n\t//neg := false\n\tif err == nil {\n\t\tbuff = buff[0:n]\n\t\t//if buff[0]&0x80 == 0x80 {\n\t\t//\tneg = true\n\t\t//\tbuff[0] &= 0x7f\n\t\t//}\n\t\tb.SetBytes(buff)\n\t\t// In case the passed in big was negative...\n\t\t//b.Abs(b)\n\t\t//if neg {\n\t\t//\tb.Neg(b)\n\t\t//}\n\t}\n\treturn\n}", "func mustBigInt(v string) *big.Int {\n\tvar x big.Int\n\tif err := x.UnmarshalText([]byte(v)); err != nil {\n\t\tpanic(err)\n\t}\n\treturn &x\n}", "func NewBigInt(v string, base int) *big.Int {\n b := big.NewInt(0)\n b.SetString(v, base)\n return b\n}", "func chunkIDAsBigInt(chunkID string) (*big.Int, error) {\n\tif chunkID == \"\" {\n\t\t// \"\" indicates start of table. This is one before\n\t\t// ID 00000 .... 00000.\n\t\treturn big.NewInt(-1), nil\n\t}\n\tidBytes, err := hex.DecodeString(chunkID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tid := big.NewInt(0)\n\tid.SetBytes(idBytes)\n\treturn id, nil\n}", "func decodeBigInt(s *Stream, val reflect.Value) error {\n\t// get the content of the string\n\tb, err := s.Bytes()\n\tif err != nil {\n\t\treturn wrapStreamError(err, val.Type())\n\t}\n\n\t// assign i to *big.Int type (its' original type instead of the reflect.val type)\n\ti := val.Interface().(*big.Int)\n\n\t// this means the storage prepared to store the data has some flaws, it pointed nil\n\t// therefore, we need to fix this storage, and make this storage be able to store the data\n\tif i == nil {\n\t\t// allocated space and let i pointed to it\n\t\ti = new(big.Int)\n\t\t// pass the address pointed by i (ValuOf(i)) to val (data synchronization)\n\t\tval.Set(reflect.ValueOf(i))\n\t}\n\n\t// no leading 0s\n\tif len(b) > 0 && b[0] == 0 {\n\t\treturn wrapStreamError(ErrCanonInt, val.Type())\n\t}\n\n\t// assigning values\n\ti.SetBytes(b)\n\treturn nil\n}", "func lettersToBigInt(seq alphabet.Letters) (*big.Int, error) {\n\tout := big.NewInt(0)\n\twords := make([]big.Word, len(seq)/33+1)\n\tfor i := range seq {\n\t\tindex := alphabet.DNA.IndexOf(seq[len(seq)-i-1])\n\t\tif index < 0 {\n\t\t\treturn out, fmt.Errorf(\"Sequence is not a valid DNA sequence at position %d\\n\", i+1)\n\t\t} else {\n\t\t\twordIndex := i / 32\n\t\t\tshiftDist := uint(i-wordIndex*32) * 2\n\t\t\twords[wordIndex] |= big.Word(index << shiftDist)\n\t\t}\n\t}\n\treturn out.SetBits(words), nil\n}", "func toInt(str string) (int64, error) {\n\tres, err := strconv.ParseInt(str, 0, 64)\n\tif err != nil {\n\t\tres = 0\n\t}\n\treturn res, err\n}", "func ToInt(x string) *big.Int {\n\tvar i big.Int\n\ti.SetBytes([]byte(x[:]))\n\treturn &i\n}", "func (b64) FromBigInt(b *big.Int, size int) string {\n\tdata := b.Bytes()\n\tif size > 0 {\n\t\tdata = bytesPadding(data, size)\n\t}\n\n\treturn base64.RawURLEncoding.EncodeToString(data)\n}", "func Txt2int(s string) uint64 {\n\tx := uint64(len(s)) * Prime\n\tfor i := len(s) - 1; i >= 0; i-- {\n\t\tx ^= uint64(s[i])\n\t\tx *= Prime\n\t}\n\treturn x\n}", "func (t TokenID) BigInt() *big.Int {\n\treturn utils.ByteSliceToBigInt(t[:])\n}", "func DecodeBig(input string) (*big.Int, error) {\n\traw, err := checkNumber(input)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(raw) > 64 {\n\t\treturn nil, ErrBig256Range\n\t}\n\twords := make([]big.Word, len(raw)/bigWordNibbles+1)\n\tend := len(raw)\n\tfor i := range words {\n\t\tstart := end - bigWordNibbles\n\t\tif start < 0 {\n\t\t\tstart = 0\n\t\t}\n\t\tfor ri := start; ri < end; ri++ {\n\t\t\tnib := decodeNibble(raw[ri])\n\t\t\tif nib == badNibble {\n\t\t\t\treturn nil, ErrSyntax\n\t\t\t}\n\t\t\twords[i] *= 16\n\t\t\twords[i] += big.Word(nib)\n\t\t}\n\t\tend = start\n\t}\n\tdec := new(big.Int).SetBits(words)\n\treturn dec, nil\n}", "func StringToInt(s string) (int64, error) {\n\treturn strconv.ParseInt(s, 10, 64)\n}", "func (z *Element22) ToBigInt(res *big.Int) *big.Int {\n\tbits := (*[22]big.Word)(unsafe.Pointer(z))\n\treturn res.SetBits(bits[:])\n}", "func base64ToInt(s string) *big.Int {\n\tvar tmp big.Int\n\tsb := []byte(s)\n\tfor i := len(sb) - 1; i >= 0; i-- {\n\t\tb := big.NewInt(base64de[sb[i]])\n\t\ttmp.Lsh(&tmp, 6).Or(&tmp, b)\n\t}\n\treturn &tmp\n}", "func IntSetString(z *big.Int, s string, base int) (*big.Int, bool)", "func Hex(s string) Integer { return integer{x: bigint.MustHex(s)} }", "func IntString(x *big.Int,) string", "func byteArrayToBigInt(bytes []byte) *big.Int {\n\ttotalPower := big.NewInt(1)\n\tpower := big.NewInt(256)\n\tbigInt := big.NewInt(0)\n\tfor _, value := range bytes {\n\t\tbigValue := big.NewInt(int64(value))\n\t\tbigInt.Add(bigInt, bigValue.Mul(totalPower, bigValue))\n\t\ttotalPower.Mul(totalPower, power)\n\t}\n\treturn bigInt\n}", "func ByteToBigInt(in []byte) *big.Int {\n\tout := new(big.Int)\n\tout.SetBytes(in)\n\treturn out\n}", "func NewIntFromString(s string) *big.Int {\n\tv, ok := new(big.Int).SetString(s, 10) //nolint:gomnd\n\tif !ok {\n\t\tpanic(fmt.Sprintf(\"Bad base 10 string %s\", s))\n\t}\n\treturn v\n}", "func MustParseBigInt(str string) *cells.BinaryCell {\n\tc, err := ParseBigInt(str)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn c\n}", "func IntText(x *big.Int, base int) string", "func AddBigInt(a, b string) (*big.Int, error) {\n\taInt, bInt, err := DecodeTwoBigInts(a, b)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn aInt.Add(aInt, bInt), nil\n}", "func (n *Node) SetBigInt(x *big.Int)", "func main() {\r\n\t\r\n//\tn, _ := new(big.Int).SetString(\"16329805957987392833\", 10)\r\n//\tfmt.Println(n)\r\n\r\n\tstrs := []string{ \"0\", \"15\", \"53\", \"193\", \"456\", \"46340\", \"4200000000\",\r\n\t\t\t\t\t\t\t\"12345678901234567\", \"1111111111111\", \"9223372036854775807\", \"18446744073709551615\",\r\n\t\t\t\t\t\t\t\"1844674407370955161518446744073709551615\",\r\n\t\t\t\t\t\t\t\"999999999999999999999999999999999999999\",\r\n\t\t\t\t\t\t\t\"340282366920938463426481119284349108225\", \t\t// 18446744073709551615 * 18446744073709551615 => 340282366920938463426481119284349108225\r\n\t\t\t\t\t\t\t };\r\n\r\n\tfor _, v := range strs {\r\n\t bigInt := &big.Int{}\r\n\t value, _ := bigInt.SetString(v, 10)\r\n\t sqrt := bigInt.Sqrt( value )\r\n\t fmt.Println( v, \" : sqrt( \", v , \") = \", sqrt)\r\n\t}\r\n\r\n\r\n}", "func HashString(elt string) *big.Int {\n\thasher := sha1.New()\n\thasher.Write([]byte(elt))\n\treturn new(big.Int).SetBytes(hasher.Sum(nil))\n}", "func (d Decimal) BigInt() *big.Int {\n\tscaledD := d.rescale(0)\n\ti := &big.Int{}\n\ti.SetString(scaledD.String(), 10)\n\treturn i\n}", "func atoi(s string) int64 {\n\tsCopy := s\n\tif sCopy[0] == '-' {\n\t\tsCopy = s[1:]\n\t}\n\n\tres := 0\n\tfor _, myrune := range sCopy {\n\t\tres = res*10 + (int(myrune) - 48)\n\t}\n\n\tif s[0] == '-' {\n\t\tres = res * -1\n\t}\n\n\tvar result int64\n\tresult = int64(res)\n\n\treturn result\n}", "func str2dec(what string) uint64 {\n\twhat = strings.TrimLeft(what, \"0\")\n\tif len(what) == 0 {\n\t\treturn 0\n\t}\n\tout, err := strconv.ParseUint(what, 10, 64)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\treturn out\n}", "func StringToTokenValue(input string, decimals uint8) (*big.Int, error) {\n\toutput := big.NewInt(0)\n\tif input == \"\" {\n\t\treturn output, nil\n\t}\n\n\t// Count the number of items after the decimal point.\n\tparts := strings.Split(input, \".\")\n\tvar additionalZeros int\n\tif len(parts) == 2 {\n\t\t// There is a decimal place.\n\t\tadditionalZeros = int(decimals) - len(parts[1])\n\t} else {\n\t\t// There is not a decimal place.\n\t\tadditionalZeros = int(decimals)\n\t}\n\t// Remove the decimal point.\n\ttmp := strings.ReplaceAll(input, \".\", \"\")\n\t// Add zeros to ensure that there are an appropriate number of decimals.\n\ttmp += strings.Repeat(\"0\", additionalZeros)\n\n\t// Set the output\n\toutput.SetString(tmp, 10)\n\n\treturn output, nil\n}", "func SetString(z *big.Int, s string, base int) (*big.Int, bool) {\n\treturn z.SetString(s, base)\n}", "func ProtoToBigInt(pb *BigInt, bi *big.Int) error {\n\tif pb == nil {\n\t\treturn errors.New(\"nil proto big_int\")\n\t}\n\tbi.SetBytes(pb.Raw)\n\treturn nil\n}", "func ParseInteger(s string) (Number, error) {\n\tif res, ok := new(big.Int).SetString(s, 0); ok {\n\t\tif res.IsInt64() {\n\t\t\treturn Integer(res.Int64()), nil\n\t\t}\n\t\treturn (*BigInt)(res), nil\n\t}\n\treturn nil, fmt.Errorf(ErrExpectedInteger, s)\n}", "func atoi(b []byte) (int, error) {\n\tif len(b) > len(powers) {\n\t\treturn 0, fmt.Errorf(\"sam: integer overflow: %q\", b)\n\t}\n\tvar n int64\n\tk := len(b) - 1\n\tfor i, v := range b {\n\t\tn += int64(v-'0') * powers[k-i]\n\t\tif int64(int(n)) != n {\n\t\t\treturn 0, fmt.Errorf(\"sam: integer overflow: %q at %d\", b, i)\n\t\t}\n\t}\n\treturn int(n), nil\n}", "func parseEthereumBig256(s string) (*big.Int, bool) {\n\tif s == \"\" {\n\t\treturn new(big.Int), true\n\t}\n\tvar bigint *big.Int\n\tvar ok bool\n\tif len(s) >= 2 && (s[:2] == \"0x\" || s[:2] == \"0X\") {\n\t\tbigint, ok = new(big.Int).SetString(s[2:], 16)\n\t} else {\n\t\tbigint, ok = new(big.Int).SetString(s, 10)\n\t}\n\tif ok && bigint.BitLen() > 256 {\n\t\tbigint, ok = nil, false\n\t}\n\treturn bigint, ok\n}", "func ReadBigInt(r io.Reader) (*big.Int, error) {\n\td, err := ReadBytes(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn new(big.Int).SetBytes(d), nil\n}", "func parseInt64FromString(content string, aggErr *AggregateError) int64 {\n result, err := strconv.ParseInt(content, 10, 64)\n if err != nil {\n aggErr.Append(err)\n }\n return result\n}", "func ConvertToDec(numS string, fromBase int) (string, error) {\n\tif fromBase < 2 {\n\t\treturn \"\", fmt.Errorf(\"Invalid base: %v\", fromBase)\n\t}\n\tif numS == \"\" {\n\t\treturn \"\", fmt.Errorf(\"Nothing to convert\")\n\t}\n\n\t// If the number is negative: flagNeg = 1 and \"saving\" the negative sign.\n\tnum := []rune(numS)\n\tif num[0] == rune('-') {\n\t\tflagNeg = 1\n\t\tnum = append(num[1:])\n\t}\n\t// After removing \"-\" we have to check our number again.\n\tif len(num) == 0 {\n\t\treturn \"\", fmt.Errorf(\"Nothing to convert\")\n\t}\n\t// Converting the number to decimal base using math/big library in order to get\n\t// numbers bigger than int64.\n\tbDecNum := big.NewInt(0)\n\tiFromEnd := len(num) - 1\n\tfor _, vRune := range num {\n\t\tvInt, err := letterToNum(vRune, fromBase)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tbVint := big.NewInt(int64(vInt))\n\t\tbFromBase := big.NewInt(int64(fromBase))\n\t\tbIfromEnd := big.NewInt(int64(iFromEnd))\n\t\tbPow := big.NewInt(0)\n\t\tmod := big.NewInt(0)\n\t\tbRight := big.NewInt(0)\n\t\tbDecNum.Add(bDecNum, bRight.Mul(bPow.Exp(bFromBase, bIfromEnd, mod), bVint))\n\t\tiFromEnd--\n\t}\n\tif flagNeg == 1 {\n\t\t// If original number was negative - making new one negative too.\n\t\tbDecNum.Neg(bDecNum)\n\t}\n\n\treturn bDecNum.String(), nil\n}", "func BigIntToHexStr(i *big.Int) string {\n\th := i.Text(16)\n\tif len(h)%2 == 1 {\n\t\th = \"0\" + h // make sure that the length is even\n\t}\n\treturn \"0x\" + h\n}", "func stringToInt(s string) (int64, NumberType) {\n\tn, f, tp := StringToNumber(s)\n\tswitch tp {\n\tcase IsInt:\n\t\treturn n, IsInt\n\tcase IsFloat:\n\t\treturn FloatToInt(f)\n\t}\n\treturn 0, NaN\n}", "func String2Int(shortURL string) (seq uint64) {\n\tshortURL = reverse(shortURL)\n\tfor index, char := range shortURL {\n\t\tbase := uint64(math.Pow(float64(BaseStringLength), float64(index)))\n\t\tseq += uint64(strings.Index(BaseString, string(char))) * base\n\t}\n\treturn\n}", "func (d LegacyDec) BigInt() *big.Int {\n\tif d.IsNil() {\n\t\treturn nil\n\t}\n\n\tcp := new(big.Int)\n\treturn cp.Set(d.i)\n}", "func BigIntToProto(x *big.Int) *BigInt {\n\tif x == nil {\n\t\treturn nil\n\t}\n\tpb := new(BigInt)\n\tpb.Raw = x.Bytes()\n\treturn pb\n}", "func ToI(str string) int64 {\n\tval, err := strconv.ParseInt(str, 10, 64)\n\tL.IsError(err, str)\n\treturn val\n}", "func (z Element22) ToBigIntRegular(res *big.Int) *big.Int {\n\tz.FromMont()\n\tbits := (*[22]big.Word)(unsafe.Pointer(&z))\n\treturn res.SetBits(bits[:])\n}", "func ToInt(str string) (int64, error) {\n\tres, err := strconv.ParseInt(str, 0, 64)\n\tif err != nil {\n\t\tres = 0\n\t}\n\treturn res, err\n}", "func ToInt(str string) (int64, error) {\n\tres, err := strconv.ParseInt(str, 0, 64)\n\tif err != nil {\n\t\tres = 0\n\t}\n\treturn res, err\n}", "func SetBigInt(gauge prometheus.Gauge, arg *big.Int) {\n\tgauge.Set(float64(arg.Int64()))\n}", "func (z *Element22) SetBigInt(v *big.Int) *Element22 {\n\tz.SetZero()\n\n\tzero := big.NewInt(0)\n\tq := element22ModulusBigInt()\n\n\t// copy input\n\tvv := new(big.Int).Set(v)\n\n\t// while v < 0, v+=q\n\tfor vv.Cmp(zero) == -1 {\n\t\tvv.Add(vv, q)\n\t}\n\t// while v > q, v-=q\n\tfor vv.Cmp(q) == 1 {\n\t\tvv.Sub(vv, q)\n\t}\n\t// if v == q, return 0\n\tif vv.Cmp(q) == 0 {\n\t\treturn z\n\t}\n\t// v should\n\tvBits := vv.Bits()\n\tfor i := 0; i < len(vBits); i++ {\n\t\tz[i] = uint64(vBits[i])\n\t}\n\treturn z.ToMont()\n}", "func StringToInt64(str string) (i int64, err error) {\n\ti, err = strconv.ParseInt(str, 10, 64)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn i, nil\n}", "func strToInt64Point(s string) (int64, error) {\n\treturn strconv.ParseInt(s, 10, 64)\n}", "func MaxBigInt(a, b *big.Int) *big.Int {\n\tif a.Cmp(b) > 0 {\n\t\treturn a\n\t}\n\treturn b\n}", "func stringToInt64(s string) (int64, error) {\n\tvar v int64\n\tif strings.Contains(s, \".\") {\n\t\tfv, err := strconv.ParseFloat(s, 64)\n\t\tif err != nil {\n\t\t\treturn v, err\n\t\t}\n\t\tv = int64(fv)\n\t} else {\n\t\tiv, err := strconv.ParseInt(s, 10, 64)\n\t\tif err != nil {\n\t\t\treturn v, err\n\t\t}\n\t\tv = iv\n\t}\n\treturn v, nil\n}", "func hashString(x string) uint64 {\n\thash := offset64\n\tfor _, codepoint := range x {\n\t\thash ^= uint64(codepoint)\n\t\thash *= prime64\n\t}\n\treturn hash\n}", "func StringToInt64(s string) int64 {\n\ti, _ := strconv.ParseInt(s, 10, 64)\n\treturn i\n}", "func asciiToNumber(c byte) (uint8, error) {\n\tif c < one || c > nine {\n\t\treturn uint8(c), ErrParseInvalidNumber\n\t}\n\treturn uint8(c) - zero, nil\n}", "func StringToHashID(str string) (string, error) {\n\th, err := newHashID()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Convert string to []int\n\tvar ss []int\n\tfor _, v := range str {\n\t\tss = append(ss, int(v))\n\t}\n\n\t// Encode\n\te, err := h.Encode(ss)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn e, nil\n}", "func TestLipmaaDecompositionWithBigInteger(t *testing.T) {\n\tbigInt, _ := new(big.Int).SetString(\"16714772973240639959372252262788596420406994288943442724185217359247384753656472309049760952976644136858333233015922583099687128195321947212684779063190875332970679291085543110146729439665070418750765330192961290161474133279960593149307037455272278582955789954847238104228800942225108143276152223829168166008095539967222363070565697796008563529948374781419181195126018918350805639881625937503224895840081959848677868603567824611344898153185576740445411565094067875133968946677861528581074542082733743513314354002186235230287355796577107626422168586230066573268163712626444511811717579062108697723640288393001520781671\", 10)\n\troots, _ := lipmaaDecompose(bigInt)\n\tif squareRootsAndSum(roots).Cmp(bigInt) != 0 {\n\t\tt.Errorf(\"decomposition does not work correctly for a large integer\")\n\t}\n\n}", "func StrintToInt64(s string) int64 {\n\ti, err := strconv.ParseInt(s, 10, 64)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn i\n}", "func parseInt(s string, base int) (Value, error) {\n\tvar n int64\n\tvar err error\n\tvar cutoff, maxVal int64\n\tvar sign bool\n\ti := 0\n\n\tif len(s) < 1 {\n\t\terr = strconv.ErrSyntax\n\t\tgoto Error\n\t}\n\n\tswitch s[0] {\n\tcase '-':\n\t\tsign = true\n\t\ts = s[1:]\n\tcase '+':\n\t\ts = s[1:]\n\t}\n\n\tif len(s) < 1 {\n\t\terr = strconv.ErrSyntax\n\t\tgoto Error\n\t}\n\n\t// Look for hex prefix.\n\tif s[0] == '0' && len(s) > 1 && (s[1] == 'x' || s[1] == 'X') {\n\t\tif base == 0 || base == 16 {\n\t\t\tbase = 16\n\t\t\ts = s[2:]\n\t\t}\n\t}\n\n\tswitch {\n\tcase len(s) < 1:\n\t\terr = strconv.ErrSyntax\n\t\tgoto Error\n\n\tcase 2 <= base && base <= 36:\n\t// valid base; nothing to do\n\n\tcase base == 0:\n\t\t// Look for hex prefix.\n\t\tswitch {\n\t\tcase s[0] == '0' && len(s) > 1 && (s[1] == 'x' || s[1] == 'X'):\n\t\t\tif len(s) < 3 {\n\t\t\t\terr = strconv.ErrSyntax\n\t\t\t\tgoto Error\n\t\t\t}\n\t\t\tbase = 16\n\t\t\ts = s[2:]\n\t\tdefault:\n\t\t\tbase = 10\n\t\t}\n\n\tdefault:\n\t\terr = errors.New(\"invalid base \" + strconv.Itoa(base))\n\t\tgoto Error\n\t}\n\n\t// Cutoff is the smallest number such that cutoff*base > maxInt64.\n\t// Use compile-time constants for common cases.\n\tswitch base {\n\tcase 10:\n\t\tcutoff = math.MaxInt64/10 + 1\n\tcase 16:\n\t\tcutoff = math.MaxInt64/16 + 1\n\tdefault:\n\t\tcutoff = math.MaxInt64/int64(base) + 1\n\t}\n\n\tmaxVal = math.MaxInt64\n\tfor ; i < len(s); i++ {\n\t\tif n >= cutoff {\n\t\t\t// n*base overflows\n\t\t\treturn parseLargeInt(float64(n), s[i:], base, sign)\n\t\t}\n\t\tv := digitVal(s[i])\n\t\tif v >= base {\n\t\t\tbreak\n\t\t}\n\t\tn *= int64(base)\n\n\t\tn1 := n + int64(v)\n\t\tif n1 < n || n1 > maxVal {\n\t\t\t// n+v overflows\n\t\t\treturn parseLargeInt(float64(n)+float64(v), s[i+1:], base, sign)\n\t\t}\n\t\tn = n1\n\t}\n\n\tif i == 0 {\n\t\terr = strconv.ErrSyntax\n\t\tgoto Error\n\t}\n\n\tif sign {\n\t\tn = -n\n\t}\n\treturn intToValue(n), nil\n\nError:\n\treturn _NaN, err\n}", "func (l *BigInt) String() string {\n\treturn (*big.Int)(l).String()\n}", "func dtoi(s string) (n int, i int, ok bool) {\n\tn = 0\n\tfor i = 0; i < len(s) && '0' <= s[i] && s[i] <= '9'; i++ {\n\t\tn = n*10 + int(s[i]-'0')\n\t\tif n >= bigInt {\n\t\t\treturn bigInt, i, false\n\t\t}\n\t}\n\tif i == 0 {\n\t\treturn 0, 0, false\n\t}\n\treturn n, i, true\n}", "func BigIntToB64(i *big.Int) string {\n\tb := BigBytes(i)\n\tbuff := make([]byte, base64.StdEncoding.EncodedLen(len(b)))\n\tbase64.StdEncoding.Encode(buff, b)\n\treturn string(buff)\n}", "func ConvertSizeToBytes(s string) (string, error) {\n\ts = strings.TrimSpace(strings.ToLower(s))\n\n\t// spin until we find a match, if no match return original string\n\tfor _, k := range units {\n\t\tvar y int = lookupTable[k]\n\t\tif strings.HasSuffix(s, k) {\n\t\t\ts = s[:len(s)-len(k)]\n\t\t\ti, err := strconv.Atoi(s)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\ti = i * Pow(1024, y)\n\t\t\ts = strconv.Itoa(i)\n\t\t\treturn s, nil\n\t\t}\n\t}\n\n\treturn s, nil\n}", "func (s VerbatimString) ToInt64() (int64, error) { return _verbatimString(s).ToInt64() }", "func BigNumStrToHex(s string) string {\n\tbignum := ethutil.Big(s)\n\tbignum_bytes := ethutil.BigToBytes(bignum, 16)\n\treturn ethutil.Bytes2Hex(bignum_bytes)\n}", "func StringToSuperint(s string) Superint {\n\tvar si Superint\n\t//TODO add validation later\n\tif s[0] == '-' {\n\t\tsi.negative = true\n\t\ts = s[1:]\n\t}\n\t// \"12345\" would be stored as [5, 4, 3, 2, 1]\n\tfor i := len(s) - 1; i >= 0; i-- {\n\t\tnextDigit, _ := strconv.Atoi(string(s[i]))\n\t\tsi.digits = append(si.digits, nextDigit)\n\t}\n\treturn si\n}", "func FloatIntStr(valInt string) (out *big.Float, err error) {\n\ti, err := DecodeBigInt(valInt)\n\tif err != nil {\n\t\treturn\n\t}\n\tout, err = FloatInt(i)\n\treturn\n}", "func SplitBigIntToChars(num *big.Int) []string {\n\treturn strings.Split(num.String(), \"\")\n}", "func ParseStringToInt(str string) (int, error) {\n\ti64, err := strconv.ParseInt(str, 10, 0)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn int(i64), nil\n}", "func ConvertFromDec(numS string, toBase int) (string, error) {\n\tif toBase < 2 {\n\t\treturn \"\", fmt.Errorf(\"Invalid base: %v\", toBase)\n\t}\n\tif numS == \"\" {\n\t\treturn \"\", fmt.Errorf(\"Nothing to convert\")\n\t}\n\t// Converting string to the number bigger than int64.\n\tbNum := big.NewInt(0)\n\tbNum, ok := bNum.SetString(numS, 10)\n\tif ok != true {\n\t\treturn \"\", fmt.Errorf(\"Invalid number: %v\", numS)\n\t}\n\tbZero := big.NewInt(0)\n\t// If original number is equal to \"0...0\".\n\tif bNum.Cmp(bZero) == 0 {\n\t\treturn \"0\", nil\n\t}\n\t// If the number is negativ: flagNeg = 1 and \"saving\" the negative sign.\n\tif bNum.Cmp(bZero) == -1 {\n\t\tflagNeg = 1\n\t\tbNum.Neg(bNum)\n\t}\n\t// Converting the number to needed base (toBase).\n\tvar newNum string\n\tbToBase := big.NewInt(int64(toBase))\n\tbReminder := big.NewInt(0)\n\tfor bNum.Cmp(bZero) != 0 {\n\t\tbNum.DivMod(bNum, bToBase, bReminder)\n\t\treminderHex := numToLetter(bReminder.Int64(), toBase)\n\t\tnewNum += reminderHex\n\t}\n\n\tif flagNeg != 0 {\n\t\t// If original number was negative - making new one negative too.\n\t\tnewNum += \"-\"\n\t\tflagNeg = 0\n\t}\n\t// Reversing the number.\n\tnumRunes := []rune(newNum)\n\tleft := 0\n\tright := len(numRunes) - 1\n\tfor left < len(numRunes)/2 {\n\t\tnumRunes[left], numRunes[right] = numRunes[right], numRunes[left]\n\t\tleft++\n\t\tright--\n\t}\n\n\treturn string(numRunes), nil\n}", "func (t *Table) BigInt(colNm string) *Table {\n\tt.columns = append(t.columns, &column{Name: colNm, ColumnType: TypeBigInt})\n\treturn t\n}", "func StringToUint(s string) (uint64, error) {\n\treturn strconv.ParseUint(s, 10, 64)\n}", "func ToCodepoint(s string) (int64, error) {\n\ts = strings.ToUpper(s)\n\tvar base = 16\n\tswitch {\n\tcase strings.HasPrefix(s, \"0X\"), strings.HasPrefix(s, \"U+\"):\n\t\ts = s[2:]\n\tcase strings.HasPrefix(s, \"U\"):\n\t\ts = s[1:]\n\tcase strings.HasPrefix(s, \"0O\"):\n\t\ts = s[2:]\n\t\tbase = 8\n\tcase strings.HasPrefix(s, \"0B\"):\n\t\ts = s[2:]\n\t\tbase = 2\n\t}\n\treturn strconv.ParseInt(s, base, 64)\n}", "func toBase(bi *big.Int, destBase []string) string {\n\t// Hack in order to \"clone\" the big.Int and avoid changing it.\n\tsrc := big.NewInt(0)\n\tsrc.Add(bi, big.NewInt(0))\n\n\tif big.NewInt(0).Cmp(src) == 0 {\n\t\treturn destBase[0]\n\t}\n\n\tvar digits []string\n\tnumericBase := big.NewInt(int64(len(destBase)))\n\n\t// Keep going while bi is greater than 0.\n\tfor src.Cmp(big.NewInt(0)) > 0 {\n\t\tremainder := big.NewInt(0).Rem(src, numericBase)\n\t\tsrc.Div(src, numericBase)\n\t\tdigits = append(digits, destBase[remainder.Int64()])\n\t}\n\n\treturn strings.Join(digits, \" \")\n}", "func FromInterface(i1 interface{}) big.Int {\n\tvar val big.Int\n\n\tswitch c1 := i1.(type) {\n\tcase big.Int:\n\t\tval.Set(&c1)\n\tcase *big.Int:\n\t\tval.Set(c1)\n\tcase uint64:\n\t\tval.SetUint64(c1)\n\tcase int:\n\t\tval.SetInt64(int64(c1))\n\tcase string:\n\t\tif _, ok := val.SetString(c1, 10); !ok {\n\t\t\tpanic(\"unable to set big.Int from base10 string\")\n\t\t}\n\tcase []byte:\n\t\tval.SetBytes(c1)\n\tdefault:\n\t\tif v, ok := i1.(toBigIntInterface); ok {\n\t\t\tv.ToBigIntRegular(&val)\n\t\t\treturn val\n\t\t} else if reflect.ValueOf(i1).Kind() == reflect.Ptr {\n\t\t\tvv := reflect.ValueOf(i1).Elem()\n\t\t\tif vv.CanInterface() {\n\t\t\t\tif v, ok := vv.Interface().(toBigIntInterface); ok {\n\t\t\t\t\tv.ToBigIntRegular(&val)\n\t\t\t\t\treturn val\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tpanic(\"unsupported type\")\n\t}\n\n\treturn val\n}", "func Int(s string) int {\n\tif s == \"\" {\n\t\treturn 0\n\t}\n\n\tresult, err := strconv.ParseInt(s, 10, 64)\n\n\tif err != nil {\n\t\treturn 0\n\t}\n\n\treturn int(result)\n}", "func HexStrToInt64(hexString string) (int64, error) {\n\tif !strings.HasPrefix(hexString, \"0x\") {\n\t\thexString = \"0x\" + hexString\n\t}\n\treturn strconv.ParseInt(hexString, 0, 64)\n}", "func StringAsInteger(s string) int {\n\tif s == \"\" {\n\t\treturn 0\n\t}\n\n\tif i, err := strconv.ParseInt(s, 10, 32); err == nil {\n\t\treturn int(i)\n\t}\n\n\treturn 0\n}", "func parseInt(b []byte, t reflect.Type) (int64, []byte, error) {\n\tvar value int64\n\tvar count int\n\n\tif len(b) == 0 {\n\t\treturn 0, b, syntaxError(b, \"cannot decode integer from an empty input\")\n\t}\n\n\tif b[0] == '-' {\n\t\tconst max = math.MinInt64\n\t\tconst lim = max / 10\n\n\t\tif len(b) == 1 {\n\t\t\treturn 0, b, syntaxError(b, \"cannot decode integer from '-'\")\n\t\t}\n\n\t\tif len(b) > 2 && b[1] == '0' && '0' <= b[2] && b[2] <= '9' {\n\t\t\treturn 0, b, syntaxError(b, \"invalid leading character '0' in integer\")\n\t\t}\n\n\t\tfor _, d := range b[1:] {\n\t\t\tif !(d >= '0' && d <= '9') {\n\t\t\t\tif count == 0 {\n\t\t\t\t\tb, err := inputError(b, t)\n\t\t\t\t\treturn 0, b, err\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif value < lim {\n\t\t\t\treturn 0, b, unmarshalOverflow(b, t)\n\t\t\t}\n\n\t\t\tvalue *= 10\n\t\t\tx := int64(d - '0')\n\n\t\t\tif value < (max + x) {\n\t\t\t\treturn 0, b, unmarshalOverflow(b, t)\n\t\t\t}\n\n\t\t\tvalue -= x\n\t\t\tcount++\n\t\t}\n\n\t\tcount++\n\t} else {\n\t\tconst max = math.MaxInt64\n\t\tconst lim = max / 10\n\n\t\tif len(b) > 1 && b[0] == '0' && '0' <= b[1] && b[1] <= '9' {\n\t\t\treturn 0, b, syntaxError(b, \"invalid leading character '0' in integer\")\n\t\t}\n\n\t\tfor _, d := range b {\n\t\t\tif !(d >= '0' && d <= '9') {\n\t\t\t\tif count == 0 {\n\t\t\t\t\tb, err := inputError(b, t)\n\t\t\t\t\treturn 0, b, err\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tx := int64(d - '0')\n\n\t\t\tif value > lim {\n\t\t\t\treturn 0, b, unmarshalOverflow(b, t)\n\t\t\t}\n\n\t\t\tif value *= 10; value > (max - x) {\n\t\t\t\treturn 0, b, unmarshalOverflow(b, t)\n\t\t\t}\n\n\t\t\tvalue += x\n\t\t\tcount++\n\t\t}\n\t}\n\n\tif count < len(b) {\n\t\tswitch b[count] {\n\t\tcase '.', 'e', 'E': // was this actually a float?\n\t\t\tv, r, err := parseNumber(b)\n\t\t\tif err != nil {\n\t\t\t\tv, r = b[:count+1], b[count+1:]\n\t\t\t}\n\t\t\treturn 0, r, unmarshalTypeError(v, t)\n\t\t}\n\t}\n\n\treturn value, b[count:], nil\n}", "func StrToInt64(s string) int64 {\n\treturn int64(StrToInt(s))\n}", "func decodeToBigLE(src []byte) big.Int {\n\tn := len(src)\n\ttt := make([]byte, n)\n\tfor i := 0; i < n; i ++ {\n\t\ttt[i] = src[n - 1 - i]\n\t}\n\tvar x big.Int\n\tx.SetBytes(tt)\n\treturn x\n}", "func String2Int(v string) int {\n\treturn int(String2Int64(v))\n}", "func (z *Element22) SetString(s string) *Element22 {\n\tx, ok := new(big.Int).SetString(s, 10)\n\tif !ok {\n\t\tpanic(\"Element22.SetString failed -> can't parse number in base10 into a big.Int\")\n\t}\n\treturn z.SetBigInt(x)\n}", "func parseInt64(content []byte, aggErr *AggregateError) int64 {\n result, err := strconv.ParseInt(string(content), 10, 64)\n if err != nil {\n aggErr.Append(err)\n }\n return result\n}", "func hashString(text string) int64 {\n\thasher := fnv.New64()\n\thasher.Write([]byte(text))\n\tvalue := int64(hasher.Sum64())\n\t// Flip the sign if we wrapped\n\tif value < 0 {\n\t\treturn -value\n\t}\n\treturn value\n}", "func StringToHash(s string) int {\n\tv := int(crc32.ChecksumIEEE([]byte(s)))\n\tif v >= 0 {\n\t\treturn v\n\t}\n\tif -v >= 0 {\n\t\treturn -v\n\t}\n\t// v == MinInt\n\treturn 0\n}", "func parseIntEx(s string, bitSize int) (int64, error) {\n\tif s[0:2] == \"0b\" {\n\t\treturn strconv.ParseInt(s[2:], 2, bitSize)\n\t} else {\n\t\treturn strconv.ParseInt(s, 0, bitSize)\n\t}\n}", "func strToInt(input string) int {\n\toutput, _ := strconv.Atoi(input)\n\treturn output\n}", "func ConvertStringToInt(str string) int {\n\ts, err := strconv.Atoi(str)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn s\n}", "func StringToInteger(s string) (r int) {\n\tr, err := strconv.Atoi(s)\n\tif err != nil {\n\t\tlog.Fatal(\"ERROR: Invalid data type! Please use an integer instead of a string. Exiting!\\n\\n\")\n\t}\n\treturn r\n}", "func String2Int64(v string) int64 {\n\ti, err := strconv.ParseInt(v, 10, 64)\n\tif err != nil {\n\t\t// Log conversion error\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"string\": v,\n\t\t\t\"error\": err.Error(),\n\t\t}).Warn(\"Error converting string to int64\")\n\n\t\treturn 0\n\t}\n\n\treturn i\n}" ]
[ "0.8503275", "0.8007486", "0.7599278", "0.74680173", "0.74680173", "0.73421395", "0.70222", "0.6859304", "0.68342394", "0.6643473", "0.6609426", "0.6585258", "0.6492842", "0.63858724", "0.6366537", "0.63351583", "0.631695", "0.6280062", "0.62524414", "0.6239087", "0.6191838", "0.6183829", "0.6172", "0.6140018", "0.6129758", "0.61147565", "0.60841566", "0.60381263", "0.6008889", "0.5995458", "0.5953314", "0.5913333", "0.5842075", "0.5825297", "0.5805031", "0.5783098", "0.57770115", "0.57747436", "0.5766547", "0.5729747", "0.5689134", "0.56739086", "0.56576693", "0.5651874", "0.56484884", "0.56146324", "0.56138724", "0.5603463", "0.56016946", "0.55855817", "0.55754566", "0.55749583", "0.55706525", "0.55561525", "0.55561525", "0.5517805", "0.55085194", "0.5496422", "0.54901713", "0.5477559", "0.5468399", "0.546378", "0.5459693", "0.54415613", "0.54383665", "0.54225695", "0.5421711", "0.541823", "0.5417489", "0.541675", "0.5412852", "0.54041797", "0.5403946", "0.5402474", "0.5389868", "0.53876793", "0.53819954", "0.5376196", "0.5369262", "0.5367784", "0.5359723", "0.5347965", "0.533819", "0.5337022", "0.53360385", "0.5332845", "0.5331582", "0.5322452", "0.53211886", "0.5320343", "0.53182405", "0.53137726", "0.53125757", "0.531059", "0.5306465", "0.5302368", "0.52936673", "0.5289738", "0.52811134", "0.52772725" ]
0.8299093
1
NewStorageReader creates a new instance of StorageReader
NewStorageReader создает новый экземпляр StorageReader
func NewStorageReader(accountName, accountKey, containerName string) (*StorageReader, error) { logp.Debug( "storage_reader", "Creating new instance of storage reader", ) c := &Config{ accountName: accountName, accountKey: accountKey, containerName: containerName, } sr := &StorageReader{ config: c, } err := sr.initialize() if err != nil { return nil, err } return sr, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func StorageReader(storage StorageAPI, volume, path string, offset int64) io.Reader {\n\treturn &storageReader{storage, volume, path, offset}\n}", "func newStorage() *storage {\n\tr := make(map[string][]byte)\n\treturn &storage{\n\t\trepository: r,\n\t}\n}", "func NewReader(r io.Reader) io.Reader {\n return reader{r}\n}", "func NewRawStorage(config *storagebackend.ConfigForResource, newFunc func() runtime.Object) (storage.Interface, factory.DestroyFunc, error) {\n\treturn factory.Create(*config, newFunc)\n}", "func NewReader() Reader {\n\treturn reader{}\n}", "func (s *StandAloneStorage) Reader(ctx *kvrpcpb.Context) (storage.StorageReader, error) {\n\treturn &standAloneStorageReader{txn: s.db.NewTransaction(false)}, nil\n}", "func NewStorage(namespace, name string) (*Storage, error) {\n\tif err := k8sutil.CreateCRD(name); err != nil {\n\t\treturn nil, err\n\t}\n\tcli := k8sutil.NewRESTClient()\n\treturn &Storage{\n\t\tNamespace: namespace,\n\t\tName: strings.ToLower(name),\n\t\trestcli: cli,\n\t}, nil\n}", "func newStorage(account *account, prov provider.Account, cfg *config.Storage) (*storage, error) {\n\tlog.Debug(\"Initializing Storage\")\n\n\t// Validate the config.Storage object.\n\tif cfg.Buckets == nil {\n\t\treturn nil, fmt.Errorf(\"The buckets element is missing from the storage configuration\")\n\t}\n\n\ts := &storage{\n\t\tResources: resource.NewResources(),\n\t\tStorage: cfg,\n\t\taccount: account,\n\t}\n\n\tvar err error\n\ts.providerStorage, err = prov.NewStorage(cfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ts.buckets, err = newBuckets(s, prov, cfg.Buckets)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ts.Append(s.buckets)\n\treturn s, nil\n}", "func NewStorage() (*Storage, error) {\n\tvar err error\n\n\ts := new(Storage)\n\n\t_, filename, _, _ := runtime.Caller(0)\n\tp := path.Dir(filename)\n\n\ts.db, err = scribble.New(p+dir, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn s, nil\n}", "func NewStorageReadClient(c datatypes.Storage_ReadClient) *StorageReadClient {\n\treturn &StorageReadClient{c: c}\n}", "func newStorageObject(URL string, source interface{}, fileInfo os.FileInfo) storage.Object {\n\tabstract := storage.NewAbstractStorageObject(URL, source, fileInfo)\n\tresult := &object{\n\t\tAbstractObject: abstract,\n\t}\n\tresult.AbstractObject.Object = result\n\treturn result\n}", "func newStorage() *storage {\n\treturn &storage{\n\t\tsto: make(map[uint16]mqtt.Message),\n\t\tmux: new(sync.RWMutex),\n\t}\n}", "func (lm *SimpleManager) NewReader(r io.Reader) *Reader {\n\tlr := NewReader(r)\n\tlm.Manage(lr)\n\treturn lr\n}", "func NewStorage() Storage {\n\treturn &storage{}\n}", "func NewReader(r io.Reader) *Reader { return &Reader{r: r} }", "func NewStorage(l log.Logger, reg prometheus.Registerer, stCallback startTimeCallback, walDir string, flushDeadline time.Duration, sm ReadyScrapeManager) *Storage {\n\tif l == nil {\n\t\tl = log.NewNopLogger()\n\t}\n\tlogger := logging.Dedupe(l, 1*time.Minute)\n\n\ts := &Storage{\n\t\tlogger: logger,\n\t\tlocalStartTimeCallback: stCallback,\n\t}\n\ts.rws = NewWriteStorage(s.logger, reg, walDir, flushDeadline, sm)\n\treturn s\n}", "func NewStorage() *Storage {\r\n\treturn new(Storage)\r\n}", "func NewStorage(config StorageConfig) (spec.Storage, error) {\n\tnewStorage := &storage{\n\t\tStorageConfig: config,\n\n\t\tID: id.MustNew(),\n\t\tShutdownOnce: sync.Once{},\n\t\tType: ObjectType,\n\t}\n\n\t// Dependencies.\n\tif newStorage.Log == nil {\n\t\treturn nil, maskAnyf(invalidConfigError, \"logger must not be empty\")\n\t}\n\tif newStorage.Pool == nil {\n\t\treturn nil, maskAnyf(invalidConfigError, \"connection pool must not be empty\")\n\t}\n\t// Settings.\n\tif newStorage.BackOffFactory == nil {\n\t\treturn nil, maskAnyf(invalidConfigError, \"backoff factory must not be empty\")\n\t}\n\tif newStorage.Prefix == \"\" {\n\t\treturn nil, maskAnyf(invalidConfigError, \"prefix must not be empty\")\n\t}\n\n\tnewStorage.Log.Register(newStorage.GetType())\n\n\treturn newStorage, nil\n}", "func NewStorage(cfg *api.Config, rootPath string, syncFrequency time.Duration) (storage.Interface, error) {\n\tcfg.WaitTime = syncFrequency\n\n\t// Get a new client\n\tclient, err := api.NewClient(cfg)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"creating consul client\")\n\t}\n\n\treturn &Client{\n\t\tv1: &v1client{\n\t\t\tupstreams: &upstreamsClient{\n\t\t\t\tbase: base.NewConsulStorageClient(rootPath+\"/upstreams\", client),\n\t\t\t},\n\t\t\tvirtualHosts: &virtualHostsClient{\n\t\t\t\tbase: base.NewConsulStorageClient(rootPath+\"/virtualhosts\", client),\n\t\t\t},\n\t\t},\n\t}, nil\n}", "func NewStorage(cfg *Config) *Storage {\n\tif cfg.Engine == nil {\n\t\tlog.Fatalln(\"Cannot create a ops proxy without an engine\")\n\t}\n\tif cfg.App == nil {\n\t\tnrConfig := newrelic.NewConfig(\"widget\", \"\")\n\t\tnrConfig.Enabled = false\n\t\tapp, err := newrelic.NewApplication(nrConfig)\n\t\tif err != nil {\n\t\t\tlogrus.WithField(\"error\", err).Fatalln(\"could not create dummy new relic app\")\n\t\t}\n\t\tcfg.App = app\n\t}\n\treturn &Storage{engine: cfg.Engine, newrelic: cfg.App}\n}", "func NewStorage(lgr *log.Logger) *Storage {\n\treturn &Storage{\n\t\tdataStack: graph.NewStack(),\n\t\tdataStorage: NewKVStorage(),\n\t\tlgr: lgr,\n\t}\n}", "func NewStorage() (*Storage, error) {\n\tvar err error\n\ts := new(Storage)\n\tcwd, _ := os.Getwd()\n\ts.db, err = scribble.New(cwd+viper.GetString(\"storage.basedir\"), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn s, nil\n}", "func NewStorage() *Storage {\n\treturn &Storage{}\n}", "func NewStorage(t mockConstructorTestingTNewStorage) *Storage {\n\tmock := &Storage{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func NewStorage(t mockConstructorTestingTNewStorage) *Storage {\n\tmock := &Storage{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func NewStorage(client *clientv3.Client, codec codec.Codec) storage.Store {\n\treturn &Storage{\n\t\tclient: client,\n\t\tcodec: codec,\n\t}\n}", "func NewStorage(opts ...StorageOption) *Storage {\n\ts := &Storage{\n\t\tcr: config.DefaultManager,\n\t\tmu: sync.RWMutex{},\n\t}\n\tfor _, opt := range opts {\n\t\tif opt != nil {\n\t\t\topt(s)\n\t\t}\n\t}\n\treturn s\n}", "func New(path string) (Storage, error) {\n\tif path == \":memory:\" {\n\t\treturn newMemoryStorage(), nil\n\t}\n\n\treturn newFileStorage(path)\n}", "func NewReader(dev *Device, readerName string) *Reader {\n\tr := &Reader{\n\t\tdev: dev,\n\t\treaderName: readerName,\n\t}\n\treturn r\n}", "func NewStorage(mds MetadataStore, tr track.Tracker, chunks *chunk.Storage, opts ...StorageOption) *Storage {\n\ts := &Storage{\n\t\tstore: mds,\n\t\ttracker: tr,\n\t\tchunks: chunks,\n\t\tidxCache: index.NewCache(chunks, DefaultIndexCacheSize),\n\t\tmemThreshold: DefaultMemoryThreshold,\n\t\tshardConfig: &index.ShardConfig{\n\t\t\tNumFiles: index.DefaultShardNumThreshold,\n\t\t\tSizeBytes: index.DefaultShardSizeThreshold,\n\t\t},\n\t\tcompactionConfig: &CompactionConfig{\n\t\t\tLevelFactor: DefaultCompactionLevelFactor,\n\t\t},\n\t\tfilesetSem: semaphore.NewWeighted(math.MaxInt64),\n\t\tprefetchLimit: DefaultPrefetchLimit,\n\t}\n\tfor _, opt := range opts {\n\t\topt(s)\n\t}\n\tif s.compactionConfig.LevelFactor < 1 {\n\t\tpanic(\"level factor cannot be < 1\")\n\t}\n\treturn s\n}", "func NewStorage() *Storage {\n\tstorageHandler = new(Storage)\n\n\treturn storageHandler\n}", "func FakeNewStorage() *fakeStorage {\n\treturn &fakeStorage{}\n}", "func newFileFromReader(upload *Upload, name string, reader io.Reader) *File {\n\treturn newFileFromReadCloser(upload, name, io.NopCloser(reader))\n}", "func NewStorage(first, second storage.Storage) (*Storage, error) {\n\treturn &Storage{first, second}, nil\n}", "func NewReader(store EntryStore) Reader {\n\treturn defaultReader{\n\t\tstore: store,\n\t}\n}", "func New(timeout time.Duration) (*Storage, error) {\n\tif timeout <= 0 {\n\t\treturn nil, errors.New(\"timeout must be positive\")\n\t}\n\treturn &Storage{\n\t\tdata: make(map[string]interface{}),\n\t\tcancelFuncs: make(map[string]context.CancelFunc),\n\t\ttimeout: timeout,\n\t}, nil\n}", "func New(o *Options) *Storage {\n\ts := &Storage{}\n\tif o.GraphiteAddress != \"\" {\n\t\tc := graphite.NewClient(\n\t\t\to.GraphiteAddress, o.GraphiteTransport,\n\t\t\to.StorageTimeout, o.GraphitePrefix)\n\t\ts.queues = append(s.queues, NewStorageQueueManager(c, defaultConfig))\n\t}\n\tif o.OpentsdbURL != \"\" {\n\t\tc := opentsdb.NewClient(o.OpentsdbURL, o.StorageTimeout)\n\t\ts.queues = append(s.queues, NewStorageQueueManager(c, defaultConfig))\n\t}\n\tif o.InfluxdbURL != nil {\n\t\tconf := influx.Config{\n\t\t\tURL: *o.InfluxdbURL,\n\t\t\tUsername: o.InfluxdbUsername,\n\t\t\tPassword: o.InfluxdbPassword,\n\t\t\tTimeout: o.StorageTimeout,\n\t\t}\n\t\tc := influxdb.NewClient(conf, o.InfluxdbDatabase, o.InfluxdbRetentionPolicy)\n\t\tprometheus.MustRegister(c)\n\t\ts.queues = append(s.queues, NewStorageQueueManager(c, defaultConfig))\n\t}\n\tif o.GenericURL != \"\" {\n\t\theaders := http.Header{}\n\t\tif o.GenericHeaderName != \"\" {\n\t\t\theaders.Add(o.GenericHeaderName, o.GenericHeaderValue)\n\t\t}\n\t\tc := generic.NewClient(o.GenericURL, headers, o.StorageTimeout)\n\t\ts.queues = append(s.queues, NewStorageQueueManager(c, defaultConfig))\n\t}\n\tif len(s.queues) == 0 {\n\t\treturn nil\n\t}\n\treturn s\n}", "func New(configs ...Configurator) (*Storage, error) {\n\tinstance := &Storage{}\n\tfor _, configure := range configs {\n\t\tif err := configure(instance); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn instance, nil\n}", "func New(ctx context.Context, storageConfig *config.StorageConfig) *Storage {\n\tctx, cancel := context.WithCancel(ctx)\n\treturn &Storage{\n\t\tctx: ctx,\n\t\tconfig: storageConfig,\n\t\tcancel: cancel,\n\t\tstate: Created,\n\t\tlog: logger.GetLogger(),\n\t}\n}", "func NewReader(r io.Reader, rd int) (*Reader, error) {\n\tbg, err := bgzf.NewReader(r, rd)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\th, _ := sam.NewHeader(nil, nil)\n\tbr := &Reader{\n\t\tr: bg,\n\t\th: h,\n\n\t\treferences: int32(len(h.Refs())),\n\t}\n\terr = br.h.DecodeBinary(br.r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbr.lastChunk.End = br.r.LastChunk().End\n\treturn br, nil\n}", "func NewStorage(path string) (*Storage, error) {\n\tdb, err := bolt.Open(path, 0600, nil)\n\tif err != nil {\n\t\treturn nil, common.Error(common.InitFailed, err)\n\t}\n\tstore := &Storage{db}\n\treturn store, nil\n}", "func NewReader(sourceKey, filepath, dbFilename string) *Reader {\n\treturn &Reader{\n\t\tSourceKey: sourceKey,\n\t\tPath: filepath,\n\t\tFilename: dbFilename,\n\t}\n}", "func (s *MockQueueService) NewReader(topic string) queue.Reader {\n\treturn &mockReader{\n\t\tService: s,\n\t\tTopic: topic,\n\t}\n}", "func NewReader() Reader {\n\treturn &readerImpl{}\n}", "func NewStorage(size int, hash HashFunc) *Storage {\n\ts := &Storage{n: size, h: hash}\n\ts.Reset()\n\treturn s\n}", "func NewReader(r io.Reader) *Reader {\n\treturn &Reader{\n\t\tMaxObjectsLimit: DefaultMaxObjectsLimit,\n\n\t\tr: &trackingReader{r: r},\n\t\toffsets: make(map[int64]core.Hash, 0),\n\t}\n}", "func NewStorage(db *sql.DB) *Storage {\n\treturn &Storage{db}\n}", "func NewStorage(cat *repository.MongoCatalog, cache *rediscache.Redis) *Storage {\n\treturn &Storage{\n\t\tcat,\n\t\tcache,\n\t}\n}", "func NewStorage(typ string) (*Storage, error) {\n\tswitch typ {\n\tcase \"\", \"postgres\":\n\t\tpostgresStore, err := NewPostgresStorage()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tinst := Storage(postgresStore)\n\t\treturn &inst, nil\n\tcase \"inmem\":\n\t\tinst := Storage(new(InMemStorage))\n\t\treturn &inst, nil\n\tdefault:\n\t\treturn nil, errors.New(\"Invalid storage type provided.\")\n\t}\n}", "func NewStorage() (s *Storage, err error) {\n\ts = new(Storage)\n\n\terr = s.initDB()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tc := make(chan time.Time, 10)\n\ts.C = c\n\ts.c = c\n\n\treturn\n}", "func NewMockReaderStorage(ctrl *gomock.Controller) *MockReaderStorage {\n\tmock := &MockReaderStorage{ctrl: ctrl}\n\tmock.recorder = &MockReaderStorageMockRecorder{mock}\n\treturn mock\n}", "func New(ioReader io.Reader) (r KafkalogReader, err error) {\n\tr = &reader{\n\t\tioReader: ioReader,\n\t}\n\treturn\n}", "func New(config *config.ConfYaml) *Storage {\n\treturn &Storage{\n\t\tconfig: config,\n\t}\n}", "func NewReader(path string) (*Reader, error) {\n\tvar err error\n\tr := new(Reader)\n\n\tr.v, err = ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn r, nil\n}", "func New() *Storage {\n\treturn &Storage{\n\t\tstat: &statApp{},\n\t}\n}", "func (c *S3StorageConfig) NewStorage() (Storage, error) {\n\treturn NewS3Storage(c, nil)\n}", "func NewStorage() Storage {\n\tmemtable := memtable.NewRollingMemtable()\n\n\tstorage := Storage{memtable: memtable, wal: wal.Wal{Memtable: &memtable}}\n\tstorage.wal.Start()\n\treturn storage\n}", "func NewReader(r UnderlyingReader) Reader {\n\treturn Reader{\n\t\trequest: r,\n\t}\n}", "func newFileFromReadCloser(upload *Upload, name string, reader io.ReadCloser) *File {\n\tfile := &File{}\n\tfile.upload = upload\n\tfile.Name = name\n\tfile.reader = reader\n\treturn file\n}", "func newStorageLayer(disk string) (storage StorageAPI, err error) {\n\tif !strings.ContainsRune(disk, ':') || filepath.VolumeName(disk) != \"\" {\n\t\t// Initialize filesystem storage API.\n\t\treturn newPosix(disk)\n\t}\n\t// Initialize rpc client storage API.\n\treturn newRPCClient(disk)\n}", "func newTestModel() *Storage {\n\treturn &Storage{}\n}", "func NewStorage(vol string) *Storage {\n\tloc := vol\n\n\tif vol[len(vol)-1:] != \"/\" {\n\t\tloc = fmt.Sprintf(\"%s/\", vol)\n\t}\n\n\treturn &Storage{\n\t\tloc,\n\t}\n}", "func New(ctx context.Context, bucket string) (fs.Interface, error) {\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &gcs{\n\t\tbucket: client.Bucket(bucket),\n\t}, nil\n}", "func NewReader(ctx context.Context, client pb.RoutedJournalClient, req pb.ReadRequest) *Reader {\n\tvar r = &Reader{\n\t\tRequest: req,\n\t\tctx: ctx,\n\t\tclient: client,\n\t}\n\treturn r\n}", "func NewReader(clients []drive.Client, t *time.Ticker) (*Reader, error) {\n\tc := &Reader{\n\t\tclients: clients,\n\t\tnodes: map[string]Node{\n\t\t\t\"/\": {\n\t\t\t\tFilename: \"/\",\n\t\t\t\tChildren: make(map[string]bool),\n\t\t\t}},\n\t}\n\tif err := c.refresh(); err != nil {\n\t\treturn nil, fmt.Errorf(\"initializing cache: %s\", err)\n\t}\n\tgo c.periodicRefresh(t)\n\treturn c, nil\n}", "func NewStorage() *Storage {\n\treturn &Storage{\n\t\tkv: btree.NewKVTree(),\n\t}\n}", "func NewReader(r io.Reader) *Reader {\n\treturn s2.NewReader(r, s2.ReaderMaxBlockSize(maxBlockSize))\n}", "func newOfferStorage() *offerStorage {\n\treturn &offerStorage{\n\t\tcidMap: make(map[string]*digestOffer),\n\t\tlock: sync.RWMutex{},\n\t}\n}", "func (r *Reference) NewReader(ctx context.Context, path iosrc.URI, readspan nano.Span) (*Reader, error) {\n\tsegspan := r.Span()\n\tspan := segspan.Intersect(readspan)\n\tobjectPath := r.RowObjectPath(path)\n\tif span.Dur == 0 {\n\t\treturn nil, fmt.Errorf(\"segment reader: segment does not intersect provided span: %s chunkspan %v readspan %v\", path, segspan, readspan)\n\t}\n\treader, err := iosrc.NewReader(ctx, objectPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsr := &Reader{\n\t\tReader: reader,\n\t\tCloser: reader,\n\t\tTotalBytes: r.Size,\n\t\tReadBytes: r.Size,\n\t}\n\tif span == segspan {\n\t\treturn sr, nil\n\t}\n\ts, err := seekindex.Open(ctx, r.SeekObjectPath(path))\n\tif err != nil {\n\t\tif zqe.IsNotFound(err) {\n\t\t\treturn sr, nil\n\t\t}\n\t\treturn nil, err\n\t}\n\tdefer s.Close()\n\trg, err := s.Lookup(ctx, span)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trg = rg.TrimEnd(sr.TotalBytes)\n\tsr.ReadBytes = rg.Size()\n\tsr.Reader, err = rg.LimitReader(reader)\n\treturn sr, err\n}", "func NewStorageAPI(g func(ctx context.Context) (*grpc.ClientConn, error)) *StorageAPI {\n\treturn &StorageAPI{g}\n}", "func newStorage(\n\tmachineName,\n\ttablename,\n\tdatabase,\n\tretentionPolicy,\n\tusername,\n\tpassword,\n\tinfluxdbHost string,\n\tisSecure bool,\n\tbufferDuration time.Duration,\n) (*influxdbStorage, error) {\n\turl := &url.URL{\n\t\tScheme: \"http\",\n\t\tHost: influxdbHost,\n\t}\n\tif isSecure {\n\t\turl.Scheme = \"https\"\n\t}\n\n\tconfig := &influxdb.Config{\n\t\tURL: *url,\n\t\tUsername: username,\n\t\tPassword: password,\n\t\tUserAgent: fmt.Sprintf(\"%v/%v\", \"cAdvisor\", version.Info[\"version\"]),\n\t}\n\tclient, err := influxdb.NewClient(*config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tret := &influxdbStorage{\n\t\tclient: client,\n\t\tmachineName: machineName,\n\t\tdatabase: database,\n\t\tretentionPolicy: retentionPolicy,\n\t\tbufferDuration: bufferDuration,\n\t\tlastWrite: time.Now(),\n\t\tpoints: make([]*influxdb.Point, 0),\n\t}\n\tret.readyToFlush = ret.defaultReadyToFlush\n\treturn ret, nil\n}", "func NewStorage(DBName string) *Storage {\n\ts := &Storage{}\n\tmutex.Lock()\n\tif db == nil {\n\t\ts.checkMakeDatabase(DBName)\n\t\tdb = s.db\n\t\tif chQueryArgs == nil {\n\t\t\tchQueryArgs = make(chan *queryArgs, 100)\n\t\t\tgo executeStatements()\n\t\t}\n\n\t\ts.setupTables()\n\t}\n\tmutex.Unlock()\n\treturn s\n}", "func NewStorage(db *gorm.DB) *Storage {\n\treturn &Storage{\n\t\tdb: db,\n\t}\n}", "func NewStorage(cfg *configuration.Storage, timeout time.Duration) (*Storage, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), timeout)\n\tdefer cancel()\n\n\tclient, err := mongo.Connect(ctx, options.Client().ApplyURI(cfg.URI))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"connect to mongo %s: %s\", cfg.URI, err)\n\t}\n\n\terr = client.Ping(ctx, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"ping mongo %s: %s\", cfg.URI, err)\n\t}\n\n\treturn &Storage{\n\t\tclient: client,\n\t\tcollection: client.Database(cfg.DBName).Collection(cfg.CollectionName),\n\t}, nil\n}", "func NewStorage(s map[string]interface{}) (Storage, error) {\n\tstype, ok := s[\"Type\"].(string)\n\tif !ok || stype == \"\" {\n\t\treturn nil, errors.New(\"Template do not have Storage type\")\n\t}\n\n\tswitch stype {\n\tcase \"Local\":\n\t\treturn newStorageLocal(s), nil\n\tcase \"S3\":\n\t\treturn newStorageS3(s)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Unexecepted Storage type: %v\", stype)\n\t}\n}", "func NewReader(rd io.Reader) *Reader {\n\treturn &Reader{rd: rd}\n}", "func NewReader(cfg Config, plannerCfg PlannerConfig) (*Reader, error) {\n\tplanner, err := NewPlanner(plannerCfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tscanner, err := storage.NewChunkScanner(cfg.StorageType, cfg.StorageConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tid := fmt.Sprintf(\"%d_%d\", plannerCfg.FirstShard, plannerCfg.LastShard)\n\n\t// Default to one worker if none is set\n\tif cfg.NumWorkers < 1 {\n\t\tcfg.NumWorkers = 1\n\t}\n\n\treturn &Reader{\n\t\tcfg: cfg,\n\t\tid: id,\n\t\tplanner: planner,\n\t\tscanner: scanner,\n\t\tscanRequestsChan: make(chan chunk.ScanRequest),\n\t\tquit: make(chan struct{}),\n\t}, nil\n}", "func newReader(filePath string) (*Reader, func(), error) {\n\tf, err := os.Open(filePath)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tfz, err := gzip.NewReader(f)\n\tif err != nil {\n\t\tf.Close()\n\t\treturn nil, nil, err\n\t}\n\n\tcleanup := func() {\n\t\tf.Close()\n\t\tfz.Close()\n\t}\n\treturn &Reader{r: fz}, cleanup, nil\n}", "func NewReader(r io.Reader) *Reader {\n\treturn &Reader{\n\t\tr: bufio.NewReader(r),\n\t\tcurrentSection: \"default\",\n\t}\n}", "func NewReader(s string) *Reader { return &Reader{s, 0, -1} }", "func makeStorage(name string) ds.Storage {\n\tswitch name {\n\tcase \"skiplist\":\n\t\treturn ds.NewSkipList()\n\tcase \"dict\":\n\t\treturn ds.NewDict()\n\tcase \"b-tree\":\n\t\treturn ds.InitBTree(10)\n\t}\n\treturn ds.NewDict()\n}", "func New(db *badger.DB) *Storage {\n\treturn &Storage{DB: db}\n}", "func NewReader(r io.ReaderAt, size int64) (*Reader, error) {\n\tszr := new(Reader)\n\tif err := szr.init(r, size, false); err != nil {\n\t\treturn nil, err\n\t}\n\treturn szr, nil\n}", "func NewReader(reader io.Reader) (*Reader, error) {\n\treturn NewReaderMode(reader, DefaultMode)\n}", "func NewStorage() SafeMap {\n\tsm := make(safeMap)\n\tgo sm.run()\n\treturn sm\n}", "func NewGenericStorage(rawStorage RawStorage, serializer serializer.Serializer) Storage {\n\treturn &GenericStorage{rawStorage, serializer, patchutil.NewPatcher(serializer)}\n}", "func New(r io.Reader) *Reader {\n\treturn &Reader{reader: r}\n}", "func newStorage(\n\tmachineName,\n\ttablename,\n\tdatabase,\n\tusername,\n\tpassword,\n\tinfluxdbHost string,\n\tisSecure bool,\n\tbufferDuration time.Duration,\n) (*influxdbStorage, error) {\n\tconfig := &influxdb.ClientConfig{\n\t\tHost: influxdbHost,\n\t\tUsername: username,\n\t\tPassword: password,\n\t\tDatabase: database,\n\t\tIsSecure: isSecure,\n\t}\n\tclient, err := influxdb.NewClient(config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// TODO(monnand): With go 1.3, we cannot compress data now.\n\tclient.DisableCompression()\n\n\tret := &influxdbStorage{\n\t\tclient: client,\n\t\tmachineName: machineName,\n\t\ttableName: tablename,\n\t\tbufferDuration: bufferDuration,\n\t\tlastWrite: time.Now(),\n\t\tseries: make([]*influxdb.Series, 0),\n\t}\n\tret.readyToFlush = ret.defaultReadyToFlush\n\treturn ret, nil\n}", "func NewStorage(address common.Address, backend bind.ContractBackend) (*Storage, error) {\n\tcontract, err := bindStorage(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Storage{StorageCaller: StorageCaller{contract: contract}, StorageTransactor: StorageTransactor{contract: contract}, StorageFilterer: StorageFilterer{contract: contract}}, nil\n}", "func NewStorage(address common.Address, backend bind.ContractBackend) (*Storage, error) {\n\tcontract, err := bindStorage(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Storage{StorageCaller: StorageCaller{contract: contract}, StorageTransactor: StorageTransactor{contract: contract}, StorageFilterer: StorageFilterer{contract: contract}}, nil\n}", "func NewStorage(address common.Address, backend bind.ContractBackend) (*Storage, error) {\n\tcontract, err := bindStorage(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Storage{StorageCaller: StorageCaller{contract: contract}, StorageTransactor: StorageTransactor{contract: contract}, StorageFilterer: StorageFilterer{contract: contract}}, nil\n}", "func New(b string) *Storage {\n\treturn &Storage{new(atomic.Value), []byte(b), new(sync.RWMutex)}\n}", "func New(b string) *Storage {\n\treturn &Storage{new(atomic.Value), []byte(b), new(sync.RWMutex)}\n}", "func NewReader(base io.Reader) *Reader {\n\tbr, ok := base.(byteReader)\n\tif !ok {\n\t\tbr = simpleByteReader{Reader: base}\n\t}\n\treturn &Reader{base: br}\n}", "func NewReader(r io.ReaderAt, size int64) (*File, error) {\n\tf, err := odf.NewReader(r, size)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn newFile(f)\n}", "func NewReader(r io.Reader) *Reader {\n\treturn NewReaderConfig(r, ReaderConfig{})\n\n}", "func NewReader(rd io.Reader) io.ReadCloser {\n\tif rd == nil {\n\t\treturn nil\n\t}\n\n\tret, err := NewReaderSize(rd, DefaultBuffers, DefaultBufferSize)\n\n\t// Should not be possible to trigger from other packages.\n\tif err != nil {\n\t\tpanic(\"unexpected error:\" + err.Error())\n\t}\n\treturn ret\n}", "func Open(backend Backend) (*Storage, error) {\n\ts := new(Storage)\n\ts.backend = backend\n\terr := s.readHeader()\n\tif err != nil {\n\t\tlog.Errorf(\"error reading storage header: %s\", err)\n\t\treturn nil, err\n\t}\n\treturn s, nil\n}", "func NewStorage() *Storage {\n\tConfig := util.NewConfig()\n\tses, err := mgo.Dial(string(Config.Mongo.Addr))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn &Storage{database: Config.Mongo.DB, table: Config.Mongo.Table, session: ses}\n}", "func newStorageImpl(db orm.DB) *storageImpl {\n\treturn &storageImpl{\n\t\tdb: db,\n\t}\n}" ]
[ "0.7486464", "0.6991443", "0.6769339", "0.6694343", "0.6630447", "0.6618453", "0.65807104", "0.65728444", "0.65710235", "0.6547296", "0.6508507", "0.6461586", "0.64510155", "0.6447975", "0.64442575", "0.643639", "0.64106154", "0.64028615", "0.64025176", "0.6393443", "0.63858974", "0.63664305", "0.63573116", "0.6268965", "0.6268965", "0.62672997", "0.6261094", "0.62588423", "0.62455034", "0.62413496", "0.6234098", "0.6219892", "0.62139815", "0.62067163", "0.62032855", "0.6193568", "0.619092", "0.6188907", "0.6151001", "0.61491066", "0.61483735", "0.6146575", "0.6143666", "0.6133681", "0.613246", "0.6127565", "0.6117868", "0.6116097", "0.6115075", "0.6087051", "0.60844755", "0.6077219", "0.6069329", "0.6059845", "0.6058852", "0.6040307", "0.6037868", "0.60370004", "0.6027065", "0.60243344", "0.60218644", "0.60163265", "0.6016274", "0.60111576", "0.60083246", "0.60046273", "0.60022444", "0.59985024", "0.5997143", "0.599365", "0.5992232", "0.59888196", "0.59869707", "0.59835976", "0.5976019", "0.5971808", "0.59702164", "0.5965017", "0.59582406", "0.5953995", "0.59468544", "0.59449583", "0.59434426", "0.59276044", "0.59089047", "0.5903224", "0.5901446", "0.5891993", "0.5889064", "0.5889064", "0.58883977", "0.58864605", "0.58864605", "0.5884565", "0.5881899", "0.5878274", "0.5862856", "0.5862103", "0.5860604", "0.5859196" ]
0.77779114
0
ListBlobsModifiedBetween Get list of blobs modified between two specified timestamps
ListBlobsModifiedBetween Получить список объектов, измененных между двумя указанными временными метками
func (sr *StorageReader) ListBlobsModifiedBetween(startTime, endTime int64) *[]BlobDetails { logp.Debug("storage_reader", "Listing blobs modified between %v and %v.", startTime, endTime) ctx := context.Background() var blobItems []BlobDetails i := 0 for marker := (azblob.Marker{}); marker.NotDone(); { listBlob, err := sr.container.ListBlobsFlatSegment(ctx, marker, azblob.ListBlobsSegmentOptions{}) marker = listBlob.NextMarker if err != nil { logp.Error(err) continue } for _, blobInfo := range listBlob.Segment.BlobItems { i++ lastModified := blobInfo.Properties.LastModified.UTC().Unix() if lastModified > startTime && lastModified < endTime { length := *blobInfo.Properties.ContentLength if length == int64(0) { continue } blobItems = append(blobItems, NewBlobDetails(blobInfo.Name, string(blobInfo.Properties.Etag), length, lastModified)) } } } logp.Info("Found %v blobs in container. Found %v blobs modified between %v and %v.", i, len(blobItems), startTime, endTime, ) return &blobItems }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (w *Wallet) ListSinceBlock(start, end, syncHeight int32) ([]btcjson.ListTransactionsResult, er.R) {\n\ttxList := []btcjson.ListTransactionsResult{}\n\terr := walletdb.View(w.db, func(tx walletdb.ReadTx) er.R {\n\t\ttxmgrNs := tx.ReadBucket(wtxmgrNamespaceKey)\n\n\t\trangeFn := func(details []wtxmgr.TxDetails) (bool, er.R) {\n\t\t\tfor _, detail := range details {\n\t\t\t\tjsonResults := listTransactions(tx, &detail,\n\t\t\t\t\tw.Manager, syncHeight, w.chainParams)\n\t\t\t\ttxList = append(txList, jsonResults...)\n\t\t\t}\n\t\t\treturn false, nil\n\t\t}\n\n\t\treturn w.TxStore.RangeTransactions(txmgrNs, start, end, rangeFn)\n\t})\n\treturn txList, err\n}", "func (bbcblr BlockBlobsCommitBlockListResponse) LastModified() time.Time {\n\ts := bbcblr.rawResponse.Header.Get(\"Last-Modified\")\n\tif s == \"\" {\n\t\treturn time.Time{}\n\t}\n\tt, err := time.Parse(time.RFC1123, s)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn t\n}", "func (a *App) ListBlobs(w http.ResponseWriter, r *http.Request) {\n\tresource := a.eventID\n\tblobs, err := a.Blob.List(resource)\n\tif err != nil {\n\t\trespondWithError(err, http.StatusNotFound, w)\n\t\treturn\n\t}\n\tw.Header().Set(types.ContentType, types.ContentTypeApplicationJSON)\n\terr = json.NewEncoder(w).Encode(blobs)\n\tif err != nil {\n\t\trespondWithError(err, http.StatusInternalServerError, w)\n\t\treturn\n\t}\n}", "func ReadTimestamps(bkt *bolt.Bucket, created, updated *time.Time) error {\n\tfor _, f := range []struct {\n\t\tb []byte\n\t\tt *time.Time\n\t}{\n\t\t{bucketKeyCreatedAt, created},\n\t\t{bucketKeyUpdatedAt, updated},\n\t} {\n\t\tv := bkt.Get(f.b)\n\t\tif v != nil {\n\t\t\tif err := f.t.UnmarshalBinary(v); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (b *BucketManager) ListFilesInTimeSlot(property string, ts string) ([]string, error) {\n\tsvc := s3.New(b.session)\n\tlogFiles := regexp.MustCompile(`([a-zA-Z0-9]+)\\.([0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2})\\.([a-z0-9]+)\\.gz`)\n\tresp, _ := svc.ListObjects(&s3.ListObjectsInput{\n\t\tBucket: &b.bucket,\n\t\tPrefix: aws.String(fmt.Sprintf(\"%s.%s.\", property, ts)),\n\t})\n\tif len(resp.Contents) == 0 {\n\t\treturn nil, errors.New(\"no log files matching the requested parameters in the bucket\")\n\t}\n\tvar files []string\n\tfor _, key := range resp.Contents {\n\t\tif logFiles.MatchString(*key.Key) {\n\t\t\tfiles = append(files, *key.Key)\n\t\t}\n\t}\n\treturn files, nil\n}", "func (ti *TimeIndex) Notify(blobs ...*blob.Blob) {\n ti.lock.Lock()\n defer ti.lock.Unlock()\n\n for _, b := range blobs {\n tp := b.Type()\n if tp == blob.NoType || tp == blob.Object {\n continue\n }\n\n t, err := b.Timestamp()\n if err != nil {\n continue\n }\n\n ti.entries = append(ti.entries, &timeEntry{tm: t, ref: b.Ref()})\n }\n}", "func (a *Account) ListSinceBlock(since, curBlockHeight int32,\n\tminconf int) ([]btcjson.ListTransactionsResult, error) {\n\n\ttxList := []btcjson.ListTransactionsResult{}\n\tfor _, txRecord := range a.TxStore.Records() {\n\t\t// Transaction records must only be considered if they occur\n\t\t// after the block height since.\n\t\tif since != -1 && txRecord.BlockHeight <= since {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Transactions that have not met minconf confirmations are to\n\t\t// be ignored.\n\t\tif !txRecord.Confirmed(minconf, curBlockHeight) {\n\t\t\tcontinue\n\t\t}\n\n\t\tjsonResults, err := txRecord.ToJSON(a.name, curBlockHeight,\n\t\t\ta.KeyStore.Net())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttxList = append(txList, jsonResults...)\n\t}\n\n\treturn txList, nil\n}", "func (a *Account) ListSinceBlock(since, curBlockHeight int32, minconf int) ([]map[string]interface{}, error) {\n\tvar txInfoList []map[string]interface{}\n\tfor _, txRecord := range a.TxStore.SortedRecords() {\n\t\t// check block number.\n\t\tif since != -1 && txRecord.Height() <= since {\n\t\t\tcontinue\n\t\t}\n\n\t\ttxInfoList = append(txInfoList,\n\t\t\ttxRecord.TxInfo(a.name, curBlockHeight, a.Net())...)\n\t}\n\n\treturn txInfoList, nil\n}", "func (am *AccountManager) ListSinceBlock(since, curBlockHeight int32,\n\tminconf int) ([]btcjson.ListTransactionsResult, error) {\n\n\t// Create and fill a map of account names and their balances.\n\tvar txList []btcjson.ListTransactionsResult\n\tfor _, a := range am.AllAccounts() {\n\t\ttxTmp, err := a.ListSinceBlock(since, curBlockHeight, minconf)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttxList = append(txList, txTmp...)\n\t}\n\treturn txList, nil\n}", "func (fmd *FakeMysqlDaemon) ReadBinlogFilesTimestamps(ctx context.Context, req *mysqlctlpb.ReadBinlogFilesTimestampsRequest) (*mysqlctlpb.ReadBinlogFilesTimestampsResponse, error) {\n\treturn nil, nil\n}", "func BlobTime(v interface{}) (t time.Time) {\n\tvar (\n\t\tf *os.File\n\t\tfn string\n\t\terr error\n\t\tok bool\n\t)\n\tif fn, ok = v.(string); ok {\n\t\tif f, err = os.Open(fn); err != nil {\n\t\t\treturn\n\t\t}\n\t\tdefer f.Close()\n\t} else if f, ok = v.(*os.File); !ok {\n\t\treturn\n\t}\n\tf.Seek(BlobTimeOff, os.SEEK_SET)\n\t(NBOReader{f}).ReadNBO(&t)\n\treturn\n}", "func BlobTime(v interface{}) (t time.Time) {\n\tvar (\n\t\tf *os.File\n\t\tfn string\n\t\terr error\n\t\tok bool\n\t)\n\tif fn, ok = v.(string); ok {\n\t\tif f, err = os.Open(fn); err != nil {\n\t\t\treturn\n\t\t}\n\t\tdefer f.Close()\n\t} else if f, ok = v.(*os.File); !ok {\n\t\treturn\n\t}\n\tf.Seek(BlobTimeOff, os.SEEK_SET)\n\t(NBOReader{f}).ReadNBO(&t)\n\treturn\n}", "func (t *Tag) LastModified() (lastModified time.Time) {\n\tfor _, history := range t.History {\n\t\tif history.Created.After(lastModified) {\n\t\t\tlastModified = history.Created\n\t\t}\n\t}\n\treturn lastModified\n}", "func getRecentlyModified(match []string, modified int, verbose bool) []string {\n\tvar matches []string // slice to hold the matching file paths\n\tvar paths []string // slice to hold the file paths\n\tvar modTimes []time.Time // slice to hold the modification times of the files\n\n\t// Loop through the provided slice of file names\n\tfor _, file := range match {\n\t\t// Get the file info and handle any errors\n\t\tinfo, err := os.Stat(file)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tcontinue\n\t\t}\n\t\t// Append the file path and modification time to the corresponding slices\n\t\tpaths = append(paths, file)\n\t\tmodTimes = append(modTimes, info.ModTime())\n\t}\n\n\t// Sort the slices by modification time\n\tsort.SliceStable(paths, func(i, j int) bool {\n\t\treturn modTimes[i].After(modTimes[j])\n\t})\n\n\t// Get the current time\n\tnow := time.Now()\n\n\t// Loop through the sorted slice of file paths\n\tfor i, path := range paths {\n\t\t// Check if the file was modified within the last modified hours\n\t\tif now.Sub(modTimes[i]) < (time.Duration(modified) * time.Hour) {\n\t\t\t// If it was, append the file path to the matches slice\n\t\t\tmatches = append(matches, path)\n\t\t} else {\n\t\t\tif verbose {\n\t\t\t\tlog.Printf(\"[IGNORING] Last modified time: %s older than configured timeframe (%d hours): %s.\", modTimes[i], modified, path)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return the slice of matching file paths\n\treturn matches\n}", "func SplitChangesFetchRaw(since int64) ([]byte, error) {\n\n\tvar bufferQuery bytes.Buffer\n\tbufferQuery.WriteString(\"/splitChanges\")\n\n\tif since >= -1 {\n\t\tbufferQuery.WriteString(\"?since=\")\n\t\tbufferQuery.WriteString(strconv.FormatInt(since, 10))\n\t}\n\n\tdata, err := sdkFetch(bufferQuery.String())\n\tif err != nil {\n\t\tlog.Error.Println(\"Error fetching split changes \", err)\n\t\treturn nil, err\n\t}\n\n\treturn data, nil\n}", "func (s *TaskService) ListWithLastModifiedDate(modifiedDate time.Time) ([]Task, *http.Response, error) {\n\tfilterDateType := \"DATE_TASK_MODIFIED\"\n\tfilterDateOperator := 3 // Is Later Than Or On\n\tmodifiedDateStr := modifiedDate.Format(\"2006-01-02\")\n\tresObj := new(TaskResponse)\n\tresp, err := s.sling.New().\n\t\tQueryStruct(CreateFunctionParam(\"gettasks\")).\n\t\tQueryStruct(&GetTasksParam{\n\t\t\tFilterFirstDate: &filterDateType,\n\t\t\tFilterFirstDateOperator: &filterDateOperator,\n\t\t\tFilterFirstDateValue: &modifiedDateStr,\n\t\t}).\n\t\tReceiveSuccess(resObj)\n\tif resObj != nil && len(resObj.Results) > 0 {\n\t\tif resObj.Results[0].ErrorDesc != nil {\n\t\t\treturn nil, resp, Error{*resObj.Results[0].ErrorDesc}\n\t\t}\n\t\treturn *(&resObj.Results), resp, err\n\t}\n\treturn make([]Task, 0), resp, err\n}", "func historyBetween(since string, until string) ([]gitobject.Commit, error) {\n\tall, err := history()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Filter the commits\n\tvar between []gitobject.Commit\n\tsawSince := false\n\tfor _, c := range all {\n\t\tif sawSince {\n\t\t\tbetween = append(between, c)\n\t\t}\n\n\t\tif c.Hash.String() == since {\n\t\t\tsawSince = true\n\t\t}\n\n\t\tif c.Hash.String() == until {\n\t\t\tbreak\n\t\t}\n\n\t}\n\n\treturn between, nil\n}", "func (db *pg) GetLogsBetweenInterval(ctx context.Context, start time.Time, end time.Time, userID string) ([]*Log, error) {\n\tconst stmt = `SELECT * FROM audit.\"Logs\" WHERE \"UserId\" = $1 AND \"Timestamp\" >= $2 AND \"Timestamp\" <= $3;`\n\trows, err := db.QueryContext(ctx, stmt, userID, start, end)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlst := make([]*Log, 0, 100)\n\tfor rows.Next() {\n\t\tl := Log{}\n\t\tif err := rows.Scan(&l.Timestamp, &l.UserID, &l.Action); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tlst = append(lst, &l)\n\t}\n\treturn lst, nil\n}", "func (pb PageBlobURL) GetPageRangesDiff(ctx context.Context, offset int64, count int64, prevSnapshot string, ac BlobAccessConditions) (*PageList, error) {\n\tifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()\n\treturn pb.pbClient.GetPageRangesDiff(ctx, nil, nil, &prevSnapshot,\n\t\tnil, // Get managed disk diff\n\t\thttpRange{offset: offset, count: count}.pointers(),\n\t\tac.LeaseAccessConditions.pointers(),\n\t\tifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,\n\t\tnil, // Blob ifTags\n\t\tnil)\n}", "func RecentBlockTargets(db *types.DB, size, length int) []string {\n\tif length == 0 {\n\t\tlength = db.Length\n\t}\n\n\tstart := length - size\n\tif start < 0 {\n\t\tstart = 0\n\t}\n\n\tvar ts []string\n\tfor index := start; index < length; index++ {\n\t\t// if not index in storage:\n\t\t// storage[index] = db_get(index, db)[\"target\"]\n\t\t_, ok := targets[index]\n\t\tif !ok {\n\t\t\ttargets[index] = db.GetBlock(index).Target\n\t\t}\n\n\t\tts = append(ts, targets[index])\n\t}\n\n\treturn ts\n}", "func (c *containerdCAS) ListBlobs() ([]string, error) {\n\tinfos, err := getContentInfoList()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"ListBlobs: Exception while getting blob list. %s\", err.Error())\n\t}\n\tblobDigests := make([]string, 0)\n\tfor _, info := range infos {\n\t\tblobDigests = append(blobDigests, info.Digest.String())\n\t}\n\treturn blobDigests, nil\n}", "func (sto *overlayStorage) StatBlobs(ctx context.Context, blobs []blob.Ref, f func(blob.SizedRef) error) error {\n\texists := make([]blob.Ref, 0, len(blobs))\n\tfor _, br := range blobs {\n\t\tif !sto.isDeleted(br) {\n\t\t\texists = append(exists, br)\n\t\t}\n\t}\n\n\tseen := make(map[blob.Ref]struct{}, len(exists))\n\n\terr := sto.upper.StatBlobs(ctx, exists, func(sbr blob.SizedRef) error {\n\t\tseen[sbr.Ref] = struct{}{}\n\t\treturn f(sbr)\n\t})\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlowerBlobs := make([]blob.Ref, 0, len(exists))\n\tfor _, br := range exists {\n\t\tif _, s := seen[br]; !s {\n\t\t\tlowerBlobs = append(lowerBlobs, br)\n\t\t}\n\t}\n\n\treturn sto.lower.StatBlobs(ctx, lowerBlobs, f)\n}", "func GetMessagesBetweenTimeStamps(context *gin.Context) {\n\trequest := context.Request\n\twriter := context.Writer\n\n\t// Check for required headers\n\ttoken, appID, isOK := auth.GetAuthData(request)\n\n\tif !isOK {\n\t\twriter.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t// Validate token\n\tidentity, isOK := auth.VerifyToken(token)\n\n\t// If not valid return\n\tif !isOK || !identity.CanUseAppID(appID) {\n\t\twriter.WriteHeader(http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\tchannelID := context.Params.ByName(\"channelID\")\n\n\tif channelID == \"\" {\n\t\twriter.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tfirstTimeStampStr := context.Params.ByName(\"firstTimeStamp\")\n\tsecondTimeStampStr := context.Params.ByName(\"secondTimeStamp\")\n\n\tif firstTimeStampStr == \"\" || secondTimeStampStr == \"\" {\n\t\twriter.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tfirstTimeStamp, err := strconv.ParseInt(firstTimeStampStr, 10, 64)\n\tsecondTimeStamp, err := strconv.ParseInt(secondTimeStampStr, 10, 64)\n\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"HTTP Get messages between timestamps: failed convert timestamp %v\\n\", err)\n\t}\n\n\t// Check if channel exists\n\texists, err := GetEngine().GetChannelRepository().ExistsAppChannel(appID, channelID)\n\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"HTTP Get messages between timestamps: failed to check app channel existence %v\\n\", err)\n\t\twriter.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif !exists {\n\t\twriter.WriteHeader(http.StatusNotFound)\n\t\treturn\n\t}\n\n\t// Get events\n\tevents, err := GetEngine().GetChannelRepository().GetChannelEventsAfterAndBefore(appID, channelID, firstTimeStamp, secondTimeStamp)\n\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"HTTP Get messages between timestamps: failed fetch events %v\\n\", err)\n\t\twriter.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Prepare response\n\tresponse := getChannelEventsResponse{Events: events}\n\n\tvar json = jsoniter.ConfigCompatibleWithStandardLibrary\n\tdata, err := json.Marshal(response)\n\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"HTTP Get messages since timestamp: failed to marshal response %v\\n\", err)\n\t\twriter.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\twriter.WriteHeader(http.StatusOK)\n\twriter.Write(data)\n}", "func bookChanged(timestamps1, timestamps2 []float64) bool {\n\tfor i := 0; i < 40; i++ {\n\t\tif math.Abs(timestamps1[i]-timestamps2[i]) > .5 {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (dao *DAOName) GetUpdatedAfter(timestamp time.Time) ([]ReferenceModel, error) {\n\tm := []ReferenceModel{}\n\tif err := dao.db.Where(\"updated_at > ?\", timestamp).Find(&m).Error; err != nil {\n\t\treturn nil, err\n\t}\n\treturn m, nil\n}", "func (tl *TombstonesLoader) GetPendingTombstonesForInterval(userID string, from, to model.Time) (*TombstonesSet, error) {\n\tallTombstones, err := tl.GetPendingTombstones(userID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !allTombstones.HasTombstonesForInterval(from, to) {\n\t\treturn &TombstonesSet{}, nil\n\t}\n\n\tfilteredSet := TombstonesSet{oldestTombstoneStart: model.Now()}\n\n\tfor _, tombstone := range allTombstones.tombstones {\n\t\tif !intervalsOverlap(model.Interval{Start: from, End: to}, model.Interval{Start: tombstone.StartTime, End: tombstone.EndTime}) {\n\t\t\tcontinue\n\t\t}\n\n\t\tfilteredSet.tombstones = append(filteredSet.tombstones, tombstone)\n\n\t\tif tombstone.StartTime < filteredSet.oldestTombstoneStart {\n\t\t\tfilteredSet.oldestTombstoneStart = tombstone.StartTime\n\t\t}\n\n\t\tif tombstone.EndTime > filteredSet.newestTombstoneEnd {\n\t\t\tfilteredSet.newestTombstoneEnd = tombstone.EndTime\n\t\t}\n\t}\n\n\treturn &filteredSet, nil\n}", "func (c *doubleCacheItem[T]) ListAfter(ts uint64) []T {\n\tc.mut.RLock()\n\tdefer c.mut.RUnlock()\n\tidx := sort.Search(len(c.data), func(idx int) bool {\n\t\treturn c.data[idx].Timestamp() >= ts\n\t})\n\t// not found\n\tif idx == len(c.data) {\n\t\treturn nil\n\t}\n\treturn c.data[idx:]\n}", "func (i *IndexBuilder) listModifiedChartDirs(c *git.Commit, tree *git.Tree) ([]string, error) {\n\tmodified, err := i.g.ModifiedFiles(c, tree)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trelativeDir := i.relativeDir()\n\tchartDirs := []string{}\n\tfor _, entry := range modified {\n\t\tabsEntryPath := fmt.Sprintf(\"/%s\", entry)\n\t\tif !strings.HasPrefix(absEntryPath, relativeDir) {\n\t\t\tcontinue\n\t\t}\n\n\t\tchartRelativePath := strings.TrimPrefix(absEntryPath, relativeDir)\n\t\tpathElements := strings.Split(chartRelativePath, string(os.PathSeparator))\n\t\tif len(pathElements) <= 1 {\n\t\t\tcontinue\n\t\t}\n\n\t\tchartRootDir := pathElements[0]\n\t\tif !ContainsStringSlice(chartDirs, chartRootDir) {\n\t\t\tchartDirs = append(chartDirs, pathElements[0])\n\t\t}\n\t}\n\treturn chartDirs, nil\n}", "func (p *Bucket) Ls() (m map[time.Time]string, err error) {\n\tresp, err := p.service.ListObjectsV2(&s3.ListObjectsV2Input{\n\t\tBucket: aws.String(p.name),\n\t\tPrefix: aws.String(p.path),\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tm = make(map[time.Time]string)\n\tfor _, item := range resp.Contents {\n\t\tm[*item.LastModified] = *item.Key\n\t}\n\treturn\n}", "func (p *commentsPlugin) saveTimestamps(token []byte, ts map[uint32]comments.CommentTimestamp) error {\n\t// Setup the blob entries\n\tblobs := make(map[string][]byte, len(ts))\n\tkeys := make([]string, 0, len(ts))\n\tfor cid, v := range ts {\n\t\tk, err := getTimestampKey(token, cid)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tb, err := json.Marshal(v)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tblobs[k] = b\n\t\tkeys = append(keys, k)\n\t}\n\n\t// Delete exisiting digests\n\terr := p.tstore.CacheDel(keys)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Save the blob entries\n\treturn p.tstore.CachePut(blobs, false)\n}", "func (ar *accountRepository) RetrieveTransferredTokensInBlockAfter(\n\taccountId int64,\n\tconsensusTimestamp int64,\n) ([]types.Token, *rTypes.Error) {\n\ttokens := make([]pTypes.Token, 0)\n\tif err := ar.dbClient.Raw(\n\t\tselectTransferredTokensInBlockAfterTimestamp,\n\t\tsql.Named(\"account_id\", accountId),\n\t\tsql.Named(\"consensus_timestamp\", consensusTimestamp),\n\t).Scan(&tokens).Error; err != nil {\n\t\tlog.Errorf(databaseErrorFormat, hErrors.ErrDatabaseError.Message, err)\n\t\treturn nil, hErrors.ErrDatabaseError\n\t}\n\n\treturn getDomainTokens(tokens)\n}", "func (c *Client) ListChangedBlocks(ctx context.Context, params *ListChangedBlocksInput, optFns ...func(*Options)) (*ListChangedBlocksOutput, error) {\n\tif params == nil {\n\t\tparams = &ListChangedBlocksInput{}\n\t}\n\n\tresult, metadata, err := c.invokeOperation(ctx, \"ListChangedBlocks\", params, optFns, addOperationListChangedBlocksMiddlewares)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tout := result.(*ListChangedBlocksOutput)\n\tout.ResultMetadata = metadata\n\treturn out, nil\n}", "func FilterUnchanged(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {\n\tfiles := p.Get(\"files\", []string{}).([]string)\n\tsince := p.Get(\"since\", time.Now().Add(time.Second * -10)).(time.Time)\n\n\tmodified := []string{}\n\tfor _, file := range files {\n\t\tstat, err := os.Stat(file)\n\t\tif err == nil && stat.ModTime().After(since) {\n\t\t\tmodified = append(modified, file)\n\t\t}\n\t}\n\n\treturn modified, nil\n}", "func fetchChanges(c context.Context, b *buildbot.Build) error {\n\tmemcache.Set(c, buildRevCache(c, b))\n\n\t// initialize the slice so that when serialized to JSON, it is [], not null.\n\tb.Sourcestamp.Changes = []buildbot.Change{}\n\n\thost, project, err := gitiles.ParseRepoURL(b.Sourcestamp.Repository)\n\tif err != nil {\n\t\tlogging.Warningf(\n\t\t\tc,\n\t\t\t\"build %q does not have a valid Gitiles repository URL, %q. Skipping blamelist computation\",\n\t\t\tb.ID(), b.Sourcestamp.Repository)\n\t\treturn nil\n\t}\n\n\tif !commitHashRe.MatchString(b.Sourcestamp.Revision) {\n\t\tlogging.Warningf(\n\t\t\tc,\n\t\t\t\"build %q revision %q is not a commit hash. Skipping blamelist computation\",\n\t\t\tb.Sourcestamp.Revision, b.ID())\n\t\treturn nil\n\t}\n\n\tprevRev, err := getPrevRev(c, b, 100)\n\tswitch {\n\tcase err != nil:\n\t\treturn errors.Annotate(err, \"failed to get prev revision for build %q\", b.ID()).Err()\n\tcase prevRev == \"\":\n\t\tlogging.Warningf(c, \"prev rev of build %q is unknown. Skipping blamelist computation\", b.ID())\n\t\treturn nil\n\t}\n\n\t// Note that prev build may be coming from buildbot and having commit different\n\t// from the true previous _LUCI_ build, which may cause blamelist to have\n\t// extra or missing commits. This matters only for the first build after\n\t// next build number bump.\n\n\t// we don't really need a blamelist with a length > 50\n\tcommits, err := git.Get(c).Log(c, host, project, b.Sourcestamp.Revision, &git.LogOptions{Limit: 50})\n\tswitch status.Code(err) {\n\tcase codes.OK:\n\t\tfor _, commit := range commits {\n\t\t\tif commit.Id == prevRev {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tchange := changeFromGitiles(b.Sourcestamp.Repository, \"master\", commit)\n\t\t\tb.Sourcestamp.Changes = append(b.Sourcestamp.Changes, change)\n\t\t}\n\t\treturn nil\n\n\tcase codes.NotFound:\n\t\tlogging.WithError(err).Warningf(\n\t\t\tc,\n\t\t\t\"gitiles.log returned 404 %s/+/%s\",\n\t\t\tb.Sourcestamp.Repository, b.Sourcestamp.Revision)\n\t\tb.Sourcestamp.Changes = nil\n\t\treturn nil\n\n\tdefault:\n\t\treturn err\n\t}\n}", "func cacheSnapshotBlobs(p *Progress, s Server, c *Cache, id backend.ID) (*Map, error) {\n\tdebug.Log(\"CacheSnapshotBlobs\", \"create cache for snapshot %v\", id.Str())\n\n\tsn, err := LoadSnapshot(s, id)\n\tif err != nil {\n\t\tdebug.Log(\"CacheSnapshotBlobs\", \"unable to load snapshot %v: %v\", id.Str(), err)\n\t\treturn nil, err\n\t}\n\n\tm := NewMap()\n\n\t// add top-level node\n\tm.Insert(sn.Tree)\n\n\tp.Report(Stat{Trees: 1})\n\n\t// start walker\n\tvar wg sync.WaitGroup\n\tch := make(chan WalkTreeJob)\n\n\twg.Add(1)\n\tgo func() {\n\t\tWalkTree(s, sn.Tree, nil, ch)\n\t\twg.Done()\n\t}()\n\n\tfor i := 0; i < maxConcurrencyPreload; i++ {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tfor job := range ch {\n\t\t\t\tif job.Tree == nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tp.Report(Stat{Trees: 1})\n\t\t\t\tdebug.Log(\"CacheSnapshotBlobs\", \"got job %v\", job)\n\t\t\t\tm.Merge(job.Tree.Map)\n\t\t\t}\n\n\t\t\twg.Done()\n\t\t}()\n\t}\n\n\twg.Wait()\n\n\t// save blob list for snapshot\n\treturn m, c.StoreMap(id, m)\n}", "func getAllDescChanges(\n\tctx context.Context,\n\tdb *client.DB,\n\tstartTime, endTime hlc.Timestamp,\n\tpriorIDs map[sqlbase.ID]sqlbase.ID,\n) ([]BackupDescriptor_DescriptorRevision, error) {\n\tstartKey := roachpb.Key(keys.MakeTablePrefix(keys.DescriptorTableID))\n\tendKey := startKey.PrefixEnd()\n\n\tallRevs, err := getAllRevisions(ctx, db, startKey, endKey, startTime, endTime)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar res []BackupDescriptor_DescriptorRevision\n\n\tfor _, revs := range allRevs {\n\t\tid, err := keys.DecodeDescMetadataID(revs.Key)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tfor _, rev := range revs.Values {\n\t\t\tr := BackupDescriptor_DescriptorRevision{ID: sqlbase.ID(id), Time: rev.Timestamp}\n\t\t\tif len(rev.RawBytes) != 0 {\n\t\t\t\tvar desc sqlbase.Descriptor\n\t\t\t\tif err := rev.GetProto(&desc); err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tr.Desc = &desc\n\t\t\t\tif t := desc.GetTable(); t != nil && t.ReplacementOf.ID != sqlbase.InvalidID {\n\t\t\t\t\tpriorIDs[t.ID] = t.ReplacementOf.ID\n\t\t\t\t}\n\t\t\t}\n\t\t\tres = append(res, r)\n\t\t}\n\t}\n\treturn res, nil\n}", "func GetWatchdogsViaTimestamp(offset int, limit int, Timestamp_ int, field string) (*[]*Watchdog, error) {\n\tvar _Watchdog = new([]*Watchdog)\n\terr := Engine.Table(\"watchdog\").Where(\"timestamp = ?\", Timestamp_).Limit(limit, offset).Desc(field).Find(_Watchdog)\n\treturn _Watchdog, err\n}", "func (that *Stream) ListSince(timestamp int64, pageModel *PageModel) (*StreamResponseModelList, error) {\n\n\tpath := fmt.Sprintf(\"%s/%s/%s/%s/%d\", lib.DefaultAPIURL, lib.DefaultAPIVersion,\n\t\t\"streams\", \"since\", timestamp/1e6)\n\tpath = paramsUtil(path, pageModel)\n\n\tdata, err := that.client.Get(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponseList := new(StreamResponseModelList)\n\terr = json.Unmarshal(data, &responseList)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn responseList, nil\n}", "func (s *Server) List(ctx context.Context, in *proto.GetBlockRequest) (*proto.GetBlockResponse, error) {\n\ti, err := metrics.Gauge(\"List\", func() (interface{}, error) {\n\t\tresp := new(proto.GetBlockResponse)\n\n\t\tfor _, b := range s.Blockchain.Blocks {\n\t\t\tresp.Blocks = append(resp.Blocks, &proto.Block{\n\t\t\t\tPrevBlockHash: b.PrevBlockHash,\n\t\t\t\tData: b.Data,\n\t\t\t\tHash: b.Hash,\n\t\t\t})\n\t\t}\n\n\t\treturn resp, nil\n\t})\n\treturn i.(*proto.GetBlockResponse), err\n}", "func ImportBlobs(filepath string) ([]string, int64, error) {\n\n\tf, err := os.Open(filepath)\n\tif err != nil {\n\t\tlogger.Errorf(\"file of %s not exist\\n\", filepath)\n\t\treturn nil, 0, err\n\t}\n\tdefer f.Close()\n\n\tvar fileLength int64\n\thashList := make([]string, 0)\n\tfor {\n\t\tbuffer := make([]byte, configuration.BlobSize)\n\t\tn, err := f.Read(buffer)\n\t\tif err == io.EOF {\n\t\t\tif n > 0 {\n\t\t\t\tdgst := writeBlob(buffer[:n])\n\t\t\t\thashList = append(hashList, dgst)\n\t\t\t\tfileLength += int64(n)\n\t\t\t}\n\t\t\tbreak\n\t\t} else if err != nil {\n\t\t\tlogger.Errorf(\"read file error %s, %s bytes already read\\n\", err, filepath)\n\t\t\treturn nil, fileLength, err\n\t\t}\n\n\t\tdgst := writeBlob(buffer[:n])\n\t\tfileLength += int64(n)\n\t\thashList = append(hashList, dgst)\n\t}\n\n\treturn hashList, fileLength, nil\n}", "func (ts TombstonesSet) GetDeletedIntervals(lbls labels.Labels, from, to model.Time) []model.Interval {\n\tif len(ts.tombstones) == 0 || to < ts.oldestTombstoneStart || from > ts.newestTombstoneEnd {\n\t\treturn nil\n\t}\n\n\tvar deletedIntervals []model.Interval\n\trequestedInterval := model.Interval{Start: from, End: to}\n\n\tfor i := range ts.tombstones {\n\t\toverlaps, overlappingInterval := getOverlappingInterval(requestedInterval,\n\t\t\tmodel.Interval{Start: ts.tombstones[i].StartTime, End: ts.tombstones[i].EndTime})\n\n\t\tif !overlaps {\n\t\t\tcontinue\n\t\t}\n\n\t\tmatches := false\n\t\tfor _, matchers := range ts.tombstones[i].Matchers {\n\t\t\tif labels.Selector(matchers).Matches(lbls) {\n\t\t\t\tmatches = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif !matches {\n\t\t\tcontinue\n\t\t}\n\n\t\tif overlappingInterval == requestedInterval {\n\t\t\t// whole interval deleted\n\t\t\treturn []model.Interval{requestedInterval}\n\t\t}\n\n\t\tdeletedIntervals = append(deletedIntervals, overlappingInterval)\n\t}\n\n\tif len(deletedIntervals) == 0 {\n\t\treturn nil\n\t}\n\n\treturn mergeIntervals(deletedIntervals)\n}", "func (c *SequenceClockImpl) findModified(other SequenceClock) (modified []uint16) {\n\tif c.hashEquals(other.GetHashedValue()) {\n\t\treturn nil\n\t}\n\tfor vb, sequence := range other.Value() {\n\t\tif sequence > c.value[vb] {\n\t\t\tmodified = append(modified, uint16(vb))\n\t\t}\n\t}\n\treturn modified\n}", "func TestGetStatusByIPAddressAtTimestamp2(t *testing.T) {\n\n\tbefore(t, dbStorage, dbSchema)\n\n\tprivateIPs := []string{\"44.33.22.11\"}\n\tpublicIPs := []string{\"88.77.66.55\"}\n\thostnames := []string{\"yahoo.com\"} // nolint\n\ttimestamp, _ := time.Parse(time.RFC3339, \"2019-08-09T08:29:35+00:00\")\n\n\tfakeCloudAssetChange := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames, timestamp, `arn`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\t// just reuse the existing struct\n\tfakeCloudAssetChange.ARN = \"arn2\"\n\ttimestamp2, _ := time.Parse(time.RFC3339, \"2019-08-11T08:29:35+00:00\") // August 11\n\tfakeCloudAssetChange.ChangeTime = timestamp2\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tipAddress := \"88.77.66.55\"\n\tat, _ := time.Parse(time.RFC3339, \"2019-08-10T08:29:35+00:00\") // query is for status on August 10\n\tnetworkChangeEvents, err := dbStorage.FetchByIP(ctx, at, ipAddress)\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tassert.Equal(t, 1, len(networkChangeEvents))\n\n\texpected := []domain.CloudAssetDetails{\n\t\tdomain.CloudAssetDetails{nil, []string{\"88.77.66.55\"}, []string{\"yahoo.com\"}, \"rtype\", \"aid\", \"region\", \"arn\", nil, domain.AccountOwner{}}, // nolint\n\t}\n\n\tassertArrayEqualIgnoreOrder(t, expected, networkChangeEvents)\n\n}", "func cephRBDVolumeListSnapshots(clusterName string, poolName string,\n\tvolumeName string, volumeType string,\n\tuserName string) ([]string, error) {\n\tmsg, err := shared.RunCommand(\n\t\t\"rbd\",\n\t\t\"--id\", userName,\n\t\t\"--format\", \"json\",\n\t\t\"--cluster\", clusterName,\n\t\t\"--pool\", poolName,\n\t\t\"snap\",\n\t\t\"ls\", fmt.Sprintf(\"%s_%s\", volumeType, volumeName))\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\n\tvar data []map[string]interface{}\n\terr = json.Unmarshal([]byte(msg), &data)\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\n\tsnapshots := []string{}\n\tfor _, v := range data {\n\t\t_, ok := v[\"name\"]\n\t\tif !ok {\n\t\t\treturn []string{}, fmt.Errorf(\"No \\\"name\\\" property found\")\n\t\t}\n\n\t\tname, ok := v[\"name\"].(string)\n\t\tif !ok {\n\t\t\treturn []string{}, fmt.Errorf(\"\\\"name\\\" property did not have string type\")\n\t\t}\n\n\t\tname = strings.TrimSpace(name)\n\t\tsnapshots = append(snapshots, name)\n\t}\n\n\tif len(snapshots) == 0 {\n\t\treturn []string{}, db.ErrNoSuchObject\n\t}\n\n\treturn snapshots, nil\n}", "func (client ContainerAppsRevisionsClient) ListRevisionsSender(req *http.Request) (*http.Response, error) {\n\treturn client.Send(req, azure.DoRetryWithRegistration(client.Client))\n}", "func (b *Client) GetModifiedFiles(repo models.Repo, pull models.PullRequest) ([]string, error) {\n\tvar files []string\n\n\tnextPageURL := fmt.Sprintf(\"%s/2.0/repositories/%s/pullrequests/%d/diffstat\", b.BaseURL, repo.FullName, pull.Num)\n\t// We'll only loop 1000 times as a safety measure.\n\tmaxLoops := 1000\n\tfor i := 0; i < maxLoops; i++ {\n\t\tresp, err := b.makeRequest(\"GET\", nextPageURL, nil)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tvar diffStat DiffStat\n\t\tif err := json.Unmarshal(resp, &diffStat); err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"Could not parse response %q\", string(resp))\n\t\t}\n\t\tif err := validator.New().Struct(diffStat); err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"API response %q was missing fields\", string(resp))\n\t\t}\n\t\tfor _, v := range diffStat.Values {\n\t\t\tif v.Old != nil {\n\t\t\t\tfiles = append(files, *v.Old.Path)\n\t\t\t}\n\t\t\tif v.New != nil {\n\t\t\t\tfiles = append(files, *v.New.Path)\n\t\t\t}\n\t\t}\n\t\tif diffStat.Next == nil || *diffStat.Next == \"\" {\n\t\t\tbreak\n\t\t}\n\t\tnextPageURL = *diffStat.Next\n\t}\n\n\t// Now ensure all files are unique.\n\thash := make(map[string]bool)\n\tvar unique []string\n\tfor _, f := range files {\n\t\tif !hash[f] {\n\t\t\tunique = append(unique, f)\n\t\t\thash[f] = true\n\t\t}\n\t}\n\treturn unique, nil\n}", "func (p *commentsPlugin) cachedTimestamps(token []byte, commentIDs []uint32) (map[uint32]*comments.CommentTimestamp, error) {\n\t// Setup the timestamp keys\n\tkeys := make([]string, 0, len(commentIDs))\n\tfor _, cid := range commentIDs {\n\t\tk, err := getTimestampKey(token, cid)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tkeys = append(keys, k)\n\t}\n\n\t// Get the timestamp blob entries\n\tblobs, err := p.tstore.CacheGet(keys)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Decode the timestamps\n\tts := make(map[uint32]*comments.CommentTimestamp, len(blobs))\n\tcacheIDs := make([]uint32, 0, len(blobs))\n\tfor k, v := range blobs {\n\t\tvar t comments.CommentTimestamp\n\t\terr := json.Unmarshal(v, &t)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcid, err := parseTimestampKey(k)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tts[cid] = &t\n\t\tcacheIDs = append(cacheIDs, cid)\n\t}\n\n\tlog.Debugf(\"Retrieved cached final comment timestamps of %v/%v\",\n\t\tlen(cacheIDs), len(commentIDs))\n\treturn ts, nil\n}", "func FindModifiedFiles() []string {\n\tresult := GitDiff(\"--name-only\", \"-z\")\n\tresult = append(result, GitDiff(\"--name-only\", \"--cached\", \"-z\")...)\n\n\treturn result\n}", "func (pb PageBlobURL) GetManagedDiskPageRangesDiff(ctx context.Context, offset int64, count int64, prevSnapshot *string, prevSnapshotURL *string, ac BlobAccessConditions) (*PageList, error) {\n\tifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag := ac.ModifiedAccessConditions.pointers()\n\n\treturn pb.pbClient.GetPageRangesDiff(ctx, nil, nil, prevSnapshot,\n\t\tprevSnapshotURL, // Get managed disk diff\n\t\thttpRange{offset: offset, count: count}.pointers(),\n\t\tac.LeaseAccessConditions.pointers(),\n\t\tifModifiedSince, ifUnmodifiedSince, ifMatchETag, ifNoneMatchETag,\n\t\tnil, // Blob ifTags\n\t\tnil)\n}", "func MessagesInRange(start, end, path string) ([]Message, error) {\n\tif isEmpty(start) {\n\t\tstart = \"HEAD\"\n\t}\n\n\tif isEmpty(path) {\n\t\tpath = \".\"\n\t}\n\n\tvar logrange string\n\tif isEmpty(end) {\n\t\tlogrange = start\n\t} else {\n\t\tlogrange = fmt.Sprintf(\"%s...%s\", start, end)\n\t}\n\n\tcmd := exec.Command(\"git\", \"log\", logrange, path)\n\tout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn []Message{}, nil\n\t}\n\n\terr = cmd.Start()\n\tif err != nil {\n\t\treturn []Message{}, nil\n\t}\n\tdefer cmd.Wait()\n\treturn parseMessages(out)\n}", "func (g *Git) GetCommitsBetween(from *plumbing.Reference, to *plumbing.Reference) ([]*ChangelogItem, error) {\n\tvar history []*ChangelogItem\n\tvar exists bool\n\n\tcommits, err := g.repo.Log(&git.LogOptions{From: from.Hash()})\n\tif err != nil {\n\t\treturn history, err\n\t}\n\n\t// Iterate over all commits\n\t// Break when `to` has been found\n\terr = commits.ForEach(func(commit *object.Commit) error {\n\t\tif commit.Hash == to.Hash() {\n\t\t\texists = true\n\t\t\treturn errors.New(\"ErrStop\")\n\t\t}\n\n\t\t// Check if commit message contains issue in form `(#0..9)`\n\t\t// and add commit as a changelog item\n\t\tif hasIssue(commit.Message) {\n\t\t\thistory = append(history, &ChangelogItem{\n\t\t\t\tHash: commit.Hash.String(),\n\t\t\t\tText: commit.Message,\n\t\t\t\tIssueID: getIssueFrom(commit.Message),\n\t\t\t\tAuthor: commit.Author.Name,\n\t\t\t})\n\t\t}\n\t\treturn nil\n\t})\n\n\tif exists {\n\t\treturn history, nil\n\t}\n\n\treturn history, errors.Errorf(\"Unable to compare references, %v not found in history of %v\", to.Name().Short(), from.Name().Short())\n}", "func getRelevantDescChanges(\n\tctx context.Context,\n\tdb *client.DB,\n\tstartTime, endTime hlc.Timestamp,\n\tdescs []sqlbase.Descriptor,\n\texpanded []sqlbase.ID,\n\tpriorIDs map[sqlbase.ID]sqlbase.ID,\n) ([]BackupDescriptor_DescriptorRevision, error) {\n\n\tallChanges, err := getAllDescChanges(ctx, db, startTime, endTime, priorIDs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// If no descriptors changed, we can just stop now and have RESTORE use the\n\t// normal list of descs (i.e. as of endTime).\n\tif len(allChanges) == 0 {\n\t\treturn nil, nil\n\t}\n\n\t// interestingChanges will be every descriptor change relevant to the backup.\n\tvar interestingChanges []BackupDescriptor_DescriptorRevision\n\n\t// interestingIDs are the descriptor for which we're interested in capturing\n\t// changes. This is initially the descriptors matched (as of endTime) by our\n\t// target spec, plus those that belonged to a DB that our spec expanded at any\n\t// point in the interval.\n\tinterestingIDs := make(map[sqlbase.ID]struct{}, len(descs))\n\n\t// The descriptors that currently (endTime) match the target spec (desc) are\n\t// obviously interesting to our backup.\n\tfor _, i := range descs {\n\t\tinterestingIDs[i.GetID()] = struct{}{}\n\t\tif t := i.GetTable(); t != nil {\n\t\t\tfor j := t.ReplacementOf.ID; j != sqlbase.InvalidID; j = priorIDs[j] {\n\t\t\t\tinterestingIDs[j] = struct{}{}\n\t\t\t}\n\t\t}\n\t}\n\n\t// We're also interested in any desc that belonged to a DB we're backing up.\n\t// We'll start by looking at all descriptors as of the beginning of the\n\t// interval and add to the set of IDs that we are interested any descriptor that\n\t// belongs to one of the parents we care about.\n\tinterestingParents := make(map[sqlbase.ID]struct{}, len(expanded))\n\tfor _, i := range expanded {\n\t\tinterestingParents[i] = struct{}{}\n\t}\n\n\tif !startTime.IsEmpty() {\n\t\tstarting, err := loadAllDescs(ctx, db, startTime)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tfor _, i := range starting {\n\t\t\tif table := i.GetTable(); table != nil {\n\t\t\t\t// We need to add to interestingIDs so that if we later see a delete for\n\t\t\t\t// this ID we still know it is interesting to us, even though we will not\n\t\t\t\t// have a parentID at that point (since the delete is a nil desc).\n\t\t\t\tif _, ok := interestingParents[table.ParentID]; ok {\n\t\t\t\t\tinterestingIDs[table.ID] = struct{}{}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif _, ok := interestingIDs[i.GetID()]; ok {\n\t\t\t\tdesc := i\n\t\t\t\t// We inject a fake \"revision\" that captures the starting state for\n\t\t\t\t// matched descriptor, to allow restoring to times before its first rev\n\t\t\t\t// actually inside the window. This likely ends up duplicating the last\n\t\t\t\t// version in the previous BACKUP descriptor, but avoids adding more\n\t\t\t\t// complicated special-cases in RESTORE, so it only needs to look in a\n\t\t\t\t// single BACKUP to restore to a particular time.\n\t\t\t\tinitial := BackupDescriptor_DescriptorRevision{Time: startTime, ID: i.GetID(), Desc: &desc}\n\t\t\t\tinterestingChanges = append(interestingChanges, initial)\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, change := range allChanges {\n\t\t// A change to an ID that we are interested in is obviously interesting --\n\t\t// a change is also interesting if it is to a table that has a parent that\n\t\t// we are interested and thereafter it also becomes an ID in which we are\n\t\t// interested in changes (since, as mentioned above, to decide if deletes\n\t\t// are interesting).\n\t\tif _, ok := interestingIDs[change.ID]; ok {\n\t\t\tinterestingChanges = append(interestingChanges, change)\n\t\t} else if change.Desc != nil {\n\t\t\tif table := change.Desc.GetTable(); table != nil {\n\t\t\t\tif _, ok := interestingParents[table.ParentID]; ok {\n\t\t\t\t\tinterestingIDs[table.ID] = struct{}{}\n\t\t\t\t\tinterestingChanges = append(interestingChanges, change)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tsort.Slice(interestingChanges, func(i, j int) bool {\n\t\treturn interestingChanges[i].Time.Less(interestingChanges[j].Time)\n\t})\n\n\treturn interestingChanges, nil\n}", "func (core *coreService) LogsInRange(filter *logfilter.LogFilter, start, end, paginationSize uint64) ([]*action.Log, []hash.Hash256, error) {\n\tstart, end, err := core.correctQueryRange(start, end)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif paginationSize == 0 {\n\t\tpaginationSize = 1000\n\t}\n\tif paginationSize > 5000 {\n\t\tpaginationSize = 5000\n\t}\n\t// getLogs via range Blooom filter [start, end]\n\tblockNumbers, err := core.bfIndexer.FilterBlocksInRange(filter, start, end, paginationSize)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tvar (\n\t\tlogs = []*action.Log{}\n\t\thashes = []hash.Hash256{}\n\t\tlogsInBlk = make([][]*action.Log, len(blockNumbers))\n\t\tHashInBlk = make([]hash.Hash256, len(blockNumbers))\n\t\tjobs = make(chan jobDesc, len(blockNumbers))\n\t\teg, ctx = errgroup.WithContext(context.Background())\n\t)\n\tif len(blockNumbers) == 0 {\n\t\treturn logs, hashes, nil\n\t}\n\n\tfor i, v := range blockNumbers {\n\t\tjobs <- jobDesc{i, v}\n\t}\n\tclose(jobs)\n\tfor w := 0; w < _workerNumbers; w++ {\n\t\teg.Go(func() error {\n\t\t\tfor {\n\t\t\t\tselect {\n\t\t\t\tcase <-ctx.Done():\n\t\t\t\t\treturn ctx.Err()\n\t\t\t\tdefault:\n\t\t\t\t\tjob, ok := <-jobs\n\t\t\t\t\tif !ok {\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t\tlogsInBlock, err := core.logsInBlock(filter, job.blkNum)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tblkHash, err := core.dao.GetBlockHash(job.blkNum)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tlogsInBlk[job.idx] = logsInBlock\n\t\t\t\t\tHashInBlk[job.idx] = blkHash\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\tif err := eg.Wait(); err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tfor i := 0; i < len(blockNumbers); i++ {\n\t\tfor j := range logsInBlk[i] {\n\t\t\tlogs = append(logs, logsInBlk[i][j])\n\t\t\thashes = append(hashes, HashInBlk[i])\n\t\t\tif len(logs) >= int(paginationSize) {\n\t\t\t\treturn logs, hashes, nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn logs, hashes, nil\n}", "func ReadBlocksHashByTmSlice(db ReadIteration, slice uint64) ([]common.Hash, error) {\n\t//mTime := utils.GetMainTime(slice)\n\tvar hashes []common.Hash\n\tkey := blockLookUpKey(slice)\n\titerator := db.NewIteratorWithPrefix(key)\n\tif iterator == nil {\n\t\treturn nil, fmt.Errorf(\"Failed to get iterator\")\n\t}\n\n\tfor iterator.Next() {\n\t\thash := common.BytesToHash(iterator.Value())\n\t\thashes = append(hashes, hash)\n\t}\n\n\treturn hashes, nil\n}", "func (l Logfiles) FilterOld(oldTime time.Time) Logfiles {\n\tf := make(Logfiles, 0)\n\tfor _, logfile := range l {\n\t\tfinfo, err := os.Stat(logfile.FileName)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif finfo.ModTime().After(oldTime) {\n\t\t\tf = append(f, logfile)\n\t\t}\n\t}\n\treturn f\n}", "func (c *Client) ListHistory(ctx context.Context, userID, appID string, start, end int64, opts ...grpc.CallOption) (map[*trillian.SignedMapRoot][]byte, error) {\n\tif start < 0 {\n\t\treturn nil, fmt.Errorf(\"start=%v, want >= 0\", start)\n\t}\n\tvar currentProfile []byte\n\tprofiles := make(map[*trillian.SignedMapRoot][]byte)\n\tepochsReceived := int64(0)\n\tepochsWant := end - start + 1\n\tfor epochsReceived < epochsWant {\n\t\ttrustedSnapshot := c.trusted\n\t\tresp, err := c.cli.ListEntryHistory(ctx, &pb.ListEntryHistoryRequest{\n\t\t\tDomainId: c.domainID,\n\t\t\tUserId: userID,\n\t\t\tAppId: appID,\n\t\t\tFirstTreeSize: trustedSnapshot.TreeSize,\n\t\t\tStart: start,\n\t\t\tPageSize: min(int32((end-start)+1), pageSize),\n\t\t}, opts...)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tepochsReceived += int64(len(resp.GetValues()))\n\n\t\tfor i, v := range resp.GetValues() {\n\t\t\tVlog.Printf(\"Processing entry for %v, epoch %v\", userID, start+int64(i))\n\t\t\terr = c.VerifyGetEntryResponse(ctx, c.domainID, appID, userID, trustedSnapshot, v)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tc.updateTrusted(v.GetLogRoot())\n\n\t\t\t// Compress profiles that are equal through time. All\n\t\t\t// nil profiles before the first profile are ignored.\n\t\t\tprofile := v.GetCommitted().GetData()\n\t\t\tif bytes.Equal(currentProfile, profile) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Append the slice and update currentProfile.\n\t\t\tprofiles[v.GetSmr()] = profile\n\t\t\tcurrentProfile = profile\n\t\t}\n\t\tif resp.NextStart == 0 {\n\t\t\tbreak // No more data.\n\t\t}\n\t\tstart = resp.NextStart // Fetch the next block of results.\n\t}\n\n\tif epochsReceived < epochsWant {\n\t\treturn nil, ErrIncomplete\n\t}\n\n\treturn profiles, nil\n}", "func printBlobList(blobClient *storage.BlobStorageClient, containerName string) error {\n\tfmt.Printf(\"Get blob list from container '%v'...\\n\", containerName)\n\tlist, err := blobClient.ListBlobs(containerName, storage.ListBlobsParameters{})\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(\"Blobs inside '%v' container:\\n\", containerName)\n\tfor _, b := range list.Blobs {\n\t\tfmt.Printf(\"\\t%v\\n\", b.Name)\n\t}\n\treturn nil\n}", "func (db *database) QueryByModified(lastTime time.Time, lastID int64, limit int) ([]snippet, error) {\n\tif lastTime.IsZero() && lastID == 0 {\n\t\tlastTime, lastID = maxTime, maxID // Find everything\n\t}\n\tvar ss []snippet\n\terr := db.db.View(func(tx *bolt.Tx) error {\n\t\t// Seek to the latest value that is immediately before the search key.\n\t\tbktByDate := tx.Bucket([]byte(bucketByDate))\n\t\tc := bktByDate.Cursor()\n\t\tsk := dualKey(lastID, lastTime)\n\t\tk, _ := c.Seek(sk)\n\t\tif k == nil {\n\t\t\tk, _ = c.Last()\n\t\t}\n\n\t\t// Iterate through all results.\n\t\tss = nil\n\t\tbktByID := tx.Bucket([]byte(bucketByID))\n\t\tfor ; k != nil; k, _ = c.Prev() {\n\t\t\tif len(ss) >= limit && limit >= 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif bytes.Compare(k, sk) >= 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tvar s snippet\n\t\t\tv := bktByID.Get(k[12:20]) // Extract ID from dual key\n\t\t\tif err := s.UnmarshalBinary(v); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tss = append(ss, s)\n\t\t}\n\t\treturn nil\n\t})\n\treturn ss, err\n}", "func ListSnapshots(sg *snapshotgroup.SnapshotGroup) ([]GeminiSnapshot, error) {\n\tclient := kube.GetClient()\n\tsnapshots, err := client.SnapshotClient.Namespace(sg.ObjectMeta.Namespace).List(metav1.ListOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tGeminiSnapshots := []GeminiSnapshot{}\n\tfor _, snapshot := range snapshots.Items {\n\t\tsnapshotMeta, err := meta.Accessor(&snapshot)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tannotations := snapshotMeta.GetAnnotations()\n\t\tif managedBy, ok := annotations[managedByAnnotation]; !ok || managedBy != managerName {\n\t\t\tcontinue\n\t\t}\n\t\tif annotations[GroupNameAnnotation] != sg.ObjectMeta.Name {\n\t\t\tcontinue\n\t\t}\n\t\ttimestampStr := annotations[TimestampAnnotation]\n\t\ttimestamp, err := strconv.Atoi(timestampStr)\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"%s/%s: failed to parse unix timestamp %s for %s\", sg.ObjectMeta.Namespace, sg.ObjectMeta.Name, timestampStr, snapshotMeta.GetName())\n\t\t\tcontinue\n\t\t}\n\t\tintervals := []string{}\n\t\tintervalsStr := annotations[IntervalsAnnotation]\n\t\tif intervalsStr != \"\" {\n\t\t\tintervals = strings.Split(intervalsStr, intervalsSeparator)\n\t\t}\n\t\tGeminiSnapshots = append(GeminiSnapshots, GeminiSnapshot{\n\t\t\tNamespace: snapshotMeta.GetNamespace(),\n\t\t\tName: snapshotMeta.GetName(),\n\t\t\tTimestamp: time.Unix(int64(timestamp), 0),\n\t\t\tIntervals: intervals,\n\t\t\tRestore: annotations[RestoreAnnotation],\n\t\t})\n\t}\n\tsort.Slice(GeminiSnapshots, func(i, j int) bool {\n\t\treturn GeminiSnapshots[j].Timestamp.Before(GeminiSnapshots[i].Timestamp)\n\t})\n\treturn GeminiSnapshots, nil\n}", "func (a *ChangeAgent) handleGetChanges(\n\tresp http.ResponseWriter, req *http.Request, params httprouter.Params) {\n\tqps := req.URL.Query()\n\n\tlimitStr := qps.Get(\"limit\")\n\tif limitStr == \"\" {\n\t\tlimitStr = defaultLimit\n\t}\n\tlmt, err := strconv.ParseUint(limitStr, 10, 32)\n\tif err != nil {\n\t\twriteError(resp, http.StatusBadRequest, errors.New(\"Invalid limit\"))\n\t\treturn\n\t}\n\tlimit := uint(lmt)\n\n\tsinceStr := qps.Get(\"since\")\n\tif sinceStr == \"\" {\n\t\tsinceStr = defaultSince\n\t}\n\tsince, err := strconv.ParseUint(sinceStr, 10, 64)\n\tif err != nil {\n\t\twriteError(resp, http.StatusBadRequest, errors.New(\"Invalid since\"))\n\t\treturn\n\t}\n\n\tblockStr := qps.Get(\"block\")\n\tif blockStr == \"\" {\n\t\tblockStr = defaultBlock\n\t}\n\tbk, err := strconv.ParseUint(blockStr, 10, 32)\n\tif err != nil {\n\t\twriteError(resp, http.StatusBadRequest, errors.New(\"Invalid block\"))\n\t\treturn\n\t}\n\tblock := time.Duration(bk)\n\n\ttags := qps[\"tag\"]\n\n\t// Fetch more than we need so we can see if we're at the beginning or end\n\tfetchLimit := limit + 1\n\tfetchSince := since\n\tif fetchSince > 0 {\n\t\tfetchSince--\n\t\tfetchLimit++\n\t}\n\n\tentries, lastFullChange, err := a.fetchEntries(fetchSince, fetchLimit, tags, resp)\n\tif err != nil {\n\t\treturn\n\t}\n\tentries, atStart, atEnd := pruneChanges(entries, since, limit)\n\n\tif (len(entries) == 0) && (block > 0) {\n\t\tnow := time.Now()\n\t\twaitEnd := now.Add(block * time.Second)\n\t\twaitFor := lastFullChange\n\t\tfor len(entries) == 0 && waitEnd.After(now) {\n\t\t\t// Because of tags, do this in a loop, so we check for tags every time and re-wait\n\t\t\twaitFor++\n\t\t\twaitRemaining := waitEnd.Sub(now)\n\t\t\tglog.V(2).Infof(\"Waiting %d milliseconds for the next change after %d\", waitRemaining, waitFor)\n\t\t\ta.raft.GetAppliedTracker().TimedWait(waitFor, waitRemaining)\n\t\t\tentries, _, err = a.fetchEntries(waitFor-1, fetchLimit, tags, resp)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tentries, atStart, atEnd = pruneChanges(entries, since, limit)\n\t\t\tglog.V(2).Infof(\"Got %d changes after blocking\", len(entries))\n\t\t\tnow = time.Now()\n\t\t}\n\t}\n\n\tresp.Header().Set(\"Content-Type\", jsonContent)\n\tmarshalChanges(entries, atStart, atEnd, resp)\n}", "func ListSnapshots(storagDriverConfig interface{}, pred func(id string) bool) (ids []string, err error) {\n\t// create (backup) storage driver (so we can list snapshot headers from it)\n\tdriver, err := newStorageDriver(storagDriverConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tids, err = driver.GetHeaders()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif pred == nil {\n\t\treturn ids, nil\n\t}\n\n\tfilterPos := 0\n\tvar ok bool\n\tfor _, id := range ids {\n\t\tok = pred(id)\n\t\tif ok {\n\t\t\tids[filterPos] = id\n\t\t\tfilterPos++\n\t\t}\n\t}\n\n\treturn ids[:filterPos], nil\n}", "func (g *GitRepo) ModifiedFiles(c *git.Commit, tree *git.Tree) ([]string, error) {\n\topts := &git.DiffOptions{}\n\tmodified := []string{}\n\tparentCount := c.ParentCount()\n\tfor i := uint(0); i <= parentCount; i++ {\n\t\tparentID := c.ParentId(i)\n\t\tif parentID == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tlog.Debugf(\"Looking up parent commit-id '%s'\", parentID.String())\n\t\tparent, err := g.r.LookupCommit(parentID)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer parent.Free()\n\n\t\tparentTree, err := parent.Tree()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer parentTree.Free()\n\n\t\tdiff, err := g.r.DiffTreeToTree(parentTree, tree, opts)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer diff.Free()\n\n\t\t_ = diff.ForEach(func(f git.DiffDelta, p float64) (git.DiffForEachHunkCallback, error) {\n\t\t\tmodified = append(modified, f.OldFile.Path)\n\t\t\treturn nil, nil\n\t\t}, git.DiffDetailFiles)\n\t}\n\treturn modified, nil\n}", "func GetBlogVersionsesViaLastUpdated(offset int, limit int, LastUpdated_ time.Time, field string) (*[]*BlogVersions, error) {\n\tvar _BlogVersions = new([]*BlogVersions)\n\terr := Engine.Table(\"blog_versions\").Where(\"last_updated = ?\", LastUpdated_).Limit(limit, offset).Desc(field).Find(_BlogVersions)\n\treturn _BlogVersions, err\n}", "func (s Secret) Blobs() [][]byte {\n\tout := make([][]byte, 0, 1+len(s.Previous))\n\tout = append(out, s.Current)\n\tout = append(out, s.Previous...)\n\treturn out\n}", "func (r Repository) LogBetween(since, until time.Time, opt *LogBetweenOptions) ([]CommitInfo, error) {\n\tif opt == nil {\n\t\topt = &LogBetweenOptions{}\n\t}\n\targs := []string{\"log\",\n\t\t\"--since\", since.Format(time.RFC3339),\n\t\t\"--until\", until.Format(time.RFC3339),\n\t\tlogPrettyFormatArg,\n\t}\n\tout, err := r.run(nil, opt.Timeout, args...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn parseLog(out)\n}", "func TestGetStatusByIPAddressAtTimestamp4(t *testing.T) {\n\n\tbefore(t, dbStorage, dbSchema)\n\n\tprivateIPs := []string{\"44.33.22.11\"}\n\tpublicIPs := []string{\"88.77.66.55\"}\n\thostnames := []string{\"yahoo.com\"} // nolint\n\ttimestamp, _ := time.Parse(time.RFC3339, \"2019-08-09T08:29:35+00:00\")\n\n\tfakeCloudAssetChange := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames, timestamp, `arn`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\ttimestamp2, _ := time.Parse(time.RFC3339, \"2019-08-12T08:29:35+00:00\") // August 12\n\thostnames2 := []string{\"blarg.com\"}\n\tfakeCloudAssetChange2 := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames2, timestamp2, `arn2`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange2); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tipAddress := \"88.77.66.55\"\n\tat, _ := time.Parse(time.RFC3339, \"2019-08-11T08:29:35+00:00\") // query is for status on August 11\n\tnetworkChangeEvents, err := dbStorage.FetchByIP(ctx, at, ipAddress)\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tassert.Equal(t, 1, len(networkChangeEvents))\n\n\texpected := []domain.CloudAssetDetails{\n\t\tdomain.CloudAssetDetails{nil, []string{\"88.77.66.55\"}, []string{\"yahoo.com\"}, \"rtype\", \"aid\", \"region\", \"arn\", nil, domain.AccountOwner{}}, // nolint\n\t}\n\n\tassertArrayEqualIgnoreOrder(t, expected, networkChangeEvents)\n\n}", "func getHistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\ttype AuditHistory struct {\n\t\tTxId string `json:\"txId\"`\n\t\tValue Marble `json:\"value\"`\n\t}\n\tvar history []AuditHistory;\n\tvar marble Marble\n\n\tif len(args) != 1 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 1\")\n\t}\n\n\tmarbleId := args[0]\n\tfmt.Printf(\"- start getHistoryForMarble: %s\\n\", marbleId)\n\n\t// Get History\n\tresultsIterator, err := stub.GetHistoryForKey(marbleId)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tfor resultsIterator.HasNext() {\n\t\thistoryData, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\n\t\tvar tx AuditHistory\n\t\ttx.TxId = historyData.TxId //copy transaction id over\n\t\tjson.Unmarshal(historyData.Value, &marble) //un stringify it aka JSON.parse()\n\t\tif historyData.Value == nil { //marble has been deleted\n\t\t\tvar emptyMarble Marble\n\t\t\ttx.Value = emptyMarble //copy nil marble\n\t\t} else {\n\t\t\tjson.Unmarshal(historyData.Value, &marble) //un stringify it aka JSON.parse()\n\t\t\ttx.Value = marble //copy marble over\n\t\t}\n\t\thistory = append(history, tx) //add this tx to the list\n\t}\n\tfmt.Printf(\"- getHistoryForMarble returning:\\n%s\", history)\n\n\t//change to array of bytes\n\thistoryAsBytes, _ := json.Marshal(history) //convert to array of bytes\n\treturn shim.Success(historyAsBytes)\n}", "func (ct *ctrlerCtx) diffBucket(apicl apiclient.Services) {\n\topts := api.ListWatchOptions{}\n\n\t// get a list of all objects from API server\n\tobjlist, err := apicl.ObjstoreV1().Bucket().List(context.Background(), &opts)\n\tif err != nil {\n\t\tct.logger.Errorf(\"Error getting a list of objects. Err: %v\", err)\n\t\treturn\n\t}\n\n\tct.logger.Infof(\"diffBucket(): BucketList returned %d objects\", len(objlist))\n\n\t// build an object map\n\tobjmap := make(map[string]*objstore.Bucket)\n\tfor _, obj := range objlist {\n\t\tobjmap[obj.GetKey()] = obj\n\t}\n\n\tlist, err := ct.Bucket().List(context.Background(), &opts)\n\tif err != nil && !strings.Contains(err.Error(), \"not found in local cache\") {\n\t\tct.logger.Infof(\"Failed to get a list of objects. Err: %s\", err)\n\t\treturn\n\t}\n\n\t// if an object is in our local cache and not in API server, trigger delete for it\n\tfor _, obj := range list {\n\t\t_, ok := objmap[obj.GetKey()]\n\t\tif !ok {\n\t\t\tct.logger.Infof(\"diffBucket(): Deleting existing object %#v since its not in apiserver\", obj.GetKey())\n\t\t\tevt := kvstore.WatchEvent{\n\t\t\t\tType: kvstore.Deleted,\n\t\t\t\tKey: obj.GetKey(),\n\t\t\t\tObject: &obj.Bucket,\n\t\t\t}\n\t\t\tct.handleBucketEvent(&evt)\n\t\t}\n\t}\n\n\t// trigger create event for all others\n\tfor _, obj := range objlist {\n\t\tct.logger.Infof(\"diffBucket(): Adding object %#v\", obj.GetKey())\n\t\tevt := kvstore.WatchEvent{\n\t\t\tType: kvstore.Created,\n\t\t\tKey: obj.GetKey(),\n\t\t\tObject: obj,\n\t\t}\n\t\tct.handleBucketEvent(&evt)\n\t}\n}", "func TestGetStatusByHostnameAtTimestamp2(t *testing.T) {\n\n\tbefore(t, dbStorage, dbSchema)\n\n\tprivateIPs := []string{\"44.33.22.11\"}\n\tpublicIPs := []string{\"88.77.66.55\"} // nolint\n\thostnames := []string{\"yahoo.com\"} // nolint\n\ttimestamp, _ := time.Parse(time.RFC3339, \"2019-08-09T08:29:35+00:00\")\n\n\tfakeCloudAssetChange := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames, timestamp, `arn`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\t// just reuse the existing struct\n\tfakeCloudAssetChange.ARN = \"arn2\"\n\ttimestamp2, _ := time.Parse(time.RFC3339, \"2019-08-11T08:29:35+00:00\") // August 11\n\tfakeCloudAssetChange.ChangeTime = timestamp2\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\thostname := \"yahoo.com\" // nolint\n\tat, _ := time.Parse(time.RFC3339, \"2019-08-10T08:29:35+00:00\") // query is for status on August 10\n\tnetworkChangeEvents, err := dbStorage.FetchByHostname(ctx, at, hostname)\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tassert.Equal(t, 1, len(networkChangeEvents))\n\n\texpected := []domain.CloudAssetDetails{{nil, []string{\"88.77.66.55\"}, []string{\"yahoo.com\"}, \"rtype\", \"aid\", \"region\", \"arn\", nil, domain.AccountOwner{}}} // nolint\n\n\tassertArrayEqualIgnoreOrder(t, expected, networkChangeEvents)\n\n}", "func (o *DeeplinkApp) SetModifiedTs(v int32) {\n\to.ModifiedTs = &v\n}", "func cephRBDSnapshotListClones(clusterName string, poolName string,\n\tvolumeName string, volumeType string,\n\tsnapshotName string, userName string) ([]string, error) {\n\tmsg, err := shared.RunCommand(\n\t\t\"rbd\",\n\t\t\"--id\", userName,\n\t\t\"--cluster\", clusterName,\n\t\t\"--pool\", poolName,\n\t\t\"children\",\n\t\t\"--image\", fmt.Sprintf(\"%s_%s\", volumeType, volumeName),\n\t\t\"--snap\", snapshotName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tmsg = strings.TrimSpace(msg)\n\tclones := strings.Fields(msg)\n\tif len(clones) == 0 {\n\t\treturn nil, db.ErrNoSuchObject\n\t}\n\n\treturn clones, nil\n}", "func Diff(a, b string) []string {\n\topts := jsondiff.Options{\n\t\tAdded: jsondiff.Tag{Begin: \"{\\\"changed\\\":[\", End: \"]}\"},\n\t\tRemoved: jsondiff.Tag{Begin: \"{\\\"changed\\\":[\", End: \"]}\"},\n\t\tChanged: jsondiff.Tag{Begin: \"{\\\"changed\\\":[\", End: \"]}\"},\n\t\tChangedSeparator: \", \",\n\t\tIndent: \" \",\n\t}\n\n\tresult, comparedStr := jsondiff.Compare([]byte(a), []byte(b), &opts)\n\n\tif !(result == jsondiff.NoMatch || result == jsondiff.SupersetMatch) {\n\t\treturn nil\n\t}\n\n\treader := bufio.NewReader(bytes.NewReader([]byte(comparedStr)))\n\tdiffMap := make(map[string]bool)\n\tvar currentProperty string\n\tfor {\n\t\tstringRead, err := reader.ReadString('\\n')\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tlog.Printf(\"Error finding difference in json strings %v\", err)\n\t\t}\n\t\tif yes, str := isNewTopLevelProp(stringRead); yes {\n\t\t\tcurrentProperty = str\n\t\t}\n\t\tif strings.Contains(stringRead, changePattern) {\n\t\t\tdiffMap[currentProperty] = true\n\t\t}\n\t}\n\treturn mapKeysToSlice(reflect.ValueOf(diffMap).MapKeys())\n}", "func Difference(a, b []byte) []*Delta {\n\tn := len(a)\n\tm := len(b)\n\tedits := edits(a, b, n, m)\n\tif edits < 0 {\n\t\t// Error determining length of edit script\n\t\treturn nil\n\t}\n\tds := deltas(a, b, n, m, edits)\n\t// Compact deltas\n\tds = Compact(ds)\n\t// Rebase deltas into sequence\n\tvar change uint64\n\tfor _, d := range ds {\n\t\td.Offset += change\n\t\tchange -= d.Delete\n\t\tchange += uint64(len(d.Insert))\n\t}\n\treturn ds\n}", "func findModifiedContainers(podTemplate *v1.PodTemplateSpec, pod *v1.Pod) ([]hookv1alpha1.Argument, error) {\n\toldImages := make(map[string]string)\n\tfor _, container := range pod.Spec.Containers {\n\t\toldImages[container.Name] = container.Image\n\t}\n\n\targuments := make([]hookv1alpha1.Argument, 0)\n\tfor _, container := range podTemplate.Spec.Containers {\n\t\tif image, ok := oldImages[container.Name]; !ok || container.Image != image {\n\t\t\ttmp := new(string)\n\t\t\t*tmp = container.Name\n\t\t\timageArgs := hookv1alpha1.Argument{\n\t\t\t\tName: ModifiedArgKey + \"[\" + strconv.Itoa(len(arguments)) + \"]\",\n\t\t\t\tValue: tmp,\n\t\t\t}\n\t\t\targuments = append(arguments, imageArgs)\n\t\t}\n\n\t}\n\treturn arguments, nil\n}", "func getBlobsWithPrefix(tx *sql.Tx, prefix string) ([]*Blob, error) {\n\tvar blobs []*Blob\n\trows, err := tx.Query(\"SELECT * from blobinfo WHERE hasPrefix(digest, $1)\", prefix)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor rows.Next() {\n\t\tblob := &Blob{}\n\t\tif err := blobRowScan(rows, blob); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tblobs = append(blobs, blob)\n\t}\n\tif err := rows.Err(); err != nil {\n\t\treturn nil, err\n\t}\n\treturn blobs, err\n}", "func (m *MockEnginePolicyManager) ListPKBetweenUpdatedAt(beginUpdatedAt, endUpdatedAt int64) ([]int64, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ListPKBetweenUpdatedAt\", beginUpdatedAt, endUpdatedAt)\n\tret0, _ := ret[0].([]int64)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (s BlobSet) List() BlobHandles {\n\tlist := make(BlobHandles, 0, len(s))\n\tfor h := range s {\n\t\tlist = append(list, h)\n\t}\n\n\tsort.Sort(list)\n\n\treturn list\n}", "func GetBlogVersionsesByDbVersionAndLastUpdated(offset int, limit int, DbVersion_ string, LastUpdated_ time.Time) (*[]*BlogVersions, error) {\n\tvar _BlogVersions = new([]*BlogVersions)\n\terr := Engine.Table(\"blog_versions\").Where(\"db_version = ? and last_updated = ?\", DbVersion_, LastUpdated_).Limit(limit, offset).Find(_BlogVersions)\n\treturn _BlogVersions, err\n}", "func TestGetStatusByIPAddressAtTimestamp5(t *testing.T) {\n\n\tbefore(t, dbStorage, dbSchema)\n\n\tprivateIPs := []string{\"44.33.22.11\"}\n\tpublicIPs := []string{\"88.77.66.55\"}\n\thostnames := []string{\"yahoo.com\"} // nolint\n\ttimestamp, _ := time.Parse(time.RFC3339, \"2019-08-09T08:29:35+00:00\")\n\n\tfakeCloudAssetChange := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames, timestamp, `arn`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\ttimestamp2, _ := time.Parse(time.RFC3339, \"2019-08-12T08:29:35+00:00\") // August 12\n\thostnames2 := []string{\"blarg.com\"}\n\tfakeCloudAssetChange2 := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames2, timestamp2, `arn2`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange2); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\ttimestamp3, _ := time.Parse(time.RFC3339, \"2019-08-10T08:29:35+00:00\") // August 10, arn3\n\thostnames3 := []string{\"reddit.com\"}\n\tfakeCloudAssetChange3 := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames3, timestamp3, `arn3`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange3); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\ttimestamp4, _ := time.Parse(time.RFC3339, \"2019-08-10T08:39:35+00:00\") // August 10, 10 minutes later, arn3 drops the same IP address\n\tfakeCloudAssetChange4 := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames3, timestamp4, `arn3`, `rtype`, `aid`, `region`, nil, false)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange4); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tipAddress := \"88.77.66.55\"\n\tat, _ := time.Parse(time.RFC3339, \"2019-08-13T08:29:35+00:00\") // query is for status on August 13\n\tnetworkChangeEvents, err := dbStorage.FetchByIP(ctx, at, ipAddress)\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tassert.Equal(t, 2, len(networkChangeEvents))\n\n\texpected := []domain.CloudAssetDetails{\n\t\tdomain.CloudAssetDetails{nil, []string{\"88.77.66.55\"}, []string{\"yahoo.com\"}, \"rtype\", \"aid\", \"region\", \"arn\", nil, domain.AccountOwner{}}, //nolint\n\t\tdomain.CloudAssetDetails{nil, []string{\"88.77.66.55\"}, []string{\"blarg.com\"}, \"rtype\", \"aid\", \"region\", \"arn2\", nil, domain.AccountOwner{}}, //nolint\n\t}\n\n\tassertArrayEqualIgnoreOrder(t, expected, networkChangeEvents)\n\n}", "func GetBlogVersionsesByBlogIdAndLastUpdated(offset int, limit int, BlogId_ int64, LastUpdated_ time.Time) (*[]*BlogVersions, error) {\n\tvar _BlogVersions = new([]*BlogVersions)\n\terr := Engine.Table(\"blog_versions\").Where(\"blog_id = ? and last_updated = ?\", BlogId_, LastUpdated_).Limit(limit, offset).Find(_BlogVersions)\n\treturn _BlogVersions, err\n}", "func (m *MockUploadService) GetAuditLogsForUpload(v0 context.Context, v1 int) ([]types.UploadLog, error) {\n\tr0, r1 := m.GetAuditLogsForUploadFunc.nextHook()(v0, v1)\n\tm.GetAuditLogsForUploadFunc.appendCall(UploadServiceGetAuditLogsForUploadFuncCall{v0, v1, r0, r1})\n\treturn r0, r1\n}", "func TestGetStatusByIPAddressAtTimestamp3(t *testing.T) {\n\n\tbefore(t, dbStorage, dbSchema)\n\n\tprivateIPs := []string{\"44.33.22.11\"}\n\tpublicIPs := []string{\"88.77.66.55\"}\n\thostnames := []string{\"yahoo.com\"} // nolint\n\ttimestamp, _ := time.Parse(time.RFC3339, \"2019-08-09T08:29:35+00:00\")\n\n\tfakeCloudAssetChange := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames, timestamp, `arn`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\ttimestamp2, _ := time.Parse(time.RFC3339, \"2019-08-11T08:29:35+00:00\") // August 11\n\thostnames2 := []string{\"blarg.com\"}\n\tfakeCloudAssetChange2 := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames2, timestamp2, `arn2`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange2); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tipAddress := \"88.77.66.55\"\n\tat, _ := time.Parse(time.RFC3339, \"2019-08-12T08:29:35+00:00\") // query is for status on August 12\n\tnetworkChangeEvents, err := dbStorage.FetchByIP(ctx, at, ipAddress)\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tassert.Equal(t, 2, len(networkChangeEvents))\n\n\texpected := []domain.CloudAssetDetails{\n\t\tdomain.CloudAssetDetails{nil, []string{\"88.77.66.55\"}, []string{\"yahoo.com\"}, \"rtype\", \"aid\", \"region\", \"arn\", nil, domain.AccountOwner{}}, // nolint\n\t\tdomain.CloudAssetDetails{nil, []string{\"88.77.66.55\"}, []string{\"blarg.com\"}, \"rtype\", \"aid\", \"region\", \"arn2\", nil, domain.AccountOwner{}}, // nolint\n\t}\n\n\tassertArrayEqualIgnoreOrder(t, expected, networkChangeEvents)\n\n}", "func ListTrackedTimesByRepository(ctx *context.APIContext) {\n\t// swagger:operation GET /repos/{owner}/{repo}/times repository repoTrackedTimes\n\t// ---\n\t// summary: List a repo's tracked times\n\t// produces:\n\t// - application/json\n\t// parameters:\n\t// - name: owner\n\t// in: path\n\t// description: owner of the repo\n\t// type: string\n\t// required: true\n\t// - name: repo\n\t// in: path\n\t// description: name of the repo\n\t// type: string\n\t// required: true\n\t// - name: user\n\t// in: query\n\t// description: optional filter by user (available for issue managers)\n\t// type: string\n\t// - name: since\n\t// in: query\n\t// description: Only show times updated after the given time. This is a timestamp in RFC 3339 format\n\t// type: string\n\t// format: date-time\n\t// - name: before\n\t// in: query\n\t// description: Only show times updated before the given time. This is a timestamp in RFC 3339 format\n\t// type: string\n\t// format: date-time\n\t// - name: page\n\t// in: query\n\t// description: page number of results to return (1-based)\n\t// type: integer\n\t// - name: limit\n\t// in: query\n\t// description: page size of results\n\t// type: integer\n\t// responses:\n\t// \"200\":\n\t// \"$ref\": \"#/responses/TrackedTimeList\"\n\t// \"400\":\n\t// \"$ref\": \"#/responses/error\"\n\t// \"403\":\n\t// \"$ref\": \"#/responses/forbidden\"\n\n\tif !ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {\n\t\tctx.Error(http.StatusBadRequest, \"\", \"time tracking disabled\")\n\t\treturn\n\t}\n\n\topts := &issues_model.FindTrackedTimesOptions{\n\t\tListOptions: utils.GetListOptions(ctx),\n\t\tRepositoryID: ctx.Repo.Repository.ID,\n\t}\n\n\t// Filters\n\tqUser := ctx.FormTrim(\"user\")\n\tif qUser != \"\" {\n\t\tuser, err := user_model.GetUserByName(ctx, qUser)\n\t\tif user_model.IsErrUserNotExist(err) {\n\t\t\tctx.Error(http.StatusNotFound, \"User does not exist\", err)\n\t\t} else if err != nil {\n\t\t\tctx.Error(http.StatusInternalServerError, \"GetUserByName\", err)\n\t\t\treturn\n\t\t}\n\t\topts.UserID = user.ID\n\t}\n\n\tvar err error\n\tif opts.CreatedBeforeUnix, opts.CreatedAfterUnix, err = context.GetQueryBeforeSince(ctx.Base); err != nil {\n\t\tctx.Error(http.StatusUnprocessableEntity, \"GetQueryBeforeSince\", err)\n\t\treturn\n\t}\n\n\tcantSetUser := !ctx.Doer.IsAdmin &&\n\t\topts.UserID != ctx.Doer.ID &&\n\t\t!ctx.IsUserRepoWriter([]unit.Type{unit.TypeIssues})\n\n\tif cantSetUser {\n\t\tif opts.UserID == 0 {\n\t\t\topts.UserID = ctx.Doer.ID\n\t\t} else {\n\t\t\tctx.Error(http.StatusForbidden, \"\", fmt.Errorf(\"query by user not allowed; not enough rights\"))\n\t\t\treturn\n\t\t}\n\t}\n\n\tcount, err := issues_model.CountTrackedTimes(ctx, opts)\n\tif err != nil {\n\t\tctx.InternalServerError(err)\n\t\treturn\n\t}\n\n\ttrackedTimes, err := issues_model.GetTrackedTimes(ctx, opts)\n\tif err != nil {\n\t\tctx.Error(http.StatusInternalServerError, \"GetTrackedTimes\", err)\n\t\treturn\n\t}\n\tif err = trackedTimes.LoadAttributes(ctx); err != nil {\n\t\tctx.Error(http.StatusInternalServerError, \"LoadAttributes\", err)\n\t\treturn\n\t}\n\n\tctx.SetTotalCountHeader(count)\n\tctx.JSON(http.StatusOK, convert.ToTrackedTimeList(ctx, trackedTimes))\n}", "func (vdb *VspDatabase) GetVoteChanges(ticketHash string) (map[uint32]VoteChangeRecord, error) {\n\n\trecords := make(map[uint32]VoteChangeRecord)\n\n\terr := vdb.db.View(func(tx *bolt.Tx) error {\n\t\tbkt := tx.Bucket(vspBktK).Bucket(voteChangeBktK).\n\t\t\tBucket([]byte(ticketHash))\n\n\t\tif bkt == nil {\n\t\t\treturn nil\n\t\t}\n\n\t\terr := bkt.ForEach(func(k, v []byte) error {\n\t\t\tvar record VoteChangeRecord\n\t\t\terr := json.Unmarshal(v, &record)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"could not unmarshal vote change record: %w\", err)\n\t\t\t}\n\n\t\t\trecords[bytesToUint32(k)] = record\n\n\t\t\treturn nil\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error iterating over vote change bucket: %w\", err)\n\t\t}\n\n\t\treturn nil\n\t})\n\n\treturn records, err\n}", "func ListBlobs(ctx context.Context, accountName, accountGroupName, containerName string) (*azblob.ListBlobsFlatSegmentResponse, error) {\n\tu := getContainerURL(ctx, accountName, accountGroupName, containerName)\n\treturn u.ListBlobsFlatSegment(\n\t\tctx,\n\t\tazblob.Marker{},\n\t\tazblob.ListBlobsSegmentOptions{\n\t\t\tDetails: azblob.BlobListingDetails{\n\t\t\t\tSnapshots: true,\n\t\t\t},\n\t\t})\n}", "func (i *interactor) Diff(head, sha string) ([]string, error) {\n\ti.logger.Infof(\"Finding the differences between %q and %q\", head, sha)\n\tout, err := i.executor.Run(\"diff\", head, sha, \"--name-only\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar changes []string\n\tscan := bufio.NewScanner(bytes.NewReader(out))\n\tscan.Split(bufio.ScanLines)\n\tfor scan.Scan() {\n\t\tchanges = append(changes, scan.Text())\n\t}\n\treturn changes, nil\n}", "func (t *TrillianLogRPCServer) GetLeavesByRange(ctx context.Context, req *trillian.GetLeavesByRangeRequest) (*trillian.GetLeavesByRangeResponse, error) {\n\tctx, spanEnd := spanFor(ctx, \"GetLeavesByRange\")\n\tdefer spanEnd()\n\tif err := validateGetLeavesByRangeRequest(req); err != nil {\n\t\treturn nil, err\n\t}\n\n\ttree, ctx, err := t.getTreeAndContext(ctx, req.LogId, optsLogRead)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ttx, err := t.snapshotForTree(ctx, tree, \"GetLeavesByRange\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer t.closeAndLog(ctx, tree.TreeId, tx, \"GetLeavesByRange\")\n\n\tslr, err := tx.LatestSignedLogRoot(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar root types.LogRootV1\n\tif err := root.UnmarshalBinary(slr.LogRoot); err != nil {\n\t\treturn nil, status.Errorf(codes.Internal, \"Could not read current log root: %v\", err)\n\t}\n\n\tr := &trillian.GetLeavesByRangeResponse{SignedLogRoot: slr}\n\n\tif req.StartIndex < int64(root.TreeSize) {\n\t\tleaves, err := tx.GetLeavesByRange(ctx, req.StartIndex, req.Count)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tt.fetchedLeaves.Add(float64(len(leaves)))\n\t\tr.Leaves = leaves\n\t}\n\n\tif err := t.commitAndLog(ctx, req.LogId, tx, \"GetLeavesByRange\"); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn r, nil\n}", "func blobGets(fn string) string {\n\tf, err := os.Open(fn)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn \"\"\n\t\t}\n\t\tpanic(err)\n\t}\n\tdefer f.Close()\n\tpos := blobSeek(f)\n\tfi, err := f.Stat()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tb := make([]byte, int(fi.Size()-pos))\n\tif _, err = f.Read(b); err != nil {\n\t\tpanic(err)\n\t}\n\treturn string(b)\n}", "func FindFailedCommitQueuePatchesInTimeRange(projectID string, startTime, endTime time.Time) ([]Patch, error) {\n\tquery := bson.M{\n\t\tProjectKey: projectID,\n\t\tStatusKey: evergreen.PatchFailed,\n\t\tAliasKey: evergreen.CommitQueueAlias,\n\t\t\"$or\": []bson.M{\n\t\t\t{\"$and\": []bson.M{\n\t\t\t\t{StartTimeKey: bson.M{\"$lte\": endTime}},\n\t\t\t\t{StartTimeKey: bson.M{\"$gte\": startTime}},\n\t\t\t}},\n\t\t\t{\"$and\": []bson.M{\n\t\t\t\t{FinishTimeKey: bson.M{\"$lte\": endTime}},\n\t\t\t\t{FinishTimeKey: bson.M{\"$gte\": startTime}},\n\t\t\t}},\n\t\t},\n\t}\n\treturn Find(db.Query(query).Sort([]string{CreateTimeKey}))\n}", "func (sc *snapshotInfoContainer) RemoveRecentThanTS(tsVbuuid *common.TsVbuuid) error {\n\tnewList := list.New()\n\tts := getSeqTsFromTsVbuuid(tsVbuuid)\n\tfor e := sc.snapshotList.Front(); e != nil; e = e.Next() {\n\t\tsnapshot := e.Value.(SnapshotInfo)\n\t\tsnapTsVbuuid := snapshot.Timestamp()\n\t\tsnapTs := getSeqTsFromTsVbuuid(snapTsVbuuid)\n\n\t\tif !snapTs.GreaterThan(ts) {\n\t\t\tnewList.PushBack(snapshot)\n\t\t}\n\t}\n\n\tsc.snapshotList = newList\n\treturn nil\n}", "func BlobLT(v []byte) predicate.User {\n\treturn predicate.User(func(s *sql.Selector) {\n\t\ts.Where(sql.LT(s.C(FieldBlob), v))\n\t})\n}", "func TestGetStatusByIPAddressAtTimestamp1(t *testing.T) {\n\n\tbefore(t, dbStorage, dbSchema)\n\n\tprivateIPs := []string{\"44.33.22.11\"}\n\tpublicIPs := []string{\"88.77.66.55\"} // nolint\n\thostnames := []string{\"yahoo.com\"} // nolint\n\ttimestamp, _ := time.Parse(time.RFC3339, \"2019-08-09T08:29:35+00:00\")\n\n\tfakeCloudAssetChange := newFakeCloudAssetChange(privateIPs, publicIPs, hostnames, timestamp, `arn`, `rtype`, `aid`, `region`, nil, true)\n\tif err := dbStorage.Store(ctx, fakeCloudAssetChange); err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tipAddress := \"88.77.66.55\" // nolint\n\tat, _ := time.Parse(time.RFC3339, \"2019-08-10T08:29:35+00:00\")\n\tnetworkChangeEvents, err := dbStorage.FetchByIP(ctx, at, ipAddress)\n\tif err != nil {\n\t\tt.Fatal(err.Error())\n\t}\n\n\tassert.Equal(t, 1, len(networkChangeEvents))\n\n\texpected := []domain.CloudAssetDetails{\n\t\tdomain.CloudAssetDetails{nil, []string{\"88.77.66.55\"}, []string{\"yahoo.com\"}, \"rtype\", \"aid\", \"region\", \"arn\", nil, domain.AccountOwner{}}, // nolint\n\t}\n\n\tassertArrayEqualIgnoreOrder(t, expected, networkChangeEvents)\n\n}", "func (zh *zipHandler) blobList(dirPath string, dirBlob blob.Ref) ([]*blobFile, error) {\n\t//\tdr := zh.search.NewDescribeRequest()\n\t//\tdr.Describe(dirBlob, 3)\n\t//\tres, err := dr.Result()\n\t//\tif err != nil {\n\t//\t\treturn nil, fmt.Errorf(\"Could not describe %v: %v\", dirBlob, err)\n\t//\t}\n\tres, err := zh.describeMembers(dirBlob)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdescribed := res.Meta[dirBlob.String()]\n\tmembers := described.Members()\n\tdirBlobPath, _, isDir := described.PermanodeDir()\n\tif len(members) == 0 && !isDir {\n\t\treturn nil, nil\n\t}\n\tvar list []*blobFile\n\tif isDir {\n\t\tdirRoot := dirBlobPath[1]\n\t\tchildren, err := zh.blobsFromDir(\"/\", dirRoot)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Could not get list of blobs from %v: %v\", dirRoot, err)\n\t\t}\n\t\tlist = append(list, children...)\n\t\treturn list, nil\n\t}\n\tfor _, member := range members {\n\t\tif fileBlobPath, fileInfo, ok := getFileInfo(member.BlobRef, res.Meta); ok {\n\t\t\t// file\n\t\t\tlist = append(list,\n\t\t\t\t&blobFile{fileBlobPath[1], path.Join(dirPath, fileInfo.FileName)})\n\t\t\tcontinue\n\t\t}\n\t\tif dirBlobPath, dirInfo, ok := getDirInfo(member.BlobRef, res.Meta); ok {\n\t\t\t// directory\n\t\t\tnewZipRoot := dirBlobPath[1]\n\t\t\tchildren, err := zh.blobsFromDir(\n\t\t\t\tpath.Join(dirPath, dirInfo.FileName), newZipRoot)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Could not get list of blobs from %v: %v\", newZipRoot, err)\n\t\t\t}\n\t\t\tlist = append(list, children...)\n\t\t\t// TODO(mpl): we assume a directory permanode does not also have members.\n\t\t\t// I know there is nothing preventing it, but does it make any sense?\n\t\t\tcontinue\n\t\t}\n\t\t// it might have members, so recurse\n\t\t// If it does have members, we must consider it as a pseudo dir,\n\t\t// so we can build a fullpath for each of its members.\n\t\t// As a dir name, we're using its title if it has one, its (shortened)\n\t\t// blobref otherwise.\n\t\tpseudoDirName := member.Title()\n\t\tif pseudoDirName == \"\" {\n\t\t\tpseudoDirName = member.BlobRef.DigestPrefix(10)\n\t\t}\n\t\tfullpath := path.Join(dirPath, pseudoDirName)\n\t\tmoreMembers, err := zh.blobList(fullpath, member.BlobRef)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Could not get list of blobs from %v: %v\", member.BlobRef, err)\n\t\t}\n\t\tlist = append(list, moreMembers...)\n\t}\n\treturn list, nil\n}", "func (c *Client) ContainerChanges(id string) ([]Change, error) {\n\tpath := \"/containers/\" + id + \"/changes\"\n\tresp, err := c.do(http.MethodGet, path, doOptions{})\n\tif err != nil {\n\t\tvar e *Error\n\t\tif errors.As(err, &e) && e.Status == http.StatusNotFound {\n\t\t\treturn nil, &NoSuchContainer{ID: id}\n\t\t}\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tvar changes []Change\n\tif err := json.NewDecoder(resp.Body).Decode(&changes); err != nil {\n\t\treturn nil, err\n\t}\n\treturn changes, nil\n}", "func updatedTokens() []Token {\n\tdata := database.ReadFile(path)\n\tfmt.Println(\"Successfully opened tokens file\")\n\n\tvar tokens, validTokens []Token\n\tjson.Unmarshal(data, &tokens)\n\n\tfor i := 0; i < len(tokens); i++ {\n\t\tif time.Now().Unix()-tokens[i].CreatedAt < timeLimit {\n\t\t\tvalidTokens = append(validTokens, tokens[i])\n\t\t}\n\t}\n\n\tdata, err := json.Marshal(validTokens)\n\n\tif err != nil {\n\t\tlog.Fatal(\"[ERROR] Error in converting to JSON\\n\" + err.Error())\n\t}\n\n\tif err = database.WriteFile(path, data); err != nil {\n\t\tlog.Fatal(\"[ERROR] Unable to write in tokens file\\n\" + err.Error())\n\t}\n\n\treturn validTokens\n}", "func TestClient_GetModifiedFilesPagination(t *testing.T) {\n\trespTemplate := `\n{\n \"values\": [\n {\n \"path\": {\n \"toString\": \"%s\"\n }\n },\n {\n \"path\": {\n \"toString\": \"%s\"\n }\n }\n ],\n \"size\": 2,\n \"isLastPage\": true,\n \"start\": 0,\n \"limit\": 2,\n \"nextPageStart\": null\n}\n`\n\tfirstResp := fmt.Sprintf(respTemplate, \"file1.txt\", \"file2.txt\")\n\tsecondResp := fmt.Sprintf(respTemplate, \"file2.txt\", \"file3.txt\")\n\tvar serverURL string\n\n\ttestServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tswitch r.RequestURI {\n\t\t// The first request should hit this URL.\n\t\tcase \"/rest/api/1.0/projects/ow/repos/repo/pull-requests/1/changes?start=0\":\n\t\t\tresp := strings.Replace(firstResp, `\"isLastPage\": true`, `\"isLastPage\": false`, -1)\n\t\t\tresp = strings.Replace(resp, `\"nextPageStart\": null`, `\"nextPageStart\": 3`, -1)\n\t\t\tw.Write([]byte(resp)) // nolint: errcheck\n\t\t\treturn\n\t\t\t// The second should hit this URL.\n\t\tcase \"/rest/api/1.0/projects/ow/repos/repo/pull-requests/1/changes?start=3\":\n\t\t\tw.Write([]byte(secondResp)) // nolint: errcheck\n\t\tdefault:\n\t\t\tt.Errorf(\"got unexpected request at %q\", r.RequestURI)\n\t\t\thttp.Error(w, \"not found\", http.StatusNotFound)\n\t\t\treturn\n\t\t}\n\t}))\n\tdefer testServer.Close()\n\n\tserverURL = testServer.URL\n\tclient, err := bitbucketserver.NewClient(http.DefaultClient, \"user\", \"pass\", serverURL, \"runatlantis.io\")\n\tOk(t, err)\n\n\tfiles, err := client.GetModifiedFiles(models.Repo{\n\t\tFullName: \"owner/repo\",\n\t\tOwner: \"owner\",\n\t\tName: \"repo\",\n\t\tSanitizedCloneURL: fmt.Sprintf(\"%s/scm/ow/repo.git\", serverURL),\n\t\tVCSHost: models.VCSHost{\n\t\t\tType: models.BitbucketCloud,\n\t\t\tHostname: \"bitbucket.org\",\n\t\t},\n\t}, models.PullRequest{\n\t\tNum: 1,\n\t})\n\tOk(t, err)\n\tEquals(t, []string{\"file1.txt\", \"file2.txt\", \"file3.txt\"}, files)\n}", "func (f *UploadServiceGetListTagsFunc) History() []UploadServiceGetListTagsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]UploadServiceGetListTagsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func GetHistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\ttype KeyModificationWrapper struct {\n\t\tRealValue interface{} `json:\"InterfaceValue\"`\n\t\tTx queryresult.KeyModification\n\t}\n\tvar sliceReal []KeyModificationWrapper\n\n\tvar history []queryresult.KeyModification\n\tvar value interface{}\n\n\tif len(args) != 1 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 1\")\n\t}\n\n\tkey := args[0]\n\tfmt.Printf(\"- start GetHistory: %s\\n\", key)\n\n\t// Get History\n\tresultsIterator, err := stub.GetHistoryForKey(key)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tfor resultsIterator.HasNext() {\n\t\thistoryData, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\n\t\tvar singleReal KeyModificationWrapper\n\t\tvar tx queryresult.KeyModification\n\t\tsingleReal.Tx.TxId = historyData.TxId //copy transaction id over\n\t\tjson.Unmarshal(historyData.Value, &value) //un stringify it aka JSON.parse()\n\t\tif historyData.Value == nil { //value has been deleted\n\t\t\tvar emptyBytes []byte\n\t\t\tsingleReal.Tx.Value = emptyBytes //copy nil value\n\t\t} else {\n\t\t\tjson.Unmarshal(historyData.Value, &value) //un stringify it aka JSON.parse()\n\t\t\tsingleReal.Tx.Value = historyData.Value //copy value over\n\t\t\tsingleReal.Tx.Timestamp = historyData.Timestamp\n\t\t\tsingleReal.Tx.IsDelete = historyData.IsDelete\n\t\t\tsingleReal.RealValue = value\n\t\t}\n\t\thistory = append(history, tx) //add this Tx to the list\n\t\tsliceReal = append(sliceReal, singleReal)\n\t}\n\t// fmt.Printf(\"- getHistoryForService returning:\\n%s\", history)\n\tPrettyPrintHistory(history)\n\n\t//change to array of bytes\n\t// historyAsBytes, _ := json.Marshal(history) //convert to array of bytes\n\n\trealAsBytes, _ := json.Marshal(sliceReal)\n\treturn shim.Success(realAsBytes)\n}", "func (b *logEventBuffer) peekRange(start, end int64) []fetchedLog {\n\tb.lock.RLock()\n\tdefer b.lock.RUnlock()\n\n\tblocksInRange := b.getBlocksInRange(int(start), int(end))\n\n\tvar results []fetchedLog\n\tfor _, block := range blocksInRange {\n\t\t// double checking that we don't have any gaps in the range\n\t\tif block.blockNumber < start || block.blockNumber > end {\n\t\t\tcontinue\n\t\t}\n\t\tresults = append(results, block.logs...)\n\t}\n\n\tsort.SliceStable(results, func(i, j int) bool {\n\t\treturn results[i].log.BlockNumber < results[j].log.BlockNumber\n\t})\n\n\tb.lggr.Debugw(\"Peeked logs\", \"results\", len(results), \"start\", start, \"end\", end)\n\n\treturn results\n}", "func (_TellorMesosphere *TellorMesosphereCaller) Timestamps(opts *bind.CallOpts, arg0 *big.Int, arg1 *big.Int) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _TellorMesosphere.contract.Call(opts, &out, \"timestamps\", arg0, arg1)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}" ]
[ "0.5353702", "0.50202537", "0.4984611", "0.49060214", "0.4898732", "0.4884065", "0.48787692", "0.48241475", "0.48237765", "0.47981906", "0.47307202", "0.47307202", "0.47245994", "0.4690016", "0.4667888", "0.46565905", "0.46333495", "0.45517814", "0.45401368", "0.4535804", "0.45274872", "0.44983017", "0.44820955", "0.44628102", "0.44481578", "0.44253832", "0.44161403", "0.44023532", "0.43945006", "0.4386002", "0.43805748", "0.4376409", "0.43416312", "0.4338946", "0.43111756", "0.43102202", "0.4310045", "0.43051895", "0.43050998", "0.43029574", "0.43022552", "0.4297824", "0.429432", "0.4293291", "0.42920136", "0.42887828", "0.4287077", "0.4279522", "0.42738897", "0.4266608", "0.42665768", "0.42652637", "0.42519894", "0.42077488", "0.41997457", "0.41974163", "0.41957626", "0.41826916", "0.41823816", "0.4182345", "0.4178998", "0.41766602", "0.41760632", "0.4173336", "0.41719788", "0.41718662", "0.41497588", "0.41473207", "0.41401494", "0.41351628", "0.4131712", "0.41244298", "0.41228244", "0.41227216", "0.41150948", "0.41127792", "0.41104534", "0.4106742", "0.41015577", "0.40908805", "0.40903997", "0.4083502", "0.4079127", "0.40738612", "0.40664086", "0.40662745", "0.40654987", "0.4061564", "0.40605563", "0.4052441", "0.40480652", "0.40476853", "0.40475821", "0.40470845", "0.40412357", "0.4038616", "0.40349832", "0.40332216", "0.40303028", "0.40270504" ]
0.8394095
0
ReadBlobData Reads blob from specified starting location
ReadBlobData считывает боб из указанного начального положения
func (sr *StorageReader) ReadBlobData(path string, startIndex, length int64) []byte { ctx := context.Background() blobURL := sr.container.NewBlockBlobURL(path) downloadResponse, err := blobURL.Download(ctx, startIndex, length, azblob.BlobAccessConditions{}, false) logp.Info("Attempting to download blob %s at %v", path, startIndex) bodyStream := downloadResponse.Body(azblob.RetryReaderOptions{MaxRetryRequests: 10}) downloadedData := bytes.Buffer{} _, err = downloadedData.ReadFrom(bodyStream) if err != nil { panic(err) } return downloadedData.Bytes() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func ReadBlob(length int32, data []byte) ([]byte, int64) {\n\tl := length\n\tif length > int32(len(data)) {\n\t\tl = int32(len(data))\n\t}\n\n\tvar idx int32\n\tfor idx = l; (idx % 4) != 0; idx++ {\n\t\tif idx >= int32(len(data)) {\n\t\t\tdata = append(data, 0)\n\t\t}\n\t}\n\treturn data[:idx], int64(idx)\n}", "func (fh *FilesystemHandler) ReadBlob(container models.SimpleContainer, blobName string) models.SimpleBlob {\n\tvar blob models.SimpleBlob\n\n\tdirPath := fh.generateFullPath(&container)\n\tfullPath := filepath.Join(dirPath, blobName)\n\n\tblob.DataCachedAtPath = fullPath\n\tblob.BlobInMemory = false\n\tblob.Name = blobName\n\tblob.ParentContainer = &container\n\tblob.Origin = container.Origin\n\tblob.URL = fullPath\n\treturn blob\n}", "func readBlob(nd *Node) *Blob {\n\treturn nd.ReadMemo(blobNodeKey{}, func() interface{} {\n\t\tfn := nd.Path()\n\t\tsrc, err := ioutil.ReadFile(fn)\n\t\tif err != nil {\n\t\t\treturn &Blob{err: err}\n\t\t}\n\t\treturn &Blob{src: src}\n\t}).(*Blob)\n}", "func blobSeek(r io.ReadSeeker) int64 {\n\tvar b [1]byte\n\t_, err := r.Seek(BlobNameLenOff, os.SEEK_SET)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t_, err = r.Read(b[:])\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tn, err := r.Seek(int64(b[0]), os.SEEK_CUR)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}", "func blobSeek(r io.ReadSeeker) int64 {\n\tvar b [1]byte\n\t_, err := r.Seek(BlobNameLenOff, os.SEEK_SET)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t_, err = r.Read(b[:])\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tn, err := r.Seek(int64(b[0]), os.SEEK_CUR)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}", "func (d *swiftDriver) ReadBlob(account keppel.Account, storageID string) (io.ReadCloser, uint64, error) {\n\tc, _, err := d.getBackendConnection(account)\n\tif err != nil {\n\t\treturn nil, 0, err\n\t}\n\to := blobObject(c, storageID)\n\thdr, err := o.Headers()\n\tif err != nil {\n\t\treturn nil, 0, err\n\t}\n\treader, err := o.Download(nil).AsReadCloser()\n\treturn reader, hdr.SizeBytes().Get(), err\n}", "func (b Base) GetBlob(sum string) (ReadSeekCloser, error) {\n\treturn os.Open(b.blobPath(sum))\n}", "func (c *containerdCAS) ReadBlob(blobHash string) (io.Reader, error) {\n\tshaDigest := digest.Digest(blobHash)\n\t_, err := contentStore.Info(ctrdCtx, shaDigest)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"ReadBlob: Exception getting info of blob: %s. %s\", blobHash, err.Error())\n\t}\n\treaderAt, err := contentStore.ReaderAt(ctrdCtx, spec.Descriptor{Digest: shaDigest})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"ReadBlob: Exception while reading blob: %s. %s\", blobHash, err.Error())\n\t}\n\treturn content.NewReader(readerAt), nil\n}", "func (is *ObjectStorage) GetBlobPartial(repo string, digest godigest.Digest, mediaType string, from, to int64,\n) (io.ReadCloser, int64, int64, error) {\n\tvar lockLatency time.Time\n\n\tif err := digest.Validate(); err != nil {\n\t\treturn nil, -1, -1, err\n\t}\n\n\tblobPath := is.BlobPath(repo, digest)\n\n\tis.RLock(&lockLatency)\n\tdefer is.RUnlock(&lockLatency)\n\n\tbinfo, err := is.store.Stat(context.Background(), blobPath)\n\tif err != nil {\n\t\tis.log.Error().Err(err).Str(\"blob\", blobPath).Msg(\"failed to stat blob\")\n\n\t\treturn nil, -1, -1, zerr.ErrBlobNotFound\n\t}\n\n\tend := to\n\n\tif to < 0 || to >= binfo.Size() {\n\t\tend = binfo.Size() - 1\n\t}\n\n\tblobHandle, err := is.store.Reader(context.Background(), blobPath, from)\n\tif err != nil {\n\t\tis.log.Error().Err(err).Str(\"blob\", blobPath).Msg(\"failed to open blob\")\n\n\t\treturn nil, -1, -1, err\n\t}\n\n\tblobReadCloser, err := NewBlobStream(blobHandle, from, end)\n\tif err != nil {\n\t\tis.log.Error().Err(err).Str(\"blob\", blobPath).Msg(\"failed to open blob stream\")\n\n\t\treturn nil, -1, -1, err\n\t}\n\n\t// is a 'deduped' blob?\n\tif binfo.Size() == 0 {\n\t\tdefer blobReadCloser.Close()\n\n\t\t// Check blobs in cache\n\t\tdstRecord, err := is.checkCacheBlob(digest)\n\t\tif err != nil {\n\t\t\tis.log.Error().Err(err).Str(\"digest\", digest.String()).Msg(\"cache: not found\")\n\n\t\t\treturn nil, -1, -1, zerr.ErrBlobNotFound\n\t\t}\n\n\t\tbinfo, err := is.store.Stat(context.Background(), dstRecord)\n\t\tif err != nil {\n\t\t\tis.log.Error().Err(err).Str(\"blob\", dstRecord).Msg(\"failed to stat blob\")\n\n\t\t\treturn nil, -1, -1, zerr.ErrBlobNotFound\n\t\t}\n\n\t\tend := to\n\n\t\tif to < 0 || to >= binfo.Size() {\n\t\t\tend = binfo.Size() - 1\n\t\t}\n\n\t\tblobHandle, err := is.store.Reader(context.Background(), dstRecord, from)\n\t\tif err != nil {\n\t\t\tis.log.Error().Err(err).Str(\"blob\", dstRecord).Msg(\"failed to open blob\")\n\n\t\t\treturn nil, -1, -1, err\n\t\t}\n\n\t\tblobReadCloser, err := NewBlobStream(blobHandle, from, end)\n\t\tif err != nil {\n\t\t\tis.log.Error().Err(err).Str(\"blob\", blobPath).Msg(\"failed to open blob stream\")\n\n\t\t\treturn nil, -1, -1, err\n\t\t}\n\n\t\treturn blobReadCloser, end - from + 1, binfo.Size(), nil\n\t}\n\n\t// The caller function is responsible for calling Close()\n\treturn blobReadCloser, end - from + 1, binfo.Size(), nil\n}", "func (s *server) ReadBlob(ctx context.Context, req *pb.ReadBlobRequest) (*pb.ReadBlobResponse, error) {\n\n\t// Run a Get request to Azure with the incoming blob key\n\tresp, err := http.Get(strings.Join([]string{base_uri,req.Key},\"\"))\n\tif err != nil {\n\t\tlog.Fatalf(\"failed get request: %v\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\t// Read the body of the http response containing the blob data\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed response read: %v\", err)\n\t}\n\n\t// Return the body of the response to the client\n\treturn &pb.ReadBlobResponse{Data: body}, nil\n}", "func (r *azblobObjectReader) Read(p []byte) (n int, err error) {\n\tmaxCnt := r.totalSize - r.pos\n\tif maxCnt > int64(len(p)) {\n\t\tmaxCnt = int64(len(p))\n\t}\n\tif maxCnt == 0 {\n\t\treturn 0, io.EOF\n\t}\n\tresp, err := r.blobClient.DownloadStream(r.ctx, &blob.DownloadStreamOptions{\n\t\tRange: blob.HTTPRange{\n\t\t\tOffset: r.pos,\n\t\t\tCount: maxCnt,\n\t\t},\n\n\t\tCPKInfo: r.cpkInfo,\n\t})\n\tif err != nil {\n\t\treturn 0, errors.Annotatef(err, \"Failed to read data from azure blob, data info: pos='%d', count='%d'\", r.pos, maxCnt)\n\t}\n\tbody := resp.NewRetryReader(r.ctx, &blob.RetryReaderOptions{\n\t\tMaxRetries: azblobRetryTimes,\n\t})\n\tn, err = body.Read(p)\n\tif err != nil && err != io.EOF {\n\t\treturn 0, errors.Annotatef(err, \"Failed to read data from azure blob response, data info: pos='%d', count='%d'\", r.pos, maxCnt)\n\t}\n\tr.pos += int64(n)\n\treturn n, body.Close()\n}", "func (fr *FileReader) readerForOffset(off int64) (io.ReadCloser, error) {\n\tif off < 0 {\n\t\tpanic(\"negative offset\")\n\t}\n\tif off >= fr.size {\n\t\treturn eofReader, nil\n\t}\n\toffRemain := off\n\tparts := fr.ss.Parts\n\tfor len(parts) > 0 && parts[0].Size <= uint64(offRemain) {\n\t\toffRemain -= int64(parts[0].Size)\n\t\tparts = parts[1:]\n\t}\n\tif len(parts) == 0 {\n\t\treturn eofReader, nil\n\t}\n\tp0 := parts[0]\n\tvar rsc blobref.ReadSeekCloser\n\tvar err error\n\tswitch {\n\tcase p0.BlobRef != nil && p0.BytesRef != nil:\n\t\treturn nil, fmt.Errorf(\"part illegally contained both a blobRef and bytesRef\")\n\tcase p0.BlobRef == nil && p0.BytesRef == nil:\n\t\treturn &nZeros{int(p0.Size - uint64(offRemain))}, nil\n\tcase p0.BlobRef != nil:\n\t\trsc, _, err = fr.fetcher.Fetch(p0.BlobRef)\n\tcase p0.BytesRef != nil:\n\t\trsc, err = NewFileReader(fr.fetcher, p0.BytesRef)\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\toffRemain += int64(p0.Offset)\n\tif offRemain > 0 {\n\t\tnewPos, err := rsc.Seek(offRemain, os.SEEK_SET)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif newPos != offRemain {\n\t\t\tpanic(\"Seek didn't work\")\n\t\t}\n\t}\n\treturn struct {\n\t\tio.Reader\n\t\tio.Closer\n\t}{\n\t\tio.LimitReader(rsc, int64(p0.Size)),\n\t\trsc,\n\t}, nil\n}", "func blobGets(fn string) string {\n\tf, err := os.Open(fn)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn \"\"\n\t\t}\n\t\tpanic(err)\n\t}\n\tdefer f.Close()\n\tpos := blobSeek(f)\n\tfi, err := f.Stat()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tb := make([]byte, int(fi.Size()-pos))\n\tif _, err = f.Read(b); err != nil {\n\t\tpanic(err)\n\t}\n\treturn string(b)\n}", "func BlobSeek(r io.ReadSeeker) (n int64, err error) {\n\tdefer func() {\n\t\tif perr := recover(); perr != nil {\n\t\t\terr = perr.(error)\n\t\t}\n\t}()\n\tn = blobSeek(r)\n\treturn\n}", "func BlobSeek(r io.ReadSeeker) (n int64, err error) {\n\tdefer func() {\n\t\tif perr := recover(); perr != nil {\n\t\t\terr = perr.(error)\n\t\t}\n\t}()\n\tn = blobSeek(r)\n\treturn\n}", "func (c *INDIClient) GetBlob(deviceName, propName, blobName string) (rdr io.ReadCloser, fileName string, length int64, err error) {\n\tdevice, err := c.findDevice(deviceName)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tprop, ok := device.BlobProperties[propName]\n\tif !ok {\n\t\terr = ErrPropertyNotFound\n\t\treturn\n\t}\n\n\tval, ok := prop.Values[blobName]\n\tif !ok {\n\t\terr = ErrPropertyValueNotFound\n\t\treturn\n\t}\n\n\trdr, err = c.fs.Open(val.Value)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tfileName = filepath.Base(val.Value)\n\n\tlength = val.Size\n\treturn\n}", "func ReadPointer(reader io.Reader) (Pointer, error) {\n\tbuf := make([]byte, blobSizeCutoff)\n\tn, err := io.ReadFull(reader, buf)\n\tif err != nil && err != io.ErrUnexpectedEOF {\n\t\treturn Pointer{}, err\n\t}\n\tbuf = buf[:n]\n\n\treturn ReadPointerFromBuffer(buf)\n}", "func (d *DriveDB) ReadFiledata(f *File, offset, size, filesize int64) ([]byte, error) {\n\tvar ret []byte\n\t// Read all the necessary chunks\n\tchunk0, chunkN := d.chunkNumbers(offset, size)\n\tfor chunk := chunk0; chunk <= chunkN; chunk++ {\n\t\tdata, err := d.readChunk(f, chunk, filesize)\n\t\tif err != nil {\n\t\t\tlog.Printf(\" chunk %v read error: %v\", chunk, err)\n\t\t\treturn nil, err\n\t\t}\n\t\tret = append(ret, data...)\n\t}\n\n\t// We may have too much data here -- before offset and after end. Return an appropriate slice.\n\tdsize := int64(len(ret))\n\tlow := offset - chunk0*(*driveCacheChunk)\n\tif low < 0 {\n\t\tlow = 0\n\t}\n\tif low > dsize {\n\t\treturn nil, fmt.Errorf(\"tried to read past end of chunk (low:%d, dsize:%d): fileId: %s, offset:%d, size:%d, filesize:%d\", low, dsize, f.Id, offset, size, filesize)\n\t}\n\thigh := low + size\n\tif high > dsize {\n\t\thigh = dsize\n\t}\n\tbuf := ret[low:high]\n\treturn buf, nil\n}", "func FileReadAt(f *os.File, b []byte, off int64) (int, error)", "func (is *ObjectStorage) GetBlob(repo string, digest godigest.Digest, mediaType string) (io.ReadCloser, int64, error) {\n\tvar lockLatency time.Time\n\n\tif err := digest.Validate(); err != nil {\n\t\treturn nil, -1, err\n\t}\n\n\tblobPath := is.BlobPath(repo, digest)\n\n\tis.RLock(&lockLatency)\n\tdefer is.RUnlock(&lockLatency)\n\n\tbinfo, err := is.store.Stat(context.Background(), blobPath)\n\tif err != nil {\n\t\tis.log.Error().Err(err).Str(\"blob\", blobPath).Msg(\"failed to stat blob\")\n\n\t\treturn nil, -1, zerr.ErrBlobNotFound\n\t}\n\n\tblobReadCloser, err := is.store.Reader(context.Background(), blobPath, 0)\n\tif err != nil {\n\t\tis.log.Error().Err(err).Str(\"blob\", blobPath).Msg(\"failed to open blob\")\n\n\t\treturn nil, -1, err\n\t}\n\n\t// is a 'deduped' blob?\n\tif binfo.Size() == 0 {\n\t\t// Check blobs in cache\n\t\tdstRecord, err := is.checkCacheBlob(digest)\n\t\tif err != nil {\n\t\t\tis.log.Error().Err(err).Str(\"digest\", digest.String()).Msg(\"cache: not found\")\n\n\t\t\treturn nil, -1, zerr.ErrBlobNotFound\n\t\t}\n\n\t\tbinfo, err := is.store.Stat(context.Background(), dstRecord)\n\t\tif err != nil {\n\t\t\tis.log.Error().Err(err).Str(\"blob\", dstRecord).Msg(\"failed to stat blob\")\n\n\t\t\treturn nil, -1, zerr.ErrBlobNotFound\n\t\t}\n\n\t\tblobReadCloser, err := is.store.Reader(context.Background(), dstRecord, 0)\n\t\tif err != nil {\n\t\t\tis.log.Error().Err(err).Str(\"blob\", dstRecord).Msg(\"failed to open blob\")\n\n\t\t\treturn nil, -1, err\n\t\t}\n\n\t\treturn blobReadCloser, binfo.Size(), nil\n\t}\n\n\t// The caller function is responsible for calling Close()\n\treturn blobReadCloser, binfo.Size(), nil\n}", "func readFileAtOffset(file *os.File, offset int, size int) []byte {\n\tbytes := make([]byte, size)\n\tfile.Seek(int64(offset), 0)\n\n\tdata, err := file.Read(bytes)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn bytes[:data]\n}", "func SMBExtractValueFromOffset(blob []byte, idx int) ([]byte, int, error) {\n\tres := []byte{}\n\n\tif len(blob) < (idx + 6) {\n\t\treturn res, idx, fmt.Errorf(\"data truncated\")\n\t}\n\n\tlen1 := binary.LittleEndian.Uint16(blob[idx:])\n\tidx += 2\n\n\t// len2 := binary.LittleEndian.Uint16(blob[idx:])\n\tidx += 2\n\n\toff := binary.LittleEndian.Uint32(blob[idx:])\n\tidx += 4\n\n\t// Allow zero length values\n\tif len1 == 0 {\n\t\treturn res, idx, nil\n\t}\n\n\tif len(blob) < int(off+uint32(len1)) {\n\t\treturn res, idx, fmt.Errorf(\"data value truncated\")\n\t}\n\n\tres = append(res, blob[off:off+uint32(len1)]...)\n\treturn res, idx, nil\n}", "func (is *ImageStoreLocal) GetBlobPartial(repo string, digest godigest.Digest, mediaType string, from, to int64,\n) (io.ReadCloser, int64, int64, error) {\n\tvar lockLatency time.Time\n\n\tif err := digest.Validate(); err != nil {\n\t\treturn nil, -1, -1, err\n\t}\n\n\tblobPath := is.BlobPath(repo, digest)\n\n\tis.RLock(&lockLatency)\n\tdefer is.RUnlock(&lockLatency)\n\n\tbinfo, err := os.Stat(blobPath)\n\tif err != nil {\n\t\tis.log.Debug().Err(err).Str(\"blob\", blobPath).Msg(\"failed to stat blob\")\n\n\t\treturn nil, -1, -1, zerr.ErrBlobNotFound\n\t}\n\n\tif to < 0 || to >= binfo.Size() {\n\t\tto = binfo.Size() - 1\n\t}\n\n\tblobReadCloser, err := newBlobStream(blobPath, from, to)\n\tif err != nil {\n\t\tis.log.Debug().Err(err).Str(\"blob\", blobPath).Msg(\"failed to open blob\")\n\n\t\treturn nil, -1, -1, err\n\t}\n\n\t// The caller function is responsible for calling Close()\n\treturn blobReadCloser, to - from + 1, binfo.Size(), nil\n}", "func FromDataBlob(blob *serialization.DataBlob) ([]byte, string) {\n\tif blob == nil || len(blob.Data) == 0 {\n\t\treturn nil, \"\"\n\t}\n\treturn blob.Data, string(blob.Encoding)\n}", "func (r *Repository) PullBlob(digest string) (size int64, data io.ReadCloser, err error) {\n\treq, err := http.NewRequest(\"GET\", buildBlobURL(r.Endpoint.String(), r.Name, digest), nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tresp, err := r.client.Do(req)\n\tif err != nil {\n\t\terr = parseError(err)\n\t\treturn\n\t}\n\n\tif resp.StatusCode == http.StatusOK {\n\t\tcontengLength := resp.Header.Get(http.CanonicalHeaderKey(\"Content-Length\"))\n\t\tsize, err = strconv.ParseInt(contengLength, 10, 64)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tdata = resp.Body\n\t\treturn\n\t}\n\t// can not close the connect if the status code is 200\n\tdefer resp.Body.Close()\n\n\tb, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn\n\t}\n\n\terr = &commonhttp.Error{\n\t\tCode: resp.StatusCode,\n\t\tMessage: string(b),\n\t}\n\n\treturn\n}", "func (h *Handler) readOneBlob(ctx context.Context, getTime *timeReadWrite,\n\tserviceController controller.ServiceController,\n\tblob blobGetArgs, sortedVuids []sortedVuid, shards [][]byte) error {\n\tspan := trace.SpanFromContextSafe(ctx)\n\n\ttactic := blob.CodeMode.Tactic()\n\tsizes, err := ec.GetBufferSizes(int(blob.BlobSize), tactic)\n\tif err != nil {\n\t\treturn err\n\t}\n\tempties := emptyDataShardIndexes(sizes)\n\n\tdataN, dataParityN := tactic.N, tactic.N+tactic.M\n\tminShardsRead := dataN + h.MinReadShardsX\n\tif minShardsRead > len(sortedVuids) {\n\t\tminShardsRead = len(sortedVuids)\n\t}\n\tshardSize, shardOffset, shardReadSize := blob.ShardSize, blob.ShardOffset, blob.ShardReadSize\n\n\tstopChan := make(chan struct{})\n\tnextChan := make(chan struct{}, len(sortedVuids))\n\tshardPipe := func() <-chan shardData {\n\t\tch := make(chan shardData)\n\t\tgo func() {\n\t\t\twg := new(sync.WaitGroup)\n\t\t\tdefer func() {\n\t\t\t\twg.Wait()\n\t\t\t\tclose(ch)\n\t\t\t}()\n\n\t\t\tfor _, vuid := range sortedVuids[:minShardsRead] {\n\t\t\t\tif _, ok := empties[vuid.index]; !ok {\n\t\t\t\t\twg.Add(1)\n\t\t\t\t\tgo func(vuid sortedVuid) {\n\t\t\t\t\t\tch <- h.readOneShard(ctx, serviceController, blob, vuid, stopChan)\n\t\t\t\t\t\twg.Done()\n\t\t\t\t\t}(vuid)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor _, vuid := range sortedVuids[minShardsRead:] {\n\t\t\t\tif _, ok := empties[vuid.index]; ok {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tselect {\n\t\t\t\tcase <-stopChan:\n\t\t\t\t\treturn\n\t\t\t\tcase <-nextChan:\n\t\t\t\t}\n\n\t\t\t\twg.Add(1)\n\t\t\t\tgo func(vuid sortedVuid) {\n\t\t\t\t\tch <- h.readOneShard(ctx, serviceController, blob, vuid, stopChan)\n\t\t\t\t\twg.Done()\n\t\t\t\t}(vuid)\n\t\t\t}\n\t\t}()\n\n\t\treturn ch\n\t}()\n\n\treceived := make(map[int]bool, minShardsRead)\n\tfor idx := range empties {\n\t\treceived[idx] = true\n\t\th.memPool.Zero(shards[idx])\n\t}\n\n\tstartRead := time.Now()\n\treconstructed := false\n\tfor shard := range shardPipe {\n\t\t// swap shard buffer\n\t\tif shard.status {\n\t\t\tbuf := shards[shard.index]\n\t\t\tshards[shard.index] = shard.buffer\n\t\t\th.memPool.Put(buf)\n\t\t}\n\n\t\treceived[shard.index] = shard.status\n\t\tif len(received) < dataN {\n\t\t\tcontinue\n\t\t}\n\n\t\t// bad data index\n\t\tbadIdx := make([]int, 0, 8)\n\t\tfor i := 0; i < dataN; i++ {\n\t\t\tif succ, ok := received[i]; !ok || !succ {\n\t\t\t\tbadIdx = append(badIdx, i)\n\t\t\t}\n\t\t}\n\t\tif len(badIdx) == 0 {\n\t\t\treconstructed = true\n\t\t\tclose(stopChan)\n\t\t\tbreak\n\t\t}\n\n\t\t// update bad parity index\n\t\tfor i := dataN; i < dataParityN; i++ {\n\t\t\tif succ, ok := received[i]; !ok || !succ {\n\t\t\t\tbadIdx = append(badIdx, i)\n\t\t\t}\n\t\t}\n\n\t\tbadShards := 0\n\t\tfor _, succ := range received {\n\t\t\tif !succ {\n\t\t\t\tbadShards++\n\t\t\t}\n\t\t}\n\t\t// it will not wait all the shards, cos has no enough shards to reconstruct\n\t\tif badShards > dataParityN-dataN {\n\t\t\tspan.Infof(\"%s bad(%d) has no enough to reconstruct\", blob.ID(), badShards)\n\t\t\tclose(stopChan)\n\t\t\tbreak\n\t\t}\n\n\t\t// has bad shards, but have enough shards to reconstruct\n\t\tif len(received) >= dataN+badShards {\n\t\t\tvar err error\n\t\t\tif shardReadSize < shardSize {\n\t\t\t\tspan.Debugf(\"bid(%d) ready to segment ec reconstruct data\", blob.Bid)\n\t\t\t\treportDownload(blob.Cid, \"EC\", \"segment\")\n\t\t\t\tsegments := make([][]byte, len(shards))\n\t\t\t\tfor idx := range shards {\n\t\t\t\t\tsegments[idx] = shards[idx][shardOffset : shardOffset+shardReadSize]\n\t\t\t\t}\n\t\t\t\terr = h.encoder[blob.CodeMode].ReconstructData(segments, badIdx)\n\t\t\t} else {\n\t\t\t\tspan.Debugf(\"bid(%d) ready to ec reconstruct data\", blob.Bid)\n\t\t\t\terr = h.encoder[blob.CodeMode].ReconstructData(shards, badIdx)\n\t\t\t}\n\t\t\tif err == nil {\n\t\t\t\treconstructed = true\n\t\t\t\tclose(stopChan)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tspan.Errorf(\"%s ec reconstruct data error:%s\", blob.ID(), err.Error())\n\t\t}\n\n\t\tif len(received) >= len(sortedVuids) {\n\t\t\tclose(stopChan)\n\t\t\tbreak\n\t\t}\n\t\tnextChan <- struct{}{}\n\t}\n\tgetTime.IncR(time.Since(startRead))\n\n\t// release buffer of delayed shards\n\tgo func() {\n\t\tfor shard := range shardPipe {\n\t\t\tif shard.status {\n\t\t\t\th.memPool.Put(shard.buffer)\n\t\t\t}\n\t\t}\n\t}()\n\n\tif reconstructed {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"broken %s\", blob.ID())\n}", "func (s *AzureBlobStorage) ReadFile(ctx context.Context, name string) ([]byte, error) {\n\tclient := s.containerClient.NewBlockBlobClient(s.withPrefix(name))\n\tresp, err := client.DownloadStream(ctx, &blob.DownloadStreamOptions{\n\t\tCPKInfo: s.cpkInfo,\n\t})\n\tif err != nil {\n\t\treturn nil, errors.Annotatef(err, \"Failed to download azure blob file, file info: bucket(container)='%s', key='%s'\", s.options.Bucket, s.withPrefix(name))\n\t}\n\tbody := resp.NewRetryReader(ctx, &blob.RetryReaderOptions{\n\t\tMaxRetries: azblobRetryTimes,\n\t})\n\tdata, err := io.ReadAll(body)\n\tif err != nil {\n\t\treturn nil, errors.Annotatef(err, \"Failed to read azure blob file, file info: bucket(container)='%s', key='%s'\", s.options.Bucket, s.withPrefix(name))\n\t}\n\treturn data, body.Close()\n}", "func (w *wrapped) GetBlobAt(ctx context.Context, info types.BlobInfo, chunks []private.ImageSourceChunk) (chan io.ReadCloser, chan error, error) {\n\treturn nil, nil, fmt.Errorf(\"internal error: GetBlobAt is not supported by the %q transport\", w.Reference().Transport().Name())\n}", "func ReadBytes(ctx context.Context, filename string) ([]byte, error) {\n\tif strings.HasPrefix(filename, \"gs://\") {\n\t\treturn readGCSObject(ctx, filename)\n\t}\n\treturn ioutil.ReadFile(filename)\n}", "func (b *ByteArray) ReadSeek(offset int, whence int) (absolute int, err error) {\n\tswitch whence {\n\tcase SEEK_SET:\n\t\tabsolute = offset\n\tcase SEEK_CUR:\n\t\tabsolute = b.readPos.current + offset\n\tcase SEEK_END:\n\t\tabsolute = b.usedBytes - offset\n\t}\n\tif absolute < 0 {\n\t\tabsolute = 0\n\t\terr = io.EOF\n\t}\n\tif absolute > b.usedBytes {\n\t\tabsolute = b.usedBytes\n\t\terr = io.EOF\n\t}\n\tb.readPos = b.seek(b.readPos, absolute, SEEK_SET)\n\treturn b.readPos.current, err\n}", "func (mcm *MinioChunkManager) ReadAt(ctx context.Context, filePath string, off int64, length int64) ([]byte, error) {\n\tif off < 0 || length < 0 {\n\t\treturn nil, io.EOF\n\t}\n\n\topts := minio.GetObjectOptions{}\n\terr := opts.SetRange(off, off+length-1)\n\tif err != nil {\n\t\tlog.Warn(\"failed to set range\", zap.String(\"bucket\", mcm.bucketName), zap.String(\"path\", filePath), zap.Error(err))\n\t\treturn nil, err\n\t}\n\n\tobject, err := mcm.getMinioObject(ctx, mcm.bucketName, filePath, opts)\n\tif err != nil {\n\t\tlog.Warn(\"failed to get object\", zap.String(\"bucket\", mcm.bucketName), zap.String(\"path\", filePath), zap.Error(err))\n\t\treturn nil, err\n\t}\n\tdefer object.Close()\n\n\tdata, err := Read(object, length)\n\tif err != nil {\n\t\terrResponse := minio.ToErrorResponse(err)\n\t\tif errResponse.Code == \"NoSuchKey\" {\n\t\t\treturn nil, WrapErrNoSuchKey(filePath)\n\t\t}\n\t\tlog.Warn(\"failed to read object\", zap.String(\"bucket\", mcm.bucketName), zap.String(\"path\", filePath), zap.Error(err))\n\t\treturn nil, err\n\t}\n\tmetrics.PersistentDataKvSize.WithLabelValues(metrics.DataGetLabel).Observe(float64(length))\n\treturn data, nil\n}", "func (q *QQwry) readData(num int, offset ...int64) (rs []byte) {\n\tif len(offset) > 0 {\n\t\tq.setOffset(offset[0])\n\t}\n\tnums := int64(num)\n\tend := q.Offset + nums\n\tdataNum := int64(len(q.Data.Data))\n\tif q.Offset > dataNum {\n\t\treturn nil\n\t}\n\n\tif end > dataNum {\n\t\tend = dataNum\n\t}\n\trs = q.Data.Data[q.Offset:end]\n\tq.Offset = end\n\treturn\n}", "func (sto *unionStorage) ReceiveBlob(ctx context.Context, br blob.Ref, src io.Reader) (sb blob.SizedRef, err error) {\n\treturn blob.SizedRef{}, blobserver.ErrReadonly\n}", "func peekBlob(nd *Node) *Blob {\n\tb, _ := nd.PeekMemo(blobNodeKey{}).(*Blob)\n\treturn b\n}", "func DecodeBlob(b []byte, preAlloc ...int) (byte, [][]byte, error) {\n\tif len(b) == 0 {\n\t\treturn 0, nil, fmt.Errorf(\"zero length blob not allowed\")\n\t}\n\tver := b[0]\n\tb = b[1:]\n\tpushes, err := ExtractPushes(b, preAlloc...)\n\treturn ver, pushes, err\n}", "func (r *chunkReader) Read(data []byte) (int, error) {\n\tbytesToRead := len(data)\n\tr.l.Debug(\"Start cafs reader Read\", zap.Int(\"length\", bytesToRead))\n\n\tif r.lastChunk && r.rdr == nil {\n\t\treturn 0, io.EOF\n\t}\n\tfor {\n\t\tkey := r.keys[r.idx]\n\t\tif r.rdr == nil {\n\t\t\trdr, err := r.fs.Get(context.Background(), r.pather(key))\n\t\t\tif err != nil {\n\t\t\t\treturn r.readSoFar, err\n\t\t\t}\n\t\t\tr.rdr = rdr\n\t\t}\n\n\t\tn, errRead := r.rdr.Read(data[r.readSoFar:])\n\n\t\tdefer func() {\n\t\t\tif r.MetricsEnabled() && errRead == nil {\n\t\t\t\tr.m.Volume.Blobs.IncBlob(\"read\")\n\t\t\t\tr.m.Volume.Blobs.Size(int64(n), \"read\")\n\t\t\t}\n\t\t\tr.l.Debug(\"End cafs reader Read\", zap.Int(\"length\", bytesToRead))\n\t\t}()\n\n\t\tr.currLeaf = append(r.currLeaf, data[r.readSoFar:r.readSoFar+n]...)\n\t\tif errRead != nil {\n\t\t\tr.rdr.Close() // TODO(fred): nice - why are we ignoring errors here?\n\t\t\tr.readSoFar += n\n\t\t\tif errRead == io.EOF { // we reached the end of the stream for this key\n\t\t\t\tr.idx++\n\t\t\t\tr.rdr = nil\n\t\t\t\tr.lastChunk = r.idx == len(r.keys)\n\t\t\t\tif r.withVerifyHash {\n\t\t\t\t\tnodeOffset := r.idx\n\t\t\t\t\tisLastNode := false\n\n\t\t\t\t\t// NOTE: we follow the checksumming scheme adopted by the writer.\n\t\t\t\t\t// The writer behaves in a way a bit unexpected here: not only offets don't start at zero\n\t\t\t\t\t// as one might expect, but the last node is not flagged as the last one\n\t\t\t\t\t// when the content size is aligned with the leaf size.\n\t\t\t\t\tif r.lastChunk && uint32(len(r.currLeaf)) != r.leafSize {\n\t\t\t\t\t\tnodeOffset--\n\t\t\t\t\t\tisLastNode = true\n\t\t\t\t\t}\n\t\t\t\t\tr.l.Debug(\"cafs reader Read: hash verification\", zap.Stringer(\"key\", key))\n\t\t\t\t\tif err := r.verifyHash(key, r.currLeaf, nodeOffset, isLastNode); err != nil {\n\t\t\t\t\t\treturn 0, err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif r.lastChunk { // this was the last chunk, so also EOF for this hash\n\t\t\t\t\tif n == bytesToRead {\n\t\t\t\t\t\treturn n, nil\n\t\t\t\t\t}\n\t\t\t\t\treturn r.readSoFar, io.EOF\n\t\t\t\t}\n\t\t\t\t// move on to the next key\n\t\t\t\tr.currLeaf = make([]byte, 0)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn n, errRead\n\t\t}\n\t\t// we filled up the entire byte slice but still have data remaining in the reader,\n\t\t// we should move on to receive the next buffer\n\t\tr.readSoFar += n\n\t\tif r.readSoFar >= bytesToRead {\n\t\t\tr.readSoFar = 0\n\t\t\t// return without error\n\t\t\treturn bytesToRead, nil\n\t\t}\n\t}\n}", "func parseBinaryBlob(blob []byte) (*Digest, error) {\n\t// Read a single item from the binary stream. Timeout after\n\t// five seconds because it shouldn't take that long to parse\n\t// a blob that is already loaded into memory.\n\tch := parseBinaryStream(bytes.NewReader(blob))\n\tselect {\n\tcase out := <-ch:\n\t\treturn out.Digest, out.Error\n\tcase <-time.After(5 * time.Second):\n\t\treturn nil, errors.New(\"timed out waiting for parser to finish\")\n\t}\n}", "func (fs *FileStream) ReadAt(b []byte, offset int64) (int, error) {\n\treturn fs.f.ReadAt(b, offset)\n}", "func (sto *overlayStorage) ReceiveBlob(ctx context.Context, br blob.Ref, src io.Reader) (sb blob.SizedRef, err error) {\n\tsb, err = sto.upper.ReceiveBlob(ctx, br, src)\n\tif err == nil && sto.deleted != nil {\n\t\terr = sto.deleted.Delete(br.String())\n\t}\n\treturn sb, err\n}", "func GetBlob(blobSum string, digest string) *Blob {\n\n\tb := new(Blob)\n\tb.ID = digest\n\n\tif !b.IsExist() {\n\t\tlogger.Errorf(\"blob of %s not exist\\n\", digest)\n\t\treturn nil\n\t}\n\n\tfd, err := os.Open(b.FilePath())\n\tif err != nil {\n\t\tlogger.Errorf(\"open file of %s error\\n\", b.FilePath())\n\t\treturn nil\n\t}\n\n\tdefer fd.Close()\n\n\tdata, err := ioutil.ReadAll(fd)\n\tif err != nil {\n\t\tlogger.Errorf(\"read file from %s error\\n\", b.FilePath())\n\t\treturn nil\n\t}\n\n\tb.Data = data\n\tb.Size = utils.GetFileSize(b.FilePath())\n\tb.RefCount = b.GetRefCount()\n\n\treturn b\n}", "func (w *blobWriter) ReadFrom(r io.Reader) (n int64, err error) {\n\treturn w.BlobWriter.ReadFrom(r)\n}", "func (g *deltaGenerator) readSourceData(source *sourceInfo, offset int64, size int64) ([]byte, error) {\n\t_, err := g.analysis.sourceData.Seek(int64(source.offset+offset), 0)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbuf := make([]byte, size)\n\t_, err = io.ReadFull(g.analysis.sourceData, buf)\n\treturn buf, err\n}", "func ReadFromManagedReader(oid uint64, data []byte) (int, int) {\n\tri, ok := GetManagedObject(oid)\n\tif !ok {\n\t\tpanic(\"failed to get reader\")\n\t}\n\tr := ri.(io.Reader)\n\tn, err := r.Read(data)\n\tif err != nil {\n\t\tif err == io.EOF {\n\t\t\treturn 0, 0\n\t\t}\n\t\tplog.Errorf(\"got err %+v when reading from the snapshot reader\", err)\n\t\treturn -1, getErrnoFromError(err)\n\t}\n\treturn n, 0\n}", "func (i *DataIndex) getBlob(hash string, fpath string) error {\n\n\t// disallow empty paths\n\tif len(fpath) == 0 {\n\t\treturn fmt.Errorf(\"get blob %.7s - error: no path supplied\", hash)\n\t}\n\n\tfpath = path.Clean(fpath)\n\n\tpErr(\"get blob %.7s %s\\n\", hash, fpath)\n\tw, err := createFile(fpath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer w.Close()\n\n\treturn i.copyBlob(hash, w)\n}", "func (c *Client) Read(path gfs.Path, offset gfs.Offset, data []byte) (n int, err error) {\n\tvar f gfs.GetFileInfoReply\n\terr = util.Call(c.master, \"Master.RPCGetFileInfo\", gfs.GetFileInfoArg{path}, &f)\n\tif err != nil {\n\t\treturn -1, err\n\t}\n\n\tif int64(offset/gfs.MaxChunkSize) > f.Chunks {\n\t\treturn -1, fmt.Errorf(\"read offset exceeds file size\")\n\t}\n\n\tpos := 0\n\tfor pos < len(data) {\n\t\tindex := gfs.ChunkIndex(offset / gfs.MaxChunkSize)\n\t\tchunkOffset := offset % gfs.MaxChunkSize\n\n\t\tif int64(index) >= f.Chunks {\n\t\t\terr = gfs.Error{gfs.ReadEOF, \"EOF over chunks\"}\n\t\t\tbreak\n\t\t}\n\n\t\tvar handle gfs.ChunkHandle\n\t\thandle, err = c.GetChunkHandle(path, index)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tvar n int\n\t\t//wait := time.NewTimer(gfs.ClientTryTimeout)\n\t\t//loop:\n\t\tfor {\n\t\t\t//select {\n\t\t\t//case <-wait.C:\n\t\t\t// err = gfs.Error{gfs.Timeout, \"Read Timeout\"}\n\t\t\t// break loop\n\t\t\t//default:\n\t\t\t//}\n\t\t\tn, err = c.ReadChunk(handle, chunkOffset, data[pos:])\n\t\t\tif err == nil || err.(gfs.Error).Code == gfs.ReadEOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tlog.Warning(\"Read \", handle, \" connection error, try again: \", err)\n\t\t}\n\n\t\toffset += gfs.Offset(n)\n\t\tpos += n\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif err != nil && err.(gfs.Error).Code == gfs.ReadEOF {\n\t\treturn pos, io.EOF\n\t} else {\n\t\treturn pos, err\n\t}\n}", "func TestReadByByte(t *testing.T) {\n\trun.skipIfNoFUSE(t)\n\n\tvar data = []byte(\"hellohello\")\n\trun.createFile(t, \"testfile\", string(data))\n\trun.checkDir(t, \"testfile 10\")\n\n\tfor i := 0; i < len(data); i++ {\n\t\tfd, err := os.Open(run.path(\"testfile\"))\n\t\tassert.NoError(t, err)\n\t\tfor j := 0; j < i; j++ {\n\t\t\tbuf := make([]byte, 1)\n\t\t\tn, err := io.ReadFull(fd, buf)\n\t\t\tassert.NoError(t, err)\n\t\t\tassert.Equal(t, 1, n)\n\t\t\tassert.Equal(t, buf[0], data[j])\n\t\t}\n\t\terr = fd.Close()\n\t\tassert.NoError(t, err)\n\t}\n\n\trun.rm(t, \"testfile\")\n}", "func (f *FileBlob) ReadCloser() (io.ReadCloser, error) {\n\tif f.blob == nil {\n\t\treturn nil, fmt.Errorf(\"underlying blob ([]byte) is nil\")\n\t}\n\treturn blob.NewBufferedReadCloser(f.blob), nil\n}", "func (r *bytesReader) ReadAt(b []byte, offset int64) (n int, err error) {\n\tif offset < 0 {\n\t\treturn 0, errors.New(\"buffer.bytesReader.ReadAt: negative offset\")\n\t}\n\tif offset >= int64(len(r.bs)) {\n\t\treturn 0, io.EOF\n\t}\n\tn = copy(b, r.bs[offset:])\n\tif n < len(b) {\n\t\terr = io.EOF\n\t}\n\treturn\n}", "func (c *Client) GetObjectData(ctx context.Context, obj string) ([]byte, error) {\n\tr, err := c.gcsClient.Bucket(c.bucket).Object(obj).NewReader(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"GetObjectData: failed to create reader for object %q in bucket %q: %q\", obj, c.bucket, err)\n\t}\n\tdefer r.Close()\n\n\treturn io.ReadAll(r)\n}", "func (bsf *bucketstorefile) ReadAt(p []byte, off int64) (n int, err error) {\n\tbsf.apply(func() {\n\t\tatomic.AddInt64(&bsf.stats.Reads, 1)\n\t\tn, err = bsf.file.ReadAt(p, off)\n\t\tif err != nil {\n\t\t\tatomic.AddInt64(&bsf.stats.ReadErrors, 1)\n\t\t}\n\t\tatomic.AddInt64(&bsf.stats.ReadBytes, int64(n))\n\t})\n\treturn n, err\n}", "func (s *Snappy) DecompressBlob(ctx context.Context, data []byte) ([]byte, error) {\n\treturn gs.Decode(nil, data)\n}", "func newDataFileReaderBytes(buf []byte, datumReader DatumReader) (reader *DataFileReader, err error) {\n\tif len(buf) < len(magic) || !bytes.Equal(magic, buf[0:4]) {\n\t\treturn nil, NotAvroFile\n\t}\n\n\tdec := NewBinaryDecoder(buf)\n\tblockDecoder := NewBinaryDecoder(nil)\n\treader = &DataFileReader{\n\t\tdata: buf,\n\t\tdec: dec,\n\t\tblockDecoder: blockDecoder,\n\t\tdatum: datumReader,\n\t}\n\n\tif reader.header, err = readObjFileHeader(dec); err != nil {\n\t\treturn nil, err\n\t}\n\n\tschema, err := ParseSchema(string(reader.header.Meta[schemaKey]))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treader.datum.SetSchema(schema)\n\treader.block = &DataBlock{}\n\n\tif reader.hasNextBlock() {\n\t\tif err := reader.NextBlock(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn reader, nil\n}", "func (self *Blob) FileReader() (reader io.ReadCloser, filename, contentType string, err error) {\n\treturn Config.Backend.FileReader(self.FileID.Get())\n}", "func (b *Block) ReadAt(off int) ([]byte, error) {\n\tif off > blockSize || off < 0 {\n\t\treturn []byte{}, ErrOffsetRange\n\t}\n\n\treturn b.data[off:], nil\n}", "func ReadBlockData(chain uint64, key []byte) []byte {\n\tstream, _ := runtime.DbGet(dbBlockData{}, chain, key)\n\treturn stream\n}", "func (s *storageImageSource) GetBlob(ctx context.Context, info types.BlobInfo) (rc io.ReadCloser, n int64, err error) {\n\tif info.Digest == image.GzippedEmptyLayerDigest {\n\t\treturn ioutil.NopCloser(bytes.NewReader(image.GzippedEmptyLayer)), int64(len(image.GzippedEmptyLayer)), nil\n\t}\n\trc, n, _, err = s.getBlobAndLayerID(info)\n\treturn rc, n, err\n}", "func (d *DriveDB) readChunk(f *File, chunk, filesize int64) ([]byte, error) {\n\tif chunk*(*driveCacheChunk) > filesize {\n\t\treturn nil, fmt.Errorf(\"read past eof\")\n\t}\n\tkey := cacheMapKey(f.Id, chunk)\n\tv, err := d.sf.Do(string(key), func() (interface{}, error) {\n\t\treturn d.readChunkImpl(f, chunk, filesize)\n\t})\n\treturn v.([]byte), err\n}", "func (d *demo) readFile(fileName string, data *[]byte) {\r\n\t// ファイルを開く\r\n\trc, err := d.bucket.Object(fileName).NewReader(d.ctx)\r\n\tif err != nil {\r\n\t\td.errorf(\"readFile: unable to open file from bucket %q, file %q: %v\", d.bucketName, fileName, err)\r\n\t\treturn\r\n\t}\r\n\tdefer rc.Close()\r\n\r\n\t// データを読み込む\r\n\tslurp, err := ioutil.ReadAll(rc)\r\n\tif err != nil {\r\n\t\td.errorf(\"readFile: unable to read data from bucket %q, file %q: %v\", d.bucketName, fileName, err)\r\n\t\treturn\r\n\t}\r\n\r\n\t*data = slurp\r\n}", "func readMetadata(r io.ReaderAt, firstBlock int64, initialBlockOffset uint32, byteOffset uint16, size int) ([]byte, error) {\n\tvar (\n\t\tb []byte\n\t\tblockOffset = int(initialBlockOffset)\n\t)\n\t// we know how many blocks, so read them all in\n\tread, m, err := readMetadataBlock(r, firstBlock+int64(blockOffset))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tb = append(b, m[byteOffset:]...)\n\t// do we have any more to read?\n\tfor len(b) < size {\n\t\tblockOffset += read\n\t\tread, m, err = readMetadataBlock(r, firstBlock+int64(blockOffset))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tb = append(b, m...)\n\t}\n\tif len(b) >= size {\n\t\tb = b[:size]\n\t}\n\treturn b, nil\n}", "func (s *SeekerWrapper) ReadAt(p []byte, offset int64) (int, error) { return s.s.ReadAt(p, offset) }", "func (is *ImageStoreLocal) GetBlob(repo string, digest godigest.Digest, mediaType string,\n) (io.ReadCloser, int64, error) {\n\tvar lockLatency time.Time\n\n\tif err := digest.Validate(); err != nil {\n\t\treturn nil, -1, err\n\t}\n\n\tblobPath := is.BlobPath(repo, digest)\n\n\tis.RLock(&lockLatency)\n\tdefer is.RUnlock(&lockLatency)\n\n\tbinfo, err := os.Stat(blobPath)\n\tif err != nil {\n\t\tis.log.Debug().Err(err).Str(\"blob\", blobPath).Msg(\"failed to stat blob\")\n\n\t\treturn nil, -1, zerr.ErrBlobNotFound\n\t}\n\n\tblobReadCloser, err := os.Open(blobPath)\n\tif err != nil {\n\t\tis.log.Debug().Err(err).Str(\"blob\", blobPath).Msg(\"failed to open blob\")\n\n\t\treturn nil, -1, err\n\t}\n\n\t// The caller function is responsible for calling Close()\n\treturn blobReadCloser, binfo.Size(), nil\n}", "func ReadDataAt(r io.ReaderAt, n uint64, off int64) ([]byte, error) {\n\tif int64(n) < 0 || n != uint64(int(n)) {\n\t\t// n is too large to fit in int, so we can't allocate\n\t\t// a buffer large enough. Treat this as a read failure.\n\t\treturn nil, io.ErrUnexpectedEOF\n\t}\n\n\tif n < chunk {\n\t\tbuf := make([]byte, n)\n\t\t_, err := r.ReadAt(buf, off)\n\t\tif err != nil {\n\t\t\t// io.SectionReader can return EOF for n == 0,\n\t\t\t// but for our purposes that is a success.\n\t\t\tif err != io.EOF || n > 0 {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\treturn buf, nil\n\t}\n\n\tvar buf []byte\n\tbuf1 := make([]byte, chunk)\n\tfor n > 0 {\n\t\tnext := n\n\t\tif next > chunk {\n\t\t\tnext = chunk\n\t\t}\n\t\t_, err := r.ReadAt(buf1[:next], off)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tbuf = append(buf, buf1[:next]...)\n\t\tn -= next\n\t\toff += int64(next)\n\t}\n\treturn buf, nil\n}", "func (b *Blob) Bytes() ([]byte, error) {\n\tdone := make(chan struct{})\n\tfr := js.Global.Get(\"FileReader\").New()\n\tfr.Set(\"onloadend\", func() { close(done) })\n\tfr.Call(\"readAsArrayBuffer\", b)\n\t<-done // Wait for the read to finish\n\tif err := fr.Get(\"error\"); err != nil {\n\t\treturn nil, &js.Error{err}\n\t}\n\treturn js.Global.Get(\"Uint8Array\").New(fr.Get(\"result\")).Interface().([]uint8), nil\n}", "func (a *file_asset) ReadAt(b []byte, off int64) (n int, err error) {\n\treturn a.f.ReadAt(b, off)\n}", "func ReadBytes(buffer []byte, offset int, size int) []byte {\n return buffer[offset:offset + size]\n}", "func (rc *RegClient) BlobHead(ctx context.Context, r ref.Ref, d types.Descriptor) (blob.Reader, error) {\n\tschemeAPI, err := rc.schemeGet(r.Scheme)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn schemeAPI.BlobHead(ctx, r, d)\n}", "func (c *Client) ReadCheckpoint(ctx context.Context) ([]byte, error) {\n\tbkt := c.gcsClient.Bucket(c.bucket)\n\tobj := bkt.Object(layout.CheckpointPath)\n\n\tr, err := obj.NewReader(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer r.Close()\n\n\treturn io.ReadAll(r)\n}", "func (file *Remote) ReadAt(buf []byte, off int64) (int, error) {\n\tsize := len(buf)\n\tif size > file.maxBufSize() {\n\t\tsize = file.maxBufSize()\n\t}\n\n\tvar total int\n\tfor start := 0; start < len(buf); start += size {\n\t\tend := start + size\n\t\tif end > len(buf) {\n\t\t\tend = len(buf)\n\t\t}\n\n\t\tn, err := file.readPart(buf[start:end], off+int64(start))\n\t\ttotal += n\n\t\tif err != nil {\n\t\t\treturn total, err\n\t\t}\n\t}\n\treturn total, nil\n}", "func readFileToByteArray(p string) []byte {\n\tb, err := ioutil.ReadFile(p)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error reading file: #%v \", err)\n\t}\n\treturn b\n}", "func readFileToByteArray(p string) []byte {\n\tb, err := ioutil.ReadFile(p)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error reading file: #%v \", err)\n\t}\n\treturn b\n}", "func (rc *RegClient) BlobGet(ctx context.Context, r ref.Ref, d types.Descriptor) (blob.Reader, error) {\n\tdata, err := d.GetData()\n\tif err == nil {\n\t\treturn blob.NewReader(blob.WithDesc(d), blob.WithRef(r), blob.WithReader(bytes.NewReader(data))), nil\n\t}\n\tschemeAPI, err := rc.schemeGet(r.Scheme)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn schemeAPI.BlobGet(ctx, r, d)\n}", "func downloadBlob(blobClient *storage.BlobStorageClient, containerName, blobName, fileName string) error {\n\tfmt.Printf(\"Download blob data into '%v'...\\n\", fileName)\n\tif _, err := os.Stat(fileName); err == nil {\n\t\treturn fmt.Errorf(\"File '%v' already exists\", fileName)\n\t}\n\treadCloser, err := blobClient.GetBlob(containerName, blobName)\n\tif err != nil {\n\t\treturn err\n\t}\n\tbytesRead, err := ioutil.ReadAll(readCloser)\n\tdefer readCloser.Close()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(fileName, bytesRead, 0666)\n}", "func (r *objReader) readData() Data {\n\tn := r.readInt()\n\td := Data{Offset: r.offset, Size: int64(n)}\n\tr.skip(int64(n))\n\treturn d\n}", "func ReadFromContainer(ip, containerName, volPath, fileName string) (string, error) {\n\tlog.Printf(\"Reading from file [%s] in container [%s] on VM [%s]\\n\", fileName, containerName, ip)\n\n\treadCmd := \" /bin/sh -c 'cat \" + volPath + \"/\" + fileName + \"'\"\n\tfullCmd := dockercli.RunCmdInContainer + containerName + readCmd\n\n\tlog.Println(fullCmd)\n\treturn ssh.InvokeCommand(ip, fullCmd)\n}", "func (s *AzureBlobStorage) Open(ctx context.Context, name string) (ExternalFileReader, error) {\n\tclient := s.containerClient.NewBlockBlobClient(s.withPrefix(name))\n\tresp, err := client.GetProperties(ctx, nil)\n\tif err != nil {\n\t\treturn nil, errors.Annotate(err, \"Failed to get properties from the azure blob\")\n\t}\n\n\treturn &azblobObjectReader{\n\t\tblobClient: client,\n\n\t\tpos: 0,\n\t\ttotalSize: *resp.ContentLength,\n\n\t\tctx: ctx,\n\n\t\tcpkInfo: s.cpkInfo,\n\t}, nil\n}", "func (reader *embedFileReader) ReadAt(p []byte, off int64) (int, error) {\n\treturn 0, ErrNotImplemented\n}", "func (c *Conn) ReadDataUnit() (data []byte, err error) {\n\tvar s uint32\n\terr = binary.Read(c.Conn, binary.BigEndian, &s)\n\tif err != nil {\n\t\treturn\n\t}\n\tdata = make([]byte, s)\n\tn, err := c.Conn.Read(data)\n\tif err != nil {\n\t\treturn\n\t}\n\tif 4+n != int(s) {\n\t\treturn data, io.ErrNoProgress\n\t}\n\treturn data, nil\n}", "func BlobTime(v interface{}) (t time.Time) {\n\tvar (\n\t\tf *os.File\n\t\tfn string\n\t\terr error\n\t\tok bool\n\t)\n\tif fn, ok = v.(string); ok {\n\t\tif f, err = os.Open(fn); err != nil {\n\t\t\treturn\n\t\t}\n\t\tdefer f.Close()\n\t} else if f, ok = v.(*os.File); !ok {\n\t\treturn\n\t}\n\tf.Seek(BlobTimeOff, os.SEEK_SET)\n\t(NBOReader{f}).ReadNBO(&t)\n\treturn\n}", "func BlobTime(v interface{}) (t time.Time) {\n\tvar (\n\t\tf *os.File\n\t\tfn string\n\t\terr error\n\t\tok bool\n\t)\n\tif fn, ok = v.(string); ok {\n\t\tif f, err = os.Open(fn); err != nil {\n\t\t\treturn\n\t\t}\n\t\tdefer f.Close()\n\t} else if f, ok = v.(*os.File); !ok {\n\t\treturn\n\t}\n\tf.Seek(BlobTimeOff, os.SEEK_SET)\n\t(NBOReader{f}).ReadNBO(&t)\n\treturn\n}", "func ReadByte(buffer []byte, offset int) byte {\n return buffer[offset]\n}", "func (b *Blob) Reader() (core.ObjectReader, error) {\n\treturn b.obj.Reader()\n}", "func (c *poolConn) ReadPart() ([]byte, error) {\n\tfor {\n\t\tfor i := c.buffer.index; i < c.buffer.size; i++ {\n\t\t\tif c.buffer.realBuffer[i-1] == '\\r' && c.buffer.realBuffer[i] == '\\n' {\n\t\t\t\tindex := c.buffer.index\n\t\t\t\tc.buffer.index = i + 1\n\t\t\t\tif c.buffer.index >= c.buffer.size {\n\t\t\t\t\tc.mustRead = true\n\t\t\t\t}\n\t\t\t\treturn c.buffer.realBuffer[index: i-1], nil\n\t\t\t}\n\t\t}\n\t\terr := c.ReadUnsafeBuffer()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n}", "func getBlob(tx *sql.Tx, digest string) (*Blob, error) {\n\tvar b *Blob\n\trows, err := tx.Query(\"SELECT * from blobinfo WHERE digest == $1\", digest)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor rows.Next() {\n\t\tb = &Blob{}\n\t\tif err := blobRowScan(rows, b); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\t// No more than one row for digest must exist.\n\t\tbreak\n\t}\n\tif err := rows.Err(); err != nil {\n\t\treturn nil, err\n\t}\n\treturn b, err\n}", "func (bio *BinaryIO) ReadData(off int64, data interface{}) {\n\tsr := NewSequentialReader(bio, off)\n\tsr.ReadData(data)\n}", "func GetBlobContent(ctx context.Context, bucketURL, key string) ([]byte, error) {\n\tbucket, err := blob.OpenBucket(ctx, bucketURL)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error from blob.OpenBucket: %w\", err)\n\t}\n\tdefer bucket.Close()\n\n\tkeyData, err := bucket.ReadAll(ctx, key)\n\tif err != nil {\n\t\treturn keyData, fmt.Errorf(\"error during bucket.ReadAll: %w\", err)\n\t}\n\treturn keyData, nil\n}", "func (fs *FileSystem) loadData(ino uint64) ([]byte, error) {\n\tif ino == 0 {\n\t\treturn nil, errNilIno\n\t}\n\n\tvar data []byte\n\terr := fs.db.View(func(tx *bolt.Tx) error {\n\t\tb := tx.Bucket([]byte(\"data\"))\n\t\td := b.Get(i2b(ino))\n\t\tif d == nil {\n\t\t\td = []byte{}\n\t\t}\n\t\tdata = make([]byte, len(d))\n\t\tcopy(data, d)\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn data, err\n\t}\n\n\treturn data, err\n}", "func readLocalFileExtent(filename string, ofs int64, len int) ([]byte, error) {\n\tfReader, err := os.Open(filename)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer fReader.Close()\n\n\tbuf := make([]byte, len)\n\trecvLen, err := fReader.ReadAt(buf, ofs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif recvLen != len {\n\t\tpanic(fmt.Sprintf(\"short read, got %d bytes instead of %d\",\n\t\t\trecvLen, len))\n\t}\n\treturn buf, nil\n}", "func (h *proxyHandler) GetBlob(args []any) (replyBuf, error) {\n\th.lock.Lock()\n\tdefer h.lock.Unlock()\n\n\tvar ret replyBuf\n\n\tif h.sysctx == nil {\n\t\treturn ret, fmt.Errorf(\"client error: must invoke Initialize\")\n\t}\n\tif len(args) != 3 {\n\t\treturn ret, fmt.Errorf(\"found %d args, expecting (imgid, digest, size)\", len(args))\n\t}\n\timgref, err := h.parseImageFromID(args[0])\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\tdigestStr, ok := args[1].(string)\n\tif !ok {\n\t\treturn ret, fmt.Errorf(\"expecting string blobid\")\n\t}\n\tsize, err := parseUint64(args[2])\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tctx := context.TODO()\n\td, err := digest.Parse(digestStr)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\tblobr, blobSize, err := imgref.src.GetBlob(ctx, types.BlobInfo{Digest: d, Size: int64(size)}, h.cache)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tpiper, f, err := h.allocPipe()\n\tif err != nil {\n\t\tblobr.Close()\n\t\treturn ret, err\n\t}\n\tgo func() {\n\t\t// Signal completion when we return\n\t\tdefer blobr.Close()\n\t\tdefer f.wg.Done()\n\t\tverifier := d.Verifier()\n\t\ttr := io.TeeReader(blobr, verifier)\n\t\tn, err := io.Copy(f.w, tr)\n\t\tif err != nil {\n\t\t\tf.err = err\n\t\t\treturn\n\t\t}\n\t\tif n != int64(size) {\n\t\t\tf.err = fmt.Errorf(\"expected %d bytes in blob, got %d\", size, n)\n\t\t}\n\t\tif !verifier.Verified() {\n\t\t\tf.err = fmt.Errorf(\"corrupted blob, expecting %s\", d.String())\n\t\t}\n\t}()\n\n\tret.value = blobSize\n\tret.fd = piper\n\tret.pipeid = uint32(f.w.Fd())\n\treturn ret, nil\n}", "func (b *BitsImageManager) GetBlob(name string, digest string) io.ReadCloser {\n\tif digest == b.rootfsDigest {\n\t\tr, e := b.rootFSBlobstore.Get(\"assets/eirinifs.tar\")\n\t\tutil.PanicOnError(errors.WithStack(e))\n\t\treturn r\n\t}\n\n\tr, e := b.digestLookupStore.Get(digest)\n\tif _, notFound := e.(*bitsgo.NotFoundError); notFound {\n\t\treturn nil\n\t}\n\n\tutil.PanicOnError(errors.WithStack(e))\n\treturn r\n}", "func (mcm *MinioChunkManager) Read(ctx context.Context, filePath string) ([]byte, error) {\n\tobject, err := mcm.getMinioObject(ctx, mcm.bucketName, filePath, minio.GetObjectOptions{})\n\tif err != nil {\n\t\tlog.Warn(\"failed to get object\", zap.String(\"bucket\", mcm.bucketName), zap.String(\"path\", filePath), zap.Error(err))\n\t\treturn nil, err\n\t}\n\tdefer object.Close()\n\n\t// Prefetch object data\n\tvar empty []byte\n\t_, err = object.Read(empty)\n\tif err != nil {\n\t\terrResponse := minio.ToErrorResponse(err)\n\t\tif errResponse.Code == \"NoSuchKey\" {\n\t\t\treturn nil, WrapErrNoSuchKey(filePath)\n\t\t}\n\t\tlog.Warn(\"failed to read object\", zap.String(\"path\", filePath), zap.Error(err))\n\t\treturn nil, err\n\t}\n\n\tobjectInfo, err := object.Stat()\n\tif err != nil {\n\t\tlog.Warn(\"failed to stat object\", zap.String(\"bucket\", mcm.bucketName), zap.String(\"path\", filePath), zap.Error(err))\n\t\terrResponse := minio.ToErrorResponse(err)\n\t\tif errResponse.Code == \"NoSuchKey\" {\n\t\t\treturn nil, WrapErrNoSuchKey(filePath)\n\t\t}\n\t\treturn nil, err\n\t}\n\n\tdata, err := Read(object, objectInfo.Size)\n\tif err != nil {\n\t\terrResponse := minio.ToErrorResponse(err)\n\t\tif errResponse.Code == \"NoSuchKey\" {\n\t\t\treturn nil, WrapErrNoSuchKey(filePath)\n\t\t}\n\t\tlog.Warn(\"failed to read object\", zap.String(\"bucket\", mcm.bucketName), zap.String(\"path\", filePath), zap.Error(err))\n\t\treturn nil, err\n\t}\n\tmetrics.PersistentDataKvSize.WithLabelValues(metrics.DataGetLabel).Observe(float64(objectInfo.Size))\n\treturn data, nil\n}", "func fetchData(r reader) error {\n\tfmt.Printf(\"type %T\\n\", r)\n\tdata := make([]byte, 50)\n\tlen, err := r.read(data)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Println(string(data[:len]))\n\treturn nil\n\n}", "func (s *storageImageDestination) getConfigBlob(info types.BlobInfo) ([]byte, error) {\n\tif info.Digest == \"\" {\n\t\treturn nil, errors.Errorf(`no digest supplied when reading blob`)\n\t}\n\tif err := info.Digest.Validate(); err != nil {\n\t\treturn nil, errors.Wrapf(err, `invalid digest supplied when reading blob`)\n\t}\n\t// Assume it's a file, since we're only calling this from a place that expects to read files.\n\tif filename, ok := s.filenames[info.Digest]; ok {\n\t\tcontents, err2 := ioutil.ReadFile(filename)\n\t\tif err2 != nil {\n\t\t\treturn nil, errors.Wrapf(err2, `error reading blob from file %q`, filename)\n\t\t}\n\t\treturn contents, nil\n\t}\n\t// If it's not a file, it's a bug, because we're not expecting to be asked for a layer.\n\treturn nil, errors.New(\"blob not found\")\n}", "func recoveredDataOffset(chunkFetchOffset uint64, rs modules.ErasureCoder) uint64 {\n\t// If partialDecoding is not available we downloaded the whole sector and\n\t// recovered the whole chunk which means the offset and length are actually\n\t// equal to the chunkFetchOffset and chunkFetchLength.\n\tif !rs.SupportsPartialEncoding() {\n\t\treturn chunkFetchOffset\n\t}\n\t// Else we need to adjust the offset a bit.\n\trecoveredSegmentSize := uint64(rs.MinPieces() * crypto.SegmentSize)\n\treturn chunkFetchOffset % recoveredSegmentSize\n}", "func (rh *readHandle) ReadAt(ctx context.Context, p []byte, off int64) (n int, err error) {\n\trh.g.add(ctx, Event{\n\t\tOp: ReadOp,\n\t\tFileNum: rh.fileNum,\n\t\tHandleID: rh.handleID,\n\t\tOffset: off,\n\t\tSize: int64(len(p)),\n\t})\n\treturn rh.rh.ReadAt(ctx, p, off)\n}", "func alignReads(offsetInFile int64, readLen int64) []alignedBlobRead {\n\tblobIdx, offsetInBlob := stoclient.BlobIdxFromOffset(offsetInFile)\n\n\t// simplest, general case\n\tif offsetInBlob+readLen <= stotypes.BlobSize {\n\t\treturn []alignedBlobRead{\n\t\t\t{blobIdx: blobIdx, offsetInBlob: int(offsetInBlob), lenInBlob: readLen},\n\t\t}\n\t}\n\n\tfirstRead := alignedBlobRead{blobIdx: blobIdx, offsetInBlob: int(offsetInBlob), lenInBlob: stotypes.BlobSize - offsetInBlob}\n\treadLen -= firstRead.lenInBlob\n\n\tadditionalReads := []alignedBlobRead{}\n\n\tfor readLen > 0 {\n\t\tblobIdx++\n\t\treadLenForBlob := min(readLen, stotypes.BlobSize)\n\t\tadditionalReads = append(additionalReads, alignedBlobRead{blobIdx: blobIdx, offsetInBlob: 0, lenInBlob: readLenForBlob})\n\n\t\treadLen -= readLenForBlob\n\t}\n\n\treturn append([]alignedBlobRead{firstRead}, additionalReads...)\n}", "func (s *Service) GetBlob(c context.Context, req *blobpb.GetBlobRequest) (*blobpb.GetBlobResponse, error) {\n\tbr, err := s.getBlobRecord(c, id.BlobID(req.Id))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tr, err := s.Storage.Get(c, br.Path)\n\tif r != nil {\n\t\tdefer r.Close()\n\t}\n\tif err != nil {\n\t\treturn nil, status.Errorf(codes.Aborted, \"cannnot get storage: %v\", err)\n\t}\n\n\tb, err := ioutil.ReadAll(r)\n\tif err != nil {\n\t\treturn nil, status.Errorf(codes.Aborted, \"cannot read from response: %v\", err)\n\t}\n\n\treturn &blobpb.GetBlobResponse{\n\t\tData: b,\n\t}, nil\n}", "func (d *driver) Reader(ctx context.Context, path string, offset int64) (io.ReadCloser, error) {\n\tbaseUrl := d.getBaseUrl(path)\n\n\tinfo, err := d.Bucket.Stat(ctx, path)\n\tif err != nil {\n\t\treturn nil, err;\n\t}\n\n\tif offset > info.Fsize {\n\t\treturn ioutil.NopCloser(bytes.NewReader(nil)), nil\n\t}\n\n\thttpClient := &http.Client{}\n\treq, err := http.NewRequest(\"GET\", baseUrl, nil)\n\treq.Header.Add(\"Range\", \"bytes=\"+strconv.FormatInt(offset, 10)+\"-\")\n\tresp, err := httpClient.Do(req)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tc,_ := ioutil.ReadAll(resp.Body)\n\n\tfmt.Print(\"content\"+string(c)+\"\\n\")\n\n\treturn resp.Body,err\n}", "func (tf *Temp) ReadAt(buffer []byte, off int64) (int, error) {\n\ttf.Lock()\n\tdefer tf.Unlock()\n\n\tread, err := tf.file.ReadAt(buffer, off)\n\treturn read, ex.New(err)\n}", "func (is *ObjectStorage) GetBlobContent(repo string, digest godigest.Digest) ([]byte, error) {\n\tif err := digest.Validate(); err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\tblobPath := is.BlobPath(repo, digest)\n\n\tbinfo, err := is.store.Stat(context.Background(), blobPath)\n\tif err != nil {\n\t\tis.log.Error().Err(err).Str(\"blob\", blobPath).Msg(\"failed to stat blob\")\n\n\t\treturn []byte{}, zerr.ErrBlobNotFound\n\t}\n\n\tblobBuf, err := is.store.GetContent(context.Background(), blobPath)\n\tif err != nil {\n\t\tis.log.Error().Err(err).Str(\"blob\", blobPath).Msg(\"failed to open blob\")\n\n\t\treturn nil, err\n\t}\n\n\t// is a 'deduped' blob?\n\tif binfo.Size() == 0 {\n\t\t// Check blobs in cache\n\t\tdstRecord, err := is.checkCacheBlob(digest)\n\t\tif err != nil {\n\t\t\tis.log.Error().Err(err).Str(\"digest\", digest.String()).Msg(\"cache: not found\")\n\n\t\t\treturn nil, zerr.ErrBlobNotFound\n\t\t}\n\n\t\tblobBuf, err := is.store.GetContent(context.Background(), dstRecord)\n\t\tif err != nil {\n\t\t\tis.log.Error().Err(err).Str(\"blob\", dstRecord).Msg(\"failed to open blob\")\n\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn blobBuf, nil\n\t}\n\n\treturn blobBuf, nil\n}", "func (*BlobReadRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_store_store_proto_rawDescGZIP(), []int{19}\n}" ]
[ "0.7054809", "0.6706905", "0.6526644", "0.6507054", "0.6507054", "0.64965016", "0.6126463", "0.6124615", "0.6026566", "0.6013546", "0.5956357", "0.59294546", "0.5917369", "0.58980083", "0.58980083", "0.5863768", "0.58041257", "0.5774745", "0.5771428", "0.565637", "0.5630689", "0.56029814", "0.5590403", "0.5540793", "0.5530199", "0.5484269", "0.54775345", "0.5464464", "0.54614997", "0.5457328", "0.541358", "0.540986", "0.53908813", "0.53624713", "0.53595024", "0.53545994", "0.5336888", "0.5327992", "0.52963454", "0.5293901", "0.5288893", "0.5288691", "0.5264519", "0.52623904", "0.52525765", "0.5250638", "0.52406687", "0.52253485", "0.52228606", "0.52069503", "0.52025014", "0.51978046", "0.51749545", "0.5169728", "0.51634544", "0.51600623", "0.5158146", "0.5148585", "0.5147973", "0.5144297", "0.51418734", "0.51329577", "0.5127217", "0.51240057", "0.5113481", "0.51109874", "0.51039976", "0.50966835", "0.50887054", "0.50887054", "0.5083", "0.508018", "0.50796163", "0.50768614", "0.50761753", "0.5056775", "0.50511926", "0.5039565", "0.5039565", "0.5038713", "0.503745", "0.5034949", "0.50319904", "0.5029698", "0.5027055", "0.5017164", "0.5016795", "0.50117373", "0.50114876", "0.5005926", "0.4999733", "0.49993855", "0.49863642", "0.49828675", "0.49765438", "0.49724004", "0.49703413", "0.495218", "0.49512842", "0.49483335" ]
0.73583215
0
Convenience wrapper to return Response.Data as a string.
Удобная обертка для возврата Response.Data в виде строки.
func (r *Response) String() string { return string(r.Data) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r Response) String() string {\n\tJSON, err := json.Marshal(r)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\treturn string(JSON)\n}", "func (r *Response) String() string {\n\tif r.Error != nil {\n\t\treturn \"\"\n\t}\n\n\tr.populateResponseByteBuffer()\n\n\treturn r.internalByteBuffer.String()\n}", "func (o SchematizedDataResponseOutput) Data() pulumi.StringOutput {\n\treturn o.ApplyT(func(v SchematizedDataResponse) string { return v.Data }).(pulumi.StringOutput)\n}", "func (this *Response) ToString() (string, error) {\n\tbytes, err := this.ReadAll()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(bytes), nil\n}", "func (self *BatchResponse) ResponseAsString() string {\n\treturn string(self.Debug.RawResponse)\n}", "func (r Response) String() string {\n\t// format:\n\t// VALUE <key> <flags> <bytes> [<cas unique>]\\r\\n\n\t//<data block>\\r\\n\n\n\tvar b bytes.Buffer\n\n\tfor i := range r.Values {\n\t\t//b.WriteString(fmt.Sprintf(\"VALUE %s %s %d\\r\\n\", r.Values[i].Key, r.Values[i].Flags, len(r.Values[i].Data)))\n\t\tb.WriteString(\"VALUE \")\n\t\tb.WriteString(r.Values[i].Key)\n\t\tb.WriteString(\" \")\n\t\tb.WriteString(r.Values[i].Flags)\n\t\tb.WriteString(\" \")\n\t\tb.WriteString(strconv.Itoa(len(r.Values[i].Data)))\n\n\t\tif r.Values[i].Cas != \"\" {\n\t\t\tb.WriteString(\" \")\n\t\t\tb.WriteString(r.Values[i].Cas)\n\t\t}\n\n\t\tb.WriteString(\"\\r\\n\")\n\n\t\tb.Write(r.Values[i].Data)\n\t\tb.WriteString(\"\\r\\n\")\n\t}\n\n\tb.WriteString(r.Response)\n\tb.WriteString(\"\\r\\n\")\n\n\treturn b.String()\n}", "func (r *Response) Data(data interface{}) JResponseWriter {\n\treturn r.Field(fieldData, data)\n}", "func (o GetRecordResultOutput) Data() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetRecordResult) string { return v.Data }).(pulumi.StringOutput)\n}", "func DataResponse(data interface{}) Response {\n\treturn Response{\n\t\tCode: 200,\n\t\tData: data,\n\t\tMessage: \"ok\",\n\t}\n}", "func StringResponse(req *http.Request, status int, headers http.Header, body string) *http.Response {\n\treturn SimpleResponse(req, status, headers, int64(len(body)), strings.NewReader(body))\n}", "func (v *DCHttpResponse) ToString() (body string, err error) {\n\tv.cacheBodyToMemory()\n\tif v.bodyErr != nil {\n\t\treturn \"\", v.bodyErr\n\t}\n\treturn string(v.body), nil\n}", "func (r *Response) ToString() string {\n\treturn r.recorder.Body.String()\n}", "func (r Response) String() string {\n\treturn fmt.Sprintf(\"%s : %s\", r.Regex.String(), r.Extra)\n}", "func (ctx *Context) Data(code int, contentType string, data []byte) {\n\tctx.Response.StatusCode = code\n\tctx.SetContentType(contentType)\n\tctx.Response.Body = ioutil.NopCloser(bytes.NewBuffer(data))\n}", "func (t AuthChallengeResponseResponse) String() string {\n\treturn string(t)\n}", "func (e Data) String() string {\n\tj, _ := e.MarshalJSON()\n\treturn string(j)\n}", "func (r *Response) String() string {\n\tif r.body == nil {\n\t\treturn \"\"\n\t}\n\treturn strings.TrimSpace(string(r.body))\n}", "func Data(status int, content []byte, headers Headers) *Response {\n\treturn &Response{\n\t\tStatus: status,\n\t\tContent: bytes.NewBuffer(content),\n\t\tHeaders: headers,\n\t}\n}", "func AsData(ip string, data interface{}) (resp Response, err error) {\n\traw, err := json.Marshal(data)\n\tif err != nil {\n\t\treturn AsError(ip, err)\n\t}\n\n\tresp = Response{\n\t\tStatusCode: 200,\n\t\tHeaders: jsonHeaders,\n\t\tBody: string(raw),\n\t}\n\treturn\n}", "func (r *Response) String() string {\n\n\tbasicCode := r.BasicCode\n\tcomment := r.Comment\n\tif len(comment) == 0 && r.BasicCode == 0 {\n\t\tvar ok bool\n\t\tif comment, ok = defaultTexts.m[EnhancedStatusCode{r.Class, r.EnhancedCode}]; !ok {\n\t\t\tswitch r.Class {\n\t\t\tcase 2:\n\t\t\t\tcomment = \"OK\"\n\t\t\tcase 4:\n\t\t\t\tcomment = \"Temporary failure.\"\n\t\t\tcase 5:\n\t\t\t\tcomment = \"Permanent failure.\"\n\t\t\t}\n\t\t}\n\t}\n\te := EnhancedStatusCode{r.Class, r.EnhancedCode}\n\tif r.BasicCode == 0 {\n\t\tbasicCode = getBasicStatusCode(e)\n\t}\n\n\treturn fmt.Sprintf(\"%d %s %s\", basicCode, e.String(), comment)\n}", "func (d *Decoder) Data() string {\n\treturn string(d.buffer)\n}", "func (c *Context) String(status int, data string) error {\n\tc.SetHeader(\"Content-Type\", \"text/plain; charset=utf-8\")\n\treturn c.Bytes(status, []byte(data))\n}", "func (s IntegrationResponse) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s IntegrationResponse) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s IntegrationResponse) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (statsResponse *StatsResponse) String() string {\n\tstatsResponseBytes, err := json.Marshal(statsResponse)\n\tif err != nil {\n\t\treturn err.Error()\n\t}\n\n\treturn string(statsResponseBytes)\n}", "func (p *Proxy) String() string {\n\treturn string(p.lastResponseBody)\n}", "func Data(w http.ResponseWriter, r *http.Request, v []byte) {\n\trender.Data(w, r, v)\n}", "func (s *ResponseModifier) String(body string) {\n\ts.Response.Body = ioutil.NopCloser(bytes.NewReader([]byte(body)))\n}", "func ResponseWithData(writer http.ResponseWriter, statusCode int, data interface{}) {\n\twriter.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\twriter.WriteHeader(statusCode)\n\tif data != nil {\n\t\tencodeBody(writer, data)\n\t}\n}", "func (s ResponseMetadata) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (si SignedIdentifiers) Response() *http.Response {\n\treturn si.rawResponse\n}", "func (o CertificateOutput) Data() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *Certificate) pulumi.StringPtrOutput { return v.Data }).(pulumi.StringPtrOutput)\n}", "func (c *Context) Write(data interface{}) {\n\t// use DataWriter to write response if possible\n\tif dw, ok := c.Response.(DataWriter); ok {\n\t\tif err := dw.WriteData(data); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\treturn\n\t}\n\n\tswitch data.(type) {\n\tcase []byte:\n\t\tc.Response.Write(data.([]byte))\n\tcase string:\n\t\tc.Response.Write([]byte(data.(string)))\n\tdefault:\n\t\tif data != nil {\n\t\t\tfmt.Fprint(c.Response, data)\n\t\t}\n\t}\n}", "func (bblr BlobsBreakLeaseResponse) Response() *http.Response {\n\treturn bblr.rawResponse\n}", "func (self *GeocodeResult) ResponseAsString() string {\n\treturn string(self.Debug.RawResponse)\n}", "func responseText(h func(r *http.Request) (interface{}, int, error)) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tdata, status, err := h(r)\n\t\tif err != nil {\n\t\t\tdata = err.Error()\n\t\t}\n\n\t\tvar b bytes.Buffer\n\t\tswitch v := data.(type) {\n\t\tcase []*storage.Item:\n\t\t\tfor _, item := range v {\n\t\t\t\t// https://www.ietf.org/rfc/rfc2046.txt says that the newline of\n\t\t\t\t// text is CRLF\n\t\t\t\tfmt.Fprintf(&b, \"%v\\r\\n\", item.Value)\n\t\t\t}\n\t\tdefault:\n\t\t\tfmt.Fprintf(&b, \"%v\\r\\n\", data)\n\t\t}\n\n\t\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\t\tw.WriteHeader(status)\n\t\tw.Write(b.Bytes())\n\t}\n}", "func (o SchematizedDataResponsePtrOutput) Data() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *SchematizedDataResponse) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.Data\n\t}).(pulumi.StringPtrOutput)\n}", "func (o SnapmirrorResyncResponse) String() string {\n\treturn ToString(reflect.ValueOf(o))\n}", "func (c *Controller) Data(data []byte) {\n ctx := c.Context()\n r := render.NewData(data)\n\n ctx.PushLog(\"status\", http.StatusOK)\n ctx.SetHeader(\"Content-Type\", r.ContentType())\n ctx.End(r.HttpCode(), r.Content())\n}", "func (self *WebServer) respData(c *gin.Context, status, code int,\n\tmessage string, data interface{}) {\n\tc.JSON(status, &CR{\n\t\tMessage: message,\n\t\tCode: code,\n\t\tTimestamp: time.Now().Unix(),\n\t})\n}", "func (dr downloadResponse) Response() *http.Response {\n\treturn dr.rawResponse\n}", "func (res Responder) String() string {\n\treturn res.b.String()\n}", "func (resp *Response) Text() (string, error) {\n\tb, err := resp.DecompressedContent()\n\ts := string(b)\n\treturn s, err\n}", "func String(c Doer, r *Request) string {\n\tc <- r\n\treturn (<-r.resp).(string)\n}", "func (r *Response) ResStr() (string, error) {\n\treturn r.ResultString, r.Error\n}", "func responseString(rw http.ResponseWriter, statusCode int, s string) {\n\trw.Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\trw.WriteHeader(statusCode)\n\trw.Write([]byte(s))\n}", "func (r *Response) Raw() []byte {\n\treturn r.raw\n}", "func (p *FsData) Data() string {\n\treturn string(p.byteS)\n}", "func (s FunctionResponse) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (o SSLHealthCheckResponseOutput) Response() pulumi.StringOutput {\n\treturn o.ApplyT(func(v SSLHealthCheckResponse) string { return v.Response }).(pulumi.StringOutput)\n}", "func (s MethodResponse) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (cdr ContainersDeleteResponse) Response() *http.Response {\n\treturn cdr.rawResponse\n}", "func (s ComponentResponse) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (r *request) Data() []byte {\n\treturn r.msg.Data\n}", "func (h *ResponseHeader) String() string {\n\treturn string(h.Header())\n}", "func (cblr ContainersBreakLeaseResponse) Response() *http.Response {\n\treturn cblr.rawResponse\n}", "func (r Response) Bytes() []byte {\n\tvar b bytes.Buffer\n\tenc := gob.NewEncoder(&b)\n\tenc.Encode(&r)\n\n\treturn b.Bytes()\n}", "func (r Response) Bytes() []byte {\n\tvar b bytes.Buffer\n\tenc := gob.NewEncoder(&b)\n\tenc.Encode(&r)\n\n\treturn b.Bytes()\n}", "func (lpr LeasePathResponse) Response() *http.Response {\n\treturn lpr.rawResponse\n}", "func (bdr BlobsDeleteResponse) Response() *http.Response {\n\treturn bdr.rawResponse\n}", "func (resp *Response) Text(e ...encoding.Encoding) (string, error) {\n\tb, err := resp.Content()\n\tif err != nil || len(e) == 0 {\n\t\treturn b2s(b), err\n\t}\n\n\tb, err = e[0].NewDecoder().Bytes(b)\n\treturn b2s(b), err\n}", "func (dpr DeletePathResponse) Response() *http.Response {\n\treturn dpr.rawResponse\n}", "func RespondData(w http.ResponseWriter, data string) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tfmt.Fprintf(w, `{\n\t\t\"data\": %s\n\t}`, string(data))\n}", "func stringifyHTTPResponseBody(r *http.Response) (body string) {\n\tif r == nil {\n\t\treturn \"\"\n\t}\n\n\tbuf := new(bytes.Buffer)\n\tbuf.ReadFrom(r.Body)\n\tbody = buf.String()\n\treturn body\n}", "func (bstr BlobsSetTierResponse) Response() *http.Response {\n\treturn bstr.rawResponse\n}", "func (c *Context) Data(statusCode int, contentType string, data []byte) {\n\tc.SetStatusCode(statusCode)\n\tc.SetContentType(contentType)\n\tc.Write(data)\n}", "func (resp *CommonRPCResponse) String() string {\n\treturn fmt.Sprintf(\"<Code: %d, Msg: %s>\", resp.Code, resp.Msg)\n}", "func (r *TestRequest) Data() []byte {\n\treturn r.data\n}", "func (o HTTPHealthCheckResponseOutput) Response() pulumi.StringOutput {\n\treturn o.ApplyT(func(v HTTPHealthCheckResponse) string { return v.Response }).(pulumi.StringOutput)\n}", "func (o HTTPSHealthCheckResponseOutput) Response() pulumi.StringOutput {\n\treturn o.ApplyT(func(v HTTPSHealthCheckResponse) string { return v.Response }).(pulumi.StringOutput)\n}", "func (bur BlobsUndeleteResponse) Response() *http.Response {\n\treturn bur.rawResponse\n}", "func (abcr AppendBlobsCreateResponse) Response() *http.Response {\n\treturn abcr.rawResponse\n}", "func (ks *KerbServer) Response() string {\n\treturn C.GoString(ks.state.response)\n}", "func (t *Transaction) Data() string {\n\treturn utils.EncodeToBase64(t.data)\n}", "func (o ExportPolicyDestroyResponse) String() string {\n\treturn ToString(reflect.ValueOf(o))\n}", "func (crlr ContainersReleaseLeaseResponse) Response() *http.Response {\n\treturn crlr.rawResponse\n}", "func (s ResponseDetails) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (ctx *Context) String(code int, s string) (err error) {\n\tctx.response.Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\tctx.response.WriteHeader(code)\n\t_, err = ctx.response.Write([]byte(s))\n\treturn\n}", "func (s *StashConsumer) Data() string {\n\tb, _ := json.Marshal(s)\n\treturn string(b)\n}", "func (s GetIntegrationResponseOutput) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (kc *KerbClient) Response() string {\n\treturn C.GoString(kc.state.response)\n}", "func (o SnapmirrorCreateResponse) String() string {\n\treturn ToString(reflect.ValueOf(o))\n}", "func encodeStringResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n\tw.Header().Set(\"Content-Type\", \"application/json;charset=utf-8\")\n\treturn json.NewEncoder(w).Encode(response)\n}", "func (sss StorageServiceStats) Response() *http.Response {\n\treturn sss.rawResponse\n}", "func (o *Posttextresponse) String() string {\n\tj, _ := json.Marshal(o)\n\tstr, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\\\u`, `\\u`, -1))\n\n\treturn str\n}", "func (brlr BlobsReleaseLeaseResponse) Response() *http.Response {\n\treturn brlr.rawResponse\n}", "func (dfr DeleteFilesystemResponse) Response() *http.Response {\n\treturn dfr.rawResponse\n}", "func (s ResponseOutputItem) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s *Server) Response(body string) string {\n\treturn \"HTTP/1.1 200 OK\\r\\n\" +\n\t\t\"Content-Length: \" + strconv.Itoa(len(body)) + lineBreaker +\n\t\t\"Content-Type: text/html\\r\\n\" +\n\t\t\"Connection: close\\r\\n\" +\n\t\tlineBreaker + body\n}", "func (o ExportPolicyCreateResponse) String() string {\n\treturn ToString(reflect.ValueOf(o))\n}", "func (s ComputeResponse) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (a *ADMResponse) Bytes() ([]byte, error) {\n\treturn json.Marshal(a)\n}", "func (o LunOnlineResponse) String() string {\n\treturn ToString(reflect.ValueOf(o))\n}", "func (o LunGetSerialNumberResponse) String() string {\n\treturn ToString(reflect.ValueOf(o))\n}", "func (bclr BlobsChangeLeaseResponse) Response() *http.Response {\n\treturn bclr.rawResponse\n}", "func (o QtreeCreateResponse) String() string {\n\treturn ToString(reflect.ValueOf(o))\n}", "func (o *Createshareresponse) String() string {\n\tj, _ := json.Marshal(o)\n\tstr, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\\\u`, `\\u`, -1))\n\n\treturn str\n}", "func GetStringFromResponse(r *http.Response) (string, error) {\n\t// If the content length is not set, limit reading to 8K worth of data.\n\treturn getResponse(r, strMax)\n}", "func (c *Context) Data(status int, v []byte) {\n\tif c.Header().Get(ContentType) == \"\" {\n\t\tc.Header().Set(ContentType, ContentBinary)\n\t}\n\tc.WriteHeader(status)\n\tc.Write(v)\n}" ]
[ "0.65663695", "0.6464477", "0.63433754", "0.62904406", "0.62059665", "0.6119778", "0.6021124", "0.6019827", "0.5965781", "0.5939541", "0.5917699", "0.5897104", "0.58647394", "0.5861402", "0.5832401", "0.5828792", "0.57842326", "0.57667345", "0.5754301", "0.56678456", "0.56670046", "0.5643823", "0.56369996", "0.56369996", "0.56369996", "0.5636495", "0.55978066", "0.55825263", "0.55708325", "0.55707943", "0.5566887", "0.5561343", "0.55561554", "0.5553434", "0.5551459", "0.554803", "0.55442375", "0.55431134", "0.55362165", "0.55351937", "0.55344903", "0.5526572", "0.5523935", "0.5521774", "0.5519714", "0.55182266", "0.5517297", "0.5507337", "0.55011487", "0.54996926", "0.5499683", "0.548567", "0.54739517", "0.54674244", "0.5462056", "0.5459856", "0.54571277", "0.54446375", "0.54446375", "0.54322565", "0.5427457", "0.542705", "0.5410796", "0.5408524", "0.5406744", "0.5406536", "0.54042363", "0.5398121", "0.5390205", "0.5381489", "0.53810036", "0.5380017", "0.53791237", "0.53728557", "0.5361761", "0.536052", "0.535204", "0.53392357", "0.53368485", "0.533627", "0.53334033", "0.5327318", "0.5325814", "0.5324395", "0.5323145", "0.5319973", "0.5318605", "0.5315278", "0.53135794", "0.53032255", "0.53005874", "0.52952033", "0.5292796", "0.5288559", "0.5286346", "0.5258392", "0.5258187", "0.52544814", "0.5247798", "0.52435917" ]
0.75903463
0
NewPolicyDefinitionsClient creates a new instance of PolicyDefinitionsClient with the specified values.
NewPolicyDefinitionsClient создает новый экземпляр PolicyDefinitionsClient с указанными значениями.
func NewPolicyDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PolicyDefinitionsClient { cp := arm.ClientOptions{} if options != nil { cp = *options } if len(cp.Host) == 0 { cp.Host = arm.AzurePublicCloud } return &PolicyDefinitionsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewRegistrationDefinitionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*RegistrationDefinitionsClient, error) {\n\tcl, err := arm.NewClient(moduleName+\".RegistrationDefinitionsClient\", moduleVersion, credential, options)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient := &RegistrationDefinitionsClient{\n\t\tinternal: cl,\n\t}\n\treturn client, nil\n}", "func NewClient(confs ...ClientConfiguration) *Client {\n\tq := setupClient()\n\n\t// Loop through the configurations and apply them to the client.\n\tfor _, c := range confs {\n\t\tc(q)\n\t}\n\n\treturn q\n}", "func NewPoliciesClient(cc grpc.ClientConnInterface) PoliciesClient { return src.NewPoliciesClient(cc) }", "func NewClient(cfg watson.Config) (Client, error) {\n\tdialog := Client{version: \"/\" + defaultMajorVersion}\n\tif len(cfg.Version) > 0 {\n\t\tdialog.version = \"/\" + cfg.Version\n\t}\n\tif len(cfg.Credentials.ServiceName) == 0 {\n\t\tcfg.Credentials.ServiceName = \"dialog\"\n\t}\n\tif len(cfg.Credentials.Url) == 0 {\n\t\tcfg.Credentials.Url = defaultUrl\n\t}\n\tclient, err := watson.NewClient(cfg.Credentials)\n\tif err != nil {\n\t\treturn Client{}, err\n\t}\n\tdialog.watsonClient = client\n\treturn dialog, nil\n}", "func NewClient(kubeClient client.Client, secretName, namespace, project string) (*gcpClient, error) {\n\tctx := context.Background()\n\tsecret := &corev1.Secret{}\n\terr := kubeClient.Get(ctx, types.NamespacedName{Namespace: namespace, Name: secretName}, secret)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tconfig, err := utils.GetCredentialsJSON(kubeClient, types.NamespacedName{Namespace: namespace, Name: secretName})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tservice, err := dnsv1.NewService(context.Background(), option.WithCredentials(config))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &gcpClient{\n\t\tclient: *service,\n\t\tproject: project,\n\t}, nil\n}", "func NewClient(options ...func(c *Client)) *Client {\n\tc := &Client{}\n\tfor _, option := range options {\n\t\toption(c)\n\t}\n\n\t// Set default user-agent if not set\n\tif c.UserAgent == \"\" {\n\t\tc.UserAgent = \"wporg/1.0\"\n\t}\n\n\t// Set default client if not set\n\tif c.HTTPClient == nil {\n\t\tc.HTTPClient = getDefaultClient()\n\t}\n\n\treturn c\n}", "func New(client *client.Client, properties ClientProperties) *Client {\n\treturn &Client{\n\t\tclient: client,\n\n\t\tflowSid: properties.FlowSid,\n\t\tsid: properties.Sid,\n\n\t\tContext: func() *context.Client {\n\t\t\treturn context.New(client, context.ClientProperties{\n\t\t\t\tExecutionSid: properties.Sid,\n\t\t\t\tFlowSid: properties.FlowSid,\n\t\t\t})\n\t\t},\n\t\tStep: func(stepSid string) *step.Client {\n\t\t\treturn step.New(client, step.ClientProperties{\n\t\t\t\tExecutionSid: properties.Sid,\n\t\t\t\tFlowSid: properties.FlowSid,\n\t\t\t\tSid: stepSid,\n\t\t\t})\n\t\t},\n\t\tSteps: steps.New(client, steps.ClientProperties{\n\t\t\tExecutionSid: properties.Sid,\n\t\t\tFlowSid: properties.FlowSid,\n\t\t}),\n\t}\n}", "func NewRoleDefinitionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *RoleDefinitionsClient {\n\tcp := arm.ClientOptions{}\n\tif options != nil {\n\t\tcp = *options\n\t}\n\tif len(cp.Host) == 0 {\n\t\tcp.Host = arm.AzurePublicCloud\n\t}\n\treturn &RoleDefinitionsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)}\n}", "func NewClient(query, list, versionsByID, byCatalogKindNameVersion, byCatalogKindNameVersionReadme, byCatalogKindNameVersionYaml, byVersionID, byCatalogKindName, byID, getRawYamlByCatalogKindNameVersion, getLatestRawYamlByCatalogKindName goa.Endpoint) *Client {\n\treturn &Client{\n\t\tQueryEndpoint: query,\n\t\tListEndpoint: list,\n\t\tVersionsByIDEndpoint: versionsByID,\n\t\tByCatalogKindNameVersionEndpoint: byCatalogKindNameVersion,\n\t\tByCatalogKindNameVersionReadmeEndpoint: byCatalogKindNameVersionReadme,\n\t\tByCatalogKindNameVersionYamlEndpoint: byCatalogKindNameVersionYaml,\n\t\tByVersionIDEndpoint: byVersionID,\n\t\tByCatalogKindNameEndpoint: byCatalogKindName,\n\t\tByIDEndpoint: byID,\n\t\tGetRawYamlByCatalogKindNameVersionEndpoint: getRawYamlByCatalogKindNameVersion,\n\t\tGetLatestRawYamlByCatalogKindNameEndpoint: getLatestRawYamlByCatalogKindName,\n\t}\n}", "func NewClient(cfg *Config) (*Client, error) {\r\n\tBaseURL := new(url.URL)\r\n\tvar err error\r\n\r\n\tviper.SetEnvPrefix(\"TS\")\r\n\tviper.BindEnv(\"LOG\")\r\n\r\n\tswitch l := viper.Get(\"LOG\"); l {\r\n\tcase \"trace\":\r\n\t\tlog.SetLevel(log.TraceLevel)\r\n\tcase \"debug\":\r\n\t\tlog.SetLevel(log.DebugLevel)\r\n\tcase \"info\":\r\n\t\tlog.SetLevel(log.InfoLevel)\r\n\tcase \"warn\":\r\n\t\tlog.SetLevel(log.WarnLevel)\r\n\tcase \"fatal\":\r\n\t\tlog.SetLevel(log.FatalLevel)\r\n\tcase \"panic\":\r\n\t\tlog.SetLevel(log.PanicLevel)\r\n\t}\r\n\r\n\tif cfg.BaseURL != \"\" {\r\n\t\tBaseURL, err = url.Parse(cfg.BaseURL)\r\n\t\tif err != nil {\r\n\t\t\treturn nil, err\r\n\t\t}\r\n\t} else {\r\n\t\tBaseURL, err = url.Parse(defaultBaseURL)\r\n\t\tif err != nil {\r\n\t\t\treturn nil, err\r\n\t\t}\r\n\t}\r\n\r\n\tnewClient := &Client{\r\n\t\tBaseURL: BaseURL,\r\n\t\tclient: http.DefaultClient,\r\n\t\tcreds: &Credentials{\r\n\t\t\tAPIKey: cfg.APIKey,\r\n\t\t\tOrganizationID: cfg.OrganizationID,\r\n\t\t\tUserID: cfg.UserID,\r\n\t\t},\r\n\t}\r\n\r\n\tnewClient.Rulesets = &RulesetService{newClient}\r\n\tnewClient.Rules = &RuleService{newClient}\r\n\r\n\treturn newClient, nil\r\n}", "func NewClient(apiDef *raml.APIDefinition, packageName, rootImportPath, targetDir string,\n\tlibsRootURLs []string) (Client, error) {\n\t// rootImportPath only needed if we use libraries\n\tif rootImportPath == \"\" && len(apiDef.Libraries) > 0 {\n\t\treturn Client{}, fmt.Errorf(\"--import-path can't be empty when we use libraries\")\n\t}\n\n\trootImportPath = setRootImportPath(rootImportPath, targetDir)\n\tglobRootImportPath = rootImportPath\n\tglobAPIDef = apiDef\n\tglobLibRootURLs = libsRootURLs\n\n\tservices := map[string]*ClientService{}\n\tfor k, v := range apiDef.Resources {\n\t\trd := resource.New(apiDef, commons.NormalizeURITitle(apiDef.Title), packageName)\n\t\trd.GenerateMethods(&v, langGo, newServerMethod, newGoClientMethod)\n\t\tservices[k] = &ClientService{\n\t\t\trootEndpoint: k,\n\t\t\tPackageName: packageName,\n\t\t\tMethods: rd.Methods,\n\t\t}\n\t}\n\tclient := Client{\n\t\tapiDef: apiDef,\n\t\tName: escapeIdentifier(commons.NormalizeURI(apiDef.Title)),\n\t\tBaseURI: apiDef.BaseURI,\n\t\tlibraries: apiDef.Libraries,\n\t\tPackageName: packageName,\n\t\tRootImportPath: rootImportPath,\n\t\tServices: services,\n\t\tTargetDir: targetDir,\n\t\tlibsRootURLs: libsRootURLs,\n\t}\n\n\tif strings.Index(client.BaseURI, \"{version}\") > 0 {\n\t\tclient.BaseURI = strings.Replace(client.BaseURI, \"{version}\", apiDef.Version, -1)\n\t}\n\treturn client, nil\n}", "func New(client *client.Client, properties ClientProperties) *Client {\n\treturn &Client{\n\t\tclient: client,\n\n\t\tidentity: properties.Identity,\n\t\tserviceSid: properties.ServiceSid,\n\n\t\tChallenge: func(challengeSid string) *challenge.Client {\n\t\t\treturn challenge.New(client, challenge.ClientProperties{\n\t\t\t\tIdentity: properties.Identity,\n\t\t\t\tServiceSid: properties.ServiceSid,\n\t\t\t\tSid: challengeSid,\n\t\t\t})\n\t\t},\n\t\tChallenges: challenges.New(client, challenges.ClientProperties{\n\t\t\tIdentity: properties.Identity,\n\t\t\tServiceSid: properties.ServiceSid,\n\t\t}),\n\t\tFactor: func(factorSid string) *factor.Client {\n\t\t\treturn factor.New(client, factor.ClientProperties{\n\t\t\t\tIdentity: properties.Identity,\n\t\t\t\tServiceSid: properties.ServiceSid,\n\t\t\t\tSid: factorSid,\n\t\t\t})\n\t\t},\n\t\tFactors: factors.New(client, factors.ClientProperties{\n\t\t\tIdentity: properties.Identity,\n\t\t\tServiceSid: properties.ServiceSid,\n\t\t}),\n\t}\n}", "func NewClient(pluginsDir, configsDir string) (*client, error) {\n\treturn &client{\n\t\tpluginsDir: pluginsDir,\n\t\tconfigsDir: configsDir,\n\t}, nil\n}", "func NewPolicyClient(cfg aws.Config) PolicyClient {\n\treturn iam.NewFromConfig(cfg)\n}", "func (c *clientsFactory) PoliciesClient() (authz.PoliciesServiceClient, error) {\n\tconn, err := c.connectionByName(\"authz-service\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn authz.NewPoliciesServiceClient(conn), nil\n}", "func NewClient() (*Client, error) {\n\tgoprscClient, err := newGoprscClient()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to initialize Postfix REST Server API client: %s\", err)\n\t}\n\n\tc := &Client{client: goprscClient}\n\ts := service{client: goprscClient} // Reuse the same structure instead of allocating one for each service\n\tc.Auth = (*AuthService)(&s)\n\tc.Domains = (*DomainService)(&s)\n\tc.Accounts = (*AccountService)(&s)\n\tc.Aliases = (*AliasService)(&s)\n\t// Allocate separate structs for the BCC services as they have different state\n\tc.InputBccs = NewInputBccService(goprscClient)\n\tc.OutputBccs = NewOutputBccService(goprscClient)\n\treturn c, nil\n}", "func NewClient(cfg *restclient.Config) (Client, error) {\n\tresult := &client{}\n\tc, err := dynamic.NewForConfig(cfg)\n\tif err != nil {\n\t\tmsg := fmt.Sprintf(\"Failed to create client, with error: %v\", err)\n\t\tlog.Printf(\"[Error] %s\", msg)\n\t\treturn nil, fmt.Errorf(msg)\n\t}\n\tresult.dynamicClient = c\n\treturn result, nil\n}", "func NewClient(secretBytes []byte, authorizeHandler func(string) (string, error)) (Client, error) {\n\tvar secret map[string]interface{}\n\tif err := json.Unmarshal(secretBytes, &secret); err != nil {\n\t\treturn nil, err\n\t}\n\tif authorizeHandler == nil {\n\t\tauthorizeHandler = defaultAuthorizeFlowHandler\n\t}\n\n\t// TODO: support \"web\" client secret by using a local web server.\n\t// According to the content in the json, decide whether to run three-legged\n\t// flow (for client secret) or two-legged flow (for service account).\n\tif installed, ok := secret[\"installed\"]; ok {\n\t\t// When the secret contains \"installed\" field, it is a client secret. We\n\t\t// will run a three-legged flow\n\t\tinstalledMap, ok := installed.(map[string]interface{})\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"Malformatted secret json, expected map for param \\\"installed\\\"\")\n\t\t}\n\t\treturn ThreeLeggedClient{installedMap, authorizeHandler}, nil\n\t} else if tokenType, ok := secret[\"type\"]; ok && \"service_account\" == tokenType {\n\t\t// If the token type is \"service_account\", we will run the two-legged flow\n\t\treturn TwoLeggedClient{secret}, nil\n\t} else {\n\t\treturn nil, fmt.Errorf(\"Unsupported token type.\")\n\t}\n}", "func New(client *client.Client, properties ClientProperties) *Client {\n\treturn &Client{\n\t\tclient: client,\n\n\t\tserviceSid: properties.ServiceSid,\n\t\tsid: properties.Sid,\n\n\t\tMessage: func(messageSid string) *message.Client {\n\t\t\treturn message.New(client, message.ClientProperties{\n\t\t\t\tConversationSid: properties.Sid,\n\t\t\t\tServiceSid: properties.ServiceSid,\n\t\t\t\tSid: messageSid,\n\t\t\t})\n\t\t},\n\t\tMessages: messages.New(client, messages.ClientProperties{\n\t\t\tConversationSid: properties.Sid,\n\t\t\tServiceSid: properties.ServiceSid,\n\t\t}),\n\t\tParticipant: func(participantSid string) *participant.Client {\n\t\t\treturn participant.New(client, participant.ClientProperties{\n\t\t\t\tConversationSid: properties.Sid,\n\t\t\t\tServiceSid: properties.ServiceSid,\n\t\t\t\tSid: participantSid,\n\t\t\t})\n\t\t},\n\t\tParticipants: participants.New(client, participants.ClientProperties{\n\t\t\tConversationSid: properties.Sid,\n\t\t\tServiceSid: properties.ServiceSid,\n\t\t}),\n\t\tWebhook: func(webhookSid string) *webhook.Client {\n\t\t\treturn webhook.New(client, webhook.ClientProperties{\n\t\t\t\tConversationSid: properties.Sid,\n\t\t\t\tServiceSid: properties.ServiceSid,\n\t\t\t\tSid: webhookSid,\n\t\t\t})\n\t\t},\n\t\tWebhooks: webhooks.New(client, webhooks.ClientProperties{\n\t\t\tConversationSid: properties.Sid,\n\t\t\tServiceSid: properties.ServiceSid,\n\t\t}),\n\t}\n}", "func NewClient(name string, initAddrs ...string) (*Client, error) {\n\tc := new(Client)\n\n\tlog.Debugf(\"pd-client: initial pds, pds=<%v>\",\n\t\tinitAddrs)\n\n\tc.name = name\n\tc.addrs = append(c.addrs, initAddrs...)\n\tc.seq = 0\n\n\terr := c.resetConn()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn c, nil\n}", "func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {\n\tclientOpts := defaultGRPCClientOptions()\n\tif newClientHook != nil {\n\t\thookOpts, err := newClientHook(ctx, clientHookParams{})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tclientOpts = append(clientOpts, hookOpts...)\n\t}\n\n\tconnPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient := Client{CallOptions: defaultCallOptions()}\n\n\tc := &gRPCClient{\n\t\tconnPool: connPool,\n\t\tclient: osconfigpb.NewOsConfigServiceClient(connPool),\n\t\tCallOptions: &client.CallOptions,\n\t}\n\tc.setGoogleClientInfo()\n\n\tclient.internalClient = c\n\n\treturn &client, nil\n}", "func New(c rest.Interface) *Clientset {\n\tvar cs Clientset\n\tcs.policiesV1alpha2 = policiesv1alpha2.New(c)\n\n\tcs.DiscoveryClient = discovery.NewDiscoveryClient(c)\n\treturn &cs\n}", "func NewClient(cfg watson.Config) (Client, error) {\n\tci := Client{version: \"/\" + defaultMajorVersion}\n\tif len(cfg.Credentials.ServiceName) == 0 {\n\t\tcfg.Credentials.ServiceName = \"retrieve_and_rank\"\n\t}\n\tif len(cfg.Credentials.Url) == 0 {\n\t\tcfg.Credentials.Url = defaultUrl\n\t}\n\tclient, err := watson.NewClient(cfg.Credentials)\n\tif err != nil {\n\t\treturn Client{}, err\n\t}\n\tci.watsonClient = client\n\treturn ci, nil\n}", "func New(client *client.Client, properties ClientProperties) *Client {\n\treturn &Client{\n\t\tclient: client,\n\n\t\taccountSid: properties.AccountSid,\n\t\tdomainSid: properties.DomainSid,\n\t\tsid: properties.Sid,\n\t}\n}", "func New(client *client.Client, properties ClientProperties) *Client {\n\treturn &Client{\n\t\tclient: client,\n\n\t\tserviceSid: properties.ServiceSid,\n\t}\n}", "func NewPolicyStatesClient() PolicyStatesClient {\n\treturn NewPolicyStatesClientWithBaseURI(DefaultBaseURI)\n}", "func New(client *client.Client, properties ClientProperties) *Client {\n\treturn &Client{\n\t\tclient: client,\n\n\t\tsid: properties.Sid,\n\n\t\tAccessTokens: access_tokens.New(client, access_tokens.ClientProperties{\n\t\t\tServiceSid: properties.Sid,\n\t\t}),\n\t\tEntities: entities.New(client, entities.ClientProperties{\n\t\t\tServiceSid: properties.Sid,\n\t\t}),\n\t\tEntity: func(identity string) *entity.Client {\n\t\t\treturn entity.New(client, entity.ClientProperties{\n\t\t\t\tIdentity: identity,\n\t\t\t\tServiceSid: properties.Sid,\n\t\t\t})\n\t\t},\n\t\tMessagingConfiguration: func(countryCode string) *messaging_configuration.Client {\n\t\t\treturn messaging_configuration.New(client, messaging_configuration.ClientProperties{\n\t\t\t\tCountryCode: countryCode,\n\t\t\t\tServiceSid: properties.Sid,\n\t\t\t})\n\t\t},\n\t\tMessagingConfigurations: messaging_configurations.New(client, messaging_configurations.ClientProperties{\n\t\t\tServiceSid: properties.Sid,\n\t\t}),\n\t\tRateLimit: func(rateLimitSid string) *rate_limit.Client {\n\t\t\treturn rate_limit.New(client, rate_limit.ClientProperties{\n\t\t\t\tServiceSid: properties.Sid,\n\t\t\t\tSid: rateLimitSid,\n\t\t\t})\n\t\t},\n\t\tRateLimits: rate_limits.New(client, rate_limits.ClientProperties{\n\t\t\tServiceSid: properties.Sid,\n\t\t}),\n\t\tVerification: func(verificationSid string) *verification.Client {\n\t\t\treturn verification.New(client, verification.ClientProperties{\n\t\t\t\tServiceSid: properties.Sid,\n\t\t\t\tSid: verificationSid,\n\t\t\t})\n\t\t},\n\t\tVerificationCheck: verification_check.New(client, verification_check.ClientProperties{\n\t\t\tServiceSid: properties.Sid,\n\t\t}),\n\t\tVerifications: verifications.New(client, verifications.ClientProperties{\n\t\t\tServiceSid: properties.Sid,\n\t\t}),\n\t\tWebhook: func(webhookSid string) *webhook.Client {\n\t\t\treturn webhook.New(client, webhook.ClientProperties{\n\t\t\t\tServiceSid: properties.Sid,\n\t\t\t\tSid: webhookSid,\n\t\t\t})\n\t\t},\n\t\tWebhooks: webhooks.New(client, webhooks.ClientProperties{\n\t\t\tServiceSid: properties.Sid,\n\t\t}),\n\t}\n}", "func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {\n\tclientOpts := defaultGRPCClientOptions()\n\tif newClientHook != nil {\n\t\thookOpts, err := newClientHook(ctx, clientHookParams{})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tclientOpts = append(clientOpts, hookOpts...)\n\t}\n\n\tconnPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient := Client{CallOptions: defaultCallOptions()}\n\n\tc := &gRPCClient{\n\t\tconnPool: connPool,\n\t\tclient: firestorepb.NewFirestoreClient(connPool),\n\t\tCallOptions: &client.CallOptions,\n\t\toperationsClient: longrunningpb.NewOperationsClient(connPool),\n\t}\n\tc.setGoogleClientInfo()\n\n\tclient.internalClient = c\n\n\treturn &client, nil\n}", "func NewClient(api client.KeysAPI) storage.Client {\n\treturn &Client{\n\t\tAPI: api,\n\t}\n}", "func NewClient(config *clientcmdapi.Config, log log.Logger, commandPath string) Client {\n\treturn &client{\n\t\tconfig: config,\n\t\tlog: log,\n\t\thelmPath: commandPath,\n\t}\n}", "func NewClient(userList, getUser, createUser, updateUser, deleteUser goa.Endpoint) *Client {\n\treturn &Client{\n\t\tUserListEndpoint: userList,\n\t\tGetUserEndpoint: getUser,\n\t\tCreateUserEndpoint: createUser,\n\t\tUpdateUserEndpoint: updateUser,\n\t\tDeleteUserEndpoint: deleteUser,\n\t}\n}", "func NewClient(kclient k8s.Client) (*Client, error) {\n\tctx := context.Background()\n\tsecret := &corev1.Secret{}\n\terr := kclient.Get(\n\t\tctx,\n\t\ttypes.NamespacedName{\n\t\t\tName: config.GCPSecretName,\n\t\t\tNamespace: config.OperatorNamespace,\n\t\t},\n\t\tsecret)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"couldn't get Secret with credentials %w\", err)\n\t}\n\tserviceAccountJSON, ok := secret.Data[\"service_account.json\"]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"access credentials missing service account\")\n\t}\n\n\t// initialize actual client\n\tc, err := newClient(ctx, serviceAccountJSON)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"couldn't create GCP client %s\", err)\n\t}\n\n\t// enchant the client with params required\n\tregion, err := getClusterRegion(kclient)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tc.region = region\n\n\tmasterList, err := baseutils.GetMasterMachines(kclient)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tc.masterList = masterList\n\tinfrastructureName, err := baseutils.GetClusterName(kclient)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tc.clusterName = infrastructureName\n\tbaseDomain, err := baseutils.GetClusterBaseDomain(kclient)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tc.baseDomain = baseDomain\n\n\treturn c, nil\n}", "func NewGroupPolicyDefinition()(*GroupPolicyDefinition) {\n m := &GroupPolicyDefinition{\n Entity: *NewEntity(),\n }\n return m\n}", "func NewClient(opts ...func(c *Client) error) (*Client, error) {\n\tc := &Client{\n\t\tclient: http.DefaultClient,\n\t\tBasePath: basePath,\n\t}\n\tc.common.client = c\n\tfor _, opt := range opts {\n\t\tif err := opt(c); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tc.Run = (*RunService)(&c.common)\n\n\treturn c, nil\n}", "func NewClient() *Client {\n\tclient := &Client{\n\t\tapi: C.Create(),\n\t\tVariables: map[SettableVariable]string{},\n\t\tTrim: true,\n\t\tshouldInit: true,\n\t\tLanguages: []string{\"eng\"},\n\t}\n\treturn client\n}", "func NewGCPClient(keys, projectName string) (*GCPClient, error) {\n\tlog.Debugf(\"Connecting to GCP\")\n\tctx := context.Background()\n\tvar client *GCPClient\n\tif projectName == \"\" {\n\t\treturn nil, fmt.Errorf(\"the project name is not specified\")\n\t}\n\tif keys != \"\" {\n\t\tlog.Debugf(\"Using Keys %s\", keys)\n\t\tf, err := os.Open(keys)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tjsonKey, err := io.ReadAll(f)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tconfig, err := google.JWTConfigFromJSON(jsonKey,\n\t\t\tstorage.DevstorageReadWriteScope,\n\t\t\tcompute.ComputeScope,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tclient = &GCPClient{\n\t\t\tclient: config.Client(ctx),\n\t\t\tprojectName: projectName,\n\t\t}\n\t} else {\n\t\tlog.Debugf(\"Using Application Default credentials\")\n\t\tgc, err := google.DefaultClient(\n\t\t\tctx,\n\t\t\tstorage.DevstorageReadWriteScope,\n\t\t\tcompute.ComputeScope,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tclient = &GCPClient{\n\t\t\tclient: gc,\n\t\t\tprojectName: projectName,\n\t\t}\n\t}\n\n\tvar err error\n\tclient.compute, err = compute.NewService(ctx, option.WithHTTPClient(client.client))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient.storage, err = storage.NewService(ctx, option.WithHTTPClient(client.client))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlog.Debugf(\"Generating SSH Keypair\")\n\tclient.privKey, err = rsa.GenerateKey(rand.Reader, 2048)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn client, nil\n}", "func NewClient(projectID string) (*Client, error) {\n\tctx := context.Background()\n\toauthClient, err := google.DefaultClient(ctx, dataflow.CloudPlatformScope)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tservice, err := dataflow.New(oauthClient)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Client{\n\t\tservice: service,\n\t\tprojectID: projectID,\n\t}, nil\n}", "func (f *extendedPodFactory) CreateClient(cfg *rest.Config) (interface{}, error) {\n\treturn f.client, nil\n}", "func NewClient(cfg Config) (*Client, error) {\n\tvar (\n\t\tc Client\n\t\tv *validator.Validate\n\t\terr error\n\t)\n\n\tv = validator.New()\n\n\terr = v.Struct(cfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tc.cfg = cfg\n\tc.clntCredCfg = clientcredentials.Config{\n\t\tClientID: cfg.ClientID,\n\t\tClientSecret: cfg.ClientSecret,\n\t}\n\n\tc.oauth = OAuth{\n\t\tClientID: cfg.ClientID,\n\t\tClientSecret: cfg.ClientSecret,\n\t}\n\n\terr = c.SetRegionParameters(cfg.Region, cfg.Locale)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &c, nil\n}", "func (o *ClientConfig) NewClient(options ...ClientOption) (Client, error) {\n\n\t// Run provided ClientOption configuration options.\n\tfor _, opt := range options {\n\t\terr := opt(o)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed applying functional option: %w\", err)\n\t\t}\n\t}\n\n\t// Check mandatory option is provided.\n\tif o.githubUserClient == nil {\n\t\treturn nil, fmt.Errorf(\"github client not provided\")\n\t}\n\n\ttokenGenerator := secret.GetTokenGenerator(o.tokenPath)\n\n\tgitFactory, err := o.GitClient(o.githubUserClient, tokenGenerator, secret.Censor, false)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tgitClient := &client{}\n\t// Initialize map to enable writing to it in methods.\n\tgitClient.clonedRepos = make(map[string]string)\n\tgitClient.ClientFactory = gitFactory\n\treturn gitClient, err\n}", "func NewClient(cacheDir string, quiet bool, policyBundleRepo string, opts ...Option) (*Client, error) {\n\to := &options{\n\t\tclock: clock.RealClock{},\n\t}\n\n\tfor _, opt := range opts {\n\t\topt(o)\n\t}\n\n\tif policyBundleRepo == \"\" {\n\t\tpolicyBundleRepo = fmt.Sprintf(\"%s:%d\", BundleRepository, BundleVersion)\n\t}\n\n\treturn &Client{\n\t\toptions: o,\n\t\tpolicyDir: filepath.Join(cacheDir, \"policy\"),\n\t\tpolicyBundleRepo: policyBundleRepo,\n\t\tquiet: quiet,\n\t}, nil\n}", "func NewClient(cfg *rest.Config) (versioned.Interface, error) {\n\tglog.Info(\"NewClient()\")\n\tscheme := runtime.NewScheme()\n\tif err := v1.AddToScheme(scheme); err != nil {\n\t\treturn nil, err\n\t}\n\n\tconfig := *cfg\n\tconfig.GroupVersion = &v1.SchemeGroupVersion\n\tconfig.APIPath = \"/apis\"\n\tconfig.ContentType = runtime.ContentTypeJSON\n\tconfig.NegotiatedSerializer = serializer.WithoutConversionCodecFactory{CodecFactory: serializer.NewCodecFactory(scheme)}\n\n\tcs, err := versioned.NewForConfig(&config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn cs, nil\n}", "func New(client *client.Client, properties ClientProperties) *Client {\n\treturn &Client{\n\t\tclient: client,\n\n\t\taccountSid: properties.AccountSid,\n\t\tcallSid: properties.CallSid,\n\t}\n}", "func NewClient(kubeConfig string, opts ...ClientOption) (*Client, error) {\n\toptions := clientOptions{ // Default options\n\t\tNamespace: \"default\",\n\t\tDriver: \"secrets\",\n\t\tDebugLog: func(format string, v ...interface{}) {},\n\t}\n\tfor _, opt := range opts {\n\t\topt.apply(&options)\n\t}\n\t// Create actionConfig, which will be used for all actions of this helm client.\n\tactionConfig := new(action.Configuration)\n\tclientGetter := &restClientGetter{\n\t\tNamespace: options.Namespace,\n\t\tKubeConfig: kubeConfig,\n\t}\n\tif err := actionConfig.Init(clientGetter, options.Namespace, options.Driver, options.DebugLog); err != nil {\n\t\treturn nil, err\n\t}\n\tc := &Client{\n\t\tkubeConfig: kubeConfig,\n\t\toptions: options,\n\t\tactionConfig: actionConfig,\n\t\trepoFile: repo.NewFile(),\n\t}\n\tif err := c.setupDirs(); err != nil {\n\t\tc.Close()\n\t\treturn nil, err\n\t}\n\treturn c, nil\n}", "func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {\n\tclientOpts := defaultGRPCClientOptions()\n\tif newClientHook != nil {\n\t\thookOpts, err := newClientHook(ctx, clientHookParams{})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tclientOpts = append(clientOpts, hookOpts...)\n\t}\n\n\tconnPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient := Client{CallOptions: defaultCallOptions()}\n\n\tc := &gRPCClient{\n\t\tconnPool: connPool,\n\t\tclient: cloudtaskspb.NewCloudTasksClient(connPool),\n\t\tCallOptions: &client.CallOptions,\n\t\tlocationsClient: locationpb.NewLocationsClient(connPool),\n\t}\n\tc.setGoogleClientInfo()\n\n\tclient.internalClient = c\n\n\treturn &client, nil\n}", "func (client *PolicyDefinitionsClient) listCreateRequest(ctx context.Context, options *PolicyDefinitionsListOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\tif options != nil && options.Top != nil {\n\t\treqQP.Set(\"$top\", strconv.FormatInt(int64(*options.Top), 10))\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tunencodedParams := []string{req.Raw().URL.RawQuery}\n\tif options != nil && options.Filter != nil {\n\t\tunencodedParams = append(unencodedParams, \"$filter=\"+*options.Filter)\n\t}\n\treq.Raw().URL.RawQuery = strings.Join(unencodedParams, \"&\")\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func NewClient(conn *rpcc.Conn) *domainClient {\n\treturn &domainClient{conn: conn}\n}", "func NewClient(conn *rpcc.Conn) *domainClient {\n\treturn &domainClient{conn: conn}\n}", "func NewClient(conn *rpcc.Conn) *domainClient {\n\treturn &domainClient{conn: conn}\n}", "func newClient(configuration *Configuration, options ...ClientOption) (Client, error) {\n\tclientCfg, err := newTLSClientConfig(configuration)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading and/or parsing the certification files. Cause: %w\", err)\n\t}\n\n\tnetClient := http.Client{\n\t\tTransport: &http.Transport{\n\t\t\tTLSClientConfig: clientCfg,\n\t\t},\n\t}\n\n\tinstance := &client{client: &netClient, configuration: configuration, encoder: newJSONEncoder(), decoder: newJSONDecoder()}\n\n\t// Apply options if there are any, can overwrite default\n\tfor _, option := range options {\n\t\toption(instance)\n\t}\n\n\treturn instance, nil\n}", "func New(client *client.Client, properties ClientProperties) *Client {\n\treturn &Client{\n\t\tclient: client,\n\n\t\taccountSid: properties.AccountSid,\n\t\tcountryCode: properties.CountryCode,\n\t}\n}", "func NewAccountQuotaPolicyClient(subscriptionID string) AccountQuotaPolicyClient {\n return NewAccountQuotaPolicyClientWithBaseURI(DefaultBaseURI, subscriptionID)\n}", "func NewClient(graphql GraphQLClient, opts ...ClientOption) *Client {\n\tc := &Client{graphQLAPI: graphql}\n\tfor _, opt := range opts {\n\t\topt(c)\n\t}\n\treturn c\n}", "func New() (*Client, error) {\n\tvar client Client\n\tvar err error\n\n\t// initialize client-go clients\n\tloadingRules := clientcmd.NewDefaultClientConfigLoadingRules()\n\tconfigOverrides := &clientcmd.ConfigOverrides{}\n\tclient.KubeConfig = clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides)\n\n\tclient.KubeClientConfig, err = client.KubeConfig.ClientConfig()\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, errorMsg)\n\t}\n\n\tclient.KubeClient, err = kubernetes.NewForConfig(client.KubeClientConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient.Namespace, _, err = client.KubeConfig.Namespace()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient.OperatorClient, err = operatorsclientset.NewForConfig(client.KubeClientConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient.DynamicClient, err = dynamic.NewForConfig(client.KubeClientConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &client, nil\n}", "func NewClient() (*Client, error) {\n\tpipePath := client.PipePath(GroupName, Version)\n\treturn NewClientWithPipePath(pipePath)\n}", "func NewClient(c credentials) Client {\n\treturn Client{\n\t\tcredentials: c,\n\t\tAPIVersion: defaultAPIVersion,\n\t\tEndpoint: defaultEndpoint,\n\t\tDebug: false,\n\t\thttpClient: &http.Client{},\n\t\tLogger: defaultLogger,\n\t}\n}", "func NewClient(httpClient *http.Client) (*Client, error) {\n\tif httpClient == nil {\n\t\thttpClient = http.DefaultClient\n\t}\n\n\tc := &Client{}\n\n\tbaseURL, _ := url.Parse(DefaultBaseURL)\n\tvsspsBaseURL, _ := url.Parse(DefaultVsspsBaseURL)\n\tvsaexBaseURL, _ := url.Parse(DefaultVsaexBaseURL)\n\n\tc.client = httpClient\n\tc.BaseURL = *baseURL\n\tc.VsspsBaseURL = *vsspsBaseURL\n\tc.VsaexBaseURL = *vsaexBaseURL\n\tc.UserAgent = userAgent\n\n\tc.Boards = &BoardsService{client: c}\n\tc.BuildDefinitions = &BuildDefinitionsService{client: c}\n\tc.Builds = &BuildsService{client: c}\n\tc.DeliveryPlans = &DeliveryPlansService{client: c}\n\tc.Favourites = &FavouritesService{client: c}\n\tc.Git = &GitService{client: c}\n\tc.Iterations = &IterationsService{client: c}\n\tc.PolicyEvaluations = &PolicyEvaluationsService{client: c}\n\tc.PullRequests = &PullRequestsService{client: c}\n\tc.Teams = &TeamsService{client: c}\n\tc.Tests = &TestsService{client: c}\n\tc.Users = &UsersService{client: c}\n\tc.UserEntitlements = &UserEntitlementsService{client: c}\n\tc.WorkItems = &WorkItemsService{client: c}\n\n\treturn c, nil\n}", "func NewHCRPAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*HCRPAssignmentsClient, error) {\n\tcl, err := arm.NewClient(moduleName+\".HCRPAssignmentsClient\", moduleVersion, credential, options)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient := &HCRPAssignmentsClient{\n\t\tsubscriptionID: subscriptionID,\n\t\tinternal: cl,\n\t}\n\treturn client, nil\n}", "func NewCreatePolicyParamsWithHTTPClient(client *http.Client) *CreatePolicyParams {\n\tvar ()\n\treturn &CreatePolicyParams{\n\t\tHTTPClient: client,\n\t}\n}", "func New(ctx context.Context, credentials, token string, opts ...ClientOption) (*Client, error) {\r\n\r\n\tclient := &Client{\r\n\t\tscope: \"https://www.googleapis.com/auth/spreadsheets.readonly\",\r\n\t}\r\n\r\n\tfor _, opt := range opts {\r\n\t\tclient = opt(client)\r\n\t}\r\n\r\n\treturn new(ctx, credentials, token, client)\r\n}", "func NewClient(clientType int, credentials Credentials) (*Client, error) {\n\tvar client Client\n\n\tswitch clientType {\n\tcase ClientTypeATT:\n\t\tclient = ATTClient{\n\t\t\tcredentials: credentials,\n\t\t}\n\tcase ClientTypeVerizon:\n\t\tclient = VerizonClient{\n\t\t\tcredentials: credentials,\n\t\t}\n\t}\n\n\treturn &client, nil\n}", "func NewClient(cfg *rest.Config) (versioned.Interface, error) {\n\tscheme := runtime.NewScheme()\n\tif err := api.AddToScheme(scheme); err != nil {\n\t\treturn nil, err\n\t}\n\n\tconfig := *cfg\n\tconfig.GroupVersion = &api.SchemeGroupVersion\n\tconfig.APIPath = \"/apis\"\n\tconfig.ContentType = runtime.ContentTypeJSON\n\tconfig.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: serializer.NewCodecFactory(scheme)}\n\n\tcs, err := versioned.NewForConfig(&config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn cs, nil\n}", "func NewClient(registry *syncbase.Registry, dispatcher orchestrator.Dispatcher) ConfigClient {\n\treturn &client{\n\t\tregistry: registry,\n\t\tdispatcher: dispatcher,\n\t}\n}", "func NewClient(list, create, show, update, delete_ goa.Endpoint) *Client {\n\treturn &Client{\n\t\tListEndpoint: list,\n\t\tCreateEndpoint: create,\n\t\tShowEndpoint: show,\n\t\tUpdateEndpoint: update,\n\t\tDeleteEndpoint: delete_,\n\t}\n}", "func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {\n\tclientOpts := defaultGRPCClientOptions()\n\tif newClientHook != nil {\n\t\thookOpts, err := newClientHook(ctx, clientHookParams{})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tclientOpts = append(clientOpts, hookOpts...)\n\t}\n\n\tconnPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient := Client{CallOptions: defaultCallOptions()}\n\n\tc := &gRPCClient{\n\t\tconnPool: connPool,\n\t\tclient: serviceusagepb.NewServiceUsageClient(connPool),\n\t\tCallOptions: &client.CallOptions,\n\t}\n\tc.setGoogleClientInfo()\n\n\tclient.internalClient = c\n\n\tclient.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))\n\tif err != nil {\n\t\t// This error \"should not happen\", since we are just reusing old connection pool\n\t\t// and never actually need to dial.\n\t\t// If this does happen, we could leak connp. However, we cannot close conn:\n\t\t// If the user invoked the constructor with option.WithGRPCConn,\n\t\t// we would close a connection that's still in use.\n\t\t// TODO: investigate error conditions.\n\t\treturn nil, err\n\t}\n\tc.LROClient = &client.LROClient\n\treturn &client, nil\n}", "func NewClient(conf ClientConfig) (*Client, error) {\n\tkubeClient, kubeConfig, err := getKubeClient(conf.DNSAddress)\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\ttunnel, err := portforwarder.New(\"kube-system\", kubeClient, kubeConfig)\n\tif err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\toptions := []helm.Option{\n\t\thelm.Host(fmt.Sprintf(\"127.0.0.1:%d\", tunnel.Local)),\n\t}\n\treturn &Client{\n\t\tclient: helm.NewClient(options...),\n\t\ttunnel: tunnel,\n\t}, nil\n}", "func NewPipelinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PipelinesClient, error) {\n\tcl, err := arm.NewClient(moduleName+\".PipelinesClient\", moduleVersion, credential, options)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient := &PipelinesClient{\n\t\tsubscriptionID: subscriptionID,\n\t\tinternal: cl,\n\t}\n\treturn client, nil\n}", "func newClientFromFlags(fs tbnflag.FlagSet) client {\n\treturn &clientImpl{}\n}", "func NewPermissionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *PermissionsClient {\n\tcp := arm.ClientOptions{}\n\tif options != nil {\n\t\tcp = *options\n\t}\n\tif len(cp.Endpoint) == 0 {\n\t\tcp.Endpoint = arm.AzurePublicCloud\n\t}\n\tclient := &PermissionsClient{\n\t\thost: string(cp.Endpoint),\n\t\tpl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, &cp),\n\t}\n\treturn client\n}", "func New(clientID string, options ...Option) (Client, error) {\n\topts := clientOptions{\n\t\tauthority: base.AuthorityPublicCloud,\n\t\thttpClient: shared.DefaultClient,\n\t}\n\n\tfor _, o := range options {\n\t\to(&opts)\n\t}\n\tif err := opts.validate(); err != nil {\n\t\treturn Client{}, err\n\t}\n\n\tbase, err := base.New(clientID, opts.authority, oauth.New(opts.httpClient), base.WithCacheAccessor(opts.accessor), base.WithClientCapabilities(opts.capabilities), base.WithInstanceDiscovery(!opts.disableInstanceDiscovery))\n\tif err != nil {\n\t\treturn Client{}, err\n\t}\n\treturn Client{base}, nil\n}", "func NewClient(t string) *gophercloud.ServiceClient {\n\tvar err error\n\tao, region, err := authMethod()\n\tif err != nil {\n\t\tfmt.Printf(\"Error retrieving authentication credentials: %s\\n\", err)\n\t}\n\tif ao.IdentityEndpoint == \"\" {\n\t\tao.IdentityEndpoint = rackspace.RackspaceUSIdentity\n\t}\n\tpc, err := rackspace.AuthenticatedClient(ao)\n\tif err != nil {\n\t\tfmt.Printf(\"Error creating ProviderClient: %s\\n\", err)\n\t\tos.Exit(1)\n\t}\n\tvar sc *gophercloud.ServiceClient\n\tswitch t {\n\tcase \"compute\":\n\t\tsc, err = rackspace.NewComputeV2(pc, gophercloud.EndpointOpts{\n\t\t\tRegion: region,\n\t\t})\n\t\tbreak\n\tcase \"blockstorage\":\n\t\tsc, err = rackspace.NewBlockStorageV1(pc, gophercloud.EndpointOpts{\n\t\t\tRegion: region,\n\t\t})\n\t\tbreak\n\tcase \"networking\":\n\t\tsc, err = rackspace.NewNetworkV2(pc, gophercloud.EndpointOpts{\n\t\t\tRegion: region,\n\t\t})\n\t\tbreak\n\t}\n\tif err != nil {\n\t\tfmt.Printf(\"Error creating ServiceClient (%s): %s\\n\", err, t)\n\t\tos.Exit(1)\n\t}\n\t// sc.UserAgent.Prepend(\"rack/\" + util.Version)\n\treturn sc\n}", "func NewClient(config *Settings) (*PlatformClient, error) {\n\tif err := config.Validate(); err != nil {\n\t\treturn nil, err\n\t}\n\tcfClient, err := config.CF.CFClientProvider(&config.CF.Config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &PlatformClient{\n\t\tclient: cfClient,\n\t\tsettings: config,\n\t\tplanResolver: NewPlanResolver(),\n\t}, nil\n}", "func NewPeeringPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PeeringPoliciesClient, error) {\n\tcl, err := arm.NewClient(moduleName+\".PeeringPoliciesClient\", moduleVersion, credential, options)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient := &PeeringPoliciesClient{\n\t\tsubscriptionID: subscriptionID,\n\t\tinternal: cl,\n\t}\n\treturn client, nil\n}", "func NewClient(config *Configuration) (*Client, error) {\n\t// Check that authorization values are defined at all\n\tif config.AuthorizationHeaderToken == \"\" {\n\t\treturn nil, fmt.Errorf(\"No authorization is defined. You need AuthorizationHeaderToken\")\n\t}\n\n\tif config.ApplicationID == \"\" {\n\t\treturn nil, fmt.Errorf(\"ApplicationID is required - this is the only way to identify your requests in highwinds logs\")\n\t}\n\n\t// Configure the client from final configuration\n\tc := &Client{\n\t\tc: http.DefaultClient,\n\t\tDebug: config.Debug,\n\t\tApplicationID: config.ApplicationID,\n\t\tIdentity: &identity.Identification{\n\t\t\tAuthorizationHeaderToken: config.AuthorizationHeaderToken,\n\t\t},\n\t}\n\n\t// TODO eventually instantiate a custom client but not ready for that yet\n\n\t// Configure timeout on default client\n\tif config.Timeout == 0 {\n\t\tc.c.Timeout = time.Second * 10\n\t} else {\n\t\tc.c.Timeout = time.Second * time.Duration(config.Timeout)\n\t}\n\n\t// Set default headers\n\tc.Headers = c.GetHeaders()\n\treturn c, nil\n}", "func NewClient(config *Config) (c *Client, err error) {\n\tif config == nil {\n\t\treturn nil, errClientConfigNil\n\t}\n\n\tc = &Client{\n\t\trevocationTransport: http.DefaultTransport,\n\t}\n\n\tif c.transport, err = ghinstallation.NewAppsTransport(\n\t\thttp.DefaultTransport,\n\t\tint64(config.AppID),\n\t\t[]byte(config.PrvKey),\n\t); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif c.url, err = url.ParseRequestURI(fmt.Sprintf(\n\t\t\"%s/app/installations/%v/access_tokens\",\n\t\tstrings.TrimSuffix(fmt.Sprint(config.BaseURL), \"/\"),\n\t\tconfig.InsID,\n\t)); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif c.revocationURL, err = url.ParseRequestURI(fmt.Sprintf(\n\t\t\"%s/installation/token\",\n\t\tstrings.TrimSuffix(fmt.Sprint(config.BaseURL), \"/\"),\n\t)); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn c, nil\n}", "func NewClient(opts *cli.Options) (pulsar.Client, error) {\n\tclientOpts := pulsar.ClientOptions{\n\t\tURL: opts.Pulsar.Address,\n\t\tOperationTimeout: 30 * time.Second,\n\t\tConnectionTimeout: opts.Pulsar.ConnectTimeout,\n\t\tTLSAllowInsecureConnection: opts.Pulsar.InsecureTLS,\n\t}\n\n\tif opts.Pulsar.AuthCertificateFile != \"\" && opts.Pulsar.AuthKeyFile != \"\" {\n\t\tclientOpts.Authentication = pulsar.NewAuthenticationTLS(opts.Pulsar.AuthCertificateFile, opts.Pulsar.AuthKeyFile)\n\t}\n\n\tclient, err := pulsar.NewClient(clientOpts)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"Could not instantiate Pulsar client\")\n\t}\n\n\treturn client, nil\n}", "func NewClient() (*Client, error) {\n\tpath, err := exec.LookPath(\"helm\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"helm must be installed and available in path: %s\", err.Error())\n\t}\n\tklog.V(3).Infof(\"found helm at %s\", path)\n\treturn &Client{path}, nil\n}", "func NewClient(healthcheck, listDevices, createDevice, updateCharge, getChargeHistory, updateDevice goa.Endpoint) *Client {\n\treturn &Client{\n\t\tHealthcheckEndpoint: healthcheck,\n\t\tListDevicesEndpoint: listDevices,\n\t\tCreateDeviceEndpoint: createDevice,\n\t\tUpdateChargeEndpoint: updateCharge,\n\t\tGetChargeHistoryEndpoint: getChargeHistory,\n\t\tUpdateDeviceEndpoint: updateDevice,\n\t}\n}", "func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {\n\tclientOpts := defaultGRPCClientOptions()\n\tif newClientHook != nil {\n\t\thookOpts, err := newClientHook(ctx, clientHookParams{})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tclientOpts = append(clientOpts, hookOpts...)\n\t}\n\n\tconnPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient := Client{CallOptions: defaultCallOptions()}\n\n\tc := &gRPCClient{\n\t\tconnPool: connPool,\n\t\tclient: netapppb.NewNetAppClient(connPool),\n\t\tCallOptions: &client.CallOptions,\n\t\toperationsClient: longrunningpb.NewOperationsClient(connPool),\n\t\tlocationsClient: locationpb.NewLocationsClient(connPool),\n\t}\n\tc.setGoogleClientInfo()\n\n\tclient.internalClient = c\n\n\tclient.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))\n\tif err != nil {\n\t\t// This error \"should not happen\", since we are just reusing old connection pool\n\t\t// and never actually need to dial.\n\t\t// If this does happen, we could leak connp. However, we cannot close conn:\n\t\t// If the user invoked the constructor with option.WithGRPCConn,\n\t\t// we would close a connection that's still in use.\n\t\t// TODO: investigate error conditions.\n\t\treturn nil, err\n\t}\n\tc.LROClient = &client.LROClient\n\treturn &client, nil\n}", "func New(client *client.Client, properties ClientProperties) *Client {\n\treturn &Client{\n\t\tclient: client,\n\n\t\taccountSid: properties.AccountSid,\n\t\tsid: properties.Sid,\n\t}\n}", "func NewClient(options ...DNSOption) networkservice.NetworkServiceClient {\n\tvar c = &dnsContextClient{\n\t\tchainContext: context.Background(),\n\t\tdefaultNameServerIP: \"127.0.0.1\",\n\t\tresolveConfigPath: \"/etc/resolv.conf\",\n\t}\n\tfor _, o := range options {\n\t\to.apply(c)\n\t}\n\n\tc.initialize()\n\n\treturn c\n}", "func NewClient(id string, wsClient ws.WsClient, dispatcher ClientDispatcher, stateHandler ClientState, profiles ...*ocpp.Profile) *Client {\n\tendpoint := Endpoint{}\n\tif wsClient == nil {\n\t\tpanic(\"wsClient parameter cannot be nil\")\n\t}\n\tfor _, profile := range profiles {\n\t\tendpoint.AddProfile(profile)\n\t}\n\tif dispatcher == nil {\n\t\tdispatcher = NewDefaultClientDispatcher(NewFIFOClientQueue(10))\n\t}\n\tif stateHandler == nil {\n\t\tstateHandler = NewClientState()\n\t}\n\tdispatcher.SetNetworkClient(wsClient)\n\tdispatcher.SetPendingRequestState(stateHandler)\n\treturn &Client{Endpoint: endpoint, client: wsClient, Id: id, dispatcher: dispatcher, RequestState: stateHandler}\n}", "func NewClient(health, deposit, withdraw, transfer, balance, adminWallets goa.Endpoint) *Client {\n\treturn &Client{\n\t\tHealthEndpoint: health,\n\t\tDepositEndpoint: deposit,\n\t\tWithdrawEndpoint: withdraw,\n\t\tTransferEndpoint: transfer,\n\t\tBalanceEndpoint: balance,\n\t\tAdminWalletsEndpoint: adminWallets,\n\t}\n}", "func NewClient(batchAvailabilityLookup, checkAvailability, createBooking, updateBooking, getBookingStatus, listBookings goa.Endpoint) *Client {\n\treturn &Client{\n\t\tBatchAvailabilityLookupEndpoint: batchAvailabilityLookup,\n\t\tCheckAvailabilityEndpoint: checkAvailability,\n\t\tCreateBookingEndpoint: createBooking,\n\t\tUpdateBookingEndpoint: updateBooking,\n\t\tGetBookingStatusEndpoint: getBookingStatus,\n\t\tListBookingsEndpoint: listBookings,\n\t}\n}", "func NewClient(token string) *Client {\n\tc := Client{\n\t\ttoken: token,\n\t\thclient: retryablehttp.NewClient(),\n\t}\n\n\t// set up http client\n\tc.hclient.Logger = nil\n\tc.hclient.ErrorHandler = c.errorHandler\n\tc.hclient.RetryMax = retryLimit\n\tc.hclient.RetryWaitMin = maxRateLimit / 3\n\tc.hclient.RetryWaitMax = maxRateLimit\n\n\t// add services\n\tc.Account = &AccountService{&c}\n\tc.Server = &ServerService{&c}\n\tc.Transaction = &TransactionService{&c}\n\tc.CreateOptions = &CreateOptionsService{&c}\n\tc.SSHKey = &SSHKeyService{&c}\n\n\treturn &c\n}", "func NewClient(ctx *pulumi.Context,\n\tname string, args *ClientArgs, opts ...pulumi.ResourceOption) (*Client, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.Brand == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Brand'\")\n\t}\n\tif args.DisplayName == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'DisplayName'\")\n\t}\n\tsecrets := pulumi.AdditionalSecretOutputs([]string{\n\t\t\"secret\",\n\t})\n\topts = append(opts, secrets)\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource Client\n\terr := ctx.RegisterResource(\"gcp:iap/client:Client\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewClient(modifiers ...RequestModifier) *Client {\n\treturn &Client{modifiers}\n}", "func New(clientSet apimachinery.ClientSetInterface) Factory {\n\treturn &factory{\n\t\tclientSet: clientSet,\n\t}\n}", "func NewClient(opts ClientOptions, client *http.Client) (Client, error) {\n\tif err := opts.Validate(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif opts.ResourceType == \"\" {\n\t\topts.ResourceType = DefaultResourceType\n\t}\n\tif opts.ResourceID == \"\" {\n\t\tvar err error\n\t\thostname, err := os.Hostname()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\topts.ResourceID = hostname\n\t}\n\tif opts.LogID == \"\" {\n\t\treturn nil, errors.New(\"cloudlogging: no LogID is provided\")\n\t}\n\n\tservice, err := cloudlog.New(client)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif opts.UserAgent != \"\" {\n\t\tservice.UserAgent = opts.UserAgent\n\t}\n\n\tc := clientImpl{\n\t\tClientOptions: &opts,\n\t\tservice: cloudlog.NewProjectsLogsEntriesService(service),\n\t\tcommonLabels: make(map[string]string, len(opts.CommonLabels)),\n\t}\n\tfor k, v := range opts.CommonLabels {\n\t\tc.commonLabels[k] = v\n\t}\n\tif c.ResourceType != \"\" {\n\t\tc.commonLabels[\"compute.googleapis.com/resource_type\"] = c.ResourceType\n\t}\n\tif c.ResourceID != \"\" {\n\t\tc.commonLabels[\"compute.googleapis.com/resource_id\"] = c.ResourceID\n\t}\n\treturn &c, nil\n}", "func NewClient(options ...ClientOption) (*Client, error) {\n\tc := &Client{\n\t\thttpClient: http.DefaultClient,\n\t\tbaseURL: DefaultBaseURL,\n\t\tlangs: append([]Lang{DefaultLang}, Langs...),\n\t}\n\tfor _, o := range options {\n\t\to(c)\n\t}\n\ttags := make([]language.Tag, len(c.langs))\n\tfor i, lang := range c.langs {\n\t\ttag, err := language.Parse(string(lang))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttags[i] = tag\n\t}\n\tc.matcher = language.NewMatcher(tags)\n\treturn c, nil\n}", "func (auth ClientCredentialsAuth) NewClient(ctx context.Context) Client {\n\tclient := auth.config.Client(ctx)\n\treturn Client{\n\t\tclient: client,\n\t\tbaseURL: BaseURL,\n\t}\n}", "func NewClient(batchGetWaitEstimates, createWaitlistEntry, getWaitlistEntry, deleteWaitlistEntry goa.Endpoint) *Client {\n\treturn &Client{\n\t\tBatchGetWaitEstimatesEndpoint: batchGetWaitEstimates,\n\t\tCreateWaitlistEntryEndpoint: createWaitlistEntry,\n\t\tGetWaitlistEntryEndpoint: getWaitlistEntry,\n\t\tDeleteWaitlistEntryEndpoint: deleteWaitlistEntry,\n\t}\n}", "func NewDomainsClient(tenantId string) *DomainsClient {\n\treturn &DomainsClient{\n\t\tBaseClient: NewClient(Version10, tenantId),\n\t}\n}", "func NewProcessesClient(subscriptionID string) ProcessesClient {\n\treturn NewProcessesClientWithBaseURI(DefaultBaseURI, subscriptionID)\n}", "func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {\n\tclientOpts := defaultGRPCClientOptions()\n\tif newClientHook != nil {\n\t\thookOpts, err := newClientHook(ctx, clientHookParams{})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tclientOpts = append(clientOpts, hookOpts...)\n\t}\n\n\tdisableDeadlines, err := checkDisableDeadlines()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tconnPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient := Client{CallOptions: defaultCallOptions()}\n\n\tc := &gRPCClient{\n\t\tconnPool: connPool,\n\t\tdisableDeadlines: disableDeadlines,\n\t\tclient: bigtablepb.NewBigtableClient(connPool),\n\t\tCallOptions: &client.CallOptions,\n\t}\n\tc.setGoogleClientInfo()\n\n\tclient.internalClient = c\n\n\treturn &client, nil\n}", "func NewClient(protocol Protocol, pool Pool) (Client, error) {\n\tfactory, ok := clients[protocol]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"client for protocol '%v' does not exist\", protocol)\n\t}\n\n\treturn factory(pool)\n}", "func newClient() (*storage.Client, error) {\n\tctx := context.Background()\n\n\tbyteKey, err := gcloud.GetDecodedKey()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get gcp key, err: %w\", err)\n\t}\n\tclient, err := storage.NewClient(ctx, option.WithCredentialsJSON(byteKey))\n\tif err != nil {\n\t\tlog.Println(\"failed to login with GCP_KEY, trying with default application credentials...\")\n\t\tclient, err = storage.NewClient(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to open Google Cloud Storage client: %w\", err)\n\t\t}\n\t}\n\n\treturn client, nil\n}", "func (g *Gitlab) NewClient(ctx context.Context, store esv1alpha1.GenericStore, kube kclient.Client, namespace string) (provider.SecretsClient, error) {\n\tstoreSpec := store.GetSpec()\n\tif storeSpec == nil || storeSpec.Provider == nil || storeSpec.Provider.Gitlab == nil {\n\t\treturn nil, fmt.Errorf(\"no store type or wrong store type\")\n\t}\n\tstoreSpecGitlab := storeSpec.Provider.Gitlab\n\n\tcliStore := gClient{\n\t\tkube: kube,\n\t\tstore: storeSpecGitlab,\n\t\tnamespace: namespace,\n\t\tstoreKind: store.GetObjectKind().GroupVersionKind().Kind,\n\t}\n\n\tif err := cliStore.setAuth(ctx); err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar err error\n\n\t// Create client options\n\tvar opts []gitlab.ClientOptionFunc\n\tif cliStore.store.URL != \"\" {\n\t\topts = append(opts, gitlab.WithBaseURL(cliStore.store.URL))\n\t}\n\t// ClientOptionFunc from the gitlab package can be mapped with the CRD\n\t// in a similar way to extend functionality of the provider\n\n\t// Create a new Gitlab client using credentials and options\n\tgitlabClient, err := gitlab.NewClient(string(cliStore.credentials), opts...)\n\tif err != nil {\n\t\tlog.Logf(\"Failed to create client: %v\", err)\n\t}\n\n\tg.client = gitlabClient.ProjectVariables\n\tg.projectID = cliStore.store.ProjectID\n\n\treturn g, nil\n}", "func NewClient(ctx context.Context, cfg ClientConfig) (*Client, error) {\n\tconfig := &tfe.Config{\n\t\tToken: cfg.Token,\n\t}\n\ttfeClient, err := tfe.NewClient(config)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not create a new TFE tfeClient: %w\", err)\n\t}\n\n\tw, err := tfeClient.Workspaces.Read(ctx, cfg.Organization, cfg.Workspace)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not retrieve workspace '%v/%v': %w\", cfg.Organization, cfg.Workspace, err)\n\t}\n\n\tc := Client{\n\t\tclient: tfeClient,\n\t\tworkspace: w,\n\t}\n\treturn &c, nil\n}", "func NewClient(config *sdk.Config, credential *auth.Credential) *Client {\n\tvar handler sdk.RequestHandler = func(c *sdk.Client, req request.Common) (request.Common, error) {\n\t\terr := req.SetProjectId(PickResourceID(req.GetProjectId()))\n\t\treturn req, err\n\t}\n\tvar (\n\t\tuaccountClient = *uaccount.NewClient(config, credential)\n\t\tuhostClient = *uhost.NewClient(config, credential)\n\t\tunetClient = *unet.NewClient(config, credential)\n\t\tvpcClient = *vpc.NewClient(config, credential)\n\t\tudpnClient = *udpn.NewClient(config, credential)\n\t\tpathxClient = *pathx.NewClient(config, credential)\n\t\tudiskClient = *udisk.NewClient(config, credential)\n\t\tulbClient = *ulb.NewClient(config, credential)\n\t\tudbClient = *udb.NewClient(config, credential)\n\t\tumemClient = *umem.NewClient(config, credential)\n\t\tuphostClient = *uphost.NewClient(config, credential)\n\t\tpuhostClient = *puhost.NewClient(config, credential)\n\t\tpudbClient = *pudb.NewClient(config, credential)\n\t\tpumemClient = *pumem.NewClient(config, credential)\n\t\tppathxClient = *ppathx.NewClient(config, credential)\n\t)\n\n\tuaccountClient.Client.AddRequestHandler(handler)\n\tuhostClient.Client.AddRequestHandler(handler)\n\tunetClient.Client.AddRequestHandler(handler)\n\tvpcClient.Client.AddRequestHandler(handler)\n\tudpnClient.Client.AddRequestHandler(handler)\n\tpathxClient.Client.AddRequestHandler(handler)\n\tudiskClient.Client.AddRequestHandler(handler)\n\tulbClient.Client.AddRequestHandler(handler)\n\tudbClient.Client.AddRequestHandler(handler)\n\tumemClient.Client.AddRequestHandler(handler)\n\tuphostClient.Client.AddRequestHandler(handler)\n\tpuhostClient.Client.AddRequestHandler(handler)\n\tpudbClient.Client.AddRequestHandler(handler)\n\tpumemClient.Client.AddRequestHandler(handler)\n\tppathxClient.Client.AddRequestHandler(handler)\n\n\treturn &Client{\n\t\tuaccountClient,\n\t\tuhostClient,\n\t\tunetClient,\n\t\tvpcClient,\n\t\tudpnClient,\n\t\tpathxClient,\n\t\tudiskClient,\n\t\tulbClient,\n\t\tudbClient,\n\t\tumemClient,\n\t\tuphostClient,\n\t\tpuhostClient,\n\t\tpudbClient,\n\t\tpumemClient,\n\t\tppathxClient,\n\t}\n}" ]
[ "0.5942576", "0.573209", "0.57141393", "0.54691076", "0.53663653", "0.5332414", "0.5331938", "0.53184956", "0.53092986", "0.52872276", "0.5274721", "0.52648884", "0.52600336", "0.5255136", "0.5240479", "0.52287835", "0.51977056", "0.5182397", "0.51636803", "0.5156131", "0.5116386", "0.51113915", "0.5105239", "0.50993115", "0.50757015", "0.5075413", "0.507471", "0.5074036", "0.50378627", "0.5020879", "0.50100976", "0.49984142", "0.4997607", "0.49972013", "0.49884763", "0.4982421", "0.49777135", "0.49741006", "0.49663725", "0.4962417", "0.49534974", "0.4947993", "0.49471518", "0.49378332", "0.49305797", "0.49293706", "0.49263668", "0.49263668", "0.49263668", "0.49243793", "0.492412", "0.49188536", "0.49185416", "0.49184158", "0.49164593", "0.49143887", "0.49129698", "0.49074313", "0.49062622", "0.4897761", "0.48948616", "0.4894256", "0.48908487", "0.48842347", "0.48840714", "0.48835513", "0.488216", "0.48792246", "0.48745388", "0.48727855", "0.48701784", "0.48679662", "0.48658457", "0.4863561", "0.48624408", "0.48524603", "0.4849794", "0.48478934", "0.48435977", "0.48368266", "0.48366392", "0.48352078", "0.48331523", "0.48309857", "0.48286328", "0.48226783", "0.4819294", "0.48162434", "0.48145646", "0.4814161", "0.48112723", "0.48107338", "0.48077616", "0.48054874", "0.48044482", "0.48041838", "0.48023784", "0.47993535", "0.47984073", "0.4794498" ]
0.80434936
0
createOrUpdateCreateRequest creates the CreateOrUpdate request.
createOrUpdateCreateRequest создает запрос CreateOrUpdate.
func (client *PolicyDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, policyDefinitionName string, parameters PolicyDefinition, options *PolicyDefinitionsCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" if policyDefinitionName == "" { return nil, errors.New("parameter policyDefinitionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, runtime.MarshalAsJSON(req, parameters) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *RoleDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, roleDefinitionID string, roleDefinition RoleDefinition, options *RoleDefinitionsCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\tif roleDefinitionID == \"\" {\n\t\treturn nil, errors.New(\"parameter roleDefinitionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{roleDefinitionId}\", url.PathEscape(roleDefinitionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, roleDefinition)\n}", "func (client *ApplyUpdatesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, options *ApplyUpdatesClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif providerName == \"\" {\n\t\treturn nil, errors.New(\"parameter providerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{providerName}\", url.PathEscape(providerName))\n\tif resourceType == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceType}\", url.PathEscape(resourceType))\n\tif resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(resourceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *RegistrationDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, registrationDefinitionID string, scope string, requestBody RegistrationDefinition, options *RegistrationDefinitionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}\"\n\tif registrationDefinitionID == \"\" {\n\t\treturn nil, errors.New(\"parameter registrationDefinitionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{registrationDefinitionId}\", url.PathEscape(registrationDefinitionID))\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, requestBody)\n}", "func (client *WorkspacesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, parameters Workspace, options *WorkspacesBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *ServersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serverName string, parameters Server, options *ServersClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serverName == \"\" {\n\t\treturn nil, errors.New(\"parameter serverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serverName}\", url.PathEscape(serverName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *DefenderSettingsClient) createOrUpdateCreateRequest(ctx context.Context, defenderSettingsModel DefenderSettingsModel, options *DefenderSettingsClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.IoTSecurity/defenderSettings/default\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, defenderSettingsModel)\n}", "func (client *FactoriesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, factoryName string, factory Factory, options *FactoriesClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif factoryName == \"\" {\n\t\treturn nil, errors.New(\"parameter factoryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{factoryName}\", url.PathEscape(factoryName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Raw().Header[\"If-Match\"] = []string{*options.IfMatch}\n\t}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, factory)\n}", "func (client *AssociationsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, associationName string, association Association, options *AssociationsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\tif associationName == \"\" {\n\t\treturn nil, errors.New(\"parameter associationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{associationName}\", url.PathEscape(associationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-09-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, association)\n}", "func (client *CloudServicesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, cloudServiceName string, parameters CloudService, options *CloudServicesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif cloudServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter cloudServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{cloudServiceName}\", url.PathEscape(cloudServiceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-09-04\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *IotSecuritySolutionClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, solutionName string, iotSecuritySolutionData IoTSecuritySolutionModel, options *IotSecuritySolutionClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif solutionName == \"\" {\n\t\treturn nil, errors.New(\"parameter solutionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{solutionName}\", url.PathEscape(solutionName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2019-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, iotSecuritySolutionData)\n}", "func (client *WebAppsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, name string, siteEnvelope Site, options *WebAppsBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, siteEnvelope)\n}", "func (client *APIClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, parameters APICreateOrUpdateParameter, options *APIClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif apiID == \"\" {\n\t\treturn nil, errors.New(\"parameter apiID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{apiId}\", url.PathEscape(apiID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Raw().Header[\"If-Match\"] = []string{*options.IfMatch}\n\t}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *VirtualApplianceSitesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, networkVirtualApplianceName string, siteName string, parameters VirtualApplianceSite, options *VirtualApplianceSitesBeginCreateOrUpdateOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkVirtualAppliances/{networkVirtualApplianceName}/virtualApplianceSites/{siteName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{networkVirtualApplianceName}\", url.PathEscape(networkVirtualApplianceName))\n\turlPath = strings.ReplaceAll(urlPath, \"{siteName}\", url.PathEscape(siteName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-07-01\")\n\treq.URL.RawQuery = query.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, req.MarshalAsJSON(parameters)\n}", "func (client *UserMetricsKeysClient) createOrUpdateCreateRequest(ctx context.Context, options *UserMetricsKeysClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *LocalRulestacksClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, localRulestackName string, resource LocalRulestackResource, options *LocalRulestacksClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif localRulestackName == \"\" {\n\t\treturn nil, errors.New(\"parameter localRulestackName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{localRulestackName}\", url.PathEscape(localRulestackName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-29\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, resource)\n}", "func (client *ClustersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, parameters Cluster, options *ClustersBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *SQLVirtualMachinesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, sqlVirtualMachineName string, parameters SQLVirtualMachine, options *SQLVirtualMachinesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sqlVirtualMachineName == \"\" {\n\t\treturn nil, errors.New(\"parameter sqlVirtualMachineName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sqlVirtualMachineName}\", url.PathEscape(sqlVirtualMachineName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-03-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *AvailabilitySetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters AvailabilitySet, options *AvailabilitySetsCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif availabilitySetName == \"\" {\n\t\treturn nil, errors.New(\"parameter availabilitySetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{availabilitySetName}\", url.PathEscape(availabilitySetName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *IncidentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, incidentID string, incident Incident, options *IncidentsClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/incidents/{incidentId}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif incidentID == \"\" {\n\t\treturn nil, errors.New(\"parameter incidentID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{incidentId}\", url.PathEscape(incidentID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-05-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, incident)\n}", "func (client *DevicesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, deviceName string, parameters Device, options *DevicesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif deviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter deviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{deviceName}\", url.PathEscape(deviceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *ServerVulnerabilityAssessmentClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, options *ServerVulnerabilityAssessmentClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif resourceNamespace == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceNamespace cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceNamespace}\", url.PathEscape(resourceNamespace))\n\tif resourceType == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceType}\", url.PathEscape(resourceType))\n\tif resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(resourceName))\n\turlPath = strings.ReplaceAll(urlPath, \"{serverVulnerabilityAssessment}\", url.PathEscape(\"default\"))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-01-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ConnectedEnvironmentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, connectedEnvironmentName string, environmentEnvelope ConnectedEnvironment, options *ConnectedEnvironmentsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif connectedEnvironmentName == \"\" {\n\t\treturn nil, errors.New(\"parameter connectedEnvironmentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{connectedEnvironmentName}\", url.PathEscape(connectedEnvironmentName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, environmentEnvelope)\n}", "func (client *InteractionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, hubName string, interactionName string, parameters InteractionResourceFormat, options *InteractionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomerInsights/hubs/{hubName}/interactions/{interactionName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif hubName == \"\" {\n\t\treturn nil, errors.New(\"parameter hubName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hubName}\", url.PathEscape(hubName))\n\tif interactionName == \"\" {\n\t\treturn nil, errors.New(\"parameter interactionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{interactionName}\", url.PathEscape(interactionName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-04-26\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *RouteTablesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, routeTableName string, parameters RouteTable, options *RouteTablesBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif routeTableName == \"\" {\n\t\treturn nil, errors.New(\"parameter routeTableName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{routeTableName}\", url.PathEscape(routeTableName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *PortalConfigClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalConfigID string, ifMatch string, parameters PortalConfigContract, options *PortalConfigClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif portalConfigID == \"\" {\n\t\treturn nil, errors.New(\"parameter portalConfigID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{portalConfigId}\", url.PathEscape(portalConfigID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"If-Match\"] = []string{ifMatch}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *JobExecutionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serverName string, jobAgentName string, jobName string, jobExecutionID string, options *JobExecutionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/jobAgents/{jobAgentName}/jobs/{jobName}/executions/{jobExecutionId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serverName == \"\" {\n\t\treturn nil, errors.New(\"parameter serverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serverName}\", url.PathEscape(serverName))\n\tif jobAgentName == \"\" {\n\t\treturn nil, errors.New(\"parameter jobAgentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{jobAgentName}\", url.PathEscape(jobAgentName))\n\tif jobName == \"\" {\n\t\treturn nil, errors.New(\"parameter jobName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{jobName}\", url.PathEscape(jobName))\n\turlPath = strings.ReplaceAll(urlPath, \"{jobExecutionId}\", url.PathEscape(jobExecutionID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *IPAllocationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, ipAllocationName string, parameters IPAllocation, options *IPAllocationsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/IpAllocations/{ipAllocationName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif ipAllocationName == \"\" {\n\t\treturn nil, errors.New(\"parameter ipAllocationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ipAllocationName}\", url.PathEscape(ipAllocationName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *NotebookWorkspacesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, notebookWorkspaceName NotebookWorkspaceName, notebookCreateUpdateParameters NotebookWorkspaceCreateUpdateParameters, options *NotebookWorkspacesBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif accountName == \"\" {\n\t\treturn nil, errors.New(\"parameter accountName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{accountName}\", url.PathEscape(accountName))\n\tif notebookWorkspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter notebookWorkspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{notebookWorkspaceName}\", url.PathEscape(string(notebookWorkspaceName)))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-10-15\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, notebookCreateUpdateParameters)\n}", "func (client *KpiClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, hubName string, kpiName string, parameters KpiResourceFormat, options *KpiClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomerInsights/hubs/{hubName}/kpi/{kpiName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif hubName == \"\" {\n\t\treturn nil, errors.New(\"parameter hubName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hubName}\", url.PathEscape(hubName))\n\tif kpiName == \"\" {\n\t\treturn nil, errors.New(\"parameter kpiName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{kpiName}\", url.PathEscape(kpiName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-04-26\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *ManagedInstancesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstance, options *ManagedInstancesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif managedInstanceName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedInstanceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedInstanceName}\", url.PathEscape(managedInstanceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *DatasetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, factoryName string, datasetName string, dataset DatasetResource, options *DatasetsClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/datasets/{datasetName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif factoryName == \"\" {\n\t\treturn nil, errors.New(\"parameter factoryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{factoryName}\", url.PathEscape(factoryName))\n\tif datasetName == \"\" {\n\t\treturn nil, errors.New(\"parameter datasetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{datasetName}\", url.PathEscape(datasetName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Raw().Header[\"If-Match\"] = []string{*options.IfMatch}\n\t}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, dataset)\n}", "func (client *VirtualMachineImageTemplatesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, imageTemplateName string, parameters ImageTemplate, options *VirtualMachineImageTemplatesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif imageTemplateName == \"\" {\n\t\treturn nil, errors.New(\"parameter imageTemplateName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{imageTemplateName}\", url.PathEscape(imageTemplateName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-10-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *PipelinesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, factoryName string, pipelineName string, pipeline PipelineResource, options *PipelinesClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/pipelines/{pipelineName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif factoryName == \"\" {\n\t\treturn nil, errors.New(\"parameter factoryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{factoryName}\", url.PathEscape(factoryName))\n\tif pipelineName == \"\" {\n\t\treturn nil, errors.New(\"parameter pipelineName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{pipelineName}\", url.PathEscape(pipelineName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Raw().Header[\"If-Match\"] = []string{*options.IfMatch}\n\t}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, pipeline)\n}", "func (client *ManagedClustersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters ManagedCluster, options *ManagedClustersClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(resourceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *TagRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, resource TagRule, options *TagRulesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/monitors/{monitorName}/tagRules/{ruleSetName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif monitorName == \"\" {\n\t\treturn nil, errors.New(\"parameter monitorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{monitorName}\", url.PathEscape(monitorName))\n\tif ruleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter ruleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ruleSetName}\", url.PathEscape(ruleSetName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-27\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, resource); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *GroupClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, parameters GroupCreateParameters, options *GroupCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif groupID == \"\" {\n\t\treturn nil, errors.New(\"parameter groupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{groupId}\", url.PathEscape(groupID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Raw().Header.Set(\"If-Match\", *options.IfMatch)\n\t}\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *ManagementAssociationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, managementAssociationName string, parameters ManagementAssociation, options *ManagementAssociationsCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.providerName == \"\" {\n\t\treturn nil, errors.New(\"parameter client.providerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{providerName}\", url.PathEscape(client.providerName))\n\tif client.resourceType == \"\" {\n\t\treturn nil, errors.New(\"parameter client.resourceType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceType}\", url.PathEscape(client.resourceType))\n\tif client.resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter client.resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(client.resourceName))\n\tif managementAssociationName == \"\" {\n\t\treturn nil, errors.New(\"parameter managementAssociationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementAssociationName}\", url.PathEscape(managementAssociationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2015-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *SparkJobDefinitionClient) createOrUpdateSparkJobDefinitionCreateRequest(ctx context.Context, sparkJobDefinitionName string, sparkJobDefinition SparkJobDefinitionResource, options *SparkJobDefinitionBeginCreateOrUpdateSparkJobDefinitionOptions) (*azcore.Request, error) {\n\turlPath := \"/sparkJobDefinitions/{sparkJobDefinitionName}\"\n\tif sparkJobDefinitionName == \"\" {\n\t\treturn nil, errors.New(\"parameter sparkJobDefinitionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sparkJobDefinitionName}\", url.PathEscape(sparkJobDefinitionName))\n\treq, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\treqQP := req.URL.Query()\n\treqQP.Set(\"api-version\", \"2019-06-01-preview\")\n\treq.URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Header.Set(\"If-Match\", *options.IfMatch)\n\t}\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, req.MarshalAsJSON(sparkJobDefinition)\n}", "func (client *AgentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, agentName string, agent Agent, options *AgentsClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/agents/{agentName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif storageMoverName == \"\" {\n\t\treturn nil, errors.New(\"parameter storageMoverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{storageMoverName}\", url.PathEscape(storageMoverName))\n\tif agentName == \"\" {\n\t\treturn nil, errors.New(\"parameter agentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{agentName}\", url.PathEscape(agentName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-07-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, agent)\n}", "func (client *ActionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, ruleID string, actionID string, action ActionRequest, options *ActionsClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/alertRules/{ruleId}/actions/{actionId}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif ruleID == \"\" {\n\t\treturn nil, errors.New(\"parameter ruleID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ruleId}\", url.PathEscape(ruleID))\n\tif actionID == \"\" {\n\t\treturn nil, errors.New(\"parameter actionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{actionId}\", url.PathEscape(actionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-10-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, action)\n}", "func (client *ScriptExecutionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, scriptExecution ScriptExecution, options *ScriptExecutionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateCloudName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateCloudName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateCloudName}\", url.PathEscape(privateCloudName))\n\tif scriptExecutionName == \"\" {\n\t\treturn nil, errors.New(\"parameter scriptExecutionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{scriptExecutionName}\", url.PathEscape(scriptExecutionName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, scriptExecution); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *WebAppsClient) createOrUpdateConfigurationCreateRequest(ctx context.Context, resourceGroupName string, name string, siteConfig SiteConfigResource, options *WebAppsCreateOrUpdateConfigurationOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/web\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, siteConfig)\n}", "func (client *FirewallRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule, options *FirewallRulesBeginCreateOrUpdateOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/firewallRules/{firewallRuleName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serverName == \"\" {\n\t\treturn nil, errors.New(\"parameter serverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serverName}\", url.PathEscape(serverName))\n\tif firewallRuleName == \"\" {\n\t\treturn nil, errors.New(\"parameter firewallRuleName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{firewallRuleName}\", url.PathEscape(firewallRuleName))\n\treq, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\treqQP := req.URL.Query()\n\treqQP.Set(\"api-version\", \"2017-12-01\")\n\treq.URL.RawQuery = reqQP.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, req.MarshalAsJSON(parameters)\n}", "func (client *SchemaRegistryClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, schemaGroupName string, parameters SchemaGroup, options *SchemaRegistryClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/schemagroups/{schemaGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif namespaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter namespaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{namespaceName}\", url.PathEscape(namespaceName))\n\tif schemaGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter schemaGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{schemaGroupName}\", url.PathEscape(schemaGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-10-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *AlertProcessingRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, alertProcessingRule AlertProcessingRule, options *AlertProcessingRulesClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif alertProcessingRuleName == \"\" {\n\t\treturn nil, errors.New(\"parameter alertProcessingRuleName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{alertProcessingRuleName}\", url.PathEscape(alertProcessingRuleName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-08\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, alertProcessingRule)\n}", "func (client *AgentPoolsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, kubernetesClusterName string, agentPoolName string, agentPoolParameters AgentPool, options *AgentPoolsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkCloud/kubernetesClusters/{kubernetesClusterName}/agentPools/{agentPoolName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif kubernetesClusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter kubernetesClusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{kubernetesClusterName}\", url.PathEscape(kubernetesClusterName))\n\tif agentPoolName == \"\" {\n\t\treturn nil, errors.New(\"parameter agentPoolName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{agentPoolName}\", url.PathEscape(agentPoolName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, agentPoolParameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *SourceControlConfigurationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, sourceControlConfigurationName string, sourceControlConfiguration SourceControlConfiguration, options *SourceControlConfigurationsClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterRp == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterRp cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterRp}\", url.PathEscape(clusterRp))\n\tif clusterResourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterResourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterResourceName}\", url.PathEscape(clusterResourceName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\tif sourceControlConfigurationName == \"\" {\n\t\treturn nil, errors.New(\"parameter sourceControlConfigurationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sourceControlConfigurationName}\", url.PathEscape(sourceControlConfigurationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-11-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, sourceControlConfiguration)\n}", "func (client *ServersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroup string, fluidRelayServerName string, resource Server, options *ServersClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.FluidRelay/fluidRelayServers/{fluidRelayServerName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroup == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroup cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroup}\", url.PathEscape(resourceGroup))\n\tif fluidRelayServerName == \"\" {\n\t\treturn nil, errors.New(\"parameter fluidRelayServerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{fluidRelayServerName}\", url.PathEscape(fluidRelayServerName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, resource)\n}", "func (client *SubscriptionClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, parameters SubscriptionCreateParameters, options *SubscriptionClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif sid == \"\" {\n\t\treturn nil, errors.New(\"parameter sid cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sid}\", url.PathEscape(sid))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.Notify != nil {\n\t\treqQP.Set(\"notify\", strconv.FormatBool(*options.Notify))\n\t}\n\treqQP.Set(\"api-version\", \"2022-08-01\")\n\tif options != nil && options.AppType != nil {\n\t\treqQP.Set(\"appType\", string(*options.AppType))\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Raw().Header[\"If-Match\"] = []string{*options.IfMatch}\n\t}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *VirtualNetworkTapsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, tapName string, parameters VirtualNetworkTap, options *VirtualNetworkTapsBeginCreateOrUpdateOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkTaps/{tapName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{tapName}\", url.PathEscape(tapName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-07-01\")\n\treq.URL.RawQuery = query.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, req.MarshalAsJSON(parameters)\n}", "func (client *ProductPolicyClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID PolicyIDName, parameters PolicyContract, options *ProductPolicyClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif productID == \"\" {\n\t\treturn nil, errors.New(\"parameter productID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{productId}\", url.PathEscape(productID))\n\tif policyID == \"\" {\n\t\treturn nil, errors.New(\"parameter policyID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{policyId}\", url.PathEscape(string(policyID)))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Raw().Header[\"If-Match\"] = []string{*options.IfMatch}\n\t}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *DedicatedHostsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string, parameters DedicatedHost, options *DedicatedHostsBeginCreateOrUpdateOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{hostGroupName}\", url.PathEscape(hostGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{hostName}\", url.PathEscape(hostName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-06-01\")\n\treq.URL.RawQuery = query.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, req.MarshalAsJSON(parameters)\n}", "func (client *VideosClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, videoName string, parameters VideoEntity, options *VideosClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/videos/{videoName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif accountName == \"\" {\n\t\treturn nil, errors.New(\"parameter accountName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{accountName}\", url.PathEscape(accountName))\n\tif videoName == \"\" {\n\t\treturn nil, errors.New(\"parameter videoName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{videoName}\", url.PathEscape(videoName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *VendorSKUPreviewClient) createOrUpdateCreateRequest(ctx context.Context, vendorName string, skuName string, previewSubscription string, parameters PreviewSubscription, options *VendorSKUPreviewClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}\"\n\tif vendorName == \"\" {\n\t\treturn nil, errors.New(\"parameter vendorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vendorName}\", url.PathEscape(vendorName))\n\tif skuName == \"\" {\n\t\treturn nil, errors.New(\"parameter skuName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{skuName}\", url.PathEscape(skuName))\n\tif previewSubscription == \"\" {\n\t\treturn nil, errors.New(\"parameter previewSubscription cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{previewSubscription}\", url.PathEscape(previewSubscription))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *CapacityReservationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, capacityReservationGroupName string, capacityReservationName string, parameters CapacityReservation, options *CapacityReservationsBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif capacityReservationGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter capacityReservationGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{capacityReservationGroupName}\", url.PathEscape(capacityReservationGroupName))\n\tif capacityReservationName == \"\" {\n\t\treturn nil, errors.New(\"parameter capacityReservationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{capacityReservationName}\", url.PathEscape(capacityReservationName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *DedicatedHostsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string, parameters DedicatedHost, options *DedicatedHostsBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif hostGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter hostGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hostGroupName}\", url.PathEscape(hostGroupName))\n\tif hostName == \"\" {\n\t\treturn nil, errors.New(\"parameter hostName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hostName}\", url.PathEscape(hostName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *HCRPAssignmentsClient) createOrUpdateCreateRequest(ctx context.Context, guestConfigurationAssignmentName string, resourceGroupName string, machineName string, parameters Assignment, options *HCRPAssignmentsClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}\"\n\tif guestConfigurationAssignmentName == \"\" {\n\t\treturn nil, errors.New(\"parameter guestConfigurationAssignmentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{guestConfigurationAssignmentName}\", url.PathEscape(guestConfigurationAssignmentName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif machineName == \"\" {\n\t\treturn nil, errors.New(\"parameter machineName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{machineName}\", url.PathEscape(machineName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-25\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *DicomServicesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, dicomServiceName string, dicomservice DicomService, options *DicomServicesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/dicomservices/{dicomServiceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif dicomServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter dicomServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{dicomServiceName}\", url.PathEscape(dicomServiceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, dicomservice)\n}", "func (client *WebAppsClient) createOrUpdateHostSecretCreateRequest(ctx context.Context, resourceGroupName string, name string, keyType string, keyName string, key KeyInfo, options *WebAppsCreateOrUpdateHostSecretOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/host/default/{keyType}/{keyName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif keyType == \"\" {\n\t\treturn nil, errors.New(\"parameter keyType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{keyType}\", url.PathEscape(keyType))\n\tif keyName == \"\" {\n\t\treturn nil, errors.New(\"parameter keyName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{keyName}\", url.PathEscape(keyName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, key)\n}", "func (client *MetricAlertsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, parameters MetricAlertResource, options *MetricAlertsClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif ruleName == \"\" {\n\t\treturn nil, errors.New(\"parameter ruleName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ruleName}\", url.PathEscape(ruleName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *StorageTargetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, storageTargetName string, storagetarget StorageTarget, options *StorageTargetsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif cacheName == \"\" {\n\t\treturn nil, errors.New(\"parameter cacheName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{cacheName}\", url.PathEscape(cacheName))\n\tif storageTargetName == \"\" {\n\t\treturn nil, errors.New(\"parameter storageTargetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{storageTargetName}\", url.PathEscape(storageTargetName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, storagetarget)\n}", "func (client *ManagedDatabasesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, parameters ManagedDatabase, options *ManagedDatabasesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif managedInstanceName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedInstanceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedInstanceName}\", url.PathEscape(managedInstanceName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *NotebookClient) createOrUpdateNotebookCreateRequest(ctx context.Context, notebookName string, notebook NotebookResource, options *NotebookClientBeginCreateOrUpdateNotebookOptions) (*policy.Request, error) {\n\turlPath := \"/notebooks/{notebookName}\"\n\tif notebookName == \"\" {\n\t\treturn nil, errors.New(\"parameter notebookName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{notebookName}\", url.PathEscape(notebookName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.endpoint, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-12-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Raw().Header[\"If-Match\"] = []string{*options.IfMatch}\n\t}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, notebook); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *VirtualMachineScaleSetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, vmScaleSetName string, parameters VirtualMachineScaleSet, options *VirtualMachineScaleSetsBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif vmScaleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter vmScaleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vmScaleSetName}\", url.PathEscape(vmScaleSetName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *CertificateOrdersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, certificateDistinguishedName CertificateOrder, options *CertificateOrdersClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif certificateOrderName == \"\" {\n\t\treturn nil, errors.New(\"parameter certificateOrderName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{certificateOrderName}\", url.PathEscape(certificateOrderName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-09-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, certificateDistinguishedName)\n}", "func (client *SyncGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup, options *SyncGroupsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serverName == \"\" {\n\t\treturn nil, errors.New(\"parameter serverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serverName}\", url.PathEscape(serverName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif syncGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter syncGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{syncGroupName}\", url.PathEscape(syncGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *DiskEncryptionSetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, diskEncryptionSetName string, diskEncryptionSet DiskEncryptionSet, options *DiskEncryptionSetsBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif diskEncryptionSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter diskEncryptionSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{diskEncryptionSetName}\", url.PathEscape(diskEncryptionSetName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, diskEncryptionSet)\n}", "func (client *ContainerGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, containerGroup ContainerGroup, options *ContainerGroupsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif containerGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter containerGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{containerGroupName}\", url.PathEscape(containerGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, containerGroup)\n}", "func (client *ApplicationTypeVersionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, version string, parameters ApplicationTypeVersionResource, options *ApplicationTypeVersionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\tif applicationTypeName == \"\" {\n\t\treturn nil, errors.New(\"parameter applicationTypeName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{applicationTypeName}\", url.PathEscape(applicationTypeName))\n\tif version == \"\" {\n\t\treturn nil, errors.New(\"parameter version cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{version}\", url.PathEscape(version))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *IscsiTargetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, diskPoolName string, iscsiTargetName string, iscsiTargetCreatePayload IscsiTargetCreate, options *IscsiTargetsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StoragePool/diskPools/{diskPoolName}/iscsiTargets/{iscsiTargetName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif diskPoolName == \"\" {\n\t\treturn nil, errors.New(\"parameter diskPoolName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{diskPoolName}\", url.PathEscape(diskPoolName))\n\tif iscsiTargetName == \"\" {\n\t\treturn nil, errors.New(\"parameter iscsiTargetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{iscsiTargetName}\", url.PathEscape(iscsiTargetName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, iscsiTargetCreatePayload)\n}", "func (client *PublicIPAddressesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, publicIPAddressName string, parameters PublicIPAddress, options *PublicIPAddressesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif publicIPAddressName == \"\" {\n\t\treturn nil, errors.New(\"parameter publicIPAddressName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{publicIpAddressName}\", url.PathEscape(publicIPAddressName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func CreateOrUpdate(ctx context.Context, client *k8s.Client, req k8s.Resource, options ...k8s.Option) error {\n\tif err := client.Create(ctx, req, options...); err == nil {\n\t\treturn nil\n\t} else if !IsK8sAlreadyExists(err) {\n\t\treturn maskAny(err)\n\t}\n\t// Exists, update it\n\tif err := client.Update(ctx, req, options...); err != nil {\n\t\treturn maskAny(err)\n\t}\n\treturn nil\n}", "func (client *ConfigurationProfilesVersionsClient) createOrUpdateCreateRequest(ctx context.Context, configurationProfileName string, versionName string, resourceGroupName string, parameters ConfigurationProfile, options *ConfigurationProfilesVersionsClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfiles/{configurationProfileName}/versions/{versionName}\"\n\tif configurationProfileName == \"\" {\n\t\treturn nil, errors.New(\"parameter configurationProfileName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{configurationProfileName}\", url.PathEscape(configurationProfileName))\n\tif versionName == \"\" {\n\t\treturn nil, errors.New(\"parameter versionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{versionName}\", url.PathEscape(versionName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-05-04\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *PeeringPoliciesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkPeeringPolicyName string, managedNetworkPolicy PeeringPolicy, options *PeeringPoliciesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif managedNetworkName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedNetworkName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedNetworkName}\", url.PathEscape(managedNetworkName))\n\tif managedNetworkPeeringPolicyName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedNetworkPeeringPolicyName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedNetworkPeeringPolicyName}\", url.PathEscape(managedNetworkPeeringPolicyName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2019-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, managedNetworkPolicy)\n}", "func CreateOrUpdate(ctx context.Context, c client.Client, obj client.Object, f controllerutil.MutateFn) (controllerutil.OperationResult, error) {\n\n\t// check if the name key has to be generated\n\taccessor, err := meta.Accessor(obj)\n\tif err != nil {\n\t\treturn controllerutil.OperationResultNone, err\n\t}\n\tkey := client.ObjectKey{Namespace: accessor.GetNamespace(), Name: accessor.GetName()}\n\n\tif accessor.GetName() == \"\" && accessor.GetGenerateName() != \"\" {\n\t\tif err := Mutate(f, key, obj); err != nil {\n\t\t\treturn controllerutil.OperationResultNone, err\n\t\t}\n\t\tif err := c.Create(ctx, obj); err != nil {\n\t\t\treturn controllerutil.OperationResultNone, err\n\t\t}\n\t\treturn controllerutil.OperationResultCreated, nil\n\t}\n\n\treturn controllerutil.CreateOrUpdate(ctx, c, obj, f)\n}", "func (ro *ResourceOperations) CreateOrUpdate(resourceGroupName string, identity *ResourceIdentity) (*ResourceCreateOrUpdateResult, *AzureOperationResponse, error) {\n\treturn nil, nil, nil\n}", "func (client *VirtualRoutersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualRouterName string, parameters VirtualRouter, options *VirtualRoutersClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualRouters/{virtualRouterName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif virtualRouterName == \"\" {\n\t\treturn nil, errors.New(\"parameter virtualRouterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{virtualRouterName}\", url.PathEscape(virtualRouterName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func CreateOrUpdate(ctx context.Context, client resource.Interface, obj runtime.Object, mutate MutateFn) (OperationResult, error) {\n\treturn maybeCreateOrUpdate(ctx, client, obj, mutate, opCreate)\n}", "func (client *ApplyUpdatesClient) createOrUpdateParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *ApplyUpdatesClientCreateOrUpdateParentOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif providerName == \"\" {\n\t\treturn nil, errors.New(\"parameter providerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{providerName}\", url.PathEscape(providerName))\n\tif resourceParentType == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceParentType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceParentType}\", url.PathEscape(resourceParentType))\n\tif resourceParentName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceParentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceParentName}\", url.PathEscape(resourceParentName))\n\tif resourceType == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceType}\", url.PathEscape(resourceType))\n\tif resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(resourceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *FirewallRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, cacheName string, ruleName string, parameters FirewallRule, options *FirewallRulesClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{cacheName}/firewallRules/{ruleName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif cacheName == \"\" {\n\t\treturn nil, errors.New(\"parameter cacheName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{cacheName}\", url.PathEscape(cacheName))\n\tif ruleName == \"\" {\n\t\treturn nil, errors.New(\"parameter ruleName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ruleName}\", url.PathEscape(ruleName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *RecordSetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateZoneName string, recordType RecordType, relativeRecordSetName string, parameters RecordSet, options *RecordSetsCreateOrUpdateOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateDnsZones/{privateZoneName}/{recordType}/{relativeRecordSetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateZoneName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateZoneName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateZoneName}\", url.PathEscape(privateZoneName))\n\tif recordType == \"\" {\n\t\treturn nil, errors.New(\"parameter recordType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{recordType}\", url.PathEscape(string(recordType)))\n\tif relativeRecordSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter relativeRecordSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{relativeRecordSetName}\", relativeRecordSetName)\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\treqQP := req.URL.Query()\n\treqQP.Set(\"api-version\", \"2020-06-01\")\n\treq.URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Header.Set(\"If-Match\", *options.IfMatch)\n\t}\n\tif options != nil && options.IfNoneMatch != nil {\n\t\treq.Header.Set(\"If-None-Match\", *options.IfNoneMatch)\n\t}\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, req.MarshalAsJSON(parameters)\n}", "func (client *DatasetClient) createOrUpdateDatasetCreateRequest(ctx context.Context, datasetName string, dataset DatasetResource, options *DatasetBeginCreateOrUpdateDatasetOptions) (*azcore.Request, error) {\n\turlPath := \"/datasets/{datasetName}\"\n\tif datasetName == \"\" {\n\t\treturn nil, errors.New(\"parameter datasetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{datasetName}\", url.PathEscape(datasetName))\n\treq, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\treqQP := req.URL.Query()\n\treqQP.Set(\"api-version\", \"2019-06-01-preview\")\n\treq.URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Header.Set(\"If-Match\", *options.IfMatch)\n\t}\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, req.MarshalAsJSON(dataset)\n}", "func (client *ManagedDatabaseSecurityAlertPoliciesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, securityAlertPolicyName SecurityAlertPolicyName, parameters ManagedDatabaseSecurityAlertPolicy, options *ManagedDatabaseSecurityAlertPoliciesClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies/{securityAlertPolicyName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif managedInstanceName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedInstanceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedInstanceName}\", url.PathEscape(managedInstanceName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif securityAlertPolicyName == \"\" {\n\t\treturn nil, errors.New(\"parameter securityAlertPolicyName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{securityAlertPolicyName}\", url.PathEscape(string(securityAlertPolicyName)))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *AvailabilityGroupListenersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, sqlVirtualMachineGroupName string, availabilityGroupListenerName string, parameters AvailabilityGroupListener, options *AvailabilityGroupListenersClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sqlVirtualMachineGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter sqlVirtualMachineGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sqlVirtualMachineGroupName}\", url.PathEscape(sqlVirtualMachineGroupName))\n\tif availabilityGroupListenerName == \"\" {\n\t\treturn nil, errors.New(\"parameter availabilityGroupListenerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{availabilityGroupListenerName}\", url.PathEscape(availabilityGroupListenerName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *CustomDomainsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, appName string, domainName string, domainResource CustomDomainResource, options *CustomDomainsBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif appName == \"\" {\n\t\treturn nil, errors.New(\"parameter appName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{appName}\", url.PathEscape(appName))\n\tif domainName == \"\" {\n\t\treturn nil, errors.New(\"parameter domainName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{domainName}\", url.PathEscape(domainName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-09-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, domainResource)\n}", "func (client *PermissionBindingsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, permissionBindingName string, permissionBindingInfo PermissionBinding, options *PermissionBindingsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/namespaces/{namespaceName}/permissionBindings/{permissionBindingName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif namespaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter namespaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{namespaceName}\", url.PathEscape(namespaceName))\n\tif permissionBindingName == \"\" {\n\t\treturn nil, errors.New(\"parameter permissionBindingName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{permissionBindingName}\", url.PathEscape(permissionBindingName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, permissionBindingInfo)\n}", "func (client *MachineExtensionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtension, options *MachineExtensionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif extensionName == \"\" {\n\t\treturn nil, errors.New(\"parameter extensionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{extensionName}\", url.PathEscape(extensionName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-10-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, extensionParameters)\n}", "func (client *GalleryImagesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImage GalleryImage, options *GalleryImagesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif galleryName == \"\" {\n\t\treturn nil, errors.New(\"parameter galleryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{galleryName}\", url.PathEscape(galleryName))\n\tif galleryImageName == \"\" {\n\t\treturn nil, errors.New(\"parameter galleryImageName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{galleryImageName}\", url.PathEscape(galleryImageName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, galleryImage)\n}", "func (client *VirtualNetworkLinksClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateZoneName string, virtualNetworkLinkName string, parameters VirtualNetworkLink, options *VirtualNetworkLinksBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateDnsZones/{privateZoneName}/virtualNetworkLinks/{virtualNetworkLinkName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateZoneName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateZoneName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateZoneName}\", url.PathEscape(privateZoneName))\n\tif virtualNetworkLinkName == \"\" {\n\t\treturn nil, errors.New(\"parameter virtualNetworkLinkName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{virtualNetworkLinkName}\", url.PathEscape(virtualNetworkLinkName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Raw().Header.Set(\"If-Match\", *options.IfMatch)\n\t}\n\tif options != nil && options.IfNoneMatch != nil {\n\t\treq.Raw().Header.Set(\"If-None-Match\", *options.IfNoneMatch)\n\t}\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *VendorNetworkFunctionsClient) createOrUpdateCreateRequest(ctx context.Context, locationName string, vendorName string, serviceKey string, parameters VendorNetworkFunction, options *VendorNetworkFunctionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/locations/{locationName}/vendors/{vendorName}/networkFunctions/{serviceKey}\"\n\tif locationName == \"\" {\n\t\treturn nil, errors.New(\"parameter locationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{locationName}\", url.PathEscape(locationName))\n\tif vendorName == \"\" {\n\t\treturn nil, errors.New(\"parameter vendorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vendorName}\", url.PathEscape(vendorName))\n\tif serviceKey == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceKey cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceKey}\", url.PathEscape(serviceKey))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *NotificationRecipientEmailClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string, options *NotificationRecipientEmailClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif notificationName == \"\" {\n\t\treturn nil, errors.New(\"parameter notificationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{notificationName}\", url.PathEscape(string(notificationName)))\n\tif email == \"\" {\n\t\treturn nil, errors.New(\"parameter email cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{email}\", url.PathEscape(email))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *CassandraClustersClient) createUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, body ClusterResource, options *CassandraClustersClientBeginCreateUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-03-15-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, body)\n}", "func (client *BuildServiceClient) createOrUpdateBuildCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, buildServiceName string, buildName string, buildParam Build, options *BuildServiceClientCreateOrUpdateBuildOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif buildServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter buildServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{buildServiceName}\", url.PathEscape(buildServiceName))\n\tif buildName == \"\" {\n\t\treturn nil, errors.New(\"parameter buildName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{buildName}\", url.PathEscape(buildName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, buildParam)\n}", "func (client *VirtualMachineScaleSetVMRunCommandsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, vmScaleSetName string, instanceID string, runCommandName string, runCommand VirtualMachineRunCommand, options *VirtualMachineScaleSetVMRunCommandsBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif vmScaleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter vmScaleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vmScaleSetName}\", url.PathEscape(vmScaleSetName))\n\tif instanceID == \"\" {\n\t\treturn nil, errors.New(\"parameter instanceID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{instanceId}\", url.PathEscape(instanceID))\n\tif runCommandName == \"\" {\n\t\treturn nil, errors.New(\"parameter runCommandName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{runCommandName}\", url.PathEscape(runCommandName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json, text/json\")\n\treturn req, runtime.MarshalAsJSON(req, runCommand)\n}", "func (client *GalleryImageVersionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string, galleryImageVersion GalleryImageVersion, options *GalleryImageVersionsBeginCreateOrUpdateOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{galleryName}\", url.PathEscape(galleryName))\n\turlPath = strings.ReplaceAll(urlPath, \"{galleryImageName}\", url.PathEscape(galleryImageName))\n\turlPath = strings.ReplaceAll(urlPath, \"{galleryImageVersionName}\", url.PathEscape(galleryImageVersionName))\n\treq, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-09-30\")\n\treq.URL.RawQuery = query.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, req.MarshalAsJSON(galleryImageVersion)\n}", "func CreateValuateTemplateRequest() (request *ValuateTemplateRequest) {\n\trequest = &ValuateTemplateRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"BPStudio\", \"2021-09-31\", \"ValuateTemplate\", \"bpstudio\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *PacketCoreDataPlanesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, parameters PacketCoreDataPlane, options *PacketCoreDataPlanesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif packetCoreControlPlaneName == \"\" {\n\t\treturn nil, errors.New(\"parameter packetCoreControlPlaneName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{packetCoreControlPlaneName}\", url.PathEscape(packetCoreControlPlaneName))\n\tif packetCoreDataPlaneName == \"\" {\n\t\treturn nil, errors.New(\"parameter packetCoreDataPlaneName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{packetCoreDataPlaneName}\", url.PathEscape(packetCoreDataPlaneName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *PrivateDNSZoneGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateEndpointName string, privateDNSZoneGroupName string, parameters PrivateDNSZoneGroup, options *PrivateDNSZoneGroupsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateEndpoints/{privateEndpointName}/privateDnsZoneGroups/{privateDnsZoneGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateEndpointName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateEndpointName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateEndpointName}\", url.PathEscape(privateEndpointName))\n\tif privateDNSZoneGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateDNSZoneGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateDnsZoneGroupName}\", url.PathEscape(privateDNSZoneGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (c *MockRouteTablesClient) CreateOrUpdate(ctx context.Context, resourceGroupName, routeTableName string, parameters network.RouteTable) error {\n\t// Ignore resourceGroupName for simplicity.\n\tif _, ok := c.RTs[routeTableName]; ok {\n\t\treturn fmt.Errorf(\"update not supported\")\n\t}\n\tparameters.Name = &routeTableName\n\tc.RTs[routeTableName] = parameters\n\treturn nil\n}", "func (c *MockPublicIPAddressesClient) CreateOrUpdate(ctx context.Context, resourceGroupName, publicIPAddressName string, parameters network.PublicIPAddress) (*network.PublicIPAddress, error) {\n\tif _, ok := c.PubIPs[publicIPAddressName]; ok {\n\t\treturn nil, fmt.Errorf(\"update not supported\")\n\t}\n\tparameters.Name = &publicIPAddressName\n\tc.PubIPs[publicIPAddressName] = parameters\n\treturn &parameters, nil\n}" ]
[ "0.716981", "0.6974975", "0.69614655", "0.6951513", "0.69285613", "0.68497676", "0.6784493", "0.67738926", "0.6750997", "0.67280304", "0.6690952", "0.6675086", "0.6671258", "0.6670252", "0.664669", "0.6608871", "0.6569229", "0.65341884", "0.6533084", "0.647038", "0.6438516", "0.6425159", "0.6408161", "0.6404987", "0.64041424", "0.6401796", "0.63853526", "0.6384109", "0.63840634", "0.63785195", "0.63676035", "0.6366991", "0.6365389", "0.6337108", "0.63213724", "0.62981117", "0.629042", "0.6267041", "0.6252352", "0.6233127", "0.62270796", "0.62270266", "0.6208398", "0.620413", "0.61944807", "0.6182333", "0.6180793", "0.617838", "0.61696935", "0.6163759", "0.61583614", "0.61542094", "0.61495376", "0.61331797", "0.61249065", "0.6124418", "0.6124305", "0.6111921", "0.6110269", "0.61093163", "0.60906965", "0.60836834", "0.6081216", "0.60785604", "0.60762787", "0.60730594", "0.60691416", "0.60396636", "0.6020484", "0.6006138", "0.5992349", "0.5971212", "0.5949746", "0.59238976", "0.5923075", "0.58981013", "0.5875367", "0.5849852", "0.5845767", "0.5842828", "0.5824946", "0.57579225", "0.5739348", "0.57110316", "0.5697961", "0.5648799", "0.5619693", "0.5611493", "0.56029093", "0.55952024", "0.5584893", "0.55734396", "0.5560341", "0.55541956", "0.55520713", "0.5549516", "0.5504143", "0.55006266", "0.54762214", "0.5465384" ]
0.7014643
1
createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request.
createOrUpdateAtManagementGroupCreateRequest создает запрос CreateOrUpdateAtManagementGroup.
func (client *PolicyDefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, parameters PolicyDefinition, options *PolicyDefinitionsCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" if policyDefinitionName == "" { return nil, errors.New("parameter policyDefinitionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, runtime.MarshalAsJSON(req, parameters) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *GroupClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, parameters GroupCreateParameters, options *GroupCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif groupID == \"\" {\n\t\treturn nil, errors.New(\"parameter groupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{groupId}\", url.PathEscape(groupID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Raw().Header.Set(\"If-Match\", *options.IfMatch)\n\t}\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *PolicyDefinitionsClient) getAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, options *PolicyDefinitionsGetAtManagementGroupOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}\"\n\tif policyDefinitionName == \"\" {\n\t\treturn nil, errors.New(\"parameter policyDefinitionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{policyDefinitionName}\", url.PathEscape(policyDefinitionName))\n\tif managementGroupID == \"\" {\n\t\treturn nil, errors.New(\"parameter managementGroupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementGroupId}\", url.PathEscape(managementGroupID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ContainerGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, containerGroup ContainerGroup, options *ContainerGroupsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif containerGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter containerGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{containerGroupName}\", url.PathEscape(containerGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, containerGroup)\n}", "func (c *MockResourceGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, parameters resources.Group) error {\n\tparameters.Name = &resourceGroupName\n\tc.RGs[resourceGroupName] = parameters\n\treturn nil\n}", "func (client *SyncGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, parameters SyncGroup, options *SyncGroupsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serverName == \"\" {\n\t\treturn nil, errors.New(\"parameter serverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serverName}\", url.PathEscape(serverName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif syncGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter syncGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{syncGroupName}\", url.PathEscape(syncGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (c GroupClient) CreateOrUpdate(ctx context.Context, resourceGroupName, region string) error {\n\tif _, err := c.client.CreateOrUpdate(ctx, resourceGroupName, resources.Group{\n\t\tLocation: &region,\n\t}); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (client *PolicyDefinitionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, options *PolicyDefinitionsDeleteAtManagementGroupOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}\"\n\tif policyDefinitionName == \"\" {\n\t\treturn nil, errors.New(\"parameter policyDefinitionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{policyDefinitionName}\", url.PathEscape(policyDefinitionName))\n\tif managementGroupID == \"\" {\n\t\treturn nil, errors.New(\"parameter managementGroupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementGroupId}\", url.PathEscape(managementGroupID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ManagementAssociationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, managementAssociationName string, parameters ManagementAssociation, options *ManagementAssociationsCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.providerName == \"\" {\n\t\treturn nil, errors.New(\"parameter client.providerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{providerName}\", url.PathEscape(client.providerName))\n\tif client.resourceType == \"\" {\n\t\treturn nil, errors.New(\"parameter client.resourceType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceType}\", url.PathEscape(client.resourceType))\n\tif client.resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter client.resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(client.resourceName))\n\tif managementAssociationName == \"\" {\n\t\treturn nil, errors.New(\"parameter managementAssociationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementAssociationName}\", url.PathEscape(managementAssociationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2015-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (c *MockApplicationSecurityGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName, asgName string, parameters network.ApplicationSecurityGroup) (*network.ApplicationSecurityGroup, error) {\n\t// Ignore resourceGroupName for simplicity.\n\tif _, ok := c.ASGs[asgName]; ok {\n\t\treturn nil, fmt.Errorf(\"update not supported\")\n\t}\n\tparameters.Name = &asgName\n\tc.ASGs[asgName] = parameters\n\treturn &parameters, nil\n}", "func (client *PrivateDNSZoneGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateEndpointName string, privateDNSZoneGroupName string, parameters PrivateDNSZoneGroup, options *PrivateDNSZoneGroupsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateEndpoints/{privateEndpointName}/privateDnsZoneGroups/{privateDnsZoneGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateEndpointName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateEndpointName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateEndpointName}\", url.PathEscape(privateEndpointName))\n\tif privateDNSZoneGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateDNSZoneGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateDnsZoneGroupName}\", url.PathEscape(privateDNSZoneGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *AvailabilitySetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters AvailabilitySet, options *AvailabilitySetsCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif availabilitySetName == \"\" {\n\t\treturn nil, errors.New(\"parameter availabilitySetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{availabilitySetName}\", url.PathEscape(availabilitySetName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func NewDeploymentAtManagementGroupScope(ctx *pulumi.Context,\n\tname string, args *DeploymentAtManagementGroupScopeArgs, opts ...pulumi.ResourceOption) (*DeploymentAtManagementGroupScope, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.GroupId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'GroupId'\")\n\t}\n\tif args.Properties == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Properties'\")\n\t}\n\taliases := pulumi.Aliases([]pulumi.Alias{\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20190501:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20190510:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20190510:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20190701:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20190701:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20190801:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20190801:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20191001:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20191001:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20200601:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20200601:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20200801:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20200801:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20201001:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20201001:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20210101:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20210101:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20210401:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20210401:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t})\n\topts = append(opts, aliases)\n\tvar resource DeploymentAtManagementGroupScope\n\terr := ctx.RegisterResource(\"azure-native:resources/v20190501:DeploymentAtManagementGroupScope\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func CreateCreateApplicationGroupRequest() (request *CreateApplicationGroupRequest) {\n\trequest = &CreateApplicationGroupRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"oos\", \"2019-06-01\", \"CreateApplicationGroup\", \"oos\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (c *MockNetworkSecurityGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName, nsgName string, parameters network.SecurityGroup) (*network.SecurityGroup, error) {\n\t// Ignore resourceGroupName for simplicity.\n\tif _, ok := c.NSGs[nsgName]; ok {\n\t\treturn nil, fmt.Errorf(\"update not supported\")\n\t}\n\tparameters.Name = &nsgName\n\tc.NSGs[nsgName] = parameters\n\treturn &parameters, nil\n}", "func (client *PolicyDefinitionsClient) listByManagementGroupCreateRequest(ctx context.Context, managementGroupID string, options *PolicyDefinitionsListByManagementGroupOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions\"\n\tif managementGroupID == \"\" {\n\t\treturn nil, errors.New(\"parameter managementGroupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementGroupId}\", url.PathEscape(managementGroupID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\tif options != nil && options.Top != nil {\n\t\treqQP.Set(\"$top\", strconv.FormatInt(int64(*options.Top), 10))\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tunencodedParams := []string{req.Raw().URL.RawQuery}\n\tif options != nil && options.Filter != nil {\n\t\tunencodedParams = append(unencodedParams, \"$filter=\"+*options.Filter)\n\t}\n\treq.Raw().URL.RawQuery = strings.Join(unencodedParams, \"&\")\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func CreatePutMetricAlarmRequest() (request *PutMetricAlarmRequest) {\n\trequest = &PutMetricAlarmRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Cms\", \"2018-03-08\", \"PutMetricAlarm\", \"cms\", \"openAPI\")\n\treturn\n}", "func (c *UMemClient) NewCreateUMemcacheGroupRequest() *CreateUMemcacheGroupRequest {\n\treq := &CreateUMemcacheGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(false)\n\treturn req\n}", "func (client *ClustersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, parameters Cluster, options *ClustersBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func CreateUpdateEndpointGroupRequest() (request *UpdateEndpointGroupRequest) {\n\trequest = &UpdateEndpointGroupRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Ga\", \"2019-11-20\", \"UpdateEndpointGroup\", \"gaplus\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func CreateModifyDesktopsPolicyGroupRequest() (request *ModifyDesktopsPolicyGroupRequest) {\n\trequest = &ModifyDesktopsPolicyGroupRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"ecd\", \"2020-09-30\", \"ModifyDesktopsPolicyGroup\", \"\", \"\")\n\trequest.Method = requests.POST\n\treturn\n}", "func NewPolicyDefinitionAtManagementGroup(ctx *pulumi.Context,\n\tname string, args *PolicyDefinitionAtManagementGroupArgs, opts ...pulumi.ResourceOption) (*PolicyDefinitionAtManagementGroup, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.ManagementGroupId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'ManagementGroupId'\")\n\t}\n\taliases := pulumi.Aliases([]pulumi.Alias{\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20190101:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20161201:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20161201:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20180301:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20180301:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20180501:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20180501:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20190601:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20190601:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20190901:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20190901:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20200301:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20200301:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20200901:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20200901:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t})\n\topts = append(opts, aliases)\n\tvar resource PolicyDefinitionAtManagementGroup\n\terr := ctx.RegisterResource(\"azure-native:authorization/v20190101:PolicyDefinitionAtManagementGroup\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func CreateCreateMonitorGroupRequest() (request *CreateMonitorGroupRequest) {\n\trequest = &CreateMonitorGroupRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Cms\", \"2019-01-01\", \"CreateMonitorGroup\", \"cms\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *TagRulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, resource TagRule, options *TagRulesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/monitors/{monitorName}/tagRules/{ruleSetName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif monitorName == \"\" {\n\t\treturn nil, errors.New(\"parameter monitorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{monitorName}\", url.PathEscape(monitorName))\n\tif ruleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter ruleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ruleSetName}\", url.PathEscape(ruleSetName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-27\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, resource); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func CreateCreateMonitorGroupByResourceGroupIdRequest() (request *CreateMonitorGroupByResourceGroupIdRequest) {\n\trequest = &CreateMonitorGroupByResourceGroupIdRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Cms\", \"2019-01-01\", \"CreateMonitorGroupByResourceGroupId\", \"cms\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (c *Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, privateZoneName string, parameters privatedns.PrivateZone, waitForCompletion bool) error {\n\tcreateOrUpdateFuture, err := c.privateDNSClient.CreateOrUpdate(ctx, resourceGroupName, privateZoneName, parameters, \"\", \"*\")\n\n\tif err != nil {\n\t\tklog.V(5).Infof(\"Received error for %s, resourceGroup: %s, error: %s\", \"privatedns.put.request\", resourceGroupName, err)\n\t\treturn err\n\t}\n\n\tif waitForCompletion {\n\t\terr := createOrUpdateFuture.WaitForCompletionRef(ctx, c.privateDNSClient.Client)\n\t\tif err != nil {\n\t\t\tklog.V(5).Infof(\"Received error while waiting for completion for %s, resourceGroup: %s, error: %s\", \"privatedns.put.request\", resourceGroupName, err)\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (client *DiskEncryptionSetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, diskEncryptionSetName string, diskEncryptionSet DiskEncryptionSet, options *DiskEncryptionSetsBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif diskEncryptionSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter diskEncryptionSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{diskEncryptionSetName}\", url.PathEscape(diskEncryptionSetName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, diskEncryptionSet)\n}", "func (client *VirtualMachineScaleSetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, vmScaleSetName string, parameters VirtualMachineScaleSet, options *VirtualMachineScaleSetsBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif vmScaleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter vmScaleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vmScaleSetName}\", url.PathEscape(vmScaleSetName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *LocalRulestacksClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, localRulestackName string, resource LocalRulestackResource, options *LocalRulestacksClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif localRulestackName == \"\" {\n\t\treturn nil, errors.New(\"parameter localRulestackName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{localRulestackName}\", url.PathEscape(localRulestackName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-29\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, resource)\n}", "func (client *KpiClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, hubName string, kpiName string, parameters KpiResourceFormat, options *KpiClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomerInsights/hubs/{hubName}/kpi/{kpiName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif hubName == \"\" {\n\t\treturn nil, errors.New(\"parameter hubName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hubName}\", url.PathEscape(hubName))\n\tif kpiName == \"\" {\n\t\treturn nil, errors.New(\"parameter kpiName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{kpiName}\", url.PathEscape(kpiName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-04-26\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *SchemaRegistryClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, schemaGroupName string, parameters SchemaGroup, options *SchemaRegistryClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/schemagroups/{schemaGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif namespaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter namespaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{namespaceName}\", url.PathEscape(namespaceName))\n\tif schemaGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter schemaGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{schemaGroupName}\", url.PathEscape(schemaGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-10-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *RegistrationDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, registrationDefinitionID string, scope string, requestBody RegistrationDefinition, options *RegistrationDefinitionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}\"\n\tif registrationDefinitionID == \"\" {\n\t\treturn nil, errors.New(\"parameter registrationDefinitionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{registrationDefinitionId}\", url.PathEscape(registrationDefinitionID))\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, requestBody)\n}", "func CreateUpdateAppInstanceGroupImageRequest() (request *UpdateAppInstanceGroupImageRequest) {\n\trequest = &UpdateAppInstanceGroupImageRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"appstream-center\", \"2021-09-01\", \"UpdateAppInstanceGroupImage\", \"\", \"\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (c *UDBClient) NewCreateUDBParamGroupRequest() *CreateUDBParamGroupRequest {\n\treq := &CreateUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(false)\n\treturn req\n}", "func (c *UDBClient) NewCreateUDBParamGroupRequest() *CreateUDBParamGroupRequest {\n\treq := &CreateUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(false)\n\treturn req\n}", "func (c *MockNatGatewaysClient) CreateOrUpdate(ctx context.Context, resourceGroupName, ngwName string, parameters network.NatGateway) (*network.NatGateway, error) {\n\t// Ignore resourceGroupName for simplicity.\n\tif _, ok := c.NGWs[ngwName]; ok {\n\t\treturn nil, fmt.Errorf(\"update not supported\")\n\t}\n\tparameters.Name = &ngwName\n\tc.NGWs[ngwName] = parameters\n\treturn &parameters, nil\n}", "func CreateDescribeContainerGroupMetricRequest() (request *DescribeContainerGroupMetricRequest) {\n\trequest = &DescribeContainerGroupMetricRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Eci\", \"2018-08-08\", \"DescribeContainerGroupMetric\", \"eci\", \"openAPI\")\n\treturn\n}", "func (client *PolicyDefinitionsClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse, error) {\n\tresult := PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PolicyDefinition); err != nil {\n\t\treturn PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func CreateDescribeScalingGroupsRequest() (request *DescribeScalingGroupsRequest) {\n\trequest = &DescribeScalingGroupsRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Ess\", \"2014-08-28\", \"DescribeScalingGroups\", \"ess\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (mg *Groups) Create(group *Group) error {\n\n\tif mg.group != nil && len(group.ID) > 0 {\n\n\t\tpath := fmt.Sprintf(\"%s%s\", marathon.APIGroups, utilities.DelInitialSlash(group.ID))\n\n\t\tif _, err := mg.client.Session.BodyAsJSON(group).Post(path, mg.deploy, mg.fail); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmg.group = group\n\t\treturn nil\n\t}\n\treturn errors.New(\"group cannot be null nor empty\")\n}", "func (client *Client) CreateOrUpdateAssetGroupWithOptions(request *CreateOrUpdateAssetGroupRequest, runtime *util.RuntimeOptions) (_result *CreateOrUpdateAssetGroupResponse, _err error) {\n\t_err = util.ValidateModel(request)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\tquery := map[string]interface{}{}\n\tif !tea.BoolValue(util.IsUnset(request.GroupId)) {\n\t\tquery[\"GroupId\"] = request.GroupId\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.GroupName)) {\n\t\tquery[\"GroupName\"] = request.GroupName\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.Uuids)) {\n\t\tquery[\"Uuids\"] = request.Uuids\n\t}\n\n\treq := &openapi.OpenApiRequest{\n\t\tQuery: openapiutil.Query(query),\n\t}\n\tparams := &openapi.Params{\n\t\tAction: tea.String(\"CreateOrUpdateAssetGroup\"),\n\t\tVersion: tea.String(\"2018-12-03\"),\n\t\tProtocol: tea.String(\"HTTPS\"),\n\t\tPathname: tea.String(\"/\"),\n\t\tMethod: tea.String(\"POST\"),\n\t\tAuthType: tea.String(\"AK\"),\n\t\tStyle: tea.String(\"RPC\"),\n\t\tReqBodyType: tea.String(\"formData\"),\n\t\tBodyType: tea.String(\"json\"),\n\t}\n\t_result = &CreateOrUpdateAssetGroupResponse{}\n\t_body, _err := client.CallApi(params, req, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_err = tea.Convert(_body, &_result)\n\treturn _result, _err\n}", "func (client *Client) CreateOrUpdateAssetGroup(request *CreateOrUpdateAssetGroupRequest) (_result *CreateOrUpdateAssetGroupResponse, _err error) {\n\truntime := &util.RuntimeOptions{}\n\t_result = &CreateOrUpdateAssetGroupResponse{}\n\t_body, _err := client.CreateOrUpdateAssetGroupWithOptions(request, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_result = _body\n\treturn _result, _err\n}", "func CreateModifySkillGroupExRequest() (request *ModifySkillGroupExRequest) {\n\trequest = &ModifySkillGroupExRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"CloudCallCenter\", \"2017-07-05\", \"ModifySkillGroupEx\", \"\", \"\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *ClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClustersClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-11-08\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *RecordSetsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, privateZoneName string, recordType RecordType, relativeRecordSetName string, parameters RecordSet, options *RecordSetsCreateOrUpdateOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateDnsZones/{privateZoneName}/{recordType}/{relativeRecordSetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateZoneName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateZoneName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateZoneName}\", url.PathEscape(privateZoneName))\n\tif recordType == \"\" {\n\t\treturn nil, errors.New(\"parameter recordType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{recordType}\", url.PathEscape(string(recordType)))\n\tif relativeRecordSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter relativeRecordSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{relativeRecordSetName}\", relativeRecordSetName)\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\treqQP := req.URL.Query()\n\treqQP.Set(\"api-version\", \"2020-06-01\")\n\treq.URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Header.Set(\"If-Match\", *options.IfMatch)\n\t}\n\tif options != nil && options.IfNoneMatch != nil {\n\t\treq.Header.Set(\"If-None-Match\", *options.IfNoneMatch)\n\t}\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, req.MarshalAsJSON(parameters)\n}", "func (client *MetricAlertsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, parameters MetricAlertResource, options *MetricAlertsClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif ruleName == \"\" {\n\t\treturn nil, errors.New(\"parameter ruleName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ruleName}\", url.PathEscape(ruleName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func CreateDeleteCorpGroupRequest() (request *DeleteCorpGroupRequest) {\n\trequest = &DeleteCorpGroupRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Vcs\", \"2020-05-15\", \"DeleteCorpGroup\", \"\", \"\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *ManagedClustersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters ManagedCluster, options *ManagedClustersClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(resourceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *AgentPoolsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, kubernetesClusterName string, agentPoolName string, agentPoolParameters AgentPool, options *AgentPoolsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkCloud/kubernetesClusters/{kubernetesClusterName}/agentPools/{agentPoolName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif kubernetesClusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter kubernetesClusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{kubernetesClusterName}\", url.PathEscape(kubernetesClusterName))\n\tif agentPoolName == \"\" {\n\t\treturn nil, errors.New(\"parameter agentPoolName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{agentPoolName}\", url.PathEscape(agentPoolName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, agentPoolParameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *CapacityReservationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, capacityReservationGroupName string, capacityReservationName string, parameters CapacityReservation, options *CapacityReservationsBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif capacityReservationGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter capacityReservationGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{capacityReservationGroupName}\", url.PathEscape(capacityReservationGroupName))\n\tif capacityReservationName == \"\" {\n\t\treturn nil, errors.New(\"parameter capacityReservationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{capacityReservationName}\", url.PathEscape(capacityReservationName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *IPAllocationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, ipAllocationName string, parameters IPAllocation, options *IPAllocationsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/IpAllocations/{ipAllocationName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif ipAllocationName == \"\" {\n\t\treturn nil, errors.New(\"parameter ipAllocationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ipAllocationName}\", url.PathEscape(ipAllocationName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (a *IAMApiService) CreateGroup(ctx context.Context, gid string, iamGroupCreate IamGroupCreate) (*http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = http.MethodPut\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/acs/api/v1/groups/{gid}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"gid\"+\"}\", fmt.Sprintf(\"%v\", gid), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{\"application/json\"}\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\t// body params\n\tlocalVarPostBody = &iamGroupCreate\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\t\tif localVarHttpResponse.StatusCode == 0 {\n\t\t\tvar v IamError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHttpResponse, newErr\n\t\t}\n\t\treturn localVarHttpResponse, newErr\n\t}\n\n\treturn localVarHttpResponse, nil\n}", "func NewAttachGroupPolicyRequestWithoutParam() *AttachGroupPolicyRequest {\n\n return &AttachGroupPolicyRequest{\n JDCloudRequest: core.JDCloudRequest{\n URL: \"/group/{groupName}:attachGroupPolicy\",\n Method: \"POST\",\n Header: nil,\n Version: \"v1\",\n },\n }\n}", "func (gr *GroupResource) Create(owner string, name string) (g *GroupDetails, err error) {\n\townerOrCurrentUser(gr, &owner)\n\n\tpath := fmt.Sprintf(\"/groups/%s/\", owner)\n\tvalues := url.Values{}\n\tvalues.Set(\"name\", name)\n\terr = gr.client.do(\"POST\", path, nil, values, &g)\n\n\treturn\n}", "func (client *DedicatedHostsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string, parameters DedicatedHost, options *DedicatedHostsBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif hostGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter hostGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hostGroupName}\", url.PathEscape(hostGroupName))\n\tif hostName == \"\" {\n\t\treturn nil, errors.New(\"parameter hostName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hostName}\", url.PathEscape(hostName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *ManagedInstancesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, managedInstanceName string, parameters ManagedInstance, options *ManagedInstancesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif managedInstanceName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedInstanceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedInstanceName}\", url.PathEscape(managedInstanceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *MonitorsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *MonitorsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func CreateRemoveAppGroupRequest() (request *RemoveAppGroupRequest) {\n\trequest = &RemoveAppGroupRequest{\n\t\tRoaRequest: &requests.RoaRequest{},\n\t}\n\trequest.InitWithApiInfo(\"OpenSearch\", \"2017-12-25\", \"RemoveAppGroup\", \"/v4/openapi/app-groups/[appGroupIdentity]\", \"\", \"\")\n\trequest.Method = requests.DELETE\n\treturn\n}", "func (client *GroupClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string, parameters GroupUpdateParameters, options *GroupUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif groupID == \"\" {\n\t\treturn nil, errors.New(\"parameter groupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{groupId}\", url.PathEscape(groupID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"If-Match\", ifMatch)\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func NewIgroupCreateRequest() *IgroupCreateRequest {\n\treturn &IgroupCreateRequest{}\n}", "func createGroup() (group resources.Group, err error) {\n\tgroupsClient := resources.NewGroupsClient(config.SubscriptionID)\n\tgroupsClient.Authorizer = autorest.NewBearerAuthorizer(token)\n\n\treturn groupsClient.CreateOrUpdate(\n\t\tctx,\n\t\tresourceGroupName,\n\t\tresources.Group{\n\t\t\tLocation: to.StringPtr(resourceGroupLocation)})\n}", "func (client *DeviceSettingsClient) createOrUpdateTimeSettingsCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, managerName string, parameters TimeSettings, options *DeviceSettingsClientBeginCreateOrUpdateTimeSettingsOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/timeSettings/default\"\n\turlPath = strings.ReplaceAll(urlPath, \"{deviceName}\", deviceName)\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", client.subscriptionID)\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", resourceGroupName)\n\turlPath = strings.ReplaceAll(urlPath, \"{managerName}\", managerName)\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (r *ProjectsGroupsService) Create(name string, group *Group) *ProjectsGroupsCreateCall {\n\tc := &ProjectsGroupsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.name = name\n\tc.group = group\n\treturn c\n}", "func (g *GroupsService) CreateGroup(group Group) (*Group, *Response, error) {\n\tif err := g.client.validate.Struct(group); err != nil {\n\t\treturn nil, nil, err\n\t}\n\treq, err := g.client.newRequest(IDM, \"POST\", \"authorize/identity/Group\", &group, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treq.Header.Set(\"api-version\", groupAPIVersion)\n\n\tvar createdGroup Group\n\n\tresp, err := g.client.do(req, &createdGroup)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\treturn &createdGroup, resp, err\n\n}", "func (client *CustomAssessmentAutomationsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *CustomAssessmentAutomationsListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customAssessmentAutomations\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ClientImpl) CreateControlInGroup(ctx context.Context, args CreateControlInGroupArgs) (*Control, error) {\n\tif args.Control == nil {\n\t\treturn nil, &azuredevops.ArgumentNilError{ArgumentName: \"args.Control\"}\n\t}\n\trouteValues := make(map[string]string)\n\tif args.ProcessId == nil {\n\t\treturn nil, &azuredevops.ArgumentNilError{ArgumentName: \"args.ProcessId\"}\n\t}\n\trouteValues[\"processId\"] = (*args.ProcessId).String()\n\tif args.WitRefName == nil || *args.WitRefName == \"\" {\n\t\treturn nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: \"args.WitRefName\"}\n\t}\n\trouteValues[\"witRefName\"] = *args.WitRefName\n\tif args.GroupId == nil || *args.GroupId == \"\" {\n\t\treturn nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: \"args.GroupId\"}\n\t}\n\trouteValues[\"groupId\"] = *args.GroupId\n\n\tbody, marshalErr := json.Marshal(*args.Control)\n\tif marshalErr != nil {\n\t\treturn nil, marshalErr\n\t}\n\tlocationId, _ := uuid.Parse(\"1f59b363-a2d0-4b7e-9bc6-eb9f5f3f0e58\")\n\tresp, err := client.Client.Send(ctx, http.MethodPost, locationId, \"6.0-preview.1\", routeValues, nil, bytes.NewReader(body), \"application/json\", \"application/json\", nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar responseValue Control\n\terr = client.Client.UnmarshalBody(resp, &responseValue)\n\treturn &responseValue, err\n}", "func (s *AutograderService) CreateGroup(ctx context.Context, in *pb.Group) (*pb.Group, error) {\n\tusr, err := s.getCurrentUser(ctx)\n\tif err != nil {\n\t\ts.logger.Errorf(\"CreateGroup failed: authentication error: %w\", err)\n\t\treturn nil, ErrInvalidUserInfo\n\t}\n\tif !s.isEnrolled(usr.GetID(), in.GetCourseID()) {\n\t\ts.logger.Errorf(\"CreateGroup failed: user %s not enrolled in course %d\", usr.GetLogin(), in.GetCourseID())\n\t\treturn nil, status.Errorf(codes.PermissionDenied, \"user not enrolled in given course\")\n\t}\n\tif !(in.Contains(usr) || s.isTeacher(usr.GetID(), in.GetCourseID())) {\n\t\ts.logger.Error(\"CreateGroup failed: user is not group member or teacher\")\n\t\treturn nil, status.Errorf(codes.PermissionDenied, \"only group member or teacher can create group\")\n\t}\n\tgroup, err := s.createGroup(in)\n\tif err != nil {\n\t\ts.logger.Errorf(\"CreateGroup failed: %w\", err)\n\t\treturn nil, status.Error(codes.InvalidArgument, \"failed to create group\")\n\t}\n\treturn group, nil\n}", "func (client *DedicatedHostsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string, parameters DedicatedHost, options *DedicatedHostsBeginCreateOrUpdateOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{hostGroupName}\", url.PathEscape(hostGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{hostName}\", url.PathEscape(hostName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-06-01\")\n\treq.URL.RawQuery = query.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, req.MarshalAsJSON(parameters)\n}", "func NewCreateVMPlacementGroupOK() *CreateVMPlacementGroupOK {\n\treturn &CreateVMPlacementGroupOK{}\n}", "func (client *DeviceSettingsClient) createOrUpdateAlertSettingsCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, managerName string, parameters AlertSettings, options *DeviceSettingsClientBeginCreateOrUpdateAlertSettingsOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/alertSettings/default\"\n\turlPath = strings.ReplaceAll(urlPath, \"{deviceName}\", deviceName)\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", client.subscriptionID)\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", resourceGroupName)\n\turlPath = strings.ReplaceAll(urlPath, \"{managerName}\", managerName)\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *ConnectedEnvironmentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, connectedEnvironmentName string, environmentEnvelope ConnectedEnvironment, options *ConnectedEnvironmentsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif connectedEnvironmentName == \"\" {\n\t\treturn nil, errors.New(\"parameter connectedEnvironmentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{connectedEnvironmentName}\", url.PathEscape(connectedEnvironmentName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, environmentEnvelope)\n}", "func (c *MockVMScaleSetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName, vmScaleSetName string, parameters compute.VirtualMachineScaleSet) (*compute.VirtualMachineScaleSet, error) {\n\t// Ignore resourceGroupName for simplicity.\n\tif _, ok := c.VMSSes[vmScaleSetName]; ok {\n\t\treturn nil, fmt.Errorf(\"update not supported\")\n\t}\n\tparameters.Name = &vmScaleSetName\n\tparameters.Identity.PrincipalID = fi.PtrTo(uuid.New().String())\n\tc.VMSSes[vmScaleSetName] = parameters\n\treturn &parameters, nil\n}", "func (client *RoleDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, roleDefinitionID string, roleDefinition RoleDefinition, options *RoleDefinitionsCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\tif roleDefinitionID == \"\" {\n\t\treturn nil, errors.New(\"parameter roleDefinitionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{roleDefinitionId}\", url.PathEscape(roleDefinitionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, roleDefinition)\n}", "func (client *InteractionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, hubName string, interactionName string, parameters InteractionResourceFormat, options *InteractionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomerInsights/hubs/{hubName}/interactions/{interactionName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif hubName == \"\" {\n\t\treturn nil, errors.New(\"parameter hubName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hubName}\", url.PathEscape(hubName))\n\tif interactionName == \"\" {\n\t\treturn nil, errors.New(\"parameter interactionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{interactionName}\", url.PathEscape(interactionName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-04-26\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (c *tiKVGroups) Create(tiKVGroup *v1alpha1.TiKVGroup) (result *v1alpha1.TiKVGroup, err error) {\n\tresult = &v1alpha1.TiKVGroup{}\n\terr = c.client.Post().\n\t\tNamespace(c.ns).\n\t\tResource(\"tikvgroups\").\n\t\tBody(tiKVGroup).\n\t\tDo().\n\t\tInto(result)\n\treturn\n}", "func (client *AvailabilityGroupListenersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, sqlVirtualMachineGroupName string, availabilityGroupListenerName string, parameters AvailabilityGroupListener, options *AvailabilityGroupListenersClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sqlVirtualMachineGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter sqlVirtualMachineGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sqlVirtualMachineGroupName}\", url.PathEscape(sqlVirtualMachineGroupName))\n\tif availabilityGroupListenerName == \"\" {\n\t\treturn nil, errors.New(\"parameter availabilityGroupListenerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{availabilityGroupListenerName}\", url.PathEscape(availabilityGroupListenerName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *UserMetricsKeysClient) createOrUpdateCreateRequest(ctx context.Context, options *UserMetricsKeysClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateDescribeMultiContainerGroupMetricRequest() (request *DescribeMultiContainerGroupMetricRequest) {\n\trequest = &DescribeMultiContainerGroupMetricRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Eci\", \"2018-08-08\", \"DescribeMultiContainerGroupMetric\", \"eci\", \"openAPI\")\n\treturn\n}", "func (client *IotSecuritySolutionClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *IotSecuritySolutionClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2019-08-01\")\n\tif options != nil && options.Filter != nil {\n\t\treqQP.Set(\"$filter\", *options.Filter)\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (c *UDBClient) NewUploadUDBParamGroupRequest() *UploadUDBParamGroupRequest {\n\treq := &UploadUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(true)\n\treturn req\n}", "func (client *DevicesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, deviceName string, parameters Device, options *DevicesClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif deviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter deviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{deviceName}\", url.PathEscape(deviceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *ConnectedEnvironmentsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ConnectedEnvironmentsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client IdentityClient) CreateGroup(ctx context.Context, request CreateGroupRequest) (response CreateGroupResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\n\tif !(request.OpcRetryToken != nil && *request.OpcRetryToken != \"\") {\n\t\trequest.OpcRetryToken = common.String(common.RetryToken())\n\t}\n\n\tociResponse, err = common.Retry(ctx, request, client.createGroup, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = CreateGroupResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = CreateGroupResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(CreateGroupResponse); ok {\n\t\tcommon.EcContext.UpdateEndOfWindow(time.Duration(240 * time.Second))\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into CreateGroupResponse\")\n\t}\n\treturn\n}", "func (_BaseContentSpace *BaseContentSpaceTransactor) CreateGroup(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _BaseContentSpace.contract.Transact(opts, \"createGroup\")\n}", "func (client *DiskEncryptionSetsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DiskEncryptionSetsListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClustersListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (_RandomBeacon *RandomBeaconTransactor) UpdateGroupCreationParameters(opts *bind.TransactOpts, groupCreationFrequency *big.Int, groupLifetime *big.Int, dkgResultChallengePeriodLength *big.Int, dkgResultChallengeExtraGas *big.Int, dkgResultSubmissionTimeout *big.Int, dkgSubmitterPrecedencePeriodLength *big.Int) (*types.Transaction, error) {\n\treturn _RandomBeacon.contract.Transact(opts, \"updateGroupCreationParameters\", groupCreationFrequency, groupLifetime, dkgResultChallengePeriodLength, dkgResultChallengeExtraGas, dkgResultSubmissionTimeout, dkgSubmitterPrecedencePeriodLength)\n}", "func (c *UDBClient) NewUpdateUDBParamGroupRequest() *UpdateUDBParamGroupRequest {\n\treq := &UpdateUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(true)\n\treturn req\n}", "func (client *Client) CreateMonitorGroupByResourceGroupId(request *CreateMonitorGroupByResourceGroupIdRequest) (response *CreateMonitorGroupByResourceGroupIdResponse, err error) {\n\tresponse = CreateCreateMonitorGroupByResourceGroupIdResponse()\n\terr = client.DoAction(request, response)\n\treturn\n}", "func (sqlStore *SQLStore) CreateGroup(group *model.Group) error {\n\tgroup.ID = model.NewID()\n\tgroup.CreateAt = GetMillis()\n\n\t_, err := sqlStore.execBuilder(sqlStore.db, sq.\n\t\tInsert(`\"Group\"`).\n\t\tSetMap(map[string]interface{}{\n\t\t\t\"ID\": group.ID,\n\t\t\t\"Name\": group.Name,\n\t\t\t\"Description\": group.Description,\n\t\t\t\"Version\": group.Version,\n\t\t\t\"CreateAt\": group.CreateAt,\n\t\t\t\"DeleteAt\": 0,\n\t\t}),\n\t)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to create group\")\n\t}\n\n\treturn nil\n}", "func (client *ContainerGroupsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ContainerGroupsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (s *GroupsService) Create(\n\tctx context.Context,\n\tgroupName string,\n) error {\n\traw, err := json.Marshal(struct {\n\t\tGroupName string `json:\"group_name\"`\n\t}{\n\t\tgroupName,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treq, err := http.NewRequest(\n\t\thttp.MethodPost,\n\t\ts.client.url+\"2.0/groups/create\",\n\t\tbytes.NewBuffer(raw),\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq = req.WithContext(ctx)\n\tres, err := s.client.client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif res.StatusCode >= 300 || res.StatusCode <= 199 {\n\t\treturn fmt.Errorf(\n\t\t\t\"Failed to returns 2XX response: %d\", res.StatusCode)\n\t}\n\n\treturn nil\n}", "func (client *MetricAlertsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *MetricAlertsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *AssociationsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, associationName string, association Association, options *AssociationsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\tif associationName == \"\" {\n\t\treturn nil, errors.New(\"parameter associationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{associationName}\", url.PathEscape(associationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-09-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, association)\n}", "func (client *MonitoringSettingsClient) updatePutCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, monitoringSettingResource MonitoringSettingResource, options *MonitoringSettingsClientBeginUpdatePutOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, monitoringSettingResource)\n}", "func (client *DefenderSettingsClient) createOrUpdateCreateRequest(ctx context.Context, defenderSettingsModel DefenderSettingsModel, options *DefenderSettingsClientCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.IoTSecurity/defenderSettings/default\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, defenderSettingsModel)\n}", "func (client IdentityClient) createGroup(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodPost, \"/groups\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response CreateGroupResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func handleCreateGroup(c *Context, w http.ResponseWriter, r *http.Request) {\n\tcreateGroupRequest, err := model.NewCreateGroupRequestFromReader(r.Body)\n\tif err != nil {\n\t\tc.Logger.WithError(err).Error(\"failed to decode request\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tgroup := model.Group{\n\t\tName: createGroupRequest.Name,\n\t\tDescription: createGroupRequest.Description,\n\t\tVersion: createGroupRequest.Version,\n\t\tImage: createGroupRequest.Image,\n\t\tMaxRolling: createGroupRequest.MaxRolling,\n\t\tAPISecurityLock: createGroupRequest.APISecurityLock,\n\t\tMattermostEnv: createGroupRequest.MattermostEnv,\n\t}\n\n\tannotations, err := model.AnnotationsFromStringSlice(createGroupRequest.Annotations)\n\tif err != nil {\n\t\tc.Logger.WithError(err).Error(\"invalid annotations\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\terr = c.Store.CreateGroup(&group, annotations)\n\tif err != nil {\n\t\tc.Logger.WithError(err).Error(\"failed to create group\")\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tc.Supervisor.Do()\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\toutputJSON(c, w, group.ToDTO(annotations))\n}", "func (client *ServersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serverName string, parameters Server, options *ServersClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serverName == \"\" {\n\t\treturn nil, errors.New(\"parameter serverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serverName}\", url.PathEscape(serverName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, parameters); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (c *EtcdGroupService) GroupCreate(ctx context.Context, groupName string) error {\n\treturn c.createGroup(ctx, groupName, 0)\n}", "func (_RandomBeacon *RandomBeaconTransactorSession) UpdateGroupCreationParameters(groupCreationFrequency *big.Int, groupLifetime *big.Int, dkgResultChallengePeriodLength *big.Int, dkgResultChallengeExtraGas *big.Int, dkgResultSubmissionTimeout *big.Int, dkgSubmitterPrecedencePeriodLength *big.Int) (*types.Transaction, error) {\n\treturn _RandomBeacon.Contract.UpdateGroupCreationParameters(&_RandomBeacon.TransactOpts, groupCreationFrequency, groupLifetime, dkgResultChallengePeriodLength, dkgResultChallengeExtraGas, dkgResultSubmissionTimeout, dkgSubmitterPrecedencePeriodLength)\n}" ]
[ "0.5988593", "0.5798292", "0.5685915", "0.558678", "0.5551827", "0.5526636", "0.54961526", "0.5459959", "0.54404885", "0.5392508", "0.5279132", "0.5272559", "0.5239537", "0.5215954", "0.5215764", "0.51848537", "0.51664686", "0.5060169", "0.505902", "0.5002327", "0.49339387", "0.49327195", "0.48570153", "0.4852222", "0.48519197", "0.48420623", "0.48413515", "0.48401713", "0.4818292", "0.4815378", "0.4798992", "0.47798774", "0.47621012", "0.47621012", "0.47567642", "0.47543117", "0.47517595", "0.47428077", "0.47325537", "0.47321534", "0.4721099", "0.47121555", "0.47100124", "0.47089314", "0.47050878", "0.4699813", "0.46988317", "0.46870938", "0.46846768", "0.46581635", "0.46429998", "0.4635851", "0.46298972", "0.46210358", "0.46175376", "0.46136954", "0.46030098", "0.45921335", "0.45894906", "0.4583414", "0.4559696", "0.45583516", "0.45466834", "0.45463932", "0.4542331", "0.45413345", "0.4534764", "0.45320785", "0.4529007", "0.452327", "0.45142534", "0.45079163", "0.4502758", "0.4496058", "0.44864586", "0.44811934", "0.44788498", "0.4475255", "0.44750527", "0.44718936", "0.44607985", "0.44366774", "0.44364947", "0.4434716", "0.443427", "0.4423846", "0.44159448", "0.4415907", "0.44154227", "0.4415147", "0.44149703", "0.44135624", "0.4410747", "0.4410395", "0.44079345", "0.44074267", "0.43964246", "0.4379501", "0.4369535", "0.43645966" ]
0.7278163
0
createOrUpdateAtManagementGroupHandleResponse handles the CreateOrUpdateAtManagementGroup response.
createOrUpdateAtManagementGroupHandleResponse обрабатывает ответ CreateOrUpdateAtManagementGroup.
func (client *PolicyDefinitionsClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse, error) { result := PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.PolicyDefinition); err != nil { return PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse{}, runtime.NewResponseError(err, resp) } return result, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *GroupClient) createOrUpdateHandleResponse(resp *http.Response) (GroupCreateOrUpdateResponse, error) {\n\tresult := GroupCreateOrUpdateResponse{RawResponse: resp}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.GroupContract); err != nil {\n\t\treturn GroupCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *SchemaRegistryClient) createOrUpdateHandleResponse(resp *http.Response) (SchemaRegistryClientCreateOrUpdateResponse, error) {\n\tresult := SchemaRegistryClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SchemaGroup); err != nil {\n\t\treturn SchemaRegistryClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func handleCreateGroup(c *Context, w http.ResponseWriter, r *http.Request) {\n\tcreateGroupRequest, err := model.NewCreateGroupRequestFromReader(r.Body)\n\tif err != nil {\n\t\tc.Logger.WithError(err).Error(\"failed to decode request\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tgroup := model.Group{\n\t\tName: createGroupRequest.Name,\n\t\tDescription: createGroupRequest.Description,\n\t\tVersion: createGroupRequest.Version,\n\t\tImage: createGroupRequest.Image,\n\t\tMaxRolling: createGroupRequest.MaxRolling,\n\t\tAPISecurityLock: createGroupRequest.APISecurityLock,\n\t\tMattermostEnv: createGroupRequest.MattermostEnv,\n\t}\n\n\tannotations, err := model.AnnotationsFromStringSlice(createGroupRequest.Annotations)\n\tif err != nil {\n\t\tc.Logger.WithError(err).Error(\"invalid annotations\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\terr = c.Store.CreateGroup(&group, annotations)\n\tif err != nil {\n\t\tc.Logger.WithError(err).Error(\"failed to create group\")\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tc.Supervisor.Do()\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\toutputJSON(c, w, group.ToDTO(annotations))\n}", "func (client *ManagementAssociationsClient) createOrUpdateHandleResponse(resp *http.Response) (ManagementAssociationsCreateOrUpdateResponse, error) {\n\tresult := ManagementAssociationsCreateOrUpdateResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagementAssociation); err != nil {\n\t\treturn ManagementAssociationsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *AvailabilitySetsClient) createOrUpdateHandleResponse(resp *http.Response) (AvailabilitySetsCreateOrUpdateResponse, error) {\n\tresult := AvailabilitySetsCreateOrUpdateResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AvailabilitySet); err != nil {\n\t\treturn AvailabilitySetsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *PolicyDefinitionsClient) getAtManagementGroupHandleResponse(resp *http.Response) (PolicyDefinitionsGetAtManagementGroupResponse, error) {\n\tresult := PolicyDefinitionsGetAtManagementGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PolicyDefinition); err != nil {\n\t\treturn PolicyDefinitionsGetAtManagementGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *PolicyDefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, parameters PolicyDefinition, options *PolicyDefinitionsCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}\"\n\tif policyDefinitionName == \"\" {\n\t\treturn nil, errors.New(\"parameter policyDefinitionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{policyDefinitionName}\", url.PathEscape(policyDefinitionName))\n\tif managementGroupID == \"\" {\n\t\treturn nil, errors.New(\"parameter managementGroupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementGroupId}\", url.PathEscape(managementGroupID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client IotHubResourceClient) CreateEventHubConsumerGroupResponder(resp *http.Response) (result EventHubConsumerGroupInfo, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func CreateCreateMonitorGroupResponse() (response *CreateMonitorGroupResponse) {\n\tresponse = &CreateMonitorGroupResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func CreateCreateMonitorGroupByResourceGroupIdResponse() (response *CreateMonitorGroupByResourceGroupIdResponse) {\n\tresponse = &CreateMonitorGroupByResourceGroupIdResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func CreateModifyDesktopsPolicyGroupResponse() (response *ModifyDesktopsPolicyGroupResponse) {\n\tresponse = &ModifyDesktopsPolicyGroupResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client FirewallPolicyRuleGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result FirewallPolicyRuleGroup, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func CreateUpdateEndpointGroupResponse() (response *UpdateEndpointGroupResponse) {\n\tresponse = &UpdateEndpointGroupResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client *MetricAlertsClient) createOrUpdateHandleResponse(resp *http.Response) (MetricAlertsClientCreateOrUpdateResponse, error) {\n\tresult := MetricAlertsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.MetricAlertResource); err != nil {\n\t\treturn MetricAlertsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func CreateUpdateAppInstanceGroupImageResponse() (response *UpdateAppInstanceGroupImageResponse) {\n\tresponse = &UpdateAppInstanceGroupImageResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (a *IAMApiService) CreateGroup(ctx context.Context, gid string, iamGroupCreate IamGroupCreate) (*http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = http.MethodPut\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/acs/api/v1/groups/{gid}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"gid\"+\"}\", fmt.Sprintf(\"%v\", gid), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{\"application/json\"}\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\t// body params\n\tlocalVarPostBody = &iamGroupCreate\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\t\tif localVarHttpResponse.StatusCode == 0 {\n\t\t\tvar v IamError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarHttpResponse, newErr\n\t\t}\n\t\treturn localVarHttpResponse, newErr\n\t}\n\n\treturn localVarHttpResponse, nil\n}", "func (c GroupClient) CreateOrUpdate(ctx context.Context, resourceGroupName, region string) error {\n\tif _, err := c.client.CreateOrUpdate(ctx, resourceGroupName, resources.Group{\n\t\tLocation: &region,\n\t}); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (client *UserMetricsKeysClient) createOrUpdateHandleResponse(resp *http.Response) (UserMetricsKeysClientCreateOrUpdateResponse, error) {\n\tresult := UserMetricsKeysClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.UserMetricsModel); err != nil {\n\t\treturn UserMetricsKeysClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *HCRPAssignmentsClient) createOrUpdateHandleResponse(resp *http.Response) (HCRPAssignmentsClientCreateOrUpdateResponse, error) {\n\tresult := HCRPAssignmentsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Assignment); err != nil {\n\t\treturn HCRPAssignmentsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ServerVulnerabilityAssessmentClient) createOrUpdateHandleResponse(resp *http.Response) (ServerVulnerabilityAssessmentClientCreateOrUpdateResponse, error) {\n\tresult := ServerVulnerabilityAssessmentClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ServerVulnerabilityAssessment); err != nil {\n\t\treturn ServerVulnerabilityAssessmentClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func CreateCreateApplicationGroupResponse() (response *CreateApplicationGroupResponse) {\n\tresponse = &CreateApplicationGroupResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (c *MockResourceGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, parameters resources.Group) error {\n\tparameters.Name = &resourceGroupName\n\tc.RGs[resourceGroupName] = parameters\n\treturn nil\n}", "func (client WorkloadNetworksClient) CreateVMGroupResponder(resp *http.Response) (result WorkloadNetworkVMGroup, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func CreatePutMetricAlarmResponse() (response *PutMetricAlarmResponse) {\n\tresponse = &PutMetricAlarmResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client *RecordSetsClient) createOrUpdateHandleResponse(resp *azcore.Response) (RecordSetResponse, error) {\n\tvar val *RecordSet\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn RecordSetResponse{}, err\n\t}\n\treturn RecordSetResponse{RawResponse: resp.Response, RecordSet: val}, nil\n}", "func (client *RoleDefinitionsClient) createOrUpdateHandleResponse(resp *http.Response) (RoleDefinitionsCreateOrUpdateResponse, error) {\n\tresult := RoleDefinitionsCreateOrUpdateResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil {\n\t\treturn RoleDefinitionsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *IotSecuritySolutionClient) createOrUpdateHandleResponse(resp *http.Response) (IotSecuritySolutionClientCreateOrUpdateResponse, error) {\n\tresult := IotSecuritySolutionClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.IoTSecuritySolutionModel); err != nil {\n\t\treturn IotSecuritySolutionClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *MonitorsClient) listByResourceGroupHandleResponse(resp *http.Response) (MonitorsClientListByResourceGroupResponse, error) {\n\tresult := MonitorsClientListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.MonitorResourceListResponse); err != nil {\n\t\treturn MonitorsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ActionsClient) createOrUpdateHandleResponse(resp *http.Response) (ActionsClientCreateOrUpdateResponse, error) {\n\tresult := ActionsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ActionResponse); err != nil {\n\t\treturn ActionsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *PolicyDefinitionsClient) listByManagementGroupHandleResponse(resp *http.Response) (PolicyDefinitionsListByManagementGroupResponse, error) {\n\tresult := PolicyDefinitionsListByManagementGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PolicyDefinitionListResult); err != nil {\n\t\treturn PolicyDefinitionsListByManagementGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *CustomAssessmentAutomationsClient) listByResourceGroupHandleResponse(resp *http.Response) (CustomAssessmentAutomationsListByResourceGroupResponse, error) {\n\tresult := CustomAssessmentAutomationsListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.CustomAssessmentAutomationsListResult); err != nil {\n\t\treturn CustomAssessmentAutomationsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (a *HyperflexApiService) UpdateHyperflexInitiatorGroupExecute(r ApiUpdateHyperflexInitiatorGroupRequest) (*HyperflexInitiatorGroup, *http.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = http.MethodPost\n\t\tlocalVarPostBody interface{}\n\t\tformFiles []formFile\n\t\tlocalVarReturnValue *HyperflexInitiatorGroup\n\t)\n\n\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \"HyperflexApiService.UpdateHyperflexInitiatorGroup\")\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/api/v1/hyperflex/InitiatorGroups/{Moid}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"Moid\"+\"}\", url.PathEscape(parameterToString(r.moid, \"\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\tif r.hyperflexInitiatorGroup == nil {\n\t\treturn localVarReturnValue, nil, reportError(\"hyperflexInitiatorGroup is required and must be specified\")\n\t}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{\"application/json\", \"application/json-patch+json\"}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\tif r.ifMatch != nil {\n\t\tlocalVarHeaderParams[\"If-Match\"] = parameterToString(*r.ifMatch, \"\")\n\t}\n\t// body params\n\tlocalVarPostBody = r.hyperflexInitiatorGroup\n\treq, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHTTPResponse, err := a.client.callAPI(req)\n\tif err != nil || localVarHTTPResponse == nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)\n\tlocalVarHTTPResponse.Body.Close()\n\tlocalVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHTTPResponse, err\n\t}\n\n\tif localVarHTTPResponse.StatusCode >= 300 {\n\t\tnewErr := &GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHTTPResponse.Status,\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 400 {\n\t\t\tvar v Error\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 401 {\n\t\t\tvar v Error\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 403 {\n\t\t\tvar v Error\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tif localVarHTTPResponse.StatusCode == 404 {\n\t\t\tvar v Error\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tvar v Error\n\t\terr = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\t\tif err != nil {\n\t\t\tnewErr.error = err.Error()\n\t\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t\t}\n\t\tnewErr.model = v\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get(\"Content-Type\"))\n\tif err != nil {\n\t\tnewErr := &GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: err.Error(),\n\t\t}\n\t\treturn localVarReturnValue, localVarHTTPResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHTTPResponse, nil\n}", "func (client *PolicyDefinitionsClient) createOrUpdateHandleResponse(resp *http.Response) (PolicyDefinitionsCreateOrUpdateResponse, error) {\n\tresult := PolicyDefinitionsCreateOrUpdateResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PolicyDefinition); err != nil {\n\t\treturn PolicyDefinitionsCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *PipelinesClient) createOrUpdateHandleResponse(resp *http.Response) (PipelinesClientCreateOrUpdateResponse, error) {\n\tresult := PipelinesClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PipelineResource); err != nil {\n\t\treturn PipelinesClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func CreateDescribeScalingGroupsResponse() (response *DescribeScalingGroupsResponse) {\n\tresponse = &DescribeScalingGroupsResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client *DefenderSettingsClient) createOrUpdateHandleResponse(resp *http.Response) (DefenderSettingsClientCreateOrUpdateResponse, error) {\n\tresult := DefenderSettingsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DefenderSettingsModel); err != nil {\n\t\treturn DefenderSettingsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *GalleryImageVersionsClient) createOrUpdateHandleResponse(resp *azcore.Response) (GalleryImageVersionResponse, error) {\n\tvar val *GalleryImageVersion\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn GalleryImageVersionResponse{}, err\n\t}\n\treturn GalleryImageVersionResponse{RawResponse: resp.Response, GalleryImageVersion: val}, nil\n}", "func (client *VirtualMachineImageTemplatesClient) listByResourceGroupHandleResponse(resp *http.Response) (VirtualMachineImageTemplatesClientListByResourceGroupResponse, error) {\n\tresult := VirtualMachineImageTemplatesClientListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ImageTemplateListResult); err != nil {\n\t\treturn VirtualMachineImageTemplatesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client IdentityClient) createDynamicGroup(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodPost, \"/dynamicGroups\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response CreateDynamicGroupResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (client *ClientImpl) CreateControlInGroup(ctx context.Context, args CreateControlInGroupArgs) (*Control, error) {\n\tif args.Control == nil {\n\t\treturn nil, &azuredevops.ArgumentNilError{ArgumentName: \"args.Control\"}\n\t}\n\trouteValues := make(map[string]string)\n\tif args.ProcessId == nil {\n\t\treturn nil, &azuredevops.ArgumentNilError{ArgumentName: \"args.ProcessId\"}\n\t}\n\trouteValues[\"processId\"] = (*args.ProcessId).String()\n\tif args.WitRefName == nil || *args.WitRefName == \"\" {\n\t\treturn nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: \"args.WitRefName\"}\n\t}\n\trouteValues[\"witRefName\"] = *args.WitRefName\n\tif args.GroupId == nil || *args.GroupId == \"\" {\n\t\treturn nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: \"args.GroupId\"}\n\t}\n\trouteValues[\"groupId\"] = *args.GroupId\n\n\tbody, marshalErr := json.Marshal(*args.Control)\n\tif marshalErr != nil {\n\t\treturn nil, marshalErr\n\t}\n\tlocationId, _ := uuid.Parse(\"1f59b363-a2d0-4b7e-9bc6-eb9f5f3f0e58\")\n\tresp, err := client.Client.Send(ctx, http.MethodPost, locationId, \"6.0-preview.1\", routeValues, nil, bytes.NewReader(body), \"application/json\", \"application/json\", nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar responseValue Control\n\terr = client.Client.UnmarshalBody(resp, &responseValue)\n\treturn &responseValue, err\n}", "func (client OpenShiftManagedClustersClient) CreateOrUpdateResponder(resp *http.Response) (result v20180930preview.OpenShiftManagedCluster, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tclient.ByInspecting(),\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client *ContainerGroupsClient) listByResourceGroupHandleResponse(resp *http.Response) (ContainerGroupsClientListByResourceGroupResponse, error) {\n\tresult := ContainerGroupsClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroupListResult); err != nil {\n\t\treturn ContainerGroupsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ManagedInstancesClient) listByResourceGroupHandleResponse(resp *http.Response) (ManagedInstancesClientListByResourceGroupResponse, error) {\n\tresult := ManagedInstancesClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedInstanceListResult); err != nil {\n\t\treturn ManagedInstancesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DatasetsClient) createOrUpdateHandleResponse(resp *http.Response) (DatasetsClientCreateOrUpdateResponse, error) {\n\tresult := DatasetsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DatasetResource); err != nil {\n\t\treturn DatasetsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DiskEncryptionSetsClient) listByResourceGroupHandleResponse(resp *http.Response) (DiskEncryptionSetsListByResourceGroupResponse, error) {\n\tresult := DiskEncryptionSetsListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DiskEncryptionSetList); err != nil {\n\t\treturn DiskEncryptionSetsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ContainerGroupsClient) updateHandleResponse(resp *http.Response) (ContainerGroupsClientUpdateResponse, error) {\n\tresult := ContainerGroupsClientUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroup); err != nil {\n\t\treturn ContainerGroupsClientUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (c *Client) CreateGroupResp(ctx context.Context, group *Group) (*http.Response, error) {\n\t// POST /Groups\n\tif group == nil {\n\t\treturn nil, fmt.Errorf(\"group is required\")\n\t}\n\treturn c.getResp(ctx, \"POST\", \"/Groups\", group, nil)\n}", "func (client *LongTermRetentionManagedInstanceBackupsClient) getByResourceGroupHandleResponse(resp *http.Response) (LongTermRetentionManagedInstanceBackupsGetByResourceGroupResponse, error) {\n\tresult := LongTermRetentionManagedInstanceBackupsGetByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedInstanceLongTermRetentionBackup); err != nil {\n\t\treturn LongTermRetentionManagedInstanceBackupsGetByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *WorkspacesClient) listByResourceGroupHandleResponse(resp *http.Response) (WorkspacesListByResourceGroupResponse, error) {\n\tresult := WorkspacesListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceListResult); err != nil {\n\t\treturn WorkspacesListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *MetricAlertsClient) listByResourceGroupHandleResponse(resp *http.Response) (MetricAlertsClientListByResourceGroupResponse, error) {\n\tresult := MetricAlertsClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.MetricAlertResourceCollection); err != nil {\n\t\treturn MetricAlertsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ManagedDatabaseSecurityAlertPoliciesClient) createOrUpdateHandleResponse(resp *http.Response) (ManagedDatabaseSecurityAlertPoliciesClientCreateOrUpdateResponse, error) {\n\tresult := ManagedDatabaseSecurityAlertPoliciesClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedDatabaseSecurityAlertPolicy); err != nil {\n\t\treturn ManagedDatabaseSecurityAlertPoliciesClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) createOrUpdateDomainOwnershipIdentifierSlotHandleResponse(resp *http.Response) (WebAppsCreateOrUpdateDomainOwnershipIdentifierSlotResponse, error) {\n\tresult := WebAppsCreateOrUpdateDomainOwnershipIdentifierSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Identifier); err != nil {\n\t\treturn WebAppsCreateOrUpdateDomainOwnershipIdentifierSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ManagedClustersClient) listByResourceGroupHandleResponse(resp *http.Response) (ManagedClustersClientListByResourceGroupResponse, error) {\n\tresult := ManagedClustersClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedClusterListResult); err != nil {\n\t\treturn ManagedClustersClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) createOrUpdateHostSecretSlotHandleResponse(resp *http.Response) (WebAppsCreateOrUpdateHostSecretSlotResponse, error) {\n\tresult := WebAppsCreateOrUpdateHostSecretSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.KeyInfo); err != nil {\n\t\treturn WebAppsCreateOrUpdateHostSecretSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) createOrUpdateDomainOwnershipIdentifierHandleResponse(resp *http.Response) (WebAppsCreateOrUpdateDomainOwnershipIdentifierResponse, error) {\n\tresult := WebAppsCreateOrUpdateDomainOwnershipIdentifierResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Identifier); err != nil {\n\t\treturn WebAppsCreateOrUpdateDomainOwnershipIdentifierResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func CreateModifySkillGroupExResponse() (response *ModifySkillGroupExResponse) {\n\tresponse = &ModifySkillGroupExResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client *WCFRelaysClient) createOrUpdateAuthorizationRuleHandleResponse(resp *http.Response) (WCFRelaysClientCreateOrUpdateAuthorizationRuleResponse, error) {\n\tresult := WCFRelaysClientCreateOrUpdateAuthorizationRuleResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AuthorizationRule); err != nil {\n\t\treturn WCFRelaysClientCreateOrUpdateAuthorizationRuleResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DedicatedHostsClient) createOrUpdateHandleResponse(resp *azcore.Response) (DedicatedHostResponse, error) {\n\tvar val *DedicatedHost\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn DedicatedHostResponse{}, err\n\t}\n\treturn DedicatedHostResponse{RawResponse: resp.Response, DedicatedHost: val}, nil\n}", "func (client IdentityClient) CreateDynamicGroup(ctx context.Context, request CreateDynamicGroupRequest) (response CreateDynamicGroupResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\n\tif !(request.OpcRetryToken != nil && *request.OpcRetryToken != \"\") {\n\t\trequest.OpcRetryToken = common.String(common.RetryToken())\n\t}\n\n\tociResponse, err = common.Retry(ctx, request, client.createDynamicGroup, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = CreateDynamicGroupResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = CreateDynamicGroupResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(CreateDynamicGroupResponse); ok {\n\t\tcommon.EcContext.UpdateEndOfWindow(time.Duration(240 * time.Second))\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into CreateDynamicGroupResponse\")\n\t}\n\treturn\n}", "func (client *VideosClient) createOrUpdateHandleResponse(resp *http.Response) (VideosClientCreateOrUpdateResponse, error) {\n\tresult := VideosClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VideoEntity); err != nil {\n\t\treturn VideosClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ClustersClient) listByResourceGroupHandleResponse(resp *http.Response) (ClustersListByResourceGroupResponse, error) {\n\tresult := ClustersListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ClusterListResult); err != nil {\n\t\treturn ClustersListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *IPAllocationsClient) listByResourceGroupHandleResponse(resp *http.Response) (IPAllocationsClientListByResourceGroupResponse, error) {\n\tresult := IPAllocationsClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.IPAllocationListResult); err != nil {\n\t\treturn IPAllocationsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ApplyUpdatesClient) createOrUpdateHandleResponse(resp *http.Response) (ApplyUpdatesClientCreateOrUpdateResponse, error) {\n\tresult := ApplyUpdatesClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ApplyUpdate); err != nil {\n\t\treturn ApplyUpdatesClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *SourceControlConfigurationsClient) createOrUpdateHandleResponse(resp *http.Response) (SourceControlConfigurationsClientCreateOrUpdateResponse, error) {\n\tresult := SourceControlConfigurationsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SourceControlConfiguration); err != nil {\n\t\treturn SourceControlConfigurationsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client IdentityClient) CreateGroup(ctx context.Context, request CreateGroupRequest) (response CreateGroupResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\n\tif !(request.OpcRetryToken != nil && *request.OpcRetryToken != \"\") {\n\t\trequest.OpcRetryToken = common.String(common.RetryToken())\n\t}\n\n\tociResponse, err = common.Retry(ctx, request, client.createGroup, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = CreateGroupResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = CreateGroupResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(CreateGroupResponse); ok {\n\t\tcommon.EcContext.UpdateEndOfWindow(time.Duration(240 * time.Second))\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into CreateGroupResponse\")\n\t}\n\treturn\n}", "func (client *RedisClient) listByResourceGroupHandleResponse(resp *http.Response) (RedisListByResourceGroupResponse, error) {\n\tresult := RedisListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RedisListResult); err != nil {\n\t\treturn RedisListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func NewPolicyDefinitionAtManagementGroup(ctx *pulumi.Context,\n\tname string, args *PolicyDefinitionAtManagementGroupArgs, opts ...pulumi.ResourceOption) (*PolicyDefinitionAtManagementGroup, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.ManagementGroupId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'ManagementGroupId'\")\n\t}\n\taliases := pulumi.Aliases([]pulumi.Alias{\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20190101:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20161201:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20161201:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20180301:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20180301:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20180501:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20180501:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20190601:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20190601:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20190901:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20190901:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20200301:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20200301:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20200901:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20200901:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t})\n\topts = append(opts, aliases)\n\tvar resource PolicyDefinitionAtManagementGroup\n\terr := ctx.RegisterResource(\"azure-native:authorization/v20190101:PolicyDefinitionAtManagementGroup\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (client *GroupClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, parameters GroupCreateParameters, options *GroupCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif groupID == \"\" {\n\t\treturn nil, errors.New(\"parameter groupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{groupId}\", url.PathEscape(groupID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Raw().Header.Set(\"If-Match\", *options.IfMatch)\n\t}\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *IotSecuritySolutionClient) listByResourceGroupHandleResponse(resp *http.Response) (IotSecuritySolutionClientListByResourceGroupResponse, error) {\n\tresult := IotSecuritySolutionClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.IoTSecuritySolutionsList); err != nil {\n\t\treturn IotSecuritySolutionClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ConnectedEnvironmentsClient) listByResourceGroupHandleResponse(resp *http.Response) (ConnectedEnvironmentsClientListByResourceGroupResponse, error) {\n\tresult := ConnectedEnvironmentsClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ConnectedEnvironmentCollection); err != nil {\n\t\treturn ConnectedEnvironmentsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *AgentsClient) createOrUpdateHandleResponse(resp *http.Response) (AgentsClientCreateOrUpdateResponse, error) {\n\tresult := AgentsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Agent); err != nil {\n\t\treturn AgentsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func CreateRemoveAppGroupResponse() (response *RemoveAppGroupResponse) {\n\tresponse = &RemoveAppGroupResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client IdentityClient) UpdateDynamicGroup(ctx context.Context, request UpdateDynamicGroupRequest) (response UpdateDynamicGroupResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.updateDynamicGroup, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = UpdateDynamicGroupResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = UpdateDynamicGroupResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(UpdateDynamicGroupResponse); ok {\n\t\tcommon.EcContext.UpdateEndOfWindow(time.Duration(240 * time.Second))\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into UpdateDynamicGroupResponse\")\n\t}\n\treturn\n}", "func (client *AlertProcessingRulesClient) createOrUpdateHandleResponse(resp *http.Response) (AlertProcessingRulesClientCreateOrUpdateResponse, error) {\n\tresult := AlertProcessingRulesClientCreateOrUpdateResponse{RawResponse: resp}\n\tif val := resp.Header.Get(\"x-ms-request-id\"); val != \"\" {\n\t\tresult.XMSRequestID = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AlertProcessingRule); err != nil {\n\t\treturn AlertProcessingRulesClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *CassandraClustersClient) listByResourceGroupHandleResponse(resp *http.Response) (CassandraClustersClientListByResourceGroupResponse, error) {\n\tresult := CassandraClustersClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ListClusters); err != nil {\n\t\treturn CassandraClustersClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *LocalRulestacksClient) listByResourceGroupHandleResponse(resp *http.Response) (LocalRulestacksClientListByResourceGroupResponse, error) {\n\tresult := LocalRulestacksClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.LocalRulestackResourceListResult); err != nil {\n\t\treturn LocalRulestacksClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) createOrUpdateHostSecretHandleResponse(resp *http.Response) (WebAppsCreateOrUpdateHostSecretResponse, error) {\n\tresult := WebAppsCreateOrUpdateHostSecretResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.KeyInfo); err != nil {\n\t\treturn WebAppsCreateOrUpdateHostSecretResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func CreateUserGroup(w http.ResponseWriter, r *http.Request) {\n\tfLog := userMgmtLogger.WithField(\"func\", \"CreateUserGroup\").WithField(\"RequestID\", r.Context().Value(constants.RequestID)).WithField(\"path\", r.URL.Path).WithField(\"method\", r.Method)\n\n\tiauthctx := r.Context().Value(constants.HansipAuthentication)\n\tif iauthctx == nil {\n\t\thelper.WriteHTTPResponse(r.Context(), w, http.StatusUnauthorized, \"You are not authorized to access this resource\", nil, nil)\n\t\treturn\n\t}\n\n\tparams, err := helper.ParsePathParams(fmt.Sprintf(\"%s/management/user/{userRecId}/group/{groupRecId}\", apiPrefix), r.URL.Path)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tgroup, err := GroupRepo.GetGroupByRecID(r.Context(), params[\"groupRecId\"])\n\tif err != nil {\n\t\tfLog.Errorf(\"GroupRepo.GetGroupByRecID got %s\", err.Error())\n\t\thelper.WriteHTTPResponse(r.Context(), w, http.StatusInternalServerError, err.Error(), nil, nil)\n\t\treturn\n\t}\n\tif group == nil {\n\t\thelper.WriteHTTPResponse(r.Context(), w, http.StatusNotFound, fmt.Sprintf(\"Group recid %s not found\", params[\"groupRecId\"]), nil, nil)\n\t\treturn\n\t}\n\n\tauthCtx := iauthctx.(*hansipcontext.AuthenticationContext)\n\tif !authCtx.IsAdminOfDomain(group.GroupDomain) {\n\t\thelper.WriteHTTPResponse(r.Context(), w, http.StatusForbidden, \"You don't have the right to access group with the specified domain\", nil, nil)\n\t\treturn\n\t}\n\n\tuser, err := UserRepo.GetUserByRecID(r.Context(), params[\"userRecId\"])\n\tif err != nil {\n\t\tfLog.Errorf(\"UserRepo.GetUserByRecID got %s\", err.Error())\n\t\thelper.WriteHTTPResponse(r.Context(), w, http.StatusInternalServerError, err.Error(), nil, nil)\n\t\treturn\n\t}\n\tif user == nil {\n\t\thelper.WriteHTTPResponse(r.Context(), w, http.StatusNotFound, fmt.Sprintf(\"User recid %s not found\", params[\"userRecId\"]), nil, nil)\n\t\treturn\n\t}\n\n\t_, err = UserGroupRepo.CreateUserGroup(r.Context(), user, group)\n\tif err != nil {\n\t\tfLog.Errorf(\"UserGroupRepo.CreateUserGroup got %s\", err.Error())\n\t\thelper.WriteHTTPResponse(r.Context(), w, http.StatusBadRequest, err.Error(), nil, nil)\n\t\treturn\n\t}\n\tRevocationRepo.Revoke(r.Context(), user.Email)\n\thelper.WriteHTTPResponse(r.Context(), w, http.StatusOK, \"User-Group created\", nil, nil)\n}", "func (client *ClustersClient) listByResourceGroupHandleResponse(resp *http.Response) (ClustersClientListByResourceGroupResponse, error) {\n\tresult := ClustersClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ClusterListResult); err != nil {\n\t\treturn ClustersClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) listByResourceGroupHandleResponse(resp *http.Response) (WebAppsListByResourceGroupResponse, error) {\n\tresult := WebAppsListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.WebAppCollection); err != nil {\n\t\treturn WebAppsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func CreateModifyHostAvailabilityResponse() (response *ModifyHostAvailabilityResponse) {\n\tresponse = &ModifyHostAvailabilityResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func GroupCreateAppHandler(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\n\tlog.Infoln(\"CreateAppHandler invoked\", r.Method, r.URL.Path, r.RemoteAddr)\n\n\tuserid := vars[\"userid\"]\n\tgroupid := r.URL.Query().Get(\"groupid\")\n\ttaskid := r.URL.Query().Get(\"taskid\")\n\tif taskid == \"\" {\n\t\ttaskid = string(GenrandInt(32))\n\t}\n\n\tif len(groupid) < 1 {\n\t\trespondError(w, http.StatusBadRequest, \"groupid is requried\")\n\t\treturn\n\t}\n\n\tdefer r.Body.Close()\n\tb, _ := ioutil.ReadAll(r.Body)\n\n\tlog.Debugln(string(b))\n\tvar js map[string]interface{}\n\n\terr := CheckPodcfg(b, false)\n\tif err != nil {\n\t\trespondError(w, http.StatusBadRequest, \"Input Error: \"+err.Error())\n\t\treturn\n\t}\n\tb, err = jsonparser.Set(b, []byte(`\"IfNotPresent\"`), \"spec\", \"containers\", \"[0]\", \"imagePullPolicy\")\n\tif err != nil {\n\t\trespondError(w, http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\n\tcontainerimage, err := jsonparser.GetString(b, \"spec\", \"containers\", \"[0]\", \"image\")\n\tregistryL := strings.Split(strings.Split(containerimage, `:`)[0], `/`)\n\t//basename := registryL[len(registryL)-1] + fmt.Sprintf(\"-%d\", rand.Int(20))\n\tbasename := registryL[len(registryL)-1]\n\n\tb, err = jsonparser.Set(b, []byte(fmt.Sprintf(`\"%s\"`, basename)), \"metadata\", \"name\")\n\tif err != nil {\n\t\trespondError(w, http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\n\tb, err = jsonparser.Set(b, []byte(fmt.Sprintf(`\"%s\"`, basename)), \"spec\", \"containers\", \"[0]\", \"name\")\n\tif err != nil {\n\t\trespondError(w, http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\n\tif err = json.Unmarshal(b, &js); err != nil {\n\t\trespondError(w, http.StatusInternalServerError, \"Unexpect Error: \"+string(b))\n\t\treturn\n\t}\n\n\tb = jsonparser.Delete(b, \"spec\", \"nodeSelector\")\n\tcfg := jsonparser.Delete(b, \"spec\", \"imagePullSecrets\")\n\tlog.Debugln(string(cfg))\n\n\tT := TaskInfo{\n\t\tID: taskid,\n\t\tCurrent: 0,\n\t\tUserid: userid,\n\t\tGroupid: groupid,\n\t\tAppcfg: string(cfg),\n\t}\n\n\terr = DBGroupInQueue(T)\n\tif err != nil {\n\t\trespondError(w, http.StatusInternalServerError, \"Unexpect Error: \"+err.Error())\n\t}\n\trespondJSON(w, http.StatusOK,\n\t\tmap[string]interface{}{\"code\": 0, \"id\": T.ID})\n}", "func (client *ServersClient) listByResourceGroupHandleResponse(resp *http.Response) (ServersClientListByResourceGroupResponse, error) {\n\tresult := ServersClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ServerListResult); err != nil {\n\t\treturn ServersClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ApplyUpdatesClient) createOrUpdateParentHandleResponse(resp *http.Response) (ApplyUpdatesClientCreateOrUpdateParentResponse, error) {\n\tresult := ApplyUpdatesClientCreateOrUpdateParentResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ApplyUpdate); err != nil {\n\t\treturn ApplyUpdatesClientCreateOrUpdateParentResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *AccountsClient) listByResourceGroupHandleResponse(resp *http.Response) (AccountsClientListByResourceGroupResponse, error) {\n\tresult := AccountsClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AccountListResult); err != nil {\n\t\treturn AccountsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ServersClient) listByResourceGroupHandleResponse(resp *http.Response) (ServersClientListByResourceGroupResponse, error) {\n\tresult := ServersClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ServerList); err != nil {\n\t\treturn ServersClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *SpatialAnchorsAccountsClient) listByResourceGroupHandleResponse(resp *http.Response) (SpatialAnchorsAccountsClientListByResourceGroupResponse, error) {\n\tresult := SpatialAnchorsAccountsClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SpatialAnchorsAccountPage); err != nil {\n\t\treturn SpatialAnchorsAccountsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *GroupClient) updateHandleResponse(resp *http.Response) (GroupUpdateResponse, error) {\n\tresult := GroupUpdateResponse{RawResponse: resp}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.GroupContract); err != nil {\n\t\treturn GroupUpdateResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *VirtualMachinesClient) listByResourceGroupHandleResponse(resp *http.Response) (VirtualMachinesClientListByResourceGroupResponse, error) {\n\tresult := VirtualMachinesClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachinesList); err != nil {\n\t\treturn VirtualMachinesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *Client) CreateOrUpdateAssetGroupWithOptions(request *CreateOrUpdateAssetGroupRequest, runtime *util.RuntimeOptions) (_result *CreateOrUpdateAssetGroupResponse, _err error) {\n\t_err = util.ValidateModel(request)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\tquery := map[string]interface{}{}\n\tif !tea.BoolValue(util.IsUnset(request.GroupId)) {\n\t\tquery[\"GroupId\"] = request.GroupId\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.GroupName)) {\n\t\tquery[\"GroupName\"] = request.GroupName\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.Uuids)) {\n\t\tquery[\"Uuids\"] = request.Uuids\n\t}\n\n\treq := &openapi.OpenApiRequest{\n\t\tQuery: openapiutil.Query(query),\n\t}\n\tparams := &openapi.Params{\n\t\tAction: tea.String(\"CreateOrUpdateAssetGroup\"),\n\t\tVersion: tea.String(\"2018-12-03\"),\n\t\tProtocol: tea.String(\"HTTPS\"),\n\t\tPathname: tea.String(\"/\"),\n\t\tMethod: tea.String(\"POST\"),\n\t\tAuthType: tea.String(\"AK\"),\n\t\tStyle: tea.String(\"RPC\"),\n\t\tReqBodyType: tea.String(\"formData\"),\n\t\tBodyType: tea.String(\"json\"),\n\t}\n\t_result = &CreateOrUpdateAssetGroupResponse{}\n\t_body, _err := client.CallApi(params, req, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_err = tea.Convert(_body, &_result)\n\treturn _result, _err\n}", "func (client *DataCollectionEndpointsClient) listByResourceGroupHandleResponse(resp *http.Response) (DataCollectionEndpointsListByResourceGroupResponse, error) {\n\tresult := DataCollectionEndpointsListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DataCollectionEndpointResourceListResult); err != nil {\n\t\treturn DataCollectionEndpointsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ServersClient) createOrUpdateHandleResponse(resp *http.Response) (ServersClientCreateOrUpdateResponse, error) {\n\tresult := ServersClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Server); err != nil {\n\t\treturn ServersClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DataCollectionEndpointsClient) listByResourceGroupHandleResponse(resp *http.Response) (DataCollectionEndpointsClientListByResourceGroupResponse, error) {\n\tresult := DataCollectionEndpointsClientListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DataCollectionEndpointResourceListResult); err != nil {\n\t\treturn DataCollectionEndpointsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client IdentityClient) createGroup(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodPost, \"/groups\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response CreateGroupResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (client *CapacitiesClient) listByResourceGroupHandleResponse(resp *http.Response) (CapacitiesClientListByResourceGroupResponse, error) {\n\tresult := CapacitiesClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DedicatedCapacities); err != nil {\n\t\treturn CapacitiesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (mg *Groups) Create(group *Group) error {\n\n\tif mg.group != nil && len(group.ID) > 0 {\n\n\t\tpath := fmt.Sprintf(\"%s%s\", marathon.APIGroups, utilities.DelInitialSlash(group.ID))\n\n\t\tif _, err := mg.client.Session.BodyAsJSON(group).Post(path, mg.deploy, mg.fail); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmg.group = group\n\t\treturn nil\n\t}\n\treturn errors.New(\"group cannot be null nor empty\")\n}", "func (client *SQLVirtualMachinesClient) listByResourceGroupHandleResponse(resp *http.Response) (SQLVirtualMachinesClientListByResourceGroupResponse, error) {\n\tresult := SQLVirtualMachinesClientListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ListResult); err != nil {\n\t\treturn SQLVirtualMachinesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ConfigurationProfilesVersionsClient) createOrUpdateHandleResponse(resp *http.Response) (ConfigurationProfilesVersionsClientCreateOrUpdateResponse, error) {\n\tresult := ConfigurationProfilesVersionsClientCreateOrUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ConfigurationProfile); err != nil {\n\t\treturn ConfigurationProfilesVersionsClientCreateOrUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client WorkloadNetworksClient) UpdateVMGroupResponder(resp *http.Response) (result WorkloadNetworkVMGroup, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func CreateDescribeContainerGroupMetricResponse() (response *DescribeContainerGroupMetricResponse) {\n\tresponse = &DescribeContainerGroupMetricResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}" ]
[ "0.64995533", "0.6087047", "0.59565717", "0.577954", "0.5716804", "0.56633455", "0.5627714", "0.5607213", "0.55736977", "0.55376047", "0.5450639", "0.5443918", "0.532295", "0.52404857", "0.5232235", "0.52103275", "0.5207438", "0.5142607", "0.51312053", "0.5121249", "0.5118213", "0.5115343", "0.51078653", "0.5090818", "0.50841004", "0.50643474", "0.5059899", "0.5058732", "0.50565803", "0.5049206", "0.5016078", "0.501564", "0.5000634", "0.49947518", "0.49925056", "0.4988056", "0.4973801", "0.49694273", "0.49693176", "0.4960507", "0.495183", "0.49511233", "0.49451002", "0.49436527", "0.49384502", "0.4937776", "0.49281156", "0.492194", "0.4916605", "0.49024308", "0.48989365", "0.48889005", "0.48829654", "0.48756486", "0.48692057", "0.48423585", "0.4833977", "0.4833636", "0.48335296", "0.48248693", "0.4820857", "0.4815654", "0.481383", "0.4801977", "0.47981524", "0.47958082", "0.47881398", "0.47864708", "0.47858536", "0.47797567", "0.47783545", "0.47780067", "0.47736576", "0.47677547", "0.4764846", "0.4759437", "0.47556394", "0.47544822", "0.47538254", "0.47428885", "0.4741987", "0.47409332", "0.47322997", "0.47197413", "0.47164053", "0.47131947", "0.47047573", "0.4702847", "0.4692138", "0.46750832", "0.4670615", "0.46699104", "0.4667614", "0.4666687", "0.4664136", "0.4663989", "0.46580124", "0.46571338", "0.46555927", "0.4647787" ]
0.7587764
0
deleteCreateRequest creates the Delete request.
deleteCreateRequest создает запрос на удаление.
func (client *PolicyDefinitionsClient) deleteCreateRequest(ctx context.Context, policyDefinitionName string, options *PolicyDefinitionsDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" if policyDefinitionName == "" { return nil, errors.New("parameter policyDefinitionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *FactoriesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, factoryName string, options *FactoriesClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif factoryName == \"\" {\n\t\treturn nil, errors.New(\"parameter factoryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{factoryName}\", url.PathEscape(factoryName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (connection *Connection) CreateDeleteRequest(fnr Fnr) (*DeleteRequest, error) {\n\treturn NewDeleteRequestAdabas(connection.adabasToData, fnr), nil\n}", "func (client *CloudServicesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, cloudServiceName string, options *CloudServicesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif cloudServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter cloudServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{cloudServiceName}\", url.PathEscape(cloudServiceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-09-04\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *subscriptionClient) deleteCreateRequest(ctx context.Context, topicName string, subscriptionName string, options *SubscriptionDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/{topicName}/subscriptions/{subscriptionName}\"\n\tif topicName == \"\" {\n\t\treturn nil, errors.New(\"parameter topicName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{topicName}\", url.PathEscape(topicName))\n\tif subscriptionName == \"\" {\n\t\treturn nil, errors.New(\"parameter subscriptionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionName}\", url.PathEscape(subscriptionName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif client.apiVersion != nil {\n\t\treqQP.Set(\"api-version\", \"2017_04\")\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/xml, application/atom+xml\")\n\treturn req, nil\n}", "func (client *CertificateOrdersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, options *CertificateOrdersClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif certificateOrderName == \"\" {\n\t\treturn nil, errors.New(\"parameter certificateOrderName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{certificateOrderName}\", url.PathEscape(certificateOrderName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-09-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *RegistrationDefinitionsClient) deleteCreateRequest(ctx context.Context, registrationDefinitionID string, scope string, options *RegistrationDefinitionsClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}\"\n\tif registrationDefinitionID == \"\" {\n\t\treturn nil, errors.New(\"parameter registrationDefinitionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{registrationDefinitionId}\", url.PathEscape(registrationDefinitionID))\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *AssociationsClient) deleteCreateRequest(ctx context.Context, scope string, associationName string, options *AssociationsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\tif associationName == \"\" {\n\t\treturn nil, errors.New(\"parameter associationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{associationName}\", url.PathEscape(associationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-09-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *DevicesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, deviceName string, options *DevicesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif deviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter deviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{deviceName}\", url.PathEscape(deviceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ClustersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-11-08\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *UserMetricsKeysClient) deleteCreateRequest(ctx context.Context, options *UserMetricsKeysClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *RoleDefinitionsClient) deleteCreateRequest(ctx context.Context, scope string, roleDefinitionID string, options *RoleDefinitionsDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\tif roleDefinitionID == \"\" {\n\t\treturn nil, errors.New(\"parameter roleDefinitionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{roleDefinitionId}\", url.PathEscape(roleDefinitionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ServersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serverName == \"\" {\n\t\treturn nil, errors.New(\"parameter serverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serverName}\", url.PathEscape(serverName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *ManagedClustersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *ManagedClustersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(resourceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *WorkspacesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *CassandraClustersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *CassandraClustersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-03-15-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ManagedInstancesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, managedInstanceName string, options *ManagedInstancesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif managedInstanceName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedInstanceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedInstanceName}\", url.PathEscape(managedInstanceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *DicomServicesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dicomServiceName string, workspaceName string, options *DicomServicesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/dicomservices/{dicomServiceName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif dicomServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter dicomServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{dicomServiceName}\", url.PathEscape(dicomServiceName))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *DefenderSettingsClient) deleteCreateRequest(ctx context.Context, options *DefenderSettingsClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.IoTSecurity/defenderSettings/default\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *SQLVirtualMachinesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, sqlVirtualMachineName string, options *SQLVirtualMachinesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sqlVirtualMachineName == \"\" {\n\t\treturn nil, errors.New(\"parameter sqlVirtualMachineName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sqlVirtualMachineName}\", url.PathEscape(sqlVirtualMachineName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-03-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *RouteTablesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, routeTableName string, options *RouteTablesBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif routeTableName == \"\" {\n\t\treturn nil, errors.New(\"parameter routeTableName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{routeTableName}\", url.PathEscape(routeTableName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *DatasetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, factoryName string, datasetName string, options *DatasetsClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/datasets/{datasetName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif factoryName == \"\" {\n\t\treturn nil, errors.New(\"parameter factoryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{factoryName}\", url.PathEscape(factoryName))\n\tif datasetName == \"\" {\n\t\treturn nil, errors.New(\"parameter datasetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{datasetName}\", url.PathEscape(datasetName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *IPAllocationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, ipAllocationName string, options *IPAllocationsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/IpAllocations/{ipAllocationName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif ipAllocationName == \"\" {\n\t\treturn nil, errors.New(\"parameter ipAllocationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ipAllocationName}\", url.PathEscape(ipAllocationName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ContainerClient) deleteCreateRequest(ctx context.Context, options *ContainerClientDeleteOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (*policy.Request, error) {\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, client.endpoint)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"restype\", \"container\")\n\tif options != nil && options.Timeout != nil {\n\t\treqQP.Set(\"timeout\", strconv.FormatInt(int64(*options.Timeout), 10))\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil {\n\t\treq.Raw().Header[\"x-ms-lease-id\"] = []string{*leaseAccessConditions.LeaseID}\n\t}\n\tif modifiedAccessConditions != nil && modifiedAccessConditions.IfModifiedSince != nil {\n\t\treq.Raw().Header[\"If-Modified-Since\"] = []string{(*modifiedAccessConditions.IfModifiedSince).In(gmt).Format(time.RFC1123)}\n\t}\n\tif modifiedAccessConditions != nil && modifiedAccessConditions.IfUnmodifiedSince != nil {\n\t\treq.Raw().Header[\"If-Unmodified-Since\"] = []string{(*modifiedAccessConditions.IfUnmodifiedSince).In(gmt).Format(time.RFC1123)}\n\t}\n\treq.Raw().Header[\"x-ms-version\"] = []string{\"2020-10-02\"}\n\tif options != nil && options.RequestID != nil {\n\t\treq.Raw().Header[\"x-ms-client-request-id\"] = []string{*options.RequestID}\n\t}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/xml\"}\n\treturn req, nil\n}", "func (client *ManagedDatabasesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, options *ManagedDatabasesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif managedInstanceName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedInstanceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedInstanceName}\", url.PathEscape(managedInstanceName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *PipelinesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, factoryName string, pipelineName string, options *PipelinesClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/pipelines/{pipelineName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif factoryName == \"\" {\n\t\treturn nil, errors.New(\"parameter factoryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{factoryName}\", url.PathEscape(factoryName))\n\tif pipelineName == \"\" {\n\t\treturn nil, errors.New(\"parameter pipelineName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{pipelineName}\", url.PathEscape(pipelineName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *AccountsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif accountName == \"\" {\n\t\treturn nil, errors.New(\"parameter accountName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{accountName}\", url.PathEscape(accountName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ContainerGroupsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif containerGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter containerGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{containerGroupName}\", url.PathEscape(containerGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *GroupClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string, options *GroupDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif groupID == \"\" {\n\t\treturn nil, errors.New(\"parameter groupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{groupId}\", url.PathEscape(groupID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"If-Match\", ifMatch)\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *DedicatedHostsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string, options *DedicatedHostsBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif hostGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter hostGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hostGroupName}\", url.PathEscape(hostGroupName))\n\tif hostName == \"\" {\n\t\treturn nil, errors.New(\"parameter hostName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hostName}\", url.PathEscape(hostName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *ClustersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *DedicatedHostsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string, options *DedicatedHostsBeginDeleteOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{hostGroupName}\", url.PathEscape(hostGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{hostName}\", url.PathEscape(hostName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-06-01\")\n\treq.URL.RawQuery = query.Encode()\n\treturn req, nil\n}", "func (client *KeyVaultClient) deleteKeyCreateRequest(ctx context.Context, vaultBaseURL string, keyName string, options *KeyVaultClientDeleteKeyOptions) (*policy.Request, error) {\n\thost := \"{vaultBaseUrl}\"\n\thost = strings.ReplaceAll(host, \"{vaultBaseUrl}\", vaultBaseURL)\n\turlPath := \"/keys/{key-name}\"\n\tif keyName == \"\" {\n\t\treturn nil, errors.New(\"parameter keyName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{key-name}\", url.PathEscape(keyName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"7.3\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *KeyVaultClient) deleteKeyCreateRequest(ctx context.Context, vaultBaseURL string, keyName string, options *KeyVaultClientDeleteKeyOptions) (*policy.Request, error) {\n\thost := \"{vaultBaseUrl}\"\n\thost = strings.ReplaceAll(host, \"{vaultBaseUrl}\", vaultBaseURL)\n\turlPath := \"/keys/{key-name}\"\n\tif keyName == \"\" {\n\t\treturn nil, errors.New(\"parameter keyName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{key-name}\", url.PathEscape(keyName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"7.2\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *MonitorsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif monitorName == \"\" {\n\t\treturn nil, errors.New(\"parameter monitorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{monitorName}\", url.PathEscape(monitorName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *IotSecuritySolutionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, solutionName string, options *IotSecuritySolutionClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif solutionName == \"\" {\n\t\treturn nil, errors.New(\"parameter solutionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{solutionName}\", url.PathEscape(solutionName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2019-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *APIClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, options *APIClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif apiID == \"\" {\n\t\treturn nil, errors.New(\"parameter apiID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{apiId}\", url.PathEscape(apiID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.DeleteRevisions != nil {\n\t\treqQP.Set(\"deleteRevisions\", strconv.FormatBool(*options.DeleteRevisions))\n\t}\n\treqQP.Set(\"api-version\", \"2022-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"If-Match\"] = []string{ifMatch}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ReplicationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, replicationName string, options *ReplicationsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif registryName == \"\" {\n\t\treturn nil, errors.New(\"parameter registryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{registryName}\", url.PathEscape(registryName))\n\tif replicationName == \"\" {\n\t\treturn nil, errors.New(\"parameter replicationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{replicationName}\", url.PathEscape(replicationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *FirewallRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesBeginDeleteOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/firewallRules/{firewallRuleName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serverName == \"\" {\n\t\treturn nil, errors.New(\"parameter serverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serverName}\", url.PathEscape(serverName))\n\tif firewallRuleName == \"\" {\n\t\treturn nil, errors.New(\"parameter firewallRuleName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{firewallRuleName}\", url.PathEscape(firewallRuleName))\n\treq, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\treqQP := req.URL.Query()\n\treqQP.Set(\"api-version\", \"2017-12-01\")\n\treq.URL.RawQuery = reqQP.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *IntegrationRuntimeNodesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, factoryName string, integrationRuntimeName string, nodeName string, options *IntegrationRuntimeNodesClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif factoryName == \"\" {\n\t\treturn nil, errors.New(\"parameter factoryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{factoryName}\", url.PathEscape(factoryName))\n\tif integrationRuntimeName == \"\" {\n\t\treturn nil, errors.New(\"parameter integrationRuntimeName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{integrationRuntimeName}\", url.PathEscape(integrationRuntimeName))\n\tif nodeName == \"\" {\n\t\treturn nil, errors.New(\"parameter nodeName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{nodeName}\", url.PathEscape(nodeName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *DiskEncryptionSetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, diskEncryptionSetName string, options *DiskEncryptionSetsBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif diskEncryptionSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter diskEncryptionSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{diskEncryptionSetName}\", url.PathEscape(diskEncryptionSetName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *CapacityReservationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, capacityReservationGroupName string, capacityReservationName string, options *CapacityReservationsBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif capacityReservationGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter capacityReservationGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{capacityReservationGroupName}\", url.PathEscape(capacityReservationGroupName))\n\tif capacityReservationName == \"\" {\n\t\treturn nil, errors.New(\"parameter capacityReservationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{capacityReservationName}\", url.PathEscape(capacityReservationName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *SyncGroupsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, options *SyncGroupsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serverName == \"\" {\n\t\treturn nil, errors.New(\"parameter serverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serverName}\", url.PathEscape(serverName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif syncGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter syncGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{syncGroupName}\", url.PathEscape(syncGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func CreateDeleteApDeviceRequest() (request *DeleteApDeviceRequest) {\n\trequest = &DeleteApDeviceRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"cloudesl\", \"2020-02-01\", \"DeleteApDevice\", \"\", \"\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *WebhooksClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif registryName == \"\" {\n\t\treturn nil, errors.New(\"parameter registryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{registryName}\", url.PathEscape(registryName))\n\tif webhookName == \"\" {\n\t\treturn nil, errors.New(\"parameter webhookName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{webhookName}\", url.PathEscape(webhookName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2019-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *PrivateDNSZoneGroupsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateEndpointName string, privateDNSZoneGroupName string, options *PrivateDNSZoneGroupsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateEndpoints/{privateEndpointName}/privateDnsZoneGroups/{privateDnsZoneGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateEndpointName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateEndpointName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateEndpointName}\", url.PathEscape(privateEndpointName))\n\tif privateDNSZoneGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateDNSZoneGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateDnsZoneGroupName}\", url.PathEscape(privateDNSZoneGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ConnectedEnvironmentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, connectedEnvironmentName string, options *ConnectedEnvironmentsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif connectedEnvironmentName == \"\" {\n\t\treturn nil, errors.New(\"parameter connectedEnvironmentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{connectedEnvironmentName}\", url.PathEscape(connectedEnvironmentName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *AlertProcessingRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, options *AlertProcessingRulesClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif alertProcessingRuleName == \"\" {\n\t\treturn nil, errors.New(\"parameter alertProcessingRuleName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{alertProcessingRuleName}\", url.PathEscape(alertProcessingRuleName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-08\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *CapacitiesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dedicatedCapacityName string, options *CapacitiesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif dedicatedCapacityName == \"\" {\n\t\treturn nil, errors.New(\"parameter dedicatedCapacityName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{dedicatedCapacityName}\", url.PathEscape(dedicatedCapacityName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-01-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *DatasetClient) deleteDatasetCreateRequest(ctx context.Context, datasetName string, options *DatasetBeginDeleteDatasetOptions) (*azcore.Request, error) {\n\turlPath := \"/datasets/{datasetName}\"\n\tif datasetName == \"\" {\n\t\treturn nil, errors.New(\"parameter datasetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{datasetName}\", url.PathEscape(datasetName))\n\treq, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\treqQP := req.URL.Query()\n\treqQP.Set(\"api-version\", \"2019-06-01-preview\")\n\treq.URL.RawQuery = reqQP.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *NetworkToNetworkInterconnectsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, networkFabricName string, networkToNetworkInterconnectName string, options *NetworkToNetworkInterconnectsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetworkFabric/networkFabrics/{networkFabricName}/networkToNetworkInterconnects/{networkToNetworkInterconnectName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif networkFabricName == \"\" {\n\t\treturn nil, errors.New(\"parameter networkFabricName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{networkFabricName}\", url.PathEscape(networkFabricName))\n\tif networkToNetworkInterconnectName == \"\" {\n\t\treturn nil, errors.New(\"parameter networkToNetworkInterconnectName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{networkToNetworkInterconnectName}\", url.PathEscape(networkToNetworkInterconnectName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-06-15\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *IscsiTargetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, diskPoolName string, iscsiTargetName string, options *IscsiTargetsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StoragePool/diskPools/{diskPoolName}/iscsiTargets/{iscsiTargetName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif diskPoolName == \"\" {\n\t\treturn nil, errors.New(\"parameter diskPoolName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{diskPoolName}\", url.PathEscape(diskPoolName))\n\tif iscsiTargetName == \"\" {\n\t\treturn nil, errors.New(\"parameter iscsiTargetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{iscsiTargetName}\", url.PathEscape(iscsiTargetName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *AgentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, agentName string, options *AgentsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/agents/{agentName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif storageMoverName == \"\" {\n\t\treturn nil, errors.New(\"parameter storageMoverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{storageMoverName}\", url.PathEscape(storageMoverName))\n\tif agentName == \"\" {\n\t\treturn nil, errors.New(\"parameter agentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{agentName}\", url.PathEscape(agentName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-07-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *RoleAssignmentsClient) deleteCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, options *RoleAssignmentsDeleteOptions) (*policy.Request, error) {\n\thost := \"{vaultBaseUrl}\"\n\thost = strings.ReplaceAll(host, \"{vaultBaseUrl}\", vaultBaseURL)\n\turlPath := \"/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}\"\n\tif scope == \"\" {\n\t\treturn nil, errors.New(\"parameter scope cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\tif roleAssignmentName == \"\" {\n\t\treturn nil, errors.New(\"parameter roleAssignmentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{roleAssignmentName}\", url.PathEscape(roleAssignmentName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"7.3-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ServersClient) deleteCreateRequest(ctx context.Context, resourceGroup string, fluidRelayServerName string, options *ServersClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.FluidRelay/fluidRelayServers/{fluidRelayServerName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroup == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroup cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroup}\", url.PathEscape(resourceGroup))\n\tif fluidRelayServerName == \"\" {\n\t\treturn nil, errors.New(\"parameter fluidRelayServerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{fluidRelayServerName}\", url.PathEscape(fluidRelayServerName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *VirtualNetworkTapsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, tapName string, options *VirtualNetworkTapsBeginDeleteOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkTaps/{tapName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{tapName}\", url.PathEscape(tapName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-07-01\")\n\treq.URL.RawQuery = query.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *SubscriptionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, ifMatch string, options *SubscriptionClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif sid == \"\" {\n\t\treturn nil, errors.New(\"parameter sid cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sid}\", url.PathEscape(sid))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"If-Match\"] = []string{ifMatch}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *WebAppsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, name string, options *WebAppsDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.DeleteMetrics != nil {\n\t\treqQP.Set(\"deleteMetrics\", strconv.FormatBool(*options.DeleteMetrics))\n\t}\n\tif options != nil && options.DeleteEmptyServerFarm != nil {\n\t\treqQP.Set(\"deleteEmptyServerFarm\", strconv.FormatBool(*options.DeleteEmptyServerFarm))\n\t}\n\treqQP.Set(\"api-version\", \"2021-02-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *GuestAgentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, name string, options *GuestAgentsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif virtualMachineName == \"\" {\n\t\treturn nil, errors.New(\"parameter virtualMachineName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{virtualMachineName}\", url.PathEscape(virtualMachineName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-10-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ActionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, ruleID string, actionID string, options *ActionsClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/alertRules/{ruleId}/actions/{actionId}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif ruleID == \"\" {\n\t\treturn nil, errors.New(\"parameter ruleID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ruleId}\", url.PathEscape(ruleID))\n\tif actionID == \"\" {\n\t\treturn nil, errors.New(\"parameter actionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{actionId}\", url.PathEscape(actionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-10-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *AvailabilitySetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetName string, options *AvailabilitySetsDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif availabilitySetName == \"\" {\n\t\treturn nil, errors.New(\"parameter availabilitySetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{availabilitySetName}\", url.PathEscape(availabilitySetName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *VirtualMachineImageTemplatesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, imageTemplateName string, options *VirtualMachineImageTemplatesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif imageTemplateName == \"\" {\n\t\treturn nil, errors.New(\"parameter imageTemplateName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{imageTemplateName}\", url.PathEscape(imageTemplateName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-10-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *TagRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/monitors/{monitorName}/tagRules/{ruleSetName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif monitorName == \"\" {\n\t\treturn nil, errors.New(\"parameter monitorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{monitorName}\", url.PathEscape(monitorName))\n\tif ruleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter ruleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ruleSetName}\", url.PathEscape(ruleSetName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-27\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *VirtualNetworkLinksClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateZoneName string, virtualNetworkLinkName string, options *VirtualNetworkLinksBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateDnsZones/{privateZoneName}/virtualNetworkLinks/{virtualNetworkLinkName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateZoneName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateZoneName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateZoneName}\", url.PathEscape(privateZoneName))\n\tif virtualNetworkLinkName == \"\" {\n\t\treturn nil, errors.New(\"parameter virtualNetworkLinkName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{virtualNetworkLinkName}\", url.PathEscape(virtualNetworkLinkName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Raw().Header.Set(\"If-Match\", *options.IfMatch)\n\t}\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *VirtualApplianceSitesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, networkVirtualApplianceName string, siteName string, options *VirtualApplianceSitesBeginDeleteOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkVirtualAppliances/{networkVirtualApplianceName}/virtualApplianceSites/{siteName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{networkVirtualApplianceName}\", url.PathEscape(networkVirtualApplianceName))\n\turlPath = strings.ReplaceAll(urlPath, \"{siteName}\", url.PathEscape(siteName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-07-01\")\n\treq.URL.RawQuery = query.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *IncidentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, incidentID string, options *IncidentsClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/incidents/{incidentId}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif incidentID == \"\" {\n\t\treturn nil, errors.New(\"parameter incidentID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{incidentId}\", url.PathEscape(incidentID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-05-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ReplicationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, replicationName string, options *ReplicationsBeginDeleteOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif registryName == \"\" {\n\t\treturn nil, errors.New(\"parameter registryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{registryName}\", url.PathEscape(registryName))\n\tif replicationName == \"\" {\n\t\treturn nil, errors.New(\"parameter replicationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{replicationName}\", url.PathEscape(replicationName))\n\treq, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\treqQP := req.URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01-preview\")\n\treq.URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *ReplicationvCentersClient) deleteCreateRequest(ctx context.Context, fabricName string, vcenterName string, options *ReplicationvCentersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationvCenters/{vcenterName}\"\n\tif client.resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter client.resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(client.resourceName))\n\tif client.resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter client.resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(client.resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif fabricName == \"\" {\n\t\treturn nil, errors.New(\"parameter fabricName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{fabricName}\", url.PathEscape(fabricName))\n\tif vcenterName == \"\" {\n\t\treturn nil, errors.New(\"parameter vcenterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vcenterName}\", url.PathEscape(vcenterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-11-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *NotebookWorkspacesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, notebookWorkspaceName NotebookWorkspaceName, options *NotebookWorkspacesBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif accountName == \"\" {\n\t\treturn nil, errors.New(\"parameter accountName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{accountName}\", url.PathEscape(accountName))\n\tif notebookWorkspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter notebookWorkspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{notebookWorkspaceName}\", url.PathEscape(string(notebookWorkspaceName)))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-10-15\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *VirtualMachinesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif virtualMachineName == \"\" {\n\t\treturn nil, errors.New(\"parameter virtualMachineName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{virtualMachineName}\", url.PathEscape(virtualMachineName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-10-preview\")\n\tif options != nil && options.Force != nil {\n\t\treqQP.Set(\"force\", strconv.FormatBool(*options.Force))\n\t}\n\tif options != nil && options.Retain != nil {\n\t\treqQP.Set(\"retain\", strconv.FormatBool(*options.Retain))\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *SchemaRegistryClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, schemaGroupName string, options *SchemaRegistryClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/schemagroups/{schemaGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif namespaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter namespaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{namespaceName}\", url.PathEscape(namespaceName))\n\tif schemaGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter schemaGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{schemaGroupName}\", url.PathEscape(schemaGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-10-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *TaskRunsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif registryName == \"\" {\n\t\treturn nil, errors.New(\"parameter registryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{registryName}\", url.PathEscape(registryName))\n\tif taskRunName == \"\" {\n\t\treturn nil, errors.New(\"parameter taskRunName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{taskRunName}\", url.PathEscape(taskRunName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2019-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *LocalRulestacksClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, localRulestackName string, options *LocalRulestacksClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif localRulestackName == \"\" {\n\t\treturn nil, errors.New(\"parameter localRulestackName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{localRulestackName}\", url.PathEscape(localRulestackName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-29\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *TriggersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, shareSubscriptionName string, triggerName string, options *TriggersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataShare/accounts/{accountName}/shareSubscriptions/{shareSubscriptionName}/triggers/{triggerName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif accountName == \"\" {\n\t\treturn nil, errors.New(\"parameter accountName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{accountName}\", url.PathEscape(accountName))\n\tif shareSubscriptionName == \"\" {\n\t\treturn nil, errors.New(\"parameter shareSubscriptionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{shareSubscriptionName}\", url.PathEscape(shareSubscriptionName))\n\tif triggerName == \"\" {\n\t\treturn nil, errors.New(\"parameter triggerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{triggerName}\", url.PathEscape(triggerName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-09-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *SpatialAnchorsAccountsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *SpatialAnchorsAccountsClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/spatialAnchorsAccounts/{accountName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif accountName == \"\" {\n\t\treturn nil, errors.New(\"parameter accountName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{accountName}\", url.PathEscape(accountName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-03-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *KpiClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, hubName string, kpiName string, options *KpiClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomerInsights/hubs/{hubName}/kpi/{kpiName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif hubName == \"\" {\n\t\treturn nil, errors.New(\"parameter hubName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hubName}\", url.PathEscape(hubName))\n\tif kpiName == \"\" {\n\t\treturn nil, errors.New(\"parameter kpiName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{kpiName}\", url.PathEscape(kpiName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-04-26\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *AFDOriginsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, profileName string, originGroupName string, originName string, options *AFDOriginsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif profileName == \"\" {\n\t\treturn nil, errors.New(\"parameter profileName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{profileName}\", url.PathEscape(profileName))\n\tif originGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter originGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{originGroupName}\", url.PathEscape(originGroupName))\n\tif originName == \"\" {\n\t\treturn nil, errors.New(\"parameter originName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{originName}\", url.PathEscape(originName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *PeeringPoliciesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkPeeringPolicyName string, options *PeeringPoliciesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif managedNetworkName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedNetworkName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedNetworkName}\", url.PathEscape(managedNetworkName))\n\tif managedNetworkPeeringPolicyName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedNetworkPeeringPolicyName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedNetworkPeeringPolicyName}\", url.PathEscape(managedNetworkPeeringPolicyName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2019-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *VendorSKUPreviewClient) deleteCreateRequest(ctx context.Context, vendorName string, skuName string, previewSubscription string, options *VendorSKUPreviewClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.HybridNetwork/vendors/{vendorName}/vendorSkus/{skuName}/previewSubscriptions/{previewSubscription}\"\n\tif vendorName == \"\" {\n\t\treturn nil, errors.New(\"parameter vendorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vendorName}\", url.PathEscape(vendorName))\n\tif skuName == \"\" {\n\t\treturn nil, errors.New(\"parameter skuName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{skuName}\", url.PathEscape(skuName))\n\tif previewSubscription == \"\" {\n\t\treturn nil, errors.New(\"parameter previewSubscription cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{previewSubscription}\", url.PathEscape(previewSubscription))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *DataCollectionEndpointsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, options *DataCollectionEndpointsClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif dataCollectionEndpointName == \"\" {\n\t\treturn nil, errors.New(\"parameter dataCollectionEndpointName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{dataCollectionEndpointName}\", url.PathEscape(dataCollectionEndpointName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *CustomAssessmentAutomationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, customAssessmentAutomationName string, options *CustomAssessmentAutomationsDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customAssessmentAutomations/{customAssessmentAutomationName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif customAssessmentAutomationName == \"\" {\n\t\treturn nil, errors.New(\"parameter customAssessmentAutomationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{customAssessmentAutomationName}\", url.PathEscape(customAssessmentAutomationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *RecordSetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateZoneName string, recordType RecordType, relativeRecordSetName string, options *RecordSetsDeleteOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateDnsZones/{privateZoneName}/{recordType}/{relativeRecordSetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateZoneName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateZoneName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateZoneName}\", url.PathEscape(privateZoneName))\n\tif recordType == \"\" {\n\t\treturn nil, errors.New(\"parameter recordType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{recordType}\", url.PathEscape(string(recordType)))\n\tif relativeRecordSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter relativeRecordSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{relativeRecordSetName}\", relativeRecordSetName)\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\treqQP := req.URL.Query()\n\treqQP.Set(\"api-version\", \"2020-06-01\")\n\treq.URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Header.Set(\"If-Match\", *options.IfMatch)\n\t}\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *VideosClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, videoName string, options *VideosClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/videoAnalyzers/{accountName}/videos/{videoName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif accountName == \"\" {\n\t\treturn nil, errors.New(\"parameter accountName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{accountName}\", url.PathEscape(accountName))\n\tif videoName == \"\" {\n\t\treturn nil, errors.New(\"parameter videoName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{videoName}\", url.PathEscape(videoName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *KeyVaultClient) deleteSecretCreateRequest(ctx context.Context, vaultBaseURL string, secretName string, options *KeyVaultClientDeleteSecretOptions) (*policy.Request, error) {\n\thost := \"{vaultBaseUrl}\"\n\thost = strings.ReplaceAll(host, \"{vaultBaseUrl}\", vaultBaseURL)\n\turlPath := \"/secrets/{secret-name}\"\n\tif secretName == \"\" {\n\t\treturn nil, errors.New(\"parameter secretName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{secret-name}\", url.PathEscape(secretName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"7.2\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *DataCollectionEndpointsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, options *DataCollectionEndpointsDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif dataCollectionEndpointName == \"\" {\n\t\treturn nil, errors.New(\"parameter dataCollectionEndpointName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{dataCollectionEndpointName}\", url.PathEscape(dataCollectionEndpointName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *RedisClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, name string, options *RedisBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-12-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *VirtualRoutersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, virtualRouterName string, options *VirtualRoutersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualRouters/{virtualRouterName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif virtualRouterName == \"\" {\n\t\treturn nil, errors.New(\"parameter virtualRouterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{virtualRouterName}\", url.PathEscape(virtualRouterName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *AgentPoolsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, kubernetesClusterName string, agentPoolName string, options *AgentPoolsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkCloud/kubernetesClusters/{kubernetesClusterName}/agentPools/{agentPoolName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif kubernetesClusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter kubernetesClusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{kubernetesClusterName}\", url.PathEscape(kubernetesClusterName))\n\tif agentPoolName == \"\" {\n\t\treturn nil, errors.New(\"parameter agentPoolName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{agentPoolName}\", url.PathEscape(agentPoolName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *CloudServiceRoleInstancesClient) deleteCreateRequest(ctx context.Context, roleInstanceName string, resourceGroupName string, cloudServiceName string, options *CloudServiceRoleInstancesBeginDeleteOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}\"\n\tif roleInstanceName == \"\" {\n\t\treturn nil, errors.New(\"parameter roleInstanceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{roleInstanceName}\", url.PathEscape(roleInstanceName))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif cloudServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter cloudServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{cloudServiceName}\", url.PathEscape(cloudServiceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\treqQP := req.URL.Query()\n\treqQP.Set(\"api-version\", \"2021-03-01\")\n\treq.URL.RawQuery = reqQP.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ManagementAssociationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, managementAssociationName string, options *ManagementAssociationsDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.providerName == \"\" {\n\t\treturn nil, errors.New(\"parameter client.providerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{providerName}\", url.PathEscape(client.providerName))\n\tif client.resourceType == \"\" {\n\t\treturn nil, errors.New(\"parameter client.resourceType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceType}\", url.PathEscape(client.resourceType))\n\tif client.resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter client.resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(client.resourceName))\n\tif managementAssociationName == \"\" {\n\t\treturn nil, errors.New(\"parameter managementAssociationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementAssociationName}\", url.PathEscape(managementAssociationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2015-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ApplicationTypeVersionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, version string, options *ApplicationTypeVersionsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\tif applicationTypeName == \"\" {\n\t\treturn nil, errors.New(\"parameter applicationTypeName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{applicationTypeName}\", url.PathEscape(applicationTypeName))\n\tif version == \"\" {\n\t\treturn nil, errors.New(\"parameter version cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{version}\", url.PathEscape(version))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *AvailabilityGroupListenersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, sqlVirtualMachineGroupName string, availabilityGroupListenerName string, options *AvailabilityGroupListenersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sqlVirtualMachineGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter sqlVirtualMachineGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sqlVirtualMachineGroupName}\", url.PathEscape(sqlVirtualMachineGroupName))\n\tif availabilityGroupListenerName == \"\" {\n\t\treturn nil, errors.New(\"parameter availabilityGroupListenerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{availabilityGroupListenerName}\", url.PathEscape(availabilityGroupListenerName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *CustomDomainsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, appName string, domainName string, options *CustomDomainsBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/apps/{appName}/domains/{domainName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif appName == \"\" {\n\t\treturn nil, errors.New(\"parameter appName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{appName}\", url.PathEscape(appName))\n\tif domainName == \"\" {\n\t\treturn nil, errors.New(\"parameter domainName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{domainName}\", url.PathEscape(domainName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-09-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *PacketCoreDataPlanesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, options *PacketCoreDataPlanesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif packetCoreControlPlaneName == \"\" {\n\t\treturn nil, errors.New(\"parameter packetCoreControlPlaneName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{packetCoreControlPlaneName}\", url.PathEscape(packetCoreControlPlaneName))\n\tif packetCoreDataPlaneName == \"\" {\n\t\treturn nil, errors.New(\"parameter packetCoreDataPlaneName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{packetCoreDataPlaneName}\", url.PathEscape(packetCoreDataPlaneName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *VirtualMachineScaleSetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vmScaleSetName string, options *VirtualMachineScaleSetsBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif vmScaleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter vmScaleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vmScaleSetName}\", url.PathEscape(vmScaleSetName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.ForceDeletion != nil {\n\t\treqQP.Set(\"forceDeletion\", strconv.FormatBool(*options.ForceDeletion))\n\t}\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *PublicIPAddressesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, publicIPAddressName string, options *PublicIPAddressesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif publicIPAddressName == \"\" {\n\t\treturn nil, errors.New(\"parameter publicIPAddressName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{publicIpAddressName}\", url.PathEscape(publicIPAddressName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *NotebookClient) deleteNotebookCreateRequest(ctx context.Context, notebookName string, options *NotebookClientBeginDeleteNotebookOptions) (*policy.Request, error) {\n\turlPath := \"/notebooks/{notebookName}\"\n\tif notebookName == \"\" {\n\t\treturn nil, errors.New(\"parameter notebookName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{notebookName}\", url.PathEscape(notebookName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.endpoint, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-12-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ProductPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID PolicyIDName, ifMatch string, options *ProductPolicyClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif productID == \"\" {\n\t\treturn nil, errors.New(\"parameter productID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{productId}\", url.PathEscape(productID))\n\tif policyID == \"\" {\n\t\treturn nil, errors.New(\"parameter policyID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{policyId}\", url.PathEscape(string(policyID)))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"If-Match\"] = []string{ifMatch}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *DataFlowDebugSessionClient) deleteDataFlowDebugSessionCreateRequest(ctx context.Context, request DeleteDataFlowDebugSessionRequest, options *DataFlowDebugSessionClientDeleteDataFlowDebugSessionOptions) (*policy.Request, error) {\n\turlPath := \"/deleteDataFlowDebugSession\"\n\treq, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.endpoint, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-12-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, request); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *SourceControlConfigurationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, sourceControlConfigurationName string, options *SourceControlConfigurationsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterRp == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterRp cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterRp}\", url.PathEscape(clusterRp))\n\tif clusterResourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterResourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterResourceName}\", url.PathEscape(clusterResourceName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\tif sourceControlConfigurationName == \"\" {\n\t\treturn nil, errors.New(\"parameter sourceControlConfigurationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sourceControlConfigurationName}\", url.PathEscape(sourceControlConfigurationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-11-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *CertificateOrdersClient) deleteCertificateCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, name string, options *CertificateOrdersClientDeleteCertificateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/certificates/{name}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif certificateOrderName == \"\" {\n\t\treturn nil, errors.New(\"parameter certificateOrderName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{certificateOrderName}\", url.PathEscape(certificateOrderName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-09-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}" ]
[ "0.76320505", "0.7584632", "0.75717694", "0.7566521", "0.7531389", "0.75282", "0.7505947", "0.7504906", "0.7492394", "0.7492235", "0.74904436", "0.7432695", "0.7426466", "0.74185693", "0.7404809", "0.73585665", "0.7352774", "0.7342807", "0.7289017", "0.72818315", "0.7280017", "0.72641027", "0.72544336", "0.72520685", "0.7251728", "0.7243615", "0.72096527", "0.7201552", "0.7197194", "0.7185018", "0.717346", "0.71458405", "0.7144982", "0.7132672", "0.7121222", "0.7106942", "0.7105571", "0.7101803", "0.71004266", "0.70893526", "0.7085441", "0.70700926", "0.70616543", "0.70538044", "0.70529956", "0.70505625", "0.7023896", "0.7013103", "0.7009507", "0.7006913", "0.6999188", "0.69968814", "0.69938457", "0.6993641", "0.6988131", "0.6987731", "0.6976566", "0.6971027", "0.6964506", "0.69616055", "0.6955038", "0.6947099", "0.694701", "0.6945518", "0.6942814", "0.69391435", "0.69317603", "0.69313776", "0.6917061", "0.6907204", "0.69042027", "0.69033295", "0.69003856", "0.68977785", "0.68939674", "0.6884883", "0.68807447", "0.6877372", "0.68771124", "0.6871673", "0.6871498", "0.6854659", "0.6841991", "0.68349135", "0.68341315", "0.6832094", "0.68157667", "0.67991", "0.67865884", "0.6780297", "0.67801976", "0.6770231", "0.67655265", "0.6762833", "0.6749718", "0.67331254", "0.6730649", "0.67276996", "0.6691175", "0.6686218" ]
0.7662335
0
deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request.
deleteAtManagementGroupCreateRequest создает запрос DeleteAtManagementGroup.
func (client *PolicyDefinitionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, options *PolicyDefinitionsDeleteAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" if policyDefinitionName == "" { return nil, errors.New("parameter policyDefinitionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CreateDeleteCorpGroupRequest() (request *DeleteCorpGroupRequest) {\n\trequest = &DeleteCorpGroupRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Vcs\", \"2020-05-15\", \"DeleteCorpGroup\", \"\", \"\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *GroupClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string, options *GroupDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif groupID == \"\" {\n\t\treturn nil, errors.New(\"parameter groupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{groupId}\", url.PathEscape(groupID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"If-Match\", ifMatch)\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ContainerGroupsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif containerGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter containerGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{containerGroupName}\", url.PathEscape(containerGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *PolicyDefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, parameters PolicyDefinition, options *PolicyDefinitionsCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}\"\n\tif policyDefinitionName == \"\" {\n\t\treturn nil, errors.New(\"parameter policyDefinitionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{policyDefinitionName}\", url.PathEscape(policyDefinitionName))\n\tif managementGroupID == \"\" {\n\t\treturn nil, errors.New(\"parameter managementGroupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementGroupId}\", url.PathEscape(managementGroupID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func CreateDeleteVideoDnaGroupRequest() (request *DeleteVideoDnaGroupRequest) {\n\trequest = &DeleteVideoDnaGroupRequest{\n\t\tRoaRequest: &requests.RoaRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Green\", \"2018-05-09\", \"DeleteVideoDnaGroup\", \"/green/video/dna/group/delete\", \"\", \"\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *PolicyDefinitionsClient) getAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, options *PolicyDefinitionsGetAtManagementGroupOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}\"\n\tif policyDefinitionName == \"\" {\n\t\treturn nil, errors.New(\"parameter policyDefinitionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{policyDefinitionName}\", url.PathEscape(policyDefinitionName))\n\tif managementGroupID == \"\" {\n\t\treturn nil, errors.New(\"parameter managementGroupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementGroupId}\", url.PathEscape(managementGroupID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *PrivateDNSZoneGroupsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateEndpointName string, privateDNSZoneGroupName string, options *PrivateDNSZoneGroupsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateEndpoints/{privateEndpointName}/privateDnsZoneGroups/{privateDnsZoneGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateEndpointName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateEndpointName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateEndpointName}\", url.PathEscape(privateEndpointName))\n\tif privateDNSZoneGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateDNSZoneGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateDnsZoneGroupName}\", url.PathEscape(privateDNSZoneGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *SyncGroupsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, options *SyncGroupsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serverName == \"\" {\n\t\treturn nil, errors.New(\"parameter serverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serverName}\", url.PathEscape(serverName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif syncGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter syncGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{syncGroupName}\", url.PathEscape(syncGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *LongTermRetentionManagedInstanceBackupsClient) deleteByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string, options *LongTermRetentionManagedInstanceBackupsBeginDeleteByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif locationName == \"\" {\n\t\treturn nil, errors.New(\"parameter locationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{locationName}\", url.PathEscape(locationName))\n\tif managedInstanceName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedInstanceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedInstanceName}\", url.PathEscape(managedInstanceName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif backupName == \"\" {\n\t\treturn nil, errors.New(\"parameter backupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{backupName}\", url.PathEscape(backupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (c *UDBClient) NewDeleteUDBParamGroupRequest() *DeleteUDBParamGroupRequest {\n\treq := &DeleteUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(true)\n\treturn req\n}", "func (c *UDBClient) NewDeleteUDBParamGroupRequest() *DeleteUDBParamGroupRequest {\n\treq := &DeleteUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(true)\n\treturn req\n}", "func (client *AvailabilitySetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetName string, options *AvailabilitySetsDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif availabilitySetName == \"\" {\n\t\treturn nil, errors.New(\"parameter availabilitySetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{availabilitySetName}\", url.PathEscape(availabilitySetName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *ClustersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-11-08\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *PolicyDefinitionsClient) listByManagementGroupCreateRequest(ctx context.Context, managementGroupID string, options *PolicyDefinitionsListByManagementGroupOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions\"\n\tif managementGroupID == \"\" {\n\t\treturn nil, errors.New(\"parameter managementGroupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementGroupId}\", url.PathEscape(managementGroupID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\tif options != nil && options.Top != nil {\n\t\treqQP.Set(\"$top\", strconv.FormatInt(int64(*options.Top), 10))\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tunencodedParams := []string{req.Raw().URL.RawQuery}\n\tif options != nil && options.Filter != nil {\n\t\tunencodedParams = append(unencodedParams, \"$filter=\"+*options.Filter)\n\t}\n\treq.Raw().URL.RawQuery = strings.Join(unencodedParams, \"&\")\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ManagementAssociationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, managementAssociationName string, options *ManagementAssociationsDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.providerName == \"\" {\n\t\treturn nil, errors.New(\"parameter client.providerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{providerName}\", url.PathEscape(client.providerName))\n\tif client.resourceType == \"\" {\n\t\treturn nil, errors.New(\"parameter client.resourceType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceType}\", url.PathEscape(client.resourceType))\n\tif client.resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter client.resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(client.resourceName))\n\tif managementAssociationName == \"\" {\n\t\treturn nil, errors.New(\"parameter managementAssociationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementAssociationName}\", url.PathEscape(managementAssociationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2015-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *DiskEncryptionSetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, diskEncryptionSetName string, options *DiskEncryptionSetsBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif diskEncryptionSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter diskEncryptionSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{diskEncryptionSetName}\", url.PathEscape(diskEncryptionSetName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ClustersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func CreateRemoveAppGroupRequest() (request *RemoveAppGroupRequest) {\n\trequest = &RemoveAppGroupRequest{\n\t\tRoaRequest: &requests.RoaRequest{},\n\t}\n\trequest.InitWithApiInfo(\"OpenSearch\", \"2017-12-25\", \"RemoveAppGroup\", \"/v4/openapi/app-groups/[appGroupIdentity]\", \"\", \"\")\n\trequest.Method = requests.DELETE\n\treturn\n}", "func NewDeleteaspecificPeeringGroupRequest(server string, id string) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParam(\"simple\", false, \"id\", id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tqueryUrl, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbasePath := fmt.Sprintf(\"/peeringgroups/%s\", pathParam0)\n\tif basePath[0] == '/' {\n\t\tbasePath = basePath[1:]\n\t}\n\n\tqueryUrl, err = queryUrl.Parse(basePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"DELETE\", queryUrl.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "func (client *LocalRulestacksClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, localRulestackName string, options *LocalRulestacksClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif localRulestackName == \"\" {\n\t\treturn nil, errors.New(\"parameter localRulestackName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{localRulestackName}\", url.PathEscape(localRulestackName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-29\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *TagRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/monitors/{monitorName}/tagRules/{ruleSetName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif monitorName == \"\" {\n\t\treturn nil, errors.New(\"parameter monitorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{monitorName}\", url.PathEscape(monitorName))\n\tif ruleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter ruleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ruleSetName}\", url.PathEscape(ruleSetName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-27\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *VirtualMachineScaleSetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vmScaleSetName string, options *VirtualMachineScaleSetsBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif vmScaleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter vmScaleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vmScaleSetName}\", url.PathEscape(vmScaleSetName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.ForceDeletion != nil {\n\t\treqQP.Set(\"forceDeletion\", strconv.FormatBool(*options.ForceDeletion))\n\t}\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *ManagedInstancesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, managedInstanceName string, options *ManagedInstancesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif managedInstanceName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedInstanceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedInstanceName}\", url.PathEscape(managedInstanceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *MonitorsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif monitorName == \"\" {\n\t\treturn nil, errors.New(\"parameter monitorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{monitorName}\", url.PathEscape(monitorName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *CustomAssessmentAutomationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, customAssessmentAutomationName string, options *CustomAssessmentAutomationsDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customAssessmentAutomations/{customAssessmentAutomationName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif customAssessmentAutomationName == \"\" {\n\t\treturn nil, errors.New(\"parameter customAssessmentAutomationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{customAssessmentAutomationName}\", url.PathEscape(customAssessmentAutomationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ManagedClustersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *ManagedClustersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(resourceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *DedicatedHostsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string, options *DedicatedHostsBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif hostGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter hostGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hostGroupName}\", url.PathEscape(hostGroupName))\n\tif hostName == \"\" {\n\t\treturn nil, errors.New(\"parameter hostName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hostName}\", url.PathEscape(hostName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func CreateDeleteCasterEpisodeGroupRequest() (request *DeleteCasterEpisodeGroupRequest) {\n\trequest = &DeleteCasterEpisodeGroupRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"live\", \"2016-11-01\", \"DeleteCasterEpisodeGroup\", \"live\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (c *UMemClient) NewCreateUMemcacheGroupRequest() *CreateUMemcacheGroupRequest {\n\treq := &CreateUMemcacheGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(false)\n\treturn req\n}", "func (client *AvailabilityGroupListenersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, sqlVirtualMachineGroupName string, availabilityGroupListenerName string, options *AvailabilityGroupListenersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners/{availabilityGroupListenerName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sqlVirtualMachineGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter sqlVirtualMachineGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sqlVirtualMachineGroupName}\", url.PathEscape(sqlVirtualMachineGroupName))\n\tif availabilityGroupListenerName == \"\" {\n\t\treturn nil, errors.New(\"parameter availabilityGroupListenerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{availabilityGroupListenerName}\", url.PathEscape(availabilityGroupListenerName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *SapMonitorsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, sapMonitorName string, options *SapMonitorsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HanaOnAzure/sapMonitors/{sapMonitorName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sapMonitorName == \"\" {\n\t\treturn nil, errors.New(\"parameter sapMonitorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sapMonitorName}\", url.PathEscape(sapMonitorName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-02-07-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *CapacityReservationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, capacityReservationGroupName string, capacityReservationName string, options *CapacityReservationsBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif capacityReservationGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter capacityReservationGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{capacityReservationGroupName}\", url.PathEscape(capacityReservationGroupName))\n\tif capacityReservationName == \"\" {\n\t\treturn nil, errors.New(\"parameter capacityReservationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{capacityReservationName}\", url.PathEscape(capacityReservationName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *RecordSetsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateZoneName string, recordType RecordType, relativeRecordSetName string, options *RecordSetsDeleteOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateDnsZones/{privateZoneName}/{recordType}/{relativeRecordSetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateZoneName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateZoneName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateZoneName}\", url.PathEscape(privateZoneName))\n\tif recordType == \"\" {\n\t\treturn nil, errors.New(\"parameter recordType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{recordType}\", url.PathEscape(string(recordType)))\n\tif relativeRecordSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter relativeRecordSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{relativeRecordSetName}\", relativeRecordSetName)\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\treqQP := req.URL.Query()\n\treqQP.Set(\"api-version\", \"2020-06-01\")\n\treq.URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Header.Set(\"If-Match\", *options.IfMatch)\n\t}\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *DedicatedHostsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string, options *DedicatedHostsBeginDeleteOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{hostGroupName}\", url.PathEscape(hostGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{hostName}\", url.PathEscape(hostName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-06-01\")\n\treq.URL.RawQuery = query.Encode()\n\treturn req, nil\n}", "func (client *IPAllocationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, ipAllocationName string, options *IPAllocationsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/IpAllocations/{ipAllocationName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif ipAllocationName == \"\" {\n\t\treturn nil, errors.New(\"parameter ipAllocationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ipAllocationName}\", url.PathEscape(ipAllocationName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *SchemaRegistryClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, schemaGroupName string, options *SchemaRegistryClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/schemagroups/{schemaGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif namespaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter namespaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{namespaceName}\", url.PathEscape(namespaceName))\n\tif schemaGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter schemaGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{schemaGroupName}\", url.PathEscape(schemaGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-10-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *KpiClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, hubName string, kpiName string, options *KpiClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomerInsights/hubs/{hubName}/kpi/{kpiName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif hubName == \"\" {\n\t\treturn nil, errors.New(\"parameter hubName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hubName}\", url.PathEscape(hubName))\n\tif kpiName == \"\" {\n\t\treturn nil, errors.New(\"parameter kpiName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{kpiName}\", url.PathEscape(kpiName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-04-26\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func NewAttachGroupPolicyRequestWithoutParam() *AttachGroupPolicyRequest {\n\n return &AttachGroupPolicyRequest{\n JDCloudRequest: core.JDCloudRequest{\n URL: \"/group/{groupName}:attachGroupPolicy\",\n Method: \"POST\",\n Header: nil,\n Version: \"v1\",\n },\n }\n}", "func (client *RegistrationDefinitionsClient) deleteCreateRequest(ctx context.Context, registrationDefinitionID string, scope string, options *RegistrationDefinitionsClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}\"\n\tif registrationDefinitionID == \"\" {\n\t\treturn nil, errors.New(\"parameter registrationDefinitionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{registrationDefinitionId}\", url.PathEscape(registrationDefinitionID))\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *AgentPoolsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, kubernetesClusterName string, agentPoolName string, options *AgentPoolsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkCloud/kubernetesClusters/{kubernetesClusterName}/agentPools/{agentPoolName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif kubernetesClusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter kubernetesClusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{kubernetesClusterName}\", url.PathEscape(kubernetesClusterName))\n\tif agentPoolName == \"\" {\n\t\treturn nil, errors.New(\"parameter agentPoolName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{agentPoolName}\", url.PathEscape(agentPoolName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateDeleteDegradeControlRequest() (request *DeleteDegradeControlRequest) {\n\trequest = &DeleteDegradeControlRequest{\n\t\tRoaRequest: &requests.RoaRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Edas\", \"2017-08-01\", \"DeleteDegradeControl\", \"/pop/v5/degradeControl\", \"Edas\", \"openAPI\")\n\trequest.Method = requests.DELETE\n\treturn\n}", "func (rm *resourceManager) newDeleteRequestPayload(\n\tr *resource,\n) (*svcsdk.DeleteReplicationGroupInput, error) {\n\tres := &svcsdk.DeleteReplicationGroupInput{}\n\n\tif r.ko.Spec.ReplicationGroupID != nil {\n\t\tres.SetReplicationGroupId(*r.ko.Spec.ReplicationGroupID)\n\t}\n\n\treturn res, nil\n}", "func (client *SQLVirtualMachinesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, sqlVirtualMachineName string, options *SQLVirtualMachinesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sqlVirtualMachineName == \"\" {\n\t\treturn nil, errors.New(\"parameter sqlVirtualMachineName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sqlVirtualMachineName}\", url.PathEscape(sqlVirtualMachineName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-03-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *MetricAlertsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, options *MetricAlertsClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif ruleName == \"\" {\n\t\treturn nil, errors.New(\"parameter ruleName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ruleName}\", url.PathEscape(ruleName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func NewDeleteConsumerGroupCommand(f *factory.Factory) *cobra.Command {\n\topts := &Options{\n\t\tConnection: f.Connection,\n\t\tCfgHandler: f.CfgHandler,\n\t\tIO: f.IOStreams,\n\t\tLogger: f.Logger,\n\t\tlocalizer: f.Localizer,\n\t}\n\n\tcmd := &cobra.Command{\n\t\tUse: opts.localizer.LocalizeByID(\"kafka.consumerGroup.delete.cmd.use\"),\n\t\tShort: opts.localizer.LocalizeByID(\"kafka.consumerGroup.delete.cmd.shortDescription\"),\n\t\tLong: opts.localizer.LocalizeByID(\"kafka.consumerGroup.delete.cmd.longDescription\"),\n\t\tExample: opts.localizer.LocalizeByID(\"kafka.consumerGroup.delete.cmd.example\"),\n\t\tArgs: cobra.NoArgs,\n\t\tRunE: func(cmd *cobra.Command, args []string) (err error) {\n\t\t\tif opts.kafkaID != \"\" {\n\t\t\t\treturn runCmd(opts)\n\t\t\t}\n\n\t\t\tif !f.CfgHandler.Cfg.HasKafka() {\n\t\t\t\treturn errors.New(opts.localizer.LocalizeByID(\"kafka.consumerGroup.common.error.noKafkaSelected\"))\n\t\t\t}\n\n\t\t\topts.kafkaID = opts.CfgHandler.Cfg.Services.Kafka.ClusterID\n\n\t\t\treturn runCmd(opts)\n\t\t},\n\t}\n\n\topts.localizer.LocalizeByID(\"kafka.consumerGroup.common.flag.id.description\", localize.NewEntry(\"Action\", \"delete\"))\n\tcmd.Flags().BoolVarP(&opts.skipConfirm, \"yes\", \"y\", false, opts.localizer.LocalizeByID(\"kafka.consumerGroup.delete.flag.yes.description\"))\n\tcmd.Flags().StringVar(&opts.id, \"id\", \"\", opts.localizer.LocalizeByID(\"kafka.consumerGroup.common.flag.id.description\", localize.NewEntry(\"Action\", \"delete\")))\n\t_ = cmd.MarkFlagRequired(\"id\")\n\n\t// flag based completions for ID\n\t_ = cmd.RegisterFlagCompletionFunc(\"id\", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {\n\t\treturn cmdutil.FilterValidConsumerGroupIDs(f, toComplete)\n\t})\n\n\treturn cmd\n}", "func NewDeploymentAtManagementGroupScope(ctx *pulumi.Context,\n\tname string, args *DeploymentAtManagementGroupScopeArgs, opts ...pulumi.ResourceOption) (*DeploymentAtManagementGroupScope, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.GroupId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'GroupId'\")\n\t}\n\tif args.Properties == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Properties'\")\n\t}\n\taliases := pulumi.Aliases([]pulumi.Alias{\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20190501:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20190510:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20190510:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20190701:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20190701:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20190801:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20190801:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20191001:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20191001:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20200601:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20200601:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20200801:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20200801:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20201001:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20201001:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20210101:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20210101:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20210401:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20210401:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t})\n\topts = append(opts, aliases)\n\tvar resource DeploymentAtManagementGroupScope\n\terr := ctx.RegisterResource(\"azure-native:resources/v20190501:DeploymentAtManagementGroupScope\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (client *CloudServicesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, cloudServiceName string, options *CloudServicesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif cloudServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter cloudServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{cloudServiceName}\", url.PathEscape(cloudServiceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-09-04\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (m *MockRDSAPI) DeleteOptionGroupRequest(arg0 *rds.DeleteOptionGroupInput) (*request.Request, *rds.DeleteOptionGroupOutput) {\n\tret := m.ctrl.Call(m, \"DeleteOptionGroupRequest\", arg0)\n\tret0, _ := ret[0].(*request.Request)\n\tret1, _ := ret[1].(*rds.DeleteOptionGroupOutput)\n\treturn ret0, ret1\n}", "func (client *SourceControlConfigurationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, sourceControlConfigurationName string, options *SourceControlConfigurationsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{clusterRp}/{clusterResourceName}/{clusterName}/providers/Microsoft.KubernetesConfiguration/sourceControlConfigurations/{sourceControlConfigurationName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterRp == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterRp cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterRp}\", url.PathEscape(clusterRp))\n\tif clusterResourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterResourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterResourceName}\", url.PathEscape(clusterResourceName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\tif sourceControlConfigurationName == \"\" {\n\t\treturn nil, errors.New(\"parameter sourceControlConfigurationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sourceControlConfigurationName}\", url.PathEscape(sourceControlConfigurationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-11-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func NewRemoveControlFromGroupParams() *RemoveControlFromGroupParams {\n\tvar ()\n\treturn &RemoveControlFromGroupParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (client *DevicesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, deviceName string, options *DevicesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif deviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter deviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{deviceName}\", url.PathEscape(deviceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *PacketCoreDataPlanesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, packetCoreControlPlaneName string, packetCoreDataPlaneName string, options *PacketCoreDataPlanesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/{packetCoreControlPlaneName}/packetCoreDataPlanes/{packetCoreDataPlaneName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif packetCoreControlPlaneName == \"\" {\n\t\treturn nil, errors.New(\"parameter packetCoreControlPlaneName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{packetCoreControlPlaneName}\", url.PathEscape(packetCoreControlPlaneName))\n\tif packetCoreDataPlaneName == \"\" {\n\t\treturn nil, errors.New(\"parameter packetCoreDataPlaneName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{packetCoreDataPlaneName}\", url.PathEscape(packetCoreDataPlaneName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *AlertProcessingRulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, options *AlertProcessingRulesClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif alertProcessingRuleName == \"\" {\n\t\treturn nil, errors.New(\"parameter alertProcessingRuleName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{alertProcessingRuleName}\", url.PathEscape(alertProcessingRuleName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-08\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ReplicationvCentersClient) deleteCreateRequest(ctx context.Context, fabricName string, vcenterName string, options *ReplicationvCentersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationvCenters/{vcenterName}\"\n\tif client.resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter client.resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(client.resourceName))\n\tif client.resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter client.resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(client.resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif fabricName == \"\" {\n\t\treturn nil, errors.New(\"parameter fabricName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{fabricName}\", url.PathEscape(fabricName))\n\tif vcenterName == \"\" {\n\t\treturn nil, errors.New(\"parameter vcenterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vcenterName}\", url.PathEscape(vcenterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-11-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func NewDeleteSecurityGroupRequest(server string, id string) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParam(\"simple\", false, \"id\", id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tqueryUrl, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbasePath := fmt.Sprintf(\"/security-group/%s\", pathParam0)\n\tif basePath[0] == '/' {\n\t\tbasePath = basePath[1:]\n\t}\n\n\tqueryUrl, err = queryUrl.Parse(basePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq, err := http.NewRequest(\"DELETE\", queryUrl.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "func (client *CapacitiesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dedicatedCapacityName string, options *CapacitiesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif dedicatedCapacityName == \"\" {\n\t\treturn nil, errors.New(\"parameter dedicatedCapacityName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{dedicatedCapacityName}\", url.PathEscape(dedicatedCapacityName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-01-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *CertificateOrdersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, certificateOrderName string, options *CertificateOrdersClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif certificateOrderName == \"\" {\n\t\treturn nil, errors.New(\"parameter certificateOrderName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{certificateOrderName}\", url.PathEscape(certificateOrderName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-09-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ConnectedEnvironmentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, connectedEnvironmentName string, options *ConnectedEnvironmentsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif connectedEnvironmentName == \"\" {\n\t\treturn nil, errors.New(\"parameter connectedEnvironmentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{connectedEnvironmentName}\", url.PathEscape(connectedEnvironmentName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ManagedDatabasesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, options *ManagedDatabasesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif managedInstanceName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedInstanceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedInstanceName}\", url.PathEscape(managedInstanceName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (r *DeviceManagementScriptGroupAssignmentRequest) Delete(ctx context.Context) error {\n\treturn r.JSONRequest(ctx, \"DELETE\", \"\", nil, nil)\n}", "func (client *HCRPAssignmentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, machineName string, options *HCRPAssignmentsClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif guestConfigurationAssignmentName == \"\" {\n\t\treturn nil, errors.New(\"parameter guestConfigurationAssignmentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{guestConfigurationAssignmentName}\", url.PathEscape(guestConfigurationAssignmentName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif machineName == \"\" {\n\t\treturn nil, errors.New(\"parameter machineName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{machineName}\", url.PathEscape(machineName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-25\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *CassandraClustersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *CassandraClustersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-03-15-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateDeleteApDeviceRequest() (request *DeleteApDeviceRequest) {\n\trequest = &DeleteApDeviceRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"cloudesl\", \"2020-02-01\", \"DeleteApDevice\", \"\", \"\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *ContainerGroupsClient) stopCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsClientStopOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/stop\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif containerGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter containerGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{containerGroupName}\", url.PathEscape(containerGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (o *PcloudPlacementgroupsMembersDeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param cloud_instance_id\n\tif err := r.SetPathParam(\"cloud_instance_id\", o.CloudInstanceID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param placement_group_id\n\tif err := r.SetPathParam(\"placement_group_id\", o.PlacementGroupID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (client IdentityClient) deleteGroup(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodDelete, \"/groups/{groupId}\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response DeleteGroupResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (client *Client) DeleteGroupWithOptions(request *DeleteGroupRequest, runtime *util.RuntimeOptions) (_result *DeleteGroupResponse, _err error) {\n\t_err = util.ValidateModel(request)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\tquery := map[string]interface{}{}\n\tif !tea.BoolValue(util.IsUnset(request.GroupId)) {\n\t\tquery[\"GroupId\"] = request.GroupId\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.SourceIp)) {\n\t\tquery[\"SourceIp\"] = request.SourceIp\n\t}\n\n\treq := &openapi.OpenApiRequest{\n\t\tQuery: openapiutil.Query(query),\n\t}\n\tparams := &openapi.Params{\n\t\tAction: tea.String(\"DeleteGroup\"),\n\t\tVersion: tea.String(\"2018-12-03\"),\n\t\tProtocol: tea.String(\"HTTPS\"),\n\t\tPathname: tea.String(\"/\"),\n\t\tMethod: tea.String(\"POST\"),\n\t\tAuthType: tea.String(\"AK\"),\n\t\tStyle: tea.String(\"RPC\"),\n\t\tReqBodyType: tea.String(\"formData\"),\n\t\tBodyType: tea.String(\"json\"),\n\t}\n\t_result = &DeleteGroupResponse{}\n\t_body, _err := client.CallApi(params, req, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_err = tea.Convert(_body, &_result)\n\treturn _result, _err\n}", "func (ooc *MockOpenoltClient) DeleteGroup(ctx context.Context, in *openolt.Group, opts ...grpc.CallOption) (*openolt.Empty, error) {\n\treturn &openolt.Empty{}, nil\n}", "func (client *ContainerGroupsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ContainerGroupsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ReplicationProtectionContainersClient) deleteCreateRequest(ctx context.Context, resourceName string, resourceGroupName string, fabricName string, protectionContainerName string, options *ReplicationProtectionContainersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/remove\"\n\tif resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(resourceName))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif fabricName == \"\" {\n\t\treturn nil, errors.New(\"parameter fabricName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{fabricName}\", url.PathEscape(fabricName))\n\tif protectionContainerName == \"\" {\n\t\treturn nil, errors.New(\"parameter protectionContainerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{protectionContainerName}\", url.PathEscape(protectionContainerName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-10-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func CreateCreateApplicationGroupRequest() (request *CreateApplicationGroupRequest) {\n\trequest = &CreateApplicationGroupRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"oos\", \"2019-06-01\", \"CreateApplicationGroup\", \"oos\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func NewDeleteMsgVpnAuthorizationGroupOK() *DeleteMsgVpnAuthorizationGroupOK {\n\treturn &DeleteMsgVpnAuthorizationGroupOK{}\n}", "func (client *DiskEncryptionSetsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DiskEncryptionSetsListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *UserMetricsKeysClient) deleteCreateRequest(ctx context.Context, options *UserMetricsKeysClientDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *PeeringPoliciesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, managedNetworkName string, managedNetworkPeeringPolicyName string, options *PeeringPoliciesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedNetwork/managedNetworks/{managedNetworkName}/managedNetworkPeeringPolicies/{managedNetworkPeeringPolicyName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif managedNetworkName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedNetworkName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedNetworkName}\", url.PathEscape(managedNetworkName))\n\tif managedNetworkPeeringPolicyName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedNetworkPeeringPolicyName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedNetworkPeeringPolicyName}\", url.PathEscape(managedNetworkPeeringPolicyName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2019-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateDeleteVpdGrantRuleRequest() (request *DeleteVpdGrantRuleRequest) {\n\trequest = &DeleteVpdGrantRuleRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"eflo\", \"2022-05-30\", \"DeleteVpdGrantRule\", \"eflo\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (m *MockRDSAPI) DeleteDBClusterParameterGroupRequest(arg0 *rds.DeleteDBClusterParameterGroupInput) (*request.Request, *rds.DeleteDBClusterParameterGroupOutput) {\n\tret := m.ctrl.Call(m, \"DeleteDBClusterParameterGroupRequest\", arg0)\n\tret0, _ := ret[0].(*request.Request)\n\tret1, _ := ret[1].(*rds.DeleteDBClusterParameterGroupOutput)\n\treturn ret0, ret1\n}", "func (s *GroupsService) Delete(\n\tctx context.Context,\n\tgroupName string,\n) error {\n\traw, err := json.Marshal(struct {\n\t\tGroupName string `json:\"group_name\"`\n\t}{\n\t\tgroupName,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\treq, err := http.NewRequest(\n\t\thttp.MethodPost,\n\t\ts.client.url+\"2.0/groups/delete\",\n\t\tbytes.NewBuffer(raw),\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq = req.WithContext(ctx)\n\tres, err := s.client.client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif res.StatusCode >= 300 || res.StatusCode <= 199 {\n\t\treturn fmt.Errorf(\n\t\t\t\"Failed to returns 2XX response: %d\", res.StatusCode)\n\t}\n\n\treturn nil\n}", "func (client *AgentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, agentName string, options *AgentsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/agents/{agentName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif storageMoverName == \"\" {\n\t\treturn nil, errors.New(\"parameter storageMoverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{storageMoverName}\", url.PathEscape(storageMoverName))\n\tif agentName == \"\" {\n\t\treturn nil, errors.New(\"parameter agentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{agentName}\", url.PathEscape(agentName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-07-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *RedisClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, name string, options *RedisBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-12-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *VirtualMachineImageTemplatesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, imageTemplateName string, options *VirtualMachineImageTemplatesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif imageTemplateName == \"\" {\n\t\treturn nil, errors.New(\"parameter imageTemplateName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{imageTemplateName}\", url.PathEscape(imageTemplateName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-10-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *RoleAssignmentsClient) deleteCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, options *RoleAssignmentsDeleteOptions) (*policy.Request, error) {\n\thost := \"{vaultBaseUrl}\"\n\thost = strings.ReplaceAll(host, \"{vaultBaseUrl}\", vaultBaseURL)\n\turlPath := \"/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}\"\n\tif scope == \"\" {\n\t\treturn nil, errors.New(\"parameter scope cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\tif roleAssignmentName == \"\" {\n\t\treturn nil, errors.New(\"parameter roleAssignmentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{roleAssignmentName}\", url.PathEscape(roleAssignmentName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"7.3-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client WorkloadNetworksClient) DeleteVMGroupPreparer(ctx context.Context, resourceGroupName string, VMGroupID string, privateCloudName string) (*http.Request, error) {\n\tpathParameters := map[string]interface{}{\n\t\t\"privateCloudName\": autorest.Encode(\"path\", privateCloudName),\n\t\t\"resourceGroupName\": autorest.Encode(\"path\", resourceGroupName),\n\t\t\"subscriptionId\": autorest.Encode(\"path\", client.SubscriptionID),\n\t\t\"vmGroupId\": autorest.Encode(\"path\", VMGroupID),\n\t}\n\n\tconst APIVersion = \"2020-07-17-preview\"\n\tqueryParameters := map[string]interface{}{\n\t\t\"api-version\": APIVersion,\n\t}\n\n\tpreparer := autorest.CreatePreparer(\n\t\tautorest.AsDelete(),\n\t\tautorest.WithBaseURL(client.BaseURI),\n\t\tautorest.WithPathParameters(\"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}\", pathParameters),\n\t\tautorest.WithQueryParameters(queryParameters))\n\treturn preparer.Prepare((&http.Request{}).WithContext(ctx))\n}", "func (client *VirtualMachineScaleSetVMRunCommandsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vmScaleSetName string, instanceID string, runCommandName string, options *VirtualMachineScaleSetVMRunCommandsBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif vmScaleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter vmScaleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vmScaleSetName}\", url.PathEscape(vmScaleSetName))\n\tif instanceID == \"\" {\n\t\treturn nil, errors.New(\"parameter instanceID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{instanceId}\", url.PathEscape(instanceID))\n\tif runCommandName == \"\" {\n\t\treturn nil, errors.New(\"parameter runCommandName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{runCommandName}\", url.PathEscape(runCommandName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json, text/json\")\n\treturn req, nil\n}", "func (client *VirtualNetworkTapsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, tapName string, options *VirtualNetworkTapsBeginDeleteOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkTaps/{tapName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{tapName}\", url.PathEscape(tapName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-07-01\")\n\treq.URL.RawQuery = query.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func CreateDescribeContainerGroupMetricRequest() (request *DescribeContainerGroupMetricRequest) {\n\trequest = &DescribeContainerGroupMetricRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Eci\", \"2018-08-08\", \"DescribeContainerGroupMetric\", \"eci\", \"openAPI\")\n\treturn\n}", "func NewCreateVMPlacementGroupOK() *CreateVMPlacementGroupOK {\n\treturn &CreateVMPlacementGroupOK{}\n}", "func (client *CassandraClustersClient) deallocateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *CassandraClustersClientBeginDeallocateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-03-15-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *RoleDefinitionsClient) deleteCreateRequest(ctx context.Context, scope string, roleDefinitionID string, options *RoleDefinitionsDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\tif roleDefinitionID == \"\" {\n\t\treturn nil, errors.New(\"parameter roleDefinitionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{roleDefinitionId}\", url.PathEscape(roleDefinitionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClustersClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-11-08\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *PermissionBindingsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, permissionBindingName string, options *PermissionBindingsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/namespaces/{namespaceName}/permissionBindings/{permissionBindingName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif namespaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter namespaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{namespaceName}\", url.PathEscape(namespaceName))\n\tif permissionBindingName == \"\" {\n\t\treturn nil, errors.New(\"parameter permissionBindingName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{permissionBindingName}\", url.PathEscape(permissionBindingName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *DicomServicesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dicomServiceName string, workspaceName string, options *DicomServicesClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/dicomservices/{dicomServiceName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif dicomServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter dicomServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{dicomServiceName}\", url.PathEscape(dicomServiceName))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func NewPolicyDefinitionAtManagementGroup(ctx *pulumi.Context,\n\tname string, args *PolicyDefinitionAtManagementGroupArgs, opts ...pulumi.ResourceOption) (*PolicyDefinitionAtManagementGroup, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.ManagementGroupId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'ManagementGroupId'\")\n\t}\n\taliases := pulumi.Aliases([]pulumi.Alias{\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20190101:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20161201:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20161201:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20180301:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20180301:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20180501:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20180501:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20190601:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20190601:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20190901:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20190901:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20200301:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20200301:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:authorization/v20200901:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:authorization/v20200901:PolicyDefinitionAtManagementGroup\"),\n\t\t},\n\t})\n\topts = append(opts, aliases)\n\tvar resource PolicyDefinitionAtManagementGroup\n\terr := ctx.RegisterResource(\"azure-native:authorization/v20190101:PolicyDefinitionAtManagementGroup\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (client *PolicyDefinitionsClient) deleteCreateRequest(ctx context.Context, policyDefinitionName string, options *PolicyDefinitionsDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}\"\n\tif policyDefinitionName == \"\" {\n\t\treturn nil, errors.New(\"parameter policyDefinitionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{policyDefinitionName}\", url.PathEscape(policyDefinitionName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ServersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serverName == \"\" {\n\t\treturn nil, errors.New(\"parameter serverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serverName}\", url.PathEscape(serverName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, nil\n}", "func (client *VirtualNetworkLinksClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateZoneName string, virtualNetworkLinkName string, options *VirtualNetworkLinksBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateDnsZones/{privateZoneName}/virtualNetworkLinks/{virtualNetworkLinkName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateZoneName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateZoneName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateZoneName}\", url.PathEscape(privateZoneName))\n\tif virtualNetworkLinkName == \"\" {\n\t\treturn nil, errors.New(\"parameter virtualNetworkLinkName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{virtualNetworkLinkName}\", url.PathEscape(virtualNetworkLinkName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Raw().Header.Set(\"If-Match\", *options.IfMatch)\n\t}\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func NewDeleteSecurityGroupOK() *DeleteSecurityGroupOK {\n\treturn &DeleteSecurityGroupOK{}\n}", "func (client *ManagedClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ManagedClustersClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ScriptExecutionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, privateCloudName string, scriptExecutionName string, options *ScriptExecutionsClientBeginDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateCloudName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateCloudName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateCloudName}\", url.PathEscape(privateCloudName))\n\tif scriptExecutionName == \"\" {\n\t\treturn nil, errors.New(\"parameter scriptExecutionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{scriptExecutionName}\", url.PathEscape(scriptExecutionName))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (obj *ShopSys) GroupDelete(input ShopGroup, _opt ...map[string]string) (output ResultCount, err error) {\n\tctx := context.Background()\n\treturn obj.GroupDeleteWithContext(ctx, input, _opt...)\n}" ]
[ "0.6350999", "0.6210928", "0.6089093", "0.6042023", "0.6032062", "0.6019282", "0.59526217", "0.5916635", "0.5828889", "0.58183795", "0.58183795", "0.5775107", "0.56965506", "0.5609115", "0.56069195", "0.55307055", "0.55185777", "0.5498397", "0.54778063", "0.54416555", "0.5410034", "0.53946894", "0.538106", "0.53780043", "0.5371178", "0.5369898", "0.53370947", "0.53127927", "0.5268267", "0.5264551", "0.5248842", "0.5241432", "0.52225673", "0.52115244", "0.5185894", "0.5180158", "0.516782", "0.5140397", "0.5139879", "0.5136518", "0.51287884", "0.50877494", "0.50854516", "0.5083756", "0.50802815", "0.50705844", "0.50502485", "0.5043913", "0.50366616", "0.5030508", "0.5026679", "0.50231487", "0.501981", "0.50071937", "0.49993718", "0.4994924", "0.4976547", "0.49765176", "0.49617976", "0.49561283", "0.49469352", "0.4942604", "0.4924374", "0.49204853", "0.49195856", "0.490731", "0.4885914", "0.48858756", "0.4885752", "0.48656845", "0.48498785", "0.48477057", "0.48462418", "0.48459503", "0.48296875", "0.48281667", "0.48276523", "0.48256338", "0.48237643", "0.48163393", "0.48113084", "0.48102286", "0.48065493", "0.48060635", "0.48041022", "0.4800253", "0.47996593", "0.47942805", "0.47938704", "0.47906488", "0.47855282", "0.4779093", "0.47644225", "0.47627434", "0.47594285", "0.4748504", "0.47473055", "0.47384572", "0.4738354", "0.47302598" ]
0.782387
0
getAtManagementGroupCreateRequest creates the GetAtManagementGroup request.
getAtManagementGroupCreateRequest создает запрос GetAtManagementGroup.
func (client *PolicyDefinitionsClient) getAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, options *PolicyDefinitionsGetAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" if policyDefinitionName == "" { return nil, errors.New("parameter policyDefinitionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *PolicyDefinitionsClient) listByManagementGroupCreateRequest(ctx context.Context, managementGroupID string, options *PolicyDefinitionsListByManagementGroupOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions\"\n\tif managementGroupID == \"\" {\n\t\treturn nil, errors.New(\"parameter managementGroupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementGroupId}\", url.PathEscape(managementGroupID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\tif options != nil && options.Top != nil {\n\t\treqQP.Set(\"$top\", strconv.FormatInt(int64(*options.Top), 10))\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tunencodedParams := []string{req.Raw().URL.RawQuery}\n\tif options != nil && options.Filter != nil {\n\t\tunencodedParams = append(unencodedParams, \"$filter=\"+*options.Filter)\n\t}\n\treq.Raw().URL.RawQuery = strings.Join(unencodedParams, \"&\")\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *PolicyDefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, parameters PolicyDefinition, options *PolicyDefinitionsCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}\"\n\tif policyDefinitionName == \"\" {\n\t\treturn nil, errors.New(\"parameter policyDefinitionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{policyDefinitionName}\", url.PathEscape(policyDefinitionName))\n\tif managementGroupID == \"\" {\n\t\treturn nil, errors.New(\"parameter managementGroupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementGroupId}\", url.PathEscape(managementGroupID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *PolicyDefinitionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, options *PolicyDefinitionsDeleteAtManagementGroupOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}\"\n\tif policyDefinitionName == \"\" {\n\t\treturn nil, errors.New(\"parameter policyDefinitionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{policyDefinitionName}\", url.PathEscape(policyDefinitionName))\n\tif managementGroupID == \"\" {\n\t\treturn nil, errors.New(\"parameter managementGroupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementGroupId}\", url.PathEscape(managementGroupID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ContainerGroupsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ContainerGroupsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *CustomAssessmentAutomationsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *CustomAssessmentAutomationsListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customAssessmentAutomations\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *IPAllocationsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *IPAllocationsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/IpAllocations\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClustersClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-11-08\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateDescribeContainerGroupMetricRequest() (request *DescribeContainerGroupMetricRequest) {\n\trequest = &DescribeContainerGroupMetricRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Eci\", \"2018-08-08\", \"DescribeContainerGroupMetric\", \"eci\", \"openAPI\")\n\treturn\n}", "func (client *GroupClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, options *GroupGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif groupID == \"\" {\n\t\treturn nil, errors.New(\"parameter groupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{groupId}\", url.PathEscape(groupID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *CapacitiesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *CapacitiesClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-01-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (c *UMemClient) NewCreateUMemcacheGroupRequest() *CreateUMemcacheGroupRequest {\n\treq := &CreateUMemcacheGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(false)\n\treturn req\n}", "func (client *ManagedInstancesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ManagedInstancesClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.Expand != nil {\n\t\treqQP.Set(\"$expand\", *options.Expand)\n\t}\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *VirtualNetworkTapsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *VirtualNetworkTapsListByResourceGroupOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkTaps\"\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-07-01\")\n\treq.URL.RawQuery = query.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *MonitorsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *MonitorsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *DiskEncryptionSetsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DiskEncryptionSetsListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *MetricAlertsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *MetricAlertsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ManagedClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ManagedClustersClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClustersListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func NewIgroupCreateRequest() *IgroupCreateRequest {\n\treturn &IgroupCreateRequest{}\n}", "func (client *IotSecuritySolutionClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *IotSecuritySolutionClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2019-08-01\")\n\tif options != nil && options.Filter != nil {\n\t\treqQP.Set(\"$filter\", *options.Filter)\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *LocalRulestacksClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *LocalRulestacksClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-29\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ContainerGroupsClient) getCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif containerGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter containerGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{containerGroupName}\", url.PathEscape(containerGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *DataCollectionEndpointsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DataCollectionEndpointsListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *DataCollectionEndpointsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DataCollectionEndpointsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *SpatialAnchorsAccountsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *SpatialAnchorsAccountsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MixedReality/spatialAnchorsAccounts\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-03-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ConnectedEnvironmentsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ConnectedEnvironmentsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *VirtualMachineImageTemplatesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *VirtualMachineImageTemplatesClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-10-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *DevicesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DevicesClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func CreateCreateApplicationGroupRequest() (request *CreateApplicationGroupRequest) {\n\trequest = &CreateApplicationGroupRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"oos\", \"2019-06-01\", \"CreateApplicationGroup\", \"oos\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *AccountsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AccountsClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ServersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ServersClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.Expand != nil {\n\t\treqQP.Set(\"$expand\", *options.Expand)\n\t}\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *CapacityReservationsClient) listByCapacityReservationGroupCreateRequest(ctx context.Context, resourceGroupName string, capacityReservationGroupName string, options *CapacityReservationsListByCapacityReservationGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif capacityReservationGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter capacityReservationGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{capacityReservationGroupName}\", url.PathEscape(capacityReservationGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *AlertProcessingRulesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AlertProcessingRulesClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-08\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *SQLVirtualMachinesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *SQLVirtualMachinesClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-03-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func CreateDescribeMultiContainerGroupMetricRequest() (request *DescribeMultiContainerGroupMetricRequest) {\n\trequest = &DescribeMultiContainerGroupMetricRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Eci\", \"2018-08-08\", \"DescribeMultiContainerGroupMetric\", \"eci\", \"openAPI\")\n\treturn\n}", "func (client *CertificateOrdersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *CertificateOrdersClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-09-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *AvailabilityGroupListenersClient) listByGroupCreateRequest(ctx context.Context, resourceGroupName string, sqlVirtualMachineGroupName string, options *AvailabilityGroupListenersClientListByGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/availabilityGroupListeners\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sqlVirtualMachineGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter sqlVirtualMachineGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sqlVirtualMachineGroupName}\", url.PathEscape(sqlVirtualMachineGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *VirtualMachinesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *VirtualMachinesClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-10-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *DedicatedHostsClient) listByHostGroupCreateRequest(ctx context.Context, resourceGroupName string, hostGroupName string, options *DedicatedHostsListByHostGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif hostGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter hostGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hostGroupName}\", url.PathEscape(hostGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *PrivateDNSZoneGroupsClient) getCreateRequest(ctx context.Context, resourceGroupName string, privateEndpointName string, privateDNSZoneGroupName string, options *PrivateDNSZoneGroupsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateEndpoints/{privateEndpointName}/privateDnsZoneGroups/{privateDnsZoneGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateEndpointName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateEndpointName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateEndpointName}\", url.PathEscape(privateEndpointName))\n\tif privateDNSZoneGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateDNSZoneGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateDnsZoneGroupName}\", url.PathEscape(privateDNSZoneGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateDescribeScalingGroupsRequest() (request *DescribeScalingGroupsRequest) {\n\trequest = &DescribeScalingGroupsRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Ess\", \"2014-08-28\", \"DescribeScalingGroups\", \"ess\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func CreateCreateMonitorGroupRequest() (request *CreateMonitorGroupRequest) {\n\trequest = &CreateMonitorGroupRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Cms\", \"2019-01-01\", \"CreateMonitorGroup\", \"cms\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *DedicatedHostsClient) listByHostGroupCreateRequest(ctx context.Context, resourceGroupName string, hostGroupName string, options *DedicatedHostsListByHostGroupOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts\"\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{hostGroupName}\", url.PathEscape(hostGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-06-01\")\n\treq.URL.RawQuery = query.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *RedisClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *RedisListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-12-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *SyncGroupsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serverName string, databaseName string, syncGroupName string, options *SyncGroupsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serverName == \"\" {\n\t\treturn nil, errors.New(\"parameter serverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serverName}\", url.PathEscape(serverName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif syncGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter syncGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{syncGroupName}\", url.PathEscape(syncGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (c *UDBClient) NewCreateUDBParamGroupRequest() *CreateUDBParamGroupRequest {\n\treq := &CreateUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(false)\n\treturn req\n}", "func (c *UDBClient) NewCreateUDBParamGroupRequest() *CreateUDBParamGroupRequest {\n\treq := &CreateUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(false)\n\treturn req\n}", "func (client *WorkspacesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *WorkspacesListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func CreateDeleteCorpGroupRequest() (request *DeleteCorpGroupRequest) {\n\trequest = &DeleteCorpGroupRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Vcs\", \"2020-05-15\", \"DeleteCorpGroup\", \"\", \"\")\n\trequest.Method = requests.POST\n\treturn\n}", "func CreateGetHotlineGroupDetailReportRequest() (request *GetHotlineGroupDetailReportRequest) {\n\trequest = &GetHotlineGroupDetailReportRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"scsp\", \"2020-07-02\", \"GetHotlineGroupDetailReport\", \"\", \"\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *GroupClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, options *GroupGetEntityTagOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif groupID == \"\" {\n\t\treturn nil, errors.New(\"parameter groupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{groupId}\", url.PathEscape(groupID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodHead, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *VirtualRoutersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *VirtualRoutersClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualRouters\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ContainerGroupsClient) listCreateRequest(ctx context.Context, options *ContainerGroupsClientListOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroups\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *GroupClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, parameters GroupCreateParameters, options *GroupCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif groupID == \"\" {\n\t\treturn nil, errors.New(\"parameter groupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{groupId}\", url.PathEscape(groupID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfMatch != nil {\n\t\treq.Raw().Header.Set(\"If-Match\", *options.IfMatch)\n\t}\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *LongTermRetentionManagedInstanceBackupsClient) getByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, locationName string, managedInstanceName string, databaseName string, backupName string, options *LongTermRetentionManagedInstanceBackupsGetByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionDatabases/{databaseName}/longTermRetentionManagedInstanceBackups/{backupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif locationName == \"\" {\n\t\treturn nil, errors.New(\"parameter locationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{locationName}\", url.PathEscape(locationName))\n\tif managedInstanceName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedInstanceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedInstanceName}\", url.PathEscape(managedInstanceName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif backupName == \"\" {\n\t\treturn nil, errors.New(\"parameter backupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{backupName}\", url.PathEscape(backupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *CassandraClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *CassandraClustersClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-03-15-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *VirtualMachineScaleSetsClient) convertToSinglePlacementGroupCreateRequest(ctx context.Context, resourceGroupName string, vmScaleSetName string, parameters VMScaleSetConvertToSinglePlacementGroupInput, options *VirtualMachineScaleSetsConvertToSinglePlacementGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif vmScaleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter vmScaleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vmScaleSetName}\", url.PathEscape(vmScaleSetName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treturn req, runtime.MarshalAsJSON(req, parameters)\n}", "func (client *ServersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroup string, options *ServersClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.FluidRelay/fluidRelayServers\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroup == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroup cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroup}\", url.PathEscape(resourceGroup))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ContainerGroupsClient) startCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsClientBeginStartOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif containerGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter containerGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{containerGroupName}\", url.PathEscape(containerGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateCreateMonitorGroupByResourceGroupIdRequest() (request *CreateMonitorGroupByResourceGroupIdRequest) {\n\trequest = &CreateMonitorGroupByResourceGroupIdRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Cms\", \"2019-01-01\", \"CreateMonitorGroupByResourceGroupId\", \"cms\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *PrivateDNSZoneGroupsClient) listCreateRequest(ctx context.Context, privateEndpointName string, resourceGroupName string, options *PrivateDNSZoneGroupsClientListOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateEndpoints/{privateEndpointName}/privateDnsZoneGroups\"\n\tif privateEndpointName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateEndpointName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateEndpointName}\", url.PathEscape(privateEndpointName))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ClustersClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-11-08\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ContainerGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, containerGroup ContainerGroup, options *ContainerGroupsClientBeginCreateOrUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif containerGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter containerGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{containerGroupName}\", url.PathEscape(containerGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, containerGroup)\n}", "func (client *GroupClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *GroupListByServiceOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.Filter != nil {\n\t\treqQP.Set(\"$filter\", *options.Filter)\n\t}\n\tif options != nil && options.Top != nil {\n\t\treqQP.Set(\"$top\", strconv.FormatInt(int64(*options.Top), 10))\n\t}\n\tif options != nil && options.Skip != nil {\n\t\treqQP.Set(\"$skip\", strconv.FormatInt(int64(*options.Skip), 10))\n\t}\n\treqQP.Set(\"api-version\", \"2021-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *AvailabilitySetsClient) getCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetName string, options *AvailabilitySetsGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif availabilitySetName == \"\" {\n\t\treturn nil, errors.New(\"parameter availabilitySetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{availabilitySetName}\", url.PathEscape(availabilitySetName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *GroupClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string, options *GroupDeleteOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif groupID == \"\" {\n\t\treturn nil, errors.New(\"parameter groupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{groupId}\", url.PathEscape(groupID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"If-Match\", ifMatch)\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client IdentityClient) createGroup(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodPost, \"/groups\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response CreateGroupResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (client *ManagementAssociationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, managementAssociationName string, options *ManagementAssociationsGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.providerName == \"\" {\n\t\treturn nil, errors.New(\"parameter client.providerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{providerName}\", url.PathEscape(client.providerName))\n\tif client.resourceType == \"\" {\n\t\treturn nil, errors.New(\"parameter client.resourceType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceType}\", url.PathEscape(client.resourceType))\n\tif client.resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter client.resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(client.resourceName))\n\tif managementAssociationName == \"\" {\n\t\treturn nil, errors.New(\"parameter managementAssociationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementAssociationName}\", url.PathEscape(managementAssociationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2015-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func NewAttachGroupPolicyRequestWithoutParam() *AttachGroupPolicyRequest {\n\n return &AttachGroupPolicyRequest{\n JDCloudRequest: core.JDCloudRequest{\n URL: \"/group/{groupName}:attachGroupPolicy\",\n Method: \"POST\",\n Header: nil,\n Version: \"v1\",\n },\n }\n}", "func (client *WebAppsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *WebAppsListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.IncludeSlots != nil {\n\t\treqQP.Set(\"includeSlots\", strconv.FormatBool(*options.IncludeSlots))\n\t}\n\treqQP.Set(\"api-version\", \"2021-02-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (m *MockRDSAPI) CreateOptionGroupRequest(arg0 *rds.CreateOptionGroupInput) (*request.Request, *rds.CreateOptionGroupOutput) {\n\tret := m.ctrl.Call(m, \"CreateOptionGroupRequest\", arg0)\n\tret0, _ := ret[0].(*request.Request)\n\tret1, _ := ret[1].(*rds.CreateOptionGroupOutput)\n\treturn ret0, ret1\n}", "func (client *SQLVirtualMachinesClient) listBySQLVMGroupCreateRequest(ctx context.Context, resourceGroupName string, sqlVirtualMachineGroupName string, options *SQLVirtualMachinesClientListBySQLVMGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/{sqlVirtualMachineGroupName}/sqlVirtualMachines\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sqlVirtualMachineGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter sqlVirtualMachineGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sqlVirtualMachineGroupName}\", url.PathEscape(sqlVirtualMachineGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-03-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *IPAllocationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, ipAllocationName string, options *IPAllocationsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/IpAllocations/{ipAllocationName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif ipAllocationName == \"\" {\n\t\treturn nil, errors.New(\"parameter ipAllocationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ipAllocationName}\", url.PathEscape(ipAllocationName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\tif options != nil && options.Expand != nil {\n\t\treqQP.Set(\"$expand\", *options.Expand)\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func createGroup() (group resources.Group, err error) {\n\tgroupsClient := resources.NewGroupsClient(config.SubscriptionID)\n\tgroupsClient.Authorizer = autorest.NewBearerAuthorizer(token)\n\n\treturn groupsClient.CreateOrUpdate(\n\t\tctx,\n\t\tresourceGroupName,\n\t\tresources.Group{\n\t\t\tLocation: to.StringPtr(resourceGroupLocation)})\n}", "func (client *MonitoringSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *MonitoringSettingsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func NewDeploymentAtManagementGroupScope(ctx *pulumi.Context,\n\tname string, args *DeploymentAtManagementGroupScopeArgs, opts ...pulumi.ResourceOption) (*DeploymentAtManagementGroupScope, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.GroupId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'GroupId'\")\n\t}\n\tif args.Properties == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Properties'\")\n\t}\n\taliases := pulumi.Aliases([]pulumi.Alias{\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20190501:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20190510:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20190510:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20190701:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20190701:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20190801:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20190801:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20191001:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20191001:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20200601:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20200601:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20200801:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20200801:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20201001:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20201001:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20210101:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20210101:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:resources/v20210401:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:resources/v20210401:DeploymentAtManagementGroupScope\"),\n\t\t},\n\t})\n\topts = append(opts, aliases)\n\tvar resource DeploymentAtManagementGroupScope\n\terr := ctx.RegisterResource(\"azure-native:resources/v20190501:DeploymentAtManagementGroupScope\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func BuildCreatePermissionGroupIn() *model.CreatePermissionGroupIn {\n\treturn &model.CreatePermissionGroupIn{\n\t\tName: *RandomString(10),\n\t\tDescription: RandomString(20),\n\t\tPermissions: []model.Permission{\n\t\t\tmodel.PermissionUser,\n\t\t\tmodel.PermissionPermissionGroup,\n\t\t},\n\t}\n}", "func (client *FactoriesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *FactoriesClientListByResourceGroupOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreatePutMetricAlarmRequest() (request *PutMetricAlarmRequest) {\n\trequest = &PutMetricAlarmRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Cms\", \"2018-03-08\", \"PutMetricAlarm\", \"cms\", \"openAPI\")\n\treturn\n}", "func (gr *GroupResource) Create(owner string, name string) (g *GroupDetails, err error) {\n\townerOrCurrentUser(gr, &owner)\n\n\tpath := fmt.Sprintf(\"/groups/%s/\", owner)\n\tvalues := url.Values{}\n\tvalues.Set(\"name\", name)\n\terr = gr.client.do(\"POST\", path, nil, values, &g)\n\n\treturn\n}", "func (client *AvailabilitySetsClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *AvailabilitySetsListOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func CreateModifySkillGroupExRequest() (request *ModifySkillGroupExRequest) {\n\trequest = &ModifySkillGroupExRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"CloudCallCenter\", \"2017-07-05\", \"ModifySkillGroupEx\", \"\", \"\")\n\trequest.Method = requests.POST\n\treturn\n}", "func CreateRemoveAppGroupRequest() (request *RemoveAppGroupRequest) {\n\trequest = &RemoveAppGroupRequest{\n\t\tRoaRequest: &requests.RoaRequest{},\n\t}\n\trequest.InitWithApiInfo(\"OpenSearch\", \"2017-12-25\", \"RemoveAppGroup\", \"/v4/openapi/app-groups/[appGroupIdentity]\", \"\", \"\")\n\trequest.Method = requests.DELETE\n\treturn\n}", "func (client *MonitorsClient) getCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif monitorName == \"\" {\n\t\treturn nil, errors.New(\"parameter monitorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{monitorName}\", url.PathEscape(monitorName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ClustersClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *DeviceSettingsClient) getSecuritySettingsCreateRequest(ctx context.Context, deviceName string, resourceGroupName string, managerName string, options *DeviceSettingsClientGetSecuritySettingsOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/securitySettings/default\"\n\turlPath = strings.ReplaceAll(urlPath, \"{deviceName}\", deviceName)\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", client.subscriptionID)\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", resourceGroupName)\n\turlPath = strings.ReplaceAll(urlPath, \"{managerName}\", managerName)\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (_BaseContentSpace *BaseContentSpaceTransactor) CreateGroup(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _BaseContentSpace.contract.Transact(opts, \"createGroup\")\n}", "func (c *UDBClient) NewExtractUDBParamGroupRequest() *ExtractUDBParamGroupRequest {\n\treq := &ExtractUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(true)\n\treturn req\n}", "func (c *UDBClient) NewExtractUDBParamGroupRequest() *ExtractUDBParamGroupRequest {\n\treq := &ExtractUDBParamGroupRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(true)\n\treturn req\n}", "func (client *CapacitiesClient) getDetailsCreateRequest(ctx context.Context, resourceGroupName string, dedicatedCapacityName string, options *CapacitiesClientGetDetailsOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif dedicatedCapacityName == \"\" {\n\t\treturn nil, errors.New(\"parameter dedicatedCapacityName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{dedicatedCapacityName}\", url.PathEscape(dedicatedCapacityName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-01-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateGetManagedRuleRequest() (request *GetManagedRuleRequest) {\n\trequest = &GetManagedRuleRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Config\", \"2020-09-07\", \"GetManagedRule\", \"\", \"\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *CapacityReservationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, capacityReservationGroupName string, capacityReservationName string, options *CapacityReservationsGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif capacityReservationGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter capacityReservationGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{capacityReservationGroupName}\", url.PathEscape(capacityReservationGroupName))\n\tif capacityReservationName == \"\" {\n\t\treturn nil, errors.New(\"parameter capacityReservationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{capacityReservationName}\", url.PathEscape(capacityReservationName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.Expand != nil {\n\t\treqQP.Set(\"$expand\", string(*options.Expand))\n\t}\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *LocalRulestacksClient) getSupportInfoCreateRequest(ctx context.Context, resourceGroupName string, localRulestackName string, options *LocalRulestacksClientGetSupportInfoOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}/getSupportInfo\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif localRulestackName == \"\" {\n\t\treturn nil, errors.New(\"parameter localRulestackName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{localRulestackName}\", url.PathEscape(localRulestackName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-29\")\n\tif options != nil && options.Email != nil {\n\t\treqQP.Set(\"email\", *options.Email)\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ClientImpl) CreateControlInGroup(ctx context.Context, args CreateControlInGroupArgs) (*Control, error) {\n\tif args.Control == nil {\n\t\treturn nil, &azuredevops.ArgumentNilError{ArgumentName: \"args.Control\"}\n\t}\n\trouteValues := make(map[string]string)\n\tif args.ProcessId == nil {\n\t\treturn nil, &azuredevops.ArgumentNilError{ArgumentName: \"args.ProcessId\"}\n\t}\n\trouteValues[\"processId\"] = (*args.ProcessId).String()\n\tif args.WitRefName == nil || *args.WitRefName == \"\" {\n\t\treturn nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: \"args.WitRefName\"}\n\t}\n\trouteValues[\"witRefName\"] = *args.WitRefName\n\tif args.GroupId == nil || *args.GroupId == \"\" {\n\t\treturn nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: \"args.GroupId\"}\n\t}\n\trouteValues[\"groupId\"] = *args.GroupId\n\n\tbody, marshalErr := json.Marshal(*args.Control)\n\tif marshalErr != nil {\n\t\treturn nil, marshalErr\n\t}\n\tlocationId, _ := uuid.Parse(\"1f59b363-a2d0-4b7e-9bc6-eb9f5f3f0e58\")\n\tresp, err := client.Client.Send(ctx, http.MethodPost, locationId, \"6.0-preview.1\", routeValues, nil, bytes.NewReader(body), \"application/json\", \"application/json\", nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar responseValue Control\n\terr = client.Client.UnmarshalBody(resp, &responseValue)\n\treturn &responseValue, err\n}", "func NewIgroupAddRequest() *IgroupAddRequest {\n\treturn &IgroupAddRequest{}\n}", "func (client *SapMonitorsClient) getCreateRequest(ctx context.Context, resourceGroupName string, sapMonitorName string, options *SapMonitorsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HanaOnAzure/sapMonitors/{sapMonitorName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sapMonitorName == \"\" {\n\t\treturn nil, errors.New(\"parameter sapMonitorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sapMonitorName}\", url.PathEscape(sapMonitorName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-02-07-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *LocalRulestacksClient) getCreateRequest(ctx context.Context, resourceGroupName string, localRulestackName string, options *LocalRulestacksClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif localRulestackName == \"\" {\n\t\treturn nil, errors.New(\"parameter localRulestackName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{localRulestackName}\", url.PathEscape(localRulestackName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-29\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateGetAggregateAccountComplianceByPackRequest() (request *GetAggregateAccountComplianceByPackRequest) {\n\trequest = &GetAggregateAccountComplianceByPackRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Config\", \"2020-09-07\", \"GetAggregateAccountComplianceByPack\", \"\", \"\")\n\trequest.Method = requests.GET\n\treturn\n}", "func (client *VirtualMachineScaleSetsClient) getCreateRequest(ctx context.Context, resourceGroupName string, vmScaleSetName string, options *VirtualMachineScaleSetsGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif vmScaleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter vmScaleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vmScaleSetName}\", url.PathEscape(vmScaleSetName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\tif options != nil && options.Expand != nil {\n\t\treqQP.Set(\"$expand\", string(*options.Expand))\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ManagedInstancesClient) getCreateRequest(ctx context.Context, resourceGroupName string, managedInstanceName string, options *ManagedInstancesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif managedInstanceName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedInstanceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedInstanceName}\", url.PathEscape(managedInstanceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.Expand != nil {\n\t\treqQP.Set(\"$expand\", *options.Expand)\n\t}\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}" ]
[ "0.6663986", "0.6623923", "0.6412561", "0.6097547", "0.6086163", "0.6060779", "0.60292196", "0.5974149", "0.5945237", "0.5898692", "0.58942294", "0.58754694", "0.5872743", "0.5866616", "0.5856541", "0.58479375", "0.5844044", "0.58033", "0.5794953", "0.57581514", "0.57564795", "0.57081884", "0.5683718", "0.5651301", "0.5624999", "0.5615734", "0.5613474", "0.55924493", "0.5590977", "0.5536184", "0.55115426", "0.55091184", "0.5484719", "0.54802924", "0.54756844", "0.54740506", "0.5473192", "0.54478455", "0.54227704", "0.5422121", "0.5419113", "0.5380115", "0.5330929", "0.5329952", "0.52945894", "0.5283524", "0.5283524", "0.5245733", "0.5237009", "0.5234577", "0.52311784", "0.52190703", "0.5198627", "0.51871955", "0.5183274", "0.5169765", "0.5153166", "0.51477003", "0.51390254", "0.5131131", "0.51223123", "0.5114582", "0.5104254", "0.5102861", "0.509227", "0.50834304", "0.508195", "0.507398", "0.5069806", "0.5065219", "0.50592524", "0.50563496", "0.5042287", "0.50223005", "0.5005109", "0.49888012", "0.49637255", "0.49575073", "0.49393028", "0.49265504", "0.49102217", "0.49085715", "0.49048874", "0.48874304", "0.4883695", "0.48799044", "0.48714423", "0.48580056", "0.48580056", "0.48552725", "0.48473176", "0.4831095", "0.4827814", "0.48144203", "0.48138165", "0.48129973", "0.48102948", "0.48007643", "0.4799372", "0.47958806" ]
0.77720493
0
getAtManagementGroupHandleResponse handles the GetAtManagementGroup response.
getAtManagementGroupHandleResponse обрабатывает ответ GetAtManagementGroup.
func (client *PolicyDefinitionsClient) getAtManagementGroupHandleResponse(resp *http.Response) (PolicyDefinitionsGetAtManagementGroupResponse, error) { result := PolicyDefinitionsGetAtManagementGroupResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.PolicyDefinition); err != nil { return PolicyDefinitionsGetAtManagementGroupResponse{}, runtime.NewResponseError(err, resp) } return result, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *PolicyDefinitionsClient) listByManagementGroupHandleResponse(resp *http.Response) (PolicyDefinitionsListByManagementGroupResponse, error) {\n\tresult := PolicyDefinitionsListByManagementGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PolicyDefinitionListResult); err != nil {\n\t\treturn PolicyDefinitionsListByManagementGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *LongTermRetentionManagedInstanceBackupsClient) getByResourceGroupHandleResponse(resp *http.Response) (LongTermRetentionManagedInstanceBackupsGetByResourceGroupResponse, error) {\n\tresult := LongTermRetentionManagedInstanceBackupsGetByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedInstanceLongTermRetentionBackup); err != nil {\n\t\treturn LongTermRetentionManagedInstanceBackupsGetByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ContainerGroupsClient) listByResourceGroupHandleResponse(resp *http.Response) (ContainerGroupsClientListByResourceGroupResponse, error) {\n\tresult := ContainerGroupsClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroupListResult); err != nil {\n\t\treturn ContainerGroupsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ManagedInstancesClient) listByResourceGroupHandleResponse(resp *http.Response) (ManagedInstancesClientListByResourceGroupResponse, error) {\n\tresult := ManagedInstancesClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedInstanceListResult); err != nil {\n\t\treturn ManagedInstancesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *MetricAlertsClient) listByResourceGroupHandleResponse(resp *http.Response) (MetricAlertsClientListByResourceGroupResponse, error) {\n\tresult := MetricAlertsClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.MetricAlertResourceCollection); err != nil {\n\t\treturn MetricAlertsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *CapacitiesClient) listByResourceGroupHandleResponse(resp *http.Response) (CapacitiesClientListByResourceGroupResponse, error) {\n\tresult := CapacitiesClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DedicatedCapacities); err != nil {\n\t\treturn CapacitiesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DiskEncryptionSetsClient) listByResourceGroupHandleResponse(resp *http.Response) (DiskEncryptionSetsListByResourceGroupResponse, error) {\n\tresult := DiskEncryptionSetsListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DiskEncryptionSetList); err != nil {\n\t\treturn DiskEncryptionSetsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ManagedClustersClient) listByResourceGroupHandleResponse(resp *http.Response) (ManagedClustersClientListByResourceGroupResponse, error) {\n\tresult := ManagedClustersClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedClusterListResult); err != nil {\n\t\treturn ManagedClustersClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *CustomAssessmentAutomationsClient) listByResourceGroupHandleResponse(resp *http.Response) (CustomAssessmentAutomationsListByResourceGroupResponse, error) {\n\tresult := CustomAssessmentAutomationsListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.CustomAssessmentAutomationsListResult); err != nil {\n\t\treturn CustomAssessmentAutomationsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *IPAllocationsClient) listByResourceGroupHandleResponse(resp *http.Response) (IPAllocationsClientListByResourceGroupResponse, error) {\n\tresult := IPAllocationsClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.IPAllocationListResult); err != nil {\n\t\treturn IPAllocationsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *PolicyDefinitionsClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse, error) {\n\tresult := PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PolicyDefinition); err != nil {\n\t\treturn PolicyDefinitionsCreateOrUpdateAtManagementGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *RedisClient) listByResourceGroupHandleResponse(resp *http.Response) (RedisListByResourceGroupResponse, error) {\n\tresult := RedisListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RedisListResult); err != nil {\n\t\treturn RedisListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *VirtualMachineImageTemplatesClient) listByResourceGroupHandleResponse(resp *http.Response) (VirtualMachineImageTemplatesClientListByResourceGroupResponse, error) {\n\tresult := VirtualMachineImageTemplatesClientListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ImageTemplateListResult); err != nil {\n\t\treturn VirtualMachineImageTemplatesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DevicesClient) listByResourceGroupHandleResponse(resp *http.Response) (DevicesClientListByResourceGroupResponse, error) {\n\tresult := DevicesClientListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DeviceListResult); err != nil {\n\t\treturn DevicesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *MonitorsClient) listByResourceGroupHandleResponse(resp *http.Response) (MonitorsClientListByResourceGroupResponse, error) {\n\tresult := MonitorsClientListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.MonitorResourceListResponse); err != nil {\n\t\treturn MonitorsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *VirtualNetworkTapsClient) listByResourceGroupHandleResponse(resp *azcore.Response) (VirtualNetworkTapListResultResponse, error) {\n\tvar val *VirtualNetworkTapListResult\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn VirtualNetworkTapListResultResponse{}, err\n\t}\n\treturn VirtualNetworkTapListResultResponse{RawResponse: resp.Response, VirtualNetworkTapListResult: val}, nil\n}", "func (client *ContainerGroupsClient) getHandleResponse(resp *http.Response) (ContainerGroupsClientGetResponse, error) {\n\tresult := ContainerGroupsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroup); err != nil {\n\t\treturn ContainerGroupsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *PrivateDNSZoneGroupsClient) getHandleResponse(resp *http.Response) (PrivateDNSZoneGroupsClientGetResponse, error) {\n\tresult := PrivateDNSZoneGroupsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PrivateDNSZoneGroup); err != nil {\n\t\treturn PrivateDNSZoneGroupsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ClustersClient) listByResourceGroupHandleResponse(resp *http.Response) (ClustersListByResourceGroupResponse, error) {\n\tresult := ClustersListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ClusterListResult); err != nil {\n\t\treturn ClustersListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ConnectedEnvironmentsClient) listByResourceGroupHandleResponse(resp *http.Response) (ConnectedEnvironmentsClientListByResourceGroupResponse, error) {\n\tresult := ConnectedEnvironmentsClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ConnectedEnvironmentCollection); err != nil {\n\t\treturn ConnectedEnvironmentsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *SpatialAnchorsAccountsClient) listByResourceGroupHandleResponse(resp *http.Response) (SpatialAnchorsAccountsClientListByResourceGroupResponse, error) {\n\tresult := SpatialAnchorsAccountsClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SpatialAnchorsAccountPage); err != nil {\n\t\treturn SpatialAnchorsAccountsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ClustersClient) listByResourceGroupHandleResponse(resp *http.Response) (ClustersClientListByResourceGroupResponse, error) {\n\tresult := ClustersClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ClusterListResult); err != nil {\n\t\treturn ClustersClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *IotSecuritySolutionClient) listByResourceGroupHandleResponse(resp *http.Response) (IotSecuritySolutionClientListByResourceGroupResponse, error) {\n\tresult := IotSecuritySolutionClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.IoTSecuritySolutionsList); err != nil {\n\t\treturn IotSecuritySolutionClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *CertificateOrdersClient) listByResourceGroupHandleResponse(resp *http.Response) (CertificateOrdersClientListByResourceGroupResponse, error) {\n\tresult := CertificateOrdersClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.CertificateOrderCollection); err != nil {\n\t\treturn CertificateOrdersClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *CassandraClustersClient) listByResourceGroupHandleResponse(resp *http.Response) (CassandraClustersClientListByResourceGroupResponse, error) {\n\tresult := CassandraClustersClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ListClusters); err != nil {\n\t\treturn CassandraClustersClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DataCollectionEndpointsClient) listByResourceGroupHandleResponse(resp *http.Response) (DataCollectionEndpointsListByResourceGroupResponse, error) {\n\tresult := DataCollectionEndpointsListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DataCollectionEndpointResourceListResult); err != nil {\n\t\treturn DataCollectionEndpointsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *SyncGroupsClient) getHandleResponse(resp *http.Response) (SyncGroupsClientGetResponse, error) {\n\tresult := SyncGroupsClientGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SyncGroup); err != nil {\n\t\treturn SyncGroupsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DataCollectionEndpointsClient) listByResourceGroupHandleResponse(resp *http.Response) (DataCollectionEndpointsClientListByResourceGroupResponse, error) {\n\tresult := DataCollectionEndpointsClientListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DataCollectionEndpointResourceListResult); err != nil {\n\t\treturn DataCollectionEndpointsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *LocalRulestacksClient) listByResourceGroupHandleResponse(resp *http.Response) (LocalRulestacksClientListByResourceGroupResponse, error) {\n\tresult := LocalRulestacksClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.LocalRulestackResourceListResult); err != nil {\n\t\treturn LocalRulestacksClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) listByResourceGroupHandleResponse(resp *http.Response) (WebAppsListByResourceGroupResponse, error) {\n\tresult := WebAppsListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.WebAppCollection); err != nil {\n\t\treturn WebAppsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ServersClient) listByResourceGroupHandleResponse(resp *http.Response) (ServersClientListByResourceGroupResponse, error) {\n\tresult := ServersClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ServerListResult); err != nil {\n\t\treturn ServersClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *VirtualMachinesClient) listByResourceGroupHandleResponse(resp *http.Response) (VirtualMachinesClientListByResourceGroupResponse, error) {\n\tresult := VirtualMachinesClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachinesList); err != nil {\n\t\treturn VirtualMachinesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *AccountsClient) listByResourceGroupHandleResponse(resp *http.Response) (AccountsClientListByResourceGroupResponse, error) {\n\tresult := AccountsClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AccountListResult); err != nil {\n\t\treturn AccountsClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *SQLVirtualMachinesClient) listByResourceGroupHandleResponse(resp *http.Response) (SQLVirtualMachinesClientListByResourceGroupResponse, error) {\n\tresult := SQLVirtualMachinesClientListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ListResult); err != nil {\n\t\treturn SQLVirtualMachinesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ServersClient) listByResourceGroupHandleResponse(resp *http.Response) (ServersClientListByResourceGroupResponse, error) {\n\tresult := ServersClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ServerList); err != nil {\n\t\treturn ServersClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *AlertProcessingRulesClient) listByResourceGroupHandleResponse(resp *http.Response) (AlertProcessingRulesClientListByResourceGroupResponse, error) {\n\tresult := AlertProcessingRulesClientListByResourceGroupResponse{RawResponse: resp}\n\tif val := resp.Header.Get(\"x-ms-request-id\"); val != \"\" {\n\t\tresult.XMSRequestID = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AlertProcessingRulesList); err != nil {\n\t\treturn AlertProcessingRulesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *VirtualRoutersClient) listByResourceGroupHandleResponse(resp *http.Response) (VirtualRoutersClientListByResourceGroupResponse, error) {\n\tresult := VirtualRoutersClientListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VirtualRouterListResult); err != nil {\n\t\treturn VirtualRoutersClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WorkspacesClient) listByResourceGroupHandleResponse(resp *http.Response) (WorkspacesListByResourceGroupResponse, error) {\n\tresult := WorkspacesListByResourceGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceListResult); err != nil {\n\t\treturn WorkspacesListByResourceGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *GroupClient) getHandleResponse(resp *http.Response) (GroupGetResponse, error) {\n\tresult := GroupGetResponse{RawResponse: resp}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.GroupContract); err != nil {\n\t\treturn GroupGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client UsageDetailsClient) ListByManagementGroupResponder(resp *http.Response) (result UsageDetailsListResult, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tclient.ByInspecting(),\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client *ContainerGroupsClient) updateHandleResponse(resp *http.Response) (ContainerGroupsClientUpdateResponse, error) {\n\tresult := ContainerGroupsClientUpdateResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroup); err != nil {\n\t\treturn ContainerGroupsClientUpdateResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DedicatedHostsClient) listByHostGroupHandleResponse(resp *http.Response) (DedicatedHostsListByHostGroupResponse, error) {\n\tresult := DedicatedHostsListByHostGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DedicatedHostListResult); err != nil {\n\t\treturn DedicatedHostsListByHostGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *CapacityReservationsClient) listByCapacityReservationGroupHandleResponse(resp *http.Response) (CapacityReservationsListByCapacityReservationGroupResponse, error) {\n\tresult := CapacityReservationsListByCapacityReservationGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.CapacityReservationListResult); err != nil {\n\t\treturn CapacityReservationsListByCapacityReservationGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *SQLVirtualMachinesClient) listBySQLVMGroupHandleResponse(resp *http.Response) (SQLVirtualMachinesClientListBySQLVMGroupResponse, error) {\n\tresult := SQLVirtualMachinesClientListBySQLVMGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ListResult); err != nil {\n\t\treturn SQLVirtualMachinesClientListBySQLVMGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DedicatedHostsClient) listByHostGroupHandleResponse(resp *azcore.Response) (DedicatedHostListResultResponse, error) {\n\tvar val *DedicatedHostListResult\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn DedicatedHostListResultResponse{}, err\n\t}\n\treturn DedicatedHostListResultResponse{RawResponse: resp.Response, DedicatedHostListResult: val}, nil\n}", "func (client WorkloadNetworksClient) GetVMGroupResponder(resp *http.Response) (result WorkloadNetworkVMGroup, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client *GroupClient) listByServiceHandleResponse(resp *http.Response) (GroupListByServiceResponse, error) {\n\tresult := GroupListByServiceResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.GroupCollection); err != nil {\n\t\treturn GroupListByServiceResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ContainerGroupsClient) listHandleResponse(resp *http.Response) (ContainerGroupsClientListResponse, error) {\n\tresult := ContainerGroupsClientListResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroupListResult); err != nil {\n\t\treturn ContainerGroupsClientListResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *AvailabilityGroupListenersClient) listByGroupHandleResponse(resp *http.Response) (AvailabilityGroupListenersClientListByGroupResponse, error) {\n\tresult := AvailabilityGroupListenersClientListByGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AvailabilityGroupListenerListResult); err != nil {\n\t\treturn AvailabilityGroupListenersClientListByGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client IotHubResourceClient) GetEventHubConsumerGroupResponder(resp *http.Response) (result EventHubConsumerGroupInfo, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client *FactoriesClient) listByResourceGroupHandleResponse(resp *http.Response) (FactoriesClientListByResourceGroupResponse, error) {\n\tresult := FactoriesClientListByResourceGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.FactoryListResponse); err != nil {\n\t\treturn FactoriesClientListByResourceGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *PrivateDNSZoneGroupsClient) listHandleResponse(resp *http.Response) (PrivateDNSZoneGroupsClientListResponse, error) {\n\tresult := PrivateDNSZoneGroupsClientListResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PrivateDNSZoneGroupListResult); err != nil {\n\t\treturn PrivateDNSZoneGroupsClientListResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *GroupClient) updateHandleResponse(resp *http.Response) (GroupUpdateResponse, error) {\n\tresult := GroupUpdateResponse{RawResponse: resp}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.GroupContract); err != nil {\n\t\treturn GroupUpdateResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (gppr GetPathPropertiesResponse) XMsGroup() string {\n\treturn gppr.rawResponse.Header.Get(\"x-ms-group\")\n}", "func (client *LongTermRetentionManagedInstanceBackupsClient) listByResourceGroupInstanceHandleResponse(resp *http.Response) (LongTermRetentionManagedInstanceBackupsListByResourceGroupInstanceResponse, error) {\n\tresult := LongTermRetentionManagedInstanceBackupsListByResourceGroupInstanceResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedInstanceLongTermRetentionBackupListResult); err != nil {\n\t\treturn LongTermRetentionManagedInstanceBackupsListByResourceGroupInstanceResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *SchemaRegistryClient) getHandleResponse(resp *http.Response) (SchemaRegistryClientGetResponse, error) {\n\tresult := SchemaRegistryClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SchemaGroup); err != nil {\n\t\treturn SchemaRegistryClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client AccountClient) ListByResourceGroupResponder(resp *http.Response) (result AccountResourceDescriptionList, err error) {\n err = autorest.Respond(\n resp,\n azure.WithErrorUnlessStatusCode(http.StatusOK),\n autorest.ByUnmarshallingJSON(&result),\n autorest.ByClosing())\n result.Response = autorest.Response{Response: resp}\n return\n }", "func (c ActionGroupsAPIsClient) responderForActionGroupsGetTestNotificationsAtActionGroupResourceLevel(resp *http.Response) (result ActionGroupsGetTestNotificationsAtActionGroupResourceLevelOperationResponse, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result.Model),\n\t\tautorest.ByClosing())\n\tresult.HttpResponse = resp\n\n\treturn\n}", "func (client *LongTermRetentionManagedInstanceBackupsClient) listByResourceGroupLocationHandleResponse(resp *http.Response) (LongTermRetentionManagedInstanceBackupsListByResourceGroupLocationResponse, error) {\n\tresult := LongTermRetentionManagedInstanceBackupsListByResourceGroupLocationResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedInstanceLongTermRetentionBackupListResult); err != nil {\n\t\treturn LongTermRetentionManagedInstanceBackupsListByResourceGroupLocationResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *HardwareComponentGroupsClient) listByDeviceHandleResponse(resp *http.Response) (HardwareComponentGroupsClientListByDeviceResponse, error) {\n\tresult := HardwareComponentGroupsClientListByDeviceResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.HardwareComponentGroupList); err != nil {\n\t\treturn HardwareComponentGroupsClientListByDeviceResponse{}, err\n\t}\n\treturn result, nil\n}", "func handleGetGroups(c *Context, w http.ResponseWriter, r *http.Request) {\n\tpaging, err := parsePaging(r.URL)\n\tif err != nil {\n\t\tc.Logger.WithError(err).Error(\"failed to parse paging parameters\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\twithInstallationCount, err := parseBool(r.URL, model.ShowInstallationCountQueryParameter, false)\n\tif err != nil {\n\t\tc.Logger.WithError(err).Error(\"failed to parse request parameters\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tfilter := &model.GroupFilter{\n\t\tPaging: paging,\n\t\tWithInstallationCount: withInstallationCount,\n\t}\n\n\tgroups, err := c.Store.GetGroupDTOs(filter)\n\tif err != nil {\n\t\tc.Logger.WithError(err).Error(\"failed to query groups\")\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\tif groups == nil {\n\t\tgroups = []*model.GroupDTO{}\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\toutputJSON(c, w, groups)\n}", "func (client IotHubResourceClient) ListByResourceGroupResponder(resp *http.Response) (result IotHubDescriptionListResult, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (_obj *DataService) GetGroupInfo(groupInfo *map[int32]string, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.WriteHead(codec.MAP, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(int32(len((*groupInfo))), 0)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tfor k0, v0 := range *groupInfo {\n\n\t\terr = _os.Write_int32(k0, 0)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\terr = _os.Write_string(v0, 1)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\ttarsCtx := context.Background()\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getGroupInfo\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr, have = _is.SkipTo(codec.MAP, 1, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _is.Read_int32(&length, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t(*groupInfo) = make(map[int32]string)\n\tfor i1, e1 := int32(0), length; i1 < e1; i1++ {\n\t\tvar k1 int32\n\t\tvar v1 string\n\n\t\terr = _is.Read_int32(&k1, 0, false)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\terr = _is.Read_string(&v1, 1, false)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\t(*groupInfo)[k1] = v1\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (client *AFDOriginsClient) listByOriginGroupHandleResponse(resp *http.Response) (AFDOriginsClientListByOriginGroupResponse, error) {\n\tresult := AFDOriginsClientListByOriginGroupResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AFDOriginListResult); err != nil {\n\t\treturn AFDOriginsClientListByOriginGroupResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *SchemaRegistryClient) listByNamespaceHandleResponse(resp *http.Response) (SchemaRegistryClientListByNamespaceResponse, error) {\n\tresult := SchemaRegistryClientListByNamespaceResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SchemaGroupListResult); err != nil {\n\t\treturn SchemaRegistryClientListByNamespaceResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *GroupClient) createOrUpdateHandleResponse(resp *http.Response) (GroupCreateOrUpdateResponse, error) {\n\tresult := GroupCreateOrUpdateResponse{RawResponse: resp}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.GroupContract); err != nil {\n\t\treturn GroupCreateOrUpdateResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *LongTermRetentionManagedInstanceBackupsClient) listByResourceGroupDatabaseHandleResponse(resp *http.Response) (LongTermRetentionManagedInstanceBackupsListByResourceGroupDatabaseResponse, error) {\n\tresult := LongTermRetentionManagedInstanceBackupsListByResourceGroupDatabaseResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedInstanceLongTermRetentionBackupListResult); err != nil {\n\t\treturn LongTermRetentionManagedInstanceBackupsListByResourceGroupDatabaseResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client UsageDetailsClient) ListForBillingPeriodByManagementGroupResponder(resp *http.Response) (result UsageDetailsListResult, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tclient.ByInspecting(),\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client LabClient) ListByResourceGroupResponder(resp *http.Response) (result ResponseWithContinuationLab, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tclient.ByInspecting(),\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func ( gmhandler *GroupMessageHandler ) GetGroupMessage(response http.ResponseWriter , request *http.Request) {\n\tresponse.Header().Set(\"Content-Type\" , \"application/json\")\n\tlang := GetSetLang(gmhandler , response , request )\n\tsession := gmhandler.Session.GetSession(request)\n\tres := &struct{\n\t\tSuccess bool `json:\"success\"`\n\t\tMessage string `json:\"message\"`\n\t\tMessages []*entity.GroupMessage `json:\"messages\"`\n\t\tGroupID string `json:\"group_id\"`\n\t\tOffset int `json:\"offset\"`\n\t}{\n\t\tSuccess: false ,\n\t\tMessage: translation.Translate(lang , \"Invalid Input \" ),\n\t}\n\tgroupid := request.FormValue(\"group_id\")\n\toffsetString := request.FormValue(\"offset\")\n\toffset :=0\n\toffset , er := strconv.Atoi(offsetString)\n\tif groupid ==\"\" || er != nil {\n\t\tresponse.Write(Helper.MarshalThis(res))\n\t\treturn \n\t}\n\tres.GroupID = groupid\n\tres.Offset = offset\n\tgroupExists := gmhandler.GroupSer.DoesGroupExist(groupid)\n\tif !groupExists {\n\t\tres.Message = fmt.Sprintf(translation.Translate(lang , \"Goup With ID : %s doesn't Exist\") , groupid )\n\t\tresponse.Write(Helper.MarshalThis(res))\n\t\treturn \n\t}\n\tisMember := gmhandler.GroupSer.IsGroupMember(groupid , session.UserID )\n\tif !isMember {\n\t\tres.Message = fmt.Sprintf( translation.Translate(lang ,\" User with ID %s is Not a member in Group With ID : %s\") , session.UserID , groupid )\n\t\tresponse.Write(Helper.MarshalThis(res))\n\t\treturn \n\t}\n\tgmessages := gmhandler.MessageSer.GetGroupMessages( groupid , offset )\n\tif gmessages == nil || len(gmessages)==0 {\n\t\tres.Message = translation.Translate(lang , \"No Message Record Found \")\n\t\tresponse.Write(Helper.MarshalThis(res))\n\t\treturn \n\t}\n\tres.Message = fmt.Sprintf(translation.Translate(lang , \"Succesfuly Found %d %s \") , len(gmessages) , Helper.SetPlural(lang , \"message\" , len(gmessages)))\n\tres.Success = true \n\tres.Messages = gmessages\n\tresponse.Write(Helper.MarshalThis(res))\n}", "func (client IdentityClient) GetDynamicGroup(ctx context.Context, request GetDynamicGroupRequest) (response GetDynamicGroupResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.getDynamicGroup, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = GetDynamicGroupResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = GetDynamicGroupResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(GetDynamicGroupResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into GetDynamicGroupResponse\")\n\t}\n\treturn\n}", "func CreateDescribeContainerGroupMetricResponse() (response *DescribeContainerGroupMetricResponse) {\n\tresponse = &DescribeContainerGroupMetricResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client Client) ListByResourceGroupResponder(resp *http.Response) (result ListResult, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tclient.ByInspecting(),\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client UsageDetailsClient) ListByManagementGroup(ctx context.Context, managementGroupID string, expand string, filter string, skiptoken string, top *int32, apply string) (result UsageDetailsListResultPage, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/UsageDetailsClient.ListByManagementGroup\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.udlr.Response.Response != nil {\n\t\t\t\tsc = result.udlr.Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tif err := validation.Validate([]validation.Validation{\n\t\t{TargetValue: top,\n\t\t\tConstraints: []validation.Constraint{{Target: \"top\", Name: validation.Null, Rule: false,\n\t\t\t\tChain: []validation.Constraint{{Target: \"top\", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil},\n\t\t\t\t\t{Target: \"top\", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},\n\t\t\t\t}}}}}); err != nil {\n\t\treturn result, validation.NewError(\"consumption.UsageDetailsClient\", \"ListByManagementGroup\", err.Error())\n\t}\n\n\tresult.fn = client.listByManagementGroupNextResults\n\treq, err := client.ListByManagementGroupPreparer(ctx, managementGroupID, expand, filter, skiptoken, top, apply)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"consumption.UsageDetailsClient\", \"ListByManagementGroup\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.ListByManagementGroupSender(req)\n\tif err != nil {\n\t\tresult.udlr.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"consumption.UsageDetailsClient\", \"ListByManagementGroup\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult.udlr, err = client.ListByManagementGroupResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"consumption.UsageDetailsClient\", \"ListByManagementGroup\", resp, \"Failure responding to request\")\n\t}\n\n\treturn\n}", "func (client WorkloadNetworksClient) UpdateVMGroupResponder(resp *http.Response) (result WorkloadNetworkVMGroup, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client DataControllersClient) ListInGroupResponder(resp *http.Response) (result PageOfDataControllerResource, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client FirewallPolicyRuleGroupsClient) GetResponder(resp *http.Response) (result FirewallPolicyRuleGroup, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client UsageDetailsClient) ListByManagementGroupComplete(ctx context.Context, managementGroupID string, expand string, filter string, skiptoken string, top *int32, apply string) (result UsageDetailsListResultIterator, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/UsageDetailsClient.ListByManagementGroup\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.Response().Response.Response != nil {\n\t\t\t\tsc = result.page.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tresult.page, err = client.ListByManagementGroup(ctx, managementGroupID, expand, filter, skiptoken, top, apply)\n\treturn\n}", "func (me *TxsdOperationInformationSequenceAvailableResponseGroups) Walk() (err error) {\n\tif fn := WalkHandlers.TxsdOperationInformationSequenceAvailableResponseGroups; me != nil {\n\t\tif fn != nil {\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif err = me.XsdGoPkgHasElems_ResponseGroupsequenceCreateHITRequestschema_ResponseGroup_XsdtString_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\treturn\n\t\t}\n\t\tif fn != nil {\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func GetPolicyDefinitionAtManagementGroup(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *PolicyDefinitionAtManagementGroupState, opts ...pulumi.ResourceOption) (*PolicyDefinitionAtManagementGroup, error) {\n\tvar resource PolicyDefinitionAtManagementGroup\n\terr := ctx.ReadResource(\"azure-native:authorization/v20190101:PolicyDefinitionAtManagementGroup\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (a *IAMApiService) GetGroup(ctx context.Context, gid string) (IamGroup, *http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = http.MethodGet\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue IamGroup\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/acs/api/v1/groups/{gid}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"gid\"+\"}\", fmt.Sprintf(\"%v\", gid), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\t\tif localVarHttpResponse.StatusCode == 200 {\n\t\t\tvar v IamGroup\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\t\tif localVarHttpResponse.StatusCode == 0 {\n\t\t\tvar v IamError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t}\n\n\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\tif err != nil {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: err.Error(),\n\t\t}\n\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHttpResponse, nil\n}", "func (client IdentityClient) getGroup(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/groups/{groupId}\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response GetGroupResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (client *SyncGroupsClient) listByDatabaseHandleResponse(resp *http.Response) (SyncGroupsClientListByDatabaseResponse, error) {\n\tresult := SyncGroupsClientListByDatabaseResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SyncGroupListResult); err != nil {\n\t\treturn SyncGroupsClientListByDatabaseResponse{}, err\n\t}\n\treturn result, nil\n}", "func CreateDescribeScalingGroupsResponse() (response *DescribeScalingGroupsResponse) {\n\tresponse = &DescribeScalingGroupsResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (client IdentityClient) getDynamicGroup(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/dynamicGroups/{dynamicGroupId}\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response GetDynamicGroupResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (client UsageDetailsClient) ListByManagementGroupSender(req *http.Request) (*http.Response, error) {\n\treturn autorest.SendWithSender(client, req,\n\t\tautorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))\n}", "func handleCreateGroup(c *Context, w http.ResponseWriter, r *http.Request) {\n\tcreateGroupRequest, err := model.NewCreateGroupRequestFromReader(r.Body)\n\tif err != nil {\n\t\tc.Logger.WithError(err).Error(\"failed to decode request\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tgroup := model.Group{\n\t\tName: createGroupRequest.Name,\n\t\tDescription: createGroupRequest.Description,\n\t\tVersion: createGroupRequest.Version,\n\t\tImage: createGroupRequest.Image,\n\t\tMaxRolling: createGroupRequest.MaxRolling,\n\t\tAPISecurityLock: createGroupRequest.APISecurityLock,\n\t\tMattermostEnv: createGroupRequest.MattermostEnv,\n\t}\n\n\tannotations, err := model.AnnotationsFromStringSlice(createGroupRequest.Annotations)\n\tif err != nil {\n\t\tc.Logger.WithError(err).Error(\"invalid annotations\")\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\terr = c.Store.CreateGroup(&group, annotations)\n\tif err != nil {\n\t\tc.Logger.WithError(err).Error(\"failed to create group\")\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tc.Supervisor.Do()\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\toutputJSON(c, w, group.ToDTO(annotations))\n}", "func (o BackendResponseOutput) Group() pulumi.StringOutput {\n\treturn o.ApplyT(func(v BackendResponse) string { return v.Group }).(pulumi.StringOutput)\n}", "func handleGetGroupsStatus(c *Context, w http.ResponseWriter, r *http.Request) {\n\tfilter := &model.GroupFilter{\n\t\tPaging: model.AllPagesNotDeleted(),\n\t}\n\n\tgroups, err := c.Store.GetGroups(filter)\n\tif err != nil {\n\t\tc.Logger.WithError(err).Error(\"failed to query groups\")\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\tif groups == nil {\n\t\tw.WriteHeader(http.StatusNotFound)\n\t\treturn\n\t}\n\n\tvar groupsStatus []model.GroupsStatus\n\n\tfor _, group := range groups {\n\t\tvar groupStatus model.GroupsStatus\n\t\tstatus, err := c.Store.GetGroupStatus(group.ID)\n\t\tif err != nil {\n\t\t\tc.Logger.WithError(err).Error(\"failed to query group status\")\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tif status == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tgroupStatus.ID = group.ID\n\t\tgroupStatus.Status = *status\n\n\t\tgroupsStatus = append(groupsStatus, groupStatus)\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\toutputJSON(c, w, groupsStatus)\n}", "func (client IotHubResourceClient) CreateEventHubConsumerGroupResponder(resp *http.Response) (result EventHubConsumerGroupInfo, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (ctx *Context) SpecificGroupsHandler(w http.ResponseWriter, r *http.Request) {\n\n\tuid := getCurrentUser(w, r)\n\tif uid < 0 {\n\t\treturn\n\t}\n\n\t// Only support GET PATCH DELETE method\n\tif r.Method != \"GET\" && r.Method != \"PATCH\" && r.Method != \"DELETE\" && r.Method != \"PUT\" {\n\t\thttp.Error(w, errUnsuportMethod, http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\t// parse group id\n\turlID := path.Base(r.URL.Path)\n\tgid := getIDfromURL(w, r, urlID)\n\tif gid < 0 {\n\t\treturn\n\t}\n\n\t// read group data from db\n\tgroup, err := ctx.Store.GetGroupByID(gid)\n\tif !dbErrorHandle(w, \"Get group\", err) {\n\t\treturn\n\t}\n\n\t// GET request will return the group\n\tif r.Method == \"GET\" {\n\n\t\t//Get all meetings\n\t\tmeetings, err := ctx.Store.GetAllMeetingsOfGroup(gid)\n\t\tif !dbErrorHandle(w, \"Get all meetings\", err) {\n\t\t\treturn\n\t\t}\n\n\t\t//Get all members of the group\n\t\tmembers, err := ctx.Store.GetAllMembers(gid)\n\t\tif !dbErrorHandle(w, \"Get all members\", err) {\n\t\t\treturn\n\t\t}\n\n\t\t//Construct the return struct\n\t\tcompleteGroupInfo := model.GroupReturnBody{\n\t\t\tMeetings: meetings,\n\t\t\tGroupInfo: group,\n\t\t\tMembers: members,\n\t\t}\n\n\t\t// marshal current group into response body\n\t\tresponse := marshalRep(w, completeGroupInfo)\n\t\tif response == nil {\n\t\t\treturn\n\t\t}\n\n\t\t// write into response\n\t\trespondWithHeader(w, typeJSON, response, http.StatusOK)\n\t}\n\n\t// PUT request can update the groups' information, only creator can use this method\n\tif r.Method == \"PUT\" {\n\n\t\t// Check authorization\n\t\tif !isGroupCreator(group, uid, w) {\n\t\t\treturn\n\t\t}\n\n\t\t// Check content type\n\t\tif !isContentTypeJSON(w, r) {\n\t\t\treturn\n\t\t}\n\n\t\t// Get request body\n\t\tbody := getRequestBody(w, r)\n\t\tif body == nil {\n\t\t\treturn\n\t\t}\n\n\t\t// Marshal the body to json\n\t\tnewGroup := &model.Group{}\n\t\tif !unmarshalBody(w, body, newGroup) {\n\t\t\treturn\n\t\t}\n\n\t\t// Update information in database\n\t\terr := ctx.Store.UpdateGroup(newGroup)\n\t\tif !dbErrorHandle(w, \"Update group\", err) {\n\t\t\treturn\n\t\t}\n\n\t\t// TBD: get the newly updated group\n\t\tgroup, err = ctx.Store.GetGroupByID(group.GroupID)\n\t\tif !dbErrorHandle(w, \"Get updated group\", err) {\n\t\t\treturn\n\t\t}\n\n\t\t// marshal into body and response\n\t\tres := marshalRep(w, group)\n\t\tif res == nil {\n\t\t\treturn\n\t\t}\n\n\t\trespondWithHeader(w, typeJSON, res, http.StatusOK)\n\n\t}\n\n\t// PATCH generate an invitation link, and add the invitation email into group members\n\tif r.Method == \"PATCH\" {\n\t\t// TBD: authorization?\n\n\t\t// Get the invitation information form request\n\t\tbody := getRequestBody(w, r)\n\t\tif body == nil {\n\t\t\treturn\n\t\t}\n\n\t\tguest := &model.NewGuest{}\n\t\tif !unmarshalBody(w, body, guest) {\n\t\t\treturn\n\t\t}\n\n\t\t// TESTING: Insert into db\n\t\tguestID := model.GenerateRandomID()\n\t\t_, err := ctx.Store.InsertGuest(guestID, guest.Email, guest.DisplayName, gid, 0, uid) //Comment this\n\t\tif !dbErrorHandle(w, \"insert guest\", err) {\n\t\t\treturn\n\t\t}\n\n\t\t// Generate an invitation link with the email\n\t\tlink := fmt.Sprintf(\"%s/%s/guest/%s/%d/groups/%d\", r.Host, version, guest.Email, guestID, gid)\n\n\t\t// response with the link\n\t\trespondWithHeader(w, typeText, []byte(link), http.StatusCreated)\n\n\t}\n\n\t// Delete the current group, only creator can use this method\n\tif r.Method == \"DELETE\" {\n\n\t\t// Check authorization\n\t\tif !isGroupCreator(group, uid, w) {\n\t\t\treturn\n\t\t}\n\n\t\terr := ctx.Store.DeleteGroup(gid)\n\t\tif !dbErrorHandle(w, \"Delete group\", err) {\n\t\t\treturn\n\t\t}\n\n\t\trespondWithHeader(w, typeText, []byte(\"Delete success\"), http.StatusOK)\n\n\t}\n\n}", "func CreateDescribeMultiContainerGroupMetricResponse() (response *DescribeMultiContainerGroupMetricResponse) {\n\tresponse = &DescribeMultiContainerGroupMetricResponse{\n\t\tBaseResponse: &responses.BaseResponse{},\n\t}\n\treturn\n}", "func (fn GetAuthorizationAPIGroupHandlerFunc) Handle(params GetAuthorizationAPIGroupParams) middleware.Responder {\n\treturn fn(params)\n}", "func (client *GroupClient) getEntityTagHandleResponse(resp *http.Response) (GroupGetEntityTagResponse, error) {\n\tresult := GroupGetEntityTagResponse{RawResponse: resp}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif resp.StatusCode >= 200 && resp.StatusCode < 300 {\n\t\tresult.Success = true\n\t}\n\treturn result, nil\n}", "func (client *ManagementAssociationsClient) getHandleResponse(resp *http.Response) (ManagementAssociationsGetResponse, error) {\n\tresult := ManagementAssociationsGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagementAssociation); err != nil {\n\t\treturn ManagementAssociationsGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *PolicyDefinitionsClient) getAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, options *PolicyDefinitionsGetAtManagementGroupOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}\"\n\tif policyDefinitionName == \"\" {\n\t\treturn nil, errors.New(\"parameter policyDefinitionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{policyDefinitionName}\", url.PathEscape(policyDefinitionName))\n\tif managementGroupID == \"\" {\n\t\treturn nil, errors.New(\"parameter managementGroupID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managementGroupId}\", url.PathEscape(managementGroupID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client IdentityClient) GetGroup(ctx context.Context, request GetGroupRequest) (response GetGroupResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.getGroup, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = GetGroupResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = GetGroupResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(GetGroupResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into GetGroupResponse\")\n\t}\n\treturn\n}", "func (me *XsdGoPkgHasElem_ResponseGroupInformation) Walk() (err error) {\n\tif fn := WalkHandlers.XsdGoPkgHasElem_ResponseGroupInformation; me != nil {\n\t\tif fn != nil {\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tif err = me.ResponseGroupInformation.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\treturn\n\t\t}\n\t\tif fn != nil {\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func getGroups(w http.ResponseWriter, r *http.Request) {\n InitResponse(&w)\n if r.Method == \"OPTIONS\" {return}\n\n allow, _ := HasPermission(&w, r, CoreGroupModuleID, CoreAccessRead)\n if !allow {\n w.WriteHeader(http.StatusUnauthorized)\n json.NewEncoder(w).Encode(&CoreMessage{\n Message: \"Not authorized!\",\n })\n return\n }\n\n groups := []CoreGroup{}\n\n err := Db.Model(&groups).Select()\n if err != nil {\n w.WriteHeader(http.StatusBadRequest)\n return\n }\n\n w.WriteHeader(http.StatusOK)\n json.NewEncoder(w).Encode(groups)\n}", "func (client WorkloadNetworksClient) ListVMGroupsResponder(resp *http.Response) (result WorkloadNetworkVMGroupsList, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}" ]
[ "0.66376185", "0.6585092", "0.64261913", "0.6391692", "0.6382366", "0.63312274", "0.63303494", "0.6312258", "0.63077897", "0.62958425", "0.6260882", "0.62083423", "0.6203065", "0.61537623", "0.6131575", "0.61313987", "0.61255515", "0.61254406", "0.6121473", "0.61212695", "0.6111537", "0.60946476", "0.6072034", "0.60640395", "0.60544366", "0.6052266", "0.6044018", "0.6042864", "0.60323465", "0.6027878", "0.60266733", "0.60036016", "0.60000545", "0.5993663", "0.5993226", "0.5991735", "0.59711504", "0.59291387", "0.59057415", "0.5898499", "0.581746", "0.5798762", "0.57923824", "0.5783489", "0.57679814", "0.5740101", "0.5726802", "0.5696891", "0.5691908", "0.5669448", "0.5630803", "0.5531167", "0.5508712", "0.54644644", "0.5434885", "0.5428255", "0.5393907", "0.53299135", "0.5281433", "0.52729976", "0.52676964", "0.5249187", "0.5194669", "0.5193852", "0.5190536", "0.51792485", "0.5164216", "0.51324975", "0.51098615", "0.50987285", "0.508898", "0.50768733", "0.5048127", "0.503675", "0.50314474", "0.5024127", "0.502003", "0.50144607", "0.50125736", "0.5011326", "0.5010653", "0.49954575", "0.49835038", "0.49748948", "0.4944377", "0.4935331", "0.4933027", "0.49144515", "0.49122733", "0.49088946", "0.4880824", "0.4849112", "0.4846951", "0.48291287", "0.4797712", "0.4781146", "0.47617078", "0.47611895", "0.47610843", "0.47415704" ]
0.7855107
0
getBuiltInCreateRequest creates the GetBuiltIn request.
getBuiltInCreateRequest создает запрос GetBuiltIn.
func (client *PolicyDefinitionsClient) getBuiltInCreateRequest(ctx context.Context, policyDefinitionName string, options *PolicyDefinitionsGetBuiltInOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" if policyDefinitionName == "" { return nil, errors.New("parameter policyDefinitionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() reqQP.Set("api-version", "2021-06-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *PolicyDefinitionsClient) listBuiltInCreateRequest(ctx context.Context, options *PolicyDefinitionsListBuiltInOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.Authorization/policyDefinitions\"\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\tif options != nil && options.Top != nil {\n\t\treqQP.Set(\"$top\", strconv.FormatInt(int64(*options.Top), 10))\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tunencodedParams := []string{req.Raw().URL.RawQuery}\n\tif options != nil && options.Filter != nil {\n\t\tunencodedParams = append(unencodedParams, \"$filter=\"+*options.Filter)\n\t}\n\treq.Raw().URL.RawQuery = strings.Join(unencodedParams, \"&\")\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *BuildServiceClient) getBuildCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, buildServiceName string, buildName string, options *BuildServiceClientGetBuildOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif buildServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter buildServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{buildServiceName}\", url.PathEscape(buildServiceName))\n\tif buildName == \"\" {\n\t\treturn nil, errors.New(\"parameter buildName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{buildName}\", url.PathEscape(buildName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateGetOpenNLURequest() (request *GetOpenNLURequest) {\n\trequest = &GetOpenNLURequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"alinlp\", \"2020-06-29\", \"GetOpenNLU\", \"alinlp\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *BuildServiceClient) getSupportedBuildpackCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, buildServiceName string, buildpackName string, options *BuildServiceClientGetSupportedBuildpackOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/supportedBuildpacks/{buildpackName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif buildServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter buildServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{buildServiceName}\", url.PathEscape(buildServiceName))\n\tif buildpackName == \"\" {\n\t\treturn nil, errors.New(\"parameter buildpackName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{buildpackName}\", url.PathEscape(buildpackName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *WebhooksClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif registryName == \"\" {\n\t\treturn nil, errors.New(\"parameter registryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{registryName}\", url.PathEscape(registryName))\n\tif webhookName == \"\" {\n\t\treturn nil, errors.New(\"parameter webhookName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{webhookName}\", url.PathEscape(webhookName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2019-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *SapMonitorsClient) getCreateRequest(ctx context.Context, resourceGroupName string, sapMonitorName string, options *SapMonitorsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HanaOnAzure/sapMonitors/{sapMonitorName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sapMonitorName == \"\" {\n\t\treturn nil, errors.New(\"parameter sapMonitorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sapMonitorName}\", url.PathEscape(sapMonitorName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-02-07-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *WorkspacesClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, options *WorkspacesGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ImplicitClient) getRequiredGlobalQueryCreateRequest(ctx context.Context, options *ImplicitClientGetRequiredGlobalQueryOptions) (*policy.Request, error) {\n\turlPath := \"/reqopt/global/required/query\"\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"required-global-query\", client.requiredGlobalQuery)\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *WebAppsClient) getCreateRequest(ctx context.Context, resourceGroupName string, name string, options *WebAppsGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func CreateGetManagedRuleRequest() (request *GetManagedRuleRequest) {\n\trequest = &GetManagedRuleRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"Config\", \"2020-09-07\", \"GetManagedRule\", \"\", \"\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *RegistrationDefinitionsClient) getCreateRequest(ctx context.Context, scope string, registrationDefinitionID string, options *RegistrationDefinitionsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\tif registrationDefinitionID == \"\" {\n\t\treturn nil, errors.New(\"parameter registrationDefinitionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{registrationDefinitionId}\", url.PathEscape(registrationDefinitionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *AlertsClient) getCreateRequest(ctx context.Context, scope string, alertID string, options *AlertsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.Authorization/roleManagementAlerts/{alertId}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\turlPath = strings.ReplaceAll(urlPath, \"{alertId}\", alertID)\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ConnectedEnvironmentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, connectedEnvironmentName string, options *ConnectedEnvironmentsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif connectedEnvironmentName == \"\" {\n\t\treturn nil, errors.New(\"parameter connectedEnvironmentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{connectedEnvironmentName}\", url.PathEscape(connectedEnvironmentName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *LocalRulestacksClient) getCreateRequest(ctx context.Context, resourceGroupName string, localRulestackName string, options *LocalRulestacksClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/PaloAltoNetworks.Cloudngfw/localRulestacks/{localRulestackName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif localRulestackName == \"\" {\n\t\treturn nil, errors.New(\"parameter localRulestackName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{localRulestackName}\", url.PathEscape(localRulestackName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-29\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *MetricAlertsClient) getCreateRequest(ctx context.Context, resourceGroupName string, ruleName string, options *MetricAlertsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif ruleName == \"\" {\n\t\treturn nil, errors.New(\"parameter ruleName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ruleName}\", url.PathEscape(ruleName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *AlertOperationClient) getCreateRequest(ctx context.Context, scope string, operationID string, options *AlertOperationClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.Authorization/roleManagementAlertOperations/{operationId}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\turlPath = strings.ReplaceAll(urlPath, \"{operationId}\", operationID)\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *SQLVirtualMachinesClient) getCreateRequest(ctx context.Context, resourceGroupName string, sqlVirtualMachineName string, options *SQLVirtualMachinesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/{sqlVirtualMachineName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif sqlVirtualMachineName == \"\" {\n\t\treturn nil, errors.New(\"parameter sqlVirtualMachineName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{sqlVirtualMachineName}\", url.PathEscape(sqlVirtualMachineName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.Expand != nil {\n\t\treqQP.Set(\"$expand\", *options.Expand)\n\t}\n\treqQP.Set(\"api-version\", \"2017-03-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *GremlinResourcesClient) getGremlinDatabaseCreateRequest(ctx context.Context, resourceGroupName string, accountName string, databaseName string, options *GremlinResourcesClientGetGremlinDatabaseOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif accountName == \"\" {\n\t\treturn nil, errors.New(\"parameter accountName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{accountName}\", url.PathEscape(accountName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-10-15\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *PortalConfigClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalConfigID string, options *PortalConfigClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif portalConfigID == \"\" {\n\t\treturn nil, errors.New(\"parameter portalConfigID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{portalConfigId}\", url.PathEscape(portalConfigID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *CustomAssessmentAutomationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, customAssessmentAutomationName string, options *CustomAssessmentAutomationsGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Security/customAssessmentAutomations/{customAssessmentAutomationName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif customAssessmentAutomationName == \"\" {\n\t\treturn nil, errors.New(\"parameter customAssessmentAutomationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{customAssessmentAutomationName}\", url.PathEscape(customAssessmentAutomationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ActionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, ruleID string, actionID string, options *ActionsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/alertRules/{ruleId}/actions/{actionId}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif ruleID == \"\" {\n\t\treturn nil, errors.New(\"parameter ruleID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ruleId}\", url.PathEscape(ruleID))\n\tif actionID == \"\" {\n\t\treturn nil, errors.New(\"parameter actionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{actionId}\", url.PathEscape(actionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-10-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *MonitoringSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *MonitoringSettingsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/monitoringSettings/default\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *SchemaRegistryClient) getCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, schemaGroupName string, options *SchemaRegistryClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/schemagroups/{schemaGroupName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif namespaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter namespaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{namespaceName}\", url.PathEscape(namespaceName))\n\tif schemaGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter schemaGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{schemaGroupName}\", url.PathEscape(schemaGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-10-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *OutputsClient) getCreateRequest(ctx context.Context, resourceGroupName string, jobName string, outputName string, options *OutputsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/outputs/{outputName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif jobName == \"\" {\n\t\treturn nil, errors.New(\"parameter jobName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{jobName}\", url.PathEscape(jobName))\n\tif outputName == \"\" {\n\t\treturn nil, errors.New(\"parameter outputName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{outputName}\", url.PathEscape(outputName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *BuildServiceClient) getBuildResultCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, buildServiceName string, buildName string, buildResultName string, options *BuildServiceClientGetBuildResultOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}/results/{buildResultName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif buildServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter buildServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{buildServiceName}\", url.PathEscape(buildServiceName))\n\tif buildName == \"\" {\n\t\treturn nil, errors.New(\"parameter buildName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{buildName}\", url.PathEscape(buildName))\n\tif buildResultName == \"\" {\n\t\treturn nil, errors.New(\"parameter buildResultName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{buildResultName}\", url.PathEscape(buildResultName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *OutputsClient) getCreateRequest(ctx context.Context, resourceGroupName string, jobName string, outputName string, options *OutputsGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/outputs/{outputName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif jobName == \"\" {\n\t\treturn nil, errors.New(\"parameter jobName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{jobName}\", url.PathEscape(jobName))\n\tif outputName == \"\" {\n\t\treturn nil, errors.New(\"parameter outputName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{outputName}\", url.PathEscape(outputName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-04-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *BuildServiceClient) getBuildServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, buildServiceName string, options *BuildServiceClientGetBuildServiceOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif buildServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter buildServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{buildServiceName}\", url.PathEscape(buildServiceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *IPAllocationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, ipAllocationName string, options *IPAllocationsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/IpAllocations/{ipAllocationName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif ipAllocationName == \"\" {\n\t\treturn nil, errors.New(\"parameter ipAllocationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ipAllocationName}\", url.PathEscape(ipAllocationName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\tif options != nil && options.Expand != nil {\n\t\treqQP.Set(\"$expand\", *options.Expand)\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateGetServiceInputMappingRequest() (request *GetServiceInputMappingRequest) {\n\trequest = &GetServiceInputMappingRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"industry-brain\", \"2018-07-12\", \"GetServiceInputMapping\", \"\", \"\")\n\treturn\n}", "func (c *Client) BuildGetRequest(ctx context.Context, v interface{}) (*http.Request, error) {\n\tvar (\n\t\tid string\n\t)\n\t{\n\t\tp, ok := v.(*warehouse.GetPayload)\n\t\tif !ok {\n\t\t\treturn nil, goahttp.ErrInvalidType(\"Warehouse\", \"Get\", \"*warehouse.GetPayload\", v)\n\t\t}\n\t\tid = p.ID\n\t}\n\tu := &url.URL{Scheme: c.scheme, Host: c.host, Path: GetWarehousePath(id)}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, goahttp.ErrInvalidURL(\"Warehouse\", \"Get\", u.String(), err)\n\t}\n\tif ctx != nil {\n\t\treq = req.WithContext(ctx)\n\t}\n\n\treturn req, nil\n}", "func (client *DscCompilationJobClient) getCreateRequest(ctx context.Context, resourceGroupName string, automationAccountName string, compilationJobName string, options *DscCompilationJobClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/compilationjobs/{compilationJobName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif automationAccountName == \"\" {\n\t\treturn nil, errors.New(\"parameter automationAccountName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{automationAccountName}\", url.PathEscape(automationAccountName))\n\tif compilationJobName == \"\" {\n\t\treturn nil, errors.New(\"parameter compilationJobName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{compilationJobName}\", url.PathEscape(compilationJobName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-01-13-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *MonitorsClient) getCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif monitorName == \"\" {\n\t\treturn nil, errors.New(\"parameter monitorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{monitorName}\", url.PathEscape(monitorName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-03-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *PolicyDefinitionsClient) getCreateRequest(ctx context.Context, policyDefinitionName string, options *PolicyDefinitionsGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}\"\n\tif policyDefinitionName == \"\" {\n\t\treturn nil, errors.New(\"parameter policyDefinitionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{policyDefinitionName}\", url.PathEscape(policyDefinitionName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *RoleDefinitionsClient) getCreateRequest(ctx context.Context, scope string, roleDefinitionID string, options *RoleDefinitionsGetOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\tif roleDefinitionID == \"\" {\n\t\treturn nil, errors.New(\"parameter roleDefinitionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{roleDefinitionId}\", url.PathEscape(roleDefinitionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ClustersClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/clusters/{clusterName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ManagedDatabasesClient) getCreateRequest(ctx context.Context, resourceGroupName string, managedInstanceName string, databaseName string, options *ManagedDatabasesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif managedInstanceName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedInstanceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedInstanceName}\", url.PathEscape(managedInstanceName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateGetRenderResultRequest() (request *GetRenderResultRequest) {\n\trequest = &GetRenderResultRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"ivpd\", \"2019-06-25\", \"GetRenderResult\", \"ivpd\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *AvailabilitySetsClient) getCreateRequest(ctx context.Context, resourceGroupName string, availabilitySetName string, options *AvailabilitySetsGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif availabilitySetName == \"\" {\n\t\treturn nil, errors.New(\"parameter availabilitySetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{availabilitySetName}\", url.PathEscape(availabilitySetName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *VirtualApplianceSKUsClient) getCreateRequest(ctx context.Context, skuName string, options *VirtualApplianceSKUsGetOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.Network/networkVirtualApplianceSkus/{skuName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\turlPath = strings.ReplaceAll(urlPath, \"{skuName}\", url.PathEscape(skuName))\n\treq, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-07-01\")\n\treq.URL.RawQuery = query.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *FactoriesClient) getCreateRequest(ctx context.Context, resourceGroupName string, factoryName string, options *FactoriesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif factoryName == \"\" {\n\t\treturn nil, errors.New(\"parameter factoryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{factoryName}\", url.PathEscape(factoryName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfNoneMatch != nil {\n\t\treq.Raw().Header[\"If-None-Match\"] = []string{*options.IfNoneMatch}\n\t}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *WebAppsClient) getWebJobCreateRequest(ctx context.Context, resourceGroupName string, name string, webJobName string, options *WebAppsGetWebJobOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/webjobs/{webJobName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif webJobName == \"\" {\n\t\treturn nil, errors.New(\"parameter webJobName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{webJobName}\", url.PathEscape(webJobName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func CreateGetIndustryCommerceInfoRequest() (request *GetIndustryCommerceInfoRequest) {\n\trequest = &GetIndustryCommerceInfoRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"companyreg\", \"2020-10-22\", \"GetIndustryCommerceInfo\", \"companyreg\", \"openAPI\")\n\trequest.Method = requests.GET\n\treturn\n}", "func (client *VirtualMachinesClient) getCreateRequest(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif virtualMachineName == \"\" {\n\t\treturn nil, errors.New(\"parameter virtualMachineName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{virtualMachineName}\", url.PathEscape(virtualMachineName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-10-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateGetArmsConsoleUrlRequest() (request *GetArmsConsoleUrlRequest) {\n\trequest = &GetArmsConsoleUrlRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"ARMS\", \"2019-08-08\", \"GetArmsConsoleUrl\", \"arms\", \"openAPI\")\n\trequest.Method = requests.GET\n\treturn\n}", "func (client *ManagedClustersClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *ManagedClustersClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/managedClusters/{resourceName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(resourceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *VirtualMachineScaleSetsClient) getCreateRequest(ctx context.Context, resourceGroupName string, vmScaleSetName string, options *VirtualMachineScaleSetsGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif vmScaleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter vmScaleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vmScaleSetName}\", url.PathEscape(vmScaleSetName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\tif options != nil && options.Expand != nil {\n\t\treqQP.Set(\"$expand\", string(*options.Expand))\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *APIClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif apiID == \"\" {\n\t\treturn nil, errors.New(\"parameter apiID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{apiId}\", url.PathEscape(apiID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *UserMetricsKeysClient) getCreateRequest(ctx context.Context, options *UserMetricsKeysClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *WebAppsClient) getTriggeredWebJobCreateRequest(ctx context.Context, resourceGroupName string, name string, webJobName string, options *WebAppsGetTriggeredWebJobOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/triggeredwebjobs/{webJobName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif webJobName == \"\" {\n\t\treturn nil, errors.New(\"parameter webJobName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{webJobName}\", url.PathEscape(webJobName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *TaskRunsClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif registryName == \"\" {\n\t\treturn nil, errors.New(\"parameter registryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{registryName}\", url.PathEscape(registryName))\n\tif taskRunName == \"\" {\n\t\treturn nil, errors.New(\"parameter taskRunName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{taskRunName}\", url.PathEscape(taskRunName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2019-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *AnalysisResultsClient) getCreateRequest(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, testResultName string, analysisResultName AnalysisResultName, options *AnalysisResultsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.TestBase/testBaseAccounts/{testBaseAccountName}/packages/{packageName}/testResults/{testResultName}/analysisResults/{analysisResultName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif testBaseAccountName == \"\" {\n\t\treturn nil, errors.New(\"parameter testBaseAccountName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{testBaseAccountName}\", url.PathEscape(testBaseAccountName))\n\tif packageName == \"\" {\n\t\treturn nil, errors.New(\"parameter packageName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{packageName}\", url.PathEscape(packageName))\n\tif testResultName == \"\" {\n\t\treturn nil, errors.New(\"parameter testResultName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{testResultName}\", url.PathEscape(testResultName))\n\tif analysisResultName == \"\" {\n\t\treturn nil, errors.New(\"parameter analysisResultName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{analysisResultName}\", url.PathEscape(string(analysisResultName)))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-12-16-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *Client) getEmbeddingsCreateRequest(ctx context.Context, body EmbeddingsOptions, options *GetEmbeddingsOptions) (*policy.Request, error) {\n\turlPath := \"embeddings\"\n\treq, err := runtime.NewRequest(ctx, http.MethodPost, client.formatURL(urlPath, getDeploymentID(body)))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-07-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\tif err := runtime.MarshalAsJSON(req, body); err != nil {\n\t\treturn nil, err\n\t}\n\treturn req, nil\n}", "func (client *InteractionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, hubName string, interactionName string, options *InteractionsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomerInsights/hubs/{hubName}/interactions/{interactionName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif hubName == \"\" {\n\t\treturn nil, errors.New(\"parameter hubName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hubName}\", url.PathEscape(hubName))\n\tif interactionName == \"\" {\n\t\treturn nil, errors.New(\"parameter interactionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{interactionName}\", url.PathEscape(interactionName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.LocaleCode != nil {\n\t\treqQP.Set(\"locale-code\", *options.LocaleCode)\n\t}\n\treqQP.Set(\"api-version\", \"2017-04-26\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *subscriptionClient) getCreateRequest(ctx context.Context, topicName string, subscriptionName string, options *SubscriptionGetOptions) (*policy.Request, error) {\n\turlPath := \"/{topicName}/subscriptions/{subscriptionName}\"\n\tif topicName == \"\" {\n\t\treturn nil, errors.New(\"parameter topicName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{topicName}\", url.PathEscape(topicName))\n\tif subscriptionName == \"\" {\n\t\treturn nil, errors.New(\"parameter subscriptionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionName}\", url.PathEscape(subscriptionName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.Enrich != nil {\n\t\treqQP.Set(\"enrich\", strconv.FormatBool(*options.Enrich))\n\t}\n\tif client.apiVersion != nil {\n\t\treqQP.Set(\"api-version\", \"2017_04\")\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/xml, application/atom+xml\")\n\treturn req, nil\n}", "func (client *AlertProcessingRulesClient) getByNameCreateRequest(ctx context.Context, resourceGroupName string, alertProcessingRuleName string, options *AlertProcessingRulesClientGetByNameOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif alertProcessingRuleName == \"\" {\n\t\treturn nil, errors.New(\"parameter alertProcessingRuleName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{alertProcessingRuleName}\", url.PathEscape(alertProcessingRuleName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-08-08\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func CreateGetWsCustomizedChO2ORequest() (request *GetWsCustomizedChO2ORequest) {\n\trequest = &GetWsCustomizedChO2ORequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"alinlp\", \"2020-06-29\", \"GetWsCustomizedChO2O\", \"alinlp\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *PipelinesClient) getCreateRequest(ctx context.Context, resourceGroupName string, factoryName string, pipelineName string, options *PipelinesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/pipelines/{pipelineName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif factoryName == \"\" {\n\t\treturn nil, errors.New(\"parameter factoryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{factoryName}\", url.PathEscape(factoryName))\n\tif pipelineName == \"\" {\n\t\treturn nil, errors.New(\"parameter pipelineName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{pipelineName}\", url.PathEscape(pipelineName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\tif options != nil && options.IfNoneMatch != nil {\n\t\treq.Raw().Header[\"If-None-Match\"] = []string{*options.IfNoneMatch}\n\t}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *DefenderSettingsClient) getCreateRequest(ctx context.Context, options *DefenderSettingsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.IoTSecurity/defenderSettings/default\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *WebAppsClient) getContinuousWebJobCreateRequest(ctx context.Context, resourceGroupName string, name string, webJobName string, options *WebAppsGetContinuousWebJobOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/continuouswebjobs/{webJobName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif webJobName == \"\" {\n\t\treturn nil, errors.New(\"parameter webJobName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{webJobName}\", url.PathEscape(webJobName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *LiveOutputsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, liveEventName string, liveOutputName string, options *LiveOutputsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaservices/{accountName}/liveEvents/{liveEventName}/liveOutputs/{liveOutputName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif accountName == \"\" {\n\t\treturn nil, errors.New(\"parameter accountName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{accountName}\", url.PathEscape(accountName))\n\tif liveEventName == \"\" {\n\t\treturn nil, errors.New(\"parameter liveEventName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{liveEventName}\", url.PathEscape(liveEventName))\n\tif liveOutputName == \"\" {\n\t\treturn nil, errors.New(\"parameter liveOutputName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{liveOutputName}\", url.PathEscape(liveOutputName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *VMInsightsClient) getOnboardingStatusCreateRequest(ctx context.Context, resourceURI string, options *VMInsightsGetOnboardingStatusOptions) (*azcore.Request, error) {\n\turlPath := \"/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default\"\n\tif resourceURI == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceURI cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceUri}\", resourceURI)\n\treq, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\treqQP := req.URL.Query()\n\treqQP.Set(\"api-version\", \"2018-11-27-preview\")\n\treq.URL.RawQuery = reqQP.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *TablesClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, tableName string, options *TablesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif tableName == \"\" {\n\t\treturn nil, errors.New(\"parameter tableName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{tableName}\", url.PathEscape(tableName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *BuildServiceClient) listBuildsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, buildServiceName string, options *BuildServiceClientListBuildsOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif buildServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter buildServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{buildServiceName}\", url.PathEscape(buildServiceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ContainerAppsDiagnosticsClient) getRootCreateRequest(ctx context.Context, resourceGroupName string, containerAppName string, options *ContainerAppsDiagnosticsClientGetRootOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectorProperties/rootApi/\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif containerAppName == \"\" {\n\t\treturn nil, errors.New(\"parameter containerAppName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{containerAppName}\", url.PathEscape(containerAppName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (c *Client) NewGetMemberRequest(ctx context.Context, path string) (*http.Request, error) {\n\tscheme := c.Scheme\n\tif scheme == \"\" {\n\t\tscheme = \"https\"\n\t}\n\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif c.JWTSigner != nil {\n\t\tif err := c.JWTSigner.Sign(req); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn req, nil\n}", "func (client *AFDOriginsClient) getCreateRequest(ctx context.Context, resourceGroupName string, profileName string, originGroupName string, originName string, options *AFDOriginsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif profileName == \"\" {\n\t\treturn nil, errors.New(\"parameter profileName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{profileName}\", url.PathEscape(profileName))\n\tif originGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter originGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{originGroupName}\", url.PathEscape(originGroupName))\n\tif originName == \"\" {\n\t\treturn nil, errors.New(\"parameter originName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{originName}\", url.PathEscape(originName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *KpiClient) getCreateRequest(ctx context.Context, resourceGroupName string, hubName string, kpiName string, options *KpiClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomerInsights/hubs/{hubName}/kpi/{kpiName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif hubName == \"\" {\n\t\treturn nil, errors.New(\"parameter hubName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{hubName}\", url.PathEscape(hubName))\n\tif kpiName == \"\" {\n\t\treturn nil, errors.New(\"parameter kpiName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{kpiName}\", url.PathEscape(kpiName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-04-26\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *VirtualApplianceSitesClient) getCreateRequest(ctx context.Context, resourceGroupName string, networkVirtualApplianceName string, siteName string, options *VirtualApplianceSitesGetOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkVirtualAppliances/{networkVirtualApplianceName}/virtualApplianceSites/{siteName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\turlPath = strings.ReplaceAll(urlPath, \"{networkVirtualApplianceName}\", url.PathEscape(networkVirtualApplianceName))\n\turlPath = strings.ReplaceAll(urlPath, \"{siteName}\", url.PathEscape(siteName))\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\tquery := req.URL.Query()\n\tquery.Set(\"api-version\", \"2020-07-01\")\n\treq.URL.RawQuery = query.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *SQLResourcesClient) getSQLTriggerCreateRequest(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, triggerName string, options *SQLResourcesClientGetSQLTriggerOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif accountName == \"\" {\n\t\treturn nil, errors.New(\"parameter accountName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{accountName}\", url.PathEscape(accountName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif containerName == \"\" {\n\t\treturn nil, errors.New(\"parameter containerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{containerName}\", url.PathEscape(containerName))\n\tif triggerName == \"\" {\n\t\treturn nil, errors.New(\"parameter triggerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{triggerName}\", url.PathEscape(triggerName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-03-15-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *DevicesClient) getCreateRequest(ctx context.Context, resourceGroupName string, deviceName string, options *DevicesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridNetwork/devices/{deviceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif deviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter deviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{deviceName}\", url.PathEscape(deviceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-05-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *WorkspacePurgeClient) getPurgeStatusCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, purgeID string, options *WorkspacePurgeClientGetPurgeStatusOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/operations/{purgeId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif purgeID == \"\" {\n\t\treturn nil, errors.New(\"parameter purgeID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{purgeId}\", url.PathEscape(purgeID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-08-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ManagedInstancesClient) getCreateRequest(ctx context.Context, resourceGroupName string, managedInstanceName string, options *ManagedInstancesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif managedInstanceName == \"\" {\n\t\treturn nil, errors.New(\"parameter managedInstanceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{managedInstanceName}\", url.PathEscape(managedInstanceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.Expand != nil {\n\t\treqQP.Set(\"$expand\", *options.Expand)\n\t}\n\treqQP.Set(\"api-version\", \"2022-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *IncidentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, incidentID string, options *IncidentsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/incidents/{incidentId}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif incidentID == \"\" {\n\t\treturn nil, errors.New(\"parameter incidentID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{incidentId}\", url.PathEscape(incidentID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-05-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateGetMultiRateConfigRequest() (request *GetMultiRateConfigRequest) {\n\trequest = &GetMultiRateConfigRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"live\", \"2016-11-01\", \"GetMultiRateConfig\", \"live\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func (client *VirtualMachineScaleSetVMRunCommandsClient) getCreateRequest(ctx context.Context, resourceGroupName string, vmScaleSetName string, instanceID string, runCommandName string, options *VirtualMachineScaleSetVMRunCommandsGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif vmScaleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter vmScaleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vmScaleSetName}\", url.PathEscape(vmScaleSetName))\n\tif instanceID == \"\" {\n\t\treturn nil, errors.New(\"parameter instanceID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{instanceId}\", url.PathEscape(instanceID))\n\tif runCommandName == \"\" {\n\t\treturn nil, errors.New(\"parameter runCommandName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{runCommandName}\", url.PathEscape(runCommandName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif options != nil && options.Expand != nil {\n\t\treqQP.Set(\"$expand\", *options.Expand)\n\t}\n\treqQP.Set(\"api-version\", \"2021-07-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json, text/json\")\n\treturn req, nil\n}", "func (client *RoleDefinitionsClient) getByIDCreateRequest(ctx context.Context, roleID string, options *RoleDefinitionsGetByIDOptions) (*policy.Request, error) {\n\turlPath := \"/{roleId}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{roleId}\", roleID)\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ImplicitClient) getOptionalGlobalQueryCreateRequest(ctx context.Context, options *ImplicitClientGetOptionalGlobalQueryOptions) (*policy.Request, error) {\n\turlPath := \"/reqopt/global/optional/query\"\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\tif client.optionalGlobalQuery != nil {\n\t\treqQP.Set(\"optional-global-query\", strconv.FormatInt(int64(*client.optionalGlobalQuery), 10))\n\t}\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ImplicitClient) getRequiredGlobalPathCreateRequest(ctx context.Context, options *ImplicitClientGetRequiredGlobalPathOptions) (*policy.Request, error) {\n\turlPath := \"/reqopt/global/required/path/{required-global-path}\"\n\tif client.requiredGlobalPath == \"\" {\n\t\treturn nil, errors.New(\"parameter client.requiredGlobalPath cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{required-global-path}\", url.PathEscape(client.requiredGlobalPath))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func CreateGetSnapshotSettingsRequest() (request *GetSnapshotSettingsRequest) {\n\trequest = &GetSnapshotSettingsRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"R-kvstore\", \"2015-01-01\", \"GetSnapshotSettings\", \"redisa\", \"openAPI\")\n\treturn\n}", "func (client *ApplicationTypeVersionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, version string, options *ApplicationTypeVersionsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceFabric/clusters/{clusterName}/applicationTypes/{applicationTypeName}/versions/{version}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\tif applicationTypeName == \"\" {\n\t\treturn nil, errors.New(\"parameter applicationTypeName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{applicationTypeName}\", url.PathEscape(applicationTypeName))\n\tif version == \"\" {\n\t\treturn nil, errors.New(\"parameter version cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{version}\", url.PathEscape(version))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ExpressRoutePortsLocationsClient) getCreateRequest(ctx context.Context, locationName string, options *ExpressRoutePortsLocationsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/providers/Microsoft.Network/ExpressRoutePortsLocations/{locationName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif locationName == \"\" {\n\t\treturn nil, errors.New(\"parameter locationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{locationName}\", url.PathEscape(locationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ReplicationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, replicationName string, options *ReplicationsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif registryName == \"\" {\n\t\treturn nil, errors.New(\"parameter registryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{registryName}\", url.PathEscape(registryName))\n\tif replicationName == \"\" {\n\t\treturn nil, errors.New(\"parameter replicationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{replicationName}\", url.PathEscape(replicationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *ConsumerInvitationsClient) getCreateRequest(ctx context.Context, location string, invitationID string, options *ConsumerInvitationsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/providers/Microsoft.DataShare/locations/{location}/consumerInvitations/{invitationId}\"\n\tif location == \"\" {\n\t\treturn nil, errors.New(\"parameter location cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{location}\", url.PathEscape(location))\n\tif invitationID == \"\" {\n\t\treturn nil, errors.New(\"parameter invitationID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{invitationId}\", url.PathEscape(invitationID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-09-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *CompliancesClient) getCreateRequest(ctx context.Context, scope string, complianceName string, options *CompliancesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.Security/compliances/{complianceName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\tif complianceName == \"\" {\n\t\treturn nil, errors.New(\"parameter complianceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{complianceName}\", url.PathEscape(complianceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2017-08-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *WebAppsClient) getDeploymentCreateRequest(ctx context.Context, resourceGroupName string, name string, id string, options *WebAppsGetDeploymentOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/deployments/{id}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif id == \"\" {\n\t\treturn nil, errors.New(\"parameter id cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{id}\", url.PathEscape(id))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func CreateGetApplicationListRequest() (request *GetApplicationListRequest) {\n\trequest = &GetApplicationListRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"mse\", \"2019-05-31\", \"GetApplicationList\", \"mse\", \"openAPI\")\n\trequest.Method = requests.POST\n\treturn\n}", "func CreateGetFaceSearchUserRequest() (request *GetFaceSearchUserRequest) {\n\trequest = &GetFaceSearchUserRequest{\n\t\tRpcRequest: &requests.RpcRequest{},\n\t}\n\trequest.InitWithApiInfo(\"imm\", \"2017-09-06\", \"GetFaceSearchUser\", \"imm\", \"openAPI\")\n\treturn\n}", "func (client *DatabaseVulnerabilityAssessmentScansClient) getCreateRequest(ctx context.Context, resourceGroupName string, serverName string, databaseName string, vulnerabilityAssessmentName VulnerabilityAssessmentName, scanID string, options *DatabaseVulnerabilityAssessmentScansClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serverName == \"\" {\n\t\treturn nil, errors.New(\"parameter serverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serverName}\", url.PathEscape(serverName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif vulnerabilityAssessmentName == \"\" {\n\t\treturn nil, errors.New(\"parameter vulnerabilityAssessmentName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{vulnerabilityAssessmentName}\", url.PathEscape(string(vulnerabilityAssessmentName)))\n\tif scanID == \"\" {\n\t\treturn nil, errors.New(\"parameter scanID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{scanId}\", url.PathEscape(scanID))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-11-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ClustersClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/serverGroupsv2/{clusterName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif clusterName == \"\" {\n\t\treturn nil, errors.New(\"parameter clusterName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{clusterName}\", url.PathEscape(clusterName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-11-08\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *FirewallRulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesGetOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/firewallRules/{firewallRuleName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serverName == \"\" {\n\t\treturn nil, errors.New(\"parameter serverName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serverName}\", url.PathEscape(serverName))\n\tif firewallRuleName == \"\" {\n\t\treturn nil, errors.New(\"parameter firewallRuleName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{firewallRuleName}\", url.PathEscape(firewallRuleName))\n\treq, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\treqQP := req.URL.Query()\n\treqQP.Set(\"api-version\", \"2017-12-01\")\n\treq.URL.RawQuery = reqQP.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *AssociationsClient) getCreateRequest(ctx context.Context, scope string, associationName string, options *AssociationsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}\"\n\turlPath = strings.ReplaceAll(urlPath, \"{scope}\", scope)\n\tif associationName == \"\" {\n\t\treturn nil, errors.New(\"parameter associationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{associationName}\", url.PathEscape(associationName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2018-09-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *TagRulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Dynatrace.Observability/monitors/{monitorName}/tagRules/{ruleSetName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif monitorName == \"\" {\n\t\treturn nil, errors.New(\"parameter monitorName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{monitorName}\", url.PathEscape(monitorName))\n\tif ruleSetName == \"\" {\n\t\treturn nil, errors.New(\"parameter ruleSetName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{ruleSetName}\", url.PathEscape(ruleSetName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-04-27\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *WebAppsClient) getFunctionCreateRequest(ctx context.Context, resourceGroupName string, name string, functionName string, options *WebAppsGetFunctionOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/functions/{functionName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif functionName == \"\" {\n\t\treturn nil, errors.New(\"parameter functionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{functionName}\", url.PathEscape(functionName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-02-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *ReplicationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, replicationName string, options *ReplicationsGetOptions) (*azcore.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif registryName == \"\" {\n\t\treturn nil, errors.New(\"parameter registryName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{registryName}\", url.PathEscape(registryName))\n\tif replicationName == \"\" {\n\t\treturn nil, errors.New(\"parameter replicationName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{replicationName}\", url.PathEscape(replicationName))\n\treq, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Telemetry(telemetryInfo)\n\treqQP := req.URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01-preview\")\n\treq.URL.RawQuery = reqQP.Encode()\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *DicomServicesClient) getCreateRequest(ctx context.Context, resourceGroupName string, workspaceName string, dicomServiceName string, options *DicomServicesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/dicomservices/{dicomServiceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif workspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter workspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{workspaceName}\", url.PathEscape(workspaceName))\n\tif dicomServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter dicomServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{dicomServiceName}\", url.PathEscape(dicomServiceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-06-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *SQLResourcesClient) getSQLUserDefinedFunctionCreateRequest(ctx context.Context, resourceGroupName string, accountName string, databaseName string, containerName string, userDefinedFunctionName string, options *SQLResourcesClientGetSQLUserDefinedFunctionOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif accountName == \"\" {\n\t\treturn nil, errors.New(\"parameter accountName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{accountName}\", url.PathEscape(accountName))\n\tif databaseName == \"\" {\n\t\treturn nil, errors.New(\"parameter databaseName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{databaseName}\", url.PathEscape(databaseName))\n\tif containerName == \"\" {\n\t\treturn nil, errors.New(\"parameter containerName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{containerName}\", url.PathEscape(containerName))\n\tif userDefinedFunctionName == \"\" {\n\t\treturn nil, errors.New(\"parameter userDefinedFunctionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{userDefinedFunctionName}\", url.PathEscape(userDefinedFunctionName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-03-15-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *VirtualNetworkLinksClient) getCreateRequest(ctx context.Context, resourceGroupName string, privateZoneName string, virtualNetworkLinkName string, options *VirtualNetworkLinksGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateDnsZones/{privateZoneName}/virtualNetworkLinks/{virtualNetworkLinkName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif privateZoneName == \"\" {\n\t\treturn nil, errors.New(\"parameter privateZoneName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{privateZoneName}\", url.PathEscape(privateZoneName))\n\tif virtualNetworkLinkName == \"\" {\n\t\treturn nil, errors.New(\"parameter virtualNetworkLinkName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{virtualNetworkLinkName}\", url.PathEscape(virtualNetworkLinkName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-06-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *DataCollectionEndpointsClient) getCreateRequest(ctx context.Context, resourceGroupName string, dataCollectionEndpointName string, options *DataCollectionEndpointsGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif dataCollectionEndpointName == \"\" {\n\t\treturn nil, errors.New(\"parameter dataCollectionEndpointName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{dataCollectionEndpointName}\", url.PathEscape(dataCollectionEndpointName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-04-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}", "func (client *CloudServicesClient) getCreateRequest(ctx context.Context, resourceGroupName string, cloudServiceName string, options *CloudServicesClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}\"\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif cloudServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter cloudServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{cloudServiceName}\", url.PathEscape(cloudServiceName))\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-09-04\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (client *NotebookWorkspacesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, notebookWorkspaceName NotebookWorkspaceName, options *NotebookWorkspacesGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif accountName == \"\" {\n\t\treturn nil, errors.New(\"parameter accountName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{accountName}\", url.PathEscape(accountName))\n\tif notebookWorkspaceName == \"\" {\n\t\treturn nil, errors.New(\"parameter notebookWorkspaceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{notebookWorkspaceName}\", url.PathEscape(string(notebookWorkspaceName)))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2021-10-15\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header.Set(\"Accept\", \"application/json\")\n\treturn req, nil\n}" ]
[ "0.71907246", "0.6112511", "0.607343", "0.6039145", "0.6004508", "0.60000503", "0.5975623", "0.596344", "0.5930511", "0.5888355", "0.5842194", "0.58329374", "0.58214843", "0.58069664", "0.5786372", "0.57797956", "0.5777607", "0.5739794", "0.5726773", "0.5718954", "0.57172954", "0.570649", "0.57044214", "0.5697197", "0.56927323", "0.56807613", "0.5677242", "0.565976", "0.564308", "0.5641449", "0.5631516", "0.5622468", "0.562056", "0.5619841", "0.5601659", "0.55973166", "0.5595461", "0.5590116", "0.55893946", "0.55887157", "0.5585612", "0.5555662", "0.5535496", "0.5531304", "0.5485612", "0.5480837", "0.54791915", "0.54785955", "0.547043", "0.5470209", "0.5468979", "0.5467805", "0.5467192", "0.5466677", "0.5465907", "0.546145", "0.5455993", "0.54553443", "0.54517573", "0.5447496", "0.54420346", "0.543899", "0.54348", "0.5434444", "0.542853", "0.5424541", "0.5409712", "0.54044425", "0.5390053", "0.53895396", "0.53894883", "0.5376264", "0.5375195", "0.53707844", "0.5369067", "0.535666", "0.53552616", "0.5341876", "0.5339544", "0.5336449", "0.5330243", "0.53275496", "0.5325403", "0.5320522", "0.5320491", "0.53176135", "0.5314641", "0.5301148", "0.5293349", "0.52908015", "0.5286185", "0.5278572", "0.5270806", "0.5270629", "0.526229", "0.525296", "0.5252145", "0.52519625", "0.5242676", "0.5241544" ]
0.77959424
0
getBuiltInHandleResponse handles the GetBuiltIn response.
getBuiltInHandleResponse обрабатывает ответ GetBuiltIn.
func (client *PolicyDefinitionsClient) getBuiltInHandleResponse(resp *http.Response) (PolicyDefinitionsGetBuiltInResponse, error) { result := PolicyDefinitionsGetBuiltInResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.PolicyDefinition); err != nil { return PolicyDefinitionsGetBuiltInResponse{}, runtime.NewResponseError(err, resp) } return result, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *PolicyDefinitionsClient) listBuiltInHandleResponse(resp *http.Response) (PolicyDefinitionsListBuiltInResponse, error) {\n\tresult := PolicyDefinitionsListBuiltInResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PolicyDefinitionListResult); err != nil {\n\t\treturn PolicyDefinitionsListBuiltInResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *VirtualMachineScaleSetVMRunCommandsClient) getHandleResponse(resp *http.Response) (VirtualMachineScaleSetVMRunCommandsGetResponse, error) {\n\tresult := VirtualMachineScaleSetVMRunCommandsGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachineRunCommand); err != nil {\n\t\treturn VirtualMachineScaleSetVMRunCommandsGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *LiveOutputsClient) getHandleResponse(resp *http.Response) (LiveOutputsClientGetResponse, error) {\n\tresult := LiveOutputsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.LiveOutput); err != nil {\n\t\treturn LiveOutputsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *RegistrationDefinitionsClient) getHandleResponse(resp *http.Response) (RegistrationDefinitionsClientGetResponse, error) {\n\tresult := RegistrationDefinitionsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RegistrationDefinition); err != nil {\n\t\treturn RegistrationDefinitionsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *SchemaRegistryClient) getHandleResponse(resp *http.Response) (SchemaRegistryClientGetResponse, error) {\n\tresult := SchemaRegistryClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SchemaGroup); err != nil {\n\t\treturn SchemaRegistryClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *BuildServiceClient) getSupportedBuildpackHandleResponse(resp *http.Response) (BuildServiceClientGetSupportedBuildpackResponse, error) {\n\tresult := BuildServiceClientGetSupportedBuildpackResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SupportedBuildpackResource); err != nil {\n\t\treturn BuildServiceClientGetSupportedBuildpackResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WorkspacesClient) getHandleResponse(resp *http.Response) (WorkspacesGetResponse, error) {\n\tresult := WorkspacesGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Workspace); err != nil {\n\t\treturn WorkspacesGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *CustomAssessmentAutomationsClient) getHandleResponse(resp *http.Response) (CustomAssessmentAutomationsGetResponse, error) {\n\tresult := CustomAssessmentAutomationsGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.CustomAssessmentAutomation); err != nil {\n\t\treturn CustomAssessmentAutomationsGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) getHandleResponse(resp *http.Response) (WebAppsGetResponse, error) {\n\tresult := WebAppsGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Site); err != nil {\n\t\treturn WebAppsGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *OutputsClient) getHandleResponse(resp *http.Response) (OutputsGetResponse, error) {\n\tresult := OutputsGetResponse{RawResponse: resp}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Output); err != nil {\n\t\treturn OutputsGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *VirtualMachineImageTemplatesClient) getRunOutputHandleResponse(resp *http.Response) (VirtualMachineImageTemplatesClientGetRunOutputResponse, error) {\n\tresult := VirtualMachineImageTemplatesClientGetRunOutputResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RunOutput); err != nil {\n\t\treturn VirtualMachineImageTemplatesClientGetRunOutputResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *PolicyDefinitionsClient) getHandleResponse(resp *http.Response) (PolicyDefinitionsGetResponse, error) {\n\tresult := PolicyDefinitionsGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PolicyDefinition); err != nil {\n\t\treturn PolicyDefinitionsGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *PipelinesClient) getHandleResponse(resp *http.Response) (PipelinesClientGetResponse, error) {\n\tresult := PipelinesClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PipelineResource); err != nil {\n\t\treturn PipelinesClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ReplicationsClient) getHandleResponse(resp *azcore.Response) (ReplicationResponse, error) {\n\tvar val *Replication\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn ReplicationResponse{}, err\n\t}\n\treturn ReplicationResponse{RawResponse: resp.Response, Replication: val}, nil\n}", "func (client *NotebookWorkspacesClient) getHandleResponse(resp *http.Response) (NotebookWorkspacesGetResponse, error) {\n\tresult := NotebookWorkspacesGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.NotebookWorkspace); err != nil {\n\t\treturn NotebookWorkspacesGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *VirtualApplianceSitesClient) getHandleResponse(resp *azcore.Response) (VirtualApplianceSiteResponse, error) {\n\tvar val *VirtualApplianceSite\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn VirtualApplianceSiteResponse{}, err\n\t}\n\treturn VirtualApplianceSiteResponse{RawResponse: resp.Response, VirtualApplianceSite: val}, nil\n}", "func (client *ApplicationTypeVersionsClient) getHandleResponse(resp *http.Response) (ApplicationTypeVersionsClientGetResponse, error) {\n\tresult := ApplicationTypeVersionsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ApplicationTypeVersionResource); err != nil {\n\t\treturn ApplicationTypeVersionsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *LocalRulestacksClient) getHandleResponse(resp *http.Response) (LocalRulestacksClientGetResponse, error) {\n\tresult := LocalRulestacksClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.LocalRulestackResource); err != nil {\n\t\treturn LocalRulestacksClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *RoleDefinitionsClient) getHandleResponse(resp *http.Response) (RoleDefinitionsGetResponse, error) {\n\tresult := RoleDefinitionsGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil {\n\t\treturn RoleDefinitionsGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *SQLResourcesClient) getSQLUserDefinedFunctionHandleResponse(resp *http.Response) (SQLResourcesClientGetSQLUserDefinedFunctionResponse, error) {\n\tresult := SQLResourcesClientGetSQLUserDefinedFunctionResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SQLUserDefinedFunctionGetResults); err != nil {\n\t\treturn SQLResourcesClientGetSQLUserDefinedFunctionResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *GalleryImageVersionsClient) getHandleResponse(resp *azcore.Response) (GalleryImageVersionResponse, error) {\n\tvar val *GalleryImageVersion\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn GalleryImageVersionResponse{}, err\n\t}\n\treturn GalleryImageVersionResponse{RawResponse: resp.Response, GalleryImageVersion: val}, nil\n}", "func (client *AlertOperationClient) getHandleResponse(resp *http.Response) (AlertOperationClientGetResponse, error) {\n\tresult := AlertOperationClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AlertOperationResult); err != nil {\n\t\treturn AlertOperationClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *OutputsClient) getHandleResponse(resp *http.Response) (OutputsClientGetResponse, error) {\n\tresult := OutputsClientGetResponse{}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Output); err != nil {\n\t\treturn OutputsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *MonitorsClient) getHandleResponse(resp *http.Response) (MonitorsClientGetResponse, error) {\n\tresult := MonitorsClientGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.MonitorResource); err != nil {\n\t\treturn MonitorsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *AvailabilitySetsClient) getHandleResponse(resp *http.Response) (AvailabilitySetsGetResponse, error) {\n\tresult := AvailabilitySetsGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AvailabilitySet); err != nil {\n\t\treturn AvailabilitySetsGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *VirtualMachineScaleSetsClient) getHandleResponse(resp *http.Response) (VirtualMachineScaleSetsGetResponse, error) {\n\tresult := VirtualMachineScaleSetsGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachineScaleSet); err != nil {\n\t\treturn VirtualMachineScaleSetsGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ConnectedEnvironmentsClient) getHandleResponse(resp *http.Response) (ConnectedEnvironmentsClientGetResponse, error) {\n\tresult := ConnectedEnvironmentsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ConnectedEnvironment); err != nil {\n\t\treturn ConnectedEnvironmentsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *IntegrationRuntimeNodesClient) getHandleResponse(resp *http.Response) (IntegrationRuntimeNodesClientGetResponse, error) {\n\tresult := IntegrationRuntimeNodesClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SelfHostedIntegrationRuntimeNode); err != nil {\n\t\treturn IntegrationRuntimeNodesClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *InteractionsClient) getHandleResponse(resp *http.Response) (InteractionsClientGetResponse, error) {\n\tresult := InteractionsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.InteractionResourceFormat); err != nil {\n\t\treturn InteractionsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *MetricAlertsClient) getHandleResponse(resp *http.Response) (MetricAlertsClientGetResponse, error) {\n\tresult := MetricAlertsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.MetricAlertResource); err != nil {\n\t\treturn MetricAlertsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *VirtualApplianceSKUsClient) getHandleResponse(resp *azcore.Response) (NetworkVirtualApplianceSKUResponse, error) {\n\tvar val *NetworkVirtualApplianceSKU\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn NetworkVirtualApplianceSKUResponse{}, err\n\t}\n\treturn NetworkVirtualApplianceSKUResponse{RawResponse: resp.Response, NetworkVirtualApplianceSKU: val}, nil\n}", "func (client *KpiClient) getHandleResponse(resp *http.Response) (KpiClientGetResponse, error) {\n\tresult := KpiClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.KpiResourceFormat); err != nil {\n\t\treturn KpiClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ScriptExecutionsClient) getHandleResponse(resp *http.Response) (ScriptExecutionsClientGetResponse, error) {\n\tresult := ScriptExecutionsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ScriptExecution); err != nil {\n\t\treturn ScriptExecutionsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *MachineExtensionsClient) getHandleResponse(resp *http.Response) (MachineExtensionsClientGetResponse, error) {\n\tresult := MachineExtensionsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.MachineExtension); err != nil {\n\t\treturn MachineExtensionsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *SapMonitorsClient) getHandleResponse(resp *http.Response) (SapMonitorsClientGetResponse, error) {\n\tresult := SapMonitorsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SapMonitor); err != nil {\n\t\treturn SapMonitorsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *AFDOriginsClient) getHandleResponse(resp *http.Response) (AFDOriginsClientGetResponse, error) {\n\tresult := AFDOriginsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AFDOrigin); err != nil {\n\t\treturn AFDOriginsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *AnalysisResultsClient) getHandleResponse(resp *http.Response) (AnalysisResultsClientGetResponse, error) {\n\tresult := AnalysisResultsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AnalysisResultSingletonResource); err != nil {\n\t\treturn AnalysisResultsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) getTriggeredWebJobHandleResponse(resp *http.Response) (WebAppsGetTriggeredWebJobResponse, error) {\n\tresult := WebAppsGetTriggeredWebJobResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.TriggeredWebJob); err != nil {\n\t\treturn WebAppsGetTriggeredWebJobResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *SQLVirtualMachinesClient) getHandleResponse(resp *http.Response) (SQLVirtualMachinesClientGetResponse, error) {\n\tresult := SQLVirtualMachinesClientGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SQLVirtualMachine); err != nil {\n\t\treturn SQLVirtualMachinesClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DatabaseVulnerabilityAssessmentScansClient) getHandleResponse(resp *http.Response) (DatabaseVulnerabilityAssessmentScansClientGetResponse, error) {\n\tresult := DatabaseVulnerabilityAssessmentScansClientGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VulnerabilityAssessmentScanRecord); err != nil {\n\t\treturn DatabaseVulnerabilityAssessmentScansClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *TriggersClient) getHandleResponse(resp *http.Response) (TriggersClientGetResponse, error) {\n\tresult := TriggersClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result); err != nil {\n\t\treturn TriggersClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebhooksClient) getHandleResponse(resp *http.Response) (WebhooksClientGetResponse, error) {\n\tresult := WebhooksClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Webhook); err != nil {\n\t\treturn WebhooksClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) getProcessHandleResponse(resp *http.Response) (WebAppsGetProcessResponse, error) {\n\tresult := WebAppsGetProcessResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ProcessInfo); err != nil {\n\t\treturn WebAppsGetProcessResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *VirtualMachineScaleSetVMRunCommandsClient) listHandleResponse(resp *http.Response) (VirtualMachineScaleSetVMRunCommandsListResponse, error) {\n\tresult := VirtualMachineScaleSetVMRunCommandsListResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachineRunCommandsListResult); err != nil {\n\t\treturn VirtualMachineScaleSetVMRunCommandsListResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *AlertsClient) getHandleResponse(resp *http.Response) (AlertsClientGetResponse, error) {\n\tresult := AlertsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Alert); err != nil {\n\t\treturn AlertsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) getFunctionHandleResponse(resp *http.Response) (WebAppsGetFunctionResponse, error) {\n\tresult := WebAppsGetFunctionResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.FunctionEnvelope); err != nil {\n\t\treturn WebAppsGetFunctionResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *SQLResourcesClient) getSQLTriggerHandleResponse(resp *http.Response) (SQLResourcesClientGetSQLTriggerResponse, error) {\n\tresult := SQLResourcesClientGetSQLTriggerResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SQLTriggerGetResults); err != nil {\n\t\treturn SQLResourcesClientGetSQLTriggerResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *VirtualMachinesClient) getHandleResponse(resp *http.Response) (VirtualMachinesClientGetResponse, error) {\n\tresult := VirtualMachinesClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachine); err != nil {\n\t\treturn VirtualMachinesClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ManagedDatabasesClient) getHandleResponse(resp *http.Response) (ManagedDatabasesClientGetResponse, error) {\n\tresult := ManagedDatabasesClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedDatabase); err != nil {\n\t\treturn ManagedDatabasesClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *BuildServiceClient) getBuildHandleResponse(resp *http.Response) (BuildServiceClientGetBuildResponse, error) {\n\tresult := BuildServiceClientGetBuildResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Build); err != nil {\n\t\treturn BuildServiceClientGetBuildResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *VirtualNetworkLinksClient) getHandleResponse(resp *http.Response) (VirtualNetworkLinksGetResponse, error) {\n\tresult := VirtualNetworkLinksGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VirtualNetworkLink); err != nil {\n\t\treturn VirtualNetworkLinksGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ContainerAppsDiagnosticsClient) getDetectorHandleResponse(resp *http.Response) (ContainerAppsDiagnosticsClientGetDetectorResponse, error) {\n\tresult := ContainerAppsDiagnosticsClientGetDetectorResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Diagnostics); err != nil {\n\t\treturn ContainerAppsDiagnosticsClientGetDetectorResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *subscriptionClient) getHandleResponse(resp *http.Response) (SubscriptionGetResponse, error) {\n\tresult := SubscriptionGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsXML(resp, &result.Object); err != nil {\n\t\treturn SubscriptionGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *JobExecutionsClient) getHandleResponse(resp *http.Response) (JobExecutionsClientGetResponse, error) {\n\tresult := JobExecutionsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.JobExecution); err != nil {\n\t\treturn JobExecutionsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *RecordSetsClient) getHandleResponse(resp *azcore.Response) (RecordSetResponse, error) {\n\tvar val *RecordSet\n\tif err := resp.UnmarshalAsJSON(&val); err != nil {\n\t\treturn RecordSetResponse{}, err\n\t}\n\treturn RecordSetResponse{RawResponse: resp.Response, RecordSet: val}, nil\n}", "func (client *VendorNetworkFunctionsClient) getHandleResponse(resp *http.Response) (VendorNetworkFunctionsClientGetResponse, error) {\n\tresult := VendorNetworkFunctionsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VendorNetworkFunction); err != nil {\n\t\treturn VendorNetworkFunctionsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *DscCompilationJobClient) getHandleResponse(resp *http.Response) (DscCompilationJobClientGetResponse, error) {\n\tresult := DscCompilationJobClientGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.DscCompilationJob); err != nil {\n\t\treturn DscCompilationJobClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *PermissionBindingsClient) getHandleResponse(resp *http.Response) (PermissionBindingsClientGetResponse, error) {\n\tresult := PermissionBindingsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PermissionBinding); err != nil {\n\t\treturn PermissionBindingsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *AgentPoolsClient) getHandleResponse(resp *http.Response) (AgentPoolsClientGetResponse, error) {\n\tresult := AgentPoolsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.AgentPool); err != nil {\n\t\treturn AgentPoolsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *AgentsClient) getHandleResponse(resp *http.Response) (AgentsClientGetResponse, error) {\n\tresult := AgentsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Agent); err != nil {\n\t\treturn AgentsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ReplicationsClient) getHandleResponse(resp *http.Response) (ReplicationsClientGetResponse, error) {\n\tresult := ReplicationsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Replication); err != nil {\n\t\treturn ReplicationsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *CompliancesClient) getHandleResponse(resp *http.Response) (CompliancesClientGetResponse, error) {\n\tresult := CompliancesClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Compliance); err != nil {\n\t\treturn CompliancesClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ActionsClient) getHandleResponse(resp *http.Response) (ActionsClientGetResponse, error) {\n\tresult := ActionsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ActionResponse); err != nil {\n\t\treturn ActionsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WorkflowsClient) getHandleResponse(resp *http.Response) (WorkflowsClientGetResponse, error) {\n\tresult := WorkflowsClientGetResponse{}\n\tif val := resp.Header.Get(\"x-ms-request-id\"); val != \"\" {\n\t\tresult.XMSRequestID = &val\n\t}\n\tif val := resp.Header.Get(\"x-ms-correlation-request-id\"); val != \"\" {\n\t\tresult.XMSCorrelationRequestID = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Workflow); err != nil {\n\t\treturn WorkflowsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ManagedClustersClient) getHandleResponse(resp *http.Response) (ManagedClustersClientGetResponse, error) {\n\tresult := ManagedClustersClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedCluster); err != nil {\n\t\treturn ManagedClustersClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) listHandleResponse(resp *http.Response) (WebAppsListResponse, error) {\n\tresult := WebAppsListResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.WebAppCollection); err != nil {\n\t\treturn WebAppsListResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *VirtualMachineImageTemplatesClient) getHandleResponse(resp *http.Response) (VirtualMachineImageTemplatesClientGetResponse, error) {\n\tresult := VirtualMachineImageTemplatesClientGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ImageTemplate); err != nil {\n\t\treturn VirtualMachineImageTemplatesClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *IPAllocationsClient) getHandleResponse(resp *http.Response) (IPAllocationsClientGetResponse, error) {\n\tresult := IPAllocationsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.IPAllocation); err != nil {\n\t\treturn IPAllocationsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *LiveOutputsClient) listHandleResponse(resp *http.Response) (LiveOutputsClientListResponse, error) {\n\tresult := LiveOutputsClientListResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.LiveOutputListResult); err != nil {\n\t\treturn LiveOutputsClientListResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ReplicationvCentersClient) getHandleResponse(resp *http.Response) (ReplicationvCentersClientGetResponse, error) {\n\tresult := ReplicationvCentersClientGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VCenter); err != nil {\n\t\treturn ReplicationvCentersClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client JobClient) GetOutputResponder(resp *http.Response) (result String, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result.Value),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (client *CustomDomainsClient) getHandleResponse(resp *http.Response) (CustomDomainsGetResponse, error) {\n\tresult := CustomDomainsGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.CustomDomainResource); err != nil {\n\t\treturn CustomDomainsGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *PortalConfigClient) getHandleResponse(resp *http.Response) (PortalConfigClientGetResponse, error) {\n\tresult := PortalConfigClientGetResponse{}\n\tif val := resp.Header.Get(\"ETag\"); val != \"\" {\n\t\tresult.ETag = &val\n\t}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PortalConfigContract); err != nil {\n\t\treturn PortalConfigClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *GremlinResourcesClient) getGremlinDatabaseHandleResponse(resp *http.Response) (GremlinResourcesClientGetGremlinDatabaseResponse, error) {\n\tresult := GremlinResourcesClientGetGremlinDatabaseResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.GremlinDatabaseGetResults); err != nil {\n\t\treturn GremlinResourcesClientGetGremlinDatabaseResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *TaskRunsClient) getHandleResponse(resp *http.Response) (TaskRunsClientGetResponse, error) {\n\tresult := TaskRunsClientGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.TaskRun); err != nil {\n\t\treturn TaskRunsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *VirtualMachineImagesEdgeZoneClient) getHandleResponse(resp *http.Response) (VirtualMachineImagesEdgeZoneClientGetResponse, error) {\n\tresult := VirtualMachineImagesEdgeZoneClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VirtualMachineImage); err != nil {\n\t\treturn VirtualMachineImagesEdgeZoneClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *SourceControlConfigurationsClient) getHandleResponse(resp *http.Response) (SourceControlConfigurationsClientGetResponse, error) {\n\tresult := SourceControlConfigurationsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SourceControlConfiguration); err != nil {\n\t\treturn SourceControlConfigurationsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ExpressRoutePortsLocationsClient) getHandleResponse(resp *http.Response) (ExpressRoutePortsLocationsClientGetResponse, error) {\n\tresult := ExpressRoutePortsLocationsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ExpressRoutePortsLocation); err != nil {\n\t\treturn ExpressRoutePortsLocationsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ManagedInstancesClient) getHandleResponse(resp *http.Response) (ManagedInstancesClientGetResponse, error) {\n\tresult := ManagedInstancesClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedInstance); err != nil {\n\t\treturn ManagedInstancesClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *FirewallRulesClient) getHandleResponse(resp *azcore.Response) (FirewallRulesGetResponse, error) {\n\tresult := FirewallRulesGetResponse{RawResponse: resp.Response}\n\tif err := resp.UnmarshalAsJSON(&result.FirewallRule); err != nil {\n\t\treturn FirewallRulesGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ManagementAssociationsClient) getHandleResponse(resp *http.Response) (ManagementAssociationsGetResponse, error) {\n\tresult := ManagementAssociationsGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagementAssociation); err != nil {\n\t\treturn ManagementAssociationsGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) getProcessModuleHandleResponse(resp *http.Response) (WebAppsGetProcessModuleResponse, error) {\n\tresult := WebAppsGetProcessModuleResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ProcessModuleInfo); err != nil {\n\t\treturn WebAppsGetProcessModuleResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) getTriggeredWebJobHistoryHandleResponse(resp *http.Response) (WebAppsGetTriggeredWebJobHistoryResponse, error) {\n\tresult := WebAppsGetTriggeredWebJobHistoryResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.TriggeredJobHistory); err != nil {\n\t\treturn WebAppsGetTriggeredWebJobHistoryResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *GuestAgentsClient) getHandleResponse(resp *http.Response) (GuestAgentsClientGetResponse, error) {\n\tresult := GuestAgentsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.GuestAgent); err != nil {\n\t\treturn GuestAgentsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *RouteTablesClient) getHandleResponse(resp *http.Response) (RouteTablesGetResponse, error) {\n\tresult := RouteTablesGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RouteTable); err != nil {\n\t\treturn RouteTablesGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *MonitoringSettingsClient) getHandleResponse(resp *http.Response) (MonitoringSettingsClientGetResponse, error) {\n\tresult := MonitoringSettingsClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.MonitoringSettingResource); err != nil {\n\t\treturn MonitoringSettingsClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) getWebJobHandleResponse(resp *http.Response) (WebAppsGetWebJobResponse, error) {\n\tresult := WebAppsGetWebJobResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.WebJob); err != nil {\n\t\treturn WebAppsGetWebJobResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) getTriggeredWebJobSlotHandleResponse(resp *http.Response) (WebAppsGetTriggeredWebJobSlotResponse, error) {\n\tresult := WebAppsGetTriggeredWebJobSlotResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.TriggeredWebJob); err != nil {\n\t\treturn WebAppsGetTriggeredWebJobSlotResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) getConfigurationHandleResponse(resp *http.Response) (WebAppsGetConfigurationResponse, error) {\n\tresult := WebAppsGetConfigurationResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SiteConfigResource); err != nil {\n\t\treturn WebAppsGetConfigurationResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *VirtualRoutersClient) getHandleResponse(resp *http.Response) (VirtualRoutersClientGetResponse, error) {\n\tresult := VirtualRoutersClientGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.VirtualRouter); err != nil {\n\t\treturn VirtualRoutersClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *SQLResourcesClient) getSQLStoredProcedureHandleResponse(resp *http.Response) (SQLResourcesClientGetSQLStoredProcedureResponse, error) {\n\tresult := SQLResourcesClientGetSQLStoredProcedureResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.SQLStoredProcedureGetResults); err != nil {\n\t\treturn SQLResourcesClientGetSQLStoredProcedureResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *PolicyDefinitionsClient) getAtManagementGroupHandleResponse(resp *http.Response) (PolicyDefinitionsGetAtManagementGroupResponse, error) {\n\tresult := PolicyDefinitionsGetAtManagementGroupResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PolicyDefinition); err != nil {\n\t\treturn PolicyDefinitionsGetAtManagementGroupResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *BuildServiceClient) getBuildServiceHandleResponse(resp *http.Response) (BuildServiceClientGetBuildServiceResponse, error) {\n\tresult := BuildServiceClientGetBuildServiceResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.BuildService); err != nil {\n\t\treturn BuildServiceClientGetBuildServiceResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *LongTermRetentionManagedInstanceBackupsClient) getHandleResponse(resp *http.Response) (LongTermRetentionManagedInstanceBackupsGetResponse, error) {\n\tresult := LongTermRetentionManagedInstanceBackupsGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ManagedInstanceLongTermRetentionBackup); err != nil {\n\t\treturn LongTermRetentionManagedInstanceBackupsGetResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *ContainerAppsDiagnosticsClient) getRootHandleResponse(resp *http.Response) (ContainerAppsDiagnosticsClientGetRootResponse, error) {\n\tresult := ContainerAppsDiagnosticsClientGetRootResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ContainerApp); err != nil {\n\t\treturn ContainerAppsDiagnosticsClientGetRootResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *ReplicationProtectionContainersClient) getHandleResponse(resp *http.Response) (ReplicationProtectionContainersClientGetResponse, error) {\n\tresult := ReplicationProtectionContainersClientGetResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.ProtectionContainer); err != nil {\n\t\treturn ReplicationProtectionContainersClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *Client) getEmbeddingsHandleResponse(resp *http.Response) (GetEmbeddingsResponse, error) {\n\tresult := GetEmbeddingsResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.Embeddings); err != nil {\n\t\treturn GetEmbeddingsResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *WebAppsClient) getHostNameBindingHandleResponse(resp *http.Response) (WebAppsGetHostNameBindingResponse, error) {\n\tresult := WebAppsGetHostNameBindingResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.HostNameBinding); err != nil {\n\t\treturn WebAppsGetHostNameBindingResponse{}, runtime.NewResponseError(err, resp)\n\t}\n\treturn result, nil\n}", "func (client *RegistrationDefinitionsClient) listHandleResponse(resp *http.Response) (RegistrationDefinitionsClientListResponse, error) {\n\tresult := RegistrationDefinitionsClientListResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.RegistrationDefinitionList); err != nil {\n\t\treturn RegistrationDefinitionsClientListResponse{}, err\n\t}\n\treturn result, nil\n}", "func (client *BuildServiceClient) getBuildResultHandleResponse(resp *http.Response) (BuildServiceClientGetBuildResultResponse, error) {\n\tresult := BuildServiceClientGetBuildResultResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.BuildResult); err != nil {\n\t\treturn BuildServiceClientGetBuildResultResponse{}, err\n\t}\n\treturn result, nil\n}" ]
[ "0.76707584", "0.621644", "0.617529", "0.6060703", "0.60193557", "0.59729016", "0.5909901", "0.5874821", "0.5868759", "0.5813757", "0.57856905", "0.5783472", "0.57720095", "0.5766566", "0.57617915", "0.5760955", "0.57606834", "0.5749354", "0.57492363", "0.572956", "0.5728529", "0.57213163", "0.5705168", "0.5702858", "0.5676205", "0.56486666", "0.5639825", "0.56319714", "0.5629528", "0.5627667", "0.5620363", "0.56170624", "0.5611811", "0.56114924", "0.5607766", "0.5603515", "0.5591774", "0.5588677", "0.55854315", "0.5584036", "0.5565719", "0.5543942", "0.55434936", "0.5543315", "0.5540855", "0.55389535", "0.55364454", "0.55318147", "0.552672", "0.5523335", "0.5513076", "0.5505308", "0.5503693", "0.5496195", "0.54932356", "0.5492931", "0.5489195", "0.548413", "0.5480101", "0.54537946", "0.5440487", "0.5429066", "0.54271716", "0.54218656", "0.54168737", "0.54119784", "0.5411533", "0.538122", "0.53765464", "0.5376111", "0.53740203", "0.53725266", "0.5372324", "0.53686017", "0.53662", "0.5359172", "0.53589237", "0.5357592", "0.5349699", "0.53490585", "0.5342232", "0.533927", "0.53366274", "0.5333562", "0.5332224", "0.5328307", "0.5326817", "0.53263557", "0.53177565", "0.5305247", "0.53029966", "0.52972555", "0.52954364", "0.52915794", "0.52814573", "0.5277765", "0.52759963", "0.52755433", "0.5273516", "0.52734905" ]
0.8222317
0