From f505ee4643e2757ef6069602c2f40c1057c5f5b2 Mon Sep 17 00:00:00 2001 From: neha-Gupta1 Date: Thu, 20 Jul 2023 12:59:47 +0530 Subject: [PATCH] move m365 changes to another PR --- src/pkg/services/m365/m365.go | 80 ----------------------------------- 1 file changed, 80 deletions(-) diff --git a/src/pkg/services/m365/m365.go b/src/pkg/services/m365/m365.go index b08cf7926..91141696f 100644 --- a/src/pkg/services/m365/m365.go +++ b/src/pkg/services/m365/m365.go @@ -312,86 +312,6 @@ func SitesMap( return idname.NewCache(itn), nil } -// --------------------------------------------------------------------------- -// Teams -// --------------------------------------------------------------------------- - -// Team is the minimal information required to identify and display a M365 Team. -type Team struct { - ID string - - // DisplayName is the human-readable name of the team. Normally the plaintext name that the - // user provided when they created the team or the updated name if it was changed. - // Ex: displayName: "Testing Team" - DisplayName string -} - -// TeamsCompat returns a list of teams in the specified M365 tenant. -func TeamsCompat(ctx context.Context, acct account.Account) ([]*Team, error) { - errs := fault.New(true) - - us, err := Teams(ctx, acct, errs) - if err != nil { - return nil, err - } - - return us, errs.Failure() -} - -// Teams returns a list of teams in the specified M365 tenant -func Teams(ctx context.Context, acct account.Account, errs *fault.Bus) ([]*Team, error) { - ac, err := makeAC(ctx, acct, path.TeamsService) - if err != nil { - return nil, clues.Stack(err).WithClues(ctx) - } - - return getAllTeams(ctx, ac.Groups()) -} - -// parseUser extracts information from `models.Userable` we care about -func parseTeam(item models.Groupable) (*Team, error) { - if item.GetDisplayName() == nil { - return nil, clues.New("Team missing display name"). - With("Team ID", ptr.Val(item.GetId())) - } - - u := &Team{ - ID: ptr.Val(item.GetId()), - DisplayName: ptr.Val(item.GetDisplayName()), - } - - return u, nil -} - -type getAllGroupers interface { - GetAll(ctx context.Context, filterTeams bool, errs *fault.Bus) ([]models.Groupable, error) -} - -func getAllTeams(ctx context.Context, gas getAllGroupers) ([]*Team, error) { - teams, err := gas.GetAll(ctx, true, fault.New(true)) - // TODO: check this. Label has to be changed - if err != nil { - if clues.HasLabel(err, graph.LabelsNoSharePointLicense) { - return nil, clues.Stack(graph.ErrServiceNotEnabled, err) - } - - return nil, clues.Wrap(err, "retrieving teams") - } - - ret := make([]*Team, 0, len(teams)) - - for _, team := range teams { - t, err := parseTeam(team) - if err != nil { - return nil, clues.Wrap(err, "parsing teams") - } - - ret = append(ret, t) - } - - return ret, nil -} - // --------------------------------------------------------------------------- // helpers // ---------------------------------------------------------------------------