Esempio n. 1
0
        /// <summary>
        /// Update predefined group rule.
        /// </summary>
        /// <param name="groupId">The group id.</param>
        /// <param name="allowedAction">The rule action of the group.</param>
        /// <param name="ruleUpdateRequest">The new predefined rule for the group.</param>
        /// <param name="callback">Returns a Result that contains GroupInformation via callback when completed</param>
        public void UpdateGroupPredefinedRule(string groupId, AllowedAction allowedAction, UpdateGroupPredefinedRuleRequest ruleUpdateRequest, ResultCallback <GroupInformation> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(groupId, "Can't update group predefined rule! GroupId parameter is null!");
            Assert.AreNotEqual(AllowedAction.None, allowedAction, "Can't update group predefined rule! allowedAction parameter is null!");

            if (!this.session.IsValid())
            {
                callback.TryError(ErrorCode.IsNotLoggedIn);

                return;
            }

            this.coroutineRunner.Run(
                this.api.UpdateGroupPredefinedRule(this.@namespace, this.session.AuthorizationToken, groupId, allowedAction, ruleUpdateRequest, callback));
        }
Esempio n. 2
0
        public IEnumerator UpdateGroupPredefinedRule(string namespace_, string accessToken, string groupId, AllowedAction allowedAction, UpdateGroupPredefinedRuleRequest ruleUpdateRequest,
                                                     ResultCallback <GroupInformation> callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsFalse(string.IsNullOrEmpty(namespace_), "Can't update group predefined rule! Namespace parameter is null!");
            Assert.IsFalse(string.IsNullOrEmpty(accessToken), "Can't update group predefined rule! AccessToken parameter is null!");
            Assert.IsFalse(string.IsNullOrEmpty(groupId), "Can't update group predefined rule! GroupId parameter is null!");
            Assert.AreNotEqual(AllowedAction.None, allowedAction, "Can't update group predefined rule! allowedAction parameter is null!");

            var request = HttpRequestBuilder
                          .CreatePut(this.baseUrl + "/v1/public/namespaces/{namespace}/groups/{groupId}/rules/defined/{allowedAction}")
                          .WithPathParam("namespace", namespace_)
                          .WithPathParam("groupId", groupId)
                          .WithPathParam("allowedAction", allowedAction.ToString())
                          .WithBearerAuth(accessToken)
                          .WithContentType(MediaType.ApplicationJson)
                          .WithBody(ruleUpdateRequest.ToUtf8Json())
                          .Accepts(MediaType.ApplicationJson)
                          .GetResult();

            IHttpResponse response = null;

            yield return(this.httpClient.SendRequest(request, rsp => response = rsp));

            var result = response.TryParseJson <GroupInformation>();

            callback.Try(result);
        }