/*
* GitHub's official OpenAPI spec + Octokit extension
*
* OpenAPI specs from https://github.com/github/rest-api-description with the 'x-octokit' extension required by the Octokit SDKs
*
* The version of the OpenAPI document: 16.6.0
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration};
/// struct for typed errors of method [`dependabot_slash_add_selected_repo_to_org_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashAddSelectedRepoToOrgSecretError {
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_create_or_update_org_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashCreateOrUpdateOrgSecretError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_create_or_update_repo_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashCreateOrUpdateRepoSecretError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_delete_org_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashDeleteOrgSecretError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_delete_repo_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashDeleteRepoSecretError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_get_alert`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashGetAlertError {
Status403(models::BasicError),
Status404(models::BasicError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_get_org_public_key`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashGetOrgPublicKeyError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_get_org_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashGetOrgSecretError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_get_repo_public_key`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashGetRepoPublicKeyError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_get_repo_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashGetRepoSecretError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_list_alerts_for_enterprise`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashListAlertsForEnterpriseError {
Status403(models::BasicError),
Status404(models::BasicError),
Status422(models::ValidationErrorSimple),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_list_alerts_for_org`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashListAlertsForOrgError {
Status400(models::BasicError),
Status403(models::BasicError),
Status404(models::BasicError),
Status422(models::ValidationErrorSimple),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_list_alerts_for_repo`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashListAlertsForRepoError {
Status400(models::BasicError),
Status403(models::BasicError),
Status404(models::BasicError),
Status422(models::ValidationErrorSimple),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_list_org_secrets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashListOrgSecretsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_list_repo_secrets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashListRepoSecretsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_list_selected_repos_for_org_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashListSelectedReposForOrgSecretError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_remove_selected_repo_from_org_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashRemoveSelectedRepoFromOrgSecretError {
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_set_selected_repos_for_org_secret`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashSetSelectedReposForOrgSecretError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dependabot_slash_update_alert`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DependabotSlashUpdateAlertError {
Status400(models::BasicError),
Status403(models::BasicError),
Status404(models::BasicError),
Status409(models::BasicError),
Status422(models::ValidationErrorSimple),
UnknownValue(serde_json::Value),
}
/// Adds a repository to an organization secret when the `visibility` for repository access is set to `selected`. The visibility is set when you [Create or update an organization secret](https://docs.github.com/rest/dependabot/secrets#create-or-update-an-organization-secret). OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
pub async fn dependabot_slash_add_selected_repo_to_org_secret(configuration: &configuration::Configuration, org: &str, secret_name: &str, repository_id: i32) -> Result<(), Error<DependabotSlashAddSelectedRepoToOrgSecretError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/orgs/{org}/dependabot/secrets/{secret_name}/repositories/{repository_id}", local_var_configuration.base_path, org=crate::apis::urlencode(org), secret_name=crate::apis::urlencode(secret_name), repository_id=repository_id);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<DependabotSlashAddSelectedRepoToOrgSecretError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Creates or updates an organization secret with an encrypted value. Encrypt your secret using [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `dependabot_secrets` organization permission to use this endpoint. #### Example encrypting a secret using Node.js Encrypt your secret using the [tweetsodium](https://github.com/github/tweetsodium) library. ``` const sodium = require('tweetsodium'); const key = \"base64-encoded-public-key\"; const value = \"plain-text-secret\"; // Convert the message and key to Uint8Array's (Buffer implements that interface) const messageBytes = Buffer.from(value); const keyBytes = Buffer.from(key, 'base64'); // Encrypt using LibSodium. const encryptedBytes = sodium.seal(messageBytes, keyBytes); // Base64 the encrypted secret const encrypted = Buffer.from(encryptedBytes).toString('base64'); console.log(encrypted); ``` #### Example encrypting a secret using Python Encrypt your secret using [pynacl](https://pynacl.readthedocs.io/en/latest/public/#nacl-public-sealedbox) with Python 3. ``` from base64 import b64encode from nacl import encoding, public def encrypt(public_key: str, secret_value: str) -> str: \"\"\"Encrypt a Unicode string using the public key.\"\"\" public_key = public.PublicKey(public_key.encode(\"utf-8\"), encoding.Base64Encoder()) sealed_box = public.SealedBox(public_key) encrypted = sealed_box.encrypt(secret_value.encode(\"utf-8\")) return b64encode(encrypted).decode(\"utf-8\") ``` #### Example encrypting a secret using C# Encrypt your secret using the [Sodium.Core](https://www.nuget.org/packages/Sodium.Core/) package. ``` var secretValue = System.Text.Encoding.UTF8.GetBytes(\"mySecret\"); var publicKey = Convert.FromBase64String(\"2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvvcCU=\"); var sealedPublicKeyBox = Sodium.SealedPublicKeyBox.Create(secretValue, publicKey); Console.WriteLine(Convert.ToBase64String(sealedPublicKeyBox)); ``` #### Example encrypting a secret using Ruby Encrypt your secret using the [rbnacl](https://github.com/RubyCrypto/rbnacl) gem. ```ruby require \"rbnacl\" require \"base64\" key = Base64.decode64(\"+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0=\") public_key = RbNaCl::PublicKey.new(key) box = RbNaCl::Boxes::Sealed.from_public_key(public_key) encrypted_secret = box.encrypt(\"my_secret\") # Print the base64 encoded secret puts Base64.strict_encode64(encrypted_secret) ```
pub async fn dependabot_slash_create_or_update_org_secret(configuration: &configuration::Configuration, org: &str, secret_name: &str, dependabot_create_or_update_org_secret_request: models::DependabotCreateOrUpdateOrgSecretRequest) -> Result<serde_json::Value, Error<DependabotSlashCreateOrUpdateOrgSecretError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/orgs/{org}/dependabot/secrets/{secret_name}", local_var_configuration.base_path, org=crate::apis::urlencode(org), secret_name=crate::apis::urlencode(secret_name));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
local_var_req_builder = local_var_req_builder.json(&dependabot_create_or_update_org_secret_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DependabotSlashCreateOrUpdateOrgSecretError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Creates or updates a repository secret with an encrypted value. Encrypt your secret using [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages). For more information, see \"[Encrypting secrets for the REST API](https://docs.github.com/rest/guides/encrypting-secrets-for-the-rest-api).\" OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
pub async fn dependabot_slash_create_or_update_repo_secret(configuration: &configuration::Configuration, owner: &str, repo: &str, secret_name: &str, dependabot_create_or_update_repo_secret_request: models::DependabotCreateOrUpdateRepoSecretRequest) -> Result<serde_json::Value, Error<DependabotSlashCreateOrUpdateRepoSecretError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/repos/{owner}/{repo}/dependabot/secrets/{secret_name}", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), secret_name=crate::apis::urlencode(secret_name));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
local_var_req_builder = local_var_req_builder.json(&dependabot_create_or_update_repo_secret_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DependabotSlashCreateOrUpdateRepoSecretError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Deletes a secret in an organization using the secret name. OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
pub async fn dependabot_slash_delete_org_secret(configuration: &configuration::Configuration, org: &str, secret_name: &str) -> Result<(), Error<DependabotSlashDeleteOrgSecretError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/orgs/{org}/dependabot/secrets/{secret_name}", local_var_configuration.base_path, org=crate::apis::urlencode(org), secret_name=crate::apis::urlencode(secret_name));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<DependabotSlashDeleteOrgSecretError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Deletes a secret in a repository using the secret name. OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
pub async fn dependabot_slash_delete_repo_secret(configuration: &configuration::Configuration, owner: &str, repo: &str, secret_name: &str) -> Result<(), Error<DependabotSlashDeleteRepoSecretError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/repos/{owner}/{repo}/dependabot/secrets/{secret_name}", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), secret_name=crate::apis::urlencode(secret_name));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<DependabotSlashDeleteRepoSecretError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead.
pub async fn dependabot_slash_get_alert(configuration: &configuration::Configuration, owner: &str, repo: &str, alert_number: i32) -> Result<models::DependabotAlert, Error<DependabotSlashGetAlertError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/repos/{owner}/{repo}/dependabot/alerts/{alert_number}", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), alert_number=alert_number);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DependabotSlashGetAlertError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Gets your public key, which you need to encrypt secrets. You need to encrypt a secret before you can create or update secrets. OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
pub async fn dependabot_slash_get_org_public_key(configuration: &configuration::Configuration, org: &str) -> Result<models::DependabotPublicKey, Error<DependabotSlashGetOrgPublicKeyError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/orgs/{org}/dependabot/secrets/public-key", local_var_configuration.base_path, org=crate::apis::urlencode(org));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DependabotSlashGetOrgPublicKeyError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Gets a single organization secret without revealing its encrypted value. OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
pub async fn dependabot_slash_get_org_secret(configuration: &configuration::Configuration, org: &str, secret_name: &str) -> Result<models::OrganizationDependabotSecret, Error<DependabotSlashGetOrgSecretError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/orgs/{org}/dependabot/secrets/{secret_name}", local_var_configuration.base_path, org=crate::apis::urlencode(org), secret_name=crate::apis::urlencode(secret_name));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DependabotSlashGetOrgSecretError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Gets your public key, which you need to encrypt secrets. You need to encrypt a secret before you can create or update secrets. 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 if the repository is private.
pub async fn dependabot_slash_get_repo_public_key(configuration: &configuration::Configuration, owner: &str, repo: &str) -> Result<models::DependabotPublicKey, Error<DependabotSlashGetRepoPublicKeyError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/repos/{owner}/{repo}/dependabot/secrets/public-key", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DependabotSlashGetRepoPublicKeyError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Gets a single repository secret without revealing its encrypted value. OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
pub async fn dependabot_slash_get_repo_secret(configuration: &configuration::Configuration, owner: &str, repo: &str, secret_name: &str) -> Result<models::DependabotSecret, Error<DependabotSlashGetRepoSecretError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/repos/{owner}/{repo}/dependabot/secrets/{secret_name}", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), secret_name=crate::apis::urlencode(secret_name));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DependabotSlashGetRepoSecretError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Lists Dependabot alerts for repositories that are owned by the specified enterprise. The authenticated user must be a member of the enterprise to use this endpoint. Alerts are only returned for organizations in the enterprise for which you are an organization owner or a security manager. For more information about security managers, see \"[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization).\" OAuth app tokens and personal access tokens (classic) need the `repo` or `security_events` scope to use this endpoint.
pub async fn dependabot_slash_list_alerts_for_enterprise(configuration: &configuration::Configuration, enterprise: &str, state: Option<&str>, severity: Option<&str>, ecosystem: Option<&str>, package: Option<&str>, scope: Option<&str>, sort: Option<&str>, direction: Option<&str>, before: Option<&str>, after: Option<&str>, first: Option<i32>, last: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::DependabotAlertWithRepository>, Error<DependabotSlashListAlertsForEnterpriseError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/enterprises/{enterprise}/dependabot/alerts", local_var_configuration.base_path, enterprise=crate::apis::urlencode(enterprise));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = state {
local_var_req_builder = local_var_req_builder.query(&[("state", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = severity {
local_var_req_builder = local_var_req_builder.query(&[("severity", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ecosystem {
local_var_req_builder = local_var_req_builder.query(&[("ecosystem", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = package {
local_var_req_builder = local_var_req_builder.query(&[("package", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scope {
local_var_req_builder = local_var_req_builder.query(&[("scope", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = direction {
local_var_req_builder = local_var_req_builder.query(&[("direction", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = before {
local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = after {
local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = first {
local_var_req_builder = local_var_req_builder.query(&[("first", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = last {
local_var_req_builder = local_var_req_builder.query(&[("last", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = per_page {
local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DependabotSlashListAlertsForEnterpriseError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Lists Dependabot alerts for an organization. The authenticated user must be an owner or security manager for the organization to use this endpoint. OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead.
pub async fn dependabot_slash_list_alerts_for_org(configuration: &configuration::Configuration, org: &str, state: Option<&str>, severity: Option<&str>, ecosystem: Option<&str>, package: Option<&str>, scope: Option<&str>, sort: Option<&str>, direction: Option<&str>, before: Option<&str>, after: Option<&str>, first: Option<i32>, last: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::DependabotAlertWithRepository>, Error<DependabotSlashListAlertsForOrgError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/orgs/{org}/dependabot/alerts", local_var_configuration.base_path, org=crate::apis::urlencode(org));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = state {
local_var_req_builder = local_var_req_builder.query(&[("state", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = severity {
local_var_req_builder = local_var_req_builder.query(&[("severity", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ecosystem {
local_var_req_builder = local_var_req_builder.query(&[("ecosystem", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = package {
local_var_req_builder = local_var_req_builder.query(&[("package", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scope {
local_var_req_builder = local_var_req_builder.query(&[("scope", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = direction {
local_var_req_builder = local_var_req_builder.query(&[("direction", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = before {
local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = after {
local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = first {
local_var_req_builder = local_var_req_builder.query(&[("first", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = last {
local_var_req_builder = local_var_req_builder.query(&[("last", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = per_page {
local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DependabotSlashListAlertsForOrgError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead.
pub async fn dependabot_slash_list_alerts_for_repo(configuration: &configuration::Configuration, owner: &str, repo: &str, state: Option<&str>, severity: Option<&str>, ecosystem: Option<&str>, package: Option<&str>, manifest: Option<&str>, scope: Option<&str>, sort: Option<&str>, direction: Option<&str>, page: Option<i32>, per_page: Option<i32>, before: Option<&str>, after: Option<&str>, first: Option<i32>, last: Option<i32>) -> Result<Vec<models::DependabotAlert>, Error<DependabotSlashListAlertsForRepoError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/repos/{owner}/{repo}/dependabot/alerts", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = state {
local_var_req_builder = local_var_req_builder.query(&[("state", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = severity {
local_var_req_builder = local_var_req_builder.query(&[("severity", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ecosystem {
local_var_req_builder = local_var_req_builder.query(&[("ecosystem", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = package {
local_var_req_builder = local_var_req_builder.query(&[("package", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = manifest {
local_var_req_builder = local_var_req_builder.query(&[("manifest", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scope {
local_var_req_builder = local_var_req_builder.query(&[("scope", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = direction {
local_var_req_builder = local_var_req_builder.query(&[("direction", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = per_page {
local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = before {
local_var_req_builder = local_var_req_builder.query(&[("before", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = after {
local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = first {
local_var_req_builder = local_var_req_builder.query(&[("first", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = last {
local_var_req_builder = local_var_req_builder.query(&[("last", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DependabotSlashListAlertsForRepoError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Lists all secrets available in an organization without revealing their encrypted values. OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
pub async fn dependabot_slash_list_org_secrets(configuration: &configuration::Configuration, org: &str, per_page: Option<i32>, page: Option<i32>) -> Result<models::DependabotListOrgSecrets200Response, Error<DependabotSlashListOrgSecretsError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/orgs/{org}/dependabot/secrets", local_var_configuration.base_path, org=crate::apis::urlencode(org));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = per_page {
local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DependabotSlashListOrgSecretsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Lists all secrets available in a repository without revealing their encrypted values. OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint.
pub async fn dependabot_slash_list_repo_secrets(configuration: &configuration::Configuration, owner: &str, repo: &str, per_page: Option<i32>, page: Option<i32>) -> Result<models::DependabotListRepoSecrets200Response, Error<DependabotSlashListRepoSecretsError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/repos/{owner}/{repo}/dependabot/secrets", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = per_page {
local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DependabotSlashListRepoSecretsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Lists all repositories that have been selected when the `visibility` for repository access to a secret is set to `selected`. OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
pub async fn dependabot_slash_list_selected_repos_for_org_secret(configuration: &configuration::Configuration, org: &str, secret_name: &str, page: Option<i32>, per_page: Option<i32>) -> Result<models::ActionsListSelectedReposForOrgSecret200Response, Error<DependabotSlashListSelectedReposForOrgSecretError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/orgs/{org}/dependabot/secrets/{secret_name}/repositories", local_var_configuration.base_path, org=crate::apis::urlencode(org), secret_name=crate::apis::urlencode(secret_name));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = per_page {
local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DependabotSlashListSelectedReposForOrgSecretError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Removes a repository from an organization secret when the `visibility` for repository access is set to `selected`. The visibility is set when you [Create or update an organization secret](https://docs.github.com/rest/dependabot/secrets#create-or-update-an-organization-secret). OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
pub async fn dependabot_slash_remove_selected_repo_from_org_secret(configuration: &configuration::Configuration, org: &str, secret_name: &str, repository_id: i32) -> Result<(), Error<DependabotSlashRemoveSelectedRepoFromOrgSecretError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/orgs/{org}/dependabot/secrets/{secret_name}/repositories/{repository_id}", local_var_configuration.base_path, org=crate::apis::urlencode(org), secret_name=crate::apis::urlencode(secret_name), repository_id=repository_id);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<DependabotSlashRemoveSelectedRepoFromOrgSecretError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Replaces all repositories for an organization secret when the `visibility` for repository access is set to `selected`. The visibility is set when you [Create or update an organization secret](https://docs.github.com/rest/dependabot/secrets#create-or-update-an-organization-secret). OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
pub async fn dependabot_slash_set_selected_repos_for_org_secret(configuration: &configuration::Configuration, org: &str, secret_name: &str, dependabot_set_selected_repos_for_org_secret_request: models::DependabotSetSelectedReposForOrgSecretRequest) -> Result<(), Error<DependabotSlashSetSelectedReposForOrgSecretError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/orgs/{org}/dependabot/secrets/{secret_name}/repositories", local_var_configuration.base_path, org=crate::apis::urlencode(org), secret_name=crate::apis::urlencode(secret_name));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
local_var_req_builder = local_var_req_builder.json(&dependabot_set_selected_repos_for_org_secret_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<DependabotSlashSetSelectedReposForOrgSecretError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// The authenticated user must have access to security alerts for the repository to use this endpoint. For more information, see \"[Granting access to security alerts](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-security-and-analysis-settings-for-your-repository#granting-access-to-security-alerts).\" OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint. If this endpoint is only used with public repositories, the token can use the `public_repo` scope instead.
pub async fn dependabot_slash_update_alert(configuration: &configuration::Configuration, owner: &str, repo: &str, alert_number: i32, dependabot_update_alert_request: models::DependabotUpdateAlertRequest) -> Result<models::DependabotAlert, Error<DependabotSlashUpdateAlertError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/repos/{owner}/{repo}/dependabot/alerts/{alert_number}", local_var_configuration.base_path, owner=crate::apis::urlencode(owner), repo=crate::apis::urlencode(repo), alert_number=alert_number);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
local_var_req_builder = local_var_req_builder.json(&dependabot_update_alert_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DependabotSlashUpdateAlertError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}