/// <summary>
        /// 创建委托
        /// </summary>
        public CreateAgencyResponse CreateAgency(CreateAgencyRequest createAgencyRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();
            string      urlPath  = HttpUtils.AddUrlPath("/v3.0/OS-AGENCY/agencies", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", createAgencyRequest);
            SdkResponse response = DoHttpRequest("POST", request);

            return(JsonUtils.DeSerialize <CreateAgencyResponse>(response));
        }
Пример #2
0
        public void ApiV1AgencyByAgencyDeleteWithHttpInfo()
        {
            Configuration        configuration = GetClientConfig();
            AgencyApi            agencyApiTest = new AgencyApi(configuration);
            ApiResponse <Object> responses     = agencyApiTest.ApiV1AgencyByAgencyDeleteWithHttpInfo("int.example");

            Assert.Equal(200, responses.StatusCode);

            CreateAgencyRequest  requestAgency     = new CreateAgencyRequest("int.example", "example");
            ApiResponse <Object> responsesCreation = agencyApiTest.ApiV1AgencyPostWithHttpInfo(requestAgency);

            Assert.Equal(200, responsesCreation.StatusCode);
        }
        private static void CreateAgency(IamClient iamClient)
        {
            var createAgencyRequest = new CreateAgencyRequest()
            {
                Body = new CreateAgencyRequestBody()
                {
                    Agency = new CreateAgencyOption()
                    {
                        Name            = "",
                        Description     = "",
                        TrustDomainId   = "",
                        TrustDomainName = "",
                        Duration        = CreateAgencyOption.DurationEnum.ONEDAY,
                        DomainId        = ""
                    }
                }
            };

            try
            {
                var createAgencyResponse = iamClient.CreateAgency(createAgencyRequest);
                Console.WriteLine(JsonConvert.SerializeObject(createAgencyResponse.Agency));
            }
            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);
            }
        }
Пример #4
0
        /// <summary>
        /// Marks the repository as authoritative for the specified agency.
        /// </summary>
        /// <exception cref="Colectica.RestClientV1.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="request"> (optional)</param>
        /// <returns>Task of ApiResponse</returns>
        public async System.Threading.Tasks.Task <ApiResponse <Object> > ApiV1AgencyPostAsyncWithHttpInfo(CreateAgencyRequest request = null)
        {
            var    localVarPath         = "/api/v1/agency";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json",
                "text/json",
                "application/json-patch+json"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
            };
            String localVarHttpHeaderAccept    = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (request != null && request.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(request); // http body (model) parameter
            }
            else
            {
                localVarPostBody = request; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                       Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                       localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("ApiV1AgencyPost", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }


            return(new ApiResponse <Object>(localVarStatusCode,
                                            localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                            null));
        }
Пример #5
0
 /// <summary>
 /// Marks the repository as authoritative for the specified agency.
 /// </summary>
 /// <exception cref="Colectica.RestClientV1.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="request"> (optional)</param>
 /// <returns>Task of void</returns>
 public async System.Threading.Tasks.Task ApiV1AgencyPostAsync(CreateAgencyRequest request = null)
 {
     await ApiV1AgencyPostAsyncWithHttpInfo(request);
 }
Пример #6
0
 /// <summary>
 /// Marks the repository as authoritative for the specified agency.
 /// </summary>
 /// <exception cref="Colectica.RestClientV1.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="request"> (optional)</param>
 /// <returns></returns>
 public void ApiV1AgencyPost(CreateAgencyRequest request = null)
 {
     ApiV1AgencyPostWithHttpInfo(request);
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='request'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task ApiV1AgencyPostAsync(this IColecticaRepositoryRESTAPI operations, CreateAgencyRequest request = default(CreateAgencyRequest), CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.ApiV1AgencyPostWithHttpMessagesAsync(request, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='request'>
 /// </param>
 public static void ApiV1AgencyPost(this IColecticaRepositoryRESTAPI operations, CreateAgencyRequest request = default(CreateAgencyRequest))
 {
     operations.ApiV1AgencyPostAsync(request).GetAwaiter().GetResult();
 }