pub enum Platform {
Github,
Gitea,
Gitlab,
Codeberg,
Forgejo,
}Expand description
§Platform
is the main part of grp, this struct allows you to interact with any platform, just by giving a configuration
use grp_core::Platform;
let platform = Platform::matches("github");
assert!(platform.unwrap() == Platform::Github);Variants§
Implementations§
Source§impl Platform
impl Platform
pub async fn get<U: IntoUrl>( &self, url: U, auth: bool, config: &Config, ) -> Result<Response, Error>
pub async fn post<T, U>( &self, url: U, header: bool, config: &Config, json: &T, ) -> Result<Response, Error>
pub async fn delete<U: IntoUrl>( &self, url: U, config: &Config, ) -> Result<Response, Error>
Source§impl Platform
impl Platform
Source§impl Platform
impl Platform
Sourcepub async fn create_repo<T: Into<String>, A: Animation + ?Sized>(
&self,
owner: Option<T>,
repo: Repo,
config: &Config,
animation: &Box<A>,
) -> Result<Repo, Error>
pub async fn create_repo<T: Into<String>, A: Animation + ?Sized>( &self, owner: Option<T>, repo: Repo, config: &Config, animation: &Box<A>, ) -> Result<Repo, Error>
Creates a repository for the given owner in the selected platform.
owner: the name or path of the user or org that owns the repo.repo: agrp_core::Repowith the metadata for the new repo.config: agrp_core::Configanimation: a struct wich implements the traitgrp_core::animation::Animation
§Retuns
a grp_core::Repo with the confirmation from the platform.
#Error
a grp_core::Error containing the detail of the error.
Source§impl Platform
impl Platform
Sourcepub async fn delete_repo<T: Into<String>, A: Animation + ?Sized>(
&self,
owner: T,
repo: T,
config: &Config,
permanent: bool,
animation: &Box<A>,
) -> Result<(), Error>
pub async fn delete_repo<T: Into<String>, A: Animation + ?Sized>( &self, owner: T, repo: T, config: &Config, permanent: bool, animation: &Box<A>, ) -> Result<(), Error>
Deletes the repo that its given in the selected platform.
owner: the name or path of the user or org of the repo to be deleted.config: agrp_core::Config.permanent: only valid for “Gitlab”, it will mark for deletion and delete permanently that repo.animation: a struct wich implements the traitgrp_core::animation::Animation
§Return
() if the delete succed
§Error
a grp_core::Error containing the detail of the error.
Source§impl Platform
impl Platform
Sourcepub async fn list_repos<T: Into<String>, A: Animation + ?Sized>(
&self,
owner: Option<T>,
config: &Config,
animation: &Box<A>,
) -> (Vec<Repo>, Option<Error>, Vec<Error>)
pub async fn list_repos<T: Into<String>, A: Animation + ?Sized>( &self, owner: Option<T>, config: &Config, animation: &Box<A>, ) -> (Vec<Repo>, Option<Error>, Vec<Error>)
list all the repos for the given owner, if not present, returns all the repos for the default user (config).
§Return
a tuple with:
Vec<Repo>a list with the reposOption<Error>agrp_core::Errorcontaining the detail of the error, if this error is present, the list of repos is empty.Vec<Error>a list ofgrp_core::Errorthat contains a list of errors if something happen during the paggination.
§Why is this?
a better solution with yield is planned, but for know this is the best i could do.
pub fn get_repo( &self, response: Result<String, Error>, ) -> Result<Vec<Repo>, Error>
Source§impl Platform
impl Platform
Sourcepub async fn create_org<T: Into<String>, A: Animation + ?Sized>(
&self,
name: T,
config: &Config,
recursive: bool,
animation: &Box<A>,
) -> (Vec<User>, Vec<Error>)
pub async fn create_org<T: Into<String>, A: Animation + ?Sized>( &self, name: T, config: &Config, recursive: bool, animation: &Box<A>, ) -> (Vec<User>, Vec<Error>)
Create a given org for the logged user in the selected platform.
name: the name or path of the org to be created.config: agrp_core::Config.recursive: only valid for “Gitlab”, it will create all the groups if they not exist.animation: a struct wich implements the traitgrp_core::animation::Animation.
§Returns
a tuple with:
Vec<User>: A list of the created orgs.Vec<Error>: A list of errors if some org faild to be created.
Source§impl Platform
impl Platform
Sourcepub async fn delete_org<T: Into<String>, A: Animation + ?Sized>(
&self,
name: T,
config: &Config,
permanent: bool,
animation: &Box<A>,
) -> Result<(), Error>
pub async fn delete_org<T: Into<String>, A: Animation + ?Sized>( &self, name: T, config: &Config, permanent: bool, animation: &Box<A>, ) -> Result<(), Error>
Deletes the org that its given in the selected platform.
name: the name or path of the org of the repo to be deleted.config: agrp_core::Config.permanent: only valid for “Gitlab”, it will mark for deletion and delete permanently that org.animation: a struct wich implements the traitgrp_core::animation::Animation
§Return
() if the delete succed
§Error
a grp_core::Error containing the detail of the error.
Source§impl Platform
impl Platform
Sourcepub async fn list_orgs<A: Animation + ?Sized>(
&self,
config: &Config,
animation: &Box<A>,
) -> (Vec<User>, Option<Error>, Vec<Error>)
pub async fn list_orgs<A: Animation + ?Sized>( &self, config: &Config, animation: &Box<A>, ) -> (Vec<User>, Option<Error>, Vec<Error>)
List all the orgs in wich the logged user is member.
config: agrp_core::Configanimation: a struct wich implements the traitgrp_core::animation::Animation
§Return
a tuple with:
Vec<Repo>a list with the reposOption<Error>agrp_core::Errorcontaining the detail of the error, if this error is present, the list of repos is empty.Vec<Error>a list ofgrp_core::Errorthat contains a list of errors if something happen during the paggination.
§Why is this?
a better solution with yield is planned, but for know this is the best i could do.