jinxapi_github/v1_1_4/request/migrations_get_import_status.rs
1//! Get an import status
2//!
3//! View the progress of an import.
4//!
5//! **Import status**
6//!
7//! This section includes details about the possible values of the `status` field of the Import Progress response.
8//!
9//! An import that does not have errors will progress through these steps:
10//!
11//! * `detecting` - the "detection" step of the import is in progress because the request did not include a `vcs` parameter. The import is identifying the type of source control present at the URL.
12//! * `importing` - the "raw" step of the import is in progress. This is where commit data is fetched from the original repository. The import progress response will include `commit_count` (the total number of raw commits that will be imported) and `percent` (0 - 100, the current progress through the import).
13//! * `mapping` - the "rewrite" step of the import is in progress. This is where SVN branches are converted to Git branches, and where author updates are applied. The import progress response does not include progress information.
14//! * `pushing` - the "push" step of the import is in progress. This is where the importer updates the repository on GitHub. The import progress response will include `push_percent`, which is the percent value reported by `git push` when it is "Writing objects".
15//! * `complete` - the import is complete, and the repository is ready on GitHub.
16//!
17//! If there are problems, you will see one of these in the `status` field:
18//!
19//! * `auth_failed` - the import requires authentication in order to connect to the original repository. To update authentication for the import, please see the [Update an import](https://docs.github.com/rest/reference/migrations#update-an-import) section.
20//! * `error` - the import encountered an error. The import progress response will include the `failed_step` and an error message. Contact [GitHub Support](https://support.github.com/contact?tags=dotcom-rest-api) for more information.
21//! * `detection_needs_auth` - the importer requires authentication for the originating repository to continue detection. To update authentication for the import, please see the [Update an import](https://docs.github.com/rest/reference/migrations#update-an-import) section.
22//! * `detection_found_nothing` - the importer didn't recognize any source control at the URL. To resolve, [Cancel the import](https://docs.github.com/rest/reference/migrations#cancel-an-import) and [retry](https://docs.github.com/rest/reference/migrations#start-an-import) with the correct URL.
23//! * `detection_found_multiple` - the importer found several projects or repositories at the provided URL. When this is the case, the Import Progress response will also include a `project_choices` field with the possible project choices as values. To update project choice, please see the [Update an import](https://docs.github.com/rest/reference/migrations#update-an-import) section.
24//!
25//! **The project_choices field**
26//!
27//! When multiple projects are found at the provided URL, the response hash will include a `project_choices` field, the value of which is an array of hashes each representing a project choice. The exact key/value pairs of the project hashes will differ depending on the version control type.
28//!
29//! **Git LFS related fields**
30//!
31//! This section includes details about Git LFS related fields that may be present in the Import Progress response.
32//!
33//! * `use_lfs` - describes whether the import has been opted in or out of using Git LFS. The value can be `opt_in`, `opt_out`, or `undecided` if no action has been taken.
34//! * `has_large_files` - the boolean value describing whether files larger than 100MB were found during the `importing` step.
35//! * `large_files_size` - the total size in gigabytes of files larger than 100MB found in the originating repository.
36//! * `large_files_count` - the total number of files larger than 100MB found in the originating repository. To see a list of these files, make a "Get Large Files" request.
37//!
38//! [API method documentation](https://docs.github.com/rest/reference/migrations#get-an-import-status)
39
40
41fn url_string(
42 base_url: &str,
43 p_owner: &str,
44 p_repo: &str,
45) -> Result<String, crate::v1_1_4::ApiError> {
46 let trimmed = if base_url.is_empty() {
47 "https://api.github.com"
48 } else {
49 base_url.trim_end_matches('/')
50 };
51 let mut url = String::with_capacity(trimmed.len() + 33);
52 url.push_str(trimmed);
53 url.push_str("/repos/");
54 ::querylizer::Simple::extend(&mut url, &p_owner, false, &::querylizer::encode_path)?;
55 url.push('/');
56 ::querylizer::Simple::extend(&mut url, &p_repo, false, &::querylizer::encode_path)?;
57 url.push_str("/import");
58 Ok(url)
59}
60
61#[cfg(feature = "hyper")]
62pub fn http_builder(
63 base_url: &str,
64 p_owner: &str,
65 p_repo: &str,
66 h_user_agent: &str,
67 h_accept: ::std::option::Option<&str>,
68) -> Result<::http::request::Builder, crate::v1_1_4::ApiError> {
69 let url = url_string(
70 base_url,
71 p_owner,
72 p_repo,
73 )?;
74 let mut builder = ::http::request::Request::get(url);
75 builder = builder.header(
76 "User-Agent",
77 &::querylizer::Simple::to_string(&h_user_agent, false, &::querylizer::passthrough)?
78 );
79 if let Some(value) = &h_accept {
80 builder = builder.header(
81 "Accept",
82 &::querylizer::Simple::to_string(value, false, &::querylizer::passthrough)?
83 );
84 }
85 Ok(builder)
86}
87
88#[cfg(feature = "hyper")]
89#[inline]
90pub fn hyper_request(
91 builder: ::http::request::Builder,
92) -> Result<::http::request::Request<::hyper::Body>, crate::v1_1_4::ApiError> {
93 Ok(builder.body(::hyper::Body::empty())?)
94}
95
96#[cfg(feature = "reqwest")]
97pub fn reqwest_builder(
98 base_url: &str,
99 p_owner: &str,
100 p_repo: &str,
101 h_user_agent: &str,
102 h_accept: ::std::option::Option<&str>,
103) -> Result<::reqwest::Request, crate::v1_1_4::ApiError> {
104 let url = url_string(
105 base_url,
106 p_owner,
107 p_repo,
108 )?;
109 let reqwest_url = ::reqwest::Url::parse(&url)?;
110 let mut request = ::reqwest::Request::new(::reqwest::Method::GET, reqwest_url);
111 let headers = request.headers_mut();
112 headers.append(
113 "User-Agent",
114 ::querylizer::Simple::to_string(&h_user_agent, false, &::querylizer::passthrough)?.try_into()?
115 );
116 if let Some(value) = &h_accept {
117 headers.append(
118 "Accept",
119 ::querylizer::Simple::to_string(value, false, &::querylizer::passthrough)?.try_into()?
120 );
121 }
122 Ok(request)
123}
124
125#[cfg(feature = "reqwest")]
126#[inline(always)]
127pub fn reqwest_request(
128 builder: ::reqwest::Request,
129) -> Result<::reqwest::Request, crate::v1_1_4::ApiError>
130{
131 Ok(builder)
132}
133
134#[cfg(feature = "reqwest-blocking")]
135pub fn reqwest_blocking_builder(
136 base_url: &str,
137 p_owner: &str,
138 p_repo: &str,
139 h_user_agent: &str,
140 h_accept: ::std::option::Option<&str>,
141) -> Result<::reqwest::blocking::Request, crate::v1_1_4::ApiError> {
142 let url = url_string(
143 base_url,
144 p_owner,
145 p_repo,
146 )?;
147 let reqwest_url = ::reqwest::Url::parse(&url)?;
148 let mut request = ::reqwest::blocking::Request::new(::reqwest::Method::GET, reqwest_url);
149 let headers = request.headers_mut();
150 headers.append(
151 "User-Agent",
152 ::querylizer::Simple::to_string(&h_user_agent, false, &::querylizer::passthrough)?.try_into()?
153 );
154 if let Some(value) = &h_accept {
155 headers.append(
156 "Accept",
157 ::querylizer::Simple::to_string(value, false, &::querylizer::passthrough)?.try_into()?
158 );
159 }
160 Ok(request)
161}
162
163#[cfg(feature = "reqwest-blocking")]
164#[inline(always)]
165pub fn reqwest_blocking_request(
166 builder: ::reqwest::blocking::Request,
167) -> Result<::reqwest::blocking::Request, crate::v1_1_4::ApiError>
168{
169 Ok(builder)
170}