...

Source file src/github.com/google/go-github/v45/github/orgs_custom_roles.go

Documentation: github.com/google/go-github/v45/github

     1  // Copyright 2022 The go-github AUTHORS. All rights reserved.
     2  //
     3  // Use of this source code is governed by a BSD-style
     4  // license that can be found in the LICENSE file.
     5  
     6  package github
     7  
     8  import (
     9  	"context"
    10  	"fmt"
    11  )
    12  
    13  // OrganizationCustomRepoRoles represents custom repository roles available in specified organization.
    14  type OrganizationCustomRepoRoles struct {
    15  	TotalCount      *int               `json:"total_count,omitempty"`
    16  	CustomRepoRoles []*CustomRepoRoles `json:"custom_roles,omitempty"`
    17  }
    18  
    19  // CustomRepoRoles represents custom repository roles for an organization.
    20  // See https://docs.github.com/en/enterprise-cloud@latest/organizations/managing-peoples-access-to-your-organization-with-roles/managing-custom-repository-roles-for-an-organization
    21  // for more information.
    22  type CustomRepoRoles struct {
    23  	ID   *int64  `json:"id,omitempty"`
    24  	Name *string `json:"name,omitempty"`
    25  }
    26  
    27  // ListCustomRepoRoles lists the custom repository roles available in this organization.
    28  // In order to see custom repository roles in an organization, the authenticated user must be an organization owner.
    29  //
    30  // GitHub API docs: https://docs.github.com/en/rest/orgs/custom-roles#list-custom-repository-roles-in-an-organization
    31  func (s *OrganizationsService) ListCustomRepoRoles(ctx context.Context, org string) (*OrganizationCustomRepoRoles, *Response, error) {
    32  	u := fmt.Sprintf("orgs/%v/custom_roles", org)
    33  
    34  	req, err := s.client.NewRequest("GET", u, nil)
    35  	if err != nil {
    36  		return nil, nil, err
    37  	}
    38  
    39  	customRepoRoles := new(OrganizationCustomRepoRoles)
    40  	resp, err := s.client.Do(ctx, req, customRepoRoles)
    41  	if err != nil {
    42  		return nil, resp, err
    43  	}
    44  
    45  	return customRepoRoles, resp, nil
    46  }
    47  

View as plain text