//New - create a new oauth2 integration wrapper
196493
func (s *MyOAuth2) New(appEnv *cfenv.App) *MyOAuth2 {
	oauth2ServiceName := os.Getenv("OAUTH2_SERVICE_NAME")
	clientIdName := os.Getenv("OAUTH2_CLIENT_ID")
	clientSecretName := os.Getenv("OAUTH2_CLIENT_SECRET")
	oauth2Service, err := appEnv.Services.WithName(oauth2ServiceName)

	if err != nil {
		panic(fmt.Sprintf("oauth2 client service name error: %s", err.Error()))
	}
	s.ID = oauth2Service.Credentials[clientIdName].(string)
	s.Secret = oauth2Service.Credentials[clientSecretName].(string)
	return s
}
1367192
func New(token string, options ...Option) *Client {
	slackURL := DefaultAPIEndpoint
	httpcl := http.DefaultClient
	debug, _ := strconv.ParseBool(os.Getenv("SLACK_DEBUG"))
	var logger Logger = nilLogger{}
	for _, o := range options {
		switch o.Name() {
		case httpclkey:
			httpcl = o.Value().(*http.Client)
		case debugkey:
			debug = o.Value().(bool)
		case loggerkey:
			logger = o.Value().(Logger)
		case slackurlkey:
			slackURL = o.Value().(string)
		}
	}

	if !strings.HasSuffix(slackURL, "/") {
		slackURL = slackURL + "/"
	}

	if _, ok := logger.(nilLogger); debug && ok {
		logger = traceLogger{dst: os.Stderr}
	}

	wrappedcl := &httpClient{
		client:   httpcl,
		debug:    debug,
		slackURL: slackURL,
		logger:   logger,
	}
	return &Client{
		auth:            &AuthService{client: wrappedcl, token: token},
		bots:            &BotsService{client: wrappedcl, token: token},
		channels:        &ChannelsService{client: wrappedcl, token: token},
		chat:            &ChatService{client: wrappedcl, token: token},
		dialog:          &DialogService{client: wrappedcl, token: token},
		emoji:           &EmojiService{client: wrappedcl, token: token},
		groups:          &GroupsService{client: wrappedcl, token: token},
		oauth:           &OAuthService{client: wrappedcl},
		reminders:       &RemindersService{client: wrappedcl, token: token},
		reactions:       &ReactionsService{client: wrappedcl, token: token},
		rtm:             &RTMService{client: wrappedcl, token: token},
		users:           &UsersService{client: wrappedcl, token: token},
		usersProfile:    &UsersProfileService{client: wrappedcl, token: token},
		usergroups:      &UsergroupsService{client: wrappedcl, token: token},
		usergroupsUsers: &UsergroupsUsersService{client: wrappedcl, token: token},
		debug:           debug,
	}
}
1346124
func New(clientKey, secret, callbackURL string, scopes ...string) *Provider {
	paypalEnv := os.Getenv(envKey)

	authURL := authURLProduction
	tokenURL := tokenURLProduction
	profileEndPoint := endpointProfileProduction

	if paypalEnv == sandbox {
		authURL = authURLSandbox
		tokenURL = tokenURLSandbox
		profileEndPoint = endpointProfileSandbox
	}

	return NewCustomisedURL(clientKey, secret, callbackURL, authURL, tokenURL, profileEndPoint, scopes...)
}
582487
func (c Client) New(params *stripe.TokenParams) (*stripe.Token, error) {
	tok := &stripe.Token{}
	err := c.B.Call(http.MethodPost, "/v1/tokens", c.Key, params, tok)
	return tok, err
}
163885
func New(config *Config, authorizer Authorizer) (*NodeAuthorizer, error) {
	utils.Logger.Info("starting the node authorization service",
		zap.String("listen", config.Listen),
		zap.String("version", Version))

	if authorizer == nil {
		return nil, errors.New("no authorizer")
	}

	if err := config.IsValid(); err != nil {
		return nil, fmt.Errorf("configuration error: %s", err)
	}

	return &NodeAuthorizer{
		authorizer: authorizer,
		config:     config,
	}, nil
}
1057202
func New(authTokenHandlers ...authenticator.Token) authenticator.Token {
	if len(authTokenHandlers) == 1 {
		return authTokenHandlers[0]
	}
	return &unionAuthTokenHandler{Handlers: authTokenHandlers, FailOnError: false}
}
934067
func New(cryptoProvider core.CryptoSuite) (*SigningManager, error) {
	return &SigningManager{cryptoProvider: cryptoProvider, hashOpts: cryptosuite.GetSHAOpts()}, nil
}
940817
func New(clientProvider context.ClientProvider, opts ...ClientOption) (*Client, error) {

	ctx, err := clientProvider()
	if err != nil {
		return nil, errors.WithMessage(err, "failed to create Client")
	}

	msp := Client{
		ctx: ctx,
	}

	for _, param := range opts {
		err := param(&msp)
		if err != nil {
			return nil, errors.WithMessage(err, "failed to create Client")
		}
	}

	if msp.orgName == "" {
		msp.orgName = ctx.IdentityConfig().Client().Organization
	}
	if msp.orgName == "" {
		return nil, errors.New("organization is not provided")
	}

	caConfig, ok := ctx.IdentityConfig().CAConfig(msp.orgName)
	if ok {
		msp.caName = caConfig.CAName
	}

	networkConfig := ctx.EndpointConfig().NetworkConfig()
	_, ok = networkConfig.Organizations[strings.ToLower(msp.orgName)]
	if !ok {
		return nil, fmt.Errorf("non-existent organization: '%s'", msp.orgName)
	}
	return &msp, nil
}
878671
func (c Client) New(params *stripe.AccountParams) (*stripe.Account, error) {
	acct := &stripe.Account{}
	err := c.B.Call(http.MethodPost, "/v1/accounts", c.Key, params, acct)
	return acct, err
}
536785
func New(key, email string, opts ...Option) (*API, error) {
	if key == "" || email == "" {
		return nil, errors.New(errEmptyCredentials)
	}

	api, err := newClient(opts...)
	if err != nil {
		return nil, err
	}

	api.APIKey = key
	api.APIEmail = email
	api.authType = AuthKeyEmail

	return api, nil
}
768498
func New(auth Authenticator, opts ...Option) (*Client, error) {
	if auth == nil {
		return nil, errors.New("no authenticator provided")
	}

	client := &Client{
		authenticator: auth,
		baseURL:       apiURL,
		headers:       make(http.Header),
	}

	if err := client.parseOptions(opts...); err != nil {
		return nil, errors.Wrap(err, "options parsing failed")
	}

	// Fall back to http.DefaultClient if the user does not provide
	// their own
	if client.httpClient == nil {
		client.httpClient = &http.Client{
			Timeout: time.Second * 30,
		}
	}

	// Fall back to default log.Logger (STDOUT) if the user does not provide
	// their own
	if client.logger == nil {
		logger := &log.Logger{}
		logger.SetOutput(os.Stdout)
		client.logger = logger
	}

	return client, nil
}
1044674
func (c Client) New(params *stripe.SourceObjectParams) (*stripe.Source, error) {
	p := &stripe.Source{}
	err := c.B.Call(http.MethodPost, "/v1/sources", c.Key, params, p)
	return p, err
}
388700
func New(crioSocketPath string) (CrioClient, error) {
	tr := new(http.Transport)
	configureUnixTransport(tr, "unix", crioSocketPath)
	c := &http.Client{
		Transport: tr,
	}
	return &crioClientImpl{
		client:         c,
		crioSocketPath: crioSocketPath,
	}, nil
}
1191935
func New(client *consul.Client) *ConsulLocker {
	return &ConsulLocker{
		Client: client,
		locks:  make(map[string]*consul.Lock),
		mutex:  new(sync.RWMutex),
	}
}
1090731
func New(options *AuthOptions, httpClient *http.Client) *Client {
	if httpClient == nil {
		httpClient = http.DefaultClient
	}

	return &Client{
		Options: options,
		Client:  httpClient,
	}
}
109735
func New(clientKey, secret, callbackURL string, scopes ...string) *Provider {
	return NewCustomisedURL(clientKey, secret, callbackURL, AuthURL, TokenURL, ProfileURL, EmailURL, scopes...)
}
1057033
func New(host, port, username string, sams ...ssh.AuthMethod) (*Client, error) {
	config := &ssh.ClientConfig{
		User: username,
		Auth: sams,
	}
	client, err := ssh.Dial("tcp", BuildSSHURL(host, port), config)
	if err != nil {
		return nil, err
	}
	tmpSftpClient, err := sftp.NewClient(client)
	if err != nil {
		return nil, err
	}
	return (*Client)(unsafe.Pointer(tmpSftpClient)), err
}