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