Ads API .NET library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase Class Reference

Utility methods to upload operations for a batch job, and download the results. More...

Inheritance diagram for Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase:
Google.Api.Ads.AdWords.Util.BatchJob.v201809.BatchJobUtilities

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

Detailed Description

Utility methods to upload operations for a batch job, and download the results.

Constructor & Destructor Documentation

Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.BatchJobUtilitiesBase ( AdsUser  user)
inline

Initializes a new instance of the BatchJobUtilitiesBase class.

Parameters
userAdWords user to be used along with this utilities object.
Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.BatchJobUtilitiesBase ( AdsUser  user,
bool  useChunking,
int  chunkSize 
)
inline

Initializes a new instance of the BatchJobUtilitiesBase class.

Parameters
userAdWords user to be used along with this utilities object.
useChunkingif the operations should be broken into smaller chunks before uploading to the server.
chunkSizeThe chunk size to use for resumable upload.
Exceptions
ArgumentExceptionThrown 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.

Member Function Documentation

BatchUploadProgress Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.BeginStreamUpload ( string  url)
inline

Begins a streamed upload.

Parameters
urlThe upload URL.
Returns
A BatchUploadProgress object that tracks the progress of upload.
string Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.DownloadResults ( string  url)
inlineprotected

Downloads the batch job results from a specified URL.

Parameters
urlThe download URL from a batch job.
Returns
The results from the batch job.
BatchUploadProgress Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.EndStreamUpload ( BatchUploadProgress  uploadProgress)
inline

Completes a streamed upload.

Parameters
uploadProgressThe upload progress.
Returns
The updated BatchUploadProgress object.

References Google.Api.Ads.AdWords.Util.BatchJob.BatchUploadProgress.Url.

static string Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.GetPayload ( long  bytesUploaded,
string  postBody 
)
inlinestaticprotected

Gets the payload.

Parameters
bytesUploadedThe bytes uploaded.
postBodyThe post body.
Returns
string Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.GetResumableUploadUrl ( string  url)
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.

Returns
The resumable upload URL.
Parameters
urlThe temporary upload URL from BatchJobService.
static string Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.GetTextToLog ( byte[]  bytesToDecode,
int  start,
int  numBytes 
)
inlinestaticprotected

Attempt to convert a byte array into a UTF-8 string for logging.

Parameters
bytesToDecodeThe bytes to decode.
startThe start byte index.
numBytesThe number of bytes to decode.
Returns
The partially decoded string.

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.

virtual int Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.GetUploadProgress ( string  url)
inlineprotectedvirtual

Gets the upload progress.

Parameters
urlThe resumable upload URL.
Returns
The number of bytes uploaded so far.
void Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.Init ( AdsUser  user,
bool  useChunking,
int  chunkSize 
)
inlineprotected

Initializes the class.

Parameters
userThe AdWords user.
useChunkingif the operations should be broken into smaller chunks before uploading to the server.
chunkSizeThe chunk size to use for resumable upload.
Exceptions
ArgumentExceptionThrown if chunkSize is not a multiple of 256KB.
System.ArgumentExceptionThrown if chunked mode is used on Mono platform, or chunk size is not a multiple of 256KB.
T Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.ParseResponse< T > ( string  contents)
inlineprotected

Parses the XML response from the server into a type object.

Template Parameters
TThe type of the object.
Parameters
contentsThe XML contents.
Returns
The parsed object
BatchUploadProgress Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.StreamUpload ( BatchUploadProgress  uploadProgress,
string  postBody 
)
inlineprotected

Performs a streamed upload.

Parameters
uploadProgressThe upload progress.
postBodyThe post body to be stream uploaded.
Returns
The updated BatchUploadProgress object.

References Google.Api.Ads.AdWords.Util.BatchJob.BatchUploadProgress.BytesUploaded, and Google.Api.Ads.AdWords.Util.BatchJob.BatchUploadProgress.Url.

void Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.Upload ( string  url,
byte[]  postBody,
long  startOffset 
)
inlineprotected

Uploads the operations to a specified URL.

Parameters
urlThe temporary URL returned by a batch job.
postBodyThe data to be uploaded.
startOffsetThe start offset within the upload stream.
void Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.Upload ( string  url,
byte[]  data,
long  startOffset,
long?  totalUploadSize 
)
inlineprotected

Uploads the operations to a specified URL.

Parameters
urlThe temporary URL returned by a batch job.
dataThe data to be uploaded.
startOffsetThe 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.
totalUploadSizeIf 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.
Exceptions
System.ApplicationExceptionThrown if the upload fails.
virtual void Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.UploadChunk ( string  url,
byte[]  postBody,
int  start,
int  end,
long  startOffset,
long?  totalUploadSize 
)
inlineprotectedvirtual

Uploads a chunk of data for the batch job.

Parameters
urlThe resumable upload URL.
postBodyThe post body.
startThe start of range of bytes from the postBody to be uploaded.
endThe end of range of bytes from the postBody to be uploaded.
startOffsetThe start offset in the stream to upload to.
totalUploadSizeIf 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().

Member Data Documentation

int Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.CHUNK_SIZE
protected

The chunk size to be used for resumable upload.

const int Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.CHUNK_SIZE_ALIGN = 256 * 1024
protected

The minimal chunk size to be used for resumable upload (256KB).

const AdsFeatureUsageRegistry.Features Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.FEATURE_ID
protected
Initial value:
=
AdsFeatureUsageRegistry.Features.BatchJobHelper

The feature ID for this class.

AdsFeatureUsageRegistry Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.featureUsageRegistry = AdsFeatureUsageRegistry.Instance
protected

The registry for saving feature usage information..

const int Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.POLL_INTERVAL_SECONDS_BASE = 30
protected

The polling interval base to be used for exponential backoff.

const string Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.POSTAMBLE = "</mutate>"
protected

The postamble for streamed uploads.

This is the trailing string when serializing BatchJobMutateRequest type.

Property Documentation

AdsUser Google.Api.Ads.AdWords.Util.BatchJob.BatchJobUtilitiesBase.User
get

Returns the user associated with this object.


The documentation for this class was generated from the following file: