diff --git a/internal/twofa/disable2fa.go b/internal/twofa/disable2fa.go index 29c05622..16cb9f22 100644 --- a/internal/twofa/disable2fa.go +++ b/internal/twofa/disable2fa.go @@ -21,6 +21,7 @@ package twofa import ( + "context" "fmt" "github.com/spf13/cobra" @@ -49,12 +50,12 @@ func (c *Client) Disable() *cobra.Command { cmd.SilenceUsage = true if sms { - _, err := c.Service.DisableSms(token) + _, err := c.Service.DisableTfaSms(context.Background()).Execute() if err != nil { return fmt.Errorf("Could not disable Two-Factor Authentication via SMS: %w", err) } } else if app { - _, err := c.Service.DisableApp(token) + _, err := c.Service.DisableTfaApp(context.Background()).Execute() if err != nil { return fmt.Errorf("Could not disable Two-Factor Authentication via App: %w", err) } diff --git a/internal/twofa/enable2fa.go b/internal/twofa/enable2fa.go index 9a9b82a3..7eef7a1e 100644 --- a/internal/twofa/enable2fa.go +++ b/internal/twofa/enable2fa.go @@ -21,6 +21,7 @@ package twofa import ( + "context" "fmt" "github.com/spf13/cobra" @@ -48,12 +49,13 @@ func (c *Client) Enable() *cobra.Command { cmd.SilenceUsage = true if sms { - _, err := c.Service.EnableSms(token) + _, err := c.Service.EnableTfaSms(context.Background()).Execute() if err != nil { return fmt.Errorf("Could not enable Two-Factor Authentication: %w", err) } } else if app { - _, err := c.Service.EnableApp(token) + // _, err := c.Service.EnableApp(token) + _, err := c.Service.EnableTfaApp(context.Background()).Execute() if err != nil { return fmt.Errorf("Could not enable Two-Factor Authentication: %w", err) } diff --git a/internal/twofa/twofa.go b/internal/twofa/twofa.go index 3dcab967..b3e46fb4 100644 --- a/internal/twofa/twofa.go +++ b/internal/twofa/twofa.go @@ -21,14 +21,14 @@ package twofa import ( + metal "github.com/equinix-labs/metal-go/metal/v1" "github.com/equinix/metal-cli/internal/outputs" - "github.com/packethost/packngo" "github.com/spf13/cobra" ) type Client struct { Servicer Servicer - Service packngo.TwoFactorAuthService + Service metal.TwoFactorAuthApiService Out outputs.Outputer } @@ -45,7 +45,7 @@ func (c *Client) NewCommand() *cobra.Command { root.PersistentPreRun(cmd, args) } } - c.Service = c.Servicer.API(cmd).TwoFactorAuth + c.Service = *c.Servicer.MetalAPI(cmd).TwoFactorAuthApi }, } @@ -58,8 +58,10 @@ func (c *Client) NewCommand() *cobra.Command { } type Servicer interface { - API(*cobra.Command) *packngo.Client - ListOptions(defaultIncludes, defaultExcludes []string) *packngo.ListOptions + MetalAPI(*cobra.Command) *metal.APIClient + Filters() map[string]string + Includes(defaultIncludes []string) (incl []string) + Excludes(defaultExcludes []string) (excl []string) } func NewClient(s Servicer, out outputs.Outputer) *Client {