public UnifiedGroupEntity GetGroup(string accessToken, bool includeClassification = false) { UnifiedGroupEntity group = null; if (Group != null) { group = UnifiedGroupsUtility.GetUnifiedGroup(Group.GroupId, accessToken, includeClassification: includeClassification); } else if (!String.IsNullOrEmpty(GroupId)) { group = UnifiedGroupsUtility.GetUnifiedGroup(GroupId, accessToken, includeClassification: includeClassification); } else if (!string.IsNullOrEmpty(DisplayName)) { var groups = UnifiedGroupsUtility.GetUnifiedGroups(accessToken, DisplayName, includeSite: true, includeClassification: includeClassification); if (groups == null || groups.Count == 0) { groups = UnifiedGroupsUtility.GetUnifiedGroups(accessToken, mailNickname: DisplayName, includeSite: true, includeClassification: includeClassification); } if (groups != null && groups.Any()) { group = groups.FirstOrDefault(); } } return(group); }
protected override void ExecuteCmdlet() { UnifiedGroupEntity group = null; List <UnifiedGroupEntity> groups = null; #pragma warning disable 0618 var includeSiteUrl = ParameterSpecified(nameof(ExcludeSiteUrl)) ? !ExcludeSiteUrl.ToBool() : IncludeSiteUrl.ToBool(); #pragma warning restore 0618 if (Identity != null) { group = Identity.GetGroup(AccessToken, includeSite: includeSiteUrl); } else { groups = UnifiedGroupsUtility.GetUnifiedGroups(AccessToken, includeSite: IncludeSiteUrl, includeClassification: IncludeClassification.IsPresent, includeHasTeam: IncludeHasTeam.IsPresent); } if (group != null) { WriteObject(group); } else if (groups != null) { WriteObject(groups, true); } }
protected override void ExecuteCmdlet() { if (MailNickname.Contains(" ")) { throw new ArgumentException("MailNickname cannot contain spaces."); } bool forceCreation; if (!Force) { var candidates = UnifiedGroupsUtility.GetUnifiedGroups(AccessToken, mailNickname: MailNickname, endIndex: 1); // ListUnifiedGroups retrieves groups with starts-with, so need another check var existingGroup = candidates.Any(g => g.MailNickname.Equals(MailNickname, StringComparison.CurrentCultureIgnoreCase)); forceCreation = !existingGroup || ShouldContinue(string.Format(Resources.ForceCreationOfExistingGroup0, MailNickname), Resources.Confirm); } else { forceCreation = true; } if (forceCreation) { var group = UnifiedGroupsUtility.CreateUnifiedGroup( displayName: DisplayName, description: Description, mailNickname: MailNickname, accessToken: AccessToken, owners: Owners, members: Members, groupLogoPath: GroupLogoPath, isPrivate: IsPrivate, createTeam: CreateTeam); WriteObject(group); } }
protected override void ExecuteCmdlet() { UnifiedGroupEntity group = null; List <UnifiedGroupEntity> groups = null; if (Identity != null) { group = Identity.GetGroup(AccessToken); } else { // Retrieve all the groups groups = UnifiedGroupsUtility.GetUnifiedGroups(AccessToken, includeSite: !ExcludeSiteUrl.IsPresent, includeClassification: IncludeClassification.IsPresent, includeHasTeam: IncludeHasTeam.IsPresent); } if (group != null) { WriteObject(group); } else if (groups != null) { WriteObject(groups, true); } }