Há mais AWS SDK exemplos disponíveis no GitHub repositório AWS Doc SDK Examples
As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.
Use DeleteScheduleGroup
com um AWS SDK
Os exemplos de código a seguir mostram como usar o DeleteScheduleGroup
.
- .NET
-
- AWS SDK for .NET
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS
. /// <summary> /// Deletes an existing schedule group from Amazon EventBridge Scheduler. /// </summary> /// <param name="name">The name of the schedule group to delete.</param> /// <returns>True if the schedule group was deleted successfully, false otherwise.</returns> public async Task<bool> DeleteScheduleGroupAsync(string name) { try { var request = new DeleteScheduleGroupRequest { Name = name }; await _amazonScheduler.DeleteScheduleGroupAsync(request); Console.WriteLine($"Successfully deleted schedule group '{name}'."); return true; } catch (ResourceNotFoundException ex) { _logger.LogError( $"Failed to delete schedule group '{name}' because the resource was not found: {ex.Message}"); return true; } catch (Exception ex) { _logger.LogError( $"An error occurred while deleting schedule group '{name}': {ex.Message}"); return false; } }
-
Para API obter detalhes, consulte DeleteScheduleGroupem AWS SDK for .NET APIReferência.
-
- Java
-
- SDKpara Java 2.x
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS
. /** * Deletes the specified schedule group. * * @param name the name of the schedule group to delete * @return a {@link CompletableFuture} that completes when the schedule group has been deleted * @throws CompletionException if an error occurs while deleting the schedule group */ public CompletableFuture<Void> deleteScheduleGroupAsync(String name) { DeleteScheduleGroupRequest request = DeleteScheduleGroupRequest.builder() .name(name) .build(); return getAsyncClient().deleteScheduleGroup(request) .thenRun(() -> { logger.info("Successfully deleted schedule group {}", name); }) .whenComplete((result, ex) -> { if (ex != null) { if (ex instanceof ResourceNotFoundException) { throw new CompletionException("The resource was not found: " + ex.getMessage(), ex); } else { throw new CompletionException("Error deleting schedule group: " + ex.getMessage(), ex); } } }); }
-
Para API obter detalhes, consulte DeleteScheduleGroupem AWS SDK for Java 2.x APIReferência.
-
- Python
-
- SDKpara Python (Boto3)
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS
. class SchedulerWrapper: def __init__(self, eventbridge_scheduler_client: client): self.scheduler_client = eventbridge_scheduler_client @classmethod def from_client(cls) -> "SchedulerWrapper": """ Creates a SchedulerWrapper instance with a default EventBridge Scheduler client. :return: An instance of SchedulerWrapper initialized with the default EventBridge Scheduler client. """ eventbridge_scheduler_client = boto3.client("scheduler") return cls(eventbridge_scheduler_client) def delete_schedule_group(self, name: str) -> None: """ Deletes the schedule group with the specified name. :param name: The name of the schedule group. """ try: self.scheduler_client.delete_schedule_group(Name=name) logger.info("Schedule group %s deleted successfully.", name) except ClientError as err: if err.response["Error"]["Code"] == "ResourceNotFoundException": logger.error( "Failed to delete schedule group with ID '%s' because the resource was not found: %s", name, err.response["Error"]["Message"], ) else: logger.error( "Error deleting schedule group: %s", err.response["Error"]["Message"], ) raise
-
Para API obter detalhes, consulte a DeleteScheduleGroupReferência AWS SDK do Python (Boto3). API
-