// getClient safely returns an sioInterface
768456
func (m *sioMgr) getClient() (sioInterface, error) {
	if m.client == nil {
		klog.V(4).Info(log("creating scaleio client"))
		configs := m.configData
		username := configs[confKey.username]
		password := configs[confKey.password]
		gateway := configs[confKey.gateway]
		b, err := strconv.ParseBool(configs[confKey.sslEnabled])
		if err != nil {
			klog.Error(log("failed to parse sslEnabled, must be either \"true\" or \"false\""))
			return nil, err
		}
		certsEnabled := b

		klog.V(4).Info(log("creating new client for gateway %s", gateway))
		client, err := newSioClient(gateway, username, password, certsEnabled, m.exec)
		if err != nil {
			klog.Error(log("failed to create scaleio client: %v", err))
			return nil, err
		}

		client.sysName = configs[confKey.system]
		client.pdName = configs[confKey.protectionDomain]
		client.spName = configs[confKey.storagePool]
		client.sdcPath = configs[confKey.sdcRootPath]
		client.provisionMode = configs[confKey.storageMode]
		client.sdcGUID = configs[confKey.sdcGUID]

		m.client = client

		klog.V(4).Info(log("client created successfully [gateway=%s]", gateway))
	}
	return m.client, nil
}
123403
func getRequestingClientFromRequest(r *http.Request, w http.ResponseWriter, organizationGlobalID string, allowOnWebsite bool) (string, bool) {
	requestingClient, validClient := context.Get(r, "client_id").(string)
	if !validClient {
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return requestingClient, false
	}
	if requestingClient == "itsyouonline" {
		if allowOnWebsite {
			requestingClient = organizationGlobalID
		} else {
			// This should never happen as the oauth 2  middleware should give a 403
			writeErrorResponse(w, http.StatusBadRequest, "This api call is not available when logged in via the website")
			return requestingClient, false
		}
	} else if requestingClient != organizationGlobalID {
		writeErrorResponse(w, http.StatusForbidden, "unauthorized_organization")
		return requestingClient, false
	}
	return requestingClient, true
}
97773
func (c *FluxV1beta1Client) RESTClient() rest.Interface {
	if c == nil {
		return nil
	}
	return c.restClient
}
1243454
func GetKubernetesClient() (kubernetes.Interface, error) {
	config, err := rest.InClusterConfig()
	if err != nil {
		return nil, err
	}

	return kubernetes.NewForConfig(config)
}
258284
func GetClientIP(req *http.Request) net.IP {
	ips := SourceIPs(req)
	if len(ips) == 0 {
		return nil
	}
	return ips[0]
}
1328459
func (k *K8sClientGetter) GetCoreClient() (corev1.CoreV1Interface, error) {
	client, err := k.GetClientset(constants.DefaultK8sClientTimeout)
	if err != nil {
		return nil, errors.Wrap(err, "getting clientset")
	}
	return client.Core(), nil
}
905281
func (c *TraefikV1alpha1Client) RESTClient() rest.Interface {
	if c == nil {
		return nil
	}
	return c.restClient
}
199700
func (s *Storage) GetClient(id string) (osin.Client, error) {
	var client service.Client
	if err := dbconn.DB.Where("id = ?", id).Find(&client).Error; err != nil {
		return nil, err
	}

	var c osin.DefaultClient
	copier.Copy(&c, &client)
	c.UserData = client.UserId
	return &c, nil
}
276932
func getStorageClient(
	newClient internalazurestorage.NewClientFunc,
	storageEndpoint string,
	storageAccount *armstorage.Account,
	storageAccountKey *armstorage.AccountKey,
) (internalazurestorage.Client, error) {
	storageAccountName := to.String(storageAccount.Name)
	const useHTTPS = true
	return newClient(
		storageAccountName,
		to.String(storageAccountKey.Value),
		storageEndpoint,
		azurestorage.DefaultAPIVersion,
		useHTTPS,
	)
}
306292
func (client *Instance) GET() (statusCode int, body []byte, err error) {
	api, err := client.nextServer()
	if err != nil {
		return 0, nil, err
	}

	return api.HostClient.Get(nil, api.Addr)
}
1023266
func (cs ClientsService) Get(id, token string) (Client, error) {
	resp, err := newNetworkClient(cs.config).MakeRequest(network.Request{
		Method:                "GET",
		Path:                  fmt.Sprintf("/oauth/clients/%s", id),
		Authorization:         network.NewTokenAuthorization(token),
		AcceptableStatusCodes: []int{http.StatusOK},
	})
	if err != nil {
		return Client{}, translateError(err)
	}

	var document documents.ClientResponse
	err = json.Unmarshal(resp.Body, &document)
	if err != nil {
		return Client{}, MalformedResponseError{err}
	}

	return newClientFromDocument(document), nil
}
1354589
func (b *Birc) getClient() (*girc.Client, error) {
	server, portstr, err := net.SplitHostPort(b.GetString("Server"))
	if err != nil {
		return nil, err
	}
	port, err := strconv.Atoi(portstr)
	if err != nil {
		return nil, err
	}
	// fix strict user handling of girc
	user := b.GetString("Nick")
	for !girc.IsValidUser(user) {
		if len(user) == 1 || len(user) == 0 {
			user = "matterbridge"
			break
		}
		user = user[1:]
	}

	i := girc.New(girc.Config{
		Server:     server,
		ServerPass: b.GetString("Password"),
		Port:       port,
		Nick:       b.GetString("Nick"),
		User:       user,
		Name:       b.GetString("Nick"),
		SSL:        b.GetBool("UseTLS"),
		TLSConfig:  &tls.Config{InsecureSkipVerify: b.GetBool("SkipTLSVerify"), ServerName: server}, //nolint:gosec
		PingDelay:  time.Minute,
	})
	return i, nil
}
1046390
func (s *Sensu) GetClientsSlice(limit int, offset int) ([]interface{}, error) {
	return s.getList("clients", limit, offset)
}
465775
func (c *Conn) getClient() (*StreamClient, error) {
	// Check for cached client
	c.clientLock.Lock()
	front := c.clients.Front()
	if front != nil {
		c.clients.Remove(front)
	}
	c.clientLock.Unlock()
	if front != nil {
		return front.Value.(*StreamClient), nil
	}

	// Open a new session
	stream, err := c.session.Open()
	if err != nil {
		return nil, err
	}

	// Create the RPC client
	codec := msgpackrpc.NewClientCodec(stream)

	// Return a new stream client
	sc := &StreamClient{
		stream: stream,
		codec:  codec,
	}
	return sc, nil
}
887172
func (vm *VM) getServiceClient() (hostedservice.HostedServiceClient, error) {
	c, err := vm.getClient()
	if err != nil {
		return hostedservice.HostedServiceClient{}, err
	}

	return hostedservice.NewClient(c), nil
}
1063145
func (s *OAuth2Storage) GetClient(id string) (osin.Client, error) {
	var err error
	var numericID uint64
	if numericID, err = strconv.ParseUint(id, 10, 64); err != nil {
		return nil, fmt.Errorf("invalid client_id: %s", id)
	}

	client := new(OAuth2Client)
	err = Db().First(client, numericID)
	return client, err
}
200713
func (c *CoordinationV1Client) RESTClient() rest.Interface {
	if c == nil {
		return nil
	}
	return c.restClient
}