// New creates a new Codeship API client
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
}
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
}
49870
func New(ctx fabcontext.Client) (*Client, error) {
	authInfo, err := newAuthInfo(ctx)
	if err != nil {
		return nil, err
	}

	return &Client{
		ctx:      ctx,
		authInfo: authInfo,
	}, nil
}
658753
func New(conn net.Conn) *Client {
	return &Client{
		Client: jsonrpc.NewClient(conn),
		conn:   conn,
	}
}
687945
func New(opts ...Opt) *Client {
	c := &Client{
		codec:       DefaultCodec,
		do:          With(DefaultConfigOpt...),
		header:      cloneHeaders(DefaultHeaders),
		errorMapper: DefaultErrorMapper,
	}
	c.buildRequestFunc = c.buildRequest
	c.handleResponse = c.HandleResponse
	c.With(opts...)
	return c
}
555586
func New(writer http.ResponseWriter, httpStatus int, message string) {
	response := &response{
		Response: message,
	}

	jsonResponse, err := json.Marshal(response)
	if err != nil {
		http.Error(writer, err.Error(), http.StatusInternalServerError)
	}

	writer.Header().Set("Content-Type", "application/json")
	writer.WriteHeader(httpStatus)
	writer.Write(jsonResponse)
}
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
}
232955
func New(channelProvider context.ChannelProvider, opts ...ClientOption) (*Client, error) {

	channelContext, err := channelProvider()
	if err != nil {
		return nil, errors.WithMessage(err, "failed to create channel context")
	}

	greylistProvider := greylist.New(channelContext.EndpointConfig().Timeout(fab.DiscoveryGreylistExpiry))

	if channelContext.ChannelService() == nil {
		return nil, errors.New("channel service not initialized")
	}

	eventService, err := channelContext.ChannelService().EventService()
	if err != nil {
		return nil, errors.WithMessage(err, "event service creation failed")
	}

	membership, err := channelContext.ChannelService().Membership()
	if err != nil {
		return nil, errors.WithMessage(err, "membership creation failed")
	}

	channelClient := newClient(channelContext, membership, eventService, greylistProvider)

	for _, param := range opts {
		err := param(&channelClient)
		if err != nil {
			return nil, errors.WithMessage(err, "option failed")
		}
	}

	return &channelClient, nil
}
46145
func New(c goaclient.Doer) *Client {
	client := &Client{
		Client:  goaclient.New(c),
		Encoder: goa.NewHTTPEncoder(),
		Decoder: goa.NewHTTPDecoder(),
	}

	// Setup encoders and decoders
	client.Encoder.Register(goa.NewJSONEncoder, "application/json")
	client.Encoder.Register(goa.NewGobEncoder, "application/gob", "application/x-gob")
	client.Encoder.Register(goa.NewXMLEncoder, "application/xml")
	client.Decoder.Register(goa.NewJSONDecoder, "application/json")
	client.Decoder.Register(goa.NewGobDecoder, "application/gob", "application/x-gob")
	client.Decoder.Register(goa.NewXMLDecoder, "application/xml")

	// Setup default encoder and decoder
	client.Encoder.Register(goa.NewJSONEncoder, "*/*")
	client.Decoder.Register(goa.NewJSONDecoder, "*/*")

	return client
}
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
}
836561
func (c Client) New(params *stripe.EphemeralKeyParams) (*stripe.EphemeralKey, error) {
	if params.StripeVersion == nil || len(stripe.StringValue(params.StripeVersion)) == 0 {
		return nil, fmt.Errorf("params.StripeVersion must be specified")
	}

	if params.Headers == nil {
		params.Headers = make(http.Header)
	}
	params.Headers.Add("Stripe-Version", stripe.StringValue(params.StripeVersion))

	ephemeralKey := &stripe.EphemeralKey{}
	err := c.B.Call(http.MethodPost, "/v1/ephemeral_keys", c.Key, params, ephemeralKey)
	return ephemeralKey, err
}
1177532
func (c Client) New(params *stripe.CustomerParams) (*stripe.Customer, error) {
	cust := &stripe.Customer{}
	err := c.B.Call(http.MethodPost, "/v1/customers", c.Key, params, cust)
	return cust, err
}
287189
func New(c *client.Client, id string, pubKey string) (api.Key, error) {
	req := api.KeyCreateRequest{ID: id, Public: pubKey}
	body, err := json.Marshal(req)

	resBody, err := c.BasicRequest("POST", "/v1/keys/", body)

	if err != nil {
		return api.Key{}, err
	}

	key := api.Key{}
	if err = json.Unmarshal([]byte(resBody), &key); err != nil {
		return api.Key{}, err
	}

	return key, nil
}
1295991
func New(store, apiKey, pass string) Shopify {

	shop := Shopify{store: store, apiKey: apiKey, pass: pass}
	//	fmt.Println("[New] Creating Shopify client with: ", store, apiKey, pass)

	return shop
}
874883
func New(cfg *Config) (*Client, error) {
	var opts []grpc.DialOption
	if cfg.CertFile != "" {
		creds, err := credentials.NewClientTLSFromFile(cfg.CertFile, cfg.ServerNameOverride)
		if err != nil {
			return nil, fmt.Errorf("Failed to create TLS credentials %v", err)
		}
		opts = append(opts, grpc.WithTransportCredentials(creds))
	} else {
		opts = append(opts, grpc.WithInsecure())
	}
	conn, err := grpc.Dial(cfg.Addr, opts...)
	if err != nil {
		return nil, err
	}

	cli := &Client{
		addr:          cfg.Addr,
		cfg:           cfg,
		lainletClient: pb.NewLainletClient(conn),
		appnameClient: pb.NewAppnameClient(conn),

		appsClient:                    pb.NewAppsClient(conn),
		backupctlClient:               pb.NewBackupctlClient(conn),
		configClient:                  pb.NewConfigClient(conn),
		containersClient:              pb.NewContainersClient(conn),
		coreinfoClient:                pb.NewCoreinfoClient(conn),
		dependsClient:                 pb.NewDependsClient(conn),
		localspecClient:               pb.NewLocalspecClient(conn),
		nodesClient:                   pb.NewNodesClient(conn),
		podgroupClient:                pb.NewPodgroupClient(conn),
		proxyClient:                   pb.NewProxyClient(conn),
		rebellionLocalprocsClient:     pb.NewRebellionLocalprocsClient(conn),
		streamrouterPortsClient:       pb.NewStreamrouterPortsClient(conn),
		streamrouterStreamprocsClient: pb.NewStreamrouterStreamprocsClient(conn),
		webrouterWebprocsClient:       pb.NewWebrouterWebprocsClient(conn),
	}

	if cfg.Timeout <= 0 {
		cli.timeout = RPC_TIMEOUT * time.Second
	} else {
		cli.timeout = time.Duration(cfg.Timeout) * time.Second
	}

	return cli, nil
}
547883
func New(rs *resources.Spec) *Client {
	return &Client{rs: rs, m: minifiers.New(rs.MediaTypes, rs.OutputFormats)}
}
894655
func New(c *deis.Client, appID string) (api.App, error) {
	body := []byte{}

	if appID != "" {
		req := api.AppCreateRequest{ID: appID}
		b, err := json.Marshal(req)

		if err != nil {
			return api.App{}, err
		}
		body = b
	}

	res, reqErr := c.Request("POST", "/v2/apps/", body)
	if reqErr != nil && !deis.IsErrAPIMismatch(reqErr) {
		return api.App{}, reqErr
	}
	defer res.Body.Close()

	app := api.App{}
	if err := json.NewDecoder(res.Body).Decode(&app); err != nil {
		return api.App{}, err
	}

	return app, reqErr
}