googleapis/nodejs-scheduler

Make it easier to access the protocol definition

Closed this issue · 2 comments

I need to get at the Job State enum (ENABLED, PAUSED etc). But the protos are not exported through the package entry point, I'd have to load the "@google-cloud/scheduler/build/protos/protos.js" file directly. That seems a break in abstraction if I have to reach to a private file somewhere in the build directory.

Here is an example where I need State.ENABLED:

const [job] = await client.getJob({ name: jobPath })
if (shouldRun && job.state !== XXX.State.ENABLED) {
  await client.resumeJob({ name: jobPath });
  await client.runJob({ name: jobPath });
}

Thanks @wereHamster, we have this in plans. I can promise that the location of the files (build/protos/protos.js, build/protos/protos.d.ts) will not change without a major version bump :)

For now, we suggest this (for TypeScript):

import * as protos from '@google-cloud/scheduler/build/protos/protos';

googleapis/gapic-generator-typescript#294 is a tracking issue for this request.