// Copyright 2022 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package github

import (
	
	
)

// OrganizationCustomRoles represents custom organization roles available in specified organization.
type OrganizationCustomRoles struct {
	TotalCount      *int              `json:"total_count,omitempty"`
	CustomRepoRoles []*CustomOrgRoles `json:"roles,omitempty"`
}

// CustomOrgRoles represents custom organization role available in specified organization.
type CustomOrgRoles struct {
	ID          *int64        `json:"id,omitempty"`
	Name        *string       `json:"name,omitempty"`
	Description *string       `json:"description,omitempty"`
	Permissions []string      `json:"permissions,omitempty"`
	Org         *Organization `json:"organization,omitempty"`
	CreatedAt   *Timestamp    `json:"created_at,omitempty"`
	UpdatedAt   *Timestamp    `json:"updated_at,omitempty"`
	Source      *string       `json:"source,omitempty"`
	BaseRole    *string       `json:"base_role,omitempty"`
}

// CreateOrUpdateOrgRoleOptions represents options required to create or update a custom organization role.
type CreateOrUpdateOrgRoleOptions struct {
	Name        *string  `json:"name,omitempty"`
	Description *string  `json:"description,omitempty"`
	Permissions []string `json:"permissions"`
	BaseRole    *string  `json:"base_role,omitempty"`
}

// ListRoles lists the custom roles available in this organization.
// In order to see custom roles in an organization, the authenticated user must be an organization owner.
//
// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#get-all-organization-roles-for-an-organization
//
//meta:operation GET /orgs/{org}/organization-roles
func ( *OrganizationsService) ( context.Context,  string) (*OrganizationCustomRoles, *Response, error) {
	 := fmt.Sprintf("orgs/%v/organization-roles", )

	,  := .client.NewRequest("GET", , nil)
	if  != nil {
		return nil, nil, 
	}

	 := new(OrganizationCustomRoles)
	,  := .client.Do(, , )
	if  != nil {
		return nil, , 
	}

	return , , nil
}

// GetOrgRole gets an organization role in this organization.
// In order to get organization roles in an organization, the authenticated user must be an organization owner, or have access via an organization role.
//
// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#get-an-organization-role
//
//meta:operation GET /orgs/{org}/organization-roles/{role_id}
func ( *OrganizationsService) ( context.Context,  string,  int64) (*CustomOrgRoles, *Response, error) {
	 := fmt.Sprintf("orgs/%v/organization-roles/%v", , )

	,  := .client.NewRequest("GET", , nil)
	if  != nil {
		return nil, nil, 
	}

	 := new(CustomOrgRoles)
	,  := .client.Do(, , )
	if  != nil {
		return nil, , 
	}

	return , , 
}

// CreateCustomOrgRole creates a custom role in this organization.
// In order to create custom roles in an organization, the authenticated user must be an organization owner.
//
// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#create-a-custom-organization-role
//
//meta:operation POST /orgs/{org}/organization-roles
func ( *OrganizationsService) ( context.Context,  string,  *CreateOrUpdateOrgRoleOptions) (*CustomOrgRoles, *Response, error) {
	 := fmt.Sprintf("orgs/%v/organization-roles", )

	,  := .client.NewRequest("POST", , )
	if  != nil {
		return nil, nil, 
	}

	 := new(CustomOrgRoles)
	,  := .client.Do(, , )
	if  != nil {
		return nil, , 
	}

	return , , 
}

// UpdateCustomOrgRole updates a custom role in this organization.
// In order to update custom roles in an organization, the authenticated user must be an organization owner.
//
// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#update-a-custom-organization-role
//
//meta:operation PATCH /orgs/{org}/organization-roles/{role_id}
func ( *OrganizationsService) ( context.Context,  string,  int64,  *CreateOrUpdateOrgRoleOptions) (*CustomOrgRoles, *Response, error) {
	 := fmt.Sprintf("orgs/%v/organization-roles/%v", , )

	,  := .client.NewRequest("PATCH", , )
	if  != nil {
		return nil, nil, 
	}

	 := new(CustomOrgRoles)
	,  := .client.Do(, , )
	if  != nil {
		return nil, , 
	}

	return , , 
}

// DeleteCustomOrgRole deletes an existing custom role in this organization.
// In order to delete custom roles in an organization, the authenticated user must be an organization owner.
//
// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#delete-a-custom-organization-role
//
//meta:operation DELETE /orgs/{org}/organization-roles/{role_id}
func ( *OrganizationsService) ( context.Context,  string,  int64) (*Response, error) {
	 := fmt.Sprintf("orgs/%v/organization-roles/%v", , )

	,  := .client.NewRequest("DELETE", , nil)
	if  != nil {
		return nil, 
	}

	 := new(CustomOrgRoles)
	,  := .client.Do(, , )
	if  != nil {
		return , 
	}

	return , nil
}

// AssignOrgRoleToTeam assigns an existing organization role to a team in this organization.
// In order to assign organization roles in an organization, the authenticated user must be an organization owner.
//
// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#assign-an-organization-role-to-a-team
//
//meta:operation PUT /orgs/{org}/organization-roles/teams/{team_slug}/{role_id}
func ( *OrganizationsService) ( context.Context, ,  string,  int64) (*Response, error) {
	 := fmt.Sprintf("orgs/%v/organization-roles/teams/%v/%v", , , )

	,  := .client.NewRequest("PUT", , nil)
	if  != nil {
		return nil, 
	}

	,  := .client.Do(, , nil)
	if  != nil {
		return , 
	}

	return , nil
}

// RemoveOrgRoleFromTeam removes an existing organization role assignment from a team in this organization.
// In order to remove organization role assignments in an organization, the authenticated user must be an organization owner.
//
// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#remove-an-organization-role-from-a-team
//
//meta:operation DELETE /orgs/{org}/organization-roles/teams/{team_slug}/{role_id}
func ( *OrganizationsService) ( context.Context, ,  string,  int64) (*Response, error) {
	 := fmt.Sprintf("orgs/%v/organization-roles/teams/%v/%v", , , )

	,  := .client.NewRequest("DELETE", , nil)
	if  != nil {
		return nil, 
	}

	,  := .client.Do(, , nil)
	if  != nil {
		return , 
	}

	return , nil
}

// AssignOrgRoleToUser assigns an existing organization role to a user in this organization.
// In order to assign organization roles in an organization, the authenticated user must be an organization owner.
//
// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#assign-an-organization-role-to-a-user
//
//meta:operation PUT /orgs/{org}/organization-roles/users/{username}/{role_id}
func ( *OrganizationsService) ( context.Context, ,  string,  int64) (*Response, error) {
	 := fmt.Sprintf("orgs/%v/organization-roles/users/%v/%v", , , )

	,  := .client.NewRequest("PUT", , nil)
	if  != nil {
		return nil, 
	}

	,  := .client.Do(, , nil)
	if  != nil {
		return , 
	}

	return , nil
}

// RemoveOrgRoleFromUser removes an existing organization role assignment from a user in this organization.
// In order to remove organization role assignments in an organization, the authenticated user must be an organization owner.
//
// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#remove-an-organization-role-from-a-user
//
//meta:operation DELETE /orgs/{org}/organization-roles/users/{username}/{role_id}
func ( *OrganizationsService) ( context.Context, ,  string,  int64) (*Response, error) {
	 := fmt.Sprintf("orgs/%v/organization-roles/users/%v/%v", , , )

	,  := .client.NewRequest("DELETE", , nil)
	if  != nil {
		return nil, 
	}

	,  := .client.Do(, , nil)
	if  != nil {
		return , 
	}

	return , nil
}

// ListTeamsAssignedToOrgRole returns all teams assigned to a specific organization role.
// In order to list teams assigned to an organization role, the authenticated user must be an organization owner.
//
// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#list-teams-that-are-assigned-to-an-organization-role
//
//meta:operation GET /orgs/{org}/organization-roles/{role_id}/teams
func ( *OrganizationsService) ( context.Context,  string,  int64,  *ListOptions) ([]*Team, *Response, error) {
	 := fmt.Sprintf("orgs/%v/organization-roles/%v/teams", , )
	,  := addOptions(, )
	if  != nil {
		return nil, nil, 
	}

	,  := .client.NewRequest("GET", , nil)
	if  != nil {
		return nil, nil, 
	}

	var  []*Team
	,  := .client.Do(, , &)
	if  != nil {
		return nil, , 
	}

	return , , nil
}

// ListUsersAssignedToOrgRole returns all users assigned to a specific organization role.
// In order to list users assigned to an organization role, the authenticated user must be an organization owner.
//
// GitHub API docs: https://docs.github.com/rest/orgs/organization-roles#list-users-that-are-assigned-to-an-organization-role
//
//meta:operation GET /orgs/{org}/organization-roles/{role_id}/users
func ( *OrganizationsService) ( context.Context,  string,  int64,  *ListOptions) ([]*User, *Response, error) {
	 := fmt.Sprintf("orgs/%v/organization-roles/%v/users", , )
	,  := addOptions(, )
	if  != nil {
		return nil, nil, 
	}

	,  := .client.NewRequest("GET", , nil)
	if  != nil {
		return nil, nil, 
	}

	var  []*User
	,  := .client.Do(, , &)
	if  != nil {
		return nil, , 
	}

	return , , nil
}