RequestOptions
open class RequestOptions : ObjectBase, @unchecked Sendable
Options for processing of data requests.
If request options are used for repeatable requests, a new request options object should be used for each distinct request (or the repeatability properties should be reset before object re-use). The repeated execution of a failed request should re-use the original request options object without repeatable being reset beforehand.
-
Immutable value for “no” request options.
Declaration
Swift
public static let none: RequestOptions -
Default initializer.
Declaration
Swift
override public init() -
File for background download request. This file will temporarily be used while the background download is in progress up to the point it’s result stream has been read and closed. Alternatively (and only if backgroundName starts with “defer:” or “fetch:”), the background download will put data in the named file which is treated as a permanent file, and the result stream (e.g. for downloadMedia / downloadStream) will appear to be empty.
Declaration
Swift
open var backgroundFile: String? { get set } -
Name for background download request. A GUID string or other unique identifier should be used to avoid conflicts if multiple background downloads might be issued by the application at or around the same time. If this starts with the special prefix “defer:” (currently for Swift only), then the background download will be initiated, but the background download response will not be awaited and the initial request’s result stream will be empty. If this starts with the special prefix “fetch:” (currently for Swift only), then the response from a previously initiated background download (with the same background name suffix after “:”) will be fetched.
Declaration
Swift
open var backgroundName: String? { get set } -
In offline scenarios, can this request be combined with a previous request? Defaults to
true. A delete request can be combined with a previous create request by canceling the create request. An update request can be combined with a previous create or update request by merging the newly changed properties with the previously changed properties.Declaration
Swift
open var canCombineRequests: Bool { get set } -
Set this to a cancellation token before initiating an async request if request cancellation may be needed.
Declaration
Swift
open var cancelToken: CancelToken? { get set } -
Set the
cancelTokenand return this options object.Declaration
Swift
open func cancelable(_ token: CancelToken = CancelToken()) -> RequestOptionsParameters
tokenCancellation token.
Return Value
This options object.
-
Enable capturing of response headers into the specified object (which should have type
HTTPHeaders).Declaration
Swift
open var captureResponseHeaders: AnyObject? { get set } -
In offline scenarios, can this request be grouped with others having the same atomicity group? Intended as a performance optimization where grouping requests in a single transaction gives throughput benefits. Any such grouping is not guaranteed for requests having the same atomicity group, as there may be inter-request dependencies that prevent the grouping.
Example using proxy classes
open func transactionExample(patient: Patient) throws -> Void { let service = self.healthService let transactionID = GuidValue.random().toString() let appointment1 = Appointment() appointment1.patient = patient try service.createEntity(appointment1, headers: nil, options: RequestOptions() .transaction(transactionID)) let appointment2 = Appointment() appointment2.patient = patient try service.createEntity(appointment2, headers: nil, options: RequestOptions() .transaction(transactionID)) // Some time later... Upload both appointments in the same backend transaction. try service.upload() }Declaration
Swift
open var changeSet: String? { get set } -
Declaration
Swift
open func copy() -> RequestOptionsReturn Value
a new (mutable) request options object that is a copy of this request options object.
-
Set the
customTagand return this options object.Declaration
Swift
open func custom(_ tag: String) -> RequestOptionsParameters
tagCustom tag.
Return Value
This options object.
-
Set this to a custom tag when submitting a request for later upload in an offline scenario.
Declaration
Swift
open var customTag: String? { get set } -
Must entities for offline create requests be retained after successful upload? Defaults to
true.Declaration
Swift
open var mustRetainCreates: Bool { get set } -
Set the
canCombineRequestsproperty tofalseand return this options object.Declaration
Swift
open func noCombine() -> RequestOptionsReturn Value
This options object.
-
Set the
mustRetainCreatesproperty tofalseand return this options object.Declaration
Swift
open func noRetain() -> RequestOptionsReturn Value
This options object.
-
Declaration
Swift
open class func noneIfNull(options: RequestOptions?) -> RequestOptionsParameters
optionsOptions to be checked.
Return Value
The
optionsparameter, if non-nil; otherwisenone. -
Should create/update requests receive no content in the response? Defaults to
false.Declaration
Swift
open var preferNoContent: Bool { get set } -
Repeatability first sent time for this request.
See also
repeatable.Declaration
Swift
open var repeatabilityFirstSent: GlobalDateTime? { get set } -
Repeatability global request ID for this request.
See also
repeatable.Declaration
Swift
open var repeatabilityRequestID: GuidValue? { get set } -
Set the
repeatabilityRequestIDandrepeatabilityFirstSentand return this options object.Declaration
Swift
open func repeatable(requestID: GuidValue, firstSent: GlobalDateTime) -> RequestOptionsParameters
requestIDValue for
repeatabilityRequestID.firstSentValue for
repeatabilityFirstSent.Return Value
This options object.
-
Should no-change update requests be sent to the server? Defaults to
false.Declaration
Swift
open var sendEmptyUpdate: Bool { get set } -
Set the
changeSetand return this options object.Example using proxy classes
open func transactionExample(patient: Patient) throws -> Void { let service = self.healthService let transactionID = GuidValue.random().toString() let appointment1 = Appointment() appointment1.patient = patient try service.createEntity(appointment1, headers: nil, options: RequestOptions() .transaction(transactionID)) let appointment2 = Appointment() appointment2.patient = patient try service.createEntity(appointment2, headers: nil, options: RequestOptions() .transaction(transactionID)) // Some time later... Upload both appointments in the same backend transaction. try service.upload() }Declaration
Swift
open func transaction(_ id: String) -> RequestOptionsParameters
idTransaction ID to be copied into
changeSet.Return Value
This options object.
-
Set the
updateModeand return this options object.Declaration
Swift
open func update(_ mode: UpdateMode) -> RequestOptionsParameters
modeUpdate mode.
Return Value
This options object.
-
Determines if updates use merge (HTTP PATCH) or replace (HTTP PUT) semantics. Defaults to merge semantics.
Declaration
Swift
open var updateMode: UpdateMode { get set } -
Set the
uploadGroupand return this options object.Example using proxy classes
open func uploadGroupExample(patient: Patient) throws -> Void { let service = self.healthService let appointment1 = Appointment() appointment1.patient = patient appointment1.purpose = "Fix Broken Leg" try service.createEntity(appointment1, headers: nil, options: RequestOptions() .upload("Urgent")) let appointment2 = Appointment() appointment2.patient = patient appointment2.purpose = "Check Sore Arm" try service.createEntity(appointment2, headers: nil, options: RequestOptions() .upload("Non-Urgent")) // Some time later... Upload only the urgent appointments. try service.upload(groups: StringList.of("Urgent")) }Declaration
Swift
open func upload(_ group: String) -> RequestOptionsParameters
groupUpload group.
Return Value
This options object.
-
In offline scenarios, can this request be grouped with others to enable selective uploading by group name?
Example using proxy classes
open func uploadGroupExample(patient: Patient) throws -> Void { let service = self.healthService let appointment1 = Appointment() appointment1.patient = patient appointment1.purpose = "Fix Broken Leg" try service.createEntity(appointment1, headers: nil, options: RequestOptions() .upload("Urgent")) let appointment2 = Appointment() appointment2.patient = patient appointment2.purpose = "Check Sore Arm" try service.createEntity(appointment2, headers: nil, options: RequestOptions() .upload("Non-Urgent")) // Some time later... Upload only the urgent appointments. try service.upload(groups: StringList.of("Urgent")) }Declaration
Swift
open var uploadGroup: String? { get set } -
Set
useBatchRequesttotrueand this options object.Declaration
Swift
open func useBatch() -> RequestOptionsReturn Value
This options object.
-
Should this request be tunneled inside a batch request, e.g. for security reasons.
Declaration
Swift
open var useBatchRequest: Bool { get set }