// New creates an omaha client for updating one or more applications.
// userID must be a persistent unique identifier of this update client.
358074
func New(serverURL, userID string) (*Client, error) {
	if userID == "" {
		return nil, errors.New("omaha: empty user identifier")
	}

	c := &Client{
		apiClient:     newHTTPClient(),
		clientVersion: defaultClientVersion,
		userID:        userID,
		sessionID:     uuid.NewV4().String(),
		apps:          make(map[string]*AppClient),
	}

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

	return c, nil
}
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
}
662449
func New(serviceURL, userAccount string) *CloudAPI {
	URL, err := url.Parse(serviceURL)
	if err != nil {
		panic(err)
	}
	hostname := URL.Host
	if !strings.HasSuffix(hostname, separator) {
		hostname += separator
	}

	var (
		keys          []cloudapi.Key
		machines      []*machine
		snapshots     = map[string][]cloudapi.Snapshot{}
		firewallRules []*cloudapi.FirewallRule
		fabricVLANs   = map[int16]*fabricVLAN{}
	)

	cloudapiService := &CloudAPI{
		keys:          keys,
		packages:      initPackages(),
		images:        initImages(),
		machines:      machines,
		snapshots:     snapshots,
		firewallRules: firewallRules,
		fabricVLANs:   fabricVLANs,
		networks: []cloudapi.Network{
			{Id: "123abc4d-0011-aabb-2233-ccdd4455", Name: "Test-Joyent-Public", Public: true},
			{Id: "456def0a-33ff-7f8e-9a0b-33bb44cc", Name: "Test-Joyent-Private", Public: false},
		},
		ServiceInstance: localservices.ServiceInstance{
			Scheme:      URL.Scheme,
			Hostname:    hostname,
			UserAccount: userAccount,
		},
	}

	return cloudapiService
}
997054
func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client {
	return &Client{transport: transport, formats: formats}
}
242652
func New(apiKey string) *Linode {
	return &Linode{
		apiEndpoint: ApiEndpoint,
		apiKey:      apiKey,
		actions:     []Action{},
	}
}
949131
func New(filterAPIURL, serviceToken, xDownloadServiceToken string) *Client {
	return &Client{
		cli: rchttp.ClientWithDownloadServiceToken(
			rchttp.ClientWithServiceToken(nil, serviceToken),
			xDownloadServiceToken,
		),
		url: filterAPIURL,
	}
}
473059
func New(ua string) *UserAgent {
	o := &UserAgent{}
	o.Parse(ua)
	return o
}
125077
func New(host, user, password string, conf *AdvancedConfig) (c *Client, err error) {
	// Config
	if conf != nil {
		// Check custom config
		if conf.Port == 0 {
			conf.Port = defaultPort
		}
		if conf.RPCURI == "" {
			conf.RPCURI = defaultRPCPath
		}
		if conf.HTTPTimeout == 0 {
			conf.HTTPTimeout = defaultTimeout
		}
		if conf.UserAgent == "" {
			conf.UserAgent = defaultUserAgent
		}
	} else {
		// Spawn default config
		conf = &AdvancedConfig{
			// HTTPS false by default
			Port:        defaultPort,
			RPCURI:      defaultRPCPath,
			HTTPTimeout: defaultTimeout,
			UserAgent:   defaultUserAgent,
		}
	}
	// Build & validate URL
	var scheme string
	if conf.HTTPS {
		scheme = "https"
	} else {
		scheme = "http"
	}
	remoteURL, err := url.Parse(fmt.Sprintf("%s://%s:%d%s", scheme, host, conf.Port, conf.RPCURI))
	if err != nil {
		err = fmt.Errorf("can't build a valid URL: %v", err)
		return
	}
	// Initialize & return ready to use client
	c = &Client{
		url:       remoteURL.String(),
		user:      user,
		password:  password,
		userAgent: conf.UserAgent,
		rnd:       rand.New(rand.NewSource(time.Now().Unix())),
		httpC: &http.Client{
			Timeout: conf.HTTPTimeout,
		},
	}
	return
}
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
}
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
}
502085
func New(caller base.APICaller) API {
	fc := base.NewFacadeCaller(caller, uaFacade)
	return API{facade: fc}
}
715092
func New(hierarchyAPIURL string) *Client {
	return &Client{
		cli: rhttp.DefaultClient,
		url: hierarchyAPIURL,
	}
}
249078
func NewRequestID() (string, error) {
	id, err := uuid.NewV4()
	if err != nil {
		return "", err
	}

	return strings.Replace(id.String(), "-", "", -1), nil
}
857459
func New(ctx context.Context, client client.ContainerAPIClient, id string) (*Container, error) {
	container, err := Get(ctx, client, id)
	if err != nil {
		return nil, err
	}
	return &Container{
		client:    client,
		id:        id,
		container: container,
	}, nil
}
37410
func New(path ...string) (client ClientAPI, err error) {
	socketPath := socket
	if len(path) > 0 {
		socketPath = path[0]
	}

	conn, err := net.Dial("unix", socketPath)
	if err != nil {
		return
	}

	client = &Client{
		conn:   conn,
		writer: bufio.NewWriter(conn),
		reply:  make(chan Reply),
	}

	go client.read()

	return
}
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
}
847477
func (_class UserClass) Create(sessionID SessionRef, args UserRecord) (_retval UserRef, _err error) {
	_method := "user.create"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_argsArg, _err := convertUserRecordToXen(fmt.Sprintf("%s(%s)", _method, "args"), args)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _argsArg)
	if _err != nil {
		return
	}
	_retval, _err = convertUserRefToGo(_method + " -> ", _result.Value)
	return
}