sdk

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 5 Imported by: 0

README

Apollo Open API SDK for Go

This is a Go SDK for Apollo Open API.

Installation

go get github.com/alomerry/go-tools/components/apollo/sdk

Usage

package main

import (
    "context"
    "fmt"
    "log"

    "github.com/alomerry/go-tools/components/apollo/sdk"
)

func main() {
    client := sdk.NewClient("http://localhost:8070", "your-token")

    // Get Apps
    apps, err := client.Apps.GetApps(context.Background(), nil)
    if err != nil {
        log.Fatal(err)
    }
    for _, app := range apps {
        fmt.Printf("App: %s\n", app.Name)
    }

    // Get Namespace
    ns, err := client.Namespaces.Get(context.Background(), "DEV", "appId", "default", "application")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Namespace: %+v\n", ns)
}

Features

  • App Management
  • Cluster Management
  • Namespace Management
  • Item Management
  • Release Management

Documentation

Overview

Package sdk provides a client for the Apollo Open API.

Usage:

client := sdk.NewClient("http://localhost:8070", "token")
apps, err := client.Apps.GetApps(context.Background(), nil)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Name                       string `json:"name"`
	AppID                      string `json:"appId"`
	OrgID                      string `json:"orgId"`
	OrgName                    string `json:"orgName"`
	OwnerName                  string `json:"ownerName"`
	OwnerEmail                 string `json:"ownerEmail"`
	DataChangeCreatedBy        string `json:"dataChangeCreatedBy"`
	DataChangeLastModifiedBy   string `json:"dataChangeLastModifiedBy"`
	DataChangeCreatedTime      string `json:"dataChangeCreatedTime"`
	DataChangeLastModifiedTime string `json:"dataChangeLastModifiedTime"`
}

type AppEnvCluster

type AppEnvCluster struct {
	Env      string   `json:"env"`
	Clusters []string `json:"clusters"`
}

type AppsService

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

func (*AppsService) GetApps

func (s *AppsService) GetApps(ctx context.Context, appIDs []string) ([]*App, error)

GetApps returns the information for all apps or specific apps. URL: http://{portal_address}/openapi/v1/apps appIDs: optional, comma separated appIds

func (*AppsService) GetEnvClusters

func (s *AppsService) GetEnvClusters(ctx context.Context, appID string) ([]*AppEnvCluster, error)

GetEnvClusters returns the environment and cluster information for an app. URL: http://{portal_address}/openapi/v1/apps/{appId}/envclusters

type Client

type Client struct {

	// Services used for communicating with different parts of the Apollo Open API.
	Apps       *AppsService
	Clusters   *ClustersService
	Namespaces *NamespacesService
	Items      *ItemsService
	Releases   *ReleasesService
	// contains filtered or unexported fields
}

Client handles communication with the Apollo Open API.

func NewClient

func NewClient(baseURL, token string) *Client

NewClient returns a new Apollo Open API client. baseURL: The base URL of the Apollo Portal, e.g., "http://localhost:8070" token: The API token obtained from Apollo Portal

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, path string, body interface{}, result interface{}) (*resty.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.

type Cluster

type Cluster struct {
	Name                       string `json:"name"`
	AppID                      string `json:"appId"`
	ParentClusterID            string `json:"parentClusterId"`
	DataChangeCreatedBy        string `json:"dataChangeCreatedBy"`
	DataChangeLastModifiedBy   string `json:"dataChangeLastModifiedBy"`
	DataChangeCreatedTime      string `json:"dataChangeCreatedTime"`
	DataChangeLastModifiedTime string `json:"dataChangeLastModifiedTime"`
}

type ClustersService

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

func (*ClustersService) Create

func (s *ClustersService) Create(ctx context.Context, env, appID string, cluster *Cluster) (*Cluster, error)

func (*ClustersService) Get

func (s *ClustersService) Get(ctx context.Context, env, appID, clusterName string) (*Cluster, error)

type ErrorResponse

type ErrorResponse struct {
	Status    int    `json:"status"`
	Message   string `json:"message"`
	Exception string `json:"exception"`
	Timestamp string `json:"timestamp"`
}

ErrorResponse represents an error response from the Apollo Open API.

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type Item

type Item struct {
	Key                        string `json:"key"`
	Value                      string `json:"value"`
	Comment                    string `json:"comment"`
	DataChangeCreatedBy        string `json:"dataChangeCreatedBy"`
	DataChangeLastModifiedBy   string `json:"dataChangeLastModifiedBy"`
	DataChangeCreatedTime      string `json:"dataChangeCreatedTime"`
	DataChangeLastModifiedTime string `json:"dataChangeLastModifiedTime"`
}

type ItemsService

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

func (*ItemsService) Create

func (s *ItemsService) Create(ctx context.Context, env, appID, clusterName, namespaceName string, item *Item) (*Item, error)

func (*ItemsService) Delete

func (s *ItemsService) Delete(ctx context.Context, env, appID, clusterName, namespaceName, key, operator string) error

func (*ItemsService) Get

func (s *ItemsService) Get(ctx context.Context, env, appID, clusterName, namespaceName, key string) (*Item, error)

func (*ItemsService) List

func (s *ItemsService) List(ctx context.Context, env, appID, clusterName, namespaceName string, page, size int) (*PageDTO, error)

func (*ItemsService) Update

func (s *ItemsService) Update(ctx context.Context, env, appID, clusterName, namespaceName string, item *Item) (*Item, error)

type Namespace

type Namespace struct {
	AppID                      string `json:"appId"`
	ClusterName                string `json:"clusterName"`
	NamespaceName              string `json:"namespaceName"`
	Comment                    string `json:"comment"`
	Format                     string `json:"format"`
	IsPublic                   bool   `json:"isPublic"`
	Items                      []Item `json:"items"`
	DataChangeCreatedBy        string `json:"dataChangeCreatedBy"`
	DataChangeLastModifiedBy   string `json:"dataChangeLastModifiedBy"`
	DataChangeCreatedTime      string `json:"dataChangeCreatedTime"`
	DataChangeLastModifiedTime string `json:"dataChangeLastModifiedTime"`
}

type NamespaceLock

type NamespaceLock struct {
	NamespaceName string `json:"namespaceName"`
	IsLocked      bool   `json:"isLocked"`
	LockedBy      string `json:"lockedBy"`
}

type NamespacesService

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

func (*NamespacesService) Create

func (s *NamespacesService) Create(ctx context.Context, env, appID, clusterName string, namespace *Namespace) (*Namespace, error)

func (*NamespacesService) Get

func (s *NamespacesService) Get(ctx context.Context, env, appID, clusterName, namespaceName string) (*Namespace, error)

func (*NamespacesService) GetAll

func (s *NamespacesService) GetAll(ctx context.Context, env, appID, clusterName string) ([]*Namespace, error)

func (*NamespacesService) GetLock

func (s *NamespacesService) GetLock(ctx context.Context, env, appID, clusterName, namespaceName string) (*NamespaceLock, error)

type PageDTO

type PageDTO struct {
	Content []*Item `json:"content"`
	Page    int     `json:"page"`
	Size    int     `json:"size"`
	Total   int     `json:"total"`
}

type PublishOptions

type PublishOptions struct {
	ReleaseTitle   string `json:"releaseTitle"`
	ReleaseComment string `json:"releaseComment"`
	ReleasedBy     string `json:"releasedBy"`
}

type Release

type Release struct {
	AppID                      string            `json:"appId"`
	ClusterName                string            `json:"clusterName"`
	NamespaceName              string            `json:"namespaceName"`
	Name                       string            `json:"name"`
	Configurations             map[string]string `json:"configurations"`
	Comment                    string            `json:"comment"`
	DataChangeCreatedBy        string            `json:"dataChangeCreatedBy"`
	DataChangeLastModifiedBy   string            `json:"dataChangeLastModifiedBy"`
	DataChangeCreatedTime      string            `json:"dataChangeCreatedTime"`
	DataChangeLastModifiedTime string            `json:"dataChangeLastModifiedTime"`
}

type ReleasesService

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

func (*ReleasesService) GetLatest

func (s *ReleasesService) GetLatest(ctx context.Context, env, appID, clusterName, namespaceName string) (*Release, error)

func (*ReleasesService) Publish

func (s *ReleasesService) Publish(ctx context.Context, env, appID, clusterName, namespaceName string, opts *PublishOptions) (*Release, error)

func (*ReleasesService) Rollback

func (s *ReleasesService) Rollback(ctx context.Context, env string, releaseID int, operator string) error

Jump to

Keyboard shortcuts

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