public SingleResult <IdentityApiConnector> Create([FromBody] IdentityApiConnector ev) { if (ev == null) { throw new Exception("NULL"); } if (!string.IsNullOrEmpty(ev.Id)) { throw new Exception("Id should not be supplied. It is auto-generated."); } ev.Id = Guid.NewGuid().ToString(); if (ev.AuthenticationConfiguration == null) { throw new Exception("AuthenticationConfiguration should be supplied."); } if (ev.AuthenticationConfiguration is Pkcs12Certificate) { ev.AuthenticationConfiguration = new ClientCertificateAuthentication() { CertificateList = new List <Pkcs12CertificateInformation>() { new Pkcs12CertificateInformation() { IsActive = true, NotBefore = DateTime.UtcNow.Ticks, NotAfter = DateTime.UtcNow.AddYears(1).Ticks, Thumbprint = "AB124FED553321EBC334AB124FED553321EBC334" } } }; } else if (ev.AuthenticationConfiguration is ClientCertificateAuthentication) { throw new Exception("AuthenticationConfiguration cannot be ClientCertificateAuthentication."); } apis.Add(ev); return(SingleResult.Create(new[] { ev }.AsQueryable())); }
/// <summary> /// Create new navigation property to apiConnectors for identity /// <param name="body"></param> /// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param> /// </summary> public RequestInformation CreatePostRequestInformation(IdentityApiConnector body, Action <ApiConnectorsRequestBuilderPostRequestConfiguration> requestConfiguration = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.POST, UrlTemplate = UrlTemplate, PathParameters = PathParameters, }; requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); if (requestConfiguration != null) { var requestConfig = new ApiConnectorsRequestBuilderPostRequestConfiguration(); requestConfiguration.Invoke(requestConfig); requestInfo.AddRequestOptions(requestConfig.Options); requestInfo.AddHeaders(requestConfig.Headers); } return(requestInfo); }