DataServiceProvider

public protocol DataServiceProvider: class

A provider interface for data services. Where applicable, client applications should use the DataService wrapper to invoke provider functions.

  • Create an entity in the target system. Automatically calls CsdlDocument.resolveEntity to ensure that EntityValue.entitySet is available.

    Throws

    DataServiceException if the entity set hasn’t been explicitly provided before calling createEntity and 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) 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

    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 as label 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

    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 or CharStream. 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

    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

    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

    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

    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.

  • 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 -> 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

    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 data method (action or function) in the target system. Actions may have backend side-effects. Functions should not have backend side-effects.

    Throws

    DataServiceException or DataNetworkException if an error occurs during action invocation.

    Declaration

    Swift

    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

    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.

  • Has service metadata been loaded.

    See also

    loadMetadata.

    Declaration

    Swift

    var hasMetadata: Bool
  • Load service metadata (if not already loaded).

    See also

    metadata, hasMetadata.

    Declaration

    Swift

    func loadMetadata(headers: HTTPHeaders, options: RequestOptions) throws -> Void

    Parameters

    headers

    Optional request-specific headers.

    options

    Optional request-specific options.

  • Service metadata.

    See also

    loadMetadata.

    Declaration

    Swift

    var metadata: CSDLDocument
  • Ping the server.

    Declaration

    Swift

    func pingServer(headers: HTTPHeaders, options: RequestOptions) throws -> Void

    Parameters

    headers

    Optional request-specific headers.

    options

    Optional request-specific options.

  • Execute a request batch in the target system.

    Declaration

    Swift

    func processBatch(_ batch: RequestBatch, headers: HTTPHeaders, options: RequestOptions) throws -> Void

    Parameters

    batch

    The request batch.

    headers

    Request-specific headers.

    options

    Request-specific options.

  • Service name.

    Declaration

    Swift

    var serviceName: String
  • Unload service metadata (if previously loaded).

    See also

    metadata, hasMetadata.

    Declaration

    Swift

    func unloadMetadata() throws -> Void
  • Update an entity in the target system.

    Declaration

    Swift

    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

    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

    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

    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.