GitHub Policies API

The Policies API from GitHub — 3 operation(s) for policies.

Documentation

📖
Documentation
https://docs.github.com/en/rest/apps
📖
Documentation
https://docs.github.com/en/rest/codes-of-conduct/codes-of-conduct
📖
Documentation
https://docs.github.com/en/rest/emojis
📖
Documentation
https://docs.github.com/en/rest/gitignore
📖
Documentation
https://docs.github.com/en/rest/apps/installations
📖
Documentation
https://docs.github.com/en/rest/enterprise-admin
📖
Documentation
https://docs.github.com/en/rest/activity/events
📖
Documentation
https://docs.github.com/en/rest/orgs
📖
Documentation
https://docs.github.com/en/rest/rate-limit
📖
Documentation
https://docs.github.com/en/enterprise-cloud@latest/rest/scim
📖
Documentation
https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api
📖
Documentation
https://docs.github.com/en/rest/teams
📖
Documentation
https://docs.github.com/en/rest/meta/meta
📖
Documentation
https://docs.github.com/en/rest/actions
📖
Documentation
https://docs.github.com/en/rest/branches
📖
Documentation
https://docs.github.com/en/rest/code-scanning
📖
Documentation
https://docs.github.com/en/rest/collaborators
📖
Documentation
https://docs.github.com/en/rest/dependabot
📖
Documentation
https://docs.github.com/en/rest/webhooks
📖
Documentation
https://docs.github.com/en/rest/pulls
📖
Documentation
https://docs.github.com/en/rest/git/tags
📖
Documentation
https://docs.github.com/en/rest/repos/autolinks
📖
Documentation
https://docs.github.com/en/rest/collaborators/invitations

Specifications

Other Resources

OpenAPI Specification

github-policies-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Github Policies API
  version: 1.1.4
  contact:
    name: Support
    url: https://support.github.com/contact
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT
  termsOfService: https://docs.github.com/articles/github-terms-of-service
  description: 'Operations tagged Policies across 2 of this provider''s published API definitions: github-repo-actions-api-openapi.yml, github-repo-tags-api-openapi.yml. Each path carries the servers of the definition it was published in.'
servers:
- url: '{protocol}://{hostname}'
  variables:
    hostname:
      description: Self-hosted Enterprise Server hostname
      default: api.github.com
    protocol:
      description: Self-hosted Enterprise Server protocol
      default: https
tags:
- name: Policies
paths:
  /repos/{owner}/{repo}/actions/cache/usage-policy:
    get:
      summary: GitHub Get Github Actions Cache Usage Policy for Repository
      description: 'Gets GitHub Actions cache usage policy for a repository.


        OAuth tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.'
      tags:
      - Policies
      operationId: getGithubActionsCacheUsagePolicyForRepository
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/actions/cache#get-github-actions-cache-usage-policy-for-a-repository
      parameters:
      - $ref: '#/components/parameters/owner'
      - $ref: '#/components/parameters/repo'
      - in: header
        name: Authorization
        schema:
          type: string
        example: example_value
      - in: header
        name: X-GitHub-Api-Version
        schema:
          type: string
          default: '2022-11-28'
        example: example_value
      - in: header
        name: Accept
        schema:
          type: string
          default: application/vnd.github+json
        example: example_value
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/actions-cache-usage-policy-for-repository'
              examples:
                default:
                  $ref: '#/components/examples/actions-cache-usage-policy'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: actions
        subcategory: cache
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    patch:
      summary: GitHub Set Github Actions Cache Usage Policy for Repository
      description: 'Sets GitHub Actions cache usage policy for a repository.


        OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.'
      tags:
      - Policies
      operationId: setGithubActionsCacheUsagePolicyForRepository
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/actions/cache#set-github-actions-cache-usage-policy-for-a-repository
      parameters:
      - $ref: '#/components/parameters/owner'
      - $ref: '#/components/parameters/repo'
      - in: header
        name: Authorization
        schema:
          type: string
        example: example_value
      - in: header
        name: X-GitHub-Api-Version
        schema:
          type: string
          default: '2022-11-28'
        example: example_value
      - in: header
        name: Accept
        schema:
          type: string
          default: application/vnd.github+json
        example: example_value
      responses:
        '204':
          description: Response
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/actions-cache-usage-policy-for-repository'
            examples:
              selected_actions:
                $ref: '#/components/examples/actions-cache-usage-policy'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: actions
        subcategory: cache
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    servers:
    - url: '{protocol}://{hostname}'
      variables:
        hostname:
          description: Self-hosted Enterprise Server hostname
          default: api.github.com
        protocol:
          description: Self-hosted Enterprise Server protocol
          default: https
  /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies:
    get:
      summary: GitHub List Deployment Branch Policies
      description: 'Lists the deployment branch policies for an environment.


        Anyone with read access to the repository can use this endpoint.


        OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.'
      tags:
      - Policies
      operationId: listDeploymentBranchPolicies
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/deployments/branch-policies#list-deployment-branch-policies
      parameters:
      - $ref: '#/components/parameters/owner'
      - $ref: '#/components/parameters/repo'
      - $ref: '#/components/parameters/environment-name'
      - $ref: '#/components/parameters/per-page'
      - $ref: '#/components/parameters/page'
      - in: header
        name: Authorization
        schema:
          type: string
        example: example_value
      - in: header
        name: X-GitHub-Api-Version
        schema:
          type: string
          default: '2022-11-28'
        example: example_value
      - in: header
        name: Accept
        schema:
          type: string
          default: application/vnd.github+json
        example: example_value
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  total_count:
                    description: The number of deployment branch policies for the environment.
                    type: integer
                    example: 2
                  branch_policies:
                    type: array
                    items:
                      $ref: '#/components/schemas/deployment-branch-policy'
                required:
                - total_count
                - branch_policies
              examples:
                default:
                  $ref: '#/components/examples/deployment-branch-policies-list'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: deployments
        subcategory: branch-policies
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    post:
      summary: GitHub Create Deployment Branch Policy
      description: Creates a deployment branch policy for an environment.  OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
      tags:
      - Policies
      operationId: createDeploymentBranchPolicy
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/deployments/branch-policies#create-a-deployment-branch-policy
      parameters:
      - $ref: '#/components/parameters/owner'
      - $ref: '#/components/parameters/repo'
      - $ref: '#/components/parameters/environment-name'
      - in: header
        name: Authorization
        schema:
          type: string
        example: example_value
      - in: header
        name: X-GitHub-Api-Version
        schema:
          type: string
          default: '2022-11-28'
        example: example_value
      - in: header
        name: Accept
        schema:
          type: string
          default: application/vnd.github+json
        example: example_value
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/deployment-branch-policy-name-pattern-with-type'
            examples:
              example-wildcard:
                summary: Example of a wildcard name pattern
                value:
                  name: release/*
              example-single-branch:
                summary: Example of a single branch name pattern
                value:
                  name: main
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/deployment-branch-policy'
              examples:
                example-wildcard:
                  $ref: '#/components/examples/deployment-branch-policy-wildcard'
                example-single-branch:
                  $ref: '#/components/examples/deployment-branch-policy-single-branch'
        '303':
          description: Response if the same branch name pattern already exists
        '404':
          description: Not Found or `deployment_branch_policy.custom_branch_policies` property for the environment is set to false
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: deployments
        subcategory: branch-policies
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    servers:
    - url: '{protocol}://{hostname}'
      variables:
        hostname:
          description: Self-hosted Enterprise Server hostname
          default: api.github.com
        protocol:
          description: Self-hosted Enterprise Server protocol
          default: https
  /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}:
    get:
      summary: GitHub Get Deployment Branch Policy
      description: 'Gets a deployment branch policy for an environment.


        Anyone with read access to the repository can use this endpoint.


        OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.'
      tags:
      - Policies
      operationId: getDeploymentBranchPolicy
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/deployments/branch-policies#get-a-deployment-branch-policy
      parameters:
      - $ref: '#/components/parameters/owner'
      - $ref: '#/components/parameters/repo'
      - $ref: '#/components/parameters/environment-name'
      - $ref: '#/components/parameters/branch-policy-id'
      - in: header
        name: Authorization
        schema:
          type: string
        example: example_value
      - in: header
        name: X-GitHub-Api-Version
        schema:
          type: string
          default: '2022-11-28'
        example: example_value
      - in: header
        name: Accept
        schema:
          type: string
          default: application/vnd.github+json
        example: example_value
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/deployment-branch-policy'
              examples:
                default:
                  $ref: '#/components/examples/deployment-branch-policy-wildcard'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: deployments
        subcategory: branch-policies
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    put:
      summary: GitHub Update Deployment Branch Policy
      description: 'Updates a deployment branch policy for an environment.


        OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.'
      tags:
      - Policies
      operationId: updateDeploymentBranchPolicy
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/deployments/branch-policies#update-a-deployment-branch-policy
      parameters:
      - $ref: '#/components/parameters/owner'
      - $ref: '#/components/parameters/repo'
      - $ref: '#/components/parameters/environment-name'
      - $ref: '#/components/parameters/branch-policy-id'
      - in: header
        name: Authorization
        schema:
          type: string
        example: example_value
      - in: header
        name: X-GitHub-Api-Version
        schema:
          type: string
          default: '2022-11-28'
        example: example_value
      - in: header
        name: Accept
        schema:
          type: string
          default: application/vnd.github+json
        example: example_value
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/deployment-branch-policy-name-pattern'
            examples:
              default:
                value:
                  name: release/*
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/deployment-branch-policy'
              examples:
                default:
                  $ref: '#/components/examples/deployment-branch-policy-wildcard'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: deployments
        subcategory: branch-policies
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    delete:
      summary: GitHub Delete Deployment Branch Policy
      description: 'Deletes a deployment branch policy for an environment.


        OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.'
      tags:
      - Policies
      operationId: deleteDeploymentBranchPolicy
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/deployments/branch-policies#delete-a-deployment-branch-policy
      parameters:
      - $ref: '#/components/parameters/owner'
      - $ref: '#/components/parameters/repo'
      - $ref: '#/components/parameters/environment-name'
      - $ref: '#/components/parameters/branch-policy-id'
      - in: header
        name: Authorization
        schema:
          type: string
        example: example_value
      - in: header
        name: X-GitHub-Api-Version
        schema:
          type: string
          default: '2022-11-28'
        example: example_value
      - in: header
        name: Accept
        schema:
          type: string
          default: application/vnd.github+json
        example: example_value
      responses:
        '204':
          description: Response
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: deployments
        subcategory: branch-policies
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    servers:
    - url: '{protocol}://{hostname}'
      variables:
        hostname:
          description: Self-hosted Enterprise Server hostname
          default: api.github.com
        protocol:
          description: Self-hosted Enterprise Server protocol
          default: https
components:
  schemas:
    actions-cache-usage-policy-for-repository:
      title: Actions cache usage policy for repository
      description: GitHub Actions cache usage policy for repository.
      type: object
      properties:
        repo_cache_size_limit_in_gb:
          description: The size limit for the sum of all caches, in gigabytes.
          type: integer
          example: 14
      required:
      - repo_cache_size_limit_in_gb
    deployment-branch-policy-name-pattern-with-type:
      title: Deployment branch and tag policy name pattern
      type: object
      properties:
        name:
          description: 'The name pattern that branches or tags must match in order to deploy to the environment.


            Wildcard characters will not match `/`. For example, to match branches that begin with `release/` and contain an additional single slash, use `release/*/*`.

            For more information about pattern matching syntax, see the [Ruby File.fnmatch documentation](https://ruby-doc.org/core-2.5.1/File.html#method-c-fnmatch).'
          type: string
          example: release/*
      required:
      - name
    deployment-branch-policy:
      title: Deployment branch policy
      description: Details of a deployment branch policy.
      type: object
      properties:
        id:
          description: The unique identifier of the branch policy.
          type: integer
          example: 361471
        node_id:
          type: string
          example: MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjE0NzE=
        name:
          description: The name pattern that branches must match in order to deploy to the environment.
          type: string
          example: release/*
    deployment-branch-policy-name-pattern:
      title: Deployment branch policy name pattern
      type: object
      properties:
        name:
          description: 'The name pattern that branches must match in order to deploy to the environment.


            Wildcard characters will not match `/`. For example, to match branches that begin with `release/` and contain an additional single slash, use `release/*/*`.

            For more information about pattern matching syntax, see the [Ruby File.fnmatch documentation](https://ruby-doc.org/core-2.5.1/File.html#method-c-fnmatch).'
          type: string
          example: release/*
      required:
      - name
  parameters:
    repo:
      name: repo
      description: The name of the repository without the `.git` extension. The name is not case sensitive.
      in: path
      required: true
      schema:
        type: string
    owner:
      name: owner
      description: The account owner of the repository. The name is not case sensitive.
      in: path
      required: true
      schema:
        type: string
    per-page:
      name: per_page
      description: The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/enterprise-server@3.9/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
      in: query
      schema:
        type: integer
        default: 30
    environment-name:
      name: environment_name
      in: path
      required: true
      description: The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with `%2F`.
      schema:
        type: string
    branch-policy-id:
      name: branch_policy_id
      in: path
      required: true
      description: The unique identifier of the branch policy.
      schema:
        type: integer
    page:
      name: page
      description: The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/enterprise-server@3.9/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
      in: query
      schema:
        type: integer
        default: 1
  examples:
    actions-cache-usage-policy:
      value:
        repo_cache_size_limit_in_gb: 14
    deployment-branch-policy-wildcard:
      value:
        id: 364662
        node_id: MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjQ2NjI=
        name: release/*
    deployment-branch-policies-list:
      value:
        total_count: 2
        branch_policies:
        - id: 361471
          node_id: MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjE0NzE=
          name: release/*
        - id: 361472
          node_id: MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjE0NzI=
          name: main
    deployment-branch-policy-single-branch:
      value:
        id: 364663
        node_id: MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjQ2NjM=
        name: main
  securitySchemes:
    bearerHttpAuthentication:
      description: Bearer Token
      type: http
      scheme: Bearer
externalDocs:
  description: GitHub Enterprise Developer Docs
  url: https://docs.github.com/enterprise-server@3.9/rest/
x-refined-from:
- github-repo-actions-api-openapi.yml
- github-repo-tags-api-openapi.yml