OnlineODataProvider
open class OnlineODataProvider: ObjectBase, DataServiceProvider
A data service provider for online OData.
-
Constructs an online OData provider.
Declaration
Swift
public convenience init(serviceRoot: URL, sapURLSession: SAPURLSession = SAPURLSession())
Parameters
serviceRoot
Service root URL.
-
Constructs an online OData provider.
Declaration
Swift
public convenience init(serviceName: String, serviceRoot: URL, sapURLSession: SAPURLSession = SAPURLSession())
Parameters
serviceName
Service name.
serviceRoot
Service root URL.
-
URL session instance to be used by this data service.
Declaration
Swift
public var sapURLSession: SAPURLSession?
-
If this data service requires a security token, then acquire it now.
See also
ServiceOptions.requiresToken
.Declaration
Swift
open func acquireToken() throws -> Void
-
Create an entity in the target system. Automatically calls
CsdlDocument.resolveEntity
to ensure thatEntityValue.entitySet
is available.Throws
DataServiceException
if the entity set hasn’t been explicitly provided before callingcreateEntity
and there isn’t a unique entity set for the entity type.See also
EntityValue.ofType
,EntityValue.inSet
.Declaration
Swift
open func createEntity(_ entity: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -> Void
Parameters
entity
Entity to be created.
headers
Request-specific headers.
options
Request-specific options.
-
Create a link from a source entity to a target entity.
Declaration
Swift
open func createLink(from: EntityValue, property: Property, to: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -> Void
Parameters
from
Source entity for the link to be created.
property
Source navigation property for the link to be created.
to
Target entity for the link to be created.
headers
Request-specific headers.
options
Request-specific options.
-
Create a media entity with the specified content in the target system. If the
entity
has non-stream structural properties in addition to the key properties and media content, such aslabel
in the examples below, then this function will send two requests to the server: a first request to upload (POST) the media stream, and a second request (PATCH/PUT) to update the non-stream properties. It is not currently supported to make these two calls atomic. Caution: Having too many threads simultaneously creating streams may result in out-of-memory conditions on memory-constrained devices.Declaration
Swift
open func createMedia(entity: EntityValue, content: StreamBase, headers: HTTPHeaders, options: RequestOptions) throws -> Void
Parameters
entity
Entity to be created.
content
Initial content. Must be a
ByteStream
orCharStream
. Will be closed before this function returns.headers
Request-specific headers.
options
Request-specific options.
-
Execute query to delete data from the target system.
Declaration
Swift
open func deleteByQuery(_ query: DataQuery, headers: HTTPHeaders, options: RequestOptions) throws -> Void
Parameters
query
Data query specifying the information to be deleted.
headers
Request-specific headers.
options
Request-specific options.
-
Delete an entity from the target system.
Declaration
Swift
open func deleteEntity(_ entity: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -> Void
Parameters
entity
Entity to be deleted.
headers
Request-specific headers.
options
Request-specific options.
-
Delete a link from a source entity to a target entity.
Declaration
Swift
open func deleteLink(from: EntityValue, property: Property, to: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -> Void
Parameters
from
Source entity for the link to be deleted.
property
Source navigation property for the link to be deleted.
to
Target entity for the link to be deleted.
headers
Request-specific headers.
options
Request-specific options.
-
Delete the content of a stream property from the target system.
Declaration
Swift
open func deleteStream(entity: EntityValue, link: StreamLink, headers: HTTPHeaders, options: RequestOptions) throws -> Void
Parameters
entity
Entity containing the stream property whose content is to be deleted.
headers
Request-specific headers.
options
Request-specific options.
link
Stream link for the stream to be deleted.
-
Execute a query and obtain the result as a stream of delta items.
Declaration
Swift
open func deltaStream(query: DataQuery) throws -> DeltaStream
Parameters
query
Data query.
Return Value
Delta stream.
-
Obtain a stream for downloading the content of a media entity from the target system. Caution: streams are often used for large content that may not fit (all at once) in available application memory. Having too many threads simultaneously downloading streams, or using
ByteStream.readAndClose
, may result in out-of-memory conditions on memory-constrained devices.Declaration
Swift
open func downloadMedia(entity: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -> ByteStream
Parameters
entity
Entity whose content is to be downloaded.
headers
Request-specific headers.
options
Request-specific options.
Return Value
A stream for downloading the content of a media entity. This must be closed by the caller, or else a resource leak may occur.
-
Obtain a stream for downloading the content of a stream property from the target system. Caution: streams are often used for large content that may not fit (all at once) in available application memory. Having too many threads simultaneously downloading streams, or using
ByteStream.readAndClose
, may result in out-of-memory conditions on memory-constrained devices.See also
Property.getStreamLink
.Declaration
Swift
open func downloadStream(entity: EntityValue, link: StreamLink, headers: HTTPHeaders, options: RequestOptions) throws -> ByteStream
Parameters
entity
Entity containing the stream property whose content is to be downloaded.
link
Stream link for the stream to be downloaded.
headers
Request-specific headers.
options
Request-specific options.
Return Value
A stream for downloading the content of a stream property. This must be closed by the caller, or else a resource leak may occur.
-
Execute a query and obtain the result as a stream of entity values.
Declaration
Swift
open func entityStream(query: DataQuery) throws -> EntityStream
Parameters
query
Data query.
Return Value
Entity stream.
-
Execute a data method (action or function) in the target system. Actions may have backend side-effects. Functions should not have backend side-effects.
Throws
DataServiceException
orDataNetworkException
if an error occurs during action invocation.Declaration
Swift
open func executeMethod(_ method: DataMethod, parameters: ParameterList, headers: HTTPHeaders, options: RequestOptions) throws -> DataValue?
Parameters
method
Data method.
parameters
Method parameters.
headers
Request-specific headers.
options
Request-specific options.
Return Value
The method result, or
nil
if the method has no result. -
Execute a data query to get data from the target system.
Declaration
Swift
open func executeQuery(_ query: DataQuery, headers: HTTPHeaders, options: RequestOptions) throws -> QueryResult
Parameters
query
Data query specifying the information to be returned.
headers
Request-specific headers.
options
Request-specific options.
Return Value
The query result.
-
true
if the service metadata has been loaded byloadMetadata
, or is automatically available in a generated DataService proxy class.Declaration
Swift
open var hasMetadata: Bool
-
HTTP cookies that were returned by previous online requests.
Declaration
Swift
open var httpCookies: HTTPCookies
-
HTTP headers which should be sent in future online requests.
Declaration
Swift
open var httpHeaders: HTTPHeaders
-
Load the OData CSDL metadata for this data service into memory. If the meta-data was previously loaded into memory (by the current process), then calling this function will have no effect (except to log a warning). If the meta-data was loaded by a previous instance of the current application, or if the
ServiceOptions.metadataFile
orServiceOptions.metadataText
is non-null, then metadata may be loaded from the local file system or the provided text. Otherwise the metadata will be retrieved from the remote data service. If another DataService function that requires metadata is called before metadata has been loaded, the metadata will be automatically loaded by an implicit call toloadMetadata
.See also
hasMetadata
Declaration
Swift
open func loadMetadata(headers: HTTPHeaders, options: RequestOptions) throws -> Void
Parameters
headers
Optional request-specific headers.
options
Optional request-specific options.
-
The OData CSDL document (service metadata).
Declaration
Swift
open var metadata: CSDLDocument
-
Options for network communication, which for OData uses HTTP or HTTPS.
Declaration
Swift
open var networkOptions: NetworkOptions
-
Ping the server, by sending a non-changing request that the server can respond to quickly. The default ping behaviour is to send a HEAD request for the service document.
Declaration
Swift
open func pingServer(headers: HTTPHeaders, options: RequestOptions) throws -> Void
Parameters
headers
Optional request-specific headers.
options
Optional request-specific options.
-
Should
traceWithData
show pretty-printed JSON/XML content? Defaults tofalse
.Declaration
Swift
open var prettyTracing: Bool
-
Execute a request batch in the target system.
Declaration
Swift
open func processBatch(_ batch: RequestBatch, headers: HTTPHeaders, options: RequestOptions) throws -> Void
Parameters
batch
The request batch.
headers
Request-specific headers.
options
Request-specific options.
-
The service name.
Declaration
Swift
open var serviceName: String
-
Options for this data service, both client-side and server-side.
Declaration
Swift
open var serviceOptions: ServiceOptions
-
The service root URL.
Declaration
Swift
open var serviceRoot: String
-
Should all requests for this data service be traced? Defaults to
false
.Declaration
Swift
open var traceRequests: Bool
-
If
traceRequests
is alsotrue
, should all requests for this data service be traced with data? Defaults tofalse
. Note that care must be taken when enabling tracing with data, as the resulting log files may contain sensitive information. On the other hand, tracing with data may sometimes be invaluable for troubleshooting purposes.Declaration
Swift
open var traceWithData: Bool
-
Unload the OData CSDL metadata for this data service from memory. If metadata was not already loaded into memory, this function has no effect.
See also
loadMetadata
.Declaration
Swift
open func unloadMetadata() throws -> Void
-
Update an entity in the target system.
Declaration
Swift
open func updateEntity(_ entity: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -> Void
Parameters
entity
Entity to be updated.
headers
Request-specific headers.
options
Request-specific options.
-
Update a link from a source entity to a target entity.
Declaration
Swift
open func updateLink(from: EntityValue, property: Property, to: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -> Void
Parameters
from
Source entity for the link to be updated.
property
Source navigation property for the link to be updated. This must be a one-to-one navigation property.
to
Target entity for the link to be updated.
headers
Request-specific headers.
options
Request-specific options.
-
Upload content for a media entity to the target system Caution: Having too many threads simultaneously uploading streams may result in out-of-memory conditions on memory-constrained devices. Note: this function cannot be used to create a media entity. See
DataService.createMedia
.Declaration
Swift
open func uploadMedia(entity: EntityValue, content: StreamBase, headers: HTTPHeaders, options: RequestOptions) throws -> Void
Parameters
entity
Entity whose content is to be uploaded.
content
Upload stream content. Will be closed before this function returns.
headers
Request-specific headers.
options
Request-specific options.
-
Upload content for a stream property to the target system. Caution: Having too many threads simultaneously uploading streams may result in out-of-memory conditions on memory-constrained devices.
See also
Property.getStreamLink
.Declaration
Swift
open func uploadStream(entity: EntityValue, link: StreamLink, content: StreamBase, headers: HTTPHeaders, options: RequestOptions) throws -> Void
Parameters
entity
Entity containing the stream property whose content is to be uploaded.
link
Stream link for the stream to be uploaded.
content
Upload stream content. Will be closed before this function returns.
headers
Request-specific headers.
options
Request-specific options.