btpcli

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: Apache-2.0 Imports: 20 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 GetAppNamesBySubaccountAndApp added in v1.1.0

func GetAppNamesBySubaccountAndApp(subaccountId string, appName string, client *ClientFacade) (technicalAppName string, commercialAppName string, err error)

func GetDefaultRoleCollectionsByDirectory

func GetDefaultRoleCollectionsByDirectory(directoryId string, client *ClientFacade) (defaultRoleCollectionNames []string, err error)

func GetDefaultRoleCollectionsBySubaccount

func GetDefaultRoleCollectionsBySubaccount(subaccountId string, client *ClientFacade) (defaultRoleCollectionNames []string, err error)

func GetDefaultRolesByDirectory

func GetDefaultRolesByDirectory(directoryId string, client *ClientFacade) (defaultRoles []string, err error)

func GetDefaultRolesBySubaccount

func GetDefaultRolesBySubaccount(subaccountId string, client *ClientFacade) (defaults []string, err error)

func GetGlobalAccountId

func GetGlobalAccountId(client *ClientFacade) (string, error)

func GetServiceDataByPlanId

func GetServiceDataByPlanId(client *ClientFacade, subaccountId string, planId string) (planName string, serviceName string, err error)

func NewV2Client

func NewV2Client(serverURL *url.URL) *v2Client

func NewV2ClientWithHttpClient

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

Types

type Action

type Action string
const (
	ActionGet  Action = "get"
	ActionList Action = "list"
)

type BtpClientError

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
	Offering servicesOfferingFacade
	Security securityFacade
	// contains filtered or unexported fields
}

func GetLoggedInClient

func GetLoggedInClient() (*ClientFacade, error)

func NewClientFacade

func NewClientFacade(cliClient *v2Client) *ClientFacade

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 NewCommandRequest

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

Command

func NewGetRequest

func NewGetRequest(command string, args any) *CommandRequest

func NewListRequest

func NewListRequest(command string, args any) *CommandRequest

type CommandResponse

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

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 Session

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

	sync.Mutex
}

type SmBrokerError

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

Directories

Path Synopsis
types
cis
* Accounts Service * * The Accounts service provides REST APIs that are responsible for the management of global accounts, and the creation and management of directories, subaccounts, and their custom properties/tags.
* Accounts Service * * The Accounts service provides REST APIs that are responsible for the management of global accounts, and the creation and management of directories, subaccounts, and their custom properties/tags.
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.

Jump to

Keyboard shortcuts

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