/// <summary> /// Creates a <see cref="Job"/> with a client-generated <see cref="JobReference"/> based on /// <paramref name="options"/> and containing the given job configuration. /// </summary> /// <remarks>This method is internal for test purposes.</remarks> /// <param name="configuration">Configuration for the job. Must not be null.</param> /// <param name="options">Options for job creation. May be null.</param> internal Job CreateJob(JobConfiguration configuration, JobCreationOptions options) { GaxPreconditions.CheckNotNull(configuration, nameof(configuration)); string projectId = options?.ProjectId ?? ProjectId; string jobId = options?.JobId; string jobIdPrefix = options?.JobIdPrefix; IDictionary <string, string> jobLabels = options?.Labels; if (jobId != null && jobIdPrefix != null) { throw new ArgumentException("Only one of JobId or JobIdPrefix can be specified for a single operation."); } if (jobId == null) { var prefix = jobIdPrefix ?? DefaultJobIdPrefix; jobId = prefix + Guid.NewGuid().ToString().Replace("-", "_"); } string location = options?.JobLocation ?? DefaultLocation; if (jobLabels != null && jobLabels.Count > 0) { configuration.Labels = jobLabels; } return(new Job { Configuration = configuration, JobReference = GetJobReference(projectId, jobId, location) }); }
private InsertRequest CreateInsertJobRequest(JobConfiguration configuration, JobCreationOptions options) { var job = CreateJob(configuration, options); var request = Service.Jobs.Insert(job, job.JobReference.ProjectId); request.ModifyRequest += _versionHeaderAction; return(request); }
private InsertRequest CreateInsertJobRequest(JobConfiguration configuration, JobCreationOptions options) { var job = CreateJob(configuration, options); var request = Service.Jobs.Insert(job, job.JobReference.ProjectId); // It's safe to retry job inserts when they include a job ID, which ours always do. RetryHandler.MarkAsRetriable(request); return(request); }
private async Task<BigQueryJob> UploadDataAsync(JobConfigurationLoad loadConfiguration, Stream input, string contentType, JobCreationOptions options, CancellationToken cancellationToken) { var job = CreateJob(new JobConfiguration { Load = loadConfiguration }, options); var mediaUpload = new CustomMediaUpload(Service, job, job.JobReference.ProjectId, input, contentType); var finalProgress = await mediaUpload.UploadAsync(cancellationToken).ConfigureAwait(false); if (finalProgress.Exception != null) { throw finalProgress.Exception; } return new BigQueryJob(this, mediaUpload.ResponseBody); }
private BigQueryJob UploadData(JobConfigurationLoad loadConfiguration, Stream input, string contentType, JobCreationOptions options) { var job = CreateJob(new JobConfiguration { Load = loadConfiguration }, options); var mediaUpload = new CustomMediaUpload(Service, job, job.JobReference.ProjectId, input, contentType); var finalProgress = mediaUpload.Upload(); if (finalProgress.Exception != null) { throw finalProgress.Exception; } return new BigQueryJob(this, mediaUpload.ResponseBody); }