github.com/IBM-Cloud/bluemix-go@v0.0.0-20240423071914-9e96525baef4/api/hpcs/endpoint.go (about)

     1  package hpcs
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/IBM-Cloud/bluemix-go/client"
     7  )
     8  
     9  type EndpointResp struct {
    10  	InstanceID string    `json:"instance_id"`
    11  	Kms        Endpoints `json:"kms"`
    12  	Ep11       Endpoints `json:"ep11"`
    13  }
    14  type Endpoints struct {
    15  	Public  string `json:"public"`
    16  	Private string `json:"private"`
    17  }
    18  
    19  type EndpointRepository interface {
    20  	GetAPIEndpoint(instanceID string) (EndpointResp, error)
    21  }
    22  
    23  type hpcsRepository struct {
    24  	client *client.Client
    25  }
    26  
    27  func NewHpcsEndpointRepository(c *client.Client) EndpointRepository {
    28  	return &hpcsRepository{
    29  		client: c,
    30  	}
    31  }
    32  
    33  func (r *hpcsRepository) GetAPIEndpoint(instanceID string) (EndpointResp, error) {
    34  	res := EndpointResp{}
    35  	_, err := r.client.Get(fmt.Sprintf("/instances/%s", instanceID), &res)
    36  	if err != nil {
    37  		return EndpointResp{}, err
    38  	}
    39  	return res, nil
    40  }