Menghapus lowongan secara serentak (v4beta1)

Tugas penghapusan batch.

Jelajahi lebih lanjut

Untuk dokumentasi mendetail yang menyertakan contoh kode ini, lihat artikel berikut:

Contoh kode

Go

Untuk mempelajari cara menginstal dan menggunakan library klien untuk CTS, lihat library klien CTS. Untuk informasi selengkapnya, lihat dokumentasi referensi API CTS Go.

Untuk mengautentikasi ke CTS, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

import (
	"context"
	"fmt"
	"io"

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

// batchDeleteJobs deletes existing jobs by a filter.
func batchDeleteJobs(w io.Writer, projectID, companyID, requisitionID string) error {
	ctx := context.Background()

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

	companyName := fmt.Sprintf("projects/%s/companies/%s", projectID, companyID)
	filter := fmt.Sprintf("companyName=%q AND requisitionId=%q", companyName, requisitionID)

	// Construct a batchDeteleJobs request.
	req := &talentpb.BatchDeleteJobsRequest{
		Parent: fmt.Sprintf("projects/%s", projectID),
		// The fields eligible for filtering are `companyName` and `requisitionId`.
		Filter: filter,
	}

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

	fmt.Fprintf(w, "Batch deleted jobs from %s\n", filter)

	return err
}

Node.js

Untuk mempelajari cara menginstal dan menggunakan library klien untuk CTS, lihat library klien CTS. Untuk informasi selengkapnya, lihat dokumentasi referensi API CTS Node.js.

Untuk mengautentikasi ke CTS, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.


const talent = require('@google-cloud/talent').v4;

/**
 * Batch delete jobs using a filter
 *
 * @param projectId {string} Your Google Cloud Project ID
 * @param tenantId {string} Identifier of the Tenantd
 * @param filter {string} The filter string specifies the jobs to be deleted.
 * For example:
 * companyName = "projects/api-test-project/companies/123" AND equisitionId = "req-1"
 */
function sampleBatchDeleteJobs(projectId, tenantId, filter) {
  const client = new talent.JobServiceClient();
  // const projectId = 'Your Google Cloud Project ID';
  // const tenantId = 'Your Tenant ID (using tenancy is optional)';
  // const filter = '[Query]';
  const formattedParent = client.tenantPath(projectId, tenantId);
  const request = {
    parent: formattedParent,
    filter: filter,
  };
  client.batchDeleteJobs(request).catch(err => {
    console.error(err);
  });
  console.log('Batch deleted jobs from filter');
}

Langkah selanjutnya

Untuk menelusuri dan memfilter contoh kode untuk produk Google Cloud lainnya, lihat browser contoh Google Cloud.