@Override public Dataset create(Dataset dataset, Map<Option, ?> options) { try { return bigquery .datasets() .insert(dataset.getDatasetReference().getProjectId(), dataset) .setFields(Option.FIELDS.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); } }
@Override public Dataset patch(Dataset dataset, Map<Option, ?> options) { try { DatasetReference reference = dataset.getDatasetReference(); return bigquery .datasets() .patch(reference.getProjectId(), reference.getDatasetId(), dataset) .setFields(Option.FIELDS.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); } }
BuilderImpl(com.google.api.services.bigquery.model.Dataset datasetPb) { if (datasetPb.getDatasetReference() != null) { this.datasetId = DatasetId.fromPb(datasetPb.getDatasetReference()); } if (datasetPb.getAccess() != null) { this.acl = Lists.transform( datasetPb.getAccess(), new Function<Dataset.Access, Acl>() { @Override public Acl apply(Dataset.Access accessPb) { return Acl.fromPb(accessPb); } }); } this.creationTime = datasetPb.getCreationTime(); this.defaultTableLifetime = datasetPb.getDefaultTableExpirationMs(); this.description = datasetPb.getDescription(); this.etag = datasetPb.getEtag(); this.friendlyName = datasetPb.getFriendlyName(); this.generatedId = datasetPb.getId(); this.lastModified = datasetPb.getLastModifiedTime(); this.location = datasetPb.getLocation(); this.selfLink = datasetPb.getSelfLink(); this.labels = Labels.fromPb(datasetPb.getLabels()); }
@Test public void testListToDataset() { DatasetReference datasetRef = new DatasetReference().setDatasetId("dataset-id").setProjectId("project-id"); DatasetList.Datasets listDataSet = new DatasetList.Datasets() .setDatasetReference(datasetRef) .setId("project-id:dataset-id") .setFriendlyName("friendly") .setKind("bigquery#dataset") .setLabels(Collections.singletonMap("foo", "bar")); Dataset dataset = HttpBigQueryRpc.LIST_TO_DATASET.apply(listDataSet); assertThat(dataset.getKind()).isEqualTo("bigquery#dataset"); assertThat(dataset.getId()).isEqualTo("project-id:dataset-id"); assertThat(dataset.getFriendlyName()).isEqualTo("friendly"); assertThat(dataset.getDatasetReference()).isEqualTo(datasetRef); assertThat(dataset.getLabels()).containsExactly("foo", "bar"); } }
void emptyDataset(String projectId, Dataset dataset) throws IOException { String datasetId = dataset.getDatasetReference().getDatasetId(); deleteDataset(projectId, datasetId); createDataset(projectId, dataset); }
void createDataset(String projectId, Dataset dataset) throws IOException { try { client.datasets().insert(projectId, dataset) .execute(); } catch (GoogleJsonResponseException e) { if (e.getStatusCode() == HttpStatusCodes.STATUS_CODE_CONFLICT) { logger.debug("Dataset already exists: {}:{}", dataset.getDatasetReference()); } else { throw e; } } }
BuilderImpl(com.google.api.services.bigquery.model.Dataset datasetPb) { if (datasetPb.getDatasetReference() != null) { this.datasetId = DatasetId.fromPb(datasetPb.getDatasetReference()); } if (datasetPb.getAccess() != null) { this.acl = Lists.transform(datasetPb.getAccess(), new Function<Dataset.Access, Acl>() { @Override public Acl apply(Dataset.Access accessPb) { return Acl.fromPb(accessPb); } }); } this.creationTime = datasetPb.getCreationTime(); this.defaultTableLifetime = datasetPb.getDefaultTableExpirationMs(); this.description = datasetPb.getDescription(); this.etag = datasetPb.getEtag(); this.friendlyName = datasetPb.getFriendlyName(); this.generatedId = datasetPb.getId(); this.lastModified = datasetPb.getLastModifiedTime(); this.location = datasetPb.getLocation(); this.selfLink = datasetPb.getSelfLink(); }
BuilderImpl(com.google.api.services.bigquery.model.Dataset datasetPb) { if (datasetPb.getDatasetReference() != null) { this.datasetId = DatasetId.fromPb(datasetPb.getDatasetReference()); } if (datasetPb.getAccess() != null) { this.acl = Lists.transform(datasetPb.getAccess(), new Function<Dataset.Access, Acl>() { @Override public Acl apply(Dataset.Access accessPb) { return Acl.fromPb(accessPb); } }); } this.creationTime = datasetPb.getCreationTime(); this.defaultTableLifetime = datasetPb.getDefaultTableExpirationMs(); this.description = datasetPb.getDescription(); this.etag = datasetPb.getEtag(); this.friendlyName = datasetPb.getFriendlyName(); this.generatedId = datasetPb.getId(); this.lastModified = datasetPb.getLastModifiedTime(); this.location = datasetPb.getLocation(); this.selfLink = datasetPb.getSelfLink(); }
@Override public Dataset create(Dataset dataset, Map<Option, ?> options) { try { return bigquery .datasets() .insert(dataset.getDatasetReference().getProjectId(), dataset) .setFields(Option.FIELDS.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); } }
@Override public Dataset patch(Dataset dataset, Map<Option, ?> options) { try { DatasetReference reference = dataset.getDatasetReference(); return bigquery.datasets() .patch(this.options.projectId(), reference.getDatasetId(), dataset) .setFields(FIELDS.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); } }
@Override public Dataset patch(Dataset dataset, Map<Option, ?> options) { try { DatasetReference reference = dataset.getDatasetReference(); return bigquery.datasets() .patch(this.options.projectId(), reference.getDatasetId(), dataset) .setFields(FIELDS.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); } }
@Override public Dataset patch(Dataset dataset, Map<Option, ?> options) { try { DatasetReference reference = dataset.getDatasetReference(); return bigquery .datasets() .patch(reference.getProjectId(), reference.getDatasetId(), dataset) .setFields(Option.FIELDS.getString(options)) .execute(); } catch (IOException ex) { throw translate(ex); } }
BuilderImpl(com.google.api.services.bigquery.model.Dataset datasetPb) { if (datasetPb.getDatasetReference() != null) { this.datasetId = DatasetId.fromPb(datasetPb.getDatasetReference()); } if (datasetPb.getAccess() != null) { this.acl = Lists.transform( datasetPb.getAccess(), new Function<Dataset.Access, Acl>() { @Override public Acl apply(Dataset.Access accessPb) { return Acl.fromPb(accessPb); } }); } this.creationTime = datasetPb.getCreationTime(); this.defaultTableLifetime = datasetPb.getDefaultTableExpirationMs(); this.description = datasetPb.getDescription(); this.etag = datasetPb.getEtag(); this.friendlyName = datasetPb.getFriendlyName(); this.generatedId = datasetPb.getId(); this.lastModified = datasetPb.getLastModifiedTime(); this.location = datasetPb.getLocation(); this.selfLink = datasetPb.getSelfLink(); this.labels = Labels.fromPb(datasetPb.getLabels()); }