many incidents
This commit is contained in:
parent
b093334dce
commit
6719c8f7e3
@ -135,7 +135,7 @@ func (c Users) IsLicenseReconciliationNeeded(ctx context.Context, identifier str
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c Users) AssignedPlans(ctx context.Context, identifier string) (models.Userable, error) {
|
||||
func (c Users) AssignedPlansAndLicenses(ctx context.Context, identifier string) (models.Userable, error) {
|
||||
var (
|
||||
resp models.Userable
|
||||
err error
|
||||
@ -145,7 +145,7 @@ func (c Users) AssignedPlans(ctx context.Context, identifier string) (models.Use
|
||||
QueryParameters: &users.UserItemRequestBuilderGetQueryParameters{},
|
||||
}
|
||||
|
||||
options.QueryParameters.Select = []string{"assignedPlans"}
|
||||
options.QueryParameters.Select = []string{"assignedPlans", "assignedLicenses"}
|
||||
|
||||
resp, err = c.Stable.Client().Users().ByUserId(identifier).Get(ctx, options)
|
||||
|
||||
|
||||
@ -133,7 +133,7 @@ func UserAssignedPlansCount(ctx context.Context, acct account.Account, userID st
|
||||
return 0, clues.Stack(err).WithClues(ctx)
|
||||
}
|
||||
|
||||
us, err := ac.Users().AssignedPlans(ctx, userID)
|
||||
us, err := ac.Users().AssignedPlansAndLicenses(ctx, userID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -145,6 +145,24 @@ func UserAssignedPlansCount(ctx context.Context, acct account.Account, userID st
|
||||
return 0, clues.New("user missing assigned plans")
|
||||
}
|
||||
|
||||
func UserAssignedLicenses(ctx context.Context, acct account.Account, userID string) (int, error) {
|
||||
ac, err := makeAC(ctx, acct, path.UnknownService)
|
||||
if err != nil {
|
||||
return 0, clues.Stack(err).WithClues(ctx)
|
||||
}
|
||||
|
||||
us, err := ac.Users().AssignedPlansAndLicenses(ctx, userID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if us.GetAssignedLicenses() != nil {
|
||||
return len(us.GetAssignedLicenses()), nil
|
||||
}
|
||||
|
||||
return 0, clues.New("user missing assigned licenses")
|
||||
}
|
||||
|
||||
// parseUser extracts information from `models.Userable` we care about
|
||||
func parseUser(item models.Userable) (*UserNoInfo, error) {
|
||||
if item.GetUserPrincipalName() == nil {
|
||||
|
||||
@ -222,8 +222,12 @@ func (suite *userIntegrationSuite) TestUser_GetByID() {
|
||||
assert.NoError(t, err, clues.ToCore(err))
|
||||
plans, err := UserAssignedPlansCount(ctx, acct, s.ID)
|
||||
assert.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
lic, err := UserAssignedLicenses(ctx, acct, s.ID)
|
||||
assert.NoError(t, err, clues.ToCore(err))
|
||||
fmt.Printf("user: %v \n", reconciliationNeeded)
|
||||
fmt.Printf("user: %v \n", plans)
|
||||
fmt.Printf("plans: %v \n", plans)
|
||||
fmt.Printf("lic: %v \n", lic)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user