public void CreateClientEvent()
        {
            moq::Mock <EventService.EventServiceClient> mockGrpcClient = new moq::Mock <EventService.EventServiceClient>(moq::MockBehavior.Strict);
            CreateClientEventRequest request = new CreateClientEventRequest
            {
                ParentAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                ClientEvent        = new ClientEvent(),
            };
            ClientEvent expectedResponse = new ClientEvent
            {
                RequestId    = "request_id362c8df6",
                EventId      = "event_idaccf3744",
                CreateTime   = new wkt::Timestamp(),
                JobEvent     = new JobEvent(),
                ProfileEvent = new ProfileEvent(),
                EventNotes   = "event_notes102ba330",
            };

            mockGrpcClient.Setup(x => x.CreateClientEvent(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            EventServiceClient client   = new EventServiceClientImpl(mockGrpcClient.Object, null);
            ClientEvent        response = client.CreateClientEvent(request.Parent, request.ClientEvent);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 2
0
        // [START job_search_create_job_beta]
        public static object CreateJob(string projectId, string tenantId, string companyId, string requisitionId, string jobApplicationUrl)
        {
            JobServiceClient jobServiceClient = JobServiceClient.Create();
            TenantName       tenantName       = TenantName.FromProjectTenant(projectId, tenantId);

            ApplicationInfo applicationInfo = new ApplicationInfo();

            applicationInfo.Uris.Add(jobApplicationUrl);

            Job job = new Job
            {
                Company         = companyId,
                RequisitionId   = requisitionId,
                Title           = "Software Developer",
                Description     = "Develop, maintain the software solutions.",
                ApplicationInfo = applicationInfo,
                LanguageCode    = "en-US"
            };

            string[] addresses = { "1600 Amphitheatre Parkway, Mountain View, CA 94043", "111 8th Avenue, New York, NY 10011" };
            job.Addresses.Add(addresses);

            CreateJobRequest request = new CreateJobRequest
            {
                ParentAsTenantName = tenantName,
                Job = job
            };

            Job response = jobServiceClient.CreateJob(request);

            Console.WriteLine($"Created Job: {response.Name}");
            return(0);
        }
Ejemplo n.º 3
0
        public async stt::Task CompleteQueryRequestObjectAsync()
        {
            moq::Mock <Completion.CompletionClient> mockGrpcClient = new moq::Mock <Completion.CompletionClient>(moq::MockBehavior.Strict);
            CompleteQueryRequest request = new CompleteQueryRequest
            {
                ParentAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                Query         = "queryf0c71c1b",
                LanguageCodes =
                {
                    "language_codes1de1a181",
                },
                PageSize             = -226905851,
                CompanyAsCompanyName = CompanyName.FromProjectTenantCompany("[PROJECT]", "[TENANT]", "[COMPANY]"),
                Scope = CompleteQueryRequest.Types.CompletionScope.Unspecified,
                Type  = CompleteQueryRequest.Types.CompletionType.Combined,
            };
            CompleteQueryResponse expectedResponse = new CompleteQueryResponse
            {
                CompletionResults =
                {
                    new CompleteQueryResponse.Types.CompletionResult(),
                },
                Metadata = new ResponseMetadata(),
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task CreateClientEventRequestObjectAsync()
        {
            moq::Mock <EventService.EventServiceClient> mockGrpcClient = new moq::Mock <EventService.EventServiceClient>(moq::MockBehavior.Strict);
            CreateClientEventRequest request = new CreateClientEventRequest
            {
                ParentAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                ClientEvent        = new ClientEvent(),
            };
            ClientEvent expectedResponse = new ClientEvent
            {
                RequestId    = "request_id362c8df6",
                EventId      = "event_idaccf3744",
                CreateTime   = new wkt::Timestamp(),
                JobEvent     = new JobEvent(),
                ProfileEvent = new ProfileEvent(),
                EventNotes   = "event_notes102ba330",
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task CreateTenantRequestObjectAsync()
        {
            moq::Mock <TenantService.TenantServiceClient> mockGrpcClient = new moq::Mock <TenantService.TenantServiceClient>(moq::MockBehavior.Strict);
            CreateTenantRequest request = new CreateTenantRequest
            {
                ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"),
                Tenant = new Tenant(),
            };
            Tenant expectedResponse = new Tenant
            {
                TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                ExternalId = "external_id9442680e",
                UsageType  = Tenant.Types.DataUsageType.Unspecified,
                KeywordSearchableProfileCustomAttributes =
                {
                    "keyword_searchable_profile_custom_attributes9dbf9d03",
                },
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 6
0
        public void CompleteQueryRequestObject()
        {
            moq::Mock <Completion.CompletionClient> mockGrpcClient = new moq::Mock <Completion.CompletionClient>(moq::MockBehavior.Strict);
            CompleteQueryRequest request = new CompleteQueryRequest
            {
                ParentAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                Query         = "queryf0c71c1b",
                LanguageCodes =
                {
                    "language_codes1de1a181",
                },
                PageSize             = -226905851,
                CompanyAsCompanyName = CompanyName.FromProjectTenantCompany("[PROJECT]", "[TENANT]", "[COMPANY]"),
                Scope = CompleteQueryRequest.Types.CompletionScope.Unspecified,
                Type  = CompleteQueryRequest.Types.CompletionType.Combined,
            };
            CompleteQueryResponse expectedResponse = new CompleteQueryResponse
            {
                CompletionResults =
                {
                    new CompleteQueryResponse.Types.CompletionResult(),
                },
                Metadata = new ResponseMetadata(),
            };

            mockGrpcClient.Setup(x => x.CompleteQuery(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CompletionClient      client   = new CompletionClientImpl(mockGrpcClient.Object, null);
            CompleteQueryResponse response = client.CompleteQuery(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void CreateTenant()
        {
            moq::Mock <TenantService.TenantServiceClient> mockGrpcClient = new moq::Mock <TenantService.TenantServiceClient>(moq::MockBehavior.Strict);
            CreateTenantRequest request = new CreateTenantRequest
            {
                ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"),
                Tenant = new Tenant(),
            };
            Tenant expectedResponse = new Tenant
            {
                TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                ExternalId = "external_id9442680e",
                UsageType  = Tenant.Types.DataUsageType.Unspecified,
                KeywordSearchableProfileCustomAttributes =
                {
                    "keyword_searchable_profile_custom_attributes9dbf9d03",
                },
            };

            mockGrpcClient.Setup(x => x.CreateTenant(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            TenantServiceClient client = new TenantServiceClientImpl(mockGrpcClient.Object, null);
            Tenant response            = client.CreateTenant(request.Parent, request.Tenant);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        // [START job_search_create_company_beta]
        public static object CreateCompany(string projectId, string tenantId, string displayName, string externalId)
        {
            CompanyServiceClient companyServiceClient = CompanyServiceClient.Create();
            TenantName           tenantName           = TenantName.FromProjectTenant(projectId, tenantId);

            Company company = new Company
            {
                DisplayName = displayName,
                ExternalId  = externalId
            };

            CreateCompanyRequest request = new CreateCompanyRequest
            {
                ParentAsTenantName = tenantName,
                Company            = company
            };

            Company response = companyServiceClient.CreateCompany(request);

            Console.WriteLine("Created Company");
            Console.WriteLine($"Name: {response.Name}");
            Console.WriteLine($"Display Name: {response.DisplayName}");
            Console.WriteLine($"External ID: {response.ExternalId}");
            return(0);
        }
        /// <summary>Snippet for SearchProfilesAsync</summary>
        public async Task SearchProfilesRequestObjectAsync()
        {
            // Snippet: SearchProfilesAsync(SearchProfilesRequest, CallSettings)
            // Additional: SearchProfilesAsync(SearchProfilesRequest, CancellationToken)
            // Create client
            ProfileServiceClient profileServiceClient = await ProfileServiceClient.CreateAsync();

            // Initialize request argument(s)
            SearchProfilesRequest request = new SearchProfilesRequest
            {
                ParentAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                RequestMetadata    = new RequestMetadata(),
                ProfileQuery       = new ProfileQuery(),
                PageSize           = 0,
                PageToken          = "",
                Offset             = 0,
                DisableSpellCheck  = false,
                OrderBy            = "",
                CaseSensitiveSort  = false,
                HistogramQueries   =
                {
                    new HistogramQuery(),
                },
                ResultSetId          = "",
                StrictKeywordsSearch = false,
            };
            // Make the request
            SearchProfilesResponse response = await profileServiceClient.SearchProfilesAsync(request);

            // End snippet
        }
        public void CreateCompanyRequestObject()
        {
            moq::Mock <CompanyService.CompanyServiceClient> mockGrpcClient = new moq::Mock <CompanyService.CompanyServiceClient>(moq::MockBehavior.Strict);
            CreateCompanyRequest request = new CreateCompanyRequest
            {
                ParentAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                Company            = new Company(),
            };
            Company expectedResponse = new Company
            {
                CompanyName         = CompanyName.FromProjectTenantCompany("[PROJECT]", "[TENANT]", "[COMPANY]"),
                DisplayName         = "display_name137f65c2",
                ExternalId          = "external_id9442680e",
                Size                = CompanySize.Mini,
                HeadquartersAddress = "headquarters_address64cd7eb7",
                HiringAgency        = true,
                EeoText             = "eeo_text70a1a576",
                WebsiteUri          = "website_urid0c5dfce",
                CareerSiteUri       = "career_site_uri62d45b74",
                ImageUri            = "image_urieba3b1bc",
                KeywordSearchableJobCustomAttributes =
                {
                    "keyword_searchable_job_custom_attributese72ec77c",
                },
                DerivedInfo = new Company.Types.DerivedInfo(),
                Suspended   = true,
            };

            mockGrpcClient.Setup(x => x.CreateCompany(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CompanyServiceClient client = new CompanyServiceClientImpl(mockGrpcClient.Object, null);
            Company response            = client.CreateCompany(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for GetTenant</summary>
 public void GetTenantResourceNames()
 {
     // Snippet: GetTenant(TenantName, CallSettings)
     // Create client
     TenantServiceClient tenantServiceClient = TenantServiceClient.Create();
     // Initialize request argument(s)
     TenantName name = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]");
     // Make the request
     Tenant response = tenantServiceClient.GetTenant(name);
     // End snippet
 }
 /// <summary>Snippet for CreateProfile</summary>
 public void CreateProfileResourceNames()
 {
     // Snippet: CreateProfile(TenantName, Profile, CallSettings)
     // Create client
     ProfileServiceClient profileServiceClient = ProfileServiceClient.Create();
     // Initialize request argument(s)
     TenantName parent  = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]");
     Profile    profile = new Profile();
     // Make the request
     Profile response = profileServiceClient.CreateProfile(parent, profile);
     // End snippet
 }
 /// <summary>Snippet for CreateClientEvent</summary>
 public void CreateClientEventResourceNames()
 {
     // Snippet: CreateClientEvent(TenantName, ClientEvent, CallSettings)
     // Create client
     EventServiceClient eventServiceClient = EventServiceClient.Create();
     // Initialize request argument(s)
     TenantName  parent      = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]");
     ClientEvent clientEvent = new ClientEvent();
     // Make the request
     ClientEvent response = eventServiceClient.CreateClientEvent(parent, clientEvent);
     // End snippet
 }
 /// <summary>Snippet for CreateCompany</summary>
 public void CreateCompanyResourceNames1()
 {
     // Snippet: CreateCompany(TenantName, Company, CallSettings)
     // Create client
     CompanyServiceClient companyServiceClient = CompanyServiceClient.Create();
     // Initialize request argument(s)
     TenantName parent  = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]");
     Company    company = new Company();
     // Make the request
     Company response = companyServiceClient.CreateCompany(parent, company);
     // End snippet
 }
        // [START job_search_create_client_event]
        public static object CreateClientEvent(string projectId, string tenantId, string requestId, string eventId, IEnumerable <string> jobIds)
        {
            EventServiceClient eventServiceClient = EventServiceClient.Create();

            TenantName tenantName = TenantName.FromProjectTenant(projectId, tenantId);

            long      seconds    = 1L;
            Timestamp createTime = new Timestamp
            {
                Seconds = seconds
            };

            // The type of event attributed to the behavior of the end user.
            JobEventType type = JobEventType.View;

            // List of job names associated with this event.
            List <string> jobs = new List <string>();

            foreach (var jobId in jobIds)
            {
                //build full path of job IDs
                JobName name = JobName.FromProjectTenantJob(projectId, tenantId, jobId);
                jobs.Add(name.ToString());
            }

            JobEvent jobEvent = new JobEvent
            {
                Type = type
            };

            jobEvent.Jobs.Add(jobs);

            ClientEvent clientEvent = new ClientEvent
            {
                RequestId  = requestId,
                EventId    = eventId,
                CreateTime = createTime,
                JobEvent   = jobEvent
            };

            CreateClientEventRequest request = new CreateClientEventRequest
            {
                ParentAsTenantName = tenantName,
                ClientEvent        = clientEvent
            };

            ClientEvent response = eventServiceClient.CreateClientEvent(request);

            Console.WriteLine($"Created client event.");
            Console.WriteLine(response);

            return(0);
        }
Ejemplo n.º 16
0
        // [START job_search_delete_tenant_beta]
        public static object DeleteTenant(string projectId, string tenantId)
        {
            TenantServiceClient tenantServiceClient = TenantServiceClient.Create();
            TenantName          tenantName          = TenantName.FromProjectTenant(projectId, tenantId);
            DeleteTenantRequest request             = new DeleteTenantRequest
            {
                TenantName = tenantName
            };

            tenantServiceClient.DeleteTenant(request);
            Console.WriteLine($"Deleted Tenant.");
            return(0);
        }
 /// <summary>Snippet for GetTenant</summary>
 public void GetTenantRequestObject()
 {
     // Snippet: GetTenant(GetTenantRequest, CallSettings)
     // Create client
     TenantServiceClient tenantServiceClient = TenantServiceClient.Create();
     // Initialize request argument(s)
     GetTenantRequest request = new GetTenantRequest
     {
         TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
     };
     // Make the request
     Tenant response = tenantServiceClient.GetTenant(request);
     // End snippet
 }
        /// <summary>Snippet for DeleteTenantAsync</summary>
        public async Task DeleteTenantResourceNamesAsync()
        {
            // Snippet: DeleteTenantAsync(TenantName, CallSettings)
            // Additional: DeleteTenantAsync(TenantName, CancellationToken)
            // Create client
            TenantServiceClient tenantServiceClient = await TenantServiceClient.CreateAsync();

            // Initialize request argument(s)
            TenantName name = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]");
            // Make the request
            await tenantServiceClient.DeleteTenantAsync(name);

            // End snippet
        }
Ejemplo n.º 19
0
        // [START job_search_get_tenant_beta]
        public static object GetTenant(string projectId, string tenantId)
        {
            TenantServiceClient tenantServiceClient = TenantServiceClient.Create();
            TenantName          name    = TenantName.FromProjectTenant(projectId, tenantId);
            GetTenantRequest    request = new GetTenantRequest
            {
                TenantName = name
            };
            Tenant response = tenantServiceClient.GetTenant(request);

            Console.WriteLine($"Name: {response.Name}");
            Console.WriteLine($"External ID: {response.ExternalId}");
            return(0);
        }
        /// <summary>Snippet for ListProfilesAsync</summary>
        public async Task ListProfilesRequestObjectAsync()
        {
            // Snippet: ListProfilesAsync(ListProfilesRequest, CallSettings)
            // Create client
            ProfileServiceClient profileServiceClient = await ProfileServiceClient.CreateAsync();

            // Initialize request argument(s)
            ListProfilesRequest request = new ListProfilesRequest
            {
                ParentAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                ReadMask           = new FieldMask(),
                Filter             = "",
            };
            // Make the request
            PagedAsyncEnumerable <ListProfilesResponse, Profile> response = profileServiceClient.ListProfilesAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Profile item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListProfilesResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Profile item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int            pageSize   = 10;
            Page <Profile> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Profile item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
        /// <summary>Snippet for CreateClientEventAsync</summary>
        public async Task CreateClientEventResourceNamesAsync()
        {
            // Snippet: CreateClientEventAsync(TenantName, ClientEvent, CallSettings)
            // Additional: CreateClientEventAsync(TenantName, ClientEvent, CancellationToken)
            // Create client
            EventServiceClient eventServiceClient = await EventServiceClient.CreateAsync();

            // Initialize request argument(s)
            TenantName  parent      = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]");
            ClientEvent clientEvent = new ClientEvent();
            // Make the request
            ClientEvent response = await eventServiceClient.CreateClientEventAsync(parent, clientEvent);

            // End snippet
        }
 /// <summary>Snippet for CreateCompany</summary>
 public void CreateCompanyRequestObject()
 {
     // Snippet: CreateCompany(CreateCompanyRequest, CallSettings)
     // Create client
     CompanyServiceClient companyServiceClient = CompanyServiceClient.Create();
     // Initialize request argument(s)
     CreateCompanyRequest request = new CreateCompanyRequest
     {
         ParentAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
         Company            = new Company(),
     };
     // Make the request
     Company response = companyServiceClient.CreateCompany(request);
     // End snippet
 }
        /// <summary>Snippet for CreateCompanyAsync</summary>
        public async Task CreateCompanyResourceNames1Async()
        {
            // Snippet: CreateCompanyAsync(TenantName, Company, CallSettings)
            // Additional: CreateCompanyAsync(TenantName, Company, CancellationToken)
            // Create client
            CompanyServiceClient companyServiceClient = await CompanyServiceClient.CreateAsync();

            // Initialize request argument(s)
            TenantName parent  = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]");
            Company    company = new Company();
            // Make the request
            Company response = await companyServiceClient.CreateCompanyAsync(parent, company);

            // End snippet
        }
        /// <summary>Snippet for CreateProfileAsync</summary>
        public async Task CreateProfileResourceNamesAsync()
        {
            // Snippet: CreateProfileAsync(TenantName, Profile, CallSettings)
            // Additional: CreateProfileAsync(TenantName, Profile, CancellationToken)
            // Create client
            ProfileServiceClient profileServiceClient = await ProfileServiceClient.CreateAsync();

            // Initialize request argument(s)
            TenantName parent  = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]");
            Profile    profile = new Profile();
            // Make the request
            Profile response = await profileServiceClient.CreateProfileAsync(parent, profile);

            // End snippet
        }
 /// <summary>Snippet for CreateProfile</summary>
 public void CreateProfileRequestObject()
 {
     // Snippet: CreateProfile(CreateProfileRequest, CallSettings)
     // Create client
     ProfileServiceClient profileServiceClient = ProfileServiceClient.Create();
     // Initialize request argument(s)
     CreateProfileRequest request = new CreateProfileRequest
     {
         ParentAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
         Profile            = new Profile(),
     };
     // Make the request
     Profile response = profileServiceClient.CreateProfile(request);
     // End snippet
 }
        /// <summary>Snippet for ListCompanies</summary>
        public void ListCompaniesRequestObject()
        {
            // Snippet: ListCompanies(ListCompaniesRequest, CallSettings)
            // Create client
            CompanyServiceClient companyServiceClient = CompanyServiceClient.Create();
            // Initialize request argument(s)
            ListCompaniesRequest request = new ListCompaniesRequest
            {
                ParentAsTenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
                RequireOpenJobs    = false,
            };
            // Make the request
            PagedEnumerable <ListCompaniesResponse, Company> response = companyServiceClient.ListCompanies(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (Company item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListCompaniesResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Company item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int            pageSize   = 10;
            Page <Company> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Company item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
        public void DeleteTenantResourceNames()
        {
            moq::Mock <TenantService.TenantServiceClient> mockGrpcClient = new moq::Mock <TenantService.TenantServiceClient>(moq::MockBehavior.Strict);
            DeleteTenantRequest request = new DeleteTenantRequest
            {
                TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.DeleteTenant(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            TenantServiceClient client = new TenantServiceClientImpl(mockGrpcClient.Object, null);

            client.DeleteTenant(request.TenantName);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for DeleteTenantAsync</summary>
        public async Task DeleteTenantRequestObjectAsync()
        {
            // Snippet: DeleteTenantAsync(DeleteTenantRequest, CallSettings)
            // Additional: DeleteTenantAsync(DeleteTenantRequest, CancellationToken)
            // Create client
            TenantServiceClient tenantServiceClient = await TenantServiceClient.CreateAsync();

            // Initialize request argument(s)
            DeleteTenantRequest request = new DeleteTenantRequest
            {
                TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"),
            };
            // Make the request
            await tenantServiceClient.DeleteTenantAsync(request);

            // End snippet
        }
        /// <summary>Snippet for ListCompaniesAsync</summary>
        public async Task ListCompaniesResourceNames1Async()
        {
            // Snippet: ListCompaniesAsync(TenantName, string, int?, CallSettings)
            // Create client
            CompanyServiceClient companyServiceClient = await CompanyServiceClient.CreateAsync();

            // Initialize request argument(s)
            TenantName parent = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]");
            // Make the request
            PagedAsyncEnumerable <ListCompaniesResponse, Company> response = companyServiceClient.ListCompaniesAsync(parent);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Company item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListCompaniesResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Company item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int            pageSize   = 10;
            Page <Company> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Company item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
Ejemplo n.º 30
0
        // [START job_search_custom_ranking_search]
        public static object CustomRankingSearch(string projectId, string tenantId)
        {
            JobServiceClient jobServiceClient = JobServiceClient.Create();
            TenantName       name             = TenantName.FromProjectTenant(projectId, tenantId);

            string          domain          = "www.example.com";
            string          sessionId       = "Hashed session identifier";
            string          userId          = "Hashed user identifier";
            RequestMetadata requestMetadata = new RequestMetadata
            {
                Domain    = domain,
                SessionId = sessionId,
                UserId    = userId
            };

            CustomRankingInfo customRankingInfo = new CustomRankingInfo
            {
                ImportanceLevel = ImportanceLevel.Extreme,
                // Custom ranking supports math operators, and Field name can be CPC or Freshness
                // https://cloud.google.com/talent-solution/job-search/docs/custom-ranking#how_to_use
                RankingExpression = "(someFieldLong + 25) * 0.25"
            };
            string orderBy = "custom_ranking desc";

            SearchJobsRequest request = new SearchJobsRequest
            {
                ParentAsTenantName = name,
                CustomRankingInfo  = customRankingInfo,
                RequestMetadata    = requestMetadata,
                OrderBy            = orderBy
            };

            var response = jobServiceClient.SearchJobs(request);

            foreach (var result in response)
            {
                Console.WriteLine($"Job summary: {result.JobSummary}");
                Console.WriteLine($"Job title snippet: {result.JobTitleSnippet}");
                Job job = result.Job;
                Console.WriteLine($"Job name: {job.Name}");
                Console.WriteLine($"Job title: {job.Title}");
            }

            return(0);
        }