diff --git a/README.md b/README.md index ccbdd4b..aed5191 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # CloudConnexa Go Client + This Go library enables access to the CloudConnexa API, as detailed in the [CloudConnexa API Documentation](https://openvpn.net/cloud-docs/developer/cloudconnexa-api.html). ## Installation Instructions + To install the cloudconnexa-go-client, ensure you are using a modern Go release that supports module mode. With Go set up, execute the following command: ```sh @@ -9,8 +11,51 @@ go get github.com/openvpn/cloudconnexa-go-client/v2/cloudconnexa ``` ## How to Use + In your Go project, you can use the library by importing it as follows: ```go import "github.com/openvpn/cloudconnexa-go-client/v2/cloudconnexa" -``` \ No newline at end of file +``` + +Instantiate a new CloudConnexa client. Subsequently, utilize the diverse services provided by the client to interact with distinct segments of the CloudConnexa API. For instance: + +```go +client := cloudconnexa.NewClient("api_url", "client_id", "client_secret") + +// List connectors +connectors, _, err := client.Connectors.List(ctx, nil) +``` + +## Authentication + +For auth need to pass three parameters: +1. client_id +2. client_secret +3. api_url (example: `https://myorg.api.openvpn.com`) + +```go +package main + +import ( + "fmt" + "log" + + "github.com/openvpn/cloudconnexa-go-client/v2/cloudconnexa" +) + +func main() { + client, err := cloudconnexa.NewClient("api_url", "client_id", "client_secret") + if err != nil { + log.Fatalf("error creating client: %v", err) + } + + networkId := "your_network_id" + routes, err := client.Routes.List(networkId) + if err != nil { + log.Fatalf("error getting routes: %v", err) + } + + fmt.Println("Received routes:", routes) +} +``` diff --git a/cloudconnexa/connectors.go b/cloudconnexa/connectors.go index 54a22e4..d1daec4 100644 --- a/cloudconnexa/connectors.go +++ b/cloudconnexa/connectors.go @@ -53,7 +53,7 @@ func (c *ConnectorsService) GetByPage(page int, pageSize int) (ConnectorPageResp return response, nil } -func (c *ConnectorsService) GetAll() ([]Connector, error) { +func (c *ConnectorsService) List() ([]Connector, error) { var allConnectors []Connector page := 1 pageSize := 10 @@ -75,7 +75,7 @@ func (c *ConnectorsService) GetAll() ([]Connector, error) { } func (c *ConnectorsService) GetByName(name string) (*Connector, error) { - connectors, err := c.GetAll() + connectors, err := c.List() if err != nil { return nil, err } @@ -89,7 +89,7 @@ func (c *ConnectorsService) GetByName(name string) (*Connector, error) { } func (c *ConnectorsService) GetByID(connectorID string) (*Connector, error) { - connectors, err := c.GetAll() + connectors, err := c.List() if err != nil { return nil, err } @@ -103,7 +103,7 @@ func (c *ConnectorsService) GetByID(connectorID string) (*Connector, error) { } func (c *ConnectorsService) GetByNetworkID(networkId string) ([]Connector, error) { - connectors, err := c.GetAll() + connectors, err := c.List() if err != nil { return nil, err }