DataServiceProvider
public protocol DataServiceProvider : AnyObject
A provider interface for data services, using OData conventions for metadata, queries and updates.
Where applicable, client applications should use the DataService wrapper to invoke provider functions.
-
Create an entity in the target system. Automatically calls
CsdlDocument.resolveEntityto ensure thatEntityValue.entitySetis available.Throws
DataServiceExceptionif the entity set hasn’t been explicitly provided before callingcreateEntityand there isn’t a unique entity set for the entity type.See also
EntityValue.ofType,EntityValue.inSet.Declaration
Swift
func createEntity(_ entity: EntityValue, headers: HTTPHeaders, options: RequestOptions) throwsParameters
entityEntity to be created.
headersRequest-specific headers.
optionsRequest-specific options.
-
Create a link from a source entity to a target entity.
Declaration
Swift
func createLink(from: EntityValue, property: Property, to: EntityValue, headers: HTTPHeaders, options: RequestOptions) throwsParameters
fromSource entity for the link to be created.
propertySource navigation property for the link to be created.
toTarget entity for the link to be created.
headersRequest-specific headers.
optionsRequest-specific options.
-
Create a media entity with the specified content in the target system. If the
entityhas non-stream structural properties in addition to the key properties and media content, such aslabelin 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
func createMedia(entity: EntityValue, content: StreamBase, headers: HTTPHeaders, options: RequestOptions) throwsParameters
entityEntity to be created.
contentInitial content. Must be a
ByteStreamorCharStream. Will be closed before this function returns.headersRequest-specific headers.
optionsRequest-specific options.
-
Execute query to delete data from the target system.
Declaration
Swift
func deleteByQuery(_ query: DataQuery, headers: HTTPHeaders, options: RequestOptions) throwsParameters
queryData query specifying the information to be deleted.
headersRequest-specific headers.
optionsRequest-specific options.
-
Delete an entity from the target system.
Declaration
Swift
func deleteEntity(_ entity: EntityValue, headers: HTTPHeaders, options: RequestOptions) throwsParameters
entityEntity to be deleted.
headersRequest-specific headers.
optionsRequest-specific options.
-
Delete a link from a source entity to a target entity.
Declaration
Swift
func deleteLink(from: EntityValue, property: Property, to: EntityValue, headers: HTTPHeaders, options: RequestOptions) throwsParameters
fromSource entity for the link to be deleted.
propertySource navigation property for the link to be deleted.
toTarget entity for the link to be deleted.
headersRequest-specific headers.
optionsRequest-specific options.
-
Delete the content of a stream property from the target system.
Declaration
Swift
func deleteStream(entity: EntityValue, link: StreamLink, headers: HTTPHeaders, options: RequestOptions) throwsParameters
entityEntity containing the stream property whose content is to be deleted.
headersRequest-specific headers.
optionsRequest-specific options.
linkStream link for the stream to be deleted.
-
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
func downloadMedia(entity: EntityValue, headers: HTTPHeaders, options: RequestOptions) throws -> ByteStreamParameters
entityEntity whose content is to be downloaded.
headersRequest-specific headers.
optionsRequest-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
func downloadStream(entity: EntityValue, link: StreamLink, headers: HTTPHeaders, options: RequestOptions) throws -> ByteStreamParameters
entityEntity containing the stream property whose content is to be downloaded.
linkStream link for the stream to be downloaded.
headersRequest-specific headers.
optionsRequest-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 data method (action or function) in the target system. Actions may have backend side-effects. Functions should not have backend side-effects.
Throws
DataServiceExceptionorDataNetworkExceptionif an error occurs during action invocation.Declaration
Swift
func executeMethod(_ method: DataMethod, parameters: ParameterList, headers: HTTPHeaders, options: RequestOptions) throws -> DataValue?Parameters
methodData method.
parametersMethod parameters.
headersRequest-specific headers.
optionsRequest-specific options.
Return Value
The method result, or
nilif the method has no result. -
Execute a data query to get data from the target system.
Declaration
Swift
func executeQuery(_ query: DataQuery, headers: HTTPHeaders, options: RequestOptions) throws -> QueryResultParameters
queryData query specifying the information to be returned.
headersRequest-specific headers.
optionsRequest-specific options.
Return Value
The query result.
-
Fetch latest service metadata and return it, but don’t change the
metadataproperty.See also
loadMetadata.Declaration
Swift
func fetchMetadata(headers: HTTPHeaders, options: RequestOptions) throws -> CSDLDocumentParameters
headersOptional request-specific headers.
optionsOptional request-specific options.
Return Value
Latest service metadata.
-
Has service metadata been loaded.
See also
loadMetadata.Declaration
Swift
var hasMetadata: Bool { get } -
Load service metadata (if not already loaded).
Declaration
Swift
func loadMetadata(headers: HTTPHeaders, options: RequestOptions) throwsParameters
headersOptional request-specific headers.
optionsOptional request-specific options.
-
Service metadata.
See also
loadMetadata.Declaration
Swift
var metadata: CSDLDocument { get set } -
Ping the server.
Declaration
Swift
func pingServer(headers: HTTPHeaders, options: RequestOptions) throwsParameters
headersOptional request-specific headers.
optionsOptional request-specific options.
-
Execute a request batch in the target system.
Declaration
Swift
func processBatch(_ batch: RequestBatch, headers: HTTPHeaders, options: RequestOptions) throwsParameters
batchThe request batch.
headersRequest-specific headers.
optionsRequest-specific options.
-
Service name.
Declaration
Swift
var serviceName: String { get } -
Unload service metadata (if previously loaded).
Declaration
Swift
func unloadMetadata() throws -
Update an entity in the target system.
Declaration
Swift
func updateEntity(_ entity: EntityValue, headers: HTTPHeaders, options: RequestOptions) throwsParameters
entityEntity to be updated.
headersRequest-specific headers.
optionsRequest-specific options.
-
Update a link from a source entity to a target entity.
Declaration
Swift
func updateLink(from: EntityValue, property: Property, to: EntityValue, headers: HTTPHeaders, options: RequestOptions) throwsParameters
fromSource entity for the link to be updated.
propertySource navigation property for the link to be updated. This must be a one-to-one navigation property.
toTarget entity for the link to be updated.
headersRequest-specific headers.
optionsRequest-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
func uploadMedia(entity: EntityValue, content: StreamBase, headers: HTTPHeaders, options: RequestOptions) throwsParameters
entityEntity whose content is to be uploaded.
contentUpload stream content. Will be closed before this function returns.
headersRequest-specific headers.
optionsRequest-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
func uploadStream(entity: EntityValue, link: StreamLink, content: StreamBase, headers: HTTPHeaders, options: RequestOptions) throwsParameters
entityEntity containing the stream property whose content is to be uploaded.
linkStream link for the stream to be uploaded.
contentUpload stream content. Will be closed before this function returns.
headersRequest-specific headers.
optionsRequest-specific options.