Commit 8617ef67 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

gitlab: remove deprecated APIs

parent d5147bc0
# v0.1301.0 (unreleased)
## Deprecations
* The REST endpoint methods on the `Gitlab` structure have been removed.
Associated helper structures for resource creation endpoints have been
removed as well:
- `CreateMergeRequestParams`
- `CreateMergeRequestParamsBuilder`
- `CreateGroupParams`
- `CreateGroupParamsBuilder`
- `CreateProjectParams`
- `CreateProjectParamsBuilder`
- `MergeMethod`
- `BuildGitStrategy`
- `AutoDeployStrategy`
- `WebhookEvents`
- `CommitStatusInfo`
- `MergeRequestStateFilter`
- `RepoFile`
- `ProjectFeatures`
- `QueryParamSlice`
- `QueryParamVec`
* Now-impossible error conditions have been removed from `GitlabError`.
# v0.1300.0
## Deprecations
......
This diff is collapsed.
......@@ -27,9 +27,6 @@ mod auth;
#[cfg(feature = "client_api")]
pub use crate::auth::AuthError;
#[cfg(feature = "client_api")]
#[allow(deprecated)]
pub use crate::gitlab::{CommitStatusInfo, MergeRequestStateFilter};
#[cfg(feature = "client_api")]
pub use crate::gitlab::{Gitlab, GitlabBuilder, GitlabError};
pub use crate::types::*;
......
......@@ -69,20 +69,3 @@ macro_rules! enum_serialize {
}
};
}
macro_rules! with_event {
{ $method: ident, $name: ident } => {
pub fn $method(mut self) -> Self {
self.$name = true;
self
}
};
}
macro_rules! get_event {
{ $name: ident } => {
pub fn $name(&self) -> bool {
self.$name
}
};
}
......@@ -16,11 +16,9 @@ use std::fmt::{self, Display, Formatter};
use std::str::FromStr;
use chrono::{DateTime, NaiveDate, Utc};
use derive_builder::Builder;
use serde::de::{DeserializeOwned, Error};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_json::{self, Value};
use url::Url;
// This is only used in internal API calls.
//#[derive(Serialize, Deserialize, Debug, Clone)]
......@@ -29,14 +27,6 @@ use url::Url;
// pub name: String,
//}
/// Type alias for slice of string two-tuples
#[deprecated(since = "0.1300.0", note = "unnecessary with the new API pattern")]
pub type QueryParamSlice<'a> = &'a [(&'a str, &'a str)];
/// Type alias for Vec of string two-tuples
#[deprecated(since = "0.1300.0", note = "unnecessary with the new API pattern")]
pub type QueryParamVec<'a> = Vec<(&'a str, &'a str)>;
impl_id!(UserId, "Type-safe user ID.");
/// The states a user account can be in.
......@@ -348,62 +338,6 @@ impl From<ProjectHook> for Hook {
}
}
/// The events a webhook listener may receive.
#[derive(Debug, Default, Clone, Copy)]
pub struct WebhookEvents {
/// Whether to receive job events of not.
job: bool,
/// Whether to receive issue events of not.
issues: bool,
/// Whether to receive confidential issue events of not.
confidential_issues: bool,
/// Whether to receive merge request events of not.
merge_requests: bool,
/// Whether to receive note (comment) events of not.
note: bool,
/// Whether to receive pipeline events of not.
pipeline: bool,
/// Whether to receive push events of not.
push: bool,
/// Whether to receive wiki events of not.
wiki_page: bool,
}
impl WebhookEvents {
/// Create a new, empty webhook event set.
#[deprecated(since = "0.1300.0", note = "unnecessary with the new API pattern")]
pub fn new() -> Self {
WebhookEvents {
job: false,
issues: false,
confidential_issues: false,
merge_requests: false,
note: false,
pipeline: false,
push: false,
wiki_page: false,
}
}
with_event! {with_job, job}
with_event! {with_issues, issues}
with_event! {with_confidential_issues, issues}
with_event! {with_merge_requests, merge_requests}
with_event! {with_note, note}
with_event! {with_pipeline, pipeline}
with_event! {with_push, push}
with_event! {with_wiki_page, wiki_page}
get_event! {job}
get_event! {issues}
get_event! {confidential_issues}
get_event! {merge_requests}
get_event! {note}
get_event! {pipeline}
get_event! {push}
get_event! {wiki_page}
}
impl_id!(ProjectId, "Type-safe project ID.");
/// Basic project information.
......@@ -1891,46 +1825,6 @@ impl From<MergeRequestChanges> for MergeRequest {
}
}
/// param to create a merge request.
#[derive(Serialize, Deserialize, Builder, Debug, Clone, Default)]
#[builder(default)]
#[builder(field(private))]
#[builder(setter(into, strip_option))]
pub struct CreateMergeRequestParams {
/// The source branch on source project
pub source_branch: String,
/// The target branch
pub target_branch: String,
/// Title of MR
pub title: String,
/// assignee user ID
pub assignee_id: Option<UserId>,
/// The ID of the user(s) to assign the MR to.
/// Set to 0 or provide an empty value to unassign all assignees.
pub assignee_ids: Option<Vec<UserId>>,
/// Description of MR
pub description: Option<String>,
/// The target project (numeric id) if different from source project
pub target_project_id: Option<ProjectId>,
/// Labels for MR as a comma-separated list
pub labels: Option<String>,
/// The global ID of a milestone
pub milestone_id: Option<MilestoneId>,
/// Flag indicating if a merge request should remove the source branch when merging
pub remove_source_branch: Option<bool>,
/// Allow commits from members who can merge to the target branch
pub allow_collaboration: Option<bool>,
/// Squash commits into a single commit when merging
pub squash: Option<bool>,
}
impl CreateMergeRequestParams {
#[deprecated(since = "0.1300.0", note = "unnecessary with the new API pattern")]
pub fn builder() -> CreateMergeRequestParamsBuilder {
CreateMergeRequestParamsBuilder::default()
}
}
impl_id!(SshKeyId, "Type-safe SSH key ID.");
/// An uploaded SSH key.
......@@ -2704,277 +2598,3 @@ pub struct EventLabel {
/// The description of the label.
pub description: Option<String>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct RepoFile {
#[deprecated(since = "0.1300.0", note = "unnecessary with the new API pattern")]
pub file_path: String,
#[deprecated(since = "0.1300.0", note = "unnecessary with the new API pattern")]
pub branch: String,
}
#[derive(Debug, Clone)]
#[deprecated(since = "0.1300.0", note = "unnecessary with the new API pattern")]
pub enum ProjectFeatures {
Issues(FeatureVisibilityLevel),
Repository(FeatureVisibilityLevel),
MergeRequests(FeatureVisibilityLevel),
Builds(FeatureVisibilityLevel),
Wiki(FeatureVisibilityLevel),
Snippets(FeatureVisibilityLevel),
}
#[allow(deprecated)]
impl ProjectFeatures {
pub fn name(&self) -> &'static str {
match self {
ProjectFeatures::Issues(_) => "issues_access_level",
ProjectFeatures::Repository(_) => "repository_access_level",
ProjectFeatures::MergeRequests(_) => "merge_requests_access_level",
ProjectFeatures::Builds(_) => "builds_access_level",
ProjectFeatures::Wiki(_) => "wiki_access_level",
ProjectFeatures::Snippets(_) => "snippets_access_level",
}
}
pub fn access_level(&self) -> &FeatureVisibilityLevel {
match self {
ProjectFeatures::Issues(a)
| ProjectFeatures::Repository(a)
| ProjectFeatures::MergeRequests(a)
| ProjectFeatures::Builds(a)
| ProjectFeatures::Wiki(a)
| ProjectFeatures::Snippets(a) => a,
}
}
}
/// Params for group creation.
///
/// Used with `create_group` method (see [doc here](../gitlab/struct.Gitlab.html#method.create_group))
#[derive(Debug, Clone, Builder, Serialize, Default)]
#[builder(default)]
#[builder(field(private))]
#[builder(setter(into, strip_option))]
pub struct CreateGroupParams {
/// The group name
#[builder(setter(skip))]
pub(crate) name: Option<String>,
/// The path of the group
#[builder(setter(skip))]
pub(crate) path: Option<String>,
/// The group description
pub(crate) description: Option<String>,
/// The group visibility level, can be `private`, `internal` or `public`
pub(crate) visibility: Option<VisibilityLevel>,
/// Prevent sharing a project with another group within this group
pub(crate) share_with_group_lock: Option<bool>,
/// Require all users in this group to setup two-factor authentication
pub(crate) require_two_factor_authentication: Option<bool>,
/// Time before two-factor authentication is enforced
pub(crate) two_factor_grace_period: Option<u64>,
/// Determine if developers can create projects in the group
pub(crate) project_creation_level: Option<AccessLevel>,
/// Default to Auto Devops pipeline for all projects within this group
pub(crate) auto_devops_enabled: Option<bool>,
/// Role allowed to create subgroups
pub(crate) subgroup_creation_level: Option<AccessLevel>,
/// Disable email notification
pub(crate) emails_disabled: Option<bool>,
/// Disable the capability of a group from getting mentioned
pub(crate) mentions_disabled: Option<bool>,
/// Enable/disable Large File Storage (LFS) for the projects in this group
pub(crate) lfs_enabled: Option<bool>,
/// Allow users to request membership
pub(crate) request_access_enabled: Option<bool>,
/// The parent group ID for creating a nesting group
pub(crate) parent_id: Option<GroupId>,
/// [Gitlab Starter and higher] pipeline minutes quota for this group
pub(crate) shared_runners_minutes_limit: Option<u64>,
/// [Gitlab Starter and higher] extra pipeline minutes quota for this group
pub(crate) extra_shared_runners_minutes_limit: Option<u64>,
}
impl CreateGroupParams {
#[deprecated(since = "0.1300.0", note = "unnecessary with the new API pattern")]
pub fn builder() -> CreateGroupParamsBuilder {
CreateGroupParamsBuilder::default()
}
}
/// Params for project creation.
///
/// Used with `create_project` method (see [doc here](../gitlab/struct.Gitlab.html#method.create_project))
#[derive(Debug, Clone, Builder, Serialize, Default)]
#[builder(default)]
#[builder(field(private))]
#[builder(setter(into, strip_option))]
pub struct CreateProjectParams {
/// The name of the project
#[builder(setter(skip))]
pub(crate) name: Option<String>,
/// The path of the project
#[builder(setter(skip))]
pub(crate) path: Option<String>,
/// Namespace for the new projects (defaults to current user namespaces)
pub(crate) namespace_id: Option<u64>,
/// `master` by default
pub(crate) default_branch: Option<String>,
/// Short project description
pub(crate) description: Option<String>,
/// One of `disabled`, `private`, `enabled`
pub(crate) issues_access_level: Option<FeatureVisibilityLevel>,
/// One of `disabled`, `private`, `enabled`
pub(crate) repository_access_level: Option<FeatureVisibilityLevel>,
/// One of `disabled`, `private`, `enabled`
pub(crate) merge_requests_access_level: Option<FeatureVisibilityLevel>,
/// One of `disabled`, `private`, `enabled`
pub(crate) builds_access_level: Option<FeatureVisibilityLevel>,
/// One of `disabled`, `private`, `enabled`
pub(crate) wiki_access_level: Option<FeatureVisibilityLevel>,
/// One of `disabled`, `private`, `enabled`
pub(crate) snippets_access_level: Option<FeatureVisibilityLevel>,
/// One of `disabled`, `private`, `enabled`, `public`
pub(crate) pages_access_level: Option<FeatureVisibilityLevel>,
/// Automatically resolve merge requests diffs discussions on lines changed with a push
pub(crate) resolve_outdated_diff_discussions: Option<bool>,
/// Enable container registry for this project
pub(crate) container_registry_enabled: Option<bool>,
/// Update the container expiration for this project.
#[deprecated(note = "this field did not turn into parameters correctly")]
container_expiration_policy_attributes: Option<Vec<String>>,
/// Enable shared runners for this project
pub(crate) shared_runners_enabled: Option<bool>,
/// Project visibility level
pub(crate) visibility: Option<VisibilityLevel>,
/// URL to import repository from
#[builder(setter(name = "_import_url"))]
pub(crate) import_url: Option<String>,
/// If `true` jobs can be viewed by non-project members
pub(crate) public_builds: Option<bool>,
/// Set wether merge requests can only be merged with successful jobs
pub(crate) only_allow_merge_if_pipeline_succeeds: Option<bool>,
/// Set wether merge requests can only be merged when all the discussions are resolved
pub(crate) only_allow_merge_if_all_discussions_are_resolved: Option<bool>,
/// Set the merge method used
#[allow(deprecated)]
pub(crate) merge_method: Option<MergeMethod>,
/// Set wether auto-closing referenced issues on default branch
pub(crate) autoclose_referenced_issues: Option<bool>,
/// Enable LFS
pub(crate) lfs_enabled: Option<bool>,
/// Allow user to request member access
pub(crate) request_access_enabled: Option<bool>,
/// The list of tags for a project
pub(crate) tag_list: Option<Vec<String>>,
/// Show link to create/view merge request wehen pushing from the command line
pub(crate) printing_merge_request_link_enabled: Option<bool>,
/// The git strategy. Defaults to fetch
#[allow(deprecated)]
pub(crate) build_git_strategy: Option<BuildGitStrategy>,
/// The maximum amount of time in minutes a job is allowed to run
pub(crate) build_timeout: Option<u64>,
/// Auto-cancel pending pipeline
pub(crate) auto_cancel_pending_pipelines: Option<bool>,
/// Test coverage parsing
pub(crate) build_coverage_regex: Option<String>,
/// The path to CI config file
pub(crate) ci_config_path: Option<String>,
/// Enable Auto DevOps for this project
pub(crate) auto_devops_enabled: Option<bool>,
/// Auto Deploy strategy (`continuous`, `manual` or `timed_incremental`)
pub(crate) auto_devops_deploy_strategy: Option<String>,
/// [Gitlab starter and higher]
/// Which storage shard the repository is on. Available only to admins
pub(crate) repository_storage: Option<String>,
/// [Gitlab starter and higher]
/// How many approvers should approve merge requests by default
pub(crate) approvals_before_merge: Option<u64>,
/// [Gitlab starter and higher]
/// The classification label for the project
pub(crate) external_authorization_classification_label: Option<String>,
/// [Gitlab starter and higher] Enables pull mirroring in a project
pub(crate) mirror: Option<bool>,
/// [Gitlab starter and higher]
/// Pull mirroring triggers builds
pub(crate) mirror_trigger_builds: Option<bool>,
/// `false` by default
pub(crate) initialize_with_readme: Option<bool>,
/// When used without `use_custom_template`, name of a built-in project template.
/// When used with `use_custom_template`, name of a custom project template
pub(crate) template_name: Option<String>,
/// [Gitlab silver and higher]
/// When used with `use_custom_template`, project ID of a custom project template.
/// This is preferable to using `template_name` since `template_name` may be ambiguous
pub(crate) template_project_id: Option<u64>,
/// [Gitlab silver and higher]
/// When used with `use_custom_template`, project ID of a custom project template.
/// This is preferable to using `template_name` since `template_name` may be ambiguous
pub(crate) use_custom_template: Option<bool>,
/// [Gitlab silver and higher]
/// For group-level custom templates, specifies ID of group from which all the custom project templates are sourced.
/// Leave empty for instance-level templates. Requires `use_custom_template` to be true
pub(crate) group_with_project_templates_id: Option<u64>,
/// [Gitlab silver and higher]
/// Enable or disable packages repository feature
pub(crate) packages_enabled: Option<bool>,
}
impl CreateProjectParams {
#[deprecated(since = "0.1300.0", note = "unnecessary with the new API pattern")]
pub fn builder() -> CreateProjectParamsBuilder {
CreateProjectParamsBuilder::default()
}
}
impl CreateProjectParamsBuilder {
pub fn import_url(&mut self, url: Url) -> &mut Self {
self.import_url = Some(Some(url.as_str().to_string()));
self
}
}
#[allow(deprecated)]
mod deprecated {
use serde::{Deserialize, Serialize};
/// Merge methods
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[deprecated(since = "0.1300.0", note = "unnecessary with the new API pattern")]
pub enum MergeMethod {
/// A merge commit is created for every merge,
/// and merging is allowed as long as there are no conflicts
#[serde(rename = "merge")]
Merge,
/// A merge commit is created for every merge, but merging is possible only if
/// fast-forward merge is possible
#[serde(rename = "rebase_merge")]
RebaseMerge,
/// No merge commit create, all merges are fast-forwarded
#[serde(rename = "ff")]
FastForward,
}
/// Build git strategy
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[deprecated(since = "0.1300.0", note = "unnecessary with the new API pattern")]
pub enum BuildGitStrategy {
#[serde(rename = "fetch")]
Fetch,
#[serde(rename = "clone")]
Clone,
}
/// Auto devops deply strategy
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[deprecated(since = "0.1300.0", note = "unnecessary with the new API pattern")]
pub enum AutoDeployStrategy {
#[serde(rename = "continuous")]
Continuous,
#[serde(rename = "manual")]
Manual,
#[serde(rename = "timed_incremental")]
TimedIncremental,
}
}
pub use self::deprecated::*;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment