github.com/supabase/cli@v1.168.1/internal/sso/remove/remove.go (about) 1 package remove 2 3 import ( 4 "context" 5 "net/http" 6 "os" 7 8 "github.com/go-errors/errors" 9 "github.com/supabase/cli/internal/sso/internal/render" 10 "github.com/supabase/cli/internal/utils" 11 "github.com/supabase/cli/pkg/api" 12 ) 13 14 func Run(ctx context.Context, ref, providerId, format string) error { 15 resp, err := utils.GetSupabase().RemoveProviderByIdWithResponse(ctx, ref, providerId) 16 if err != nil { 17 return errors.Errorf("failed to remove sso provider: %w", err) 18 } 19 20 if resp.JSON200 == nil { 21 if resp.StatusCode() == http.StatusNotFound { 22 return errors.Errorf("An identity provider with ID %q could not be found.", providerId) 23 } 24 25 return errors.New("Unexpected error removing identity provider: " + string(resp.Body)) 26 } 27 28 switch format { 29 case utils.OutputPretty: 30 return render.SingleMarkdown(api.Provider{ 31 Id: resp.JSON200.Id, 32 Saml: resp.JSON200.Saml, 33 Domains: resp.JSON200.Domains, 34 CreatedAt: resp.JSON200.CreatedAt, 35 UpdatedAt: resp.JSON200.UpdatedAt, 36 }) 37 38 default: 39 return utils.EncodeOutput(format, os.Stdout, resp.JSON200) 40 } 41 }