Class Job


  • public class Job
    extends com.pulumi.resources.CustomResource
    A scheduled job that can publish a PubSub message or an HTTP request every X interval of time, using a crontab format string. To get more information about Job, see: * [API documentation](https://cloud.google.com/scheduler/docs/reference/rest/) * How-to Guides * [Official Documentation](https://cloud.google.com/scheduler/) ## Example Usage ### Scheduler Job App Engine ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.gcp.cloudscheduler.Job; import com.pulumi.gcp.cloudscheduler.JobArgs; import com.pulumi.gcp.cloudscheduler.inputs.JobAppEngineHttpTargetArgs; import com.pulumi.gcp.cloudscheduler.inputs.JobAppEngineHttpTargetAppEngineRoutingArgs; import com.pulumi.gcp.cloudscheduler.inputs.JobRetryConfigArgs; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var job = new Job("job", JobArgs.builder() .appEngineHttpTarget(JobAppEngineHttpTargetArgs.builder() .appEngineRouting(JobAppEngineHttpTargetAppEngineRoutingArgs.builder() .instance("my-instance-001") .service("web") .version("prod") .build()) .httpMethod("POST") .relativeUri("/ping") .build()) .attemptDeadline("320s") .description("test app engine job") .retryConfig(JobRetryConfigArgs.builder() .maxDoublings(2) .maxRetryDuration("10s") .minBackoffDuration("1s") .retryCount(3) .build()) .schedule("*/4 * * * *") .timeZone("Europe/London") .build()); } } ``` ### Scheduler Job Oauth ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.gcp.compute.ComputeFunctions; import com.pulumi.gcp.compute.inputs.GetDefaultServiceAccountArgs; import com.pulumi.gcp.cloudscheduler.Job; import com.pulumi.gcp.cloudscheduler.JobArgs; import com.pulumi.gcp.cloudscheduler.inputs.JobHttpTargetArgs; import com.pulumi.gcp.cloudscheduler.inputs.JobHttpTargetOauthTokenArgs; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { final var default = ComputeFunctions.getDefaultServiceAccount(); var job = new Job("job", JobArgs.builder() .description("test http job") .schedule("*/8 * * * *") .timeZone("America/New_York") .attemptDeadline("320s") .httpTarget(JobHttpTargetArgs.builder() .httpMethod("GET") .uri("https://cloudscheduler.googleapis.com/v1/projects/my-project-name/locations/us-west1/jobs") .oauthToken(JobHttpTargetOauthTokenArgs.builder() .serviceAccountEmail(default_.email()) .build()) .build()) .build()); } } ``` ### Scheduler Job Oidc ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.gcp.compute.ComputeFunctions; import com.pulumi.gcp.compute.inputs.GetDefaultServiceAccountArgs; import com.pulumi.gcp.cloudscheduler.Job; import com.pulumi.gcp.cloudscheduler.JobArgs; import com.pulumi.gcp.cloudscheduler.inputs.JobHttpTargetArgs; import com.pulumi.gcp.cloudscheduler.inputs.JobHttpTargetOidcTokenArgs; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { final var default = ComputeFunctions.getDefaultServiceAccount(); var job = new Job("job", JobArgs.builder() .description("test http job") .schedule("*/8 * * * *") .timeZone("America/New_York") .attemptDeadline("320s") .httpTarget(JobHttpTargetArgs.builder() .httpMethod("GET") .uri("https://example.com/ping") .oidcToken(JobHttpTargetOidcTokenArgs.builder() .serviceAccountEmail(default_.email()) .build()) .build()) .build()); } } ``` ## Import Job can be imported using any of these accepted formats* `projects/{{project}}/locations/{{region}}/jobs/{{name}}` * `{{project}}/{{region}}/{{name}}` * `{{region}}/{{name}}` * `{{name}}` In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Job using one of the formats above. For exampletf import { id = "projects/{{project}}/locations/{{region}}/jobs/{{name}}" to = google_cloud_scheduler_job.default } ```sh $ pulumi import gcp:cloudscheduler/job:Job When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), Job can be imported using one of the formats above. For example ``` ```sh $ pulumi import gcp:cloudscheduler/job:Job default projects/{{project}}/locations/{{region}}/jobs/{{name}} ``` ```sh $ pulumi import gcp:cloudscheduler/job:Job default {{project}}/{{region}}/{{name}} ``` ```sh $ pulumi import gcp:cloudscheduler/job:Job default {{region}}/{{name}} ``` ```sh $ pulumi import gcp:cloudscheduler/job:Job default {{name}} ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Summary

      Constructors 
      Constructor Description
      Job​(java.lang.String name)  
      Job​(java.lang.String name, JobArgs args)  
      Job​(java.lang.String name, JobArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.util.Optional<JobAppEngineHttpTarget>> appEngineHttpTarget()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> attemptDeadline()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> description()  
      static Job get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, JobState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.util.Optional<JobHttpTarget>> httpTarget()  
      com.pulumi.core.Output<java.lang.String> name()  
      com.pulumi.core.Output<java.lang.Boolean> paused()  
      com.pulumi.core.Output<java.lang.String> project()  
      com.pulumi.core.Output<java.util.Optional<JobPubsubTarget>> pubsubTarget()  
      com.pulumi.core.Output<java.lang.String> region()  
      com.pulumi.core.Output<java.util.Optional<JobRetryConfig>> retryConfig()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> schedule()  
      com.pulumi.core.Output<java.lang.String> state()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> timeZone()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Job

        public Job​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • Job

        public Job​(java.lang.String name,
                   @Nullable
                   JobArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • Job

        public Job​(java.lang.String name,
                   @Nullable
                   JobArgs args,
                   @Nullable
                   com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • appEngineHttpTarget

        public com.pulumi.core.Output<java.util.Optional<JobAppEngineHttpTarget>> appEngineHttpTarget()
        Returns:
        App Engine HTTP target. If the job providers a App Engine HTTP target the cron will send a request to the service instance Structure is documented below.
      • attemptDeadline

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> attemptDeadline()
        Returns:
        The deadline for job attempts. If the request handler does not respond by this deadline then the request is cancelled and the attempt is marked as a DEADLINE_EXCEEDED failure. The failed attempt can be viewed in execution logs. Cloud Scheduler will retry the job according to the RetryConfig. The allowed duration for this deadline is: * For HTTP targets, between 15 seconds and 30 minutes. * For App Engine HTTP targets, between 15 seconds and 24 hours. * **Note**: For PubSub targets, this field is ignored - setting it will introduce an unresolvable diff. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s"
      • description

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> description()
        Returns:
        A human-readable description for the job. This string must not contain more than 500 characters.
      • httpTarget

        public com.pulumi.core.Output<java.util.Optional<JobHttpTarget>> httpTarget()
        Returns:
        HTTP target. If the job providers a http_target the cron will send a request to the targeted url Structure is documented below.
      • name

        public com.pulumi.core.Output<java.lang.String> name()
        Returns:
        The name of the job. ***
      • paused

        public com.pulumi.core.Output<java.lang.Boolean> paused()
        Returns:
        Sets the job to a paused state. Jobs default to being enabled when this property is not set.
      • project

        public com.pulumi.core.Output<java.lang.String> project()
        Returns:
        The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
      • pubsubTarget

        public com.pulumi.core.Output<java.util.Optional<JobPubsubTarget>> pubsubTarget()
        Returns:
        Pub/Sub target If the job providers a Pub/Sub target the cron will publish a message to the provided topic Structure is documented below.
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where the scheduler job resides. If it is not provided, this provider will use the provider default.
      • retryConfig

        public com.pulumi.core.Output<java.util.Optional<JobRetryConfig>> retryConfig()
        Returns:
        By default, if a job does not complete successfully, meaning that an acknowledgement is not received from the handler, then it will be retried with exponential backoff according to the settings Structure is documented below.
      • schedule

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> schedule()
        Returns:
        Describes the schedule on which the job will be executed.
      • state

        public com.pulumi.core.Output<java.lang.String> state()
        Returns:
        State of the job.
      • timeZone

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> timeZone()
        Returns:
        Specifies the time zone to be used in interpreting schedule. The value of this field must be a time zone name from the tz database.
      • get

        public static Job get​(java.lang.String name,
                              com.pulumi.core.Output<java.lang.String> id,
                              @Nullable
                              JobState state,
                              @Nullable
                              com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.