Class: Google::Apis::Core::BaseService
- Inherits:
-
Object
- Object
- Google::Apis::Core::BaseService
- Includes:
- Logging
- Defined in:
- lib/google/apis/core/base_service.rb
Overview
Base service for all APIs. Not to be used directly.
Direct Known Subclasses
AcceleratedmobilepageurlV1::AcceleratedmobilepageurlService, Adexchangebuyer2V2beta1::AdExchangeBuyerIIService, AdexchangebuyerV1_3::AdExchangeBuyerService, AdexchangebuyerV1_4::AdExchangeBuyerService, AdexchangesellerV2_0::AdExchangeSellerService, AdminDatatransferV1::DataTransferService, AdminDirectoryV1::DirectoryService, AdminReportsV1::ReportsService, AdsenseV1_4::AdSenseService, AdsensehostV4_1::AdSenseHostService, AnalyticsV3::AnalyticsService, AnalyticsreportingV4::AnalyticsReportingService, AndroidenterpriseV1::AndroidEnterpriseService, AndroidpublisherV2::AndroidPublisherService, AppengineV1::AppengineService, AppengineV1beta4::AppengineService, AppengineV1beta5::AppengineService, AppsactivityV1::AppsactivityService, AppsmarketV2::AppsmarketService, AppstateV1::AppStateService, AutoscalerV1beta2::AutoscalerService, BigqueryV2::BigqueryService, BloggerV3::BloggerService, BooksV1::BooksService, Google::Apis::CalendarV3::CalendarService, Google::Apis::CivicinfoV2::CivicInfoService, Google::Apis::ClassroomV1::ClassroomService, Google::Apis::ClassroomV1beta1::ClassroomService, Google::Apis::CloudbillingV1::CloudbillingService, Google::Apis::CloudbuildV1::CloudBuildService, Google::Apis::ClouddebuggerV2::CloudDebuggerService, Google::Apis::ClouderrorreportingV1beta1::ClouderrorreportingService, Google::Apis::CloudfunctionsV1::CloudFunctionsService, Google::Apis::CloudkmsV1::CloudKMSService, Google::Apis::CloudkmsV1beta1::CloudKMSService, Google::Apis::CloudlatencytestV2::CloudlatencytestService, Google::Apis::CloudmonitoringV2beta2::CloudMonitoringService, Google::Apis::CloudresourcemanagerV1::CloudResourceManagerService, Google::Apis::CloudresourcemanagerV1beta1::CloudResourceManagerService, Google::Apis::CloudtraceV1::CloudTraceService, Google::Apis::ClouduseraccountsBeta::CloudUserAccountsService, Google::Apis::ComputeBeta::ComputeService, Google::Apis::ComputeV1::ComputeService, Google::Apis::ContainerV1::ContainerService, Google::Apis::ContainerV1beta1::ContainerService, Google::Apis::ContentV2::ShoppingContentService, Google::Apis::CoordinateV1::CoordinateService, Google::Apis::CustomsearchV1::CustomsearchService, DataflowV1b3::DataflowService, DataprocV1::DataprocService, DatastoreV1::DatastoreService, DatastoreV1beta2::DatastoreService, DatastoreV1beta3::DatastoreService, DeploymentmanagerV2::DeploymentManagerService, DeploymentmanagerV2beta2::DeploymentManagerService, DfareportingV2_1::DfareportingService, DfareportingV2_3::DfareportingService, DfareportingV2_5::DfareportingService, DfareportingV2_6::DfareportingService, DfareportingV2_7::DfareportingService, DfareportingV2_8::DfareportingService, DiscoveryV1::DiscoveryService, DnsV1::DnsService, DnsV2beta1::DnsService, DoubleclickbidmanagerV1::DoubleClickBidManagerService, DoubleclicksearchV2::DoubleclicksearchService, DriveV2::DriveService, DriveV3::DriveService, FirebasedynamiclinksV1::FirebaseDynamicLinksService, FirebaserulesV1::FirebaseRulesService, FitnessV1::FitnessService, FusiontablesV2::FusiontablesService, GamesConfigurationV1configuration::GamesConfigurationService, GamesManagementV1management::GamesManagementService, GamesV1::GamesService, GanV1beta1::GanService, GenomicsV1::GenomicsService, GenomicsV1beta2::GenomicsService, GmailV1::GmailService, GroupsmigrationV1::GroupsMigrationService, GroupssettingsV1::GroupssettingsService, IamV1::IamService, IdentitytoolkitV3::IdentityToolkitService, KgsearchV1::KgsearchService, LanguageV1::CloudNaturalLanguageService, LanguageV1beta1::CloudNaturalLanguageService, LicensingV1::LicensingService, LoggingV1beta3::LoggingService, LoggingV2::LoggingService, LoggingV2beta1::LoggingService, ManagerV1beta2::ManagerService, ManufacturersV1::ManufacturerCenterService, MirrorV1::MirrorService, MlV1::CloudMachineLearningEngineService, MonitoringV3::MonitoringService, MybusinessV3::MybusinessService, Oauth2V2::Oauth2Service, PagespeedonlineV2::PagespeedonlineService, PartnersV2::PartnersService, PeopleV1::PeopleServiceService, PlusDomainsV1::PlusDomainsService, PlusV1::PlusService, PredictionV1_6::PredictionService, ProximitybeaconV1beta1::ProximitybeaconService, PubsubV1::PubsubService, PubsubV1beta2::PubsubService, QpxExpressV1::QPXExpressService, ReplicapoolV1beta2::ReplicapoolService, ReplicapoolupdaterV1beta1::ReplicapoolupdaterService, ResellerV1::ResellerService, ResourceviewsV1beta2::ResourceviewsService, RuntimeconfigV1::CloudRuntimeConfigService, ScriptV1::ScriptService, SearchconsoleV1::SearchConsoleService, ServicecontrolV1::ServiceControlService, ServicemanagementV1::ServiceManagementService, ServiceuserV1::ServiceUserService, SheetsV4::SheetsService, SiteVerificationV1::SiteVerificationService, SlidesV1::SlidesService, SourcerepoV1::CloudSourceRepositoriesService, SpannerV1::SpannerService, SpeechV1beta1::SpeechService, SqladminV1beta4::SQLAdminService, StorageV1::StorageService, StoragetransferV1::StoragetransferService, SurveysV2::SurveysService, TagmanagerV1::TagManagerService, TagmanagerV2::TagManagerService, TaskqueueV1beta2::TaskqueueService, TasksV1::TasksService, ToolresultsV1beta3::ToolResultsService, TracingV1::TracingService, TranslateV2::TranslateService, UrlshortenerV1::UrlshortenerService, VisionV1::VisionService, WebfontsV1::WebfontsService, WebmastersV3::WebmastersService, YoutubeAnalyticsV1::YouTubeAnalyticsService, YoutubePartnerV1::YouTubePartnerService, YoutubeV3::YouTubeService, YoutubereportingV1::YouTubeReportingService
Instance Attribute Summary collapse
-
#authorization ⇒ Signet::OAuth2::Client
OAuth2 credentials.
-
#base_path ⇒ Addressable::URI
Additional path prefix for all API methods.
-
#batch_path ⇒ Addressable::URI
Alternate path prefix for all batch methods.
-
#client ⇒ HTTPClient
Get the current HTTP client.
-
#client_options ⇒ Google::Apis::ClientOptions
General settings.
-
#request_options ⇒ Google::Apis::RequestOptions
Default options for all requests.
-
#root_url ⇒ Addressable::URI
Root URL (host/port) for the API.
-
#upload_path ⇒ Addressable::URI
Alternate path prefix for media uploads.
Instance Method Summary collapse
-
#batch(options = nil) {|self| ... }
Perform a batch request.
-
#batch_upload(options = nil) {|self| ... }
Perform a batch upload request.
-
#fetch_all(max: nil, items: :items, cache: true, response_page_token: :next_page_token) {|token, service| ... } ⇒ Enumerble
Executes a given query with paging, automatically retrieving additional pages as necessary.
-
#http(method, url, params: nil, body: nil, download_dest: nil, options: nil) {|result, err| ... } ⇒ String
Simple escape hatch for making API requests directly to a given URL.
-
#initialize(root_url, base_path) ⇒ BaseService
constructor
private
A new instance of BaseService.
Methods included from Logging
Constructor Details
#initialize(root_url, base_path) ⇒ BaseService
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of BaseService
122 123 124 125 126 127 128 129 |
# File 'lib/google/apis/core/base_service.rb', line 122 def initialize(root_url, base_path) self.root_url = root_url self.base_path = base_path self.upload_path = "upload/#{base_path}" self.batch_path = 'batch' self. = Google::Apis::ClientOptions.default.dup self. = Google::Apis::RequestOptions.default.dup end |
Instance Attribute Details
#authorization ⇒ Signet::OAuth2::Client
Returns OAuth2 credentials
134 135 136 |
# File 'lib/google/apis/core/base_service.rb', line 134 def () . = end |
#base_path ⇒ Addressable::URI
Additional path prefix for all API methods
95 96 97 |
# File 'lib/google/apis/core/base_service.rb', line 95 def base_path @base_path end |
#batch_path ⇒ Addressable::URI
Alternate path prefix for all batch methods
103 104 105 |
# File 'lib/google/apis/core/base_service.rb', line 103 def batch_path @batch_path end |
#client ⇒ HTTPClient
Get the current HTTP client
107 108 109 |
# File 'lib/google/apis/core/base_service.rb', line 107 def client @client end |
#client_options ⇒ Google::Apis::ClientOptions
General settings
111 112 113 |
# File 'lib/google/apis/core/base_service.rb', line 111 def @client_options end |
#request_options ⇒ Google::Apis::RequestOptions
Default options for all requests
115 116 117 |
# File 'lib/google/apis/core/base_service.rb', line 115 def @request_options end |
#root_url ⇒ Addressable::URI
Root URL (host/port) for the API
91 92 93 |
# File 'lib/google/apis/core/base_service.rb', line 91 def root_url @root_url end |
#upload_path ⇒ Addressable::URI
Alternate path prefix for media uploads
99 100 101 |
# File 'lib/google/apis/core/base_service.rb', line 99 def upload_path @upload_path end |
Instance Method Details
#batch(options = nil) {|self| ... }
This method returns an undefined value.
Perform a batch request. Calls made within the block are sent in a single network request to the server.
162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/google/apis/core/base_service.rb', line 162 def batch( = nil) batch_command = BatchCommand.new(:post, Addressable::URI.parse(root_url + batch_path)) batch_command. = .merge() apply_command_defaults(batch_command) begin start_batch(batch_command) yield self ensure end_batch end batch_command.execute(client) end |
#batch_upload(options = nil) {|self| ... }
This method returns an undefined value.
Perform a batch upload request. Calls made within the block are sent in a single network request to the server. Batch uploads are useful for uploading multiple small files. For larger files, use single requests which use a resumable upload protocol.
194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/google/apis/core/base_service.rb', line 194 def batch_upload( = nil) batch_command = BatchUploadCommand.new(:put, Addressable::URI.parse(root_url + upload_path)) batch_command. = .merge() apply_command_defaults(batch_command) begin start_batch(batch_command) yield self ensure end_batch end batch_command.execute(client) end |
#fetch_all(max: nil, items: :items, cache: true, response_page_token: :next_page_token) {|token, service| ... } ⇒ Enumerble
Executes a given query with paging, automatically retrieving additional pages as necessary. Requires a block that returns the result set of a page. The current page token is supplied as an argument to the block.
Note: The returned enumerable also contains a last_result
field
containing the full result of the last query executed.
275 276 277 278 |
# File 'lib/google/apis/core/base_service.rb', line 275 def fetch_all(max: nil, items: :items, cache: true, response_page_token: :next_page_token, &block) fail "fetch_all may not be used inside a batch" if batch? return PagedResults.new(self, max: max, items: items, cache: cache, response_page_token: response_page_token, &block) end |
#http(method, url, params: nil, body: nil, download_dest: nil, options: nil) {|result, err| ... } ⇒ String
Simple escape hatch for making API requests directly to a given URL. This is not intended to be used as a generic HTTP client and should be used only in cases where no service method exists (e.g. fetching an export link for a Google Drive file.)
237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/google/apis/core/base_service.rb', line 237 def http(method, url, params: nil, body: nil, download_dest: nil, options: nil, &block) if download_dest command = DownloadCommand.new(method, url, body: body) else command = HttpCommand.new(method, url, body: body) end command. = .merge() apply_command_defaults(command) command.query.merge(Hash(params)) execute_or_queue_command(command, &block) end |