-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/rest/client: Add the client
GetExtensions
client function
Signed-off-by: Gabriel Mougard <[email protected]>
- Loading branch information
1 parent
5967d8e
commit d28ee6e
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/canonical/lxd/shared/api" | ||
"github.com/canonical/microcluster/internal/rest/types" | ||
) | ||
|
||
// GetExtensions returns the runtime extensions of the MicroCluster deployment. | ||
func (c *Client) GetExtensions(ctx context.Context, extensionVendor string, extensionName string) ([]types.RuntimeExtension, error) { | ||
queryCtx, cancel := context.WithTimeout(ctx, 30*time.Second) | ||
defer cancel() | ||
|
||
endpoint := api.NewURL().Path("extensions") | ||
if extensionVendor != "" { | ||
endpoint = endpoint.WithQuery("vendor", extensionVendor) | ||
} | ||
|
||
if extensionName != "" { | ||
endpoint = endpoint.WithQuery("extension", extensionName) | ||
} | ||
|
||
extensions := []types.RuntimeExtension{} | ||
err := c.QueryStruct(queryCtx, "GET", PublicEndpoint, endpoint, nil, &extensions) | ||
|
||
return extensions, err | ||
} |