public void GetIndexRequestObject()
        {
            moq::Mock <DatastoreAdmin.DatastoreAdminClient> mockGrpcClient = new moq::Mock <DatastoreAdmin.DatastoreAdminClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetIndexRequest request = new GetIndexRequest
            {
                ProjectId = "project_id43ad98b0",
                IndexId   = "index_id3caa18b6",
            };
            Index expectedResponse = new Index
            {
                ProjectId  = "project_id43ad98b0",
                IndexId    = "index_id3caa18b6",
                Kind       = "kindf7aa39d9",
                Ancestor   = Index.Types.AncestorMode.None,
                Properties =
                {
                    new Index.Types.IndexedProperty(),
                },
                State = Index.Types.State.Deleting,
            };

            mockGrpcClient.Setup(x => x.GetIndex(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            DatastoreAdminClient client = new DatastoreAdminClientImpl(mockGrpcClient.Object, null);
            Index response = client.GetIndex(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task GetIndexRequestObjectAsync()
        {
            moq::Mock <DatastoreAdmin.DatastoreAdminClient> mockGrpcClient = new moq::Mock <DatastoreAdmin.DatastoreAdminClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetIndexRequest request = new GetIndexRequest
            {
                ProjectId = "project_id43ad98b0",
                IndexId   = "index_id3caa18b6",
            };
            Index expectedResponse = new Index
            {
                ProjectId  = "project_id43ad98b0",
                IndexId    = "index_id3caa18b6",
                Kind       = "kindf7aa39d9",
                Ancestor   = Index.Types.AncestorMode.None,
                Properties =
                {
                    new Index.Types.IndexedProperty(),
                },
                State = Index.Types.State.Deleting,
            };

            mockGrpcClient.Setup(x => x.GetIndexAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Index>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            DatastoreAdminClient client = new DatastoreAdminClientImpl(mockGrpcClient.Object, null);
            Index responseCallSettings  = await client.GetIndexAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Index responseCancellationToken = await client.GetIndexAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
예제 #3
0
 /// <summary>
 /// Gets an index.
 /// </summary>
 /// <param name="request">
 /// The request object containing all of the parameters for the API call.
 /// </param>
 /// <param name="callSettings">
 /// If not null, applies overrides to this RPC call.
 /// </param>
 /// <returns>
 /// A Task containing the RPC response.
 /// </returns>
 public override Task <Index> GetIndexAsync(
     GetIndexRequest request,
     CallSettings callSettings = null)
 {
     Modify_GetIndexRequest(ref request, ref callSettings);
     return(_callGetIndex.Async(request, callSettings));
 }
예제 #4
0
    public Index GetIndex(
        string projectId = "your-project-id",
        string indexId   = "your-index-id")
    {
        // Create client
        DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.Create();

        // Initialize request argument(s)
        GetIndexRequest getIndexRequest = new GetIndexRequest
        {
            ProjectId = projectId,
            IndexId   = indexId
        };

        Index index = datastoreAdminClient.GetIndex(getIndexRequest);

        Console.WriteLine($"Index Id: {index.IndexId}");
        Console.WriteLine($"Kind: {index.Kind}");
        Console.WriteLine("Properties:");
        foreach (var property in index.Properties)
        {
            Console.WriteLine($"Property: {property.Name}");
            Console.WriteLine($"Direction: {property.Direction}");
        }
        return(index);
    }
예제 #5
0
 /// <summary>
 /// Gets an index.
 /// </summary>
 /// <param name="request">
 /// The request object containing all of the parameters for the API call.
 /// </param>
 /// <param name="callSettings">
 /// If not null, applies overrides to this RPC call.
 /// </param>
 /// <returns>
 /// The RPC response.
 /// </returns>
 public override Index GetIndex(
     GetIndexRequest request,
     CallSettings callSettings = null)
 {
     Modify_GetIndexRequest(ref request, ref callSettings);
     return(_callGetIndex.Sync(request, callSettings));
 }
예제 #6
0
        public async stt::Task GetIndexRequestObjectAsync()
        {
            moq::Mock <FirestoreAdmin.FirestoreAdminClient> mockGrpcClient = new moq::Mock <FirestoreAdmin.FirestoreAdminClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetIndexRequest request = new GetIndexRequest
            {
                IndexName = IndexName.FromProjectDatabaseCollectionIndex("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"),
            };
            Index expectedResponse = new Index
            {
                IndexName  = IndexName.FromProjectDatabaseCollectionIndex("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"),
                QueryScope = Index.Types.QueryScope.Unspecified,
                Fields     =
                {
                    new Index.Types.IndexField(),
                },
                State = Index.Types.State.Ready,
            };

            mockGrpcClient.Setup(x => x.GetIndexAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Index>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            FirestoreAdminClient client = new FirestoreAdminClientImpl(mockGrpcClient.Object, null);
            Index responseCallSettings  = await client.GetIndexAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Index responseCancellationToken = await client.GetIndexAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
예제 #7
0
        /// <summary>
        /// Get information about a single index.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public GetIndexResponse GetIndex(GetIndexRequest request)
        {
            var uriStr = $"{GetEndPoint(NoSQLServices.Tables, this.Region)}/{request.TableNameOrId}/{request.IndexName}";

            if (!string.IsNullOrEmpty(request.CompartmentId))
            {
                uriStr = $"{uriStr}?{request.CompartmentId}";
            }

            var uri = new Uri(uriStr);

            var httpRequestHeaderParam = new HttpRequestHeaderParam()
            {
                OpcRequestId = request.OpcRequestId
            };

            using (var webResponse = this.RestClient.Get(uri, httpRequestHeaderParam))
                using (var stream = webResponse.GetResponseStream())
                    using (var reader = new StreamReader(stream))
                    {
                        var response = reader.ReadToEnd();

                        return(new GetIndexResponse()
                        {
                            Index = this.JsonSerializer.Deserialize <IndexDetails>(response),
                            OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                            Etag = webResponse.Headers.Get("opc-request-id")
                        });
                    }
        }
예제 #8
0
        public void GetIndex()
        {
            moq::Mock <FirestoreAdmin.FirestoreAdminClient> mockGrpcClient = new moq::Mock <FirestoreAdmin.FirestoreAdminClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetIndexRequest request = new GetIndexRequest
            {
                IndexName = IndexName.FromProjectDatabaseCollectionIndex("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"),
            };
            Index expectedResponse = new Index
            {
                IndexName  = IndexName.FromProjectDatabaseCollectionIndex("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"),
                QueryScope = Index.Types.QueryScope.Unspecified,
                Fields     =
                {
                    new Index.Types.IndexField(),
                },
                State = Index.Types.State.Ready,
            };

            mockGrpcClient.Setup(x => x.GetIndex(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            FirestoreAdminClient client = new FirestoreAdminClientImpl(mockGrpcClient.Object, null);
            Index response = client.GetIndex(request.Name);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #9
0
		public void ImplicitConversion()
		{
			/**
			* Here we new an GET index elasticsearch request whichs takes Indices and Features.
			* Notice how we can use the Feature enum directly.
			*/
			var request = new GetIndexRequest(All, Feature.Settings);
		}
 public void ImplicitConversion()
 {
     /**
      * Here we new an GET index elasticsearch request whichs takes Indices and Features.
      * Notice how we can the Feature enum directly.
      */
     var request = new GetIndexRequest(All, Feature.Settings | Feature.Warmers);
 }
예제 #11
0
        /// <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 <GetIndexRequest, GetIndexResponse> ForIndex(GetIndexRequest request, WaiterConfiguration config, params Index.LifecycleStateEnum[] targetStates)
        {
            var agent = new WaiterAgent <GetIndexRequest, GetIndexResponse>(
                request,
                request => client.GetIndex(request),
                response => targetStates.Contains(response.Index.LifecycleState.Value),
                targetStates.Contains(Index.LifecycleStateEnum.Deleted)
                );

            return(new Waiter <GetIndexRequest, GetIndexResponse>(config, agent));
        }
예제 #12
0
        public void MapPersonNamePropertyTests()
        {
            //ARRANGE
            var id = Guid.NewGuid();

            var dependencyResolver = new DependencyResolverMock();

            var client        = SearchClientFactory.GetClient();
            var clientFactory = SearchClientFactory.GetClientFactory();

            SearchClientFactory.RegisterDependencies(dependencyResolver);

            //create an unique index
            var indexName       = String.Format("{0}_{1}", typeof(EsPersonSearch).Name, id).ToLower();
            var responseHandler = new ResponseHandler();
            var indexManager    = new IndexManager(dependencyResolver, clientFactory, responseHandler);
            var indexContext    = new IndexContext(typeof(EsPersonSearch), indexName);
            var index           = indexManager.GetIndex(indexContext).Result;

            //ACT

            try
            {
                Thread.Sleep(1000);
                var indexReqiest  = new GetIndexRequest(index);
                var indexResponse = client.GetIndex(indexReqiest);
                var indices       = indexResponse.Indices.ToList();
                var first         = indices.First();

                var mappings = first.Value.Mappings.Select(x => x.Value)
                               .SelectMany(x => x.Properties, (x, y) =>
                {
                    return(new { y.Key, y.Value.Name, y.Value.Type, Properties = ((ObjectProperty)y.Value).Properties });
                });
                var nameProperty      = mappings.First(x => x.Name.Name.Equals("personName", StringComparison.OrdinalIgnoreCase));
                var firstNameProperty = nameProperty.Properties.First(x => x.Key.Name.Equals("firstName", StringComparison.OrdinalIgnoreCase));
                var lastNameProperty  = nameProperty.Properties.First(x => x.Key.Name.Equals("lastName", StringComparison.OrdinalIgnoreCase));

                //ASSERT person name
                Assert.IsTrue(indexResponse.IsValid);
                Assert.AreEqual(1, indices.Count);
                Assert.AreEqual("object", nameProperty.Type.Name);

                //ASSERT person first name
                Assert.AreEqual("keyword", firstNameProperty.Value.Type.Name);

                //ASSERT person last name
                Assert.AreEqual("keyword", lastNameProperty.Value.Type.Name);
            }
            finally
            {
                client.DeleteIndex(index);
            }
        }
 /// <summary>Snippet for GetIndex</summary>
 public void GetIndex_RequestObject()
 {
     // Snippet: GetIndex(GetIndexRequest,CallSettings)
     // Create client
     FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.Create();
     // Initialize request argument(s)
     GetIndexRequest request = new GetIndexRequest
     {
         IndexName = new IndexName("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]"),
     };
     // Make the request
     Index response = firestoreAdminClient.GetIndex(request);
     // End snippet
 }
예제 #14
0
 /// <summary>Snippet for GetIndex</summary>
 public void GetIndexRequestObject()
 {
     // Snippet: GetIndex(GetIndexRequest, CallSettings)
     // Create client
     IndexServiceClient indexServiceClient = IndexServiceClient.Create();
     // Initialize request argument(s)
     GetIndexRequest request = new GetIndexRequest
     {
         IndexName = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"),
     };
     // Make the request
     gcav::Index response = indexServiceClient.GetIndex(request);
     // End snippet
 }
 /// <summary>Snippet for GetIndex</summary>
 public void GetIndexRequestObject()
 {
     // Snippet: GetIndex(GetIndexRequest, CallSettings)
     // Create client
     DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.Create();
     // Initialize request argument(s)
     GetIndexRequest request = new GetIndexRequest
     {
         ProjectId = "",
         IndexId   = "",
     };
     // Make the request
     gcdav::Index response = datastoreAdminClient.GetIndex(request);
     // End snippet
 }
        public async Task GetIndexAsync_RequestObject()
        {
            // Snippet: GetIndexAsync(GetIndexRequest,CallSettings)
            // Create client
            FirestoreAdminClient firestoreAdminClient = await FirestoreAdminClient.CreateAsync();

            // Initialize request argument(s)
            GetIndexRequest request = new GetIndexRequest
            {
                Name = new IndexName("[PROJECT]", "[DATABASE]", "[INDEX]").ToString(),
            };
            // Make the request
            Index response = await firestoreAdminClient.GetIndexAsync(request);

            // End snippet
        }
        /// <summary>Snippet for GetIndexAsync</summary>
        public async Task GetIndexAsync_RequestObject()
        {
            // Snippet: GetIndexAsync(GetIndexRequest,CallSettings)
            // Additional: GetIndexAsync(GetIndexRequest,CancellationToken)
            // Create client
            FirestoreAdminClient firestoreAdminClient = await FirestoreAdminClient.CreateAsync();

            // Initialize request argument(s)
            GetIndexRequest request = new GetIndexRequest
            {
                IndexName = new IndexName("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]"),
            };
            // Make the request
            Index response = await firestoreAdminClient.GetIndexAsync(request);

            // End snippet
        }
예제 #18
0
        /// <summary>Snippet for GetIndexAsync</summary>
        public async Task GetIndexRequestObjectAsync()
        {
            // Snippet: GetIndexAsync(GetIndexRequest, CallSettings)
            // Additional: GetIndexAsync(GetIndexRequest, CancellationToken)
            // Create client
            IndexServiceClient indexServiceClient = await IndexServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetIndexRequest request = new GetIndexRequest
            {
                IndexName = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"),
            };
            // Make the request
            gcav::Index response = await indexServiceClient.GetIndexAsync(request);

            // End snippet
        }
        /// <summary>Snippet for GetIndexAsync</summary>
        public async Task GetIndexRequestObjectAsync()
        {
            // Snippet: GetIndexAsync(GetIndexRequest, CallSettings)
            // Additional: GetIndexAsync(GetIndexRequest, CancellationToken)
            // Create client
            DatastoreAdminClient datastoreAdminClient = await DatastoreAdminClient.CreateAsync();

            // Initialize request argument(s)
            GetIndexRequest request = new GetIndexRequest
            {
                ProjectId = "",
                IndexId   = "",
            };
            // Make the request
            gcdav::Index response = await datastoreAdminClient.GetIndexAsync(request);

            // End snippet
        }
        public async stt::Task GetIndexRequestObjectAsync()
        {
            moq::Mock <IndexService.IndexServiceClient> mockGrpcClient = new moq::Mock <IndexService.IndexServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetIndexRequest request = new GetIndexRequest
            {
                IndexName = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"),
            };
            Index expectedResponse = new Index
            {
                IndexName         = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"),
                DisplayName       = "display_name137f65c2",
                Description       = "description2cf9da67",
                MetadataSchemaUri = "metadata_schema_uric874bf0a",
                Metadata          = new wkt::Value(),
                DeployedIndexes   =
                {
                    new DeployedIndexRef(),
                },
                Etag   = "etage8ad7218",
                Labels =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
            };

            mockGrpcClient.Setup(x => x.GetIndexAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Index>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            IndexServiceClient client  = new IndexServiceClientImpl(mockGrpcClient.Object, null);
            Index responseCallSettings = await client.GetIndexAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Index responseCancellationToken = await client.GetIndexAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
예제 #21
0
        public async Task GetIndexAsync2()
        {
            Mock <FirestoreAdmin.FirestoreAdminClient> mockGrpcClient = new Mock <FirestoreAdmin.FirestoreAdminClient>(MockBehavior.Strict);
            GetIndexRequest request = new GetIndexRequest
            {
                IndexName = new IndexName("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]"),
            };
            Index expectedResponse = new Index
            {
                Name = "name2-1052831874",
            };

            mockGrpcClient.Setup(x => x.GetIndexAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Index>(Task.FromResult(expectedResponse), null, null, null, null));
            FirestoreAdminClient client = new FirestoreAdminClientImpl(mockGrpcClient.Object, null);
            Index response = await client.GetIndexAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #22
0
        public void GetIndex2()
        {
            Mock <FirestoreAdmin.FirestoreAdminClient> mockGrpcClient = new Mock <FirestoreAdmin.FirestoreAdminClient>(MockBehavior.Strict);
            GetIndexRequest request = new GetIndexRequest
            {
                IndexName = new IndexName("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]"),
            };
            Index expectedResponse = new Index
            {
                Name = "name2-1052831874",
            };

            mockGrpcClient.Setup(x => x.GetIndex(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            FirestoreAdminClient client = new FirestoreAdminClientImpl(mockGrpcClient.Object, null);
            Index response = client.GetIndex(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        private void HandleOutput(GetIndexRequest request)
        {
            var waiterConfig = new WaiterConfiguration
            {
                MaxAttempts           = MaxWaitAttempts,
                GetNextDelayInSeconds = (_) => WaitIntervalSeconds
            };

            switch (ParameterSetName)
            {
            case LifecycleStateParamSet:
                response = client.Waiters.ForIndex(request, waiterConfig, WaitForLifecycleState).Execute();
                break;

            case Default:
                response = client.GetIndex(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.Index);
        }
        public void GetIndexResourceNames()
        {
            moq::Mock <IndexService.IndexServiceClient> mockGrpcClient = new moq::Mock <IndexService.IndexServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetIndexRequest request = new GetIndexRequest
            {
                IndexName = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"),
            };
            Index expectedResponse = new Index
            {
                IndexName         = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"),
                DisplayName       = "display_name137f65c2",
                Description       = "description2cf9da67",
                MetadataSchemaUri = "metadata_schema_uric874bf0a",
                Metadata          = new wkt::Value(),
                DeployedIndexes   =
                {
                    new DeployedIndexRef(),
                },
                Etag   = "etage8ad7218",
                Labels =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
            };

            mockGrpcClient.Setup(x => x.GetIndex(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            IndexServiceClient client = new IndexServiceClientImpl(mockGrpcClient.Object, null);
            Index response            = client.GetIndex(request.IndexName);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void DeletIndex_test()
        {
            //ARRANGE
            var id = Guid.NewGuid();

            var dependencyResolver = new DependencyResolverMock();

            var client        = SearchClientFactory.GetClient();
            var clientFactory = SearchClientFactory.GetClientFactory();

            //create an unique index
            var indexName       = String.Format("{0}_{1}", typeof(ParentTestClass).Name, id).ToLower();
            var responseHandler = new ResponseHandler();
            var indexManager    = new IndexManager(dependencyResolver, clientFactory, responseHandler);
            var indexContext    = new IndexContext(typeof(ParentTestClass), indexName);
            var index           = indexManager.BuildIndexName(indexContext);

            //ACT

            try
            {
                client.CreateIndex(index);
                Thread.Sleep(1000);
                var indexReqiest  = new GetIndexRequest(index);
                var indexResponse = client.GetIndex(indexReqiest);

                //delete the index
                indexManager.DeleteIndex(indexContext);

                var indexResponseAfterDelete = client.GetIndex(indexReqiest);
                //ASSERT
                Assert.IsTrue(indexResponse.IsValid);
                Assert.IsFalse(indexResponseAfterDelete.IsValid);
            }
            finally
            {
                client.DeleteIndex(index);
            }
        }
        public void CreateIndex_if_exist_test()
        {
            //ARRANGE
            var id = Guid.NewGuid();

            var dependencyResolver = new DependencyResolverMock();

            var client        = SearchClientFactory.GetClient();
            var clientFactory = SearchClientFactory.GetClientFactory();

            //create an unique index
            var indexName       = String.Format("{0}_{1}", typeof(ParentTestClass).Name, id).ToLower();
            var responseHandler = new ResponseHandler();
            var indexManager    = new IndexManager(dependencyResolver, clientFactory, responseHandler);
            var indexContext    = new IndexContext(typeof(ParentTestClass), indexName);
            var index           = indexManager.BuildIndexName(indexContext);

            //ACT

            try
            {
                indexManager.BuildIndex(index).Wait();
                Thread.Sleep(1000);
                indexManager.BuildIndex(index).Wait();
                var indexReqiest  = new GetIndexRequest(index);
                var indexResponse = client.GetIndex(indexReqiest);
                var indices       = indexResponse.Indices.ToList();
                var first         = indices.First();
                var providedName  = first.Value.Settings["index.provided_name"];
                //ASSERT
                Assert.IsTrue(indexResponse.IsValid);
                Assert.AreEqual(1, indices.Count);
                Assert.AreEqual(indexName, providedName);
            }
            finally
            {
                client.DeleteIndex(index);
            }
        }
예제 #27
0
        public void FSGetIndex()
        {
            FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\n:: Fetch a Specific Index ::\n");
            FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, "\nAvailable Indexes:\n");
            ListIndexes();

            FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, "\nEnter Index Id: ");
            var indexId = Console.ReadLine();

            var getIndexRequest = new GetIndexRequest();

            getIndexRequest.Name = indexId;
            Index retIndex;

            try
            {
                retIndex = FsAdminClient.GetIndex(getIndexRequest);
            }
            catch (Grpc.Core.RpcException e)
            {
                if ((e.Status.StatusCode == Grpc.Core.StatusCode.NotFound) ||
                    (e.Status.StatusCode == Grpc.Core.StatusCode.InvalidArgument))
                {
                    FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Red, "\nERROR: Index " + indexId + " not found!\n");
                }
                else
                {
                    Console.WriteLine("{0} Exception caught.", e);
                }
                return;
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
                return;
            }
            Utils.PrintIndex(retIndex);
            FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\nFinished getting index!\n");
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetIndexRequest request;

            try
            {
                request = new GetIndexRequest
                {
                    TableNameOrId = TableNameOrId,
                    IndexName     = IndexName,
                    CompartmentId = CompartmentId,
                    OpcRequestId  = OpcRequestId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
예제 #29
0
 /// <summary>
 /// Gets an index.
 /// </summary>
 /// <param name="request">
 /// The request object containing all of the parameters for the API call.
 /// </param>
 /// <param name="callSettings">
 /// If not null, applies overrides to this RPC call.
 /// </param>
 /// <returns>
 /// The RPC response.
 /// </returns>
 public virtual Index GetIndex(
     GetIndexRequest request,
     CallSettings callSettings = null)
 {
     throw new NotImplementedException();
 }
예제 #30
0
 /// <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 <GetIndexRequest, GetIndexResponse> ForIndex(GetIndexRequest request, params Index.LifecycleStateEnum[] targetStates)
 {
     return(this.ForIndex(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates));
 }
예제 #31
0
 partial void Modify_GetIndexRequest(ref GetIndexRequest request, ref CallSettings settings);