Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/google-maps-fleetengine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained].
1. [Select or create a Cloud Platform project][projects].
1. [Enable billing for your project][billing].
1. [Enable the Local Rides and Deliveries API API][enable_api].
1. [Set up authentication][auth] so you can access the
1. [Set up authentication with a service account][auth] so you can access the
API from your local workstation.

### Installing the client library
Expand Down Expand Up @@ -318,4 +318,4 @@ See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE)
[projects]: https://console.cloud.google.com/project
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=fleetengine.googleapis.com
[auth]: https://cloud.google.com/docs/authentication/external/set-up-adc-local
[auth]: https://cloud.google.com/docs/authentication/getting-started
3 changes: 0 additions & 3 deletions packages/google-maps-fleetengine/protos/protos.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

129 changes: 122 additions & 7 deletions packages/google-maps-fleetengine/src/v1/trip_service_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallba
import {Transform} from 'stream';
import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
import {loggingUtils as logging} from 'google-gax';

/**
* Client JSON configuration object, loaded from
Expand All @@ -46,6 +47,8 @@ export class TripServiceClient {
private _defaults: {[method: string]: gax.CallSettings};
private _universeDomain: string;
private _servicePath: string;
private _log = logging.log('fleetengine');

auth: gax.GoogleAuth;
descriptors: Descriptors = {
page: {},
Expand Down Expand Up @@ -80,7 +83,7 @@ export class TripServiceClient {
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
* the environment variable GCLOUD_PROJECT for your project ID. If your
* app is running in an environment which supports
* {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
* {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
* your project ID will be detected automatically.
* @param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
Expand Down Expand Up @@ -466,7 +469,25 @@ export class TripServiceClient {
routingParameter
);
this.initialize();
return this.innerApiCalls.createTrip(request, options, callback);
this._log.info('createTrip request %j', request);
const wrappedCallback: Callback<
protos.maps.fleetengine.v1.ITrip,
protos.maps.fleetengine.v1.ICreateTripRequest|null|undefined,
{}|null|undefined>|undefined = callback
? (error, response, options, rawResponse) => {
this._log.info('createTrip response %j', response);
callback!(error, response, options, rawResponse); // We verified callback above.
}
: undefined;
return this.innerApiCalls.createTrip(request, options, wrappedCallback)
?.then(([response, options, rawResponse]: [
protos.maps.fleetengine.v1.ITrip,
protos.maps.fleetengine.v1.ICreateTripRequest|undefined,
{}|undefined
]) => {
this._log.info('createTrip response %j', response);
return [response, options, rawResponse];
});
}
/**
* Get information about a single trip.
Expand Down Expand Up @@ -582,7 +603,25 @@ export class TripServiceClient {
routingParameter
);
this.initialize();
return this.innerApiCalls.getTrip(request, options, callback);
this._log.info('getTrip request %j', request);
const wrappedCallback: Callback<
protos.maps.fleetengine.v1.ITrip,
protos.maps.fleetengine.v1.IGetTripRequest|null|undefined,
{}|null|undefined>|undefined = callback
? (error, response, options, rawResponse) => {
this._log.info('getTrip response %j', response);
callback!(error, response, options, rawResponse); // We verified callback above.
}
: undefined;
return this.innerApiCalls.getTrip(request, options, wrappedCallback)
?.then(([response, options, rawResponse]: [
protos.maps.fleetengine.v1.ITrip,
protos.maps.fleetengine.v1.IGetTripRequest|undefined,
{}|undefined
]) => {
this._log.info('getTrip response %j', response);
return [response, options, rawResponse];
});
}
/**
* Deletes a single Trip.
Expand Down Expand Up @@ -671,7 +710,25 @@ export class TripServiceClient {
routingParameter
);
this.initialize();
return this.innerApiCalls.deleteTrip(request, options, callback);
this._log.info('deleteTrip request %j', request);
const wrappedCallback: Callback<
protos.google.protobuf.IEmpty,
protos.maps.fleetengine.v1.IDeleteTripRequest|null|undefined,
{}|null|undefined>|undefined = callback
? (error, response, options, rawResponse) => {
this._log.info('deleteTrip response %j', response);
callback!(error, response, options, rawResponse); // We verified callback above.
}
: undefined;
return this.innerApiCalls.deleteTrip(request, options, wrappedCallback)
?.then(([response, options, rawResponse]: [
protos.google.protobuf.IEmpty,
protos.maps.fleetengine.v1.IDeleteTripRequest|undefined,
{}|undefined
]) => {
this._log.info('deleteTrip response %j', response);
return [response, options, rawResponse];
});
}
/**
* Report billable trip usage.
Expand Down Expand Up @@ -769,7 +826,25 @@ export class TripServiceClient {
routingParameter
);
this.initialize();
return this.innerApiCalls.reportBillableTrip(request, options, callback);
this._log.info('reportBillableTrip request %j', request);
const wrappedCallback: Callback<
protos.google.protobuf.IEmpty,
protos.maps.fleetengine.v1.IReportBillableTripRequest|null|undefined,
{}|null|undefined>|undefined = callback
? (error, response, options, rawResponse) => {
this._log.info('reportBillableTrip response %j', response);
callback!(error, response, options, rawResponse); // We verified callback above.
}
: undefined;
return this.innerApiCalls.reportBillableTrip(request, options, wrappedCallback)
?.then(([response, options, rawResponse]: [
protos.google.protobuf.IEmpty,
protos.maps.fleetengine.v1.IReportBillableTripRequest|undefined,
{}|undefined
]) => {
this._log.info('reportBillableTrip response %j', response);
return [response, options, rawResponse];
});
}
/**
* Updates trip data.
Expand Down Expand Up @@ -900,7 +975,25 @@ export class TripServiceClient {
routingParameter
);
this.initialize();
return this.innerApiCalls.updateTrip(request, options, callback);
this._log.info('updateTrip request %j', request);
const wrappedCallback: Callback<
protos.maps.fleetengine.v1.ITrip,
protos.maps.fleetengine.v1.IUpdateTripRequest|null|undefined,
{}|null|undefined>|undefined = callback
? (error, response, options, rawResponse) => {
this._log.info('updateTrip response %j', response);
callback!(error, response, options, rawResponse); // We verified callback above.
}
: undefined;
return this.innerApiCalls.updateTrip(request, options, wrappedCallback)
?.then(([response, options, rawResponse]: [
protos.maps.fleetengine.v1.ITrip,
protos.maps.fleetengine.v1.IUpdateTripRequest|undefined,
{}|undefined
]) => {
this._log.info('updateTrip response %j', response);
return [response, options, rawResponse];
});
}

/**
Expand Down Expand Up @@ -1011,7 +1104,26 @@ export class TripServiceClient {
routingParameter
);
this.initialize();
return this.innerApiCalls.searchTrips(request, options, callback);
const wrappedCallback: PaginationCallback<
protos.maps.fleetengine.v1.ISearchTripsRequest,
protos.maps.fleetengine.v1.ISearchTripsResponse|null|undefined,
protos.maps.fleetengine.v1.ITrip>|undefined = callback
? (error, values, nextPageRequest, rawResponse) => {
this._log.info('searchTrips values %j', values);
callback!(error, values, nextPageRequest, rawResponse); // We verified callback above.
}
: undefined;
this._log.info('searchTrips request %j', request);
return this.innerApiCalls
.searchTrips(request, options, wrappedCallback)
?.then(([response, input, output]: [
protos.maps.fleetengine.v1.ITrip[],
protos.maps.fleetengine.v1.ISearchTripsRequest|null,
protos.maps.fleetengine.v1.ISearchTripsResponse
]) => {
this._log.info('searchTrips values %j', response);
return [response, input, output];
});
}

/**
Expand Down Expand Up @@ -1082,6 +1194,7 @@ export class TripServiceClient {
const defaultCallSettings = this._defaults['searchTrips'];
const callSettings = defaultCallSettings.merge(options);
this.initialize();
this._log.info('searchTrips stream %j', request);
return this.descriptors.page.searchTrips.createStream(
this.innerApiCalls.searchTrips as GaxCall,
request,
Expand Down Expand Up @@ -1160,6 +1273,7 @@ export class TripServiceClient {
const defaultCallSettings = this._defaults['searchTrips'];
const callSettings = defaultCallSettings.merge(options);
this.initialize();
this._log.info('searchTrips iterate %j', request);
return this.descriptors.page.searchTrips.asyncIterate(
this.innerApiCalls['searchTrips'] as GaxCall,
request as {},
Expand Down Expand Up @@ -1251,6 +1365,7 @@ export class TripServiceClient {
close(): Promise<void> {
if (this.tripServiceStub && !this._terminated) {
return this.tripServiceStub.then(stub => {
this._log.info('ending gRPC channel');
this._terminated = true;
stub.close();
});
Expand Down
Loading