Beispiel #1
0
        public void TestCreateUserGroupParamsCheck()
        {
            var parameters = new CreateUserGroupParams(TestName);

            parameters.Name = string.Empty;
            AssertCheck(parameters, "Name must not be empty");
        }
Beispiel #2
0
        public void TestCreateUserGroupParamsDictionary()
        {
            var parameters = new CreateUserGroupParams(TestName);

            Assert.DoesNotThrow(() => parameters.Check());

            var dictionary = parameters.ToParamsDictionary();

            Assert.AreEqual(TestName, dictionary["name"]);
        }
        public void Initialize()
        {
            AccountProvisioning = new AccountProvisioning();

            if (AccountProvisioning.ProvisioningApi.ProvisioningApiAccount.AccountId == null)
            {
                Assert.Ignore("Provisioning API is not configured, skipping tests.");
            }

            // Create a sub account(sub cloud)
            m_timestampSuffix = Utils.UnixTimeNowSeconds();
            var subAccountName         = $"jutaname{m_timestampSuffix}";
            var createSubAccountParams = new CreateSubAccountParams(subAccountName)
            {
                CloudName = subAccountName
            };
            var createSubAccountResult = AccountProvisioning.CreateSubAccountAsync(createSubAccountParams)
                                         .GetAwaiter().GetResult();

            Assert.AreEqual(HttpStatusCode.OK, createSubAccountResult.StatusCode);

            m_cloudId = createSubAccountResult.Id;

            // Create users
            m_userName1  = $"SDK TEST {m_timestampSuffix}";
            m_userEmail1 = $"sdk-test+{m_timestampSuffix}@cloudinary.com";
            m_userId1    = CreateUser(m_userName1, m_userEmail1);

            m_userName2  = $"SDK TEST 2 {m_timestampSuffix}";
            m_userEmail2 = $"sdk-test2+{m_timestampSuffix}@cloudinary.com";
            m_userId2    = CreateUser(m_userName2, m_userEmail2);

            // Create a user group
            var userGroupName         = $"test-group-{m_timestampSuffix}";
            var createUserGroupParams = new CreateUserGroupParams(userGroupName);
            var createUserGroupResult = AccountProvisioning.CreateUserGroupAsync(createUserGroupParams).GetAwaiter().GetResult();

            Assert.AreEqual(HttpStatusCode.OK, createUserGroupResult.StatusCode);

            m_groupId = createUserGroupResult.GroupId;
        }
        /// <summary>
        /// Creates a new user group asynchronously.
        /// </summary>
        /// <param name="parameters">Parameters to create user group.</param>
        /// <param name="cancellationToken">(Optional) Cancellation token.</param>
        /// <returns>Parsed information about created user group.</returns>
        public Task <UserGroupResult> CreateUserGroupAsync(CreateUserGroupParams parameters, CancellationToken?cancellationToken = null)
        {
            var url = GetUserGroupsUrl();

            return(CallAccountApiAsync <UserGroupResult>(HttpMethod.POST, url, cancellationToken, parameters));
        }
        /// <summary>
        /// Creates a new user group.
        /// </summary>
        /// <param name="parameters">Parameters to create user group.</param>
        /// <returns>Parsed information about created user group.</returns>
        public UserGroupResult CreateUserGroup(CreateUserGroupParams parameters)
        {
            var url = GetUserGroupsUrl();

            return(CallAccountApi <UserGroupResult>(HttpMethod.POST, url, parameters));
        }