initial commit
This commit is contained in:
46
internal/metal/metal.go
Normal file
46
internal/metal/metal.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package metal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.equinixmetal.net/infra9-metal-bridge/internal/metal/models"
|
||||
provider "go.equinixmetal.net/infra9-metal-bridge/internal/metal/providers"
|
||||
"go.infratographer.com/x/gidx"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Client is the Equinix Metal API Client struct.
|
||||
type Client struct {
|
||||
logger *zap.Logger
|
||||
|
||||
provider provider.Provider
|
||||
}
|
||||
|
||||
func (c *Client) GetOrganizationDetails(ctx context.Context, id gidx.PrefixedID) (*models.OrganizationDetails, error) {
|
||||
return c.provider.GetOrganizationDetails(ctx, id)
|
||||
}
|
||||
|
||||
func (c *Client) GetProjectDetails(ctx context.Context, id gidx.PrefixedID) (*models.ProjectDetails, error) {
|
||||
return c.provider.GetProjectDetails(ctx, id)
|
||||
}
|
||||
|
||||
func (c *Client) GetUserDetails(ctx context.Context, id gidx.PrefixedID) (*models.UserDetails, error) {
|
||||
return c.provider.GetUserDetails(ctx, id)
|
||||
}
|
||||
|
||||
// New creates a new Client.
|
||||
func New(options ...Option) (*Client, error) {
|
||||
client := new(Client)
|
||||
|
||||
for _, opt := range options {
|
||||
if err := opt(client); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if client.logger == nil {
|
||||
client.logger = zap.NewNop()
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
||||
Reference in New Issue
Block a user