github.com/IBM-Cloud/bluemix-go@v0.0.0-20240423071914-9e96525baef4/api/container/containerv2/satellite.go (about)

     1  package containerv2
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/IBM-Cloud/bluemix-go/client"
     7  )
     8  
     9  type SatelliteLocationInfo struct {
    10  	ID                string      `json:"id"`
    11  	Name              string      `json:"name"`
    12  	Region            string      `json:"region"`
    13  	ResourceGroup     string      `json:"resourceGroup"`
    14  	ResourceGroupName string      `json:"resourceGroupName"`
    15  	PodSubnet         string      `json:"podSubnet"`
    16  	ServiceSubnet     string      `json:"serviceSubnet"`
    17  	CreatedDate       string      `json:"createdDate"`
    18  	MasterKubeVersion string      `json:"masterKubeVersion"`
    19  	TargetVersion     string      `json:"targetVersion"`
    20  	WorkerCount       int         `json:"workerCount"`
    21  	Location          string      `json:"location"`
    22  	Datacenter        string      `json:"datacenter"`
    23  	MultiAzCapable    bool        `json:"multiAzCapable"`
    24  	Provider          string      `json:"provider"`
    25  	State             string      `json:"state"`
    26  	Status            string      `json:"status"`
    27  	VersionEOS        string      `json:"versionEOS"`
    28  	IsPaid            bool        `json:"isPaid"`
    29  	Entitlement       string      `json:"entitlement"`
    30  	Type              string      `json:"type"`
    31  	Addons            interface{} `json:"addons"`
    32  	EtcdPort          string      `json:"etcdPort"`
    33  	MasterURL         string      `json:"masterURL"`
    34  	Ingress           struct {
    35  		Hostname   string `json:"hostname"`
    36  		SecretName string `json:"secretName"`
    37  		Status     string `json:"status"`
    38  		Message    string `json:"message"`
    39  	} `json:"ingress"`
    40  	CaCertRotationStatus struct {
    41  		Status              string `json:"status"`
    42  		ActionTriggerDate   string `json:"actionTriggerDate"`
    43  		ActionCompletedDate string `json:"actionCompletedDate"`
    44  	} `json:"caCertRotationStatus"`
    45  	ImageSecurityEnabled bool     `json:"imageSecurityEnabled"`
    46  	DisableAutoUpdate    bool     `json:"disableAutoUpdate"`
    47  	Crn                  string   `json:"crn"`
    48  	WorkerZones          []string `json:"workerZones"`
    49  	Lifecycle            struct {
    50  		MasterStatus             string `json:"masterStatus"`
    51  		MasterStatusModifiedDate string `json:"masterStatusModifiedDate"`
    52  		MasterHealth             string `json:"masterHealth"`
    53  		MasterState              string `json:"masterState"`
    54  		ModifiedDate             string `json:"modifiedDate"`
    55  	} `json:"lifecycle"`
    56  	ServiceEndpoints struct {
    57  		PrivateServiceEndpointEnabled bool   `json:"privateServiceEndpointEnabled"`
    58  		PrivateServiceEndpointURL     string `json:"privateServiceEndpointURL"`
    59  		PublicServiceEndpointEnabled  bool   `json:"publicServiceEndpointEnabled"`
    60  		PublicServiceEndpointURL      string `json:"publicServiceEndpointURL"`
    61  	} `json:"serviceEndpoints"`
    62  	Features struct {
    63  		KeyProtectEnabled bool `json:"keyProtectEnabled"`
    64  		PullSecretApplied bool `json:"pullSecretApplied"`
    65  	} `json:"features"`
    66  	Vpcs      interface{} `json:"vpcs"`
    67  	CosConfig struct {
    68  		Region          string `json:"region"`
    69  		Bucket          string `json:"bucket"`
    70  		Endpoint        string `json:"endpoint"`
    71  		ServiceInstance struct {
    72  			Crn string `json:"crn"`
    73  		} `json:"serviceInstance"`
    74  	} `json:"cos_config"`
    75  	Description string `json:"description"`
    76  	Deployments struct {
    77  		Enabled bool   `json:"enabled"`
    78  		Message string `json:"message"`
    79  	} `json:"deployments"`
    80  	Hosts struct {
    81  		Total     int `json:"total"`
    82  		Available int `json:"available"`
    83  	} `json:"hosts"`
    84  	Iaas struct {
    85  		Provider string `json:"provider"`
    86  		Region   string `json:"region"`
    87  	} `json:"iaas"`
    88  	OpenVpnServerPort int `json:"open_vpn_server_port"`
    89  }
    90  
    91  type Satellite interface {
    92  	GetLocationInfo(name string, target ClusterTargetHeader) (*SatelliteLocationInfo, error)
    93  }
    94  
    95  type satellite struct {
    96  	client     *client.Client
    97  	pathPrefix string
    98  }
    99  
   100  func newSatelliteAPI(c *client.Client) Satellite {
   101  	return &satellite{
   102  		client: c,
   103  	}
   104  }
   105  
   106  func (s *satellite) GetLocationInfo(name string, target ClusterTargetHeader) (*SatelliteLocationInfo, error) {
   107  	SatLocationInfo := &SatelliteLocationInfo{}
   108  	rawURL := fmt.Sprintf("/v2/satellite/getController?controller=%s", name)
   109  	_, err := s.client.Get(rawURL, &SatLocationInfo, target.ToMap())
   110  	if err != nil {
   111  		return nil, err
   112  	}
   113  	return SatLocationInfo, err
   114  }