/// <summary>
        /// Retrieves details about crawl errors for a site's sample URL.
        /// Documentation https://developers.google.com/webmasters/v3/reference/urlcrawlerrorssamples/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated webmasters service.</param>
        /// <param name="siteUrl">The site's URL, including protocol. For example: http://www.example.com/</param>
        /// <param name="url">The relative path (without the site) of the sample URL. It must be one of the URLs returned by list(). For example, for the URL https://www.example.com/pagename on the site https://www.example.com/, the url value is pagename</param>
        /// <param name="category">The crawl error category. For example: authPermissions</param>
        /// <param name="platform">The user agent type (platform) that made the request. For example: web</param>
        /// <returns>UrlCrawlErrorsSampleResponse</returns>
        public static UrlCrawlErrorsSample Get(webmastersService service, string siteUrl, string url, string category, string platform)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (siteUrl == null)
                {
                    throw new ArgumentNullException(siteUrl);
                }
                if (url == null)
                {
                    throw new ArgumentNullException(url);
                }
                if (category == null)
                {
                    throw new ArgumentNullException(category);
                }
                if (platform == null)
                {
                    throw new ArgumentNullException(platform);
                }

                // Make the request.
                return(service.Urlcrawlerrorssamples.Get(siteUrl, url, category, platform).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Urlcrawlerrorssamples.Get failed.", ex);
            }
        }
Example #2
0
        /// <summary>
        /// Retrieves a time series of the number of URL crawl errors per error category and platform.
        /// Documentation https://developers.google.com/webmasters/v3/reference/urlcrawlerrorscounts/query
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated webmasters service.</param>
        /// <param name="siteUrl">The site's URL, including protocol. For example: http://www.example.com/</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>UrlCrawlErrorsCountsQueryResponseResponse</returns>
        public static UrlCrawlErrorsCountsQueryResponse Query(webmastersService service, string siteUrl, UrlcrawlerrorscountsQueryOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (siteUrl == null)
                {
                    throw new ArgumentNullException(siteUrl);
                }

                // Building the initial request.
                var request = service.Urlcrawlerrorscounts.Query(siteUrl);

                // Applying optional parameters to the request.
                request = (UrlcrawlerrorscountsResource.QueryRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Urlcrawlerrorscounts.Query failed.", ex);
            }
        }
        /// Documentation https://developers.google.com/webmasters/v3/reference/searchanalytics/query
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated webmasters service.</param>
        /// <param name="siteUrl">The site's URL, including protocol. For example: http://www.example.com/</param>
        /// <param name="body">A valid webmasters v3 body.</param>
        /// <returns>SearchAnalyticsQueryResponseResponse</returns>
        public static SearchAnalyticsQueryResponse Query(webmastersService service, string siteUrl, SearchAnalyticsQueryRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (siteUrl == null)
                {
                    throw new ArgumentNullException(siteUrl);
                }

                // Make the request.
                return(service.Searchanalytics.Query(body, siteUrl).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Searchanalytics.Query failed.", ex);
            }
        }
Example #4
0
        /// <summary>
        /// Retrieves information about a specific sitemap.
        /// Documentation https://developers.google.com/webmasters/v3/reference/sitemaps/get
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated webmasters service.</param>
        /// <param name="siteUrl">The site's URL, including protocol. For example: http://www.example.com/</param>
        /// <param name="feedpath">The URL of the actual sitemap. For example: http://www.example.com/sitemap.xml</param>
        /// <returns>WmxSitemapResponse</returns>
        public static WmxSitemap Get(webmastersService service, string siteUrl, string feedpath)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (siteUrl == null)
                {
                    throw new ArgumentNullException(siteUrl);
                }
                if (feedpath == null)
                {
                    throw new ArgumentNullException(feedpath);
                }

                // Make the request.
                return(service.Sitemaps.Get(siteUrl, feedpath).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Sitemaps.Get failed.", ex);
            }
        }
Example #5
0
        /// <summary>
        /// Lists the sitemaps-entries submitted for this site, or included in the sitemap index file (if sitemapIndex is specified in the request).
        /// Documentation https://developers.google.com/webmasters/v3/reference/sitemaps/list
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated webmasters service.</param>
        /// <param name="siteUrl">The site's URL, including protocol. For example: http://www.example.com/</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>SitemapsListResponseResponse</returns>
        public static SitemapsListResponse List(webmastersService service, string siteUrl, SitemapsListOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (siteUrl == null)
                {
                    throw new ArgumentNullException(siteUrl);
                }

                // Building the initial request.
                var request = service.Sitemaps.List(siteUrl);

                // Applying optional parameters to the request.
                request = (SitemapsResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Sitemaps.List failed.", ex);
            }
        }
        /// <summary>
        /// Lists the user's Search Console sites.
        /// Documentation https://developers.google.com/webmasters/v3/reference/sites/list
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated webmasters service.</param>
        /// <returns>SitesListResponseResponse</returns>
        public static SitesListResponse List(webmastersService service)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }

                // Make the request.
                return(service.Sites.List().Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Sites.List failed.", ex);
            }
        }
        /// <summary>
        /// Removes a site from the set of the user's Search Console sites.
        /// Documentation https://developers.google.com/webmasters/v3/reference/sites/delete
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated webmasters service.</param>
        /// <param name="siteUrl">The URI of the property as defined in Search Console. Examples: http://www.example.com/ or android-app://com.example/</param>
        public static void Delete(webmastersService service, string siteUrl)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (siteUrl == null)
                {
                    throw new ArgumentNullException(siteUrl);
                }

                // Make the request.
                return(service.Sites.Delete(siteUrl).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Sites.Delete failed.", ex);
            }
        }