public void GetEntityRequestObject() { moq::Mock <MetadataService.MetadataServiceClient> mockGrpcClient = new moq::Mock <MetadataService.MetadataServiceClient>(moq::MockBehavior.Strict); GetEntityRequest request = new GetEntityRequest { EntityName = EntityName.FromProjectLocationLakeZoneEntity("[PROJECT]", "[LOCATION]", "[LAKE]", "[ZONE]", "[ENTITY]"), View = GetEntityRequest.Types.EntityView.Basic, }; Entity expectedResponse = new Entity { EntityName = EntityName.FromProjectLocationLakeZoneEntity("[PROJECT]", "[LOCATION]", "[LAKE]", "[ZONE]", "[ENTITY]"), DisplayName = "display_name137f65c2", Description = "description2cf9da67", CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Id = "id74b70bb8", Etag = "etage8ad7218", Type = Entity.Types.Type.Unspecified, Asset = "assetd4344ec0", DataPath = "data_path6b0d38a8", DataPathPattern = "data_path_pattern534aa82f", CatalogEntry = "catalog_entry0c83a523", System = StorageSystem.CloudStorage, Format = new StorageFormat(), Compatibility = new Entity.Types.CompatibilityStatus(), Schema = new Schema(), }; mockGrpcClient.Setup(x => x.GetEntity(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); MetadataServiceClient client = new MetadataServiceClientImpl(mockGrpcClient.Object, null); Entity response = client.GetEntity(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task <BaseResponse> GetEntity([FromBody] GetEntityRequest request) => await RequestHelpers.GetEntity ( request, repository, mapper );
public override async Task <GetEntityReply> GetTable(GetEntityRequest request, ServerCallContext context) { try { var table = await _databaseService.GetTable(request.DbName, request.TableName); GetEntityReply response = _grpcModelMapper.GetGetEntityReplyFromTableDto(table.table); response.Code = 200; Console.WriteLine(); Console.WriteLine(); Console.WriteLine("***************************************************************************************************************"); Console.WriteLine("Get table: " + request.TableName); Console.WriteLine("***************************************************************************************************************"); return(response); } catch (Exception ex) { return(new GetEntityReply() { Code = 400, Message = ex.Message, StackTrace = ex.StackTrace }); } }
public static async Task <GetEntityResponse> GetEntity(GetEntityRequest request, IContextRepository contextRepository, IMapper mapper) => await(Task <GetEntityResponse>) "GetEntity".GetSelectMethod() .MakeGenericMethod ( Type.GetType(request.ModelType), Type.GetType(request.DataType) ).Invoke(null, new object[] { request, contextRepository, mapper });
protected override void ProcessRecord() { base.ProcessRecord(); GetEntityRequest request; try { request = new GetEntityRequest { CatalogId = CatalogId, DataAssetKey = DataAssetKey, EntityKey = EntityKey, IsIncludeObjectRelationships = IsIncludeObjectRelationships, Fields = Fields, OpcRequestId = OpcRequestId }; HandleOutput(request); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
public async Task <BaseResponse> GetList([FromBody] GetEntityRequest request) => await this.clientFactory.PostAsync <BaseResponse> ( "api/Entity/GetEntity", JsonSerializer.Serialize(request), this.configurationOptions.BaseBslUrl );
public void EntityFindTest() { var name = Guid.NewGuid().ToString(); var add = new EntityAddCommand(); var result = add.EntityAdd(new EntityAdd() { Name = name, Address = new AddressView() { AddressLine1 = "4490 Patterson Street", City = "Houston", StateCounty = "State", PostZipCode = "77063" } }).Result; result.Name.Should().Be(name); result.EntityId.Should().BeGreaterThan(0); var find = new GetEntityRequest(); var result2 = find.GetEntity(new GetEntity() { EntityId = result.EntityId }).Result; result2.Name.Should().Be(name); result2.Address.City.Should().Be("Houston"); result2.EntityId.Should().Be(result.EntityId); }
/// <summary> /// Attempts a forced replace or insert. /// If conflicts are detected, they are dropped, and the local version is again updated. /// Returns null if the method should be invoked again, otherwise the final version retrieved from the DB /// </summary> /// <typeparam name="T">Entity type</typeparam> /// <param name="store">DB to place the entity in</param> /// <param name="item">Entity to place. The _rev member may be updated in the process</param> /// <returns></returns> public static async Task <T> TryForceReplace <T>(DataBase store, T item) where T : Entity { //try { if (store == null) { return(item); //during tests, db is not loaded } var serial = JsonConvert.SerializeObject(item, Newtonsoft.Json.Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); //store.Entities.Serializer.Serialize(item); //JsonConvert.SerializeObject(item); var header = await store.Documents.PutAsync(item._id, serial); //await store.Entities.PutAsync(item._id, item); if (!header.IsSuccess /*&& header.StatusCode == System.Net.HttpStatusCode.Conflict*/) { var head = await store.Documents.HeadAsync(item._id); if (head.IsSuccess) { item._rev = head.Rev; } return(null); } var echoRequest = new GetEntityRequest(header.Id); echoRequest.Conflicts = true; var echo = await store.Documents.GetAsync(header.Id); if (!echo.IsSuccess) { return(null); } if (echo.Conflicts != null && echo.Conflicts.Length > 0) { //we do have conflicts and don't quite know whether the new version is our version var deleteHeaders = new DocumentHeader[echo.Conflicts.Length]; for (int i = 0; i < echo.Conflicts.Length; i++) { deleteHeaders[i] = new DocumentHeader(header.Id, echo.Conflicts[i]); } BulkRequest breq = new BulkRequest().Delete(deleteHeaders); //delete all conflicts await store.Documents.BulkAsync(breq); //ignore result, but wait for it item._rev = echo.Rev; //replace again. we must win return(await TryForceReplace(store, item)); } return(JsonConvert.DeserializeObject <T>(echo.Content)); //all good } //catch (Exception ex) //{ // throw; //} }
public virtual HttpRequest Create(GetEntityRequest request) { var httpRequest = CreateFor<GetEntityRequest>(HttpMethod.Get, GenerateRequestUrl(request.Id, request.Rev)); httpRequest.SetIfMatch(request.Rev); return httpRequest; }
public virtual HttpRequest Create(GetEntityRequest request) { Ensure.That(request, "request").IsNotNull(); return(new HttpRequest(HttpMethod.Get, GenerateRelativeUrl(request)) .SetRequestTypeHeader(request.GetType()) .SetIfMatchHeader(request.Rev)); }
public virtual HttpRequest Create(GetEntityRequest request) { var httpRequest = CreateFor <GetEntityRequest>(HttpMethod.Get, GenerateRequestUrl(request.Id, request.Rev)); httpRequest.SetIfMatch(request.Rev); return(httpRequest); }
public virtual async Task <GetEntityResponse <T> > GetAsync <T>(GetEntityRequest request) where T : class { var httpRequest = CreateHttpRequest(request); using (var res = await SendAsync(httpRequest).ForAwait()) { return(ProcessEntityResponse <T>(request, res)); } }
protected virtual string GenerateRelativeUrl(GetEntityRequest request) { var urlParams = new UrlParams(); urlParams.AddIfNotNullOrWhiteSpace("rev", request.Rev); urlParams.AddIfTrue("conflicts", request.Conflicts); return(string.Format("/{0}{1}", new UrlSegment(request.Id), new QueryString(urlParams))); }
public virtual async Task <GetEntityResponse <T> > GetAsync <T>(GetEntityRequest request) where T : class { var httpRequest = GetHttpRequestFactory.Create(request); using (var res = await SendAsync(httpRequest).ForAwait()) { return(await EntityResponseFactory.CreateAsync <GetEntityResponse <T>, T>(res).ForAwait()); } }
public Task <BaseResponse> GetEntity(GetEntityRequest request, string url = null) => PollyHelpers.ExecutePolicyAsync ( () => this.factory.PostAsync <BaseResponse> ( url ?? "api/Entity/GetEntity", JsonSerializer.Serialize(request), App.BASE_URL ) );
/// <summary> /// Creates a waiter using the provided configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="config">Wait Configuration</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetEntityRequest, GetEntityResponse> ForEntity(GetEntityRequest request, WaiterConfiguration config, params LifecycleState[] targetStates) { var agent = new WaiterAgent <GetEntityRequest, GetEntityResponse>( request, request => client.GetEntity(request), response => targetStates.Contains(response.Entity.LifecycleState.Value), targetStates.Contains(LifecycleState.Deleted) ); return(new Waiter <GetEntityRequest, GetEntityResponse>(config, agent)); }
public virtual async Task <EntityResponse <T> > GetAsync <T>(GetEntityRequest request) where T : class { Ensure.That(request, "request").IsNotNull(); using (var httpRequest = CreateHttpRequest(request)) { using (var res = await SendAsync(httpRequest).ForAwait()) { return(ProcessEntityResponse <T>(request, res)); } } }
public static async Task <GetEntityResponse> GetEntity <TModel, TData>(GetEntityRequest request, IContextRepository contextRepository, IMapper mapper) where TModel : EntityModelBase where TData : BaseData => new GetEntityResponse { Entity = await QueryEntity <TModel, TData> ( contextRepository, mapper.MapToOperator(request.Filter), mapper.MapExpansion(request.SelectExpandDefinition) ), Success = true };
/// <summary>Snippet for GetEntity</summary> public void GetEntityRequestObject() { // Snippet: GetEntity(GetEntityRequest, CallSettings) // Create client MetadataServiceClient metadataServiceClient = MetadataServiceClient.Create(); // Initialize request argument(s) GetEntityRequest request = new GetEntityRequest { EntityName = EntityName.FromProjectLocationLakeZoneEntity("[PROJECT]", "[LOCATION]", "[LAKE]", "[ZONE]", "[ENTITY]"), View = GetEntityRequest.Types.EntityView.Unspecified, }; // Make the request Entity response = metadataServiceClient.GetEntity(request); // End snippet }
public object GetEntity([FromUri] GetEntityRequest request) { // Variables. var result = default(object); var rootId = CoreConstants.System.Root.ToInvariantString(); // Catch all errors. try { // Variables. var id = GuidHelper.GetGuid(request.EntityId); var entity = Entities.Retrieve(id); var partialPath = entity.Path .Select(x => GuidHelper.GetString(x)); var fullPath = new[] { rootId } .Concat(partialPath) .ToArray(); // Set result. result = new { Success = true, Id = GuidHelper.GetString(entity.Id), Path = fullPath, Name = entity.Name, Icon = entity.Icon, Kind = EntityHelper.GetString(entity.Kind), HasChildren = Entities.RetrieveChildren(entity.Id).Any() }; } catch (Exception ex) { // Error. LogHelper.Error <EntitiesController>(GetEntityError, ex); result = new { Success = false, Reason = UnhandledError }; } // Return result. return(result); }
/// <summary>Snippet for GetEntityAsync</summary> public async Task GetEntityRequestObjectAsync() { // Snippet: GetEntityAsync(GetEntityRequest, CallSettings) // Additional: GetEntityAsync(GetEntityRequest, CancellationToken) // Create client MetadataServiceClient metadataServiceClient = await MetadataServiceClient.CreateAsync(); // Initialize request argument(s) GetEntityRequest request = new GetEntityRequest { EntityName = EntityName.FromProjectLocationLakeZoneEntity("[PROJECT]", "[LOCATION]", "[LAKE]", "[ZONE]", "[ENTITY]"), View = GetEntityRequest.Types.EntityView.Unspecified, }; // Make the request Entity response = await metadataServiceClient.GetEntityAsync(request); // End snippet }
private void HandleOutput(GetEntityRequest request) { var waiterConfig = new WaiterConfiguration { MaxAttempts = MaxWaitAttempts, GetNextDelayInSeconds = (_) => WaitIntervalSeconds }; switch (ParameterSetName) { case LifecycleStateParamSet: response = client.Waiters.ForEntity(request, waiterConfig, WaitForLifecycleState).Execute(); break; case Default: response = client.GetEntity(request).GetAwaiter().GetResult(); break; } WriteOutput(response, response.Entity); }
protected virtual HttpRequest CreateHttpRequest(GetEntityRequest request) { return(GetHttpRequestFactory.Create(request)); }
/// <summary> /// Creates a waiter using default wait configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetEntityRequest, GetEntityResponse> ForEntity(GetEntityRequest request, params LifecycleState[] targetStates) { return(this.ForEntity(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates)); }
protected virtual GetEntityResponse <T> ProcessEntityResponse <T>(GetEntityRequest request, HttpResponseMessage response) where T : class { return(EntityResponseFactory.Create <GetEntityResponse <T>, T>(response)); }
public Task <BaseResponse> GetEntity(GetEntityRequest request, string url = null) { return(Task.FromResult <BaseResponse>(new GetEntityResponse { Success = true })); }
public static Task <EntityResponse <T> > PerformAsync <T>(this IMyCouchClient client, GetEntityRequest request) where T : class { return(client.Entities.GetAsync <T>(request)); }