Class: Google::Apis::SearchconsoleV1::SearchConsoleService

Inherits:
Core::BaseService
  • Object
show all
Defined in:
lib/google/apis/searchconsole_v1/service.rb

Overview

Google Search Console API

The Search Console API provides access to both Search Console data (verified users only) and to public information on an URL basis (anyone)

Examples:

require 'google/apis/searchconsole_v1'

Searchconsole = Google::Apis::SearchconsoleV1 # Alias the module
service = Searchconsole::SearchConsoleService.new

See Also:

Constant Summary collapse

DEFAULT_ENDPOINT_TEMPLATE =
"https://searchconsole.$UNIVERSE_DOMAIN$/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSearchConsoleService

Returns a new instance of SearchConsoleService.



48
49
50
51
52
53
# File 'lib/google/apis/searchconsole_v1/service.rb', line 48

def initialize
  super(DEFAULT_ENDPOINT_TEMPLATE, '',
        client_name: 'google-apis-searchconsole_v1',
        client_version: Google::Apis::SearchconsoleV1::GEM_VERSION)
  @batch_path = 'batch'
end

Instance Attribute Details

#keyString

Returns API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.

Returns:

  • (String)

    API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.



41
42
43
# File 'lib/google/apis/searchconsole_v1/service.rb', line 41

def key
  @key
end

#quota_userString

Returns Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

Returns:

  • (String)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.



46
47
48
# File 'lib/google/apis/searchconsole_v1/service.rb', line 46

def quota_user
  @quota_user
end

Instance Method Details

#add_site(site_url, fields: nil, quota_user: nil, options: nil) {|result, err| ... }

This method returns an undefined value.

Adds a site to the set of the user's sites in Search Console.

Parameters:

  • site_url (String)

    The URL of the site to add.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

  • result (NilClass)

    No result returned for this method

  • err (StandardError)

    error object if request failed

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



248
249
250
251
252
253
254
# File 'lib/google/apis/searchconsole_v1/service.rb', line 248

def add_site(site_url, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:put, 'webmasters/v3/sites/{siteUrl}', options)
  command.params['siteUrl'] = site_url unless site_url.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#delete_site(site_url, fields: nil, quota_user: nil, options: nil) {|result, err| ... }

This method returns an undefined value.

Removes a site from the set of the user's Search Console sites.

Parameters:

  • site_url (String)

    The URI of the property as defined in Search Console. Examples: http:// www.example.com/ or sc-domain:example.com.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

  • result (NilClass)

    No result returned for this method

  • err (StandardError)

    error object if request failed

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



277
278
279
280
281
282
283
# File 'lib/google/apis/searchconsole_v1/service.rb', line 277

def delete_site(site_url, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:delete, 'webmasters/v3/sites/{siteUrl}', options)
  command.params['siteUrl'] = site_url unless site_url.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#delete_sitemap(site_url, feedpath, fields: nil, quota_user: nil, options: nil) {|result, err| ... }

This method returns an undefined value.

Deletes a sitemap from the Sitemaps report. Does not stop Google from crawling this sitemap or the URLs that were previously crawled in the deleted sitemap.

Parameters:

  • site_url (String)

    The site's URL, including protocol. For example: http://www.example.com/.

  • feedpath (String)

    The URL of the actual sitemap. For example: http://www.example.com/sitemap. xml.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

  • result (NilClass)

    No result returned for this method

  • err (StandardError)

    error object if request failed

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



117
118
119
120
121
122
123
124
# File 'lib/google/apis/searchconsole_v1/service.rb', line 117

def delete_sitemap(site_url, feedpath, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:delete, 'webmasters/v3/sites/{siteUrl}/sitemaps/{feedpath}', options)
  command.params['siteUrl'] = site_url unless site_url.nil?
  command.params['feedpath'] = feedpath unless feedpath.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#get_site(site_url, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::SearchconsoleV1::WmxSite

Retrieves information about specific site.

Parameters:

  • site_url (String)

    The URI of the property as defined in Search Console. Examples: http:// www.example.com/ or sc-domain:example.com.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



306
307
308
309
310
311
312
313
314
# File 'lib/google/apis/searchconsole_v1/service.rb', line 306

def get_site(site_url, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:get, 'webmasters/v3/sites/{siteUrl}', options)
  command.response_representation = Google::Apis::SearchconsoleV1::WmxSite::Representation
  command.response_class = Google::Apis::SearchconsoleV1::WmxSite
  command.params['siteUrl'] = site_url unless site_url.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#get_sitemap(site_url, feedpath, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::SearchconsoleV1::WmxSitemap

Retrieves information about a specific sitemap.

Parameters:

  • site_url (String)

    The site's URL, including protocol. For example: http://www.example.com/.

  • feedpath (String)

    The URL of the actual sitemap. For example: http://www.example.com/sitemap. xml.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



149
150
151
152
153
154
155
156
157
158
# File 'lib/google/apis/searchconsole_v1/service.rb', line 149

def get_sitemap(site_url, feedpath, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:get, 'webmasters/v3/sites/{siteUrl}/sitemaps/{feedpath}', options)
  command.response_representation = Google::Apis::SearchconsoleV1::WmxSitemap::Representation
  command.response_class = Google::Apis::SearchconsoleV1::WmxSitemap
  command.params['siteUrl'] = site_url unless site_url.nil?
  command.params['feedpath'] = feedpath unless feedpath.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#inspect_url_index(inspect_url_index_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::SearchconsoleV1::InspectUrlIndexResponse

Index inspection.

Parameters:

  • inspect_url_index_request_object (Google::Apis::SearchconsoleV1::InspectUrlIndexRequest) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



362
363
364
365
366
367
368
369
370
371
# File 'lib/google/apis/searchconsole_v1/service.rb', line 362

def inspect_url_index(inspect_url_index_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:post, 'v1/urlInspection/index:inspect', options)
  command.request_representation = Google::Apis::SearchconsoleV1::InspectUrlIndexRequest::Representation
  command.request_object = inspect_url_index_request_object
  command.response_representation = Google::Apis::SearchconsoleV1::InspectUrlIndexResponse::Representation
  command.response_class = Google::Apis::SearchconsoleV1::InspectUrlIndexResponse
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#list_sitemaps(site_url, sitemap_index: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::SearchconsoleV1::SitemapsListResponse

Lists the sitemaps-entries submitted for this site, or included in the sitemap index file (if sitemapIndex is specified in the request).

Parameters:

  • site_url (String)

    The site's URL, including protocol. For example: http://www.example.com/.

  • sitemap_index (String) (defaults to: nil)

    A URL of a site's sitemap index. For example: http://www.example.com/ sitemapindex.xml.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



185
186
187
188
189
190
191
192
193
194
# File 'lib/google/apis/searchconsole_v1/service.rb', line 185

def list_sitemaps(site_url, sitemap_index: nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:get, 'webmasters/v3/sites/{siteUrl}/sitemaps', options)
  command.response_representation = Google::Apis::SearchconsoleV1::SitemapsListResponse::Representation
  command.response_class = Google::Apis::SearchconsoleV1::SitemapsListResponse
  command.params['siteUrl'] = site_url unless site_url.nil?
  command.query['sitemapIndex'] = sitemap_index unless sitemap_index.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#list_sites(fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::SearchconsoleV1::SitesListResponse

Lists the user's Search Console sites.

Parameters:

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



334
335
336
337
338
339
340
341
# File 'lib/google/apis/searchconsole_v1/service.rb', line 334

def list_sites(fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:get, 'webmasters/v3/sites', options)
  command.response_representation = Google::Apis::SearchconsoleV1::SitesListResponse::Representation
  command.response_class = Google::Apis::SearchconsoleV1::SitesListResponse
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#query_searchanalytic(site_url, search_analytics_query_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::SearchconsoleV1::SearchAnalyticsQueryResponse

Query your data with filters and parameters that you define. Returns zero or more rows grouped by the row keys that you define. You must define a date range of one or more days. When date is one of the group by values, any days without data are omitted from the result list. If you need to know which days have data, issue a broad date range query grouped by date for any metric, and see which day rows are returned.

Parameters:

  • site_url (String)

    The site's URL, including protocol. For example: http://www.example.com/.

  • search_analytics_query_request_object (Google::Apis::SearchconsoleV1::SearchAnalyticsQueryRequest) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/google/apis/searchconsole_v1/service.rb', line 81

def query_searchanalytic(site_url, search_analytics_query_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:post, 'webmasters/v3/sites/{siteUrl}/searchAnalytics/query', options)
  command.request_representation = Google::Apis::SearchconsoleV1::SearchAnalyticsQueryRequest::Representation
  command.request_object = search_analytics_query_request_object
  command.response_representation = Google::Apis::SearchconsoleV1::SearchAnalyticsQueryResponse::Representation
  command.response_class = Google::Apis::SearchconsoleV1::SearchAnalyticsQueryResponse
  command.params['siteUrl'] = site_url unless site_url.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#run_mobile_friendly_test(run_mobile_friendly_test_request_object = nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::SearchconsoleV1::RunMobileFriendlyTestResponse

Runs Mobile-Friendly Test for a given URL.

Parameters:

  • run_mobile_friendly_test_request_object (Google::Apis::SearchconsoleV1::RunMobileFriendlyTestRequest) (defaults to: nil)
  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



392
393
394
395
396
397
398
399
400
401
# File 'lib/google/apis/searchconsole_v1/service.rb', line 392

def run_mobile_friendly_test(run_mobile_friendly_test_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:post, 'v1/urlTestingTools/mobileFriendlyTest:run', options)
  command.request_representation = Google::Apis::SearchconsoleV1::RunMobileFriendlyTestRequest::Representation
  command.request_object = run_mobile_friendly_test_request_object
  command.response_representation = Google::Apis::SearchconsoleV1::RunMobileFriendlyTestResponse::Representation
  command.response_class = Google::Apis::SearchconsoleV1::RunMobileFriendlyTestResponse
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end

#submit_sitemap(site_url, feedpath, fields: nil, quota_user: nil, options: nil) {|result, err| ... }

This method returns an undefined value.

Submits a sitemap for a site.

Parameters:

  • site_url (String)

    The site's URL, including protocol. For example: http://www.example.com/.

  • feedpath (String)

    The URL of the actual sitemap. For example: http://www.example.com/sitemap. xml.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

  • result (NilClass)

    No result returned for this method

  • err (StandardError)

    error object if request failed

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



219
220
221
222
223
224
225
226
# File 'lib/google/apis/searchconsole_v1/service.rb', line 219

def submit_sitemap(site_url, feedpath, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:put, 'webmasters/v3/sites/{siteUrl}/sitemaps/{feedpath}', options)
  command.params['siteUrl'] = site_url unless site_url.nil?
  command.params['feedpath'] = feedpath unless feedpath.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end