api

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package api provides the main ARK SDK API interface for accessing all ARK services Code generated by genservices; DO NOT EDIT. Automatically generated Ark API for all SDK services. Each service can define a module init to register its config alongside a ServiceGenerator function in the ARK SDK Golang. This package serves as the central entry point for interacting with various ARK services including SIA, SecHub, PCloud, Identity, and other components.

The ArkAPI struct acts as a service factory and registry, managing authenticators, service instances, and configuration profiles. It provides lazy loading of services, meaning services are only instantiated when first accessed, and subsequent calls return the cached instance.

Key features:

  • Centralized access to all ARK services
  • Lazy loading and caching of service instances
  • Authenticator management and distribution to services
  • Profile-based configuration management
  • Service dependency injection with authenticators
  • Consistent error handling across all services

The API supports multiple authenticators that are automatically distributed to services based on their configuration requirements. Each service specifies required and optional authenticators, and the API ensures the appropriate authenticators are provided during service initialization.

Example:

// Create authenticators
ispAuth := &auth.ArkISPAuth{...}
authenticators := []auth.ArkAuth{ispAuth}

// Create API instance
api, err := NewArkAPI(authenticators, nil) // nil uses default profile
if err != nil {
	// handle error
}

// Access services (lazy loaded)
ssoService, err := api.SiaSso()
if err != nil {
	// handle error
}

// Get specific authenticator
auth, err := api.Authenticator("isp")
if err != nil {
	// handle error
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArkAPI

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

ArkAPI wraps different API functionality of Ark Services.

ArkAPI serves as the central entry point and service factory for all ARK services. It manages authenticators, service instances, and configuration profiles, providing a unified interface for accessing various ARK components including SIA, SecHub, PCloud, Identity, and other services.

The struct implements lazy loading for services - each service is only instantiated when first accessed through its corresponding method. Subsequent calls return the cached instance, ensuring efficient resource usage and consistent service state.

Service creation follows a dependency injection pattern where authenticators are automatically distributed to services based on their configuration requirements. Each service specifies required and optional authenticators, and ArkAPI ensures the appropriate authenticators are provided during initialization.

func NewArkAPI

func NewArkAPI(authenticators []auth.ArkAuth, profile *models.ArkProfile) (*ArkAPI, error)

NewArkAPI creates a new ArkAPI instance with the provided authenticators and profile.

Initializes a new ArkAPI instance that serves as the central access point for all ARK services. The instance manages the provided authenticators and distributes them to services as needed. If no profile is provided (nil), the default profile is loaded automatically.

The services map is initialized empty and services are created lazily when first accessed through their respective getter methods. This approach ensures optimal resource usage and faster startup times.

Parameters:

  • authenticators: Slice of authenticators to be used by services. Each service will receive the authenticators it requires based on its configuration
  • profile: Configuration profile to use. If nil, the default profile is loaded automatically using the default profile loader

Returns a pointer to the initialized ArkAPI instance, or an error if the default profile cannot be loaded when profile is nil.

Example:

// With explicit profile
profile := &models.ArkProfile{...}
api, err := NewArkAPI(authenticators, profile)

// With default profile (recommended)
api, err := NewArkAPI(authenticators, nil)
if err != nil {
	// handle profile loading error
}

func (*ArkAPI) Authenticator

func (api *ArkAPI) Authenticator(authenticatorName string) (auth.ArkAuth, error)

Authenticator returns the authenticator with the specified name from the ArkAPI instance.

Searches through the API's authenticator collection and returns the first authenticator that matches the specified name. This method provides access to specific authenticators for custom operations or debugging purposes.

The search is case-sensitive and matches the exact authenticator name as returned by the authenticator's AuthenticatorName() method.

Parameters:

  • authenticatorName: The exact name of the authenticator to retrieve

Returns the matching authenticator, or an error if no authenticator with the specified name is found.

Example:

ispAuth, err := api.Authenticator("isp")
if err != nil {
	// handle authenticator not found
}
// use ispAuth for custom operations

func (*ArkAPI) Profile

func (api *ArkAPI) Profile() *models.ArkProfile

Profile returns the profile associated with the ArkAPI instance.

Provides access to the configuration profile that was set during API initialization. The profile contains environment-specific settings, endpoints, and other configuration parameters used by the various ARK services.

The returned profile is the same instance that was either explicitly provided to NewArkAPI or automatically loaded as the default profile when nil was passed.

Returns a pointer to the ArkProfile instance. The profile is never nil for a properly initialized ArkAPI instance.

Example:

profile := api.Profile()
fmt.Printf("Using profile: %s\n", profile.ProfileName)

Jump to

Keyboard shortcuts

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