Exemple #1
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            AddUserToGroupResponse response = new AddUserToGroupResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("AddUserToGroupResult", 2))
                    {
                        UnmarshallResult(context, response);
                        continue;
                    }

                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context);
                    }
                }
            }

            return(response);
        }
        public static AddUserToGroupResponse Unmarshall(UnmarshallerContext context)
        {
            AddUserToGroupResponse addUserToGroupResponse = new AddUserToGroupResponse();

            addUserToGroupResponse.HttpResponse = context.HttpResponse;
            addUserToGroupResponse.RequestId    = context.StringValue("AddUserToGroup.RequestId");

            return(addUserToGroupResponse);
        }
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            AddUserToGroupResponse response = new AddUserToGroupResponse();

            while (context.Read())
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.GetInstance().Unmarshall(context);
                    }
                }
            }


            return(response);
        }
Exemple #4
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, AddUserToGroupResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.ReadAtDepth(originalDepth))
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                }
            }

            return;
        }
        static bool AddUserToGroup(string url, Credentials c, string userId, string groupId)
        {
            Console.WriteLine("Adding user to group...");

            ArticulateOnline ao = new ArticulateOnline {
                Url = url
            };
            AddUserToGroupRequest request = new AddUserToGroupRequest
            {
                Credentials = c,
                UserID      = userId,
                GroupID     = groupId
            };


            AddUserToGroupResponse response = ao.AddUserToGroup(request);

            Console.WriteLine("Error: " + response.ErrorMessage);
            return(response.Success);
        }
        private static async Task UserAndGroupOps(IdentityClient client, string compartmentId)
        {
            // create a test user
            CreateUserDetails createUserDetails = new CreateUserDetails
            {
                CompartmentId = compartmentId,
                Name          = userName,
                Description   = "testing oci sdk for .NET"
            };
            CreateUserRequest createUserRequest = new CreateUserRequest {
                CreateUserDetails = createUserDetails
            };
            CreateUserResponse createUserResponse = await client.CreateUser(createUserRequest);

            User user = createUserResponse.User;

            logger.Info($"user created, Name : {user.Name} , ID : {user.Id}");

            // create a test group
            CreateGroupDetails createGroupDetails = new CreateGroupDetails
            {
                CompartmentId = compartmentId,
                Name          = "oci-dotnetsdk-testgroup",
                Description   = "testing oci sdk for .NET"
            };
            CreateGroupRequest createGroupRequest = new CreateGroupRequest
            {
                CreateGroupDetails = createGroupDetails
            };
            CreateGroupResponse createGroupResponse = await client.CreateGroup(createGroupRequest);

            logger.Info($"new group created, Name : {createGroupResponse.Group.Name} , Id : {createGroupResponse.Group.Id}");
            Group group = createGroupResponse.Group;

            // add the user to the group
            logger.Info("Adding new user to the new group");
            AddUserToGroupDetails addUserToGroupDetails = new AddUserToGroupDetails
            {
                UserId  = user.Id,
                GroupId = group.Id
            };

            AddUserToGroupRequest addUserToGroupRequest = new AddUserToGroupRequest {
                AddUserToGroupDetails = addUserToGroupDetails
            };
            AddUserToGroupResponse addUserToGroupResponse = await client.AddUserToGroup(addUserToGroupRequest);

            logger.Info($"Added user: {user.Name} to the group: {group.Name}");

            // remove user from the group
            logger.Info($"removing user: {user.Name} from the group: {group.Name}");
            RemoveUserFromGroupRequest removeUserFromGroupRequest = new RemoveUserFromGroupRequest
            {
                UserGroupMembershipId = addUserToGroupResponse.UserGroupMembership.Id
            };
            await client.RemoveUserFromGroup(removeUserFromGroupRequest);

            // delete the user
            logger.Info($"deleting the user: {user.Name}");
            DeleteUserRequest deleteUserRequest = new DeleteUserRequest {
                UserId = user.Id
            };
            await client.DeleteUser(deleteUserRequest);

            // delete the group
            logger.Info($"deleting the group: {group.Name}");
            DeleteGroupRequest deleteGroupRequest = new DeleteGroupRequest {
                GroupId = group.Id
            };
            await client.DeleteGroup(deleteGroupRequest);

            logger.Info("Finished delete user and group");
        }