// NewMachineClient creates a machine-wide client, updating applications
// that may be used by multiple users. On Linux the system's machine id
// is used as the user id, and boot id is used as the omaha session id.
508819
func NewMachineClient(serverURL string) (*Client, error) {
	machineID, err := ioutil.ReadFile(machineIDPath)
	if err != nil {
		fmt.Errorf("omaha: failed to read machine id: %v", err)
	}

	machineID = bytes.TrimSpace(machineID)
	// Although machineID should be a UUID, it is formatted as a
	// plain hex string, omitting the normal '-' separators, so it
	// should be 32 bytes long. It would be nice to reformat it to
	// add the '-' chars but update_engine doesn't so stick with its
	// behavior for now.
	if len(machineID) < 32 {
		fmt.Errorf("omaha: incomplete machine id: %q",
			machineID)
	}

	bootID, err := ioutil.ReadFile(bootIDPath)
	if err != nil {
		fmt.Errorf("omaha: failed to read boot id: %v", err)
	}

	bootID = bytes.TrimSpace(bootID)
	// unlike machineID, bootID *does* include '-' chars.
	if len(bootID) < 36 {
		fmt.Errorf("omaha: incomplete boot id: %q", bootID)
	}

	c := &Client{
		apiClient:     newHTTPClient(),
		clientVersion: defaultClientVersion,
		userID:        string(machineID),
		sessionID:     string(bootID),
		isMachine:     true,
		apps:          make(map[string]*AppClient),
	}

	if err := c.SetServerURL(serverURL); err != nil {
		return nil, err
	}

	return c, nil
}
1082512
func NewRedisClient(machines []string, password string, separator string) (*Client, error) {
	if separator == "" {
		separator = "/"
	}
	log.Debug(fmt.Sprintf("Redis Separator: %#v", separator))
	var err error
	clientWrapper := &Client{machines: machines, password: password, separator: separator, client: nil, pscChan: make(chan watchResponse), psc: redis.PubSubConn{Conn: nil} }
	clientWrapper.client, _, err = tryConnect(machines, password, true)
	return clientWrapper, err
}
626283
func (n *Netrc) AddMachine(name, login, password string) {
	machine := n.Machine(name)
	if machine == nil {
		machine = &Machine{}
		n.machines = append(n.machines, machine)
	}
	machine.Name = name
	machine.tokens = []string{"machine ", name, "\n"}
	machine.Set("login", login)
	machine.Set("password", password)
}
47100
func NewClient(rw io.ReadWriter, config ClientConfig) *Client {
	c := &Client{
		Conn:    NewConn(rw),
		config:  config,
		errChan: make(chan error, 1),
		caps:    make(map[string]cap),
	}

	// Replace the writer writeCallback with one of our own
	c.Conn.Writer.writeCallback = c.writeCallback

	return c
}
898281
func NewClient(apiDef *raml.APIDefinition, dir string) Client {
	return Client{
		APIDef: apiDef,
		Dir:    dir,
	}
}
410358
func NewClient() *Client {
	c := new(Client)
	c.SetSoftwareName(DefaultSoftwareName)
	c.logger = NewLogger()
	return c
}
1114989
func newClient(key string, url string, http *http.Client) *v1controller.Client {
	c := &v1controller.Client{
		Client: &httpclient.Client{
			ErrNotFound: ErrNotFound,
			Key:         key,
			URL:         url,
			HTTP:        http,
		},
	}
	return c
}
1290194
func NewClient(t string, conf map[string]string) (Client, error) {
	f, ok := BuiltinClients[t]
	if !ok {
		return nil, fmt.Errorf("unknown remote client type: %s", t)
	}

	return f(conf)
}
863965
func NewClient(conf ClientConfig) (*Client, error) {
	if conf.SampleRate == 0 {
		conf.SampleRate = defaultSampleRate
	}
	if conf.APIHost == "" {
		conf.APIHost = defaultAPIHost
	}
	if conf.Dataset == "" {
		conf.Dataset = defaultDataset
	}

	c := &Client{
		logger: conf.Logger,
	}
	c.ensureLogger()

	if conf.Transmission == nil {
		c.transmission = &transmission.Honeycomb{
			MaxBatchSize:         DefaultMaxBatchSize,
			BatchTimeout:         DefaultBatchTimeout,
			MaxConcurrentBatches: DefaultMaxConcurrentBatches,
			PendingWorkCapacity:  DefaultPendingWorkCapacity,
			UserAgentAddition:    UserAgentAddition,
			Logger:               c.logger,
			Metrics:              sd,
		}
	} else {
		c.transmission = conf.Transmission
	}
	if err := c.transmission.Start(); err != nil {
		c.logger.Printf("transmission client failed to start: %s", err.Error())
		return nil, err
	}

	c.builder = &Builder{
		WriteKey:   conf.APIKey,
		Dataset:    conf.Dataset,
		SampleRate: conf.SampleRate,
		APIHost:    conf.APIHost,
		dynFields:  make([]dynamicField, 0, 0),
		fieldHolder: fieldHolder{
			data: make(map[string]interface{}),
		},
		client: c,
	}

	return c, nil
}
1188741
func NewClient(ctx log.Interface, username, password, host string) Client {
	if ctx == nil {
		ctx = log.Get()
	}
	credentials := "guest:guest"
	if username != "" {
		if password != "" {
			credentials = fmt.Sprintf("%s:%s", username, password)
		} else {
			credentials = username
		}
	}
	return &DefaultClient{
		ctx:      ctx,
		url:      fmt.Sprintf("amqp://%s@%s", credentials, host),
		channels: make(map[*DefaultChannelClient]*AMQP.Channel),
	}
}
695124
func NewClient(config *Config) (*Client, error) {
	c, err := tlsutil.NewConfigurator(config.ToTLSUtilConfig(), nil)
	if err != nil {
		return nil, err
	}
	return NewClientLogger(config, nil, c)
}
895541
func NewClient(clientConfig ClientConfig) *Client {
	client := &Client{
		ClientConfig: clientConfig,
	}

	// If reader is nil use default rand.Reader
	if clientConfig.Reader == nil {
		client.Reader = rand.Reader
	}

	// If hash is nil use default sha256
	if clientConfig.Hash == nil {
		client.Hash = sha256.New()
	}

	return client
}
559543
func NewClient(host string, port int) (client *Client, err error) {
	client = new(Client)
	client.Host = host
	client.Port = port
	client.Connection, err = net.Dial("tcp", fmt.Sprintf("%v:%v", client.Host, client.Port))
	return
}
1047449
func NewClient(config Config) *Client {
	userAgent := fmt.Sprintf("%s/%s (%s; %s %s)",
		config.BinaryName(),
		config.BinaryVersion(),
		runtime.Version(),
		runtime.GOARCH,
		runtime.GOOS,
	)

	client := Client{
		config: config,

		connection: NewConnection(config.SkipSSLValidation(), config.UAADisableKeepAlives(), config.DialTimeout()),
		userAgent:  userAgent,
	}
	client.WrapConnection(NewErrorWrapper())

	return &client
}
432511
func NewClient(config Config) *Client {
	userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.AppName, config.AppVersion, runtime.Version(), runtime.GOARCH, runtime.GOOS)
	return &Client{
		clock:              new(internal.RealTime),
		userAgent:          userAgent,
		jobPollingInterval: config.JobPollingInterval,
		jobPollingTimeout:  config.JobPollingTimeout,
		wrappers:           append([]ConnectionWrapper{newErrorWrapper()}, config.Wrappers...),
	}
}
776807
func NewClient(auth Auth) (*Client, error) {
	c := &Client{
		auth: auth,
	}
	return c, nil
}
887613
func NewClient(h string, p int) Client {
	return Client{
		Host: h,
		Port: p,
	}
}