From a7d9ba9639be5417e4f0b10fe1ba72697c920e74 Mon Sep 17 00:00:00 2001 From: Charles Treatman Date: Mon, 22 Jan 2024 13:57:09 -0600 Subject: [PATCH] finish migrating 2fa subcommand code --- internal/twofa/disable2fa.go | 4 ++-- internal/twofa/enable2fa.go | 4 ++-- internal/twofa/receive.go | 6 +++--- internal/twofa/twofa.go | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/twofa/disable2fa.go b/internal/twofa/disable2fa.go index e5e6ab8e..1b614cdc 100644 --- a/internal/twofa/disable2fa.go +++ b/internal/twofa/disable2fa.go @@ -50,12 +50,12 @@ func (c *Client) Disable() *cobra.Command { cmd.SilenceUsage = true if sms { - _, err := c.TwoFAService.DisableTfaSms(context.Background()).Execute() + _, err := c.TwoFAService.DisableTfaSms(context.Background()).XOtpToken(token).Execute() if err != nil { return fmt.Errorf("Could not disable Two-Factor Authentication via SMS: %w", err) } } else if app { - _, err := c.TwoFAService.DisableTfaApp(context.Background()).Execute() + _, err := c.TwoFAService.DisableTfaApp(context.Background()).XOtpToken(token).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 27fea9c6..2c6b56cc 100644 --- a/internal/twofa/enable2fa.go +++ b/internal/twofa/enable2fa.go @@ -49,12 +49,12 @@ func (c *Client) Enable() *cobra.Command { cmd.SilenceUsage = true if sms { - _, err := c.TwoFAService.EnableTfaSms(context.Background()).Execute() + _, err := c.TwoFAService.EnableTfaSms(context.Background()).XOtpToken(token).Execute() if err != nil { return fmt.Errorf("Could not enable Two-Factor Authentication: %w", err) } } else if app { - _, err := c.TwoFAService.EnableTfaApp(context.Background()).Execute() + _, err := c.TwoFAService.EnableTfaApp(context.Background()).XOtpToken(token).Execute() if err != nil { return fmt.Errorf("Could not enable Two-Factor Authentication: %w", err) } diff --git a/internal/twofa/receive.go b/internal/twofa/receive.go index fc1e789d..a15eef3b 100644 --- a/internal/twofa/receive.go +++ b/internal/twofa/receive.go @@ -57,16 +57,16 @@ func (c *Client) Receive() *cobra.Command { return nil } - otpURI, _, err := c.TwoFAService.SeedApp() + resp, _, err := c.OtpService.SeedApp(context.Background()).Execute() if err != nil { return fmt.Errorf("Could not get the OTP Seed URI: %w", err) } data := make([][]string, 1) - data[0] = []string{otpURI} + data[0] = []string{resp.GetOtpUri()} header := []string{"OTP URI"} - return c.Out.Output(otpURI, header, &data) + return c.Out.Output(resp, header, &data) }, } diff --git a/internal/twofa/twofa.go b/internal/twofa/twofa.go index e3c2bcdb..d738bf46 100644 --- a/internal/twofa/twofa.go +++ b/internal/twofa/twofa.go @@ -23,14 +23,14 @@ package twofa import ( "github.com/equinix/metal-cli/internal/outputs" - metal "github.com/equinix-labs/metal-go/metal/v1" + "github.com/equinix/equinix-sdk-go/services/metalv1" "github.com/spf13/cobra" ) type Client struct { Servicer Servicer - TwoFAService *metal.TwoFactorAuthApiService - OtpService *metal.OTPsApiService + TwoFAService *metalv1.TwoFactorAuthApiService + OtpService *metalv1.OTPsApiService Out outputs.Outputer } @@ -61,7 +61,7 @@ func (c *Client) NewCommand() *cobra.Command { } type Servicer interface { - MetalAPI(*cobra.Command) *metal.APIClient + MetalAPI(*cobra.Command) *metalv1.APIClient Filters() map[string]string Includes(defaultIncludes []string) (incl []string) Excludes(defaultExcludes []string) (excl []string)