define field-value pairs
Stay organized with collections
Save and categorize content based on your preferences.
Used to add extra fields and values to a job entry
Explore further
For detailed documentation that includes this code sample, see the following:
Code sample
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],[],[],[],null,["# define field-value pairs\n\nUsed to add extra fields and values to a job entry\n\nExplore further\n---------------\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Create company and job](/talent-solution/job-search/v3/docs/create-company-job)\n- [Custom attributes (v3)](/talent-solution/job-search/v3/docs/custom-attributes)\n\nCode sample\n-----------\n\n### Go\n\n\nTo learn how to install and use the client library for CTS, see\n[CTS client libraries](/talent-solution/job-search/docs/libraries).\n\n\nFor more information, see the\n[CTS Go API\nreference documentation](/go/docs/reference/cloud.google.com/go/talent/latest/apiv4).\n\n\nTo authenticate to CTS, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n // constructJobWithCustomAttributes constructs a job with custom attributes.\n func constructJobWithCustomAttributes(companyName string, jobTitle string) *talent.Job {\n \t// requisitionID shoud be the unique ID in your system\n \trequisitionID := fmt.Sprintf(\"job-with-custom-attribute-%d\", time.Now().UnixNano())\n\n \tjob := &talent.Job{\n \t\tRequisitionId: requisitionID,\n \t\tTitle: jobTitle,\n \t\tCompanyName: companyName,\n \t\tApplicationInfo: &talent.ApplicationInfo{\n \t\t\tUris: []string{\"https://googlesample.com/career\"},\n \t\t},\n \t\tDescription: \"Design, devolop, test, deploy, maintain and improve software.\",\n \t\tCustomAttributes: map[string]talent.CustomAttribute{\n \t\t\t\"someFieldString\": {\n \t\t\t\tFilterable: true,\n \t\t\t\tStringValues: []string{\"someStrVal\"},\n \t\t\t},\n \t\t\t\"someFieldLong\": {\n \t\t\t\tFilterable: true,\n \t\t\t\tLongValues: []int64{900},\n \t\t\t},\n \t\t},\n \t}\n \treturn job\n }\n\n### Java\n\n\nTo learn how to install and use the client library for CTS, see\n[CTS client libraries](/talent-solution/job-search/docs/libraries).\n\n\nFor more information, see the\n[CTS Java API\nreference documentation](/java/docs/reference/google-cloud-talent/latest/overview).\n\n\nTo authenticate to CTS, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n /** Generate a job with a custom attribute. */\n @SuppressWarnings(\"checkstyle:AbbreviationAsWordInName\")\n public static Job generateJobWithACustomAttribute(String companyName) {\n // requisition id should be a unique Id in your system.\n String requisitionId = \"jobWithACustomAttribute:\" + String.valueOf(new Random().nextLong());\n ApplicationInfo applicationInfo =\n new ApplicationInfo().setUris(Arrays.asList(\"http://careers.google.com\"));\n\n // Constructs custom attributes map\n Map\u003cString, CustomAttribute\u003e customAttributes = new HashMap\u003c\u003e();\n customAttributes.put(\n \"someFieldName1\",\n new CustomAttribute().setStringValues(Arrays.asList(\"value1\")).setFilterable(Boolean.TRUE));\n customAttributes.put(\n \"someFieldName2\",\n new CustomAttribute().setLongValues(Arrays.asList(256L)).setFilterable(true));\n\n // Creates job with custom attributes\n Job job =\n new Job()\n .setCompanyName(companyName)\n .setRequisitionId(requisitionId)\n .setTitle(\"Software Engineer\")\n .setApplicationInfo(applicationInfo)\n .setDescription(\"Design, develop, test, deploy, maintain and improve software.\")\n .setCustomAttributes(customAttributes);\n System.out.println(\"Job generated: \" + job);\n return job;\n }\n\n### Python\n\n\nTo learn how to install and use the client library for CTS, see\n[CTS client libraries](/talent-solution/job-search/docs/libraries).\n\n\nFor more information, see the\n[CTS Python API\nreference documentation](/python/docs/reference/talent/latest).\n\n\nTo authenticate to CTS, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n def generate_job_with_custom_attributes(company_name):\n # Requisition id should be a unique Id in your system.\n requisition_id = \"job_with_custom_attributes:\" + \"\".join(\n random.choice(string.ascii_uppercase + string.digits) for _ in range(16)\n )\n\n job_title = \"Software Engineer\"\n application_urls = [\"http://careers.google.com\"]\n description = \"Design, develop, test, deploy, maintain and improve \" \"software.\"\n\n custom_attributes = {\n \"someFieldName1\": {\"string_values\": [\"value1\"], \"filterable\": True},\n \"someFieldName2\": {\"long_values\": [256], \"filterable\": True},\n }\n\n job = {\n \"company_name\": company_name,\n \"requisition_id\": requisition_id,\n \"title\": job_title,\n \"application_info\": {\"uris\": application_urls},\n \"description\": description,\n \"custom_attributes\": custom_attributes,\n }\n print(\"Job generated: %s\" % job)\n return job\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=job)."]]