ListJobsÚselo con un AWS SDKo CLI - AWS Adherencia

Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.

ListJobsÚselo con un AWS SDKo CLI

En los siguientes ejemplos de código, se muestra cómo utilizar ListJobs.

Los ejemplos de acciones son extractos de código de programas más grandes y deben ejecutarse en contexto. Puede ver esta acción en contexto en el siguiente ejemplo de código:

.NET
AWS SDK for .NET
nota

Hay más información GitHub. Consulta el ejemplo completo y aprende a configurarlo y ejecutarlo en el AWS Repositorio de ejemplos de código.

/// <summary> /// List AWS Glue jobs using a paginator. /// </summary> /// <returns>A list of AWS Glue job names.</returns> public async Task<List<string>> ListJobsAsync() { var jobNames = new List<string>(); var listJobsPaginator = _amazonGlue.Paginators.ListJobs(new ListJobsRequest { MaxResults = 10 }); await foreach (var response in listJobsPaginator.Responses) { jobNames.AddRange(response.JobNames); } return jobNames; }
  • Para API obtener más información, consulte ListJobsen AWS SDK for .NET APIReferencia.

C++
SDKpara C++
nota

Hay más información GitHub. Consulta el ejemplo completo y aprende a configurarlo y ejecutarlo en el AWS Repositorio de ejemplos de código.

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region in which the bucket was created (overrides config file). // clientConfig.region = "us-east-1"; Aws::Glue::GlueClient client(clientConfig); Aws::Glue::Model::ListJobsRequest listJobsRequest; Aws::String nextToken; std::vector<Aws::String> allJobNames; do { if (!nextToken.empty()) { listJobsRequest.SetNextToken(nextToken); } Aws::Glue::Model::ListJobsOutcome listRunsOutcome = client.ListJobs( listJobsRequest); if (listRunsOutcome.IsSuccess()) { const std::vector<Aws::String> &jobNames = listRunsOutcome.GetResult().GetJobNames(); allJobNames.insert(allJobNames.end(), jobNames.begin(), jobNames.end()); nextToken = listRunsOutcome.GetResult().GetNextToken(); } else { std::cerr << "Error listing jobs. " << listRunsOutcome.GetError().GetMessage() << std::endl; } } while (!nextToken.empty());
  • Para API obtener más información, consulte ListJobsen AWS SDK for C++ APIReferencia.

JavaScript
SDKpara JavaScript (v3)
nota

Hay más información. GitHub Consulta el ejemplo completo y aprende a configurarlo y ejecutarlo en el AWS Repositorio de ejemplos de código.

const listJobs = () => { const client = new GlueClient({}); const command = new ListJobsCommand({}); return client.send(command); };
  • Para API obtener más información, consulte ListJobsen AWS SDK for JavaScript APIReferencia.

PHP
SDK para PHP
nota

Hay más información GitHub. Consulta el ejemplo completo y aprende a configurarlo y ejecutarlo en el AWS Repositorio de ejemplos de código.

$jobs = $glueService->listJobs(); echo "Current jobs:\n"; foreach ($jobs['JobNames'] as $jobsName) { echo "{$jobsName}\n"; } public function listJobs($maxResults = null, $nextToken = null, $tags = []): Result { $arguments = []; if ($maxResults) { $arguments['MaxResults'] = $maxResults; } if ($nextToken) { $arguments['NextToken'] = $nextToken; } if (!empty($tags)) { $arguments['Tags'] = $tags; } return $this->glueClient->listJobs($arguments); }
  • Para API obtener más información, consulte ListJobsen AWS SDK for PHP APIReferencia.

Python
SDKpara Python (Boto3)
nota

Hay más información. GitHub Consulta el ejemplo completo y aprende a configurarlo y ejecutarlo en el AWS Repositorio de ejemplos de código.

class GlueWrapper: """Encapsulates AWS Glue actions.""" def __init__(self, glue_client): """ :param glue_client: A Boto3 Glue client. """ self.glue_client = glue_client def list_jobs(self): """ Lists the names of job definitions in your account. :return: The list of job definition names. """ try: response = self.glue_client.list_jobs() except ClientError as err: logger.error( "Couldn't list jobs. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise else: return response["JobNames"]
  • Para API obtener más información, consulte ListJobsen AWS SDKpara referencia de Python (Boto3). API

Ruby
SDKpara Ruby
nota

Hay más información GitHub. Consulta el ejemplo completo y aprende a configurarlo y ejecutarlo en el AWS Repositorio de ejemplos de código.

# The `GlueWrapper` class serves as a wrapper around the AWS Glue API, providing a simplified interface for common operations. # It encapsulates the functionality of the AWS SDK for Glue and provides methods for interacting with Glue crawlers, databases, tables, jobs, and S3 resources. # The class initializes with a Glue client and a logger, allowing it to make API calls and log any errors or informational messages. class GlueWrapper def initialize(glue_client, logger) @glue_client = glue_client @logger = logger end # Retrieves a list of jobs in AWS Glue. # # @return [Aws::Glue::Types::ListJobsResponse] def list_jobs @glue_client.list_jobs rescue Aws::Glue::Errors::GlueException => e @logger.error("Glue could not list jobs: \n#{e.message}") raise end
  • Para API obtener más información, consulte ListJobsen AWS SDK for Ruby APIReferencia.

Rust
SDKpara Rust
nota

Hay más información GitHub. Consulta el ejemplo completo y aprende a configurarlo y ejecutarlo en el AWS Repositorio de ejemplos de código.

let mut list_jobs = glue.list_jobs().into_paginator().send(); while let Some(list_jobs_output) = list_jobs.next().await { match list_jobs_output { Ok(list_jobs) => { let names = list_jobs.job_names(); info!(?names, "Found these jobs") } Err(err) => return Err(GlueMvpError::from_glue_sdk(err)), } }
  • Para API obtener más información, consulte ListJobsen AWS SDKpara API referencia a Rust.

Para obtener una lista completa de AWS SDKguías para desarrolladores y ejemplos de código, consulteUso de este servicio con un AWS SDK. En este tema también se incluye información sobre cómo empezar y detalles sobre SDK las versiones anteriores.