// NewUploadSessionFinishArg returns a new UploadSessionFinishArg instance
430209
func NewUploadSessionFinishArg(Cursor *UploadSessionCursor, Commit *CommitInfo) *UploadSessionFinishArg {
	s := new(UploadSessionFinishArg)
	s.Cursor = Cursor
	s.Commit = Commit
	return s
}
333673
func (os *OpenStack) NewBlockStorageV1() (*gophercloud.ServiceClient, error) {
	storage, err := openstack.NewBlockStorageV1(os.provider, gophercloud.EndpointOpts{
		Region: os.region,
	})
	if err != nil {
		glog.Errorf("Unable to initialize cinder v1 client for region: %s", os.region)
		return nil, err
	}
	return storage, nil
}
1255333
func (fs *FSObjects) NewMultipartUpload(ctx context.Context, bucket, object string, opts ObjectOptions) (string, error) {
	if err := checkNewMultipartArgs(ctx, bucket, object, fs); err != nil {
		return "", toObjectErr(err, bucket)
	}

	if _, err := fs.statBucketDir(ctx, bucket); err != nil {
		return "", toObjectErr(err, bucket)
	}

	uploadID := mustGetUUID()
	uploadIDDir := fs.getUploadIDDir(bucket, object, uploadID)

	err := mkdirAll(uploadIDDir, 0755)
	if err != nil {
		logger.LogIf(ctx, err)
		return "", err
	}

	// Initialize fs.json values.
	fsMeta := newFSMetaV1()
	fsMeta.Meta = opts.UserDefined

	fsMetaBytes, err := json.Marshal(fsMeta)
	if err != nil {
		logger.LogIf(ctx, err)
		return "", err
	}

	if err = ioutil.WriteFile(pathJoin(uploadIDDir, fs.metaJSONFile), fsMetaBytes, 0644); err != nil {
		logger.LogIf(ctx, err)
		return "", err
	}

	return uploadID, nil
}
957917
func NewUploadSessionCursor(SessionId string, Offset uint64) *UploadSessionCursor {
	s := new(UploadSessionCursor)
	s.SessionId = SessionId
	s.Offset = Offset
	return s
}
329695
func newPcapSession(client string, logger logrus.FieldLogger) *pcapSession {
	return &pcapSession{
		client: client,
		logger: logger,
	}
}
676876
func (sb *SessionBuilder) BuildSenderSession(pkb *PreKeyBundle) error {
	theirIdentityKey := pkb.IdentityKey
	if !sb.identityStore.IsTrustedIdentity(sb.recipientID, theirIdentityKey) {
		return NotTrustedError{sb.recipientID}
	}
	if pkb.SignedPreKeyPublic != nil &&
		!curve25519sign.Verify(*theirIdentityKey.Key(), pkb.SignedPreKeyPublic.Serialize(), &pkb.SignedPreKeySignature) {
		return InvalidSignatureError{pkb}
	}

	sr, err := sb.sessionStore.LoadSession(sb.recipientID, sb.deviceID)
	if err != nil {
		return err
	}
	ourBaseKey := NewECKeyPair()
	theirSignedPreKey := pkb.SignedPreKeyPublic
	theirOneTimePreKey := pkb.PreKeyPublic
	theirOneTimePreKeyID := pkb.PreKeyID

	ourIdentityKey, err := sb.identityStore.GetIdentityKeyPair()
	if err != nil {
		return err
	}
	alice := aliceAxolotlParameters{
		OurBaseKey:         ourBaseKey,
		OurIdentityKey:     ourIdentityKey,
		TheirIdentity:      pkb.IdentityKey,
		TheirSignedPreKey:  theirSignedPreKey,
		TheirRatchetKey:    theirSignedPreKey,
		TheirOneTimePreKey: theirOneTimePreKey,
	}

	if !sr.Fresh {
		sr.archiveCurrentState()
	}

	err = initializeSenderSession(sr.sessionState, 3, alice)
	if err != nil {
		return err
	}

	sr.sessionState.setUnacknowledgedPreKeyMessage(theirOneTimePreKeyID, pkb.SignedPreKeyID, &ourBaseKey.PublicKey)
	regID, err := sb.identityStore.GetLocalRegistrationID()
	if err != nil {
		return err
	}
	sr.sessionState.setLocalRegistrationID(regID)
	sr.sessionState.setRemoteRegistrationID(pkb.RegistrationID)
	sr.sessionState.setAliceBaseKey(ourBaseKey.PublicKey.Serialize())

	err = sb.sessionStore.StoreSession(sb.recipientID, sb.deviceID, sr)
	if err != nil {
		return err
	}
	err = sb.identityStore.SaveIdentity(sb.recipientID, theirIdentityKey)
	return err
}
771353
func NewWebSession(name string, spec WebSessionSpecV2) WebSession {
	return &WebSessionV2{
		Kind:    KindWebSession,
		Version: V2,
		Metadata: Metadata{
			Name:      name,
			Namespace: defaults.Namespace,
		},
		Spec: spec,
	}
}
581374
func NewFSSyncTargetDir(outdir string) session.Attachable {
	p := &fsSyncTarget{
		outdir: outdir,
	}
	return p
}
1164106
func NewFilesystemStore(path string, keyPairs ...[]byte) FilesystemStore {
	return &filesystemStore{sessions.NewFilesystemStore(path, keyPairs...)}
}
479150
func PgReplicationOriginSessionSetup(db XODB, v0 string) error {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.pg_replication_origin_session_setup($1)`

	// run query
	XOLog(sqlstr)
	_, err = db.Exec(sqlstr)
	return err
}
1014223
func (s *CreateFleetInput) SetNewGameSessionProtectionPolicy(v string) *CreateFleetInput {
	s.NewGameSessionProtectionPolicy = &v
	return s
}
1097020
func NewUploadSessionStartResult(SessionId string) *UploadSessionStartResult {
	s := new(UploadSessionStartResult)
	s.SessionId = SessionId
	return s
}
54684
func NewApiSessionLogInfo(RequestId string) *ApiSessionLogInfo {
	s := new(ApiSessionLogInfo)
	s.RequestId = RequestId
	return s
}
444675
func ServeUploadPack(path string) error {
	ep, err := transport.NewEndpoint(path)
	if err != nil {
		return err
	}

	// TODO: define and implement a server-side AuthMethod
	s, err := server.DefaultServer.NewUploadPackSession(ep, nil)
	if err != nil {
		return fmt.Errorf("error creating session: %s", err)
	}

	return common.ServeUploadPack(srvCmd, s)
}
987292
func NewDesktopClientSession(SessionId string, HostName string, ClientType *DesktopPlatform, ClientVersion string, Platform string, IsDeleteOnUnlinkSupported bool) *DesktopClientSession {
	s := new(DesktopClientSession)
	s.SessionId = SessionId
	s.HostName = HostName
	s.ClientType = ClientType
	s.ClientVersion = ClientVersion
	s.Platform = Platform
	s.IsDeleteOnUnlinkSupported = IsDeleteOnUnlinkSupported
	return s
}
221863
func NewImageService(config ImageServiceConfig) *ImageService {
	logrus.Debugf("Max Concurrent Downloads: %d", config.MaxConcurrentDownloads)
	logrus.Debugf("Max Concurrent Uploads: %d", config.MaxConcurrentUploads)
	return &ImageService{
		containers:                config.ContainerStore,
		distributionMetadataStore: config.DistributionMetadataStore,
		downloadManager:           xfer.NewLayerDownloadManager(config.LayerStores, config.MaxConcurrentDownloads),
		eventsService:             config.EventsService,
		imageStore:                config.ImageStore,
		layerStores:               config.LayerStores,
		referenceStore:            config.ReferenceStore,
		registryService:           config.RegistryService,
		uploadManager:             xfer.NewLayerUploadManager(config.MaxConcurrentUploads),
	}
}
1347961
func (c *Client) NewUploadRequest(urlStr string, reader io.Reader, size int64, mediaType string) (*http.Request, error) {
	if !strings.HasSuffix(c.UploadURL.Path, "/") {
		return nil, fmt.Errorf("UploadURL must have a trailing slash, but %q does not", c.UploadURL)
	}
	u, err := c.UploadURL.Parse(urlStr)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("POST", u.String(), reader)
	if err != nil {
		return nil, err
	}
	req.ContentLength = size

	if mediaType == "" {
		mediaType = defaultMediaType
	}
	req.Header.Set("Content-Type", mediaType)
	req.Header.Set("Accept", mediaTypeV3)
	req.Header.Set("User-Agent", c.UserAgent)
	return req, nil
}