From 16ff92ca4e29f5fec7f5c0be4fae957a307d73cf Mon Sep 17 00:00:00 2001 From: Matt Pollard Date: Tue, 22 Jun 2021 10:47:29 +0200 Subject: [PATCH] Replace explicit mentions of `api` subdomain for GitHub Enterprise Server and GitHub AE documentation (#20013) --- .../reference/authentication-in-a-workflow.md | 12 +++++----- ...g-user-provisioning-for-your-enterprise.md | 2 +- ...ment-environment-to-create-a-github-app.md | 2 +- .../apps/guides/using-content-attachments.md | 22 +++++++++---------- .../getting-started-with-the-rest-api.md | 4 +++- .../rest/guides/traversing-with-pagination.md | 12 +++++----- .../github-insights/enterprise-api-url.md | 2 +- .../rest-api/dotcom-only-guide-note.md | 13 +++++++++++ data/variables/product.yml | 4 ++-- 9 files changed, 44 insertions(+), 29 deletions(-) create mode 100644 data/reusables/rest-api/dotcom-only-guide-note.md diff --git a/content/actions/reference/authentication-in-a-workflow.md b/content/actions/reference/authentication-in-a-workflow.md index cf6b0ffe7b51..a6a4a66b7826 100644 --- a/content/actions/reference/authentication-in-a-workflow.md +++ b/content/actions/reference/authentication-in-a-workflow.md @@ -79,16 +79,16 @@ jobs: issues: write {% endif %} steps: - name: Create issue using REST API - run: {% raw %}| + run: | curl --request POST \ - --url https://api.github.com/repos/${{ github.repository }}/issues \ - --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + --url {% data variables.product.api_url_code %}/repos/${% raw %}{{ github.repository }}{% endraw %}/issues \ + --header 'authorization: Bearer ${% raw %}{{ secrets.GITHUB_TOKEN }}{% endraw %}' \ --header 'content-type: application/json' \ --data '{ - "title": "Automated issue for commit: ${{ github.sha }}", - "body": "This issue was automatically created by the GitHub Action workflow **${{ github.workflow }}**. \n\n The commit hash was: _${{ github.sha }}_." + "title": "Automated issue for commit: ${% raw %}{{ github.sha }}{% endraw %}", + "body": "This issue was automatically created by the GitHub Action workflow **${% raw %}{{ github.workflow }}{% endraw %}**. \n\n The commit hash was: _${% raw %}{{ github.sha }}{% endraw %}_." }' \ - --fail{% endraw %} + --fail ``` ## Permissions for the `GITHUB_TOKEN` diff --git a/content/admin/authentication/managing-identity-and-access-for-your-enterprise/configuring-user-provisioning-for-your-enterprise.md b/content/admin/authentication/managing-identity-and-access-for-your-enterprise/configuring-user-provisioning-for-your-enterprise.md index d9128aa9de03..c4e48243ff3c 100644 --- a/content/admin/authentication/managing-identity-and-access-for-your-enterprise/configuring-user-provisioning-for-your-enterprise.md +++ b/content/admin/authentication/managing-identity-and-access-for-your-enterprise/configuring-user-provisioning-for-your-enterprise.md @@ -84,7 +84,7 @@ You must have administrative access on your IdP to configure the application for | Value | Other names | Description | Example | | :- | :- | :- | :- | - | URL | Tenant URL | URL to the SCIM provisioning API for your enterprise on {% data variables.product.prodname_ghe_managed %} |
https://api.YOUR-GITHUB-AE-HOSTNAME/scim/v2
| + | URL | Tenant URL | URL to the SCIM provisioning API for your enterprise on {% data variables.product.prodname_ghe_managed %} | {% data variables.product.api_url_pre %} | | Shared secret | Personal access token, secret token | Token for application on your IdP to perform provisioning tasks on behalf of an enterprise owner | Personal access token you created in step 1 | {% endif %} diff --git a/content/developers/apps/getting-started-with-apps/setting-up-your-development-environment-to-create-a-github-app.md b/content/developers/apps/getting-started-with-apps/setting-up-your-development-environment-to-create-a-github-app.md index 235e02685729..c3b3eb9bfa8f 100644 --- a/content/developers/apps/getting-started-with-apps/setting-up-your-development-environment-to-create-a-github-app.md +++ b/content/developers/apps/getting-started-with-apps/setting-up-your-development-environment-to-create-a-github-app.md @@ -426,7 +426,7 @@ Here are a few common problems and some suggested solutions. If you run into any * **Q:** I'm getting an `Octokit::NotFound` 404 error in my debug output: ``` - 2018-12-06 15:00:56 - Octokit::NotFound - POST https://api.github.com/app/installations/500991/access_tokens: 404 - Not Found // See: /v3/apps/#create-a-new-installation-token: + 2018-12-06 15:00:56 - Octokit::NotFound - POST {% data variables.product.api_url_code %}/app/installations/500991/access_tokens: 404 - Not Found // See: /v3/apps/#create-a-new-installation-token: ``` **A:** Ensure the variables in your `.env` file are correct. Make sure that you have not set identical variables in any other environment variable files like `bash_profile`. You can check the environment variables your app is using by adding `puts` statements to your app code and re-running the code. For example, to ensure you have the correct private key set, you could add `puts PRIVATE_KEY` to your app code: diff --git a/content/developers/apps/guides/using-content-attachments.md b/content/developers/apps/guides/using-content-attachments.md index 3b36d827fe65..38fe4f1237fd 100644 --- a/content/developers/apps/guides/using-content-attachments.md +++ b/content/developers/apps/guides/using-content-attachments.md @@ -66,16 +66,16 @@ The content attachment flow shows you the relationship between the URL in the is The `body` parameter can contain markdown: - ```shell - curl -X POST \ - https://api.github.com/repos/Codertocat/Hello-World/content_references/17/attachments \ - -H 'Accept: application/vnd.github.corsair-preview+json' \ - -H 'Authorization: Bearer $INSTALLATION_TOKEN' \ - -d '{ - "title": "[A-1234] Error found in core/models.py file", - "body": "You have used an email that already exists for the user_email_uniq field.\n ## DETAILS:\n\nThe (email)=(Octocat@github.com) already exists.\n\n The error was found in core/models.py in get_or_create_user at line 62.\n\n self.save()" - }' - ``` +```shell +curl -X POST \ + {% data variables.product.api_url_code %}/repos/Codertocat/Hello-World/content_references/17/attachments \ + -H 'Accept: application/vnd.github.corsair-preview+json' \ + -H 'Authorization: Bearer $INSTALLATION_TOKEN' \ + -d '{ + "title": "[A-1234] Error found in core/models.py file", + "body": "You have used an email that already exists for the user_email_uniq field.\n ## DETAILS:\n\nThe (email)=(Octocat@github.com) already exists.\n\n The error was found in core/models.py in get_or_create_user at line 62.\n\n self.save()" +}' +``` For more information about creating an installation token, see "[Authenticating as a GitHub App](/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation)." @@ -111,7 +111,7 @@ mutation { Example cURL: ```shell -curl -X "POST" "https://api.github.com/graphql" \ +curl -X "POST" "{% data variables.product.api_url_code %}/graphql" \ -H 'Authorization: Bearer $INSTALLATION_TOKEN' \ -H 'Accept: application/vnd.github.corsair-preview+json' \ -H 'Content-Type: application/json; charset=utf-8' \ diff --git a/content/rest/guides/getting-started-with-the-rest-api.md b/content/rest/guides/getting-started-with-the-rest-api.md index f5f6dc0fa4d8..a4bbf05b53be 100644 --- a/content/rest/guides/getting-started-with-the-rest-api.md +++ b/content/rest/guides/getting-started-with-the-rest-api.md @@ -13,7 +13,9 @@ topics: --- -Let's walk through core API concepts as we tackle some everyday use cases. +Let's walk through core API concepts as we tackle some everyday use cases. + +{% data reusables.rest-api.dotcom-only-guide-note %} ## Overview diff --git a/content/rest/guides/traversing-with-pagination.md b/content/rest/guides/traversing-with-pagination.md index a49b04e1bfd1..8d32240dfc78 100644 --- a/content/rest/guides/traversing-with-pagination.md +++ b/content/rest/guides/traversing-with-pagination.md @@ -12,16 +12,16 @@ topics: - API --- - - The {% data variables.product.product_name %} API provides a vast wealth of information for developers to consume. Most of the time, you might even find that you're asking for _too much_ information, and in order to keep our servers happy, the API will automatically [paginate the requested items][pagination]. -In this guide, we'll make some calls to the {% data variables.product.product_name %} Search API, and iterate over +In this guide, we'll make some calls to the Search API, and iterate over the results using pagination. You can find the complete source code for this project in the [platform-samples][platform samples] repository. +{% data reusables.rest-api.dotcom-only-guide-note %} + ## Basics of Pagination To start with, it's important to know a few facts about receiving paginated items: @@ -40,7 +40,7 @@ of an API call. For example, let's make a curl request to the search API, to fin out how many times Mozilla projects use the phrase `addClass`: ```shell -$ curl -I "{% data variables.product.api_url_pre %}/search/code?q=addClass+user:mozilla" +$ curl -I "https://api.github.com/search/code?q=addClass+user:mozilla" ``` The `-I` parameter indicates that we only care about the headers, not the actual @@ -66,7 +66,7 @@ parameter. By default, `page` always starts at `1`. Let's jump ahead to page 14 and see what happens: ```shell -$ curl -I "{% data variables.product.api_url_pre %}/search/code?q=addClass+user:mozilla&page=14" +$ curl -I "https://api.github.com/search/code?q=addClass+user:mozilla&page=14" ``` Here's the link header once more: @@ -88,7 +88,7 @@ By passing the `per_page` parameter, you can specify how many items you want each page to return, up to 100 items. Let's try asking for 50 items about `addClass`: ```shell -$ curl -I "{% data variables.product.api_url_pre %}/search/code?q=addClass+user:mozilla&per_page=50" +$ curl -I "https://api.github.com/search/code?q=addClass+user:mozilla&per_page=50" ``` Notice what it does to the header response: diff --git a/data/reusables/github-insights/enterprise-api-url.md b/data/reusables/github-insights/enterprise-api-url.md index 837dc323a77e..061c6b351b46 100644 --- a/data/reusables/github-insights/enterprise-api-url.md +++ b/data/reusables/github-insights/enterprise-api-url.md @@ -1,2 +1,2 @@ -1. Under "{% data variables.product.prodname_dotcom %} API URL", type {% if currentVersion == "free-pro-team@latest" %}https://api.github.com {% else %}the URL you use to access {% data variables.product.prodname_enterprise %}{% endif %}. +1. Under "{% data variables.product.prodname_dotcom %} API URL", type {% if currentVersion == "free-pro-team@latest" %}https://api.github.com{% else %}the URL you use to access {% data variables.product.product_name %}{% endif %}. ![{% data variables.product.prodname_enterprise %} API URL field](/assets/images/help/insights/enterprise-api-url.png) diff --git a/data/reusables/rest-api/dotcom-only-guide-note.md b/data/reusables/rest-api/dotcom-only-guide-note.md new file mode 100644 index 000000000000..337cff1adf3f --- /dev/null +++ b/data/reusables/rest-api/dotcom-only-guide-note.md @@ -0,0 +1,13 @@ +{% if currentVersion != "free-pro-team@latest" %} + +{% note %} + +**Note**: The following guide uses the REST API for {% data variables.product.prodname_dotcom_the_website %}. + +- Use {% data variables.product.api_url_pre %} to access the API for {% data variables.product.product_name %}. + +- The guide specifies usernames and repositories that may not exist on {% data variables.product.product_location %}. You may need to use different names to see similar output. + +{% endnote %} + +{% endif %} diff --git a/data/variables/product.yml b/data/variables/product.yml index 0279f84228a9..db6d2517885e 100644 --- a/data/variables/product.yml +++ b/data/variables/product.yml @@ -188,7 +188,7 @@ doc_url_pre: >- {% if currentVersion == "free-pro-team@latest" %}https://docs.github.com/rest{% elsif enterpriseServerVersions contains currentVersion %}https://docs.github.com/enterprise/{{ currentVersion | version_num }}/rest{% elsif currentVersion == "github-ae@latest" %}https://docs.github.com/github-ae@latest/rest{% endif %} # Use this inside command-line code blocks api_url_pre: >- - {% if currentVersion == "free-pro-team@latest" %}https://api.github.com{% elsif enterpriseServerVersions contains currentVersion %}http(s)://[hostname]/api/v3{% elsif currentVersion == "github-ae@latest" %}https://api.[hostname]{% endif %} + {% if currentVersion == "free-pro-team@latest" %}https://api.github.com{% elsif enterpriseServerVersions contains currentVersion %}http(s)://[hostname]/api/v3{% elsif currentVersion == "github-ae@latest" %}https://[hostname]/api/v3{% endif %} # Use this inside command-line code blocks # Enterprise OAuth paths that don't include "/graphql" or "/api/v3" oauth_host_code: >- @@ -197,7 +197,7 @@ device_authorization_url: >- {% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.21" or currentVersion == "github-ae@latest" %}[`https://github.com/login/device`](https://github.com/login/device){% else %}`http(s)://[hostname]/login/device`{% endif %} # Use this all other code blocks api_url_code: >- - {% if currentVersion == "free-pro-team@latest" %}https://api.github.com{% elsif enterpriseServerVersions contains currentVersion %}http(s)://[hostname]/api/v3{% elsif currentVersion == "github-ae@latest" %}https://api.[hostname]{% endif %} + {% if currentVersion == "free-pro-team@latest" %}https://api.github.com{% elsif enterpriseServerVersions contains currentVersion %}http(s)://[hostname]/api/v3{% elsif currentVersion == "github-ae@latest" %}https://[hostname]/api/v3{% endif %} # Use this inside command-line code blocks graphql_url_pre: >- {% if currentVersion == "free-pro-team@latest" %}https://api.github.com/graphql{% elsif enterpriseServerVersions contains currentVersion %}http(s)://[hostname]/api/graphql{% elsif currentVersion == "github-ae@latest" %}https://api.[hostname]/graphql{% endif %}