Documentation
¶
Overview ¶
Package client provides a Cisco Modeling Labs API client
Package client provides configuration options for the CML client.
Index ¶
- type Client
- type Config
- type Option
- func Conditional(condition bool, option Option) Option
- func SkipReadyCheck() Option
- func WithCACertPEM(certPEM []byte) Option
- func WithHTTPClient(hc *http.Client) Option
- func WithInsecureTLS() Option
- func WithLogLevel(level slog.Level) Option
- func WithLogger(l *slog.Logger) Option
- func WithNodeExcludeConfigurations(v bool) Option
- func WithStaticToken(token string) Option
- func WithToken(token string) Option
- func WithTokenStorageFile(filename string) Option
- func WithUsernamePassword(username, password string) Option
- func WithoutNamedConfigs() Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// services
Interface *services.InterfaceService
Lab *services.LabService
Link *services.LinkService
Node *services.NodeService
System *services.SystemService
Group *services.GroupService
User *services.UserService
ImageDefinition *services.ImageDefinitionService
NodeDefinition *services.NodeDefinitionService
ExtConn *services.ExtConnService
Annotation *services.AnnotationService
SmartAnnotation *services.SmartAnnotationService
// contains filtered or unexported fields
}
Client is the main CML API client that provides access to all services.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config holds the configuration for the CML client.
type Option ¶
type Option func(*Config)
Option is a functional option for configuring the client.
func Conditional ¶
Conditional applies an option only if the condition is true.
func SkipReadyCheck ¶
func SkipReadyCheck() Option
SkipReadyCheck disables the automatic system readiness check during client initialization. By default, the client will call Ready() to verify the CML server is compatible and ready before returning. This check can be skipped for performance reasons or when working with servers that don't support the system_information endpoint.
func WithCACertPEM ¶
WithCACertPEM sets a custom CA certificate bundle (PEM). The certificates are added to the system cert pool.
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client.
func WithInsecureTLS ¶
func WithInsecureTLS() Option
WithInsecureTLS skips TLS certificate verification.
func WithLogLevel ¶
WithLogLevel sets the log level for the default client logger.
This only affects the internally-created default logger. If WithLogger is provided, the supplied logger is used as-is.
func WithNodeExcludeConfigurations ¶
WithNodeExcludeConfigurations forces the node GET/LIST query parameter exclude_configurations.
Passing true omits configuration payloads, passing false includes configuration payloads. This is useful to keep node configuration shape stable across CML versions.
func WithStaticToken ¶ added in v0.2.1
WithStaticToken sets a static bearer token for authentication.
Unlike WithToken, this token is not treated as a one-shot bootstrap token. The client will never attempt username/password authentication when this is configured.
func WithTokenStorageFile ¶
WithTokenStorageFile sets the file to store the authentication token. If no stoken storage file is provided, memory storage is being used. There's a tradeoff with memory storage as it requires more authentication API calls which is costly especially when a lot of clients are instantiated during e.g. Terraform runs. The file storage saves the token in the file system but this has a security implication as the token might be retrieved. It's up to the user to remove the configured file with a potentially still valid token!
func WithUsernamePassword ¶
WithUsernamePassword sets the username and password for authentication.
func WithoutNamedConfigs ¶
func WithoutNamedConfigs() Option
WithoutNamedConfigs enables support for named configurations. Named configurations were introduced with CML 2.7 and should be enabled.