// 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 (
	
	
)

func ( *DependabotService) ( context.Context,  string) (*PublicKey, *Response, error) {
	,  := .client.NewRequest("GET", , nil)
	if  != nil {
		return nil, nil, 
	}

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

	return , , nil
}

// GetRepoPublicKey gets a public key that should be used for Dependabot secret encryption.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/secrets#get-a-repository-public-key
//
//meta:operation GET /repos/{owner}/{repo}/dependabot/secrets/public-key
func ( *DependabotService) ( context.Context, ,  string) (*PublicKey, *Response, error) {
	 := fmt.Sprintf("repos/%v/%v/dependabot/secrets/public-key", , )
	return .getPublicKey(, )
}

// GetOrgPublicKey gets a public key that should be used for Dependabot secret encryption.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/secrets#get-an-organization-public-key
//
//meta:operation GET /orgs/{org}/dependabot/secrets/public-key
func ( *DependabotService) ( context.Context,  string) (*PublicKey, *Response, error) {
	 := fmt.Sprintf("orgs/%v/dependabot/secrets/public-key", )
	return .getPublicKey(, )
}

func ( *DependabotService) ( context.Context,  string,  *ListOptions) (*Secrets, *Response, error) {
	,  := addOptions(, )
	if  != nil {
		return nil, nil, 
	}

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

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

	return , , nil
}

// ListRepoSecrets lists all Dependabot secrets available in a repository
// without revealing their encrypted values.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/secrets#list-repository-secrets
//
//meta:operation GET /repos/{owner}/{repo}/dependabot/secrets
func ( *DependabotService) ( context.Context, ,  string,  *ListOptions) (*Secrets, *Response, error) {
	 := fmt.Sprintf("repos/%v/%v/dependabot/secrets", , )
	return .listSecrets(, , )
}

// ListOrgSecrets lists all Dependabot secrets available in an organization
// without revealing their encrypted values.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/secrets#list-organization-secrets
//
//meta:operation GET /orgs/{org}/dependabot/secrets
func ( *DependabotService) ( context.Context,  string,  *ListOptions) (*Secrets, *Response, error) {
	 := fmt.Sprintf("orgs/%v/dependabot/secrets", )
	return .listSecrets(, , )
}

func ( *DependabotService) ( context.Context,  string) (*Secret, *Response, error) {
	,  := .client.NewRequest("GET", , nil)
	if  != nil {
		return nil, nil, 
	}

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

	return , , nil
}

// GetRepoSecret gets a single repository Dependabot secret without revealing its encrypted value.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/secrets#get-a-repository-secret
//
//meta:operation GET /repos/{owner}/{repo}/dependabot/secrets/{secret_name}
func ( *DependabotService) ( context.Context, , ,  string) (*Secret, *Response, error) {
	 := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", , , )
	return .getSecret(, )
}

// GetOrgSecret gets a single organization Dependabot secret without revealing its encrypted value.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/secrets#get-an-organization-secret
//
//meta:operation GET /orgs/{org}/dependabot/secrets/{secret_name}
func ( *DependabotService) ( context.Context, ,  string) (*Secret, *Response, error) {
	 := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", , )
	return .getSecret(, )
}

// DependabotEncryptedSecret represents a secret that is encrypted using a public key for Dependabot.
//
// The value of EncryptedValue must be your secret, encrypted with
// LibSodium (see documentation here: https://libsodium.gitbook.io/doc/bindings_for_other_languages)
// using the public key retrieved using the GetPublicKey method.
type DependabotEncryptedSecret struct {
	Name                  string                           `json:"-"`
	KeyID                 string                           `json:"key_id"`
	EncryptedValue        string                           `json:"encrypted_value"`
	Visibility            string                           `json:"visibility,omitempty"`
	SelectedRepositoryIDs DependabotSecretsSelectedRepoIDs `json:"selected_repository_ids,omitempty"`
}

func ( *DependabotService) ( context.Context,  string,  *DependabotEncryptedSecret) (*Response, error) {
	,  := .client.NewRequest("PUT", , )
	if  != nil {
		return nil, 
	}

	return .client.Do(, , nil)
}

// CreateOrUpdateRepoSecret creates or updates a repository Dependabot secret with an encrypted value.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/secrets#create-or-update-a-repository-secret
//
//meta:operation PUT /repos/{owner}/{repo}/dependabot/secrets/{secret_name}
func ( *DependabotService) ( context.Context, ,  string,  *DependabotEncryptedSecret) (*Response, error) {
	 := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", , , .Name)
	return .putSecret(, , )
}

// CreateOrUpdateOrgSecret creates or updates an organization Dependabot secret with an encrypted value.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/secrets#create-or-update-an-organization-secret
//
//meta:operation PUT /orgs/{org}/dependabot/secrets/{secret_name}
func ( *DependabotService) ( context.Context,  string,  *DependabotEncryptedSecret) (*Response, error) {
	 := make([]string, len(.SelectedRepositoryIDs))
	for ,  := range .SelectedRepositoryIDs {
		[] = fmt.Sprintf("%v", )
	}
	 := struct {
		*DependabotEncryptedSecret
		 []string `json:"selected_repository_ids,omitempty"`
	}{
		: ,
		:     ,
	}

	 := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", , .Name)
	,  := .client.NewRequest("PUT", , )
	if  != nil {
		return nil, 
	}

	return .client.Do(, , nil)
}

func ( *DependabotService) ( context.Context,  string) (*Response, error) {
	,  := .client.NewRequest("DELETE", , nil)
	if  != nil {
		return nil, 
	}

	return .client.Do(, , nil)
}

// DeleteRepoSecret deletes a Dependabot secret in a repository using the secret name.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/secrets#delete-a-repository-secret
//
//meta:operation DELETE /repos/{owner}/{repo}/dependabot/secrets/{secret_name}
func ( *DependabotService) ( context.Context, , ,  string) (*Response, error) {
	 := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", , , )
	return .deleteSecret(, )
}

// DeleteOrgSecret deletes a Dependabot secret in an organization using the secret name.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/secrets#delete-an-organization-secret
//
//meta:operation DELETE /orgs/{org}/dependabot/secrets/{secret_name}
func ( *DependabotService) ( context.Context, ,  string) (*Response, error) {
	 := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", , )
	return .deleteSecret(, )
}

// ListSelectedReposForOrgSecret lists all repositories that have access to a Dependabot secret.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/secrets#list-selected-repositories-for-an-organization-secret
//
//meta:operation GET /orgs/{org}/dependabot/secrets/{secret_name}/repositories
func ( *DependabotService) ( context.Context, ,  string,  *ListOptions) (*SelectedReposList, *Response, error) {
	 := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories", , )
	,  := addOptions(, )
	if  != nil {
		return nil, nil, 
	}

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

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

	return , , nil
}

// DependabotSecretsSelectedRepoIDs are the repository IDs that have access to the dependabot secrets.
type DependabotSecretsSelectedRepoIDs []int64

// SetSelectedReposForOrgSecret sets the repositories that have access to a Dependabot secret.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/secrets#set-selected-repositories-for-an-organization-secret
//
//meta:operation PUT /orgs/{org}/dependabot/secrets/{secret_name}/repositories
func ( *DependabotService) ( context.Context, ,  string,  DependabotSecretsSelectedRepoIDs) (*Response, error) {
	 := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories", , )
	type  struct {
		 DependabotSecretsSelectedRepoIDs `json:"selected_repository_ids"`
	}

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

	return .client.Do(, , nil)
}

// AddSelectedRepoToOrgSecret adds a repository to an organization Dependabot secret.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/secrets#add-selected-repository-to-an-organization-secret
//
//meta:operation PUT /orgs/{org}/dependabot/secrets/{secret_name}/repositories/{repository_id}
func ( *DependabotService) ( context.Context, ,  string,  *Repository) (*Response, error) {
	 := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories/%v", , , *.ID)
	,  := .client.NewRequest("PUT", , nil)
	if  != nil {
		return nil, 
	}

	return .client.Do(, , nil)
}

// RemoveSelectedRepoFromOrgSecret removes a repository from an organization Dependabot secret.
//
// GitHub API docs: https://docs.github.com/rest/dependabot/secrets#remove-selected-repository-from-an-organization-secret
//
//meta:operation DELETE /orgs/{org}/dependabot/secrets/{secret_name}/repositories/{repository_id}
func ( *DependabotService) ( context.Context, ,  string,  *Repository) (*Response, error) {
	 := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories/%v", , , *.ID)
	,  := .client.NewRequest("DELETE", , nil)
	if  != nil {
		return nil, 
	}

	return .client.Do(, , nil)
}