IPWorks Cloud 2020 C++ Edition

Questions / Feedback?

Lease Method

Creates or manages a lease on a blob or container.

Syntax

ANSI (Cross Platform)
int Lease(const char* lpszBlob, int iLeaseAction, const char* lpszNewLeaseId, int iDuration);

Unicode (Windows)
INT Lease(LPCWSTR lpszBlob, INT iLeaseAction, LPCWSTR lpszNewLeaseId, INT iDuration);
- (void)lease:(NSString*)blob :(int)leaseAction :(NSString*)newLeaseId :(int)duration;
#define MID_AZUREBLOB_LEASE 22

IPWORKSCLOUD_EXTERNAL int IPWORKSCLOUD_CALL IPWorksCloud_AzureBlob_Do(void *lpObj, int methid, int cparam, void *param[], int cbparam[], int64 *lpllVal);

Remarks

This method creates or manages a lease on the container currently selected by Container (if Blob is empty), or on the specified Blob in that container.

LeaseAction specifies what action should occur. Possible values, and their effects, are:

  • Acquire (0): Requests a new lease.
    • If no active lease currently exists, a new one is created and LeaseId is populated with the new lease's Id. If a non-empty value is passed for NewLeaseId, it is used; otherwise the server generates an Id.
    • If an active lease currently exists, its Id must be passed for NewLeaseId.
    • In either case, Duration is used to specify the length of time that the lease is valid for (see below).
  • Renew (1): Renews the lease specified by LeaseId.
    • Leases can only be renewed while active or expired (and in the latter case, only if a different lease has not been acquired in the meantime).
    • Renewing an active lease will reset its expiration clock.
  • Change (2): Changes the Id of the active lease specified by LeaseId to the one specified by NewLeaseId.
    • If this action is successful, the class will automatically set LeaseId to the value passed for NewLeaseId.
  • Release (3): Releases the lease specified by LeaseId.
    • If this action is successful, the class will automatically clear LeaseId.
  • Break (4): Breaks the current lease, either immediately or after a certain period of time (the "break period") according to the value passed for Duration.
    • The lease's Id is not required to break the lease.
    • If Duration is -1, fixed-length leases are broken after their remaining time elapses, and infinite-length leases are broken immediately.
    • Otherwise, Duration specified how many seconds (see below) the lease should continue before being broken. (For fixed-length leases, the lesser of this value and the lease's remaining time is used.)
    • If this action is successful, the LeaseBreakPeriod configuration setting is populated to indicate how long the lease's break period is.

If NewLeaseId is non-empty, if must be a GUID string formatted in one of the styles described by Microsoft's .NET Guid(string) constructor documentation. For example: dddddddd-dddd-dddd-dddd-dddddddddddd, where each d is a single case-insensitive hex digit.

The value passed for Duration is only used in the cases listed below; it is ignored otherwise.

  • When LeaseAction is Acquire (0): Valid values for Duration are -1 (infinite), or a number of seconds between 15 and 60 (inclusive).
  • When LeaseAction is Break (4): Valid values for Duration are -1 (unspecified), or a number of seconds between 0 and 60 (inclusive). 0 indicates the lease should be broken immediately, regardless of whether it is fixed- or infinite-length.

For more information about how leases work, refer to Azure's Lease Blob and Lease Container API documentation.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Cloud 2020 C++ Edition - Version 20.0 [Build 8265]