Class: Google::Apis::SafebrowsingV5::SafebrowsingService

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

Overview

Safe Browsing API

Enables client applications to check web resources (most commonly URLs) against Google-generated lists of unsafe web resources. The Safe Browsing APIs are for non-commercial use only. If you need to use APIs to detect malicious URLs for commercial purposes – meaning “for sale or revenue-generating purposes” – please refer to the Web Risk API.

Examples:

require 'google/apis/safebrowsing_v5'

Safebrowsing = Google::Apis::SafebrowsingV5 # Alias the module
service = Safebrowsing::SafebrowsingService.new

See Also:

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSafebrowsingService

Returns a new instance of SafebrowsingService.



51
52
53
54
55
56
# File 'lib/google/apis/safebrowsing_v5/service.rb', line 51

def initialize
  super(DEFAULT_ENDPOINT_TEMPLATE, '',
        client_name: 'google-apis-safebrowsing_v5',
        client_version: Google::Apis::SafebrowsingV5::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.



44
45
46
# File 'lib/google/apis/safebrowsing_v5/service.rb', line 44

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.



49
50
51
# File 'lib/google/apis/safebrowsing_v5/service.rb', line 49

def quota_user
  @quota_user
end

Instance Method Details

#search_hashes(hash_prefixes: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::SafebrowsingV5::GoogleSecuritySafebrowsingV5SearchHashesResponse

Search for full hashes matching the specified prefixes. This is a custom method as defined by https://google.aip.dev/136 (the custom method refers to this method having a custom name within Google's general API development nomenclature; it does not refer to using a custom HTTP method).

Parameters:

  • hash_prefixes (Array<String>, String) (defaults to: nil)

    Required. The hash prefixes to be looked up. Clients MUST NOT send more than 1000 hash prefixes. However, following the URL processing procedure, clients SHOULD NOT need to send more than 30 hash prefixes. Currently each hash prefix is required to be exactly 4 bytes long. This MAY be relaxed in the future.

  • 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



84
85
86
87
88
89
90
91
92
# File 'lib/google/apis/safebrowsing_v5/service.rb', line 84

def search_hashes(hash_prefixes: nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:get, 'v5/hashes:search', options)
  command.response_representation = Google::Apis::SafebrowsingV5::GoogleSecuritySafebrowsingV5SearchHashesResponse::Representation
  command.response_class = Google::Apis::SafebrowsingV5::GoogleSecuritySafebrowsingV5SearchHashesResponse
  command.query['hashPrefixes'] = hash_prefixes unless hash_prefixes.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end