// New obtains an HTTP client with a RoundTripper that signs AWS requests for the provided service. An
// existing client can be specified for the `client` value, or--if nil--a new HTTP client will be created.
175269
func New(v4s *v4.Signer, client *http.Client, service string, region string) (*http.Client, error) {
	c := client
	switch {
	case v4s == nil:
		return nil, MissingSignerError{}
	case service == "":
		return nil, MissingServiceError{}
	case region == "":
		return nil, MissingRegionError{}
	case c == nil:
		c = http.DefaultClient
	}
	s := &Signer{
		transport: c.Transport,
		v4:        v4s,
		service:   service,
		region:    region,
		logger:    log.New(ioutil.Discard, "", 0),
	}
	if s.transport == nil {
		s.transport = http.DefaultTransport
	}
	signer = s
	c.Transport = s
	return c, nil
}
532414
func New(uri string) Client {
	return &client{http.DefaultClient, strings.TrimSuffix(uri, "/")}
}
287034
func NewWithClient(host, basePath string, schemes []string, client *http.Client) *Runtime {
	rt := New(host, basePath, schemes)
	if client != nil {
		rt.clientOnce.Do(func() {
			rt.client = client
		})
	}
	return rt
}
871763
func New(conn net.Conn) (*Client, error) {
	continues := make(chan bool)
	w := imap.NewClientWriter(nil, continues)
	r := imap.NewReader(nil)

	c := &Client{
		conn:      imap.NewConn(conn, r, w),
		replies:   make(chan []byte),
		loggedOut: make(chan struct{}),
		state:     imap.ConnectingState,
		ErrorLog:  log.New(os.Stderr, "imap/client: ", log.LstdFlags),
	}

	c.handleContinuationReqs(continues)
	c.handleUnilateral()
	err := c.handleGreetAndStartReading()
	return c, err
}
1090731
func New(options *AuthOptions, httpClient *http.Client) *Client {
	if httpClient == nil {
		httpClient = http.DefaultClient
	}

	return &Client{
		Options: options,
		Client:  httpClient,
	}
}
212051
func New(cfg *Config) (*Server, error) {
	// pull a few parameters from the configuration passed in by snapteld
	s := &Server{
		err:        make(chan error),
		killChan:   make(chan struct{}),
		addrString: cfg.Address,
		pprof:      cfg.Pprof,
	}
	if cfg.HTTPS {
		var err error
		s.snapTLS, err = newtls(cfg.RestCertificate, cfg.RestKey)
		if err != nil {
			return nil, err
		}
		protocolPrefix = "https"
	}
	restLogger.Info(fmt.Sprintf("Configuring REST API with HTTPS set to: %v", cfg.HTTPS))

	s.apis = []api.API{
		v1.New(&s.wg, s.killChan, protocolPrefix),
		v2.New(&s.wg, s.killChan, protocolPrefix),
	}

	s.n = negroni.New(
		NewLogger(),
		negroni.NewRecovery(),
		negroni.HandlerFunc(s.authMiddleware),
	)
	s.r = httprouter.New()

	// CORS has to be turned on explicitly in the global config.
	// Otherwise, it defauts to the same origin.
	origins, err := s.getAllowedOrigins(cfg.Corsd)
	if err != nil {
		return nil, err
	}
	if len(origins) > 0 {
		c := cors.New(cors.Options{
			AllowedOrigins: origins,
			AllowedMethods: []string{allowedMethods},
			AllowedHeaders: []string{allowedHeaders},
			MaxAge:         maxAge,
		})
		s.n.Use(c)
	}

	// Use negroni to handle routes
	s.n.UseHandler(s.r)
	return s, nil
}
507201
func New(key string) *Client {
	c := &Client{
		Endpoint: Endpoint,
		Interval: 5 * time.Second,
		Size:     250,
		Logger:   log.New(os.Stderr, "segment ", log.LstdFlags),
		Verbose:  false,
		Client:   *http.DefaultClient,
		key:      key,
		msgs:     make(chan interface{}, 100),
		quit:     make(chan struct{}),
		shutdown: make(chan struct{}),
		now:      time.Now,
		uid:      uid,
	}

	c.logf("You are currently using the v2 version analytics-go, which is being deprecated. Please update to v3 as soon as you can https://segment.com/docs/sources/server/go/#migrating-from-v2")

	c.upcond.L = &c.upmtx
	return c
}
311228
func New(u *url.URL, settings []vim.BaseOptionValue) (string, http.Handler) {
	for i := range settings {
		setting := settings[i].GetOptionValue()
		if setting.Key == "config.vpxd.sso.sts.uri" {
			endpoint, _ := url.Parse(setting.Value.(string))
			endpoint.Host = u.Host
			setting.Value = endpoint.String()
			settings[i] = setting
			return endpoint.Path, new(handler)
		}
	}
	return "", nil
}
1343367
func New(searchAPIURL string) *Client {
	return &Client{
		cli: rchttp.NewClient(),
		url: searchAPIURL,
	}
}
709524
func New(ctx context.Context, config shim.Config, opt Opt) (*Client, error) {
	s, c, err := opt(ctx, config)
	if err != nil {
		return nil, err
	}
	return &Client{
		ShimService: s,
		c:           c,
		exitCh:      make(chan struct{}),
	}, nil
}
208671
func New(awsConfig *aws.Config, queueURL string) *Adapter {
	return &Adapter{getClient(awsConfig), queueURL}
}
1241264
func New(cfgs ...ConfigFunc) *Client {
	c := &Client{
		http.Client{Transport: http.DefaultTransport},
		*NewAPI(),
	}

	c.APIClient.common.backend.(*defaultBackend).client = &c.client

	for _, cfg := range cfgs {
		cfg(c)
	}

	ForURLPattern(manifold.DefaultURLPattern)(c)

	// We need to do this after we've set the configuration. In case someone
	// provided a UserAgent, it will get loaded and overwrite our defaults since
	// we re-assign the previous transport after this.
	WithUserAgent("")(c)
	WithAPIToken(os.Getenv("MANIFOLD_API_TOKEN"))(c)

	return c
}
303657
func New(network, addr string) (client *Client, err error) {
	client = &Client{
		net:             network,
		addr:            addr,
		respHandler:     newResponseHandlerMap(),
		innerHandler:    newResponseHandlerMap(),
		in:              make(chan *Response, queueSize),
		ResponseTimeout: DefaultTimeout,
	}
	client.conn, err = net.Dial(client.net, client.addr)
	if err != nil {
		return
	}
	client.rw = bufio.NewReadWriter(bufio.NewReader(client.conn),
		bufio.NewWriter(client.conn))
	go client.readLoop()
	go client.processLoop()
	return
}
630794
func New(auth Auth) (*Client, error) {
	if err := auth.validate(); err != nil {
		return nil, err
	}

	return &Client{
		c:        &http.Client{},
		username: auth.Username,
		apiKey:   auth.Apikey,
	}, nil
}
341629
func newClient(rt http.RoundTripper) *http.Client {
	return &http.Client{Transport: rt}
}
916579
func New(userID, apiToken, apiSecret string, other ...string) (*Client, error) {
	apiEndPoint := "https://api.catapult.inetwork.com"
	if userID == "" || apiToken == "" || apiSecret == "" {
		return nil, errors.New("Missing auth data. Please use api := bandwidth.New(\"user-id\", \"api-token\", \"api-secret\")")
	}
	l := len(other)
	if l > 0 {
		apiEndPoint = other[0]
	}
	client := &Client{userID, apiToken, apiSecret, apiEndPoint, http.DefaultClient}
	return client, nil
}
1082538
func New(scheme, host string, port uint16) (*Client, error) {
	client := &Client{
		Scheme: scheme,
		Host:   host,
		Port:   port,
	}

	return client, nil
}