コード例 #1
0
    public Endpoint CreateEndpoint(
        string projectId   = "my-project",
        string locationId  = "us-east1",
        string namespaceId = "test-namespace",
        string serviceId   = "test-service",
        string endpointId  = "test-endpoint")
    {
        RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.Create();
        var serviceName = ServiceName.FromProjectLocationNamespaceService(projectId, locationId, namespaceId, serviceId);

        return(registrationServiceClient.CreateEndpoint(serviceName, new Endpoint(), endpointId));
    }
コード例 #2
0
    public void DeleteService(
        string projectId   = "my-project",
        string locationId  = "us-east1",
        string namespaceId = "test-namespace",
        string serviceId   = "test-service")
    {
        // Create client
        RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.Create();
        // Initialize request argument(s)
        var serviceName = ServiceName.FromProjectLocationNamespaceService(projectId, locationId, namespaceId, serviceId);

        registrationServiceClient.DeleteService(serviceName);
    }
コード例 #3
0
 /// <summary>Snippet for ResolveService</summary>
 public void ResolveServiceRequestObject()
 {
     // Snippet: ResolveService(ResolveServiceRequest, CallSettings)
     // Create client
     LookupServiceClient lookupServiceClient = LookupServiceClient.Create();
     // Initialize request argument(s)
     ResolveServiceRequest request = new ResolveServiceRequest
     {
         ServiceName    = ServiceName.FromProjectLocationNamespaceService("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"),
         MaxEndpoints   = 0,
         EndpointFilter = "",
     };
     // Make the request
     ResolveServiceResponse response = lookupServiceClient.ResolveService(request);
     // End snippet
 }
コード例 #4
0
    public Service ResolveService(
        string projectId   = "my-project",
        string locationId  = "us-east1",
        string namespaceId = "test-namespace",
        string serviceId   = "test-service")
    {
        // Create client
        LookupServiceClient lookupServiceClient = LookupServiceClient.Create();
        // Initialize request argument(s)
        ResolveServiceRequest request = new ResolveServiceRequest
        {
            ServiceName = ServiceName.FromProjectLocationNamespaceService(projectId, locationId, namespaceId, serviceId),
        };
        // Make the request
        ResolveServiceResponse response = lookupServiceClient.ResolveService(request);

        return(response.Service);
    }
コード例 #5
0
        /// <summary>Snippet for ResolveServiceAsync</summary>
        public async Task ResolveServiceRequestObjectAsync()
        {
            // Snippet: ResolveServiceAsync(ResolveServiceRequest, CallSettings)
            // Additional: ResolveServiceAsync(ResolveServiceRequest, CancellationToken)
            // Create client
            LookupServiceClient lookupServiceClient = await LookupServiceClient.CreateAsync();

            // Initialize request argument(s)
            ResolveServiceRequest request = new ResolveServiceRequest
            {
                ServiceName    = ServiceName.FromProjectLocationNamespaceService("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"),
                MaxEndpoints   = 0,
                EndpointFilter = "",
            };
            // Make the request
            ResolveServiceResponse response = await lookupServiceClient.ResolveServiceAsync(request);

            // End snippet
        }
コード例 #6
0
    public void CreatesService()
    {
        // Setup namespace for the test.
        var namespaceId = _fixture.RandomResourceId;

        _fixture.CreateNamespace(namespaceId);

        var serviceId = _fixture.RandomResourceId;
        // Run the sample code.
        var createServiceSample = new CreateServiceSample();
        var result = createServiceSample.CreateService(_fixture.ProjectId, _fixture.LocationId, namespaceId, serviceId);

        // Get the service.
        var serviceName = ServiceName.FromProjectLocationNamespaceService(_fixture.ProjectId, _fixture.LocationId, namespaceId, serviceId);
        RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.Create();
        var service = registrationServiceClient.GetService(serviceName);

        Assert.Contains(serviceId, service.Name);
    }
コード例 #7
0
    public void DeletesService()
    {
        // Setup namespace and service for the test.
        var namespaceId = _fixture.RandomResourceId;
        var serviceId   = _fixture.RandomResourceId;

        _fixture.CreateNamespace(namespaceId);
        _fixture.CreateService(namespaceId, serviceId);
        // Run the sample code.
        var deleteServiceSample = new DeleteServiceSample();

        deleteServiceSample.DeleteService(_fixture.ProjectId, _fixture.LocationId, namespaceId, serviceId);

        // Try to get the service.
        RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.Create();
        var serviceName = ServiceName.FromProjectLocationNamespaceService(_fixture.ProjectId, _fixture.LocationId, namespaceId, serviceId);
        var exception   = Assert.Throws <RpcException>(() => registrationServiceClient.GetService(serviceName));

        Assert.Equal(StatusCode.NotFound, exception.StatusCode);
    }
コード例 #8
0
        public void ResolveServiceRequestObject()
        {
            moq::Mock <LookupService.LookupServiceClient> mockGrpcClient = new moq::Mock <LookupService.LookupServiceClient>(moq::MockBehavior.Strict);
            ResolveServiceRequest request = new ResolveServiceRequest
            {
                ServiceName    = ServiceName.FromProjectLocationNamespaceService("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"),
                MaxEndpoints   = 1499755084,
                EndpointFilter = "endpoint_filter76fda152",
            };
            ResolveServiceResponse expectedResponse = new ResolveServiceResponse
            {
                Service = new Service(),
            };

            mockGrpcClient.Setup(x => x.ResolveService(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            LookupServiceClient    client   = new LookupServiceClientImpl(mockGrpcClient.Object, null);
            ResolveServiceResponse response = client.ResolveService(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #9
0
        public async stt::Task ResolveServiceRequestObjectAsync()
        {
            moq::Mock <LookupService.LookupServiceClient> mockGrpcClient = new moq::Mock <LookupService.LookupServiceClient>(moq::MockBehavior.Strict);
            ResolveServiceRequest request = new ResolveServiceRequest
            {
                ServiceName    = ServiceName.FromProjectLocationNamespaceService("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"),
                MaxEndpoints   = 1499755084,
                EndpointFilter = "endpoint_filter76fda152",
            };
            ResolveServiceResponse expectedResponse = new ResolveServiceResponse
            {
                Service = new Service(),
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }