btpcli

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderCorrelationID       string = "X-Correlationid"
	HeaderIDToken             string = "X-Id-Token"
	HeaderCLIFormat           string = "X-Cpcli-Format"
	HeaderCLISessionId        string = "X-Cpcli-Sessionid"
	HeaderCLISubdomain        string = "X-Cpcli-Subdomain"
	HeaderCLICustomIDP        string = "X-Cpcli-Customidp"
	HeaderCLIBackendStatus    string = "X-Cpcli-Backend-Status"
	HeaderCLIBackendMessage   string = "X-Cpcli-Backend-Message"
	HeaderCLIBackendMediaType string = "X-Cpcli-Backend-Mediatype"
	HeaderCLIClientUpdate     string = "X-Cpcli-Client-Update"
	HeaderCLIServerMessage    string = "X-Cpcli-Server-Message"
)
View Source
const DefaultServerURL string = "https://cli.btp.cloud.sap"

Variables

This section is empty.

Functions

func GiveBrowserTimeToOpen added in v1.3.0

func GiveBrowserTimeToOpen()

func NewV2Client

func NewV2Client(serverURL *url.URL) *v2Client

func NewV2ClientWithHttpClient

func NewV2ClientWithHttpClient(client *http.Client, serverURL *url.URL) *v2Client

func OptionalCustomIdpPath added in v1.3.0

func OptionalCustomIdpPath(loginReq *BrowserLoginRequest) string

Types

type Action

type Action string
const (
	ActionAdd         Action = "add"
	ActionAssign      Action = "assign"
	ActionCreate      Action = "create"
	ActionDelete      Action = "delete"
	ActionDisable     Action = "disable"
	ActionEnable      Action = "enable"
	ActionGet         Action = "get"
	ActionList        Action = "list"
	ActionRegister    Action = "register"
	ActionRemove      Action = "remove"
	ActionShare       Action = "share"
	ActionSubscribe   Action = "subscribe"
	ActionUnassign    Action = "unassign"
	ActionUnregister  Action = "unregister"
	ActionUnshare     Action = "unshare"
	ActionUnsubscribe Action = "unsubscribe"
	ActionUpdate      Action = "update"
)

type ApiCredentialInput added in v1.6.0

type ApiCredentialInput struct {
	Subaccount    string `btpcli:"subaccount"`
	Directory     string `btpcli:"directory"`
	GlobalAccount string `btpcli:"globalAccount"`
	Name          string `btpcli:"name,omitempty"`
	Certificate   string `btpcli:"certificate,omitempty"`
	ReadOnly      bool   `btpcli:"readOnly,omitempty"`
}

type BrowserLoginPostResponse added in v1.3.0

type BrowserLoginPostResponse struct {
	Issuer       string `json:"issuer"`
	RefreshToken string `json:"refreshToken"`
	Username     string `json:"user"`
	Email        string `json:"mail"`
}

type BrowserLoginRequest added in v1.3.0

type BrowserLoginRequest struct {
	CustomIdp              string `json:"customIdp"`
	GlobalAccountSubdomain string `json:"subdomain"`
}

func NewBrowserLoginRequest added in v1.3.0

func NewBrowserLoginRequest(idp string, globalaccountSubdomain string) *BrowserLoginRequest

type BrowserResponse added in v1.3.0

type BrowserResponse struct {
	LoginID           string `json:"loginId"`
	SubdomainRequired bool   `json:"subdomainRequired"`
}

type BtpClientError added in v1.4.0

type BtpClientError struct {
	Message     string         `json:"error"` // This should always be available
	Description string         `json:"description"`
	BrokerError *SmBrokerError `json:"broker_error"` // Service Broker/Service Manager specific
}

We define an Uber Error type that is used to handle errors from the BTP CLI client. The error structure comprises the possible JSON structure of the error responses

type ClientFacade

type ClientFacade struct {
	Accounts accountsFacade
	Services servicesFacade
	Security securityFacade
	// contains filtered or unexported fields
}

func NewClientFacade

func NewClientFacade(cliClient *v2Client) *ClientFacade

func (ClientFacade) BrowserLogin added in v1.3.0

func (v2 ClientFacade) BrowserLogin(ctx context.Context, loginReq *BrowserLoginRequest) (*BrowserLoginPostResponse, error)

BrowserLogin authenticates user using SSO

func (ClientFacade) Execute

func (v2 ClientFacade) Execute(ctx context.Context, cmdReq *CommandRequest, options ...CommandOptions) (cmdRes CommandResponse, err error)

Execute executes a command

func (ClientFacade) GetGlobalAccountSubdomain

func (v2 ClientFacade) GetGlobalAccountSubdomain() string

func (ClientFacade) GetLoggedInUser

func (v2 ClientFacade) GetLoggedInUser() *v2LoggedInUser

func (ClientFacade) IdTokenLogin

func (v2 ClientFacade) IdTokenLogin(ctx context.Context, loginReq *IdTokenLoginRequest) (*LoginResponse, error)

IdTokenLogin authenticates a user by providing an id token

func (ClientFacade) Login

func (v2 ClientFacade) Login(ctx context.Context, loginReq *LoginRequest) (*LoginResponse, error)

Login authenticates a user using username + password

func (ClientFacade) PasscodeLogin

func (v2 ClientFacade) PasscodeLogin(ctx context.Context, loginReq *PasscodeLoginRequest) (*LoginResponse, error)

PasscodeLogin authenticates with a pem encoded x509 key-pair

type CommandOptions

type CommandOptions struct {
	GoodState        int
	KnownErrorStates map[int]string
}

type CommandRequest

type CommandRequest struct {
	Action  Action
	Command string
	Args    any
}

func NewAddRequest

func NewAddRequest(command string, args any) *CommandRequest

NewAddRequest creates a new add request

func NewAssignRequest

func NewAssignRequest(command string, args any) *CommandRequest

NewAssignRequest creates a new assign request

func NewCommandRequest

func NewCommandRequest(action Action, command string, args any) *CommandRequest

Command

func NewCreateRequest

func NewCreateRequest(command string, args any) *CommandRequest

NewCreateRequest creates a new create request

func NewDeleteRequest

func NewDeleteRequest(command string, args any) *CommandRequest

NewDeleteRequest creates a new delete request

func NewDisableRequest

func NewDisableRequest(command string, args any) *CommandRequest

NewDisableRequest creates a new disable request

func NewEnableRequest

func NewEnableRequest(command string, args any) *CommandRequest

NewEnableRequest creates a new enable request

func NewGetRequest

func NewGetRequest(command string, args any) *CommandRequest

NewGetRequest creates a new get request

func NewListRequest

func NewListRequest(command string, args any) *CommandRequest

NewListRequest creates a new list request

func NewRegisterRequest

func NewRegisterRequest(command string, args any) *CommandRequest

NewRegisterRequest creates a new register request

func NewRemoveRequest

func NewRemoveRequest(command string, args any) *CommandRequest

NewRemoveRequest creates a new remove request

func NewShareRequest

func NewShareRequest(command string, args any) *CommandRequest

NewShareRequest creates a new share request

func NewSubscribeRequest

func NewSubscribeRequest(command string, args any) *CommandRequest

NewSubscribeRequest creates a new subscribe request

func NewUnassignRequest

func NewUnassignRequest(command string, args any) *CommandRequest

NewUnassignRequest creates a new unassign request

func NewUnregisterRequest

func NewUnregisterRequest(command string, args any) *CommandRequest

NewUnregisterRequest creates a new unregister request

func NewUnshareRequest

func NewUnshareRequest(command string, args any) *CommandRequest

NewUnshareRequest creates a new unshare request

func NewUnsubscribeRequest

func NewUnsubscribeRequest(command string, args any) *CommandRequest

NewUnsubscribeRequest creates a new unsubscribe request

func NewUpdateRequest

func NewUpdateRequest(command string, args any) *CommandRequest

NewUpdateRequest creates a new update request

type CommandResponse

type CommandResponse struct {
	StatusCode  int
	ContentType string
	Body        io.ReadCloser
}

type DirectoryAssignmentInput

type DirectoryAssignmentInput struct {
	DirectoryId          string
	ServiceName          string
	ServicePlanName      string
	Amount               int
	Distribute           bool
	AutoAssign           bool
	AutoDistributeAmount int
}

type DirectoryCreateInput

type DirectoryCreateInput struct {
	DisplayName   string              `btpcli:"displayName"`
	Description   *string             `btpcli:"description"`
	ParentID      *string             `btpcli:"parentID"`
	Subdomain     *string             `btpcli:"subdomain"`
	Labels        map[string][]string `btpcli:"labels"`
	Globalaccount string              `btpcli:"globalAccount"`
	Features      []string            `btpcli:"directoryFeatures"`
}

type DirectoryEnableInput added in v1.1.0

type DirectoryEnableInput struct {
	DirectoryId   string   `btpcli:"directoryID"`
	Globalaccount string   `btpcli:"globalAccount"`
	Subdomain     *string  `btpcli:"subdomain"`
	Features      []string `btpcli:"directoryFeatures"`
	Confirm       bool     `btpcli:"confirm"`
}

type DirectoryRoleCreateInput

type DirectoryRoleCreateInput struct {
	RoleName         string `btpcli:"roleName"`
	AppId            string `btpcli:"appId"`
	RoleTemplateName string `btpcli:"roleTemplateName"`
	DirectoryId      string `btpcli:"directory"`
	Description      string `btpcli:"description"`
}

type DirectoryUpdateInput

type DirectoryUpdateInput struct {
	DirectoryId   string              `btpcli:"directoryID"`
	Globalaccount string              `btpcli:"globalAccount"`
	DisplayName   *string             `btpcli:"displayName"`
	Description   *string             `btpcli:"description"`
	Labels        map[string][]string `btpcli:"labels"`
}

type GlobalAccountRoleCreateInput

type GlobalAccountRoleCreateInput struct {
	RoleName         string `btpcli:"roleName"`
	AppId            string `btpcli:"appId"`
	RoleTemplateName string `btpcli:"roleTemplateName"`
	Description      string `btpcli:"description"`
}

type GlobalaccountResourceProviderCreateUpdateInput

type GlobalaccountResourceProviderCreateUpdateInput struct {
	Provider      string `btpcli:"provider"`
	TechnicalName string `btpcli:"technicalName"`
	DisplayName   string `btpcli:"displayName"`
	Description   string `btpcli:"description"`
	Configuration string `btpcli:"configurationInfo"`
	Globalaccount string `btpcli:"globalAccount"`
}

type IdTokenLoginRequest

type IdTokenLoginRequest struct {
	GlobalAccountSubdomain string `json:"subdomain"`
	IdToken                string `json:"idToken"`
}

func NewIdTokenLoginRequest

func NewIdTokenLoginRequest(globalaccountSubdomain string, idToken string) *IdTokenLoginRequest

type LoginRequest

type LoginRequest struct {
	IdentityProvider       string `json:"customIdp"`
	GlobalAccountSubdomain string `json:"subdomain"`
	Username               string `json:"userName"`
	Password               string `json:"password"`
}

func NewLoginRequest

func NewLoginRequest(globalaccountSubdomain string, username string, password string) *LoginRequest

NewLoginRequest returns a new LoginRequest with `ldap` as default IdentityProvider set.

func NewLoginRequestWithCustomIDP

func NewLoginRequestWithCustomIDP(idp string, globalaccountSubdomain string, username string, password string) *LoginRequest

type LoginResponse

type LoginResponse struct {
	Username string `json:"user"`
	Email    string `json:"mail"`
	Issuer   string `json:"issuer"`
}

type PasscodeLoginRequest

type PasscodeLoginRequest struct {
	GlobalAccountSubdomain string
	IdentityProvider       string
	IdentityProviderURL    string
	Username               string
	PEMEncodedCACerts      string
	PEMEncodedPrivateKey   string
	PEMEncodedCertificate  string
}

type SecuritySettingsUpdateInput

type SecuritySettingsUpdateInput struct {
	IFrame                            string   `btpcli:"iFrameDomain"`
	CustomEmail                       []string `btpcli:"customEmailDomains,json"`
	DefaultIDPForNonInteractiveLogon  string   `btpcli:"defaultIdp"`
	TreatUsersWithSameEmailAsSameUser bool     `btpcli:"treatUsersWithSameEmailAsSameUser"`
	HomeRedirect                      string   `btpcli:"homeRedirect"`
	AccessTokenValidity               int      `btpcli:"accessTokenValidity"`
	RefreshTokenValidity              int      `btpcli:"refreshTokenValidity"`
}

type ServiceInstanceCreateInput

type ServiceInstanceCreateInput struct {
	Name          string              `btpcli:"name"`
	Subaccount    string              `btpcli:"subaccount"`
	ServicePlanId string              `btpcli:"plan"`
	Parameters    *string             `btpcli:"parameters"`
	Labels        map[string][]string `btpcli:"labels"`
}

type ServiceInstanceShareInput added in v1.2.0

type ServiceInstanceShareInput struct {
	Id         string `btpcli:"id"`
	Subaccount string `btpcli:"subaccount"`
	Name       string `btpcli:"name"`
}

type ServiceInstanceUpdateInput

type ServiceInstanceUpdateInput struct {
	Id            string  `btpcli:"id"`
	NewName       string  `btpcli:"newName"`
	Subaccount    string  `btpcli:"subaccount"`
	ServicePlanId string  `btpcli:"plan"`
	Parameters    *string `btpcli:"parameters"`
	LabelsPlan    map[string][]string
	LabelsState   map[string][]string
}

type Session

type Session struct {
	GlobalAccountSubdomain string
	SessionId              string
	IdentityProvider       string
	LoggedInUser           *v2LoggedInUser

	sync.Mutex
}

type SmBrokerError added in v1.4.0

type SmBrokerError struct {
	// The broker status code.
	StatusCode int32 `json:"StatusCode"`
	// A machine-readable error string that may be returned by the broker.
	ErrorMessage string `json:"ErrorMessage"`
	// A human-readable description of the error that may be returned by the broker.
	Description string `json:"Description"`
	// ResponseError is set to the error that occurred when unmarshalling a response body from the broker.
	ResponseError string `json:"ResponseError"`
}

The service broker error

type SubaccountCreateInput

type SubaccountCreateInput struct {
	BetaEnabled       bool                `btpcli:"betaEnabled"`
	Description       string              `btpcli:"description"`
	Directory         string              `btpcli:"directoryID"`
	DisplayName       string              `btpcli:"displayName"`
	Labels            map[string][]string `btpcli:"labels"`
	Region            string              `btpcli:"region"`
	Subdomain         string              `btpcli:"subdomain"`
	UsedForProduction string              `btpcli:"usedForProduction"`
	Globalaccount     string              `btpcli:"globalAccount"`
}

type SubaccountEnvironmentInstanceCreateInput

type SubaccountEnvironmentInstanceCreateInput struct {
	DisplayName     string `btpcli:"displayName"`
	EnvironmentType string `btpcli:"environmentType"`
	Landscape       string `btpcli:"landscapeLabel"`
	Parameters      string `btpcli:"parameters"`
	Plan            string `btpcli:"plan"`
	Service         string `btpcli:"service"`
	SubaccountID    string `btpcli:"subaccount"`
}

type SubaccountEnvironmentInstanceUpdateInput

type SubaccountEnvironmentInstanceUpdateInput struct {
	EnvironmentID string `btpcli:"environmentID"`
	Parameters    string `btpcli:"parameters"`
	Plan          string `btpcli:"plan"`
	SubaccountID  string `btpcli:"subaccount"`
}

type SubaccountRoleCreateInput

type SubaccountRoleCreateInput struct {
	RoleName         string `btpcli:"roleName"`
	AppId            string `btpcli:"appId"`
	RoleTemplateName string `btpcli:"roleTemplateName"`
	SubaccountId     string `btpcli:"subaccount"`
	Description      string `btpcli:"description"`
}

type SubaccountServiceBindingCreateInput

type SubaccountServiceBindingCreateInput struct {
	Subaccount        string              `btpcli:"subaccount"`
	ServiceInstanceId string              `btpcli:"serviceInstanceID"`
	Name              string              `btpcli:"name"`
	Parameters        string              `btpcli:"parameters"`
	Labels            map[string][]string `btpcli:"labels"`
}

type SubaccountServiceBrokerRegisterInput added in v1.5.0

type SubaccountServiceBrokerRegisterInput struct {
	Subaccount  string              `btpcli:"subaccount"`
	Name        string              `btpcli:"name"`
	Description string              `btpcli:"description"`
	User        string              `btpcli:"user"`
	Password    string              `btpcli:"password"`
	URL         string              `btpcli:"url"`
	Labels      map[string][]string `btpcli:"labels"`
}

type SubaccountServiceBrokerUpdateInput added in v1.5.0

type SubaccountServiceBrokerUpdateInput struct {
	Id          string              `btpcli:"id"`
	Subaccount  string              `btpcli:"subaccount"`
	NewName     string              `btpcli:"newName"`
	Description string              `btpcli:"description"`
	User        string              `btpcli:"user"`
	Password    string              `btpcli:"password"`
	URL         string              `btpcli:"url"`
	Labels      map[string][]string `btpcli:"labels"`
}

type SubaccountUpdateInput

type SubaccountUpdateInput struct {
	BetaEnabled       bool                `btpcli:"betaEnabled"`
	Description       string              `btpcli:"description"`
	Directory         string              `btpcli:"directoryID"`
	DisplayName       string              `btpcli:"displayName"`
	Labels            map[string][]string `btpcli:"labels"`
	SubaccountId      string              `btpcli:"subaccount"`
	UsedForProduction string              `btpcli:"usedForProduction"`
	Globalaccount     string              `btpcli:"globalAccount"`
}

type TrustConfigurationCreateInput

type TrustConfigurationCreateInput struct {
	IdentityProvider string  `btpcli:"iasTenantUrl"`
	Name             *string `btpcli:"name"`
	Description      *string `btpcli:"description"`
	Origin           *string `btpcli:"origin"`
	Domain           *string `btpcli:"domain"`
}

type TrustConfigurationUpdateInput

type TrustConfigurationUpdateInput struct {
	OriginKey             string  `btpcli:"originKey"`
	IdentityProvider      *string `btpcli:"iasTenantUrl"`
	Name                  *string `btpcli:"name"`
	Description           *string `btpcli:"description"`
	Domain                *string `btpcli:"domain"`
	LinkText              *string `btpcli:"linkText"`    // subaccount only
	AvailableForUserLogon *bool   `btpcli:"userLogon"`   // subaccount only
	AutoCreateShadowUsers *bool   `btpcli:"shadowUsers"` // subaccount only
	Status                *string `btpcli:"status"`
}

Directories

Path Synopsis
types
cis
* Entitlements Service * * The Entitlements service provides REST APIs that manage the assignments of entitlements and quotas to subaccounts and directories.
* Entitlements Service * * The Entitlements service provides REST APIs that manage the assignments of entitlements and quotas to subaccounts and directories.
cis_entitlements
* Entitlements Service * * The Entitlements service provides REST APIs that manage the assignments of entitlements and quotas to subaccounts and directories.
* Entitlements Service * * The Entitlements service provides REST APIs that manage the assignments of entitlements and quotas to subaccounts and directories.
provisioning
* Provisioning Service * * The Provisioning service provides REST APIs that are responsible for the provisioning and deprovisioning of environment instances and tenants in the corresponding region.
* Provisioning Service * * The Provisioning service provides REST APIs that are responsible for the provisioning and deprovisioning of environment instances and tenants in the corresponding region.
saas_manager_service
* SaaS Provisioning Service * * The SAP SaaS Provisioning service provides REST APIs that are responsible for the registration and provisioning of multitenant applications and services.
* SaaS Provisioning Service * * The SAP SaaS Provisioning service provides REST APIs that are responsible for the registration and provisioning of multitenant applications and services.
servicemanager
* Service Manager * * Service Manager provides REST APIs that are responsible for the creation and consumption of service instances in any connected runtime environment.
* Service Manager * * Service Manager provides REST APIs that are responsible for the creation and consumption of service instances in any connected runtime environment.
xsuaa_authz
* Authorization * * Provides functions to administrate the Authorization and Trust Management service (XSUAA) of SAP BTP, Cloud Foundry environment.
* Authorization * * Provides functions to administrate the Authorization and Trust Management service (XSUAA) of SAP BTP, Cloud Foundry environment.
xsuaa_plattform
* User Management (System for Cross-domain Identity Management (SCIM)) * * Provides functions to administrate the Authorization and Trust Management service (XSUAA) of SAP BTP, Cloud Foundry environment.
* User Management (System for Cross-domain Identity Management (SCIM)) * * Provides functions to administrate the Authorization and Trust Management service (XSUAA) of SAP BTP, Cloud Foundry environment.

Jump to

Keyboard shortcuts

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