GData.Service¶
- Subclasses:
GData.CalendarService
,GData.ContactsService
,GData.DocumentsService
,GData.FreebaseService
,GData.PicasaWebService
,GData.TasksService
,GData.YouTubeService
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
An authorizer object to provide an authorization token for each request. |
||
r/w |
The locale to use for network requests, in Unix locale format. |
||
r/w |
A |
||
r/w |
The proxy URI used internally for all network requests. |
||
r/w |
A timeout, in seconds, for network operations. |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class GData.Service(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
All the fields in the
GData.Service
structure are private and should never be accessed directly.- classmethod get_authorization_domains(service_type)¶
- Parameters:
service_type (
GObject.GType
) – theGObject.GType
of theGData.Service
subclass to retrieve the authorization domains for- Returns:
an unordered list of
GData.AuthorizationDomains
; free with g_list_free()- Return type:
Retrieves the full list of
GData.AuthorizationDomains
which relate to the specified service_type. All theGData.AuthorizationDomains
are unique and interned, so can be compared with other domains by simple pointer comparison.Note that in addition to this method,
GData.Service
subclasses may expose some or all of their authorization domains individually by means of individual accessor functions.New in version 0.9.0.
- delete_entry(domain, entry, cancellable)¶
- Parameters:
domain (
GData.AuthorizationDomain
orNone
) – theGData.AuthorizationDomain
the deletion falls under, orNone
entry (
GData.Entry
) – theGData.Entry
to deletecancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
- Raises:
- Returns:
- Return type:
Deletes entry from the server. For more information about the concept of deleting entries, see the
online documentation for the
GLib.Data
protocol.If cancellable is not
None
, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled before or during network activity, the errorGio.IOErrorEnum.CANCELLED
will be returned. Cancellation has no effect after network activity has finished, however, and the deletion will return successfully (or return an error sent by the server) if it is first cancelled after network activity has finished. See the ‘overview of cancellation [cancellable-support]’ for more details.If there is an error deleting the entry, a
GData.ServiceError.PROTOCOL_ERROR
error will be returned. Currently, subclasses cannot cannot override this or provide more specific errors.New in version 0.9.0.
- delete_entry_async(domain, entry, cancellable, callback, *user_data)¶
- Parameters:
domain (
GData.AuthorizationDomain
orNone
) – theGData.AuthorizationDomain
the deletion falls under, orNone
entry (
GData.Entry
) – theGData.Entry
to deletecancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when deletion is finished, orNone
user_data (
object
orNone
) – data to pass to the callback function
Deletes entry from the server. self and entry are both reffed when this function is called, so can safely be unreffed after this function returns.
For more details, see
GData.Service.delete_entry
(), which is the synchronous version of this function.When the operation is finished, callback will be called. You can then call
GData.Service.delete_entry_finish
() to get the results of the operation.New in version 0.9.0.
- delete_entry_finish(async_result)¶
- Parameters:
async_result (
Gio.AsyncResult
) – aGio.AsyncResult
- Raises:
- Returns:
- Return type:
Finishes an asynchronous entry deletion operation started with
GData.Service.delete_entry_async
().New in version 0.3.0.
- get_authorizer()¶
- Returns:
the authorizer object for this service, or
None
- Return type:
Gets the
GData.Authorizer
object currently in use by the service. See the documentation forGData.Service
:authorizer
for more details.New in version 0.9.0.
- get_locale()¶
- Returns:
the current locale
- Return type:
Returns the locale currently being used for network requests, or
None
if the locale is the default.New in version 0.7.0.
- get_proxy_resolver()¶
- Returns:
a
Gio.ProxyResolver
, orNone
- Return type:
Gets the
Gio.ProxyResolver
on theGData.Service
'sSoup.Session
.New in version 0.15.0.
- get_proxy_uri()¶
-
Gets the proxy URI on the
GData.Service
'sSoup.Session
.New in version 0.2.0.
Deprecated since version 0.15.0: Use
GData.Service.get_proxy_resolver
() instead, which gives more flexibility over the proxy used.
- get_timeout()¶
- Returns:
the timeout, or 0
- Return type:
Gets the
GData.Service
:timeout
property; the network timeout, in seconds.New in version 0.7.0.
- insert_entry(domain, upload_uri, entry, cancellable)¶
- Parameters:
domain (
GData.AuthorizationDomain
orNone
) – theGData.AuthorizationDomain
the insertion operation falls under, orNone
upload_uri (
str
) – the URI to which the upload should be sententry (
GData.Entry
) – theGData.Entry
to insertcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
- Raises:
- Returns:
an updated
GData.Entry
, orNone
; unref withGObject.Object.unref
()- Return type:
Inserts entry by uploading it to the online service at upload_uri. For more information about the concept of inserting entries, see the online documentation for the
GLib.Data
protocol.The service will return an updated version of the entry, which is the return value of this function on success.
If cancellable is not
None
, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled before or during network activity, the errorGio.IOErrorEnum.CANCELLED
will be returned. Cancellation has no effect after network activity has finished, however, and the insertion will return successfully (or return an error sent by the server) if it is first cancelled after network activity has finished. See the ‘overview of cancellation [cancellable-support]’ for more details.If the entry is marked as already having been inserted a
GData.ServiceError.ENTRY_ALREADYSERTED
error will be returned immediately (there will be no network requests).If there is an error inserting the entry, a
GData.ServiceError.PROTOCOL_ERROR
error will be returned. Currently, subclasses cannot cannot override this or provide more specific errors.New in version 0.9.0.
- insert_entry_async(domain, upload_uri, entry, cancellable, callback, *user_data)¶
- Parameters:
domain (
GData.AuthorizationDomain
orNone
) – theGData.AuthorizationDomain
the insertion operation falls under, orNone
upload_uri (
str
) – the URI to which the upload should be sententry (
GData.Entry
) – theGData.Entry
to insertcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when insertion is finished, orNone
user_data (
object
orNone
) – data to pass to the callback function
Inserts entry by uploading it to the online service at upload_uri. self, upload_uri and entry are all reffed/copied when this function is called, so can safely be freed after this function returns.
For more details, see
GData.Service.insert_entry
(), which is the synchronous version of this function.When the operation is finished, callback will be called. You can then call
GData.Service.insert_entry_finish
() to get the results of the operation.New in version 0.9.0.
- insert_entry_finish(async_result)¶
- Parameters:
async_result (
Gio.AsyncResult
) – aGio.AsyncResult
- Raises:
- Returns:
an updated
GData.Entry
, orNone
; unref withGObject.Object.unref
()- Return type:
Finishes an asynchronous entry insertion operation started with
GData.Service.insert_entry_async
().New in version 0.3.0.
- is_authorized()¶
-
Determines whether the service is authorized for all the
GData.AuthorizationDomains
it belongs to (as returned byGData.Service.get_authorization_domains
()). If the service’sGData.Service
:authorizer
isNone
,False
is always returned.This is basically a convenience method for checking that the service’s
GData.Authorizer
is authorized for all the service’sGData.AuthorizationDomains
.New in version 0.9.0.
- query(domain, feed_uri, query, entry_type, cancellable, progress_callback, *progress_user_data)¶
- Parameters:
domain (
GData.AuthorizationDomain
orNone
) – theGData.AuthorizationDomain
the query falls under, orNone
feed_uri (
str
) – the feed URI to query, including the host name and protocolquery (
GData.Query
orNone
) – aGData.Query
with the query parameters, orNone
entry_type (
GObject.GType
) – aGObject.GType
for theGData.Entrys
to build from the XMLcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
progress_callback (
GData.QueryProgressCallback
orNone
) – aGData.QueryProgressCallback
to call when an entry is loaded, orNone
progress_user_data (
object
orNone
) – data to pass to the progress_callback function
- Raises:
- Returns:
a
GData.Feed
of query results, orNone
; unref withGObject.Object.unref
()- Return type:
Queries the service’s feed_uri feed to build a
GData.Feed
.If cancellable is not
None
, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled before or during network activity, the errorGio.IOErrorEnum.CANCELLED
will be returned. Cancellation has no effect after network activity has finished, however, and the query will return successfully (or return an error sent by the server) if it is first cancelled after network activity has finished. See the ‘overview of cancellation [cancellable-support]’ for more details.A
GData.ServiceError.PROTOCOL_ERROR
will be returned if the server indicates there is a problem with the query, but subclasses may override this and return their own errors. See their documentation for more details.For each entry in the response feed, progress_callback will be called in the main thread. If there was an error parsing the XML response, a
GData.ParserError
will be returned.If the query is successful and the feed supports pagination, query will be updated with the pagination URIs, and the next or previous page can then be loaded by calling
GData.Query.next_page
() orGData.Query.previous_page
() before running the query again.If the
GData.Query
's ETag is set and it finds a match on the server,None
will be returned, but error will remain unset. Otherwise, query's ETag will be updated with the ETag from the returned feed, if available.New in version 0.9.0.
- query_async(domain, feed_uri, query, entry_type, cancellable, progress_callback, progress_user_data, callback, *user_data)¶
- Parameters:
domain (
GData.AuthorizationDomain
orNone
) – theGData.AuthorizationDomain
the query falls under, orNone
feed_uri (
str
) – the feed URI to query, including the host name and protocolquery (
GData.Query
orNone
) – aGData.Query
with the query parameters, orNone
entry_type (
GObject.GType
) – aGObject.GType
for theGData.Entrys
to build from the XMLcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
progress_callback (
GData.QueryProgressCallback
orNone
) – aGData.QueryProgressCallback
to call when an entry is loaded, orNone
progress_user_data (
object
orNone
) – data to pass to the progress_callback functioncallback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the query is finisheduser_data (
object
orNone
) – data to pass to the callback function
Queries the service’s feed_uri feed to build a
GData.Feed
. self, feed_uri and query are all reffed/copied when this function is called, so can safely be freed after this function returns.For more details, see
GData.Service.query
(), which is the synchronous version of this function.When the operation is finished, callback will be called. You can then call
GData.Service.query_finish
() to get the results of the operation.New in version 0.9.1.
- query_finish(async_result)¶
- Parameters:
async_result (
Gio.AsyncResult
) – aGio.AsyncResult
- Raises:
- Returns:
a
GData.Feed
of query results, orNone
; unref withGObject.Object.unref
()- Return type:
Finishes an asynchronous query operation started with
GData.Service.query_async
().
- query_single_entry(domain, entry_id, query, entry_type, cancellable)¶
- Parameters:
domain (
GData.AuthorizationDomain
orNone
) – theGData.AuthorizationDomain
the query falls under, orNone
entry_id (
str
) – the entry ID of the desired entryquery (
GData.Query
orNone
) – aGData.Query
with the query parameters, orNone
entry_type (
GObject.GType
) – aGObject.GType
for theGData.Entry
to build from the XMLcancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
a
GData.Entry
, orNone
; unref withGObject.Object.unref
()- Return type:
Retrieves information about the single entry with the given entry_id. entry_id should be as returned by
GData.Entry.get_id
().Parameters and errors are as for
GData.Service.query
(). Most of the properties of query aren’t relevant, and will cause a server-side error if used. The most useful property to use isGData.Query
:etag
, which will cause the server to not return anything if the entry hasn’t been modified since it was given the specified ETag; thus saving bandwidth. If the server does not return anything for this reason,GData.Service.query_single_entry
() will returnNone
, but will not set an error in error.New in version 0.9.0.
- query_single_entry_async(domain, entry_id, query, entry_type, cancellable, callback, *user_data)¶
- Parameters:
domain (
GData.AuthorizationDomain
orNone
) – theGData.AuthorizationDomain
the query falls under, orNone
entry_id (
str
) – the entry ID of the desired entryquery (
GData.Query
orNone
) – aGData.Query
with the query parameters, orNone
entry_type (
GObject.GType
) – aGObject.GType
for theGData.Entry
to build from the XMLcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the query is finisheduser_data (
object
orNone
) – data to pass to the callback function
Retrieves information about the single entry with the given entry_id. entry_id should be as returned by
GData.Entry.get_id
(). self, query and entry_id are reffed/copied when this function is called, so can safely be freed after this function returns.For more details, see
GData.Service.query_single_entry
(), which is the synchronous version of this function.When the operation is finished, callback will be called. You can then call
GData.Service.query_single_entry_finish
() to get the results of the operation.New in version 0.9.0.
- query_single_entry_finish(async_result)¶
- Parameters:
async_result (
Gio.AsyncResult
) – aGio.AsyncResult
- Raises:
- Returns:
a
GData.Entry
, orNone
; unref withGObject.Object.unref
()- Return type:
Finishes an asynchronous query operation for a single entry, as started with
GData.Service.query_single_entry_async
().New in version 0.7.0.
- set_authorizer(authorizer)¶
- Parameters:
authorizer (
GData.Authorizer
) – a new authorizer object for the service, orNone
Sets
GData.Service
:authorizer
to authorizer. This may beNone
if the service will only make requests in future which don’t require authorization. See the documentation forGData.Service
:authorizer
for more information.New in version 0.9.0.
- set_locale(locale)¶
- Parameters:
locale (
str
orNone
) – the new locale in Unix locale format, orNone
for the default locale
Set the locale used for network requests to locale, given in standard Unix locale format. See
GData.Service
:locale
for more details.Note that while it’s possible to change the locale after sending network requests, it is unsupported, as the server-side software may behave unexpectedly. The only supported use of this function is after creation of a service, but before any network requests are made.
New in version 0.7.0.
- set_proxy_resolver(proxy_resolver)¶
- Parameters:
proxy_resolver (
Gio.ProxyResolver
orNone
) – aGio.ProxyResolver
, orNone
Sets the
Gio.ProxyResolver
on theSoup.Session
used internally by the givenGData.Service
.Setting this will clear the
GData.Service
:proxy-uri
property.New in version 0.15.0.
- set_proxy_uri(proxy_uri)¶
-
Sets the proxy URI on the
Soup.Session
used internally by the givenGData.Service
. This forces all requests through the given proxy.If proxy_uri is
None
, no proxy will be used.Note that if a
GData.Authorizer
is being used with thisGData.Service
, the authorizer might also need its proxy URI setting.New in version 0.2.0.
Deprecated since version 0.15.0: Use
GData.Service.set_proxy_resolver
() instead, which gives more flexibility over the proxy used.
- set_timeout(timeout)¶
- Parameters:
timeout (
int
) – the timeout, or 0
Sets the
GData.Service
:timeout
property; the network timeout, in seconds.If timeout is 0, network operations will never time out.
Note that if a
GData.Authorizer
is being used with thisGData.Service
, the authorizer might also need its timeout setting.New in version 0.7.0.
- update_entry(domain, entry, cancellable)¶
- Parameters:
domain (
GData.AuthorizationDomain
orNone
) – theGData.AuthorizationDomain
the update operation falls under, orNone
entry (
GData.Entry
) – theGData.Entry
to updatecancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
- Raises:
- Returns:
an updated
GData.Entry
, orNone
; unref withGObject.Object.unref
()- Return type:
Updates entry by PUTting it to its
edit
link’s URI. For more information about the concept of updating entries, see the online documentation for theGLib.Data
protocol.The service will return an updated version of the entry, which is the return value of this function on success.
If cancellable is not
None
, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled before or during network activity, the errorGio.IOErrorEnum.CANCELLED
will be returned. Cancellation has no effect after network activity has finished, however, and the update will return successfully (or return an error sent by the server) if it is first cancelled after network activity has finished. See the ‘overview of cancellation [cancellable-support]’ for more details.If there is an error updating the entry, a
GData.ServiceError.PROTOCOL_ERROR
error will be returned. Currently, subclasses cannot cannot override this or provide more specific errors.New in version 0.9.0.
- update_entry_async(domain, entry, cancellable, callback, *user_data)¶
- Parameters:
domain (
GData.AuthorizationDomain
orNone
) – theGData.AuthorizationDomain
the update operation falls under, orNone
entry (
GData.Entry
) – theGData.Entry
to updatecancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, orNone
callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
to call when the update is finished, orNone
user_data (
object
orNone
) – data to pass to the callback function
Updates entry by PUTting it to its
edit
link’s URI. self and entry are both reffed when this function is called, so can safely be unreffed after this function returns.For more details, see
GData.Service.update_entry
(), which is the synchronous version of this function.When the operation is finished, callback will be called. You can then call
GData.Service.update_entry_finish
() to get the results of the operation.New in version 0.9.0.
- update_entry_finish(async_result)¶
- Parameters:
async_result (
Gio.AsyncResult
) – aGio.AsyncResult
- Raises:
- Returns:
an updated
GData.Entry
, orNone
; unref withGObject.Object.unref
()- Return type:
Finishes an asynchronous entry update operation started with
GData.Service.update_entry_async
().New in version 0.3.0.
- do_append_query_headers(domain, message) virtual¶
- Parameters:
domain (
GData.AuthorizationDomain
) –message (
Soup.Message
) –
Property Details¶
- GData.Service.props.authorizer¶
- Name:
authorizer
- Type:
- Default Value:
- Flags:
An object which implements
GData.Authorizer
. This should have previously been authenticated authorized against this service type (and potentially other service types). The service will use the authorizer to add an authorization token to each request it performs.Your application should call methods on the
GData.Authorizer
object itself in order to authenticate with the Google accounts service and authorize against this service type. See the documentation for the particularGData.Authorizer
implementation being used for more details.The authorizer for a service can be changed at runtime for a different
GData.Authorizer
object orNone
without affecting ongoing requests and operations.Note that it’s only necessary to set an authorizer on the service if your application is going to make requests of the service which require authorization. For example, listing the current most popular videos on YouTube does not require authorization, but uploading a video to YouTube does. It’s an unnecessary overhead to require the user to authorize against a service when not strictly required.
New in version 0.9.0.
- GData.Service.props.locale¶
-
The locale to use for network requests, in Unix locale format. (e.g. “en_GB”, “cs”, “de_DE”.) Use
None
for the default “C” locale (typically “en_US”).Typically, this locale will be used by the server-side software to localise results, such as by translating category names, or by choosing geographically relevant search results. This will vary from service to service.
The server-side behaviour is undefined if it doesn’t support a given locale.
New in version 0.7.0.
- GData.Service.props.proxy_resolver¶
- Name:
proxy-resolver
- Type:
- Default Value:
- Flags:
The
Gio.ProxyResolver
used to determine a proxy URI. Setting this will clear theGData.Service
:proxy-uri
property.New in version 0.15.0.
- GData.Service.props.proxy_uri¶
-
The proxy URI used internally for all network requests.
Note that if a
GData.Authorizer
is being used with thisGData.Service
, the authorizer might also need its proxy URI setting.New in version 0.2.0.
Deprecated since version 0.15.0: Use
GData.Service
:proxy-resolver
instead, which gives more flexibility over the proxy used.
- GData.Service.props.timeout¶
-
A timeout, in seconds, for network operations. If the timeout is exceeded, the operation will be cancelled and
GData.ServiceError.NETWORK_ERROR
will be returned.If the timeout is 0, operations will never time out.
Note that if a
GData.Authorizer
is being used with thisGData.Service
, the authorizer might also need its timeout setting.New in version 0.7.0.