Unternehmen erstellen und aktualisieren (v4beta1)

Eine Unternehmensressource in Cloud Talent Solution repräsentiert ein einzelnes Unternehmen. Jeder Job, der zu diesem Unternehmen gehört, bezieht sich auf eine Jobanzeige, die für eine offene Position in diesem Unternehmen erstellt wurde. Sie enthält Informationen wie den Namen und die Adresse des Unternehmens sowie interne Felder, die die Ressource des Cloud Talent Solution-Dienstes mit Ihren internen Datenbanken verbinden.

Unternehmen erstellen

Senden Sie zum Erstellen einer Firma eine POST-Anforderung an den Endpunkt companies und geben Sie mindestens die beiden erforderlichen Felder an. Informationen zum Erstellen eines Unternehmens finden Sie auf der Seite Schnellstart: Unternehmen und Jobs erstellen. Video-Tutorials und interaktive Codelabs sind ebenfalls verfügbar .

Go

Informationen zum Installieren und Verwenden der Clientbibliothek für CTS finden Sie unter CTS-Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur CTS Go API.

Richten Sie Standardanmeldedaten für Anwendungen ein, um sich bei CTS zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	"cloud.google.com/go/talent/apiv4beta1/talentpb"
)

// createCompany creates a company as given.
func createCompany(w io.Writer, projectID, externalID, displayName string) (*talentpb.Company, error) {
	ctx := context.Background()

	// Initializes a companyService client.
	c, err := talent.NewCompanyClient(ctx)
	if err != nil {
		return nil, fmt.Errorf("talent.NewCompanyClient: %w", err)
	}
	defer c.Close()

	// Construct a createCompany request.
	req := &talentpb.CreateCompanyRequest{
		Parent: fmt.Sprintf("projects/%s", projectID),
		Company: &talentpb.Company{
			ExternalId:  externalID,
			DisplayName: displayName,
		},
	}

	resp, err := c.CreateCompany(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("CreateCompany: %w", err)
	}

	fmt.Fprintf(w, "Created company: %q\n", resp.GetName())

	return resp, nil
}

Java

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.


import com.google.cloud.talent.v4beta1.Company;
import com.google.cloud.talent.v4beta1.CompanyServiceClient;
import com.google.cloud.talent.v4beta1.CreateCompanyRequest;
import com.google.cloud.talent.v4beta1.TenantName;
import java.io.IOException;

public class JobSearchCreateCompany {

  public static void createCompany() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String displayName = "your-company-display-name";
    String externalId = "your-external-id";
    createCompany(projectId, tenantId, displayName, externalId);
  }

  // Create a company.
  public static void createCompany(
      String projectId, String tenantId, String displayName, String externalId) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
      TenantName parent = TenantName.of(projectId, tenantId);
      Company company =
          Company.newBuilder().setDisplayName(displayName).setExternalId(externalId).build();

      CreateCompanyRequest request =
          CreateCompanyRequest.newBuilder()
              .setParent(parent.toString())
              .setCompany(company)
              .build();

      Company response = companyServiceClient.createCompany(request);
      System.out.println("Created Company");
      System.out.format("Name: %s%n", response.getName());
      System.out.format("Display Name: %s%n", response.getDisplayName());
      System.out.format("External ID: %s%n", response.getExternalId());
    }
  }
}

Python

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.


from google.cloud import talent

def create_company(project_id, tenant_id, display_name, external_id):
    """Create Company"""

    client = talent.CompanyServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # display_name = 'My Company Name'
    # external_id = 'Identifier of this company in my system'

    if isinstance(project_id, bytes):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, bytes):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(display_name, bytes):
        display_name = display_name.decode("utf-8")
    if isinstance(external_id, bytes):
        external_id = external_id.decode("utf-8")
    parent = f"projects/{project_id}/tenants/{tenant_id}"
    company = {"display_name": display_name, "external_id": external_id}

    response = client.create_company(parent=parent, company=company)
    print("Created Company")
    print(f"Name: {response.name}")
    print(f"Display Name: {response.display_name}")
    print(f"External ID: {response.external_id}")
    return response.name

Pflichtfelder

Die folgenden Felder müssen in Erstellungs-/Aktualisierungsanfragen angegeben werden:

  • displayName: Der Name des Arbeitgebers, der mit dem Job angezeigt wird, z. B. "Google LLC".

  • externalId: Ihre interne ID für dieses Unternehmen. In diesem Feld können Sie dem Unternehmen im Google-System Ihre interne Kennzeichnung zuordnen. Wenn das Unternehmen keine separate interne Kennung hat, setzen Sie dieses Feld auf den gleichen Wert wie displayName.

Häufig verwendete Felder

  • headquartersAddressDie Adresse der Hauptniederlassung des Unternehmens, die sich vom Jobstandort unterscheiden kann. Cloud Talent Solution akzeptiert pro Unternehmen nur einen einzigen Standort für die Hauptniederlassung. Der Dienst versucht, die Adresse zu lokalisieren, und füllt nach Möglichkeit einen genaueren Speicherort in derivedInfo.headquartersLocation auf (der nur ausgegeben wird).

  • size: Ein Bucket-Wert, der die Größe des Unternehmens in Bezug auf die Anzahl der Mitarbeiter von MINI bis GIANT darstellt. Die Aufzählungen und ihre Definitionen finden Sie in der Referenz size.

  • eeoText: Eine Zeichenfolge, die den gesetzlichen Haftungsausschlusstext für Chancengleichheit enthält, der allen Jobs für dieses Unternehmen zugeordnet werden soll.

  • keywordSearchableJobCustomAttributes: Gibt an, welche customAttributes in den Jobs dieses Unternehmens durch die allgemeine Stichwortsuche indiziert und durchsuchbar sein sollen.

Als vertraulich behandelte Unternehmen

In Fällen, in denen Sie einen vertraulichen Job veröffentlichen möchten, empfehlen wir, ein separates Unternehmen zu erstellen, das die Felder des Unternehmens nachahmt, jedoch die Felder displayName, externalId und andere identifizierende Felder verschleiert.

In Fällen, in denen der Endarbeitgeber anonym sein sollte (z. B. im Anwendungsfall der Personalagentur), empfehlen wir, die Werte externalId und displayName auf zufällige, aber eindeutige Werte festzulegen.

Unternehmen abrufen

Go

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	"cloud.google.com/go/talent/apiv4beta1/talentpb"
)

// getCompany gets an existing company by its resource name.
func getCompany(w io.Writer, projectID, companyID string) (*talentpb.Company, error) {
	ctx := context.Background()

	// Initialize a companyService client.
	c, err := talent.NewCompanyClient(ctx)
	if err != nil {
		return nil, fmt.Errorf("talent.NewCompanyClient: %w", err)
	}
	defer c.Close()

	// Construct a getCompany request.
	companyName := fmt.Sprintf("projects/%s/companies/%s", projectID, companyID)
	req := &talentpb.GetCompanyRequest{
		// The resource name of the company to be retrieved.
		// The format is "projects/{project_id}/companies/{company_id}".
		Name: companyName,
	}

	resp, err := c.GetCompany(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("GetCompany: %w", err)
	}

	fmt.Fprintf(w, "Company: %q\n", resp.GetName())
	fmt.Fprintf(w, "Company display name: %q\n", resp.GetDisplayName())

	return resp, nil
}

Java

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.


import com.google.cloud.talent.v4beta1.Company;
import com.google.cloud.talent.v4beta1.CompanyName;
import com.google.cloud.talent.v4beta1.CompanyServiceClient;
import com.google.cloud.talent.v4beta1.GetCompanyRequest;
import java.io.IOException;

public class JobSearchGetCompany {

  public static void getCompany() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String companyId = "your-company-id";
    getCompany(projectId, tenantId, companyId);
  }

  // Get Company.
  public static void getCompany(String projectId, String tenantId, String companyId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
      CompanyName name = CompanyName.ofProjectTenantCompanyName(projectId, tenantId, companyId);

      GetCompanyRequest request = GetCompanyRequest.newBuilder().setName(name.toString()).build();

      Company response = companyServiceClient.getCompany(request);
      System.out.format("Company name: %s%n", response.getName());
      System.out.format("Display name: %s%n", response.getDisplayName());
    }
  }
}

Python

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.


from google.cloud import talent

def get_company(project_id, tenant_id, company_id):
    """Get Company"""

    client = talent.CompanyServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # company_id = 'Company ID'

    if isinstance(project_id, bytes):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, bytes):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(company_id, bytes):
        company_id = company_id.decode("utf-8")
    name = client.company_path(project_id, tenant_id, company_id)

    response = client.get_company(name=name)
    print(f"Company name: {response.name}")
    print(f"Display name: {response.display_name}")

Unternehmen auflisten

Java

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.


import com.google.cloud.talent.v4beta1.Company;
import com.google.cloud.talent.v4beta1.CompanyServiceClient;
import com.google.cloud.talent.v4beta1.ListCompaniesRequest;
import com.google.cloud.talent.v4beta1.TenantName;
import java.io.IOException;

public class JobSearchListCompanies {

  public static void listCompanies() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    listCompanies(projectId, tenantId);
  }

  // List Companies.
  public static void listCompanies(String projectId, String tenantId) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
      TenantName parent = TenantName.of(projectId, tenantId);

      ListCompaniesRequest request =
          ListCompaniesRequest.newBuilder().setParent(parent.toString()).build();

      for (Company responseItem : companyServiceClient.listCompanies(request).iterateAll()) {
        System.out.format("Company Name: %s%n", responseItem.getName());
        System.out.format("Display Name: %s%n", responseItem.getDisplayName());
        System.out.format("External ID: %s%n", responseItem.getExternalId());
      }
    }
  }
}

Unternehmen löschen

Go

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.

import (
	"context"
	"fmt"
	"io"

	talent "cloud.google.com/go/talent/apiv4beta1"
	"cloud.google.com/go/talent/apiv4beta1/talentpb"
)

// deleteCompany deletes an existing company. Companies with
// existing jobs cannot be deleted until those jobs have been deleted.
func deleteCompany(w io.Writer, projectID, companyID string) error {
	ctx := context.Background()

	// Initialize a companyService client.
	c, err := talent.NewCompanyClient(ctx)
	if err != nil {
		return fmt.Errorf("talent.NewCompanyClient: %w", err)
	}
	defer c.Close()

	// Construct a deleteCompany request.
	companyName := fmt.Sprintf("projects/%s/companies/%s", projectID, companyID)
	req := &talentpb.DeleteCompanyRequest{
		// The resource name of the company to be deleted.
		// The format is "projects/{project_id}/companies/{company_id}".
		Name: companyName,
	}

	if err := c.DeleteCompany(ctx, req); err != nil {
		return fmt.Errorf("DeleteCompany(%s): %w", companyName, err)
	}

	fmt.Fprintf(w, "Deleted company: %q\n", companyName)

	return nil
}

Java

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.


import com.google.cloud.talent.v4beta1.CompanyName;
import com.google.cloud.talent.v4beta1.CompanyServiceClient;
import com.google.cloud.talent.v4beta1.DeleteCompanyRequest;
import java.io.IOException;

public class JobSearchDeleteCompany {

  public static void deleteCompany() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String tenantId = "your-tenant-id";
    String companyId = "your-company-id";
    deleteCompany(projectId, tenantId, companyId);
  }

  // Delete Company.
  public static void deleteCompany(String projectId, String tenantId, String companyId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
      CompanyName name = CompanyName.ofProjectTenantCompanyName(projectId, tenantId, companyId);

      DeleteCompanyRequest request =
          DeleteCompanyRequest.newBuilder().setName(name.toString()).build();

      companyServiceClient.deleteCompany(request);
      System.out.println("Deleted company");
    }
  }
}

Python

Weitere Informationen zum Installieren und Erstellen eines Cloud Talent Solution-Clients finden Sie unter Cloud Talent Solution-Clientbibliotheken.


from google.cloud import talent

def delete_company(project_id, tenant_id, company_id):
    """Delete Company"""

    client = talent.CompanyServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID (using tenancy is optional)'
    # company_id = 'ID of the company to delete'

    if isinstance(project_id, bytes):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, bytes):
        tenant_id = tenant_id.decode("utf-8")
    if isinstance(company_id, bytes):
        company_id = company_id.decode("utf-8")
    name = client.company_path(project_id, tenant_id, company_id)

    client.delete_company(name=name)
    print("Deleted company")