package scheduler
import "cloud.google.com/go/scheduler/apiv1beta1"
Package scheduler is an auto-generated package for the Cloud Scheduler API.
NOTE: This package is in beta. It is not stable, and may be subject to changes.
Creates and manages jobs run on a regular recurring schedule.
Index ¶
- func DefaultAuthScopes() []string
- type CloudSchedulerCallOptions
- type CloudSchedulerClient
- func NewCloudSchedulerClient(ctx context.Context, opts ...option.ClientOption) (*CloudSchedulerClient, error)
- func (c *CloudSchedulerClient) Close() error
- func (c *CloudSchedulerClient) Connection() *grpc.ClientConn
- func (c *CloudSchedulerClient) CreateJob(ctx context.Context, req *schedulerpb.CreateJobRequest, opts ...gax.CallOption) (*schedulerpb.Job, error)
- func (c *CloudSchedulerClient) DeleteJob(ctx context.Context, req *schedulerpb.DeleteJobRequest, opts ...gax.CallOption) error
- func (c *CloudSchedulerClient) GetJob(ctx context.Context, req *schedulerpb.GetJobRequest, opts ...gax.CallOption) (*schedulerpb.Job, error)
- func (c *CloudSchedulerClient) ListJobs(ctx context.Context, req *schedulerpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator
- func (c *CloudSchedulerClient) PauseJob(ctx context.Context, req *schedulerpb.PauseJobRequest, opts ...gax.CallOption) (*schedulerpb.Job, error)
- func (c *CloudSchedulerClient) ResumeJob(ctx context.Context, req *schedulerpb.ResumeJobRequest, opts ...gax.CallOption) (*schedulerpb.Job, error)
- func (c *CloudSchedulerClient) RunJob(ctx context.Context, req *schedulerpb.RunJobRequest, opts ...gax.CallOption) (*schedulerpb.Job, error)
- func (c *CloudSchedulerClient) UpdateJob(ctx context.Context, req *schedulerpb.UpdateJobRequest, opts ...gax.CallOption) (*schedulerpb.Job, error)
- type JobIterator
Examples ¶
- CloudSchedulerClient.CreateJob
- CloudSchedulerClient.DeleteJob
- CloudSchedulerClient.GetJob
- CloudSchedulerClient.ListJobs
- CloudSchedulerClient.PauseJob
- CloudSchedulerClient.ResumeJob
- CloudSchedulerClient.RunJob
- CloudSchedulerClient.UpdateJob
- NewCloudSchedulerClient
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type CloudSchedulerCallOptions ¶
type CloudSchedulerCallOptions struct { ListJobs []gax.CallOption GetJob []gax.CallOption CreateJob []gax.CallOption UpdateJob []gax.CallOption DeleteJob []gax.CallOption PauseJob []gax.CallOption ResumeJob []gax.CallOption RunJob []gax.CallOption }
CloudSchedulerCallOptions contains the retry settings for each method of CloudSchedulerClient.
type CloudSchedulerClient ¶
type CloudSchedulerClient struct { // The call options for this service. CallOptions *CloudSchedulerCallOptions // contains filtered or unexported fields }
CloudSchedulerClient is a client for interacting with Cloud Scheduler API.
Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
func NewCloudSchedulerClient ¶
func NewCloudSchedulerClient(ctx context.Context, opts ...option.ClientOption) (*CloudSchedulerClient, error)
NewCloudSchedulerClient creates a new cloud scheduler client.
The Cloud Scheduler API allows external entities to reliably schedule asynchronous jobs.
func (*CloudSchedulerClient) Close ¶
func (c *CloudSchedulerClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*CloudSchedulerClient) Connection ¶
func (c *CloudSchedulerClient) Connection() *grpc.ClientConn
Connection returns the client's connection to the API service.
func (*CloudSchedulerClient) CreateJob ¶
func (c *CloudSchedulerClient) CreateJob(ctx context.Context, req *schedulerpb.CreateJobRequest, opts ...gax.CallOption) (*schedulerpb.Job, error)
CreateJob creates a job.
Code:play
Example¶
package main
import (
"context"
scheduler "cloud.google.com/go/scheduler/apiv1beta1"
schedulerpb "google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1"
)
func main() {
ctx := context.Background()
c, err := scheduler.NewCloudSchedulerClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &schedulerpb.CreateJobRequest{
// TODO: Fill request struct fields.
}
resp, err := c.CreateJob(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudSchedulerClient) DeleteJob ¶
func (c *CloudSchedulerClient) DeleteJob(ctx context.Context, req *schedulerpb.DeleteJobRequest, opts ...gax.CallOption) error
DeleteJob deletes a job.
Code:play
Example¶
package main
import (
"context"
scheduler "cloud.google.com/go/scheduler/apiv1beta1"
schedulerpb "google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1"
)
func main() {
ctx := context.Background()
c, err := scheduler.NewCloudSchedulerClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &schedulerpb.DeleteJobRequest{
// TODO: Fill request struct fields.
}
err = c.DeleteJob(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*CloudSchedulerClient) GetJob ¶
func (c *CloudSchedulerClient) GetJob(ctx context.Context, req *schedulerpb.GetJobRequest, opts ...gax.CallOption) (*schedulerpb.Job, error)
GetJob gets a job.
Code:play
Example¶
package main
import (
"context"
scheduler "cloud.google.com/go/scheduler/apiv1beta1"
schedulerpb "google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1"
)
func main() {
ctx := context.Background()
c, err := scheduler.NewCloudSchedulerClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &schedulerpb.GetJobRequest{
// TODO: Fill request struct fields.
}
resp, err := c.GetJob(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudSchedulerClient) ListJobs ¶
func (c *CloudSchedulerClient) ListJobs(ctx context.Context, req *schedulerpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator
ListJobs lists jobs.
Code:play
Example¶
package main
import (
"context"
scheduler "cloud.google.com/go/scheduler/apiv1beta1"
"google.golang.org/api/iterator"
schedulerpb "google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1"
)
func main() {
ctx := context.Background()
c, err := scheduler.NewCloudSchedulerClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &schedulerpb.ListJobsRequest{
// TODO: Fill request struct fields.
}
it := c.ListJobs(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
func (*CloudSchedulerClient) PauseJob ¶
func (c *CloudSchedulerClient) PauseJob(ctx context.Context, req *schedulerpb.PauseJobRequest, opts ...gax.CallOption) (*schedulerpb.Job, error)
PauseJob pauses a job.
If a job is paused then the system will stop executing the job
until it is re-enabled via [ResumeJob][google.cloud.scheduler.v1beta1.CloudScheduler.ResumeJob]. The
state of the job is stored in [state][google.cloud.scheduler.v1beta1.Job.state]; if paused it
will be set to [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. A job must be in [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]
to be paused.
Code:play
Example¶
package main
import (
"context"
scheduler "cloud.google.com/go/scheduler/apiv1beta1"
schedulerpb "google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1"
)
func main() {
ctx := context.Background()
c, err := scheduler.NewCloudSchedulerClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &schedulerpb.PauseJobRequest{
// TODO: Fill request struct fields.
}
resp, err := c.PauseJob(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudSchedulerClient) ResumeJob ¶
func (c *CloudSchedulerClient) ResumeJob(ctx context.Context, req *schedulerpb.ResumeJobRequest, opts ...gax.CallOption) (*schedulerpb.Job, error)
ResumeJob resume a job.
This method reenables a job after it has been [Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED]. The
state of a job is stored in [Job.state][google.cloud.scheduler.v1beta1.Job.state]; after calling this method it
will be set to [Job.State.ENABLED][google.cloud.scheduler.v1beta1.Job.State.ENABLED]. A job must be in
[Job.State.PAUSED][google.cloud.scheduler.v1beta1.Job.State.PAUSED] to be resumed.
Code:play
Example¶
package main
import (
"context"
scheduler "cloud.google.com/go/scheduler/apiv1beta1"
schedulerpb "google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1"
)
func main() {
ctx := context.Background()
c, err := scheduler.NewCloudSchedulerClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &schedulerpb.ResumeJobRequest{
// TODO: Fill request struct fields.
}
resp, err := c.ResumeJob(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudSchedulerClient) RunJob ¶
func (c *CloudSchedulerClient) RunJob(ctx context.Context, req *schedulerpb.RunJobRequest, opts ...gax.CallOption) (*schedulerpb.Job, error)
RunJob forces a job to run now.
When this method is called, Cloud Scheduler will dispatch the job, even
if the job is already running.
Code:play
Example¶
package main
import (
"context"
scheduler "cloud.google.com/go/scheduler/apiv1beta1"
schedulerpb "google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1"
)
func main() {
ctx := context.Background()
c, err := scheduler.NewCloudSchedulerClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &schedulerpb.RunJobRequest{
// TODO: Fill request struct fields.
}
resp, err := c.RunJob(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*CloudSchedulerClient) UpdateJob ¶
func (c *CloudSchedulerClient) UpdateJob(ctx context.Context, req *schedulerpb.UpdateJobRequest, opts ...gax.CallOption) (*schedulerpb.Job, error)
UpdateJob updates a job.
If successful, the updated [Job][google.cloud.scheduler.v1beta1.Job] is returned. If the job does not exist, NOT_FOUND is returned.
If UpdateJob does not successfully return, it is possible for the
job to be in an [Job.State.UPDATE_FAILED][google.cloud.scheduler.v1beta1.Job.State.UPDATE_FAILED] state. A job in this state may
not be executed. If this happens, retry the UpdateJob request
until a successful response is received.
Code:play
Example¶
package main
import (
"context"
scheduler "cloud.google.com/go/scheduler/apiv1beta1"
schedulerpb "google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1"
)
func main() {
ctx := context.Background()
c, err := scheduler.NewCloudSchedulerClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &schedulerpb.UpdateJobRequest{
// TODO: Fill request struct fields.
}
resp, err := c.UpdateJob(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
type JobIterator ¶
type JobIterator struct { // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*schedulerpb.Job, nextPageToken string, err error) // contains filtered or unexported fields }
JobIterator manages a stream of *schedulerpb.Job.
func (*JobIterator) Next ¶
func (it *JobIterator) Next() (*schedulerpb.Job, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*JobIterator) PageInfo ¶
func (it *JobIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
Source Files ¶
cloud_scheduler_client.go doc.go
- Version
- v0.36.0
- Published
- Feb 6, 2019
- Platform
- linux/amd64
- Imports
- 15 packages
- Last checked
- 42 seconds ago –
Tools for package owners.