Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
50 changes: 50 additions & 0 deletions .github/workflows/create_updated_stubs_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Create updated stubs PR

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # every Sunday at midnight

jobs:
create_pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5

- name: Install uv
uses: astral-sh/setup-uv@v2
with:
enable-cache: true

- name: Update stubs
run: uv run python create_stubs.py

- name: Detect changes
id: changes
run: |
if git diff --quiet; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
fi

- name: Bump minor version in pyproject.toml
if: steps.changes.outputs.has_changes == 'true'
run: uv version --bump minor

- name: Create pull request
if: steps.changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0
with:
token: ${{ secrets.PR_TOKEN }}
commit-message: Update stubs
author: henribru <6639509+henribru@users.noreply.github.com>
committer: henribru <6639509+henribru@users.noreply.github.com>
branch: create-updated-stubs-pr
delete-branch: true
title: Update stubs


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
!/README.md
!/LICENSE
!/create_stubs.py
!discovery.pyi
8 changes: 5 additions & 3 deletions create_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
import json
import keyword
import os
import re
import shutil
import subprocess
import textwrap
from contextlib import contextmanager
from pathlib import Path
from typing import Any, DefaultDict, Dict, List, Set

from mypy.api import run

from googleapiclient.discovery import fix_method_name, key2param


Expand Down Expand Up @@ -397,6 +394,11 @@ def copytree(src, dst, symlinks=False, ignore=None, overwrite=True):


def main():
subprocess.run(["uv", "remove", "google-api-python-client"])
subprocess.run(["uv", "add", "google-api-python-client"])
subprocess.run(["git", "clone", "https://github.com/googleapis/google-api-python-client.git"]);
subprocess.run(["git", "restore", "."], cwd="google-api-python-client")
subprocess.run(["git", "pull"], cwd="google-api-python-client")
shutil.rmtree("apiclient-stubs", ignore_errors=True)
apis = []
ignored_apis = [
Expand Down
67 changes: 67 additions & 0 deletions discovery.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import types
from email.generator import BytesGenerator
from typing import Any, Protocol, TypeVar, overload

import google.auth.credentials
import httplib2
import oauth2client # type: ignore[import-not-found]
from _typeshed import Incomplete
from google.api_core.client_options import ClientOptions
from typing_extensions import Literal

from googleapiclient.discovery_cache.base import Cache
from googleapiclient.http import HttpMock, HttpRequest
from googleapiclient.model import Model

_T = TypeVar("_T")

class _BytesGenerator(BytesGenerator): ...

def fix_method_name(name): ...
def key2param(key): ...

class ResourceMethodParameters:
argmap: Incomplete
required_params: Incomplete
repeated_params: Incomplete
pattern_params: Incomplete
query_params: Incomplete
path_params: Incomplete
param_types: Incomplete
enum_params: Incomplete
def __init__(self, method_desc) -> None: ...
def set_parameters(self, method_desc) -> None: ...

class Resource:
def __init__(
self,
http,
baseUrl,
model,
requestBuilder,
developerKey,
resourceDesc,
rootDesc,
schema,
) -> None: ...
def __enter__(self: _T) -> _T: ...
def __exit__(
self,
exc_type: type[BaseException] | None,
exc: BaseException | None,
exc_tb: types.TracebackType | None,
) -> None: ...
def close(self) -> None: ...

class _RequestBuilder(Protocol):
def __call__(
self,
http,
postproc,
uri,
method: str = ...,
body: Incomplete | None = ...,
headers: Incomplete | None = ...,
methodId: Incomplete | None = ...,
resumable: Incomplete | None = ...,
) -> HttpRequest: ...
1 change: 1 addition & 0 deletions google-api-python-client
Submodule google-api-python-client added at 7c2030
4 changes: 4 additions & 0 deletions googleapiclient-stubs/_apis/accessapproval/v1/schemas.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class AccessApprovalServiceAccount(typing_extensions.TypedDict, total=False):
class AccessApprovalSettings(typing_extensions.TypedDict, total=False):
activeKeyVersion: str
ancestorHasActiveKeyVersion: bool
ancestorsEnrolledServices: _list[EnrolledService]
approvalPolicy: CustomerApprovalApprovalPolicy
effectiveApprovalPolicy: CustomerApprovalApprovalPolicy
enrolledAncestor: bool
Expand Down Expand Up @@ -168,6 +169,9 @@ class SignatureInfo(typing_extensions.TypedDict, total=False):
"PQ_SIGN_ML_DSA_87",
"PQ_SIGN_SLH_DSA_SHA2_128S",
"PQ_SIGN_HASH_SLH_DSA_SHA2_128S_SHA256",
"PQ_SIGN_ML_DSA_44_EXTERNAL_MU",
"PQ_SIGN_ML_DSA_65_EXTERNAL_MU",
"PQ_SIGN_ML_DSA_87_EXTERNAL_MU",
]
googlePublicKeyPem: str
serializedApprovalRequest: str
Expand Down
3 changes: 3 additions & 0 deletions googleapiclient-stubs/_apis/admin/directory_v1/resources.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,9 @@ class DirectoryResource(googleapiclient.discovery.Resource):
self, *, userKey: str, body: UserPhoto = ..., **kwargs: typing.Any
) -> UserPhotoHttpRequest: ...

def createGuest(
self, *, body: DirectoryUsersCreateGuestRequest = ..., **kwargs: typing.Any
) -> UserHttpRequest: ...
def delete(
self, *, userKey: str, **kwargs: typing.Any
) -> googleapiclient.http.HttpRequest: ...
Expand Down
17 changes: 17 additions & 0 deletions googleapiclient-stubs/_apis/admin/directory_v1/schemas.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ class BatchDeletePrintersResponse(typing_extensions.TypedDict, total=False):
failedPrinters: _list[FailureInfo]
printerIds: _list[str]

@typing.type_check_only
class BluetoothAdapterInfo(typing_extensions.TypedDict, total=False):
address: str
numConnectedDevices: int

@typing.type_check_only
class Building(typing_extensions.TypedDict, total=False):
address: BuildingAddress
Expand Down Expand Up @@ -205,6 +210,7 @@ class ChromeOsDevice(typing_extensions.TypedDict, total=False):
autoUpdateExpiration: str
autoUpdateThrough: str
backlightInfo: _list[BacklightInfo]
bluetoothAdapterInfo: _list[BluetoothAdapterInfo]
bootMode: str
chromeOsType: typing_extensions.Literal[
"chromeOsTypeUnspecified", "chromeOsFlex", "chromeOs"
Expand Down Expand Up @@ -391,6 +397,11 @@ class DirectoryChromeosdevicesIssueCommandResponse(
):
commandId: str

@typing.type_check_only
class DirectoryUsersCreateGuestRequest(typing_extensions.TypedDict, total=False):
customer: str
primaryGuestEmail: str

@typing.type_check_only
class DomainAlias(typing_extensions.TypedDict, total=False):
creationTime: str
Expand Down Expand Up @@ -503,6 +514,10 @@ class Groups(typing_extensions.TypedDict, total=False):
kind: str
nextPageToken: str

@typing.type_check_only
class GuestAccountInfo(typing_extensions.TypedDict, total=False):
primaryGuestEmail: str

@typing.type_check_only
class ListPrintServersResponse(typing_extensions.TypedDict, total=False):
nextPageToken: str
Expand Down Expand Up @@ -799,6 +814,7 @@ class User(typing_extensions.TypedDict, total=False):
etag: str
externalIds: typing.Any
gender: typing.Any
guestAccountInfo: GuestAccountInfo
hashFunction: str
id: str
ims: typing.Any
Expand All @@ -808,6 +824,7 @@ class User(typing_extensions.TypedDict, total=False):
isDelegatedAdmin: bool
isEnforcedIn2Sv: bool
isEnrolledIn2Sv: bool
isGuestUser: bool
isMailboxSetup: bool
keywords: typing.Any
kind: str
Expand Down
14 changes: 14 additions & 0 deletions googleapiclient-stubs/_apis/admin/reports_v1/resources.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ class ReportsResource(googleapiclient.discovery.Resource):
"vault",
"gemini_in_workspace_apps",
"classroom",
"assignments",
"cloud_search",
"tasks",
"data_migration",
"meet_hardware",
"directory_sync",
"ldap",
"profile",
"access_evaluation",
"admin_data_action",
"contacts",
"takeout",
"graduation",
],
actorIpAddress: str = ...,
customerId: str = ...,
Expand All @@ -55,6 +68,7 @@ class ReportsResource(googleapiclient.discovery.Resource):
maxResults: int = ...,
orgUnitID: str = ...,
pageToken: str = ...,
resourceDetailsFilter: str = ...,
startTime: str = ...,
**kwargs: typing.Any,
) -> ActivitiesHttpRequest: ...
Expand Down
24 changes: 24 additions & 0 deletions googleapiclient-stubs/_apis/adsense/v2/resources.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ class AdsenseResource(googleapiclient.discovery.Resource):
"CUSTOM_SEARCH_STYLE_ID",
"DOMAIN_REGISTRANT",
"WEBSEARCH_QUERY_STRING",
"OS_TYPE_NAME",
"OS_TYPE_CODE",
"BROWSER_TYPE_NAME",
"BROWSER_TYPE_CODE",
"WEBVIEW_TYPE_NAME",
"WEBVIEW_TYPE_CODE",
]
| _list[
typing_extensions.Literal[
Expand Down Expand Up @@ -383,6 +389,12 @@ class AdsenseResource(googleapiclient.discovery.Resource):
"CUSTOM_SEARCH_STYLE_ID",
"DOMAIN_REGISTRANT",
"WEBSEARCH_QUERY_STRING",
"OS_TYPE_NAME",
"OS_TYPE_CODE",
"BROWSER_TYPE_NAME",
"BROWSER_TYPE_CODE",
"WEBVIEW_TYPE_NAME",
"WEBVIEW_TYPE_CODE",
]
] = ...,
endDate_day: int = ...,
Expand Down Expand Up @@ -549,6 +561,12 @@ class AdsenseResource(googleapiclient.discovery.Resource):
"CUSTOM_SEARCH_STYLE_ID",
"DOMAIN_REGISTRANT",
"WEBSEARCH_QUERY_STRING",
"OS_TYPE_NAME",
"OS_TYPE_CODE",
"BROWSER_TYPE_NAME",
"BROWSER_TYPE_CODE",
"WEBVIEW_TYPE_NAME",
"WEBVIEW_TYPE_CODE",
]
| _list[
typing_extensions.Literal[
Expand Down Expand Up @@ -603,6 +621,12 @@ class AdsenseResource(googleapiclient.discovery.Resource):
"CUSTOM_SEARCH_STYLE_ID",
"DOMAIN_REGISTRANT",
"WEBSEARCH_QUERY_STRING",
"OS_TYPE_NAME",
"OS_TYPE_CODE",
"BROWSER_TYPE_NAME",
"BROWSER_TYPE_CODE",
"WEBVIEW_TYPE_NAME",
"WEBVIEW_TYPE_CODE",
]
] = ...,
endDate_day: int = ...,
Expand Down
Loading
Loading