// UpdateTelegrafConfig checks to see if the authorizer on context has write access to the telegraf config provided.
975892
func (s *TelegrafConfigService) UpdateTelegrafConfig(ctx context.Context, id influxdb.ID, upd *influxdb.TelegrafConfig, userID influxdb.ID) (*influxdb.TelegrafConfig, error) {
	tc, err := s.FindTelegrafConfigByID(ctx, id)
	if err != nil {
		return nil, err
	}

	if err := authorizeWriteTelegraf(ctx, tc.OrganizationID, id); err != nil {
		return nil, err
	}

	return s.s.UpdateTelegrafConfig(ctx, id, upd, userID)
}
491883
func UpdateConfigHandler(ctx *router.Context) {
	c, h := ctx.Context, ctx.Writer
	// Needed to access the PubSub API
	c = appengine.WithContext(c, ctx.Request)
	projErr := common.UpdateConsoles(c)
	if projErr != nil {
		if merr, ok := projErr.(errors.MultiError); ok {
			for _, ierr := range merr {
				logging.WithError(ierr).Errorf(c, "project update handler encountered error")
			}
		} else {
			logging.WithError(projErr).Errorf(c, "project update handler encountered error")
		}
	}
	settings, servErr := common.UpdateServiceConfig(c)
	if servErr != nil {
		logging.WithError(servErr).Errorf(c, "service update handler encountered error")
	} else {
		servErr = common.EnsurePubSubSubscribed(c, settings)
		if servErr != nil {
			logging.WithError(servErr).Errorf(
				c, "pubsub subscriber handler encountered error")
		}
	}
	if projErr != nil || servErr != nil {
		h.WriteHeader(http.StatusInternalServerError)
		return
	}
	h.WriteHeader(http.StatusOK)
}
1343429
func updateKubeConfig(h *host.Host, c *cfg.Config) *pkgutil.KubeConfigSetup {
	addr, err := h.Driver.GetURL()
	if err != nil {
		exit.WithError("Failed to get driver URL", err)
	}
	addr = strings.Replace(addr, "tcp://", "https://", -1)
	addr = strings.Replace(addr, ":2376", ":"+strconv.Itoa(c.KubernetesConfig.NodePort), -1)
	if c.KubernetesConfig.APIServerName != constants.APIServerName {
		addr = strings.Replace(addr, c.KubernetesConfig.NodeIP, c.KubernetesConfig.APIServerName, -1)
	}

	kcs := &pkgutil.KubeConfigSetup{
		ClusterName:          cfg.GetMachineName(),
		ClusterServerAddress: addr,
		ClientCertificate:    constants.MakeMiniPath("client.crt"),
		ClientKey:            constants.MakeMiniPath("client.key"),
		CertificateAuthority: constants.MakeMiniPath("ca.crt"),
		KeepContext:          viper.GetBool(keepContext),
		EmbedCerts:           viper.GetBool(embedCerts),
	}
	kcs.SetKubeConfigFile(cmdutil.GetKubeConfigPath())
	if err := pkgutil.SetupKubeConfig(kcs); err != nil {
		exit.WithError("Failed to setup kubeconfig", err)
	}
	return kcs
}
142961
func UpdateHandler(ctx *router.Context) {
	c, h := ctx.Context, ctx.Writer
	c, _ = context.WithTimeout(c, time.Minute)
	if err := updateProjects(c); err != nil {
		logging.WithError(err).Errorf(c, "error while updating project configs")
		h.WriteHeader(http.StatusInternalServerError)
		return
	}
	if err := updateSettings(c); err != nil {
		logging.WithError(err).Errorf(c, "error while updating settings")
		h.WriteHeader(http.StatusInternalServerError)
		return
	}
	h.WriteHeader(http.StatusOK)
}
996151
func (c *Client) PutTelegrafConfig(ctx context.Context, tc *platform.TelegrafConfig) error {
	return c.db.Update(func(tx *bolt.Tx) (err error) {
		pErr := c.putTelegrafConfig(ctx, tx, tc)
		if pErr != nil {
			err = pErr
		}
		return nil
	})
}
998969
func (c *client) UpdateConfiguration(ctx context.Context, throttlerName string, configuration *throttlerdatapb.Configuration, copyZeroValues bool) ([]string, error) {
	response, err := c.gRPCClient.UpdateConfiguration(ctx, &throttlerdatapb.UpdateConfigurationRequest{
		ThrottlerName:  throttlerName,
		Configuration:  configuration,
		CopyZeroValues: copyZeroValues,
	})
	if err != nil {
		return nil, vterrors.FromGRPC(err)
	}
	return response.Names, nil
}
482453
func (s *Service) DeleteTelegrafConfig(ctx context.Context, id influxdb.ID) error {
	return s.kv.Update(ctx, func(tx Tx) error {
		return s.deleteTelegrafConfig(ctx, tx, id)
	})
}
1008143
func (s *TelegrafConfigStore) DeleteTelegrafConfig(ctx context.Context, id platform.ID) error {
	return s.DeleteTelegrafConfigF(ctx, id)
}
1103385
func (c *Client) UpdateFabricVLAN(vlan FabricVLAN) (*FabricVLAN, error) {
	var resp FabricVLAN
	req := request{
		method:         client.PUT,
		url:            makeURL(apiFabricVLANs, strconv.Itoa(int(vlan.Id))),
		reqValue:       vlan,
		resp:           &resp,
		expectedStatus: http.StatusAccepted,
	}
	if _, err := c.sendRequest(req); err != nil {
		return nil, errors.Newf(err, "failed to update fabric VLAN with id %d to %s - %s", vlan.Id, vlan.Name, vlan.Description)
	}
	return &resp, nil
}
216587
func UpdateInheritedControllerConfig(pool *StatePool) error {
	st := pool.SystemState()
	model, err := st.Model()
	if err != nil {
		return errors.Trace(err)
	}
	key := cloudGlobalKey(model.Cloud())

	var ops []txn.Op
	coll, closer := st.db().GetRawCollection(globalSettingsC)
	defer closer()
	iter := coll.FindId("controller").Iter()
	defer iter.Close()
	var doc settingsDoc
	for iter.Next(&doc) {
		ops = append(ops, txn.Op{
			C:      globalSettingsC,
			Id:     doc.DocID,
			Remove: true,
			Assert: txn.DocExists,
		})
		doc.DocID = key
		ops = append(ops, txn.Op{
			C:      globalSettingsC,
			Id:     key,
			Insert: doc,
			Assert: txn.DocMissing,
		})
	}
	if err := iter.Close(); err != nil {
		return errors.Trace(err)
	}
	if len(ops) > 0 {
		err = errors.Trace(st.runRawTransaction(ops))
		return err
	}
	return nil
}
927521
func (s *Server) UpdateServerConfig(cfg map[string]string) error {
	svr, eTag, err := s.GetServer()
	if err != nil {
		return errors.Trace(err)
	}
	if svr.Config == nil {
		svr.Config = make(map[string]interface{})
	}
	for k, v := range cfg {
		svr.Config[k] = v
	}
	return errors.Trace(s.UpdateServer(svr.Writable(), eTag))
}
794965
func (l *Live) UpdateLiveDetectNotifyConfig(notifyUrl string, resp interface{}) (err error) {
	req := l.cloneRequest(UpdateLiveDetectNotifyConfigAction)
	req.SetArgs("NotifyUrl", notifyUrl)
	err = l.rpc.Query(req, resp)
	return
}
1038952
func (r *RemoteRuntimeService) UpdateRuntimeConfig(runtimeConfig *runtimeapi.RuntimeConfig) error {
	ctx, cancel := getContextWithTimeout(r.timeout)
	defer cancel()

	// Response doesn't contain anything of interest. This translates to an
	// Event notification to the network plugin, which can't fail, so we're
	// really looking to surface destination unreachable.
	_, err := r.runtimeClient.UpdateRuntimeConfig(ctx, &runtimeapi.UpdateRuntimeConfigRequest{
		RuntimeConfig: runtimeConfig,
	})

	if err != nil {
		return err
	}

	return nil
}
377155
func (s *TelegrafConfigStore) CreateTelegrafConfig(ctx context.Context, tc *platform.TelegrafConfig, userID platform.ID) error {
	return s.CreateTelegrafConfigF(ctx, tc, userID)
}
573709
func (s *Service) FindTelegrafConfigs(ctx context.Context, filter platform.TelegrafConfigFilter, opt ...platform.FindOptions) (tcs []*platform.TelegrafConfig, n int, err error) {
	op := OpPrefix + platform.OpFindTelegrafConfigs
	var pErr *platform.Error
	tcs, n, pErr = s.findTelegrafConfigs(ctx, filter)
	if pErr != nil {
		pErr.Op = op
		err = pErr
	}
	return tcs, n, err
}
433264
func makeTeleportClientConfig(ctx *SessionContext) (*client.Config, error) {
	agent, cert, err := ctx.GetAgent()
	if err != nil {
		return nil, trace.BadParameter("failed to get user credentials: %v", err)
	}

	signers, err := agent.Signers()
	if err != nil {
		return nil, trace.BadParameter("failed to get user credentials: %v", err)
	}

	tlsConfig, err := ctx.ClientTLSConfig()
	if err != nil {
		return nil, trace.BadParameter("failed to get client TLS config: %v", err)
	}

	config := &client.Config{
		Username:         ctx.user,
		Agent:            agent,
		SkipLocalAuth:    true,
		TLS:              tlsConfig,
		AuthMethods:      []ssh.AuthMethod{ssh.PublicKeys(signers...)},
		DefaultPrincipal: cert.ValidPrincipals[0],
		HostKeyCallback:  func(string, net.Addr, ssh.PublicKey) error { return nil },
	}

	return config, nil
}
968905
func (s *SecurityConfig) UpdateTLSCredentials(certificate *tls.Certificate, issuerInfo *IssuerInfo) error {
	s.mu.Lock()
	defer s.mu.Unlock()
	return s.updateTLSCredentials(certificate, issuerInfo)
}