Skip to main content

google_search_console_api/url_inspection/
mod.rs

1//! URL Inspection API types.
2//!
3//! Types for inspecting URLs and getting indexing status, crawl info, and more.
4
5use serde_derive::{Deserialize, Serialize};
6
7/// Request parameters for URL inspection.
8#[derive(Debug, Serialize, Deserialize, Clone)]
9pub struct RequestUrlInspection {
10    /// The fully-qualified URL to inspect.
11    #[serde(rename = "inspectionUrl")]
12    pub inspection_url: String,
13    /// The URL of the property as defined in Search Console.
14    #[serde(rename = "siteUrl")]
15    pub site_url: String,
16    /// Language code for localized results (e.g., "en", "ja").
17    #[serde(rename = "languageCode")]
18    pub language_code: String,
19}
20
21/// Response from the URL inspection API.
22#[derive(Debug, Serialize, Deserialize, Clone)]
23pub struct ResponseInspectionResult {
24    /// The inspection result.
25    #[serde(rename = "inspectionResult")]
26    pub inspection_result: InspectionResult,
27}
28
29/// Complete inspection result for a URL.
30#[derive(Debug, Serialize, Deserialize, Clone)]
31pub struct InspectionResult {
32    /// Link to the full inspection result in Search Console.
33    #[serde(rename = "inspectionResultLink")]
34    pub inspection_result_link: Option<String>,
35    /// Index status information.
36    #[serde(rename = "indexStatusResult")]
37    pub index_status_result: Option<IndexStatusResult>,
38    /// AMP inspection result.
39    #[serde(rename = "ampResult")]
40    pub amp_result: Option<AmpInspectionResult>,
41    /// Mobile usability inspection result.
42    #[serde(rename = "mobileUsabilityResult")]
43    pub mobile_usability_result: Option<MobileUsabilityInspectionResult>,
44    /// Rich results inspection result.
45    #[serde(rename = "richResultsResult")]
46    pub rich_results_result: Option<RichResultsInspectionResult>,
47}
48
49/// Index status information for a URL.
50#[derive(Debug, Serialize, Deserialize, Clone)]
51pub struct IndexStatusResult {
52    /// Sitemaps that contain this URL.
53    pub sitemap: Option<Vec<String>>,
54    /// URLs that refer to this URL.
55    #[serde(rename = "referringUrls")]
56    pub referring_urls: Option<Vec<String>>,
57    /// Overall verdict for indexing.
58    pub verdict: Option<Verdict>,
59    /// Coverage state description.
60    #[serde(rename = "coverageState")]
61    pub coverage_state: Option<String>,
62    /// Whether robots.txt allows crawling.
63    #[serde(rename = "robotsTxtState")]
64    pub robots_txt_state: Option<RobotsTxtState>,
65    /// Whether indexing is allowed.
66    #[serde(rename = "indexingState")]
67    pub indexing_state: Option<IndexingState>,
68    /// Last crawl time.
69    #[serde(rename = "lastCrawlTime")]
70    pub last_crawl_time: Option<String>,
71    /// Page fetch state.
72    #[serde(rename = "pageFetchState")]
73    pub page_fetch_state: Option<PageFetchState>,
74    /// Google-selected canonical URL.
75    #[serde(rename = "googleCanonical")]
76    pub google_canonical: Option<String>,
77    /// User-declared canonical URL.
78    #[serde(rename = "userCanonical")]
79    pub user_canonical: Option<String>,
80    /// User agent used for crawling.
81    #[serde(rename = "crawledAs")]
82    pub crawled_as: Option<CrawlUserAgent>,
83}
84
85/// Overall verdict for an inspection.
86#[derive(Debug, Serialize, Deserialize, Clone)]
87pub enum Verdict {
88    /// Unspecified verdict.
89    #[serde(rename = "VERDICT_UNSPECIFIED")]
90    VerdictUnspecified,
91    /// Passed inspection.
92    PASS,
93    /// Partially passed inspection.
94    PARTIAL,
95    /// Failed inspection.
96    FAIL,
97    /// Neutral result.
98    NEUTRAL,
99}
100
101/// Robots.txt crawl permission state.
102#[derive(Debug, Serialize, Deserialize, Clone)]
103pub enum RobotsTxtState {
104    /// Unspecified state.
105    #[serde(rename = "ROBOTS_TXT_STATE_UNSPECIFIED")]
106    RobotsTxtStateUnspecified,
107    /// Crawling is allowed by robots.txt.
108    ALLOWED,
109    /// Crawling is disallowed by robots.txt.
110    DISALLOWED,
111}
112
113/// Indexing permission state.
114#[derive(Debug, Serialize, Deserialize, Clone)]
115pub enum IndexingState {
116    /// Unspecified state.
117    #[serde(rename = "INDEXING_STATE_UNSPECIFIED")]
118    IndexingStateUnspecified,
119    /// Indexing is allowed.
120    #[serde(rename = "INDEXING_ALLOWED")]
121    IndexingAllowed,
122    /// Blocked by meta tag.
123    #[serde(rename = "BLOCKED_BY_META_TAG")]
124    BlockedByMetaTag,
125    /// Blocked by HTTP header.
126    #[serde(rename = "BLOCKED_BY_HTTP_HEADER")]
127    BlockedByHttpHeader,
128    /// Blocked by robots.txt.
129    #[serde(rename = "BLOCKED_BY_ROBOTS_TXT")]
130    BlockedByRobotsTxt,
131}
132
133/// Page fetch state.
134#[derive(Debug, Serialize, Deserialize, Clone)]
135pub enum PageFetchState {
136    /// Unspecified state.
137    #[serde(rename = "PAGE_FETCH_STATE_UNSPECIFIED")]
138    PageFetchStateUnspecified,
139    /// Page fetched successfully.
140    SUCCESSFUL,
141    /// Soft 404 detected.
142    #[serde(rename = "SOFT_404")]
143    Soft404,
144    /// Blocked by robots.txt.
145    #[serde(rename = "BLOCKED_ROBOTS_TXT")]
146    BlockedRobotsTxt,
147    /// Page not found (404).
148    #[serde(rename = "NOT_FOUND")]
149    NotFound,
150    /// Access denied (401).
151    #[serde(rename = "ACCESS_DENIED")]
152    AccessDenied,
153    /// Server error (5xx).
154    #[serde(rename = "SERVER_ERROR")]
155    ServerError,
156    /// Redirect error.
157    #[serde(rename = "REDIRECT_ERROR")]
158    RedirectError,
159    /// Access forbidden (403).
160    #[serde(rename = "ACCESS_FORBIDDEN")]
161    AccessForbidden,
162    /// Blocked by 4xx error.
163    #[serde(rename = "BLOCKED_4XX")]
164    Blocked4xx,
165    /// Internal crawl error.
166    #[serde(rename = "INTERNAL_CRAWL_ERROR")]
167    InternalCrawlError,
168    /// Invalid URL.
169    #[serde(rename = "INVALID_URL")]
170    InvalidUrl,
171}
172
173/// User agent used for crawling.
174#[derive(Debug, Serialize, Deserialize, Clone)]
175pub enum CrawlUserAgent {
176    /// Unspecified user agent.
177    #[serde(rename = "CRAWLING_USER_AGENT_UNSPECIFIED")]
178    CrawlingUserAgentUnspecified,
179    /// Desktop user agent.
180    DESKTOP,
181    /// Mobile user agent.
182    MOBILE,
183}
184
185/// AMP inspection result.
186#[derive(Debug, Serialize, Deserialize, Clone)]
187pub struct AmpInspectionResult {
188    /// List of AMP issues.
189    pub issues: Option<Vec<AmpIssue>>,
190    /// Overall AMP verdict.
191    pub verdict: Option<Verdict>,
192    /// The AMP URL.
193    #[serde(rename = "ampUrl")]
194    pub amp_url: Option<String>,
195    /// Robots.txt state for AMP.
196    #[serde(rename = "robotsTxtState")]
197    pub robots_txt_state: Option<RobotsTxtState>,
198    /// AMP indexing state.
199    #[serde(rename = "indexingState")]
200    pub indexing_state: Option<AmpIndexingState>,
201    /// AMP index status verdict.
202    #[serde(rename = "ampIndexStatusVerdict")]
203    pub amp_index_status_verdict: Option<Verdict>,
204    /// Last crawl time for AMP.
205    #[serde(rename = "lastCrawlTime")]
206    pub last_crawl_time: Option<String>,
207    /// Page fetch state for AMP.
208    #[serde(rename = "pageFetchState")]
209    pub page_fetch_state: Option<PageFetchState>,
210}
211
212/// AMP indexing state.
213#[derive(Debug, Serialize, Deserialize, Clone)]
214pub enum AmpIndexingState {
215    /// Unspecified state.
216    #[serde(rename = "AMP_INDEXING_STATE_UNSPECIFIED")]
217    AmpIndexingStateUnspecified,
218    /// AMP indexing is allowed.
219    #[serde(rename = "AMP_INDEXING_ALLOWED")]
220    AmpIndexingAllowed,
221    /// Blocked due to noindex.
222    #[serde(rename = "BLOCKED_DUE_TO_NOINDEX")]
223    BlockedDueToNoindex,
224    /// Blocked due to expired unavailable_after.
225    #[serde(rename = "BLOCKED_DUE_TO_EXPIRED_UNAVAILABLE_AFTER")]
226    BlockedDueToExpiredUnavailableAfter,
227}
228
229/// AMP issue.
230#[derive(Debug, Serialize, Deserialize, Clone)]
231pub struct AmpIssue {
232    /// Issue message.
233    #[serde(rename = "issueMessage")]
234    pub issue_message: Option<String>,
235    /// Issue severity.
236    pub severity: Option<Severity>,
237}
238
239/// Issue severity level.
240#[derive(Debug, Serialize, Deserialize, Clone)]
241pub enum Severity {
242    /// Unspecified severity.
243    #[serde(rename = "SEVERITY_UNSPECIFIED")]
244    SeverityUnspecified,
245    /// Warning level.
246    WARNING,
247    /// Error level.
248    ERROR,
249}
250
251/// Mobile usability inspection result.
252#[derive(Debug, Serialize, Deserialize, Clone)]
253pub struct MobileUsabilityInspectionResult {
254    /// List of mobile usability issues.
255    pub issues: Option<Vec<MobileUsabilityIssue>>,
256    /// Overall mobile usability verdict.
257    pub verdict: Option<Verdict>,
258}
259
260/// Mobile usability issue.
261#[derive(Debug, Serialize, Deserialize, Clone)]
262pub struct MobileUsabilityIssue {
263    /// Type of mobile usability issue.
264    #[serde(rename = "issueType")]
265    pub issue_type: Option<MobileUsabilityIssueType>,
266    /// Issue severity.
267    pub severity: Option<Severity>,
268    /// Issue message.
269    pub message: Option<String>,
270}
271
272/// Type of mobile usability issue.
273#[derive(Debug, Serialize, Deserialize, Clone)]
274pub enum MobileUsabilityIssueType {
275    /// Unspecified issue type.
276    #[serde(rename = "MOBILE_USABILITY_ISSUE_TYPE_UNSPECIFIED")]
277    MobileUsabilityIssueTypeUnspecified,
278    /// Uses incompatible plugins (e.g., Flash).
279    #[serde(rename = "USES_INCOMPATIBLE_PLUGINS")]
280    UsesIncompatiblePlugins,
281    /// Viewport not configured.
282    #[serde(rename = "CONFIGURE_VIEWPORT")]
283    ConfigureViewport,
284    /// Fixed-width viewport.
285    #[serde(rename = "FixedWidthViewport")]
286    FixedWidthViewport,
287    /// Content wider than viewport.
288    #[serde(rename = "SizeContentToViewport")]
289    SizeContentToViewport,
290    /// Text too small to read.
291    #[serde(rename = "UseLegibleFontSizes")]
292    UseLegibleFontSizes,
293    /// Tap targets too close together.
294    #[serde(rename = "TapTargetsTooClose")]
295    TapTargetsTooClose,
296}
297
298/// Rich results inspection result.
299#[derive(Debug, Serialize, Deserialize, Clone)]
300pub struct RichResultsInspectionResult {
301    /// Detected rich result items.
302    #[serde(rename = "detectedItems")]
303    pub detected_items: Option<Vec<DetectedItems>>,
304    /// Overall rich results verdict.
305    pub verdict: Option<Verdict>,
306}
307
308/// Detected rich result items.
309#[derive(Debug, Serialize, Deserialize, Clone)]
310pub struct DetectedItems {
311    /// List of items.
312    pub items: Option<Vec<DetectedItemsItem>>,
313    /// Type of rich result.
314    #[serde(rename = "richResultType")]
315    pub rich_result_type: Option<String>,
316}
317
318/// Individual detected rich result item.
319#[derive(Debug, Serialize, Deserialize, Clone)]
320pub struct DetectedItemsItem {
321    /// Issues with this item.
322    pub issues: Option<Vec<RichResultsIssue>>,
323    /// Name of the item.
324    pub name: Option<String>,
325}
326
327/// Rich results issue.
328#[derive(Debug, Serialize, Deserialize, Clone)]
329pub struct RichResultsIssue {
330    /// Issue message.
331    #[serde(rename = "issueMessage")]
332    pub issue_message: Option<String>,
333    /// Issue severity.
334    pub severity: Option<Severity>,
335}