Skip to content

Commit 8ae95f7

Browse files
1 parent 1ec40df commit 8ae95f7

7 files changed

Lines changed: 246 additions & 8 deletions

File tree

src/Safebrowsing.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class Safebrowsing extends \Google\Service
4343
public $hashList;
4444
public $hashLists;
4545
public $hashes;
46+
public $urls;
4647
public $rootUrlTemplate;
4748

4849
/**
@@ -160,6 +161,26 @@ public function __construct($clientOrConfig = [], $rootUrl = null)
160161
]
161162
]
162163
);
164+
$this->urls = new Safebrowsing\Resource\Urls(
165+
$this,
166+
$this->serviceName,
167+
'urls',
168+
[
169+
'methods' => [
170+
'search' => [
171+
'path' => 'v5/urls:search',
172+
'httpMethod' => 'GET',
173+
'parameters' => [
174+
'urls' => [
175+
'location' => 'query',
176+
'type' => 'string',
177+
'repeated' => true,
178+
],
179+
],
180+
],
181+
]
182+
]
183+
);
163184
}
164185
}
165186

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
/*
3+
* Copyright 2014 Google Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
6+
* use this file except in compliance with the License. You may obtain a copy of
7+
* the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations under
15+
* the License.
16+
*/
17+
18+
namespace Google\Service\Safebrowsing;
19+
20+
class GoogleSecuritySafebrowsingV5SearchUrlsResponse extends \Google\Collection
21+
{
22+
protected $collection_key = 'threats';
23+
/**
24+
* The client-side cache duration. The client MUST add this duration to the
25+
* current time to determine the expiration time. The expiration time then
26+
* applies to every URL queried by the client in the request, regardless of
27+
* how many URLs are returned in the response. Even if the server returns no
28+
* matches for a particular URL, this fact MUST also be cached by the client.
29+
* If and only if the field `threats` is empty, the client MAY increase the
30+
* `cache_duration` to determine a new expiration that is later than that
31+
* specified by the server. In any case, the increased cache duration must not
32+
* be longer than 24 hours. Important: the client MUST NOT assume that the
33+
* server will return the same cache duration for all responses. The server
34+
* MAY choose different cache durations for different responses depending on
35+
* the situation.
36+
*
37+
* @var string
38+
*/
39+
public $cacheDuration;
40+
protected $threatsType = GoogleSecuritySafebrowsingV5ThreatUrl::class;
41+
protected $threatsDataType = 'array';
42+
43+
/**
44+
* The client-side cache duration. The client MUST add this duration to the
45+
* current time to determine the expiration time. The expiration time then
46+
* applies to every URL queried by the client in the request, regardless of
47+
* how many URLs are returned in the response. Even if the server returns no
48+
* matches for a particular URL, this fact MUST also be cached by the client.
49+
* If and only if the field `threats` is empty, the client MAY increase the
50+
* `cache_duration` to determine a new expiration that is later than that
51+
* specified by the server. In any case, the increased cache duration must not
52+
* be longer than 24 hours. Important: the client MUST NOT assume that the
53+
* server will return the same cache duration for all responses. The server
54+
* MAY choose different cache durations for different responses depending on
55+
* the situation.
56+
*
57+
* @param string $cacheDuration
58+
*/
59+
public function setCacheDuration($cacheDuration)
60+
{
61+
$this->cacheDuration = $cacheDuration;
62+
}
63+
/**
64+
* @return string
65+
*/
66+
public function getCacheDuration()
67+
{
68+
return $this->cacheDuration;
69+
}
70+
/**
71+
* Unordered list. The unordered list of threat matches found. Each entry
72+
* contains a URL and the threat types that were found matching that URL. The
73+
* list size can be greater than the number of URLs in the request as the all
74+
* expressions of the URL would've been considered.
75+
*
76+
* @param GoogleSecuritySafebrowsingV5ThreatUrl[] $threats
77+
*/
78+
public function setThreats($threats)
79+
{
80+
$this->threats = $threats;
81+
}
82+
/**
83+
* @return GoogleSecuritySafebrowsingV5ThreatUrl[]
84+
*/
85+
public function getThreats()
86+
{
87+
return $this->threats;
88+
}
89+
}
90+
91+
// Adding a class alias for backwards compatibility with the previous class name.
92+
class_alias(GoogleSecuritySafebrowsingV5SearchUrlsResponse::class, 'Google_Service_Safebrowsing_GoogleSecuritySafebrowsingV5SearchUrlsResponse');
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/*
3+
* Copyright 2014 Google Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
6+
* use this file except in compliance with the License. You may obtain a copy of
7+
* the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations under
15+
* the License.
16+
*/
17+
18+
namespace Google\Service\Safebrowsing;
19+
20+
class GoogleSecuritySafebrowsingV5ThreatUrl extends \Google\Collection
21+
{
22+
protected $collection_key = 'threatTypes';
23+
/**
24+
* Unordered list. The unordered list of threat that the URL is classified as.
25+
*
26+
* @var string[]
27+
*/
28+
public $threatTypes;
29+
/**
30+
* The requested URL that was matched by one or more threats.
31+
*
32+
* @var string
33+
*/
34+
public $url;
35+
36+
/**
37+
* Unordered list. The unordered list of threat that the URL is classified as.
38+
*
39+
* @param string[] $threatTypes
40+
*/
41+
public function setThreatTypes($threatTypes)
42+
{
43+
$this->threatTypes = $threatTypes;
44+
}
45+
/**
46+
* @return string[]
47+
*/
48+
public function getThreatTypes()
49+
{
50+
return $this->threatTypes;
51+
}
52+
/**
53+
* The requested URL that was matched by one or more threats.
54+
*
55+
* @param string $url
56+
*/
57+
public function setUrl($url)
58+
{
59+
$this->url = $url;
60+
}
61+
/**
62+
* @return string
63+
*/
64+
public function getUrl()
65+
{
66+
return $this->url;
67+
}
68+
}
69+
70+
// Adding a class alias for backwards compatibility with the previous class name.
71+
class_alias(GoogleSecuritySafebrowsingV5ThreatUrl::class, 'Google_Service_Safebrowsing_GoogleSecuritySafebrowsingV5ThreatUrl');

src/Safebrowsing/Resource/HashList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
class HashList extends \Google\Service\Resource
3131
{
3232
/**
33-
* Get the latest contents of a hash list. A hash list may either by a threat
33+
* Gets the latest contents of a hash list. A hash list may either by a threat
3434
* list or a non-threat list such as the Global Cache. This is a standard Get
3535
* method as defined by https://google.aip.dev/131 and the HTTP method is also
3636
* GET. (hashList.get)

src/Safebrowsing/Resource/HashLists.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
class HashLists extends \Google\Service\Resource
3232
{
3333
/**
34-
* Get multiple hash lists at once. It is very common for a client to need to
34+
* Gets multiple hash lists at once. It is very common for a client to need to
3535
* get multiple hash lists. Using this method is preferred over using the
3636
* regular Get method multiple times. This is a standard batch Get method as
3737
* defined by https://google.aip.dev/231 and the HTTP method is also GET.
@@ -70,11 +70,11 @@ public function batchGet($optParams = [])
7070
return $this->call('batchGet', [$params], GoogleSecuritySafebrowsingV5BatchGetHashListsResponse::class);
7171
}
7272
/**
73-
* List hash lists. In the V5 API, Google will never remove a hash list that has
74-
* ever been returned by this method. This enables clients to skip using this
75-
* method and simply hard-code all hash lists they need. This is a standard List
76-
* method as defined by https://google.aip.dev/132 and the HTTP method is GET.
77-
* (hashLists.listHashLists)
73+
* Lists hash lists. In the V5 API, Google will never remove a hash list that
74+
* has ever been returned by this method. This enables clients to skip using
75+
* this method and simply hard-code all hash lists they need. This is a standard
76+
* List method as defined by https://google.aip.dev/132 and the HTTP method is
77+
* GET. (hashLists.listHashLists)
7878
*
7979
* @param array $optParams Optional parameters.
8080
*

src/Safebrowsing/Resource/Hashes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
class Hashes extends \Google\Service\Resource
3131
{
3232
/**
33-
* Search for full hashes matching the specified prefixes. This is a custom
33+
* Searches for full hashes matching the specified prefixes. This is a custom
3434
* method as defined by https://google.aip.dev/136 (the custom method refers to
3535
* this method having a custom name within Google's general API development
3636
* nomenclature; it does not refer to using a custom HTTP method).

src/Safebrowsing/Resource/Urls.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/*
3+
* Copyright 2014 Google Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
6+
* use this file except in compliance with the License. You may obtain a copy of
7+
* the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations under
15+
* the License.
16+
*/
17+
18+
namespace Google\Service\Safebrowsing\Resource;
19+
20+
use Google\Service\Safebrowsing\GoogleSecuritySafebrowsingV5SearchUrlsResponse;
21+
22+
/**
23+
* The "urls" collection of methods.
24+
* Typical usage is:
25+
* <code>
26+
* $safebrowsingService = new Google\Service\Safebrowsing(...);
27+
* $urls = $safebrowsingService->urls;
28+
* </code>
29+
*/
30+
class Urls extends \Google\Service\Resource
31+
{
32+
/**
33+
* Searches for URLs matching known threats. Each URL and it's host-suffix and
34+
* path-prefix expressions (up to a limited depth) are checked. This means that
35+
* the response may contain URLs that were not included in the request, but are
36+
* expressions of the requested URLs. (urls.search)
37+
*
38+
* @param array $optParams Optional parameters.
39+
*
40+
* @opt_param string urls Required. The URLs to be looked up. Clients MUST NOT
41+
* send more than 50 URLs.
42+
* @return GoogleSecuritySafebrowsingV5SearchUrlsResponse
43+
* @throws \Google\Service\Exception
44+
*/
45+
public function search($optParams = [])
46+
{
47+
$params = [];
48+
$params = array_merge($params, $optParams);
49+
return $this->call('search', [$params], GoogleSecuritySafebrowsingV5SearchUrlsResponse::class);
50+
}
51+
}
52+
53+
// Adding a class alias for backwards compatibility with the previous class name.
54+
class_alias(Urls::class, 'Google_Service_Safebrowsing_Resource_Urls');

0 commit comments

Comments
 (0)