public TestOutcome CreateRequest() { TestOutcome outcome = new TestOutcome(); outcome.moduleName = "Request"; outcome.methodName = "RequestCreateJob"; try { RequestsApi requestsApi = new RequestsApi(_url); Request request = RequestGenerator.GetSimpleRequest(); JobReport job = requestsApi.RequestCreateJob(_session.SessionId, "all", request); JobReport polledJob = JobHandler.pollJob(job, _session.SessionId, _url); if (polledJob.ErrorMessage != null) { outcome.outcome = polledJob.ErrorMessage; } else { outcome.outcome = "Success"; } return(outcome); } catch (Exception ex) { outcome.outcome = ex.Message; return(outcome); } }
public override void Run() { try { var siteUrl = "https://xxxx.sharepoint.com/sites/CreateSiteCollectionaaa"; var apiInstance = new RequestsApi(Configuration.Default); var lockSiteRequest = new LockSiteRequest { Summary = "lock site", ServiceId = new Guid("906d41ea-b79d-4541-97b7-df107a2dba7b"), Action = SiteLifecycleActionType.Lock, Department = "IT", SiteUrl = siteUrl, SiteId = new Guid("c3c8d93d-10d7-4a0b-98b1-37fd604711a9"), LockType = SiteLockType.ReadOnly, Metadatas = this.GetSampleMetadatas() }; // submit lock site request Guid result = apiInstance.SubmitLockSiteRequest(lockSiteRequest); Console.WriteLine(result); } catch (ApiException e) { Console.WriteLine("Exception when calling RequestsApi.SubmitLockSiteRequest: " + e.Message); Console.WriteLine("Status Code: " + e.ErrorCode); Console.WriteLine(e.StackTrace); } }
public override void Run() { try { var request = new CreateSiteRequest(); var apiInstance = new RequestsApi(Configuration.Default); request.ServiceId = new Guid("3844cf31-4b27-4636-9a15-5548e0eaa906"); request.Department = "IT"; string siteName = $"{DateTime.Now.ToString("yyyyMMddHHmmss")}"; request.Summary = siteName + " Summary"; request.SiteTitle = siteName + " Title"; request.SiteUrl = new SiteUrl() { Root = "https://xxxxx.sharepoint.com", Name = siteName, ManagedPath = "/sites/" }; request.PolicyId = new Guid("ac758b7f-6079-4fd0-8250-48490a5a34a6"); request.TimeZone = 21; request.Language = 1033; request.Template = "STS#3#Team site (no Office 365 group)#Collaboration"; request.PrimaryAdmin = new ApiUser() { LoginName = "*****@*****.**", DisplayName = "PrimaryAdmin" }; request.PrimaryContact = new ApiUser() { LoginName = "*****@*****.**", DisplayName = "PrimaryContact" }; request.SecondaryContact = new ApiUser() { LoginName = "*****@*****.**", DisplayName = "SecondaryContact" }; request.HubSiteSettings = new HubSiteSettings(); request.UserPermissions = new List <RequestUserWithPermissions>(); request.GroupPermissions = new List <RequestGroupWithPermissions>(); request.Metadatas = this.GetSampleMetadatas(); var result = apiInstance.SubmitCreateSiteRequest(request); Console.WriteLine(result); } catch (ApiException e) { Console.WriteLine("Exception when calling RequestsApi.SubmitCreateSiteRequest: " + e.Message); Console.WriteLine("Status Code: " + e.ErrorCode); Console.WriteLine(e.StackTrace); } }
public override void Run() { try { var request = new ManagePermissionRequest(); var apiInstance = new RequestsApi(Configuration.Default); request.ServiceId = new Guid("8a578313-3098-4845-b04c-3f6ebaf9b489"); request.Department = "IT"; request.Summary = "MP Summary" + $"{DateTime.Now.ToString("yyyyMMddHHmmss")}"; request.ObjectUrl = "https://xxxx.sharepoint.com/sites/xxx"; request.SpGroupManagement = new List <SPGroupManagementModel>(); var permissionModel = new PermissionManagementModel(); permissionModel.PermissionItems = new List <ObjectPermissionManagementModel>(); var permissionModelItem = new ObjectPermissionManagementModel(); permissionModelItem.ObjectInfo = new ApiUser() { LoginName = "*****@*****.**", DisplayName = "Admin" }; permissionModelItem.ObjectType = SPPrincipalType.User; permissionModelItem.Action = ManagePermissionAction.Added; permissionModelItem.GrantPermissionSetting = new GrantPermissionModel() { PermissionDurationSettings = new TemporaryPermissionRequestSetting() { IsGrantTemporaryPermission = false } }; permissionModelItem.Permissions = new List <string>() { "Design" }; permissionModel.PermissionItems.Add(permissionModelItem); permissionModel.IsUniquePermission = true; request.PermissionManagement = permissionModel; request.Metadatas = new List <RequestMetadata>(); var result = apiInstance.SubmitManagePermimssionRequest(request); } catch (ApiException e) { Console.WriteLine("Exception when calling RequestsApi.SubmitCreateSiteRequest: " + e.Message); Console.WriteLine("Status Code: " + e.ErrorCode); Console.WriteLine(e.StackTrace); } }
public TestOutcome SearchRequests(string filterstring) { TestOutcome outcome = new TestOutcome(); outcome.moduleName = "Request"; outcome.methodName = "RequestsSearch"; try { RequestsApi requestsApi = new RequestsApi(_url); NamedArray requests = requestsApi.RequestsSearch(_session.SessionId, "all", FilterGenerator.SimpleFilter("name", "like", filterstring + "%"), 100); foreach (Named request in requests) { Console.WriteLine(request.Name); } outcome.outcome = "Success"; return(outcome); } catch (Exception ex) { outcome.outcome = ex.Message; return(outcome); } }
public TestOutcome GetRequestByName(string name) { TestOutcome outcome = new TestOutcome(); outcome.moduleName = "Request"; outcome.methodName = "RequestFind"; try { RequestsApi reqApi = new RequestsApi(_url); Request request = reqApi.RequestFind(_session.SessionId, name); foreach (QueueItem qi in request.QueueItems) { Console.WriteLine(qi.Id); } outcome.outcome = "Success"; return(outcome); } catch (Exception ex) { outcome.outcome = ex.Message; return(outcome); } }
public Guid Run() { try { var apiInstance = new RequestsApi(Configuration.Default); var settingsApi = new SettingsApi(Configuration.Default); var request = new CreateGroupRequest(); //replace the servcie name with your real service name var serviceName = "service name"; var service = this.GetCreateGroupService(serviceName); request.ServiceId = service.Id; request.EnableDynamicMembership = true; var dynamicMembershipRuleItems = settingsApi.GetDynamicMembershipRuleItems(service.TenantId); //get first contact property, you can also find contact property by property name var contactMetadataId = dynamicMembershipRuleItems.Contact[0].Id; var contactMetadataName = dynamicMembershipRuleItems.Contact[0].Name; //get first organization property, you can also find organization property by property name var organizationMetadataId = dynamicMembershipRuleItems.Organization[0].Id; var organizationMetadataName = dynamicMembershipRuleItems.Organization[0].Name; //get first license property, you can also find license property by property name var licenseMetadataId = dynamicMembershipRuleItems.License[0].Id; var licenseMetadataName = dynamicMembershipRuleItems.License[0].Name; //get first license property value, you can also find license property value by property name var licenseMetadataValue = dynamicMembershipRuleItems.License[0].ChoiceItems[0].Id; var licenseMetadataDisplayValue = dynamicMembershipRuleItems.License[0].ChoiceItems[0].Name; //replace the user login name with real user login name var primaryContactLoginName = "*****@*****.**"; var secondaryContactLoginName = "*****@*****.**"; var usersApi = new UsersApi(Configuration.Default); var primaryContactUser = usersApi.ResolveUsers(primaryContactLoginName, UserType.User, UserSource.Azure, ExternalSharingOptions.Disabled).FirstOrDefault(); request.PrimaryContact = primaryContactUser; var secondaryContactUser = usersApi.ResolveUsers(secondaryContactLoginName, UserType.User, UserSource.Azure, ExternalSharingOptions.Disabled).FirstOrDefault(); request.SecondaryContact = secondaryContactUser; request.DynamicMembershipRules = new List <DynamicGroupRuleInfo> { new DynamicGroupRuleInfo { Id = Guid.NewGuid(), Order = 0, Relation = LogicalOperator.Or, Category = CategoryType.Contact, MetadataId = contactMetadataId, MetadataName = contactMetadataName, MetadataValue = "user display name", //replace with real user display name MetadataDisplayValue = "user display name", //replace with real user display name Condition = DynamicRuleCondition.Equals }, new DynamicGroupRuleInfo { Id = Guid.NewGuid(), Order = 1, Relation = LogicalOperator.Or, Category = CategoryType.Organization, MetadataId = organizationMetadataId, MetadataName = organizationMetadataName, MetadataValue = "user login name", //replace with real user login name MetadataDisplayValue = "user display name", //replace with real user display name Condition = DynamicRuleCondition.Is }, new DynamicGroupRuleInfo { Id = Guid.NewGuid(), Order = 2, Relation = LogicalOperator.Or, Category = CategoryType.License, MetadataId = licenseMetadataId, MetadataName = licenseMetadataName, MetadataValue = licenseMetadataValue, MetadataDisplayValue = licenseMetadataDisplayValue, Condition = DynamicRuleCondition.Equals }, }; request.GroupName = "XXX"; //replace with real group/team name request.GroupId = "XXX"; //replace with real group/team name var result = apiInstance.SubmitCreateGroupRequest(request); Console.WriteLine(result); return(result); } catch (ApiException e) { Console.WriteLine("Exception when calling RequestsApi.SubmitCreateGroupRequest: " + e.Message); Console.WriteLine("Status Code: " + e.ErrorCode); Console.WriteLine(e.StackTrace); } return(Guid.Empty); }