NAME
WebService::Google::Client::Discovery - Google API discovery service
VERSION
version 0.06
MORE INFORMATION
https://developers.google.com/discovery/v1/reference/
SEE ALSO
Not using Swagger but it is interesting - https://github.com/APIs-guru/openapi-directory/tree/master/APIs/googleapis.com for Swagger Specs.
Google::API::Client - contains code for parsing discovery structures
includes a chi property that is an instance of CHI using File Driver to cache discovery resources for 30 days
say $client-dicovery->chi->root_dir(); ## provides full file path to temp storage location used for caching
TODO
* deal with case of service names - either make it case insensitive or lock in a consistent approach - currently smells like case changes on context * handle 403 ( Daily Limit for Unauthenticated Use Exceeded.) errors when reqeusting a disdovery resource for a resvice but do we have access to authenticated reqeusts? * consider refactoring this entire module into UserAgent .. NB - this is also included as property of Services.pm which is the factory for dynamic classes
METHODS
get_rest()
Retrieve the description of a particular version of an API
my $d = WebService::Google::Client::Discovery->new;
$d->get_rest({ api=> 'calendar', version => 'v3' });
Return result like
$VAR1 = {
'ownerDomain' => 'google.com',
'version' => 'v2.4',
'protocol' => 'rest',
'icons' => 'HASH(0x29760c0)',
'discoveryVersion' => 'v1',
'id' => 'analytics:v2.4',
'parameters' => 'HASH(0x29709c0)',
'basePath' => '/analytics/v2.4/',
'revision' => '20170321',
'description' => 'Views and manages your Google Analytics data.',
'servicePath' => 'analytics/v2.4/',
'title' => 'Google Analytics API',
'kind' => 'discovery#restDescription',
'rootUrl' => 'https://www.googleapis.com/',
'etag' => '"YWOzh2SDasdU84ArJnpYek-OMdg/uF7o_i10s0Ir7WGM7zLi8NwSHXI"',
'ownerName' => 'Google',
'auth' => 'HASH(0x2948880)',
'resources' => 'HASH(0x296b218)',
'batchPath' => 'batch',
'name' => 'analytics',
'documentationLink' => 'https://developers.google.com/analytics/',
'baseUrl' => 'https://www.googleapis.com/analytics/v2.4/'
};
discover_all
Return details about all APIs
my $d = WebService::Google::Client::Discovery->new;
print Dumper $d
available_APIs
Return arrayref of all available API's (services)
{
'name' => 'youtube',
'versions' => [ 'v3' ]
},
Useful when printing list of supported API's in documentation
service_exists
Return 1 if service is supported by Google API discovery. Otherwise return 0
carp $d->service_exists('calendar'); # 1
carp $d->service_exists('someapi'); # 0
print_supported
Print list of supported APIs in human-readible format
NB This is not currently called by anywhere and probably better refactoring to return a string rather than print
available_versions
Show available versions of particular API
$d->available_versions('calendar'); # ['v3']
$d->available_versions('youtubeAnalytics'); # ['v1','v1beta1']
Returns arrayref
latest_stable_version
return latest stable verion of API
$d->available_versions('calendar'); # ['v3']
$d->latest_stable_version('calendar'); # 'v3'
$d->available_versions('tagmanager'); # ['v1','v2']
$d->latest_stable_version('tagmanager'); # ['v2']
$d->available_versions('storage'); # ['v1','v1beta1', 'v1beta2']
$d->latest_stable_version('storage'); # ['v1']
find_APIs_with_diff_vers
Return only APIs with multiple versions available
search_in_services
Search in services in "I'm lucky way" ? wtf?
Must process case-insensitive way:
e.g. Class is called CalendarList but resources is called calendarList in discovery
get_method_meta
Download metadata from Google API discovery for particular class method
$discovery->get_resource_meta('WebService::Google::Client::Calendar::CalendarList::delete')
get_resource_meta
Download metadata from Google API discovery for particular resource
$discovery->get_resource_meta('WebService::Google::Client::Calendar::Events')
returns a hasref with key methods
list_of_methods
Return array of methods that are available for particular resource
$discovery->list_of_methods('WebService::Google::Client::Calendar::Events')
meta_for_API
Same as get_rest method but faster. #!PS then why not replace it?
meta_for_API({ api => 'calendar', version => 'v3' });
AUTHORS
Pavel Serikov <pavelsr@cpan.org>
Peter Scott <peter@localshop.com.au>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017-2018 by Pavel Serikov, Peter Scott and others.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.