mcclient

package
v2.0.28+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2018 License: Apache-2.0, Apache-2.0 Imports: 17 Imported by: 0

README

Yunion CMP API go library

Documentation

Index

Constants

View Source
const (
	TASK_NOTIFY_URL = "X-Task-Notify-Url"

	DEFAULT_API_VERSION = "v1"
)
View Source
const REGION_ZONE_SEP = '-'

Variables

View Source
var TokenCredentialType reflect.Type

Functions

func Id2RegionZone

func Id2RegionZone(id string) (string, string)

func RegionID

func RegionID(region, zone string) string

func SplitVersionedURL

func SplitVersionedURL(url string) (string, string)

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(authUrl string, timeout int, debug bool, insecure bool) *Client

func (*Client) AuthVersion

func (this *Client) AuthVersion() string

func (*Client) Authenticate

func (this *Client) Authenticate(uname, passwd, domainName, tenantName string) (TokenCredential, error)

func (*Client) NewSession

func (this *Client) NewSession(region, zone, endpointType string, token TokenCredential, apiVersion string) *ClientSession

func (*Client) SetProject

func (this *Client) SetProject(tenantId, tenantName string, token TokenCredential) (TokenCredential, error)

func (*Client) SetTenant

func (this *Client) SetTenant(tenantId, tenantName string, token TokenCredential) (TokenCredential, error)

func (*Client) Verify

func (this *Client) Verify(adminToken, token string) (cred TokenCredential, err error)

type ClientSession

type ClientSession struct {
	Header http.Header /// headers for this session
	// contains filtered or unexported fields
}

func (*ClientSession) GetApiVersion

func (this *ClientSession) GetApiVersion() string

func (*ClientSession) GetRegion

func (this *ClientSession) GetRegion() string

func (*ClientSession) GetServiceURL

func (this *ClientSession) GetServiceURL(service, endpointType string) (string, error)

func (*ClientSession) GetTenantId

func (this *ClientSession) GetTenantId() string

func (*ClientSession) GetTenantName

func (this *ClientSession) GetTenantName() string

func (*ClientSession) IsSystemAdmin

func (this *ClientSession) IsSystemAdmin() bool

func (*ClientSession) JSONRequest

func (this *ClientSession) JSONRequest(service, endpointType, method, url string, headers http.Header, body jsonutils.JSONObject) (http.Header, jsonutils.JSONObject, error)

func (*ClientSession) ParseJSONResponse

func (this *ClientSession) ParseJSONResponse(resp *http.Response, err error) (http.Header, jsonutils.JSONObject, error)

func (*ClientSession) PrepareTask

func (this *ClientSession) PrepareTask()

func (*ClientSession) RawRequest

func (this *ClientSession) RawRequest(service, endpointType, method, url string, headers http.Header, body io.Reader) (*http.Response, error)

func (*ClientSession) RemoveTaskNotifyUrl

func (this *ClientSession) RemoveTaskNotifyUrl()

func (*ClientSession) SetTaskNotifyUrl

func (this *ClientSession) SetTaskNotifyUrl(url string)

func (*ClientSession) ToJson

func (this *ClientSession) ToJson() jsonutils.JSONObject

func (*ClientSession) WaitTaskNotify

func (this *ClientSession) WaitTaskNotify()

type Endpoint

type Endpoint struct {
	Id          string
	RegionId    string
	ServiceId   string
	ServiceName string
	Url         string
	Interface   string
}

type ExternalService

type ExternalService struct {
	Name string
	Url  string
}

type KeystoneDomainV3

type KeystoneDomainV3 struct {
	Id   string
	Name string
}

type KeystoneEndpointV2

type KeystoneEndpointV2 struct {
	Id          string
	InternalURL string
	PublicURL   string
	AdminURL    string
	Region      string
}

type KeystoneEndpointV3

type KeystoneEndpointV3 struct {
	Id        string
	Interface string
	Region    string
	Region_id string
	Url       string
	Name      string
}

type KeystoneMetadataV2

type KeystoneMetadataV2 struct {
	IsAdmin int
	Roles   []string
}

type KeystoneProjectV3

type KeystoneProjectV3 struct {
	Id     string
	Name   string
	Domain KeystoneDomainV3
}

type KeystoneRoleV2

type KeystoneRoleV2 struct {
	Name string
}

type KeystoneRoleV3

type KeystoneRoleV3 struct {
	Id   string
	Name string
}

type KeystoneServiceCatalogV2

type KeystoneServiceCatalogV2 []KeystoneServiceV2

type KeystoneServiceCatalogV3

type KeystoneServiceCatalogV3 []KeystoneServiceV3

type KeystoneServiceV2

type KeystoneServiceV2 struct {
	Name      string
	Type      string
	Endpoints []KeystoneEndpointV2
}

type KeystoneServiceV3

type KeystoneServiceV3 struct {
	Id        string
	Name      string
	Type      string
	Endpoints []KeystoneEndpointV3
}

type KeystoneTenantV2

type KeystoneTenantV2 struct {
	Id          string
	Name        string
	Enabled     bool
	Description string
}

type KeystoneTokenV2

type KeystoneTokenV2 struct {
	Id      string
	Expires time.Time
	Tenant  KeystoneTenantV2
}

type KeystoneTokenV3

type KeystoneTokenV3 struct {
	Audit_ids  []string
	Expires_at time.Time
	Is_domain  bool
	Issued_at  time.Time
	Methods    []string
	Project    KeystoneProjectV3
	Roles      []KeystoneRoleV3
	User       KeystoneUserV3
	Catalog    KeystoneServiceCatalogV3
}

type KeystoneUserV2

type KeystoneUserV2 struct {
	Id       string
	Name     string
	Username string
	Roles    []KeystoneRoleV2
}

type KeystoneUserV3

type KeystoneUserV3 struct {
	Id                  string
	Name                string
	Domain              KeystoneDomainV3
	Password_expires_at time.Time
}

type SSimpleToken

type SSimpleToken struct {
	Token     string
	Domain    string
	DomainId  string
	User      string
	UserId    string
	Project   string `json:"tenant"`
	ProjectId string `json:"tenant_id"`
	Roles     string
	Expires   time.Time
}

func (*SSimpleToken) GetDomainId

func (self *SSimpleToken) GetDomainId() string

func (*SSimpleToken) GetDomainName

func (self *SSimpleToken) GetDomainName() string

func (*SSimpleToken) GetEndpoints

func (this *SSimpleToken) GetEndpoints(region string, endpointType string) []Endpoint

func (*SSimpleToken) GetExpires

func (self *SSimpleToken) GetExpires() time.Time

func (*SSimpleToken) GetExternalServices

func (self *SSimpleToken) GetExternalServices(region string) []ExternalService

func (*SSimpleToken) GetInternalServices

func (self *SSimpleToken) GetInternalServices(region string) []string

func (*SSimpleToken) GetProjectId

func (self *SSimpleToken) GetProjectId() string

func (*SSimpleToken) GetProjectName

func (self *SSimpleToken) GetProjectName() string

func (*SSimpleToken) GetRegions

func (self *SSimpleToken) GetRegions() []string

func (*SSimpleToken) GetRoles

func (self *SSimpleToken) GetRoles() []string

func (*SSimpleToken) GetServiceURL

func (self *SSimpleToken) GetServiceURL(service, region, zone, endpointType string) (string, error)

func (*SSimpleToken) GetTenantId

func (self *SSimpleToken) GetTenantId() string

func (*SSimpleToken) GetTenantName

func (self *SSimpleToken) GetTenantName() string

func (*SSimpleToken) GetTokenString

func (self *SSimpleToken) GetTokenString() string

func (*SSimpleToken) GetUserId

func (self *SSimpleToken) GetUserId() string

func (*SSimpleToken) GetUserName

func (self *SSimpleToken) GetUserName() string

func (*SSimpleToken) IsAdmin

func (self *SSimpleToken) IsAdmin() bool

func (*SSimpleToken) IsSystemAdmin

func (self *SSimpleToken) IsSystemAdmin() bool

func (*SSimpleToken) IsValid

func (self *SSimpleToken) IsValid() bool

func (*SSimpleToken) IsZero

func (self *SSimpleToken) IsZero() bool

func (*SSimpleToken) String

func (self *SSimpleToken) String() string

func (*SSimpleToken) ValidDuration

func (self *SSimpleToken) ValidDuration() time.Duration

type TokenCredential

type TokenCredential interface {
	gotypes.ISerializable

	GetTokenString() string
	GetDomainId() string
	GetDomainName() string
	GetTenantId() string
	GetTenantName() string
	GetProjectId() string
	GetProjectName() string
	GetUserId() string
	GetUserName() string
	GetRoles() []string
	GetExpires() time.Time
	IsValid() bool
	ValidDuration() time.Duration
	IsAdmin() bool
	IsSystemAdmin() bool
	GetRegions() []string
	GetServiceURL(service, region, zone, endpointType string) (string, error)
	GetInternalServices(region string) []string
	GetExternalServices(region string) []ExternalService
	GetEndpoints(region string, endpointType string) []Endpoint
}

func SimplifyToken

func SimplifyToken(token TokenCredential) TokenCredential

func UnmarshalV2Token

func UnmarshalV2Token(rbody jsonutils.JSONObject) (cred TokenCredential, err error)

func UnmarshalV3Token

func UnmarshalV3Token(rbody jsonutils.JSONObject, tokenId string) (cred TokenCredential, err error)

type TokenCredentialV2

type TokenCredentialV2 struct {
	Token          KeystoneTokenV2
	ServiceCatalog KeystoneServiceCatalogV2
	User           KeystoneUserV2
	Metadata       KeystoneMetadataV2
}

func (*TokenCredentialV2) GetDomainId

func (token *TokenCredentialV2) GetDomainId() string

func (*TokenCredentialV2) GetDomainName

func (token *TokenCredentialV2) GetDomainName() string

func (*TokenCredentialV2) GetEndpoints

func (this *TokenCredentialV2) GetEndpoints(region string, endpointType string) []Endpoint

func (*TokenCredentialV2) GetExpires

func (this *TokenCredentialV2) GetExpires() time.Time

func (*TokenCredentialV2) GetExternalServices

func (this *TokenCredentialV2) GetExternalServices(region string) []ExternalService

func (*TokenCredentialV2) GetInternalServices

func (this *TokenCredentialV2) GetInternalServices(region string) []string

func (*TokenCredentialV2) GetProjectId

func (token *TokenCredentialV2) GetProjectId() string

func (*TokenCredentialV2) GetProjectName

func (token *TokenCredentialV2) GetProjectName() string

func (*TokenCredentialV2) GetRegions

func (this *TokenCredentialV2) GetRegions() []string

func (*TokenCredentialV2) GetRoles

func (token *TokenCredentialV2) GetRoles() []string

func (*TokenCredentialV2) GetServiceURL

func (this *TokenCredentialV2) GetServiceURL(service, region, zone, endpointType string) (string, error)

func (*TokenCredentialV2) GetTenantId

func (token *TokenCredentialV2) GetTenantId() string

func (*TokenCredentialV2) GetTenantName

func (token *TokenCredentialV2) GetTenantName() string

func (*TokenCredentialV2) GetTokenString

func (token *TokenCredentialV2) GetTokenString() string

func (*TokenCredentialV2) GetUserId

func (token *TokenCredentialV2) GetUserId() string

func (*TokenCredentialV2) GetUserName

func (token *TokenCredentialV2) GetUserName() string

func (*TokenCredentialV2) IsAdmin

func (this *TokenCredentialV2) IsAdmin() bool

func (*TokenCredentialV2) IsSystemAdmin

func (this *TokenCredentialV2) IsSystemAdmin() bool

func (*TokenCredentialV2) IsValid

func (this *TokenCredentialV2) IsValid() bool

func (*TokenCredentialV2) IsZero

func (self *TokenCredentialV2) IsZero() bool

func (*TokenCredentialV2) String

func (self *TokenCredentialV2) String() string

func (*TokenCredentialV2) ValidDuration

func (this *TokenCredentialV2) ValidDuration() time.Duration

type TokenCredentialV3

type TokenCredentialV3 struct {
	Token KeystoneTokenV3
	Id    string
}

func (*TokenCredentialV3) GetDomainId

func (token *TokenCredentialV3) GetDomainId() string

func (*TokenCredentialV3) GetDomainName

func (token *TokenCredentialV3) GetDomainName() string

func (*TokenCredentialV3) GetEndpoints

func (this *TokenCredentialV3) GetEndpoints(region string, endpointType string) []Endpoint

func (*TokenCredentialV3) GetExpires

func (this *TokenCredentialV3) GetExpires() time.Time

func (*TokenCredentialV3) GetExternalServices

func (this *TokenCredentialV3) GetExternalServices(region string) []ExternalService

func (*TokenCredentialV3) GetInternalServices

func (this *TokenCredentialV3) GetInternalServices(region string) []string

func (*TokenCredentialV3) GetProjectId

func (token *TokenCredentialV3) GetProjectId() string

func (*TokenCredentialV3) GetProjectName

func (token *TokenCredentialV3) GetProjectName() string

func (*TokenCredentialV3) GetRegions

func (this *TokenCredentialV3) GetRegions() []string

func (*TokenCredentialV3) GetRoles

func (token *TokenCredentialV3) GetRoles() []string

func (*TokenCredentialV3) GetServiceURL

func (this *TokenCredentialV3) GetServiceURL(service, region, zone, endpointType string) (string, error)

func (*TokenCredentialV3) GetTenantId

func (token *TokenCredentialV3) GetTenantId() string

func (*TokenCredentialV3) GetTenantName

func (token *TokenCredentialV3) GetTenantName() string

func (*TokenCredentialV3) GetTokenString

func (token *TokenCredentialV3) GetTokenString() string

func (*TokenCredentialV3) GetUserId

func (token *TokenCredentialV3) GetUserId() string

func (*TokenCredentialV3) GetUserName

func (token *TokenCredentialV3) GetUserName() string

func (*TokenCredentialV3) IsAdmin

func (this *TokenCredentialV3) IsAdmin() bool

func (*TokenCredentialV3) IsSystemAdmin

func (this *TokenCredentialV3) IsSystemAdmin() bool

func (*TokenCredentialV3) IsValid

func (this *TokenCredentialV3) IsValid() bool

func (*TokenCredentialV3) IsZero

func (self *TokenCredentialV3) IsZero() bool

func (*TokenCredentialV3) String

func (self *TokenCredentialV3) String() string

func (*TokenCredentialV3) ValidDuration

func (this *TokenCredentialV3) ValidDuration() time.Duration

type TokenManager

type TokenManager interface {
	Save(token TokenCredential) string
	Get(tid string) TokenCredential
	Remove(tid string)
}

func NewMapTokenManager

func NewMapTokenManager() TokenManager

Directories

Path Synopsis
k8s

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL