Ejemplo n.º 1
0
        private static void KeystoneCreateGroup(IamClient iamClient)
        {
            var keystoneCreateGroupRequest = new KeystoneCreateGroupRequest()
            {
                Body = new KeystoneCreateGroupRequestBody()
                {
                    Group = new KeystoneCreateGroupOption()
                    {
                        Description = "",
                        DomainId    = "",
                        Name        = ""
                    }
                }
            };

            try
            {
                var keystoneCreateGroupResponse = iamClient.KeystoneCreateGroup(keystoneCreateGroupRequest);
                Console.WriteLine(JsonConvert.SerializeObject(keystoneCreateGroupResponse.Group));
            }
            catch (RequestTimeoutException requestTimeoutException)
            {
                Console.WriteLine(requestTimeoutException.ErrorMessage);
            }
            catch (ServiceResponseException clientRequestException)
            {
                Console.WriteLine(clientRequestException.HttpStatusCode);
                Console.WriteLine(clientRequestException.ErrorCode);
                Console.WriteLine(clientRequestException.ErrorMsg);
            }
            catch (ConnectionException connectionException)
            {
                Console.WriteLine(connectionException.ErrorMessage);
            }
        }
        /// <summary>
        /// 创建用户组
        /// </summary>
        public KeystoneCreateGroupResponse KeystoneCreateGroup(KeystoneCreateGroupRequest keystoneCreateGroupRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();
            string      urlPath  = HttpUtils.AddUrlPath("/v3/groups", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", keystoneCreateGroupRequest);
            SdkResponse response = DoHttpRequest("POST", request);

            return(JsonUtils.DeSerialize <KeystoneCreateGroupResponse>(response));
        }