Add Google APIs typings (#19083)

* Add Google APIs typings

* [gapi.cliebt.* ] Add version as part of typings name and fix gapi.client tslint errors

* versions should not get their own folders
fixing a few typos
using /** syntax so comments show up in editors
export only actual (last) version for now

* export only actual (last) version for now

* merge namespaces and remove unnecessary namespace qualifiers

* remove namespace qualifier for gapi.client.Request from nested namespaces and change Request base interface to Promise

* disable await-promise rule

* fix collision between gapi.client.Request and Request from nested namespace
disable no-irregular-whitespace rule

* sort properties and namespace resources

* remove empty comments
sort resources amd methods in tests and readme.md

* update 'this is autogenerated file' banner to remove this text from gapi.client namespace hint
use multiline comments when comment has several lines

* implement no-trailing-whitespace, no-padding, max-line-length, await-promise, no-irregular-whitespace rules

* add strictFunctionTypes to tsconfig

* fix "Whitespace within parentheses is not allowed" rule

* fix ts-lint rules

* fixes

* remove deprecated replicapool and replicapoolupdater api

* fix no-irregular-whitespace

* fix no-irregular-whitespace
This commit is contained in:
Alexey Bolisov
2017-10-10 00:55:04 +03:00
committed by Wesley Wigham
parent c7a368b276
commit 4f8a3d571b
625 changed files with 208886 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
/* This is stub file for gapi.client.{{=it.name}} definition tests */
/* IMPORTANT.
* This file was automatically generated by https://github.com/Bolisov/google-api-typings-generator. Please do not edit it manually.
* In case of any problems please post issue to https://github.com/Bolisov/google-api-typings-generator
**/
gapi.load('client', () => {
/** now we can use gapi.client */
gapi.client.load('taskqueue', 'v1beta2', () => {
/** now we can use gapi.client.taskqueue */
/** don't forget to authenticate your client before sending any request to resources: */
/** declare client_id registered in Google Developers Console */
const client_id = '<<PUT YOUR CLIENT ID HERE>>';
const scope = [
/** Manage your Tasks and Taskqueues */
'https://www.googleapis.com/auth/taskqueue',
/** Consume Tasks from your Taskqueues */
'https://www.googleapis.com/auth/taskqueue.consumer',
];
const immediate = true;
gapi.auth.authorize({ client_id, scope, immediate }, authResult => {
if (authResult && !authResult.error) {
/** handle succesfull authorization */
run();
} else {
/** handle authorization error */
}
});
run();
});
async function run() {
/** Get detailed information about a TaskQueue. */
await gapi.client.taskqueues.get({
getStats: true,
project: "project",
taskqueue: "taskqueue",
});
/** Delete a task from a TaskQueue. */
await gapi.client.tasks.delete({
project: "project",
task: "task",
taskqueue: "taskqueue",
});
/** Get a particular task from a TaskQueue. */
await gapi.client.tasks.get({
project: "project",
task: "task",
taskqueue: "taskqueue",
});
/** Insert a new task in a TaskQueue */
await gapi.client.tasks.insert({
project: "project",
taskqueue: "taskqueue",
});
/** Lease 1 or more tasks from a TaskQueue. */
await gapi.client.tasks.lease({
groupByTag: true,
leaseSecs: 2,
numTasks: 3,
project: "project",
tag: "tag",
taskqueue: "taskqueue",
});
/** List Tasks in a TaskQueue */
await gapi.client.tasks.list({
project: "project",
taskqueue: "taskqueue",
});
/** Update tasks that are leased out of a TaskQueue. This method supports patch semantics. */
await gapi.client.tasks.patch({
newLeaseSeconds: 1,
project: "project",
task: "task",
taskqueue: "taskqueue",
});
/** Update tasks that are leased out of a TaskQueue. */
await gapi.client.tasks.update({
newLeaseSeconds: 1,
project: "project",
task: "task",
taskqueue: "taskqueue",
});
}
});

300
types/gapi.client.taskqueue/index.d.ts vendored Normal file
View File

@@ -0,0 +1,300 @@
// Type definitions for Google TaskQueue API v1beta2 1.0
// Project: https://developers.google.com/appengine/docs/python/taskqueue/rest
// Definitions by: Bolisov Alexey <https://github.com/Bolisov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// IMPORTANT
// This file was generated by https://github.com/Bolisov/google-api-typings-generator. Please do not edit it manually.
// In case of any problems please post issue to https://github.com/Bolisov/google-api-typings-generator
// Generated from: https://www.googleapis.com/discovery/v1/apis/taskqueue/v1beta2/rest
/// <reference types="gapi.client" />
declare namespace gapi.client {
/** Load TaskQueue API v1beta2 */
function load(name: "taskqueue", version: "v1beta2"): PromiseLike<void>;
function load(name: "taskqueue", version: "v1beta2", callback: () => any): void;
const taskqueues: taskqueue.TaskqueuesResource;
const tasks: taskqueue.TasksResource;
namespace taskqueue {
interface Task {
/** Time (in seconds since the epoch) at which the task was enqueued. */
enqueueTimestamp?: string;
/** Name of the task. */
id?: string;
/** The kind of object returned, in this case set to task. */
kind?: string;
/** Time (in seconds since the epoch) at which the task lease will expire. This value is 0 if the task isnt currently leased out to a worker. */
leaseTimestamp?: string;
/** A bag of bytes which is the task payload. The payload on the JSON side is always Base64 encoded. */
payloadBase64?: string;
/** Name of the queue that the task is in. */
queueName?: string;
/** The number of leases applied to this task. */
retry_count?: number;
/** Tag for the task, could be used later to lease tasks grouped by a specific tag. */
tag?: string;
}
interface TaskQueue {
/** ACLs that are applicable to this TaskQueue object. */
acl?: {
/** Email addresses of users who are "admins" of the TaskQueue. This means they can control the queue, eg set ACLs for the queue. */
adminEmails?: string[];
/** Email addresses of users who can "consume" tasks from the TaskQueue. This means they can Dequeue and Delete tasks from the queue. */
consumerEmails?: string[];
/** Email addresses of users who can "produce" tasks into the TaskQueue. This means they can Insert tasks into the queue. */
producerEmails?: string[];
};
/** Name of the taskqueue. */
id?: string;
/** The kind of REST object returned, in this case taskqueue. */
kind?: string;
/** The number of times we should lease out tasks before giving up on them. If unset we lease them out forever until a worker deletes the task. */
maxLeases?: number;
/** Statistics for the TaskQueue object in question. */
stats?: {
/** Number of tasks leased in the last hour. */
leasedLastHour?: string;
/** Number of tasks leased in the last minute. */
leasedLastMinute?: string;
/** The timestamp (in seconds since the epoch) of the oldest unfinished task. */
oldestTask?: string;
/** Number of tasks in the queue. */
totalTasks?: number;
};
}
interface Tasks {
/** The actual list of tasks returned as a result of the lease operation. */
items?: Task[];
/** The kind of object returned, a list of tasks. */
kind?: string;
}
interface Tasks2 {
/** The actual list of tasks currently active in the TaskQueue. */
items?: Task[];
/** The kind of object returned, a list of tasks. */
kind?: string;
}
interface TaskqueuesResource {
/** Get detailed information about a TaskQueue. */
get(request: {
/** Data format for the response. */
alt?: string;
/** Selector specifying which fields to include in a partial response. */
fields?: string;
/** Whether to get stats. Optional. */
getStats?: boolean;
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
key?: string;
/** OAuth 2.0 token for the current user. */
oauth_token?: string;
/** Returns response with indentations and line breaks. */
prettyPrint?: boolean;
/** The project under which the queue lies. */
project: string;
/**
* Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* Overrides userIp if both are provided.
*/
quotaUser?: string;
/** The id of the taskqueue to get the properties of. */
taskqueue: string;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<TaskQueue>;
}
interface TasksResource {
/** Delete a task from a TaskQueue. */
delete(request: {
/** Data format for the response. */
alt?: string;
/** Selector specifying which fields to include in a partial response. */
fields?: string;
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
key?: string;
/** OAuth 2.0 token for the current user. */
oauth_token?: string;
/** Returns response with indentations and line breaks. */
prettyPrint?: boolean;
/** The project under which the queue lies. */
project: string;
/**
* Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* Overrides userIp if both are provided.
*/
quotaUser?: string;
/** The id of the task to delete. */
task: string;
/** The taskqueue to delete a task from. */
taskqueue: string;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<void>;
/** Get a particular task from a TaskQueue. */
get(request: {
/** Data format for the response. */
alt?: string;
/** Selector specifying which fields to include in a partial response. */
fields?: string;
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
key?: string;
/** OAuth 2.0 token for the current user. */
oauth_token?: string;
/** Returns response with indentations and line breaks. */
prettyPrint?: boolean;
/** The project under which the queue lies. */
project: string;
/**
* Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* Overrides userIp if both are provided.
*/
quotaUser?: string;
/** The task to get properties of. */
task: string;
/** The taskqueue in which the task belongs. */
taskqueue: string;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<Task>;
/** Insert a new task in a TaskQueue */
insert(request: {
/** Data format for the response. */
alt?: string;
/** Selector specifying which fields to include in a partial response. */
fields?: string;
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
key?: string;
/** OAuth 2.0 token for the current user. */
oauth_token?: string;
/** Returns response with indentations and line breaks. */
prettyPrint?: boolean;
/** The project under which the queue lies */
project: string;
/**
* Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* Overrides userIp if both are provided.
*/
quotaUser?: string;
/** The taskqueue to insert the task into */
taskqueue: string;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<Task>;
/** Lease 1 or more tasks from a TaskQueue. */
lease(request: {
/** Data format for the response. */
alt?: string;
/** Selector specifying which fields to include in a partial response. */
fields?: string;
/** When true, all returned tasks will have the same tag */
groupByTag?: boolean;
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
key?: string;
/** The lease in seconds. */
leaseSecs: number;
/** The number of tasks to lease. */
numTasks: number;
/** OAuth 2.0 token for the current user. */
oauth_token?: string;
/** Returns response with indentations and line breaks. */
prettyPrint?: boolean;
/** The project under which the queue lies. */
project: string;
/**
* Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* Overrides userIp if both are provided.
*/
quotaUser?: string;
/**
* The tag allowed for tasks in the response. Must only be specified if group_by_tag is true. If group_by_tag is true and tag is not specified the tag
* will be that of the oldest task by eta, i.e. the first available tag
*/
tag?: string;
/** The taskqueue to lease a task from. */
taskqueue: string;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<Tasks>;
/** List Tasks in a TaskQueue */
list(request: {
/** Data format for the response. */
alt?: string;
/** Selector specifying which fields to include in a partial response. */
fields?: string;
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
key?: string;
/** OAuth 2.0 token for the current user. */
oauth_token?: string;
/** Returns response with indentations and line breaks. */
prettyPrint?: boolean;
/** The project under which the queue lies. */
project: string;
/**
* Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* Overrides userIp if both are provided.
*/
quotaUser?: string;
/** The id of the taskqueue to list tasks from. */
taskqueue: string;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<Tasks2>;
/** Update tasks that are leased out of a TaskQueue. This method supports patch semantics. */
patch(request: {
/** Data format for the response. */
alt?: string;
/** Selector specifying which fields to include in a partial response. */
fields?: string;
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
key?: string;
/** The new lease in seconds. */
newLeaseSeconds: number;
/** OAuth 2.0 token for the current user. */
oauth_token?: string;
/** Returns response with indentations and line breaks. */
prettyPrint?: boolean;
/** The project under which the queue lies. */
project: string;
/**
* Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* Overrides userIp if both are provided.
*/
quotaUser?: string;
task: string;
taskqueue: string;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<Task>;
/** Update tasks that are leased out of a TaskQueue. */
update(request: {
/** Data format for the response. */
alt?: string;
/** Selector specifying which fields to include in a partial response. */
fields?: string;
/** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
key?: string;
/** The new lease in seconds. */
newLeaseSeconds: number;
/** OAuth 2.0 token for the current user. */
oauth_token?: string;
/** Returns response with indentations and line breaks. */
prettyPrint?: boolean;
/** The project under which the queue lies. */
project: string;
/**
* Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
* Overrides userIp if both are provided.
*/
quotaUser?: string;
task: string;
taskqueue: string;
/** IP address of the site where the request originates. Use this if you want to enforce per-user limits. */
userIp?: string;
}): Request<Task>;
}
}
}

View File

@@ -0,0 +1,97 @@
# TypeScript typings for TaskQueue API v1beta2
Accesses a Google App Engine Pull Task Queue over REST.
For detailed description please check [documentation](https://developers.google.com/appengine/docs/python/taskqueue/rest).
## Installing
Install typings for TaskQueue API:
```
npm install @types/gapi.client.taskqueue@v1beta2 --save-dev
```
## Usage
You need to initialize Google API client in your code:
```typescript
gapi.load("client", () => {
// now we can use gapi.client
// ...
});
```
Then load api client wrapper:
```typescript
gapi.client.load('taskqueue', 'v1beta2', () => {
// now we can use gapi.client.taskqueue
// ...
});
```
Don't forget to authenticate your client before sending any request to resources:
```typescript
// declare client_id registered in Google Developers Console
var client_id = '',
scope = [
// Manage your Tasks and Taskqueues
'https://www.googleapis.com/auth/taskqueue',
// Consume Tasks from your Taskqueues
'https://www.googleapis.com/auth/taskqueue.consumer',
],
immediate = true;
// ...
gapi.auth.authorize({ client_id: client_id, scope: scope, immediate: immediate }, authResult => {
if (authResult && !authResult.error) {
/* handle succesfull authorization */
} else {
/* handle authorization error */
}
});
```
After that you can use TaskQueue API resources:
```typescript
/*
Get detailed information about a TaskQueue.
*/
await gapi.client.taskqueues.get({ project: "project", taskqueue: "taskqueue", });
/*
Delete a task from a TaskQueue.
*/
await gapi.client.tasks.delete({ project: "project", task: "task", taskqueue: "taskqueue", });
/*
Get a particular task from a TaskQueue.
*/
await gapi.client.tasks.get({ project: "project", task: "task", taskqueue: "taskqueue", });
/*
Insert a new task in a TaskQueue
*/
await gapi.client.tasks.insert({ project: "project", taskqueue: "taskqueue", });
/*
Lease 1 or more tasks from a TaskQueue.
*/
await gapi.client.tasks.lease({ leaseSecs: 1, numTasks: 1, project: "project", taskqueue: "taskqueue", });
/*
List Tasks in a TaskQueue
*/
await gapi.client.tasks.list({ project: "project", taskqueue: "taskqueue", });
/*
Update tasks that are leased out of a TaskQueue. This method supports patch semantics.
*/
await gapi.client.tasks.patch({ newLeaseSeconds: 1, project: "project", task: "task", taskqueue: "taskqueue", });
/*
Update tasks that are leased out of a TaskQueue.
*/
await gapi.client.tasks.update({ newLeaseSeconds: 1, project: "project", task: "task", taskqueue: "taskqueue", });
```

View File

@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"gapi.client.taskqueue-tests.ts"
]
}

View File

@@ -0,0 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
"interface-name": [false],
"ban-types": [false],
"await-promise": [true, "Request"]
}
}