Class: Google::Apis::PagespeedonlineV2::PagespeedonlineService

Inherits:
Core::BaseService show all
Defined in:
generated/google/apis/pagespeedonline_v2/service.rb

Overview

PageSpeed Insights API

Analyzes the performance of a web page and provides tailored suggestions to make that page faster.

Examples:

require 'google/apis/pagespeedonline_v2'

Pagespeedonline = Google::Apis::PagespeedonlineV2 # Alias the module
service = Pagespeedonline::PagespeedonlineService.new

See Also:

Instance Attribute Summary collapse

Attributes inherited from Core::BaseService

#authorization, #base_path, #batch_path, #client, #client_options, #request_options, #root_url, #upload_path

Instance Method Summary collapse

Methods inherited from Core::BaseService

#batch, #batch_upload, #fetch_all, #http

Methods included from Core::Logging

#logger

Constructor Details

#initializePagespeedonlineService

Returns a new instance of PagespeedonlineService



52
53
54
55
# File 'generated/google/apis/pagespeedonline_v2/service.rb', line 52

def initialize
  super('https://www.googleapis.com/', 'pagespeedonline/v2/')
  @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.



39
40
41
# File 'generated/google/apis/pagespeedonline_v2/service.rb', line 39

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. Overrides userIp if both are provided.

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. Overrides userIp if both are provided.



45
46
47
# File 'generated/google/apis/pagespeedonline_v2/service.rb', line 45

def quota_user
  @quota_user
end

#user_ipString

Returns IP address of the site where the request originates. Use this if you want to enforce per-user limits.

Returns:

  • (String)

    IP address of the site where the request originates. Use this if you want to enforce per-user limits.



50
51
52
# File 'generated/google/apis/pagespeedonline_v2/service.rb', line 50

def user_ip
  @user_ip
end

Instance Method Details

#run_pagespeed(url, filter_third_party_resources: nil, locale: nil, rule: nil, screenshot: nil, strategy: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::PagespeedonlineV2::Result

Runs PageSpeed analysis on the page at the specified URL, and returns PageSpeed scores, a list of suggestions to make that page faster, and other information.

Parameters:

  • url (String)

    The URL to fetch and analyze

  • filter_third_party_resources (Boolean)

    Indicates if third party resources should be filtered out before PageSpeed analysis.

  • locale (String)

    The locale used to localize formatted results

  • rule (Array<String>, String)

    A PageSpeed rule to run; if none are given, all rules are run

  • screenshot (Boolean)

    Indicates if binary data containing a screenshot should be included

  • strategy (String)

    The analysis strategy to use

  • fields (String)

    Selector specifying which fields to include in a partial response.

  • quota_user (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. Overrides userIp if both are provided.

  • user_ip (String)

    IP address of the site where the request originates. Use this if you want to enforce per-user limits.

  • options (Google::Apis::RequestOptions)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'generated/google/apis/pagespeedonline_v2/service.rb', line 94

def run_pagespeed(url, filter_third_party_resources: nil, locale: nil, rule: nil, screenshot: nil, strategy: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil, &block)
  command =  make_simple_command(:get, 'runPagespeed', options)
  command.response_representation = Google::Apis::PagespeedonlineV2::Result::Representation
  command.response_class = Google::Apis::PagespeedonlineV2::Result
  command.query['filter_third_party_resources'] = filter_third_party_resources unless filter_third_party_resources.nil?
  command.query['locale'] = locale unless locale.nil?
  command.query['rule'] = rule unless rule.nil?
  command.query['screenshot'] = screenshot unless screenshot.nil?
  command.query['strategy'] = strategy unless strategy.nil?
  command.query['url'] = url unless url.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  command.query['userIp'] = user_ip unless user_ip.nil?
  execute_or_queue_command(command, &block)
end