protected override void ExecuteCmdlet() { bool forceCreation; if (!Force) { var existingGroup = UnifiedGroupsUtility.ListUnifiedGroups(AccessToken, mailNickname: MailNickname, endIndex: 1).Any(); forceCreation = !existingGroup || ShouldContinue(string.Format(Resources.ForceCreationOfExistingGroup0, MailNickname), Resources.Confirm); } else { forceCreation = true; } if (forceCreation) { var group = UnifiedGroupsUtility.CreateUnifiedGroup( DisplayName, Description, MailNickname, AccessToken, Owners, Members, GroupLogoPath, IsPrivate); WriteObject(group); } }
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.ListUnifiedGroups(accessToken, DisplayName, includeSite: true, includeClassification: includeClassification); if (groups == null || groups.Count == 0) { groups = UnifiedGroupsUtility.ListUnifiedGroups(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; if (Identity != null) { // We have to retrieve a specific group if (Identity.Group != null) { group = UnifiedGroupsUtility.GetUnifiedGroup(Identity.Group.GroupId, AccessToken, includeSite: !ExcludeSiteUrl.IsPresent); } else if (!String.IsNullOrEmpty(Identity.DisplayName)) { groups = UnifiedGroupsUtility.ListUnifiedGroups(AccessToken, Identity.DisplayName, includeSite: !ExcludeSiteUrl.IsPresent); if (groups == null || groups.Count == 0) { groups = UnifiedGroupsUtility.ListUnifiedGroups(AccessToken, mailNickname: Identity.DisplayName, includeSite: !ExcludeSiteUrl.IsPresent); } } else if (!String.IsNullOrEmpty(Identity.GroupId)) { group = UnifiedGroupsUtility.GetUnifiedGroup(Identity.GroupId, AccessToken, includeSite: !ExcludeSiteUrl.IsPresent); } } else { // Retrieve all the groups groups = UnifiedGroupsUtility.ListUnifiedGroups(AccessToken, includeSite: !ExcludeSiteUrl.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.ListUnifiedGroups(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.ListUnifiedGroups(AccessToken, includeSite: !ExcludeSiteUrl.IsPresent, includeClassification: IncludeClassification.IsPresent, includeHasTeam: IncludeHasTeam.IsPresent); } if (group != null) { WriteObject(group); } else if (groups != null) { WriteObject(groups, true); } }
protected override void ExecuteCmdlet() { UnifiedGroupEntity group = null; List <UnifiedGroupEntity> groups = null; if (Identity != null) { // We have to retrieve a specific group if (Identity.Group != null) { group = UnifiedGroupsUtility.GetUnifiedGroup(Identity.Group.GroupId, AccessToken); } else if (!String.IsNullOrEmpty(Identity.DisplayName)) { groups = UnifiedGroupsUtility.ListUnifiedGroups(AccessToken, Identity.DisplayName); } else if (!String.IsNullOrEmpty(Identity.GroupId)) { group = UnifiedGroupsUtility.GetUnifiedGroup(Identity.GroupId, AccessToken); } } else { // Retrieve all the groups groups = UnifiedGroupsUtility.ListUnifiedGroups(AccessToken); } if (group != null) { WriteObject(group); } else if (groups != null) { WriteObject(groups, true); } }