diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000000..cc6e6cbeb7f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,124 @@ +# Copyright 2021 Google LLC + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# https://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: A workflow for updating discovery artifacts +# Controls when the action will run. + +on: + schedule: + # * is a special character in YAML so you have to quote this string + # Run this Github Action every day at 7 AM UTC + - cron: '0 7 * * *' + +jobs: + build: + name: Update Discovery Artifacts PR + runs-on: ubuntu-latest + steps: + - name: Get current date + id: date + run: echo "::set-output name=current_date::$(date +'%Y-%m-%d')" + + - name: Check out master branch + uses: actions/checkout@v2 + with: + ref: refs/heads/master + + - name: Create branch + run: | + git checkout -b update-discovery-artifacts-${{ steps.date.outputs.current_date }} + + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Install google-api-python-client + run: pip3 install -e . + + - name: Install script dependencies + run: pip3 install -r requirements.txt + working-directory: ./scripts + + # Apply a workaround to discovery.py to avoid DefaultCredentialsError + # which is raised when calling `build_from_document()` as a result of + # `google.auth.default()`. The workaround is to bypass the code block that + # attempts to load default credentials. + - name: Workaround to avoid DefaultCredentialsError in discovery.py + run: sed -i -e 's/if credentials is None/if False/g' googleapiclient/discovery.py + + - name: Run Change Summary + run: python3 updatediscoveryartifacts.py + working-directory: ./scripts + + - name: Commit changes + run: ./createcommits.sh + working-directory: ./scripts + + - name: Push changes + run: git push -f --set-upstream origin update-discovery-artifacts-${{ steps.date.outputs.current_date }} + + - name: Prepare summary for PR Body + id: pr_body + shell: bash + run: | + python3 buildprbody.py + output=$(cat temp/allapis.summary) + output="${output//'%'/'%25'}" + output="${output//$'\n'/'%0A'}" + output="${output//$'\r'/'%0D'}" + echo "::set-output name=change_summary::$output" + working-directory: ./scripts + + - name: Create PR + uses: actions/github-script@v4.0.2 + with: + github-token: ${{secrets.YOSHI_CODE_BOT_TOKEN}} + script: | + async function createPR () { + const { owner, repo } = context.repo + const branch = 'update-discovery-artifacts-${{ steps.date.outputs.current_date }}' + let prBody = `${{ steps.pr_body.outputs.change_summary }}` + const prTitle = 'chore: Update discovery artifacts' + const pullRequests = await github.pulls.list({ + owner: owner, + repo: repo, + head: `${owner}:${branch}`, + state: 'open' + }) + + if (pullRequests.data.length === 1) { + prNumber = pullRequests.data[0].number + await github.pulls.update({ + owner: owner, + repo: repo, + pull_number: prNumber, + title: prTitle, + body: prBody + }) + console.log('Updated PR') + } else { + const createPrResult = await github.pulls.create({ + owner: owner, + repo: repo, + base: 'master', + head: `${owner}:${branch}`, + title: prTitle, + body: prBody + }) + prNumber = createPrResult.data.number + console.log('Created PR') + } + } + createPR() diff --git a/.kokoro/release.sh b/.kokoro/release.sh index 9e91f247ad6..e10bd8921a7 100755 --- a/.kokoro/release.sh +++ b/.kokoro/release.sh @@ -26,7 +26,7 @@ python3 -m pip install --upgrade twine wheel setuptools export PYTHONUNBUFFERED=1 # Move into the package, build the distribution and upload. -TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google_cloud_pypi_password") +TWINE_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secret_manager/google-cloud-pypi-token") cd github/google-api-python-client python3 setup.py sdist bdist_wheel -twine upload --username gcloudpypi --password "${TWINE_PASSWORD}" dist/* +twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/* diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg index 3efc6f3bb57..2ea8e554f8d 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -23,18 +23,8 @@ env_vars: { value: "github/google-api-python-client/.kokoro/release.sh" } -# Fetch PyPI password -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "google_cloud_pypi_password" - } - } -} - # Tokens needed to report release status back to GitHub env_vars: { key: "SECRET_MANAGER_KEYS" - value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" -} \ No newline at end of file + value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,google-cloud-pypi-token" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 4150d8855a5..dff7ecd3353 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [2.3.0](https://www.github.com/googleapis/google-api-python-client/compare/v2.2.0...v2.3.0) (2021-04-28) + + +### Features + +* **apigee:** update the api ([3fd11cb](https://www.github.com/googleapis/google-api-python-client/commit/3fd11cbfa43679d14be7f09d9cb071d82d156ffa)) +* **dataflow:** update the api ([3fd11cb](https://www.github.com/googleapis/google-api-python-client/commit/3fd11cbfa43679d14be7f09d9cb071d82d156ffa)) +* **dialogflow:** update the api ([3fd11cb](https://www.github.com/googleapis/google-api-python-client/commit/3fd11cbfa43679d14be7f09d9cb071d82d156ffa)) +* **documentai:** update the api ([3fd11cb](https://www.github.com/googleapis/google-api-python-client/commit/3fd11cbfa43679d14be7f09d9cb071d82d156ffa)) +* **healthcare:** update the api ([3fd11cb](https://www.github.com/googleapis/google-api-python-client/commit/3fd11cbfa43679d14be7f09d9cb071d82d156ffa)) +* **osconfig:** update the api ([afea316](https://www.github.com/googleapis/google-api-python-client/commit/afea316d32842ecb9e7d626842d5926b0bf3e34f)) +* **sqladmin:** update the api ([cec4393](https://www.github.com/googleapis/google-api-python-client/commit/cec4393b8e37e229f68b2233a2041db062c2a335)) + ## [2.2.0](https://www.github.com/googleapis/google-api-python-client/compare/v2.1.0...v2.2.0) (2021-04-13) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000000..8b58ae9c01a --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,7 @@ +# Security Policy + +To report a security issue, please use [g.co/vulnz](https://g.co/vulnz). + +The Google Security Team will respond within 5 working days of your report on g.co/vulnz. + +We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue. diff --git a/describe.py b/describe.py index e53724e0494..1f846fd881c 100755 --- a/describe.py +++ b/describe.py @@ -28,7 +28,7 @@ import argparse import collections import json -import os +import pathlib import re import string import sys @@ -37,12 +37,15 @@ from googleapiclient.discovery import build from googleapiclient.discovery import build_from_document from googleapiclient.discovery import UnknownApiNameOrVersion -from googleapiclient.discovery_cache import get_static_doc from googleapiclient.http import build_http from googleapiclient.errors import HttpError import uritemplate +DISCOVERY_DOC_DIR = ( + pathlib.Path(__file__).parent.resolve() / "googleapiclient" / "discovery_cache" / "documents" +) + CSS = """ + +
+ close()
Close httplib2 connections.
+
+ list(parent, pageSize=None, pageToken=None, x__xgafv=None)
List the ad units under the specified AdMob account.
+
+ list_next(previous_request, previous_response)
Retrieves the next page of results.
+close()
+ Close httplib2 connections.+
list(parent, pageSize=None, pageToken=None, x__xgafv=None)
+ List the ad units under the specified AdMob account. + +Args: + parent: string, Required. Resource name of the account to list ad units for. Example: accounts/pub-9876543210987654 (required) + pageSize: integer, The maximum number of ad units to return. If unspecified or 0, at most 1000 ad units will be returned. The maximum value is 10,000; values above 10,000 will be coerced to 10,000. + pageToken: string, The value returned by the last `ListAdUnitsResponse`; indicates that this is a continuation of a prior `ListAdUnits` call, and that the system should return the next page of data. + x__xgafv: string, V1 error format. + Allowed values + 1 - v1 error format + 2 - v2 error format + +Returns: + An object of the form: + + { # Response for the ad units list request. + "adUnits": [ # The resulting ad units for the requested account. + { # Describes an AdMob ad unit. + "adFormat": "A String", # AdFormat of the ad unit. Possible values are as follows: "BANNER" - Banner ad format. "BANNER_INTERSTITIAL" - Legacy format that can be used as either banner or interstitial. This format can no longer be created but can be targeted by mediation groups. "INTERSTITIAL" - A full screen ad. Supported ad types are "RICH_MEDIA" and "VIDEO". "NATIVE" - Native ad format. "REWARDED" - An ad that, once viewed, gets a callback verifying the view so that a reward can be given to the user. Supported ad types are "RICH_MEDIA" (interactive) and video where video can not be excluded. + "adTypes": [ # Ad media type supported by this ad unit. Possible values as follows: "RICH_MEDIA" - Text, image, and other non-video media. "VIDEO" - Video media. + "A String", + ], + "adUnitId": "A String", # The externally visible ID of the ad unit which can be used to integrate with the AdMob SDK. This is a read only property. Example: ca-app-pub-9876543210987654/0123456789 + "appId": "A String", # The externally visible ID of the app this ad unit is associated with. Example: ca-app-pub-9876543210987654~0123456789 + "displayName": "A String", # The display name of the ad unit as shown in the AdMob UI, which is provided by the user. The maximum length allowed is 80 characters. + "name": "A String", # Resource name for this ad unit. Format is accounts/{publisher_id}/adUnits/{ad_unit_id_fragment} Example: accounts/pub-9876543210987654/adUnits/0123456789 + }, + ], + "nextPageToken": "A String", # If not empty, indicates that there may be more ad units for the request; this value should be passed in a new `ListAdUnitsRequest`. +}+
list_next(previous_request, previous_response)
+ Retrieves the next page of results. + +Args: + previous_request: The request for the previous page. (required) + previous_response: The response from the request for the previous page. (required) + +Returns: + A request object that you can call 'execute()' on to request the next + page. Returns None if there are no more items in the collection. ++