github.com/qiniu/go-sdk/v7@v7.27.0/pili/manager.go (about)

     1  package pili
     2  
     3  import (
     4  	"github.com/qiniu/go-sdk/v7/auth"
     5  	"github.com/qiniu/go-sdk/v7/client"
     6  )
     7  
     8  // Manager 提供了 Qiniu PILI Service API 相关功能
     9  type Manager struct {
    10  	apiHost       string
    11  	apiHTTPScheme string
    12  	client        *client.Client
    13  	mac           *auth.Credentials
    14  }
    15  
    16  // NewManager 用于构建一个新的 Manager
    17  func NewManager(conf ManagerConfig) *Manager {
    18  	if len(conf.APIHost) == 0 {
    19  		conf.APIHost = APIHost
    20  	}
    21  	if len(conf.APIHTTPScheme) == 0 {
    22  		conf.APIHTTPScheme = APIHTTPScheme
    23  	}
    24  	SetAppName(conf.AppName)
    25  	mac := auth.New(conf.AccessKey, conf.SecretKey)
    26  	client := client.DefaultClient
    27  	client.Transport = newTransport(mac, conf.Transport)
    28  	return &Manager{
    29  		apiHost:       conf.APIHost,
    30  		apiHTTPScheme: conf.APIHTTPScheme,
    31  		mac:           mac,
    32  		client:        &client,
    33  	}
    34  }