Ads API .NET library
|
Utility methods to upload operations for a batch job, and download the results. More...
Public Member Functions | |
BatchJobUtilitiesBase (AdsUser user) | |
Initializes a new instance of the BatchJobUtilitiesBase class. More... | |
BatchJobUtilitiesBase (AdsUser user, bool useChunking, int chunkSize) | |
Initializes a new instance of the BatchJobUtilitiesBase class. More... | |
string | GetResumableUploadUrl (string url) |
Generates a resumable upload URL for a job. This method should be used prior to calling the Upload() method when using API version >=v201601. More... | |
BatchUploadProgress | BeginStreamUpload (string url) |
Begins a streamed upload. More... | |
BatchUploadProgress | EndStreamUpload (BatchUploadProgress uploadProgress) |
Completes a streamed upload. More... | |
Protected Member Functions | |
void | Init (AdsUser user, bool useChunking, int chunkSize) |
Initializes the class. More... | |
void | Upload (string url, byte[] postBody, long startOffset) |
Uploads the operations to a specified URL. More... | |
void | Upload (string url, byte[] data, long startOffset, long?totalUploadSize) |
Uploads the operations to a specified URL. More... | |
BatchUploadProgress | StreamUpload (BatchUploadProgress uploadProgress, string postBody) |
Performs a streamed upload. More... | |
string | DownloadResults (string url) |
Downloads the batch job results from a specified URL. More... | |
virtual int | GetUploadProgress (string url) |
Gets the upload progress. More... | |
virtual void | UploadChunk (string url, byte[] postBody, int start, int end, long startOffset, long?totalUploadSize) |
Uploads a chunk of data for the batch job. More... | |
T | ParseResponse< T > (string contents) |
Parses the XML response from the server into a type object. More... | |
Static Protected Member Functions | |
static string | GetPayload (long bytesUploaded, string postBody) |
Gets the payload. More... | |
static string | GetTextToLog (byte[] bytesToDecode, int start, int numBytes) |
Attempt to convert a byte array into a UTF-8 string for logging. More... | |
Protected Attributes | |
AdsFeatureUsageRegistry | featureUsageRegistry = AdsFeatureUsageRegistry.Instance |
The registry for saving feature usage information.. More... | |
const AdsFeatureUsageRegistry.Features | FEATURE_ID |
The feature ID for this class. More... | |
const int | POLL_INTERVAL_SECONDS_BASE = 30 |
The polling interval base to be used for exponential backoff. More... | |
const string | POSTAMBLE = "</mutate>" |
The postamble for streamed uploads. More... | |
const int | CHUNK_SIZE_ALIGN = 256 * 1024 |
The minimal chunk size to be used for resumable upload (256KB). More... | |
int | CHUNK_SIZE |
The chunk size to be used for resumable upload. More... | |
Properties | |
AdsUser | User [get] |
Returns the user associated with this object. More... | |
Utility methods to upload operations for a batch job, and download the results.
|
inline |
Initializes a new instance of the BatchJobUtilitiesBase class.
user | AdWords user to be used along with this utilities object. |
|
inline |
Initializes a new instance of the BatchJobUtilitiesBase class.
user | AdWords user to be used along with this utilities object. |
useChunking | if the operations should be broken into smaller chunks before uploading to the server. |
chunkSize | The chunk size to use for resumable upload. |
ArgumentException | Thrown if chunkSize is not a multiple of 256KB. |
Use chunking if your network is spotty for uploads, or if it has restrictions such as speed limits or timeouts. Chunking makes your upload reliable when the network is unreliable, but it is inefficient over a good connection, since an HTTPs request has to be made for every chunk being uploaded.
|
inline |
Begins a streamed upload.
url | The upload URL. |
|
inlineprotected |
Downloads the batch job results from a specified URL.
url | The download URL from a batch job. |
|
inline |
Completes a streamed upload.
uploadProgress | The upload progress. |
References Google.Api.Ads.AdWords.Util.BatchJob.BatchUploadProgress.Url.
|
inlinestaticprotected |
Gets the payload.
bytesUploaded | The bytes uploaded. |
postBody | The post body. |
|
inline |
Generates a resumable upload URL for a job. This method should be used prior to calling the Upload() method when using API version >=v201601.
url | The temporary upload URL from BatchJobService. |
|
inlinestaticprotected |
Attempt to convert a byte array into a UTF-8 string for logging.
bytesToDecode | The bytes to decode. |
start | The start byte index. |
numBytes | The number of bytes to decode. |
It is possible that the encoder cannot decode correctly, if the byte array is not aligned with a UTF-8 boundary. In such cases, a character is used.
|
inlineprotectedvirtual |
Gets the upload progress.
url | The resumable upload URL. |
|
inlineprotected |
Initializes the class.
user | The AdWords user. |
useChunking | if the operations should be broken into smaller chunks before uploading to the server. |
chunkSize | The chunk size to use for resumable upload. |
ArgumentException | Thrown if chunkSize is not a multiple of 256KB. |
System.ArgumentException | Thrown if chunked mode is used on Mono platform, or chunk size is not a multiple of 256KB. |
|
inlineprotected |
Parses the XML response from the server into a type object.
T | The type of the object. |
contents | The XML contents. |
|
inlineprotected |
Performs a streamed upload.
uploadProgress | The upload progress. |
postBody | The post body to be stream uploaded. |
References Google.Api.Ads.AdWords.Util.BatchJob.BatchUploadProgress.BytesUploaded, and Google.Api.Ads.AdWords.Util.BatchJob.BatchUploadProgress.Url.
|
inlineprotected |
Uploads the operations to a specified URL.
url | The temporary URL returned by a batch job. |
postBody | The data to be uploaded. |
startOffset | The start offset within the upload stream. |
|
inlineprotected |
Uploads the operations to a specified URL.
url | The temporary URL returned by a batch job. |
data | The data to be uploaded. |
startOffset | The start offset for uploading data. If you are performing a streamed upload, then this parameter determines the file offset to write this data on the server. |
totalUploadSize | If specified, this indicates the total size of the upload. When doing a streamed upload, this value will be null for all except the last chunk. |
System.ApplicationException | Thrown if the upload fails. |
|
inlineprotectedvirtual |
Uploads a chunk of data for the batch job.
url | The resumable upload URL. |
postBody | The post body. |
start | The start of range of bytes from the postBody to be uploaded. |
end | The end of range of bytes from the postBody to be uploaded. |
startOffset | The start offset in the stream to upload to. |
totalUploadSize | If specified, this indicates the total size of the upload. When doing a streamed upload, this value will be null for all except the last chunk. |
References Google.Api.Ads.Common.Util.HttpUtilities.BuildRangeRequest().
|
protected |
The chunk size to be used for resumable upload.
|
protected |
The minimal chunk size to be used for resumable upload (256KB).
|
protected |
The feature ID for this class.
|
protected |
The registry for saving feature usage information..
|
protected |
The polling interval base to be used for exponential backoff.
|
protected |
The postamble for streamed uploads.
This is the trailing string when serializing BatchJobMutateRequest type.
|
get |
Returns the user associated with this object.