Ads API .NET library
|
Utility methods to upload operations for a batch job, and download the results. More...
Public Member Functions | |
delegate bool | WaitCallback (ApiBatchJob batchJob, long waitedMilliseconds) |
Wait callback to be used when calling WaitForPendingJob(long,int,WaitCallback) method. More... | |
BatchJobUtilities (AdsUser user) | |
Initializes a new instance of the BatchJobUtilities class. More... | |
BatchJobUtilities (AdsUser user, bool useChunking, int chunkSize) | |
Initializes a new instance of the BatchJobUtilities class. More... | |
void | Upload (string url, IEnumerable< Operation > operations) |
Uploads the operations to a specified URL. More... | |
void | Upload (string url, IEnumerable< Operation > operations, bool resumePreviousUpload) |
Uploads the operations to a specified URL. More... | |
BatchUploadProgress | StreamUpload (BatchUploadProgress uploadProgress, IEnumerable< Operation > operations) |
Uploads the operations to a specified URL in a streamed manner. More... | |
BatchJobMutateResponse | Download (string url) |
Downloads the batch job results from a specified URL. More... | |
bool | WaitForPendingJob (long batchJobId) |
Wait for the job to complete. More... | |
bool | WaitForPendingJob (long batchJobId, int numMilliSecondsToWait) |
Wait for the job to complete. More... | |
bool | WaitForPendingJob (long batchJobId, int numMilliSecondsToWait, WaitCallback callback) |
Wait for the job to complete. More... | |
void | TryToCancelJob (long batchJobId) |
Try to cancel a job. More... | |
void | Upload (string url, Operation[] operations) |
Uploads the operations to a specified URL. More... | |
void | Upload (string url, Operation[] operations, bool resumePreviousUpload) |
Uploads the operations to a specified URL. More... | |
BatchUploadProgress | StreamUpload (BatchUploadProgress uploadProgress, Operation[] operations) |
Uploads the operations to a specified URL in a streamed manner. More... | |
![]() | |
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 | |
string | GetPostBody (IEnumerable< Operation > operations) |
Gets the post body for sending a request. More... | |
![]() | |
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... | |
Additional Inherited Members | |
![]() | |
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... | |
![]() | |
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... | |
![]() | |
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 BatchJobUtilities class.
user | AdWords user to be used along with this utilities object. |
|
inline |
Initializes a new instance of the BatchJobUtilities 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 |
Downloads the batch job results from a specified URL.
url | The download URL from a batch job. |
|
inlineprotected |
Gets the post body for sending a request.
operations | The list of operations. |
|
inline |
Uploads the operations to a specified URL in a streamed manner.
uploadProgress | The upload progress tracker. |
operations | The list of operations. |
|
inline |
Uploads the operations to a specified URL in a streamed manner.
uploadProgress | The upload progress tracker. |
operations | The list of operations. |
Use this method as a workaround for https://bugzilla.xamarin.com/show_bug.cgi?id=40793 if you are using VB.NET on Mono. Otherwise use StreamUpload(BatchUploadProgress, IEnumerable{Operation}) method.
|
inline |
Try to cancel a job.
batchJobId | ID of the batch job to cancel. |
AdWordsApiException | Thrown if an API error occurred when cancelling the job. |
|
inline |
Uploads the operations to a specified URL.
url | The temporary URL returned by a batch job. |
operations | The list of operations. |
|
inline |
Uploads the operations to a specified URL.
url | The temporary URL returned by a batch job. |
operations | The list of operations. |
resumePreviousUpload | True, if a previously interrupted upload should be resumed. |
|
inline |
Uploads the operations to a specified URL.
url | The temporary URL returned by a batch job. |
operations | The list of operations. |
Use this method as a workaround for https://bugzilla.xamarin.com/show_bug.cgi?id=40793 if you are using VB.NET on Mono. Otherwise use Upload(string, IEnumerable{Operation}) method.
|
inline |
Uploads the operations to a specified URL.
url | The temporary URL returned by a batch job. |
operations | The list of operations. |
resumePreviousUpload | True, if a previously interrupted upload should be resumed. |
Use this method as a workaround for https://bugzilla.xamarin.com/show_bug.cgi?id=40793 if you are using VB.NET on Mono. Otherwise use Upload(string, IEnumerable{Operation}, bool) method.
delegate bool Google.Api.Ads.AdWords.Util.BatchJob.v201809.BatchJobUtilities.WaitCallback | ( | ApiBatchJob | batchJob, |
long | waitedMilliseconds | ||
) |
Wait callback to be used when calling WaitForPendingJob(long,int,WaitCallback) method.
batchJob | The batchjob instance that was retrieved by the WaitForPendingJob(long,int,WaitCallback) method when polling for job status. |
waitedMilliseconds | The time in milliseconds for which the WaitForPendingJob(long,int,WaitCallback) method has waited so far. |
|
inline |
Wait for the job to complete.
batchJobId | ID of the job to wait for completion. |
false
, if the job is still pending, false otherwise.
|
inline |
Wait for the job to complete.
batchJobId | ID of the job to wait for completion. |
numMilliSecondsToWait | The number of milliseconds to wait for job completion. |
false
, if the job is still pending, false otherwise.
|
inline |
Wait for the job to complete.
batchJobId | ID of the job to wait for completion. |
numMilliSecondsToWait | The number of milliseconds to wait for job completion. |
callback | The callback to be called whenever the method polls the server for job status. |
false
, if the job is still pending, true otherwise.