// NewWithURL - create client directly with URL. Used for testing.
165296
func (client *MyInventoryClient) NewWithURL(url string) *MyInventoryClient {
  client.Enabled = true
  client.ServiceBaseURL = url
  return client
}
1176992
func NewClientWithToken(consumerKey string, consumerSecret string, token string, tokenSecret string) *Client {
	c := NewClient(consumerKey, consumerSecret)
	c.SetToken(token, tokenSecret)
	return c
}
97171
func NewRequestWithBody(method, path, body string) (*http.Request, error) {
	data := strings.NewReader(body)
	req, err := http.NewRequest(method, path, data)

	return req, err
}
873019
func New(token string, url string) *API {
	api := new(API)
	api.Endpoint = url
	api.Client = newRestClient(token)
	return api
}
663172
func WithClient(client *http.Client) ClientOption {
	return func(c *Client) {
		if client == nil {
			client = &http.Client{}
		}
		c.Client = client
	}
}
927157
func New(url string, config Config) *Client {
	c := &Client{In: make(chan Message), Config: config}
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}, //nolint:gosec
	}
	c.httpclient = &http.Client{Transport: tr}
	_, _, err := net.SplitHostPort(c.BindAddress)
	if err != nil {
		log.Fatalf("incorrect bindaddress %s", c.BindAddress)
	}
	go c.StartServer()
	return c
}
879497
func (cli *Client) BuildURLWithQuery(urlPath []string, urlQuery map[string]string) string {
	u, _ := url.Parse(cli.BuildURL(urlPath...))
	q := u.Query()
	for k, v := range urlQuery {
		q.Set(k, v)
	}
	u.RawQuery = q.Encode()
	return u.String()
}
854638
func NewClient(baseAddr string) *Client {
	return &Client{
		baseAddr: baseAddr,
		client:   &http.Client{},
	}
}
796807
func NewWithDescriptor(descriptorsRoute string, docsRoute string, docslogLevel logrus.Level, requestTimeout ...time.Duration) *ProtoClient {
	newclient := newProto(docslogLevel, requestTimeout...)
	newclient.docsRoute = docsRoute
	newclient.descriptorsRoute = descriptorsRoute
	return newclient
}
119749
func NewWithHTTP(uri string, httpClient *http.Client) (*Client, error) {
	if uri == "" {
		uri = "http://logaggregator.discoverd"
	}
	u, err := url.Parse(uri)
	if err != nil {
		return nil, err
	}
	return newClient(u.String(), httpClient), nil
}
987719
func NewClient(url string, httpClient *http.Client) *Client {
	if httpClient == nil {
		httpClient = http.DefaultClient
	}
	return &Client{
		url:        url,
		httpClient: httpClient,
	}
}
953552
func NewClient(opts ...ClientOption) *Client {
	client := &Client{
		client:  &http.Client{Timeout: defaultTimeout},
		baseURL: defaultBaseURL,
	}
	for _, opt := range opts {
		opt(client)
	}
	return client
}
1151933
func New(opts ...Opt) *Client {
	c := &Client{
		endpoint:   DefaultEndpoint,
		protocol:   DefaultProtocol,
		httpClient: DefaultHTTPClient,
	}

	for _, opt := range opts {
		opt(c)
	}
	return c
}
897068
func NewClient(dbURL string) (API, error) {
	// check if we should use default db
	if dbURL == "" {
		dbURL = defaultDbURL
	}

	parts := strings.Split(dbURL, "://")
	if len(parts) < 2 {
		log.Errorf("Invalid DB URL format %s", dbURL)
		return nil, errors.New("invalid DB URL")
	}
	clientName := parts[0]
	clientURL := parts[1]

	return InitClient(clientName, []string{"http://" + clientURL})
}
1072939
func New(URL string) (p *Provider, err error) {
	u, err := url.Parse(URL)
	if err != nil {
		return
	}
	if !strings.Contains(u.Scheme, "tcp") {
		err = errInvalidURL
		return
	}
	var clientPort int
	if u.Port() != "" {
		clientPort, err = strconv.Atoi(u.Port())
		if err != nil {
			return
		}
	}
	p = &Provider{
		Host: u.Hostname(),
		Port: clientPort,
	}
	return
}
1032950
func NewCustomisedURL(clientKey, secret, callbackURL, authURL, tokenURL, profileURL, emailURL string, scopes ...string) *Provider {
	p := &Provider{
		ClientKey:    clientKey,
		Secret:       secret,
		CallbackURL:  callbackURL,
		providerName: "github",
		profileURL:   profileURL,
		emailURL:     emailURL,
	}
	p.config = newConfig(p, authURL, tokenURL, scopes)
	return p
}
348550
func New(url string) *Client {
	return &Client{
		url:    url,
		logger: log.New(os.Stderr, "[discovery] ", log.LstdFlags),
	}
}