Repository: laughingman7743/BigQuery-DatasetManager

Issue:
Migrating to Python Client Library v0.28
https://github.com/GoogleCloudPlatform/google-cloud-python/releases/tag/bigquery-0.28.0

Discussion:
codecov-io: # [Codecov](https://codecov.io/gh/laughingman7743/BigQuery-DatasetManager/pull/6?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@60e6ebe`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `40%`.

[![Impacted file tree graph](https://codecov.io/gh/laughingman7743/BigQuery-DatasetManager/pull/6/graphs/tree.svg?token=5Vtd53LMy2&src=pr&width=650&height=150)](https://codecov.io/gh/laughingman7743/BigQuery-DatasetManager/pull/6?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master       #6   +/-   ##
=========================================
  Coverage          ?   31.14%           
=========================================
  Files             ?        6           
  Lines             ?      350           
  Branches          ?        0           
=========================================
  Hits              ?      109           
  Misses            ?      241           
  Partials          ?        0
```


| [Impacted Files](https://codecov.io/gh/laughingman7743/BigQuery-DatasetManager/pull/6?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [bqdm/cli.py](https://codecov.io/gh/laughingman7743/BigQuery-DatasetManager/pull/6?src=pr&el=tree#diff-YnFkbS9jbGkucHk=) | `0% <0%> (ø)` | |
| [bqdm/model.py](https://codecov.io/gh/laughingman7743/BigQuery-DatasetManager/pull/6?src=pr&el=tree#diff-YnFkbS9tb2RlbC5weQ==) | `70.83% <44.44%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/laughingman7743/BigQuery-DatasetManager/pull/6?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/laughingman7743/BigQuery-DatasetManager/pull/6?src=pr&el=footer). Last update [60e6ebe...2f8d007](https://codecov.io/gh/laughingman7743/BigQuery-DatasetManager/pull/6?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/README.rst b/README.rst
index 3559c85..ef9cbc1 100644
--- a/README.rst
+++ b/README.rst
@@ -44,7 +44,7 @@ The resource representation of the dataset is described in `YAML format`_.
     description: null
     default_table_expiration_ms: null
     location: US
-    access_grants:
+    access_entries:
     -   role: OWNER
         entity_type: specialGroup
         entity_id: projectOwners
@@ -62,48 +62,48 @@ The resource representation of the dataset is described in `YAML format`_.
 
 See `the official documentation of BigQuery Datasets`_ for details of key names.
 
-+---------------+-------------+-----------+---------+----------------------------------------------------------+
-| Key name                                | Value   | Description                                              |
-+===============+=============+===========+=========+==========================================================+
-| name                                    | str     | The name of the dataset.                                 |
-+---------------+-------------+-----------+---------+----------------------------------------------------------+
-| friendly_name                           | str     | Title of the dataset.                                    |
-+---------------+-------------+-----------+---------+----------------------------------------------------------+
-| description                             | str     | Description of the dataset.                              |
-+---------------+-------------+-----------+---------+----------------------------------------------------------+
-| default_table_expiration_ms             | int     | Default expiration time for tables in the dataset.       |
-+---------------+-------------+-----------+---------+----------------------------------------------------------+
-| location                                | str     | Location in which the dataset is hosted.                 |
-+---------------+-------------+-----------+---------+----------------------------------------------------------+
-| access_grants                           | seq     | Roles granted to entities for this dataset.              |
-+---------------+-------------+-----------+---------+----------------------------------------------------------+
-| access_grants | role                    | str     | Role granted to the entity. One of                       |
-|               |                         |         |                                                          |
-|               |                         |         | * ``OWNER``                                              |
-|               |                         |         | * ``WRITER``                                             |
-|               |                         |         | * ``READER``                                             |
-|               |                         |         |                                                          |
-|               |                         |         | May also be ``None`` if the ``entity_type`` is ``view``. |
-+               +-------------+-----------+---------+----------------------------------------------------------+
-|               | entity_type             | str     | Type of entity being granted the role. One of            |
-|               |                         |         |                                                          |
-|               |                         |         | * ``userByEmail``                                        |
-|               |                         |         | * ``groupByEmail``                                       |
-|               |                         |         | * ``domain``                                             |
-|               |                         |         | * ``specialGroup``                                       |
-|               |                         |         | * ``view``                                               |
-+               +-------------+-----------+---------+----------------------------------------------------------+
-|               | entity_id   |           | str/map | ID of entity being granted the role.                     |
-+               +             +-----------+---------+----------------------------------------------------------+
-|               |             | datasetId | str     | The ID of the dataset containing this table.             |
-|               |             |           |         | (Specified when ``entity_type`` is ``view``.)            |
-+               +             +-----------+---------+----------------------------------------------------------+
-|               |             | projectId | str     | The ID of the project containing this table.             |
-|               |             |           |         | (Specified when ``entity_type`` is ``view``.)            |
-+               +             +-----------+---------+----------------------------------------------------------+
-|               |             | tableId   | str     | The ID of the table.                                     |
-|               |             |           |         | (Specified when ``entity_type`` is ``view``.)            |
-+---------------+-------------+-----------+---------+----------------------------------------------------------+
++----------------+-------------+-----------+---------+----------------------------------------------------------+
+| Key name                                 | Value   | Description                                              |
++================+=============+===========+=========+==========================================================+
+| dataset_id                               | str     | Dataset ID.                                              |
++----------------+-------------+-----------+---------+----------------------------------------------------------+
+| friendly_name                            | str     | Title of the dataset.                                    |
++----------------+-------------+-----------+---------+----------------------------------------------------------+
+| description                              | str     | Description of the dataset.                              |
++----------------+-------------+-----------+---------+----------------------------------------------------------+
+| default_table_expiration_ms              | int     | Default expiration time for tables in the dataset.       |
++----------------+-------------+-----------+---------+----------------------------------------------------------+
+| location                                 | str     | Location in which the dataset is hosted.                 |
++----------------+-------------+-----------+---------+----------------------------------------------------------+
+| access_entries                           | seq     | Represent grant of an access role to an entity.          |
++----------------+-------------+-----------+---------+----------------------------------------------------------+
+| access_entries | role                    | str     | Role granted to the entity. One of                       |
+|                |                         |         |                                                          |
+|                |                         |         | * ``OWNER``                                              |
+|                |                         |         | * ``WRITER``                                             |
+|                |                         |         | * ``READER``                                             |
+|                |                         |         |                                                          |
+|                |                         |         | May also be ``None`` if the ``entity_type`` is ``view``. |
++                +-------------+-----------+---------+----------------------------------------------------------+
+|                | entity_type             | str     | Type of entity being granted the role. One of            |
+|                |                         |         |                                                          |
+|                |                         |         | * ``userByEmail``                                        |
+|                |                         |         | * ``groupByEmail``                                       |
+|                |                         |         | * ``domain``                                             |
+|                |                         |         | * ``specialGroup``                                       |
+|                |                         |         | * ``view``                                               |
++                +-------------+-----------+---------+----------------------------------------------------------+
+|                | entity_id   |           | str/map | ID of entity being granted the role.                     |
++                +             +-----------+---------+----------------------------------------------------------+
+|                |             | datasetId | str     | The ID of the dataset containing this table.             |
+|                |             |           |         | (Specified when ``entity_type`` is ``view``.)            |
++                +             +-----------+---------+----------------------------------------------------------+
+|                |             | projectId | str     | The ID of the project containing this table.             |
+|                |             |           |         | (Specified when ``entity_type`` is ``view``.)            |
++                +             +-----------+---------+----------------------------------------------------------+
+|                |             | tableId   | str     | The ID of the table.                                     |
+|                |             |           |         | (Specified when ``entity_type`` is ``view``.)            |
++----------------+-------------+-----------+---------+----------------------------------------------------------+
 
 .. _`the official documentation of BigQuery Datasets`: https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets
 
diff --git a/bqdm/action.py b/bqdm/action.py
index 5f3b686..0aa750a 100644
--- a/bqdm/action.py
+++ b/bqdm/action.py
@@ -25,8 +25,8 @@ class DatasetAction(object):
 
     @staticmethod
     def get_add_datasets(source, target):
-        names = set(t.name for t in target) - set(s.name for s in source)
-        results = [t for t in target if t.name in names]
+        dataset_ids = set(t.dataset_id for t in target) - set(s.dataset_id for s in source)
+        results = [t for t in target if t.dataset_id in dataset_ids]
         return len(results), tuple(results)
 
     @staticmethod
@@ -37,21 +37,21 @@ class DatasetAction(object):
 
     @staticmethod
     def get_destroy_datasets(source, target):
-        names = set(s.name for s in source) - set(t.name for t in target)
-        results = [s for s in source if s.name in names]
+        dataset_ids = set(s.dataset_id for s in source) - set(t.dataset_id for t in target)
+        results = [s for s in source if s.dataset_id in dataset_ids]
         return len(results), tuple(results)
 
     @staticmethod
     def get_intersection_datasets(source, target):
-        names = set(s.name for s in source) & set(t.name for t in target)
-        results = [s for s in source if s.name in names]
+        dataset_ids = set(s.dataset_id for s in source) & set(t.dataset_id for t in target)
+        results = [s for s in source if s.dataset_id in dataset_ids]
         return len(results), tuple(results)
 
     def list_datasets(self):
         datasets = []
         for dataset in self.client.list_datasets():
             click.echo('Load: ' + dataset.path)
-            datasets.append(BigQueryDataset.from_dataset(dataset))
+            datasets.append(BigQueryDataset.from_dataset(self.client, dataset.dataset_id))
         click.echo('------------------------------------------------------------------------')
         click.echo()
         return datasets
@@ -60,13 +60,11 @@ class DatasetAction(object):
         if not os.path.exists(output_dir):
             os.makedirs(output_dir)
 
-        datasets = self.client.list_datasets()
-        for dataset in datasets:
-            dataset.reload()
+        for dataset in self.client.list_datasets():
             click.echo('Export: {0}'.format(dataset.path))
-            data = dump_dataset(BigQueryDataset.from_dataset(dataset))
+            data = dump_dataset(BigQueryDataset.from_dataset(self.client, dataset.dataset_id))
             _logger.debug(data)
-            with codecs.open(os.path.join(output_dir, '{0}.yml'.format(dataset.name)),
+            with codecs.open(os.path.join(output_dir, '{0}.yml'.format(dataset.dataset_id)),
                              'wb', 'utf-8') as f:
                 f.write(data)
 
@@ -74,7 +72,7 @@ class DatasetAction(object):
         count, datasets = self.get_add_datasets(source, target)
         _logger.debug('Add datasets: {0}'.format(datasets))
         for dataset in datasets:
-            click.secho('  + {0}'.format(dataset.name), fg='green')
+            click.secho('  + {0}'.format(dataset.dataset_id), fg='green')
             for line in dump_dataset(dataset).splitlines():
                 click.echo('    {0}'.format(line))
             click.echo()
@@ -96,8 +94,8 @@ class DatasetAction(object):
         count, datasets = self.get_change_datasets(source, target)
         _logger.debug('Change datasets: {0}'.format(datasets))
         for dataset in datasets:
-            click.secho('  ~ {0}'.format(dataset.name), fg='yellow')
-            old_dataset = next((o for o in source if o.name == dataset.name), None)
+            click.secho('  ~ {0}'.format(dataset.dataset_id), fg='yellow')
+            old_dataset = next((o for o in source if o.dataset_id == dataset.dataset_id), None)
             for d in ndiff(old_dataset, dataset):
                 click.echo('    {0}'.format(d))
             click.echo()
@@ -108,7 +106,7 @@ class DatasetAction(object):
         _logger.debug('Change datasets: {0}'.format(datasets))
         for dataset in datasets:
             converted = BigQueryDataset.to_dataset(self.client, dataset)
-            old_dataset = next((o for o in source if o.name == dataset.name), None)
+            old_dataset = next((o for o in source if o.dataset_id == dataset.dataset_id), None)
             diff = ndiff(old_dataset, dataset)
             click.secho('  Changing... {0}'.format(converted.path), fg='yellow')
             for d in diff:
@@ -121,7 +119,7 @@ class DatasetAction(object):
         count, datasets = self.get_destroy_datasets(source, target)
         _logger.debug('Destroy datasets: {0}'.format(datasets))
         for dataset in datasets:
-            click.secho('  - {0}'.format(dataset.name), fg='red')
+            click.secho('  - {0}'.format(dataset.dataset_id), fg='red')
             click.echo()
         return count
 
@@ -139,7 +137,7 @@ class DatasetAction(object):
         count, datasets = self.get_intersection_datasets(target, source)
         _logger.debug('Destroy datasets: {0}'.format(datasets))
         for dataset in datasets:
-            click.secho('  - {0}'.format(dataset.name), fg='red')
+            click.secho('  - {0}'.format(dataset.dataset_id), fg='red')
             click.echo()
         return count
 
@@ -148,7 +146,7 @@ class DatasetAction(object):
         _logger.debug('Destroy datasets: {0}'.format(datasets))
         for dataset in datasets:
             converted = BigQueryDataset.to_dataset(self.client, dataset)
-            click.secho('  Destroying... {0}'.format(dataset.name), fg='red')
+            click.secho('  Destroying... {0}'.format(dataset.dataset_id), fg='red')
             converted.delete()
             click.echo()
         return count
diff --git a/bqdm/cli.py b/bqdm/cli.py
index 9f2a945..5405243 100755
--- a/bqdm/cli.py
+++ b/bqdm/cli.py
@@ -12,7 +12,7 @@ from past.types import unicode
 import bqdm.message as msg
 from bqdm import CONTEXT_SETTINGS
 from bqdm.action import DatasetAction
-from bqdm.model import BigQueryDataset, BigQueryAccessGrant
+from bqdm.model import BigQueryDataset, BigQueryAccessEntry
 from bqdm.util import list_local_datasets, ordered_dict_constructor, str_representer
 
 
@@ -24,7 +24,7 @@ _logger.setLevel(logging.INFO)
 yaml.add_representer(str, str_representer)
 yaml.add_representer(unicode, str_representer)
 yaml.add_representer(BigQueryDataset, BigQueryDataset.represent)
-yaml.add_representer(BigQueryAccessGrant, BigQueryAccessGrant.represent)
+yaml.add_representer(BigQueryAccessEntry, BigQueryAccessEntry.represent)
 yaml.add_constructor('tag:yaml.org,2002:map', ordered_dict_constructor)
 
 
diff --git a/bqdm/model.py b/bqdm/model.py
index c835def..0bb4351 100644
--- a/bqdm/model.py
+++ b/bqdm/model.py
@@ -3,55 +3,58 @@ from __future__ import absolute_import
 from collections import OrderedDict
 
 from future.utils import iteritems
-from google.cloud.bigquery.dataset import Dataset, AccessGrant
+from google.cloud.bigquery.dataset import AccessEntry
 
 
 class BigQueryDataset(object):
 
-    def __init__(self, name, friendly_name, description,
-                 default_table_expiration_ms, location, access_grants):
-        self.name = name
+    def __init__(self, dataset_id, friendly_name, description,
+                 default_table_expiration_ms, location, access_entries):
+        self.dataset_id = dataset_id
         self.friendly_name = friendly_name
         self.description = description
         self.default_table_expiration_ms = default_table_expiration_ms
         self.location = location
-        self.access_grants = access_grants
+        self.access_entries = access_entries
 
     @staticmethod
     def from_dict(value):
-        access_grants = value.get('access_grants', None)
-        if access_grants:
-            access_grants = [BigQueryAccessGrant.from_dict(a) for a in access_grants]
-        return BigQueryDataset(value.get('name', None),
+        access_entries = value.get('access_entries', None)
+        if access_entries:
+            access_entries = [BigQueryAccessEntry.from_dict(a) for a in access_entries]
+        return BigQueryDataset(value.get('dataset_id', None),
                                value.get('friendly_name', None),
                                value.get('description', None),
                                value.get('default_table_expiration_ms', None),
                                value.get('location', None),
-                               access_grants)
+                               access_entries)
 
     @staticmethod
-    def from_dataset(value):
-        value.reload()
-        access_grants = value.access_grants
-        if access_grants:
-            access_grants = [BigQueryAccessGrant.from_access_grant(a) for a in access_grants]
-        return BigQueryDataset(value.name,
-                               value.friendly_name,
-                               value.description,
-                               value.default_table_expiration_ms,
-                               value.location,
-                               access_grants)
+    def from_dataset(client, dataset_id):
+        dataset_ref = client.dataset(dataset_id)
+        dataset = client.get_dataset(dataset_ref)
+        access_entries = dataset.access_entries
+        if access_entries:
+            access_entries = [BigQueryAccessEntry.from_access_entry(a) for a in access_entries]
+        return BigQueryDataset(dataset.dataset_id,
+                               dataset.friendly_name,
+                               dataset.description,
+                               dataset.default_table_expiration_ms,
+                               dataset.location,
+                               access_entries)
 
     @staticmethod
     def to_dataset(client, value):
-        access_grants = value.access_grants
-        if access_grants:
-            access_grants = tuple([BigQueryAccessGrant.to_access_grant(a) for a in access_grants])
-        dataset = Dataset(value.name, client, access_grants)
+        access_entries = value.access_entries
+        if access_entries:
+            access_entries = tuple([BigQueryAccessEntry.to_access_entry(a) for a in access_entries])
+        dataset_ref = client.dataset(value.dataset_id)
+        dataset = client.get_dataset(dataset_ref)
         dataset.friendly_name = value.friendly_name
         dataset.description = value.description
         dataset.default_table_expiration_ms = value.default_table_expiration_ms
         dataset.location = value.location
+        dataset.access_entries = access_entries
         return dataset
 
     @staticmethod
@@ -59,23 +62,23 @@ class BigQueryDataset(object):
         return dumper.represent_mapping(
             'tag:yaml.org,2002:map',
             (
-                ('name', value.name),
+                ('dataset_id', value.dataset_id),
                 ('friendly_name', value.friendly_name),
                 ('description', value.description),
                 ('default_table_expiration_ms', value.default_table_expiration_ms),
                 ('location', value.location),
-                ('access_grants', value.access_grants),
+                ('access_entries', value.access_entries),
             )
         )
 
     def _key(self):
-        return (self.name,
+        return (self.dataset_id,
                 self.friendly_name,
                 self.description,
                 self.default_table_expiration_ms,
                 self.location,
-                frozenset(self.access_grants) if self.access_grants is not None
-                else self.access_grants,)
+                frozenset(self.access_entries) if self.access_entries is not None
+                else self.access_entries,)
 
     def __eq__(self, other):
         if not isinstance(other, BigQueryDataset):
@@ -92,7 +95,7 @@ class BigQueryDataset(object):
         return 'BigQueryDataset{0}'.format(self._key())
 
 
-class BigQueryAccessGrant(object):
+class BigQueryAccessEntry(object):
 
     def __init__(self, role, entity_type, entity_id):
         self.role = role
@@ -101,21 +104,21 @@ class BigQueryAccessGrant(object):
 
     @staticmethod
     def from_dict(value):
-        return BigQueryAccessGrant(
+        return BigQueryAccessEntry(
             value.get('role', None),
             value.get('entity_type', None),
             value.get('entity_id', None),)
 
     @staticmethod
-    def from_access_grant(value):
-        return BigQueryAccessGrant(
+    def from_access_entry(value):
+        return BigQueryAccessEntry(
             value.role,
             value.entity_type,
             value.entity_id,)
 
     @staticmethod
-    def to_access_grant(value):
-        return AccessGrant(value.role, value.entity_type, value.entity_id)
+    def to_access_entry(value):
+        return AccessEntry(value.role, value.entity_type, value.entity_id)
 
     @staticmethod
     def represent(dumper, value):
@@ -135,7 +138,7 @@ class BigQueryAccessGrant(object):
                 if isinstance(self.entity_id, (dict, OrderedDict,)) else self.entity_id,)
 
     def __eq__(self, other):
-        if not isinstance(other, BigQueryAccessGrant):
+        if not isinstance(other, BigQueryAccessEntry):
             return NotImplemented
         return self._key() == other._key()
 
@@ -146,4 +149,4 @@ class BigQueryAccessGrant(object):
         return hash(self._key())
 
     def __repr__(self):
-        return 'BigQueryAccessGrant{0}'.format(self._key())
+        return 'BigQueryAccessEntry{0}'.format(self._key())
diff --git a/setup.py b/setup.py
index 6808225..742814f 100755
--- a/setup.py
+++ b/setup.py
@@ -30,7 +30,7 @@ setup(
         'future',
         'click>=6.0',
         'PyYAML>=3.12',
-        'google-cloud-bigquery>=0.27.0',
+        'google-cloud-bigquery==0.28.0',
     ],
     tests_require=[
         'pytest',


Test patch:
diff --git a/tests/__init__.py b/tests/__init__.py
index 688a9d5..95bd52a 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -2,10 +2,10 @@
 import yaml
 
 from bqdm.util import ordered_dict_constructor, str_representer
-from bqdm.model import BigQueryDataset, BigQueryAccessGrant
+from bqdm.model import BigQueryDataset, BigQueryAccessEntry
 
 
 yaml.add_representer(str, str_representer)
 yaml.add_representer(BigQueryDataset, BigQueryDataset.represent)
-yaml.add_representer(BigQueryAccessGrant, BigQueryAccessGrant.represent)
+yaml.add_representer(BigQueryAccessEntry, BigQueryAccessEntry.represent)
 yaml.add_constructor('tag:yaml.org,2002:map', ordered_dict_constructor)
diff --git a/tests/test_action.py b/tests/test_action.py
index ad52c1b..16b2cd9 100644
--- a/tests/test_action.py
+++ b/tests/test_action.py
@@ -2,7 +2,7 @@
 import unittest
 
 from bqdm.action import DatasetAction
-from bqdm.model import BigQueryDataset, BigQueryAccessGrant
+from bqdm.model import BigQueryDataset, BigQueryAccessEntry
 
 
 class TestAction(unittest.TestCase):
@@ -75,7 +75,7 @@ class TestAction(unittest.TestCase):
             24 * 30 * 60 * 1000,
             'US',
             [
-                BigQueryAccessGrant(
+                BigQueryAccessEntry(
                     None,
                     'view',
                     {
@@ -149,7 +149,7 @@ class TestAction(unittest.TestCase):
             24 * 30 * 60 * 1000,
             'US',
             [
-                BigQueryAccessGrant(
+                BigQueryAccessEntry(
                     None,
                     'view',
                     {
@@ -223,7 +223,7 @@ class TestAction(unittest.TestCase):
             24 * 30 * 60 * 1000,
             'US',
             [
-                BigQueryAccessGrant(
+                BigQueryAccessEntry(
                     None,
                     'view',
                     {
diff --git a/tests/test_model.py b/tests/test_model.py
index 653d826..16dbe16 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 import unittest
 
-from bqdm.model import BigQueryDataset, BigQueryAccessGrant
+from bqdm.model import BigQueryDataset, BigQueryAccessEntry
 
 
 class TestModel(unittest.TestCase):
@@ -44,18 +44,18 @@ class TestModel(unittest.TestCase):
         self.assertNotEqual(dataset1, dataset4)
         self.assertNotEqual(dataset3, dataset4)
 
-    def test_eq_dataset_with_access_grant(self):
-        access_grant1 = BigQueryAccessGrant(
+    def test_eq_dataset_with_access_entry(self):
+        access_entry1 = BigQueryAccessEntry(
             'OWNER',
             'specialGroup',
             'projectOwners'
         )
-        access_grant2 = BigQueryAccessGrant(
+        access_entry2 = BigQueryAccessEntry(
             'OWNER',
             'specialGroup',
             'projectOwners'
         )
-        access_grant3 = BigQueryAccessGrant(
+        access_entry3 = BigQueryAccessEntry(
             None,
             'view',
             {
@@ -65,69 +65,69 @@ class TestModel(unittest.TestCase):
             }
         )
 
-        dataset_with_access_grant1 = BigQueryDataset(
+        dataset_with_access_entry1 = BigQueryDataset(
             'test',
             'test_friendly_name',
             'test_description',
             24 * 30 * 60 * 1000,
             'US',
-            [access_grant1]
+            [access_entry1]
         )
-        dataset_with_access_grant2 = BigQueryDataset(
+        dataset_with_access_entry2 = BigQueryDataset(
             'test',
             'test_friendly_name',
             'test_description',
             24 * 30 * 60 * 1000,
             'US',
-            [access_grant2]
+            [access_entry2]
         )
-        dataset_with_access_grant3 = BigQueryDataset(
+        dataset_with_access_entry3 = BigQueryDataset(
             'test',
             'test_friendly_name',
             'test_description',
             24 * 30 * 60 * 1000,
             'US',
-            [access_grant3]
+            [access_entry3]
         )
-        dataset_with_access_grant4 = BigQueryDataset(
+        dataset_with_access_entry4 = BigQueryDataset(
             'foo',
             'bar',
             'test_description',
             24 * 30 * 60 * 1000,
             'US',
-            [access_grant1]
+            [access_entry1]
         )
-        dataset_with_access_grant5 = BigQueryDataset(
+        dataset_with_access_entry5 = BigQueryDataset(
             'foo',
             'bar',
             'test_description',
             24 * 30 * 60 * 1000,
             'US',
-            [access_grant1, access_grant3]
+            [access_entry1, access_entry3]
         )
-        dataset_with_access_grant6 = BigQueryDataset(
+        dataset_with_access_entry6 = BigQueryDataset(
             'foo',
             'bar',
             'test_description',
             24 * 30 * 60 * 1000,
             'US',
-            [access_grant3, access_grant1]
+            [access_entry3, access_entry1]
         )
-        dataset_with_access_grant7 = BigQueryDataset(
+        dataset_with_access_entry7 = BigQueryDataset(
             'foo',
             'bar',
             'test_description',
             24 * 30 * 60 * 1000,
             'US',
-            [access_grant1, access_grant2]
+            [access_entry1, access_entry2]
         )
-        self.assertEqual(dataset_with_access_grant1, dataset_with_access_grant2)
-        self.assertNotEqual(dataset_with_access_grant1, dataset_with_access_grant3)
-        self.assertNotEqual(dataset_with_access_grant1, dataset_with_access_grant4)
-        self.assertNotEqual(dataset_with_access_grant3, dataset_with_access_grant4)
-        self.assertEqual(dataset_with_access_grant5, dataset_with_access_grant6)
-        self.assertEqual(dataset_with_access_grant4, dataset_with_access_grant7)
-        self.assertNotEqual(dataset_with_access_grant6, dataset_with_access_grant7)
+        self.assertEqual(dataset_with_access_entry1, dataset_with_access_entry2)
+        self.assertNotEqual(dataset_with_access_entry1, dataset_with_access_entry3)
+        self.assertNotEqual(dataset_with_access_entry1, dataset_with_access_entry4)
+        self.assertNotEqual(dataset_with_access_entry3, dataset_with_access_entry4)
+        self.assertEqual(dataset_with_access_entry5, dataset_with_access_entry6)
+        self.assertEqual(dataset_with_access_entry4, dataset_with_access_entry7)
+        self.assertNotEqual(dataset_with_access_entry6, dataset_with_access_entry7)
 
     def test_dataset_from_dict(self):
         dataset = BigQueryDataset(
@@ -139,40 +139,40 @@ class TestModel(unittest.TestCase):
             None
         )
         dataset_from_dict1 = BigQueryDataset.from_dict({
-            'name': 'test',
+            'dataset_id': 'test',
             'friendly_name': 'test_friendly_name',
             'description': 'test_description',
             'default_table_expiration_ms': 24 * 30 * 60 * 1000,
             'location': 'US',
-            'access_grants': None
+            'access_entris': None
         })
         dataset_from_dict2 = BigQueryDataset.from_dict({
-            'name': 'test',
+            'dataset_id': 'test',
             'friendly_name': 'test_friendly_name',
             'description': 'test_description',
             'default_table_expiration_ms': None,
             'location': 'US',
-            'access_grants': None
+            'access_entries': None
         })
         dataset_from_dict3 = BigQueryDataset.from_dict({
-            'name': 'foo',
+            'dataset_id': 'foo',
             'friendly_name': 'bar',
             'description': 'test_description',
             'default_table_expiration_ms': None,
             'location': 'US',
-            'access_grants': None
+            'access_entries': None
         })
         self.assertEqual(dataset, dataset_from_dict1)
         self.assertNotEqual(dataset, dataset_from_dict2)
         self.assertNotEqual(dataset, dataset_from_dict3)
 
-    def test_dataset_from_dict_with_access_grant(self):
-        access_grant1 = BigQueryAccessGrant(
+    def test_dataset_from_dict_with_access_entry(self):
+        access_entry1 = BigQueryAccessEntry(
             'OWNER',
             'specialGroup',
             'projectOwners'
         )
-        access_grant2 = BigQueryAccessGrant(
+        access_entry2 = BigQueryAccessEntry(
             None,
             'view',
             {
@@ -182,45 +182,45 @@ class TestModel(unittest.TestCase):
             }
         )
 
-        dataset_with_access_grant1 = BigQueryDataset(
+        dataset_with_access_entry1 = BigQueryDataset(
             'test',
             'test_friendly_name',
             'test_description',
             24 * 30 * 60 * 1000,
             'US',
-            [access_grant1]
+            [access_entry1]
         )
-        dataset_with_access_grant2 = BigQueryDataset(
+        dataset_with_access_entry2 = BigQueryDataset(
             'test',
             'test_friendly_name',
             'test_description',
             24 * 30 * 60 * 1000,
             'US',
-            [access_grant2]
+            [access_entry2]
         )
-        dataset_with_access_grant3 = BigQueryDataset(
+        dataset_with_access_entry3 = BigQueryDataset(
             'test',
             'test_friendly_name',
             'test_description',
             24 * 30 * 60 * 1000,
             'US',
-            [access_grant1, access_grant2]
+            [access_entry1, access_entry2]
         )
-        dataset_with_access_grant4 = BigQueryDataset(
+        dataset_with_access_entry4 = BigQueryDataset(
             'test',
             'test_friendly_name',
             'test_description',
             24 * 30 * 60 * 1000,
             'US',
-            [access_grant1, access_grant1]
+            [access_entry1, access_entry1]
         )
-        dataset_with_access_grant_from_dict1 = BigQueryDataset.from_dict({
-            'name': 'test',
+        dataset_with_access_entry_from_dict1 = BigQueryDataset.from_dict({
+            'dataset_id': 'test',
             'friendly_name': 'test_friendly_name',
             'description': 'test_description',
             'default_table_expiration_ms': 24 * 30 * 60 * 1000,
             'location': 'US',
-            'access_grants': [
+            'access_entries': [
                 {
                     'role': 'OWNER',
                     'entity_type': 'specialGroup',
@@ -228,13 +228,13 @@ class TestModel(unittest.TestCase):
                 }
             ]
         })
-        dataset_with_access_grant_from_dict2 = BigQueryDataset.from_dict({
-            'name': 'test',
+        dataset_with_access_entry_from_dict2 = BigQueryDataset.from_dict({
+            'dataset_id': 'test',
             'friendly_name': 'test_friendly_name',
             'description': 'test_description',
             'default_table_expiration_ms': 24 * 30 * 60 * 1000,
             'location': 'US',
-            'access_grants': [
+            'access_entries': [
                 {
                     'role': None,
                     'entity_type': 'view',
@@ -246,13 +246,13 @@ class TestModel(unittest.TestCase):
                 }
             ]
         })
-        dataset_with_access_grant_from_dict3 = BigQueryDataset.from_dict({
-            'name': 'test',
+        dataset_with_access_entry_from_dict3 = BigQueryDataset.from_dict({
+            'dataset_id': 'test',
             'friendly_name': 'test_friendly_name',
             'description': 'test_description',
             'default_table_expiration_ms': 24 * 30 * 60 * 1000,
             'location': 'US',
-            'access_grants': [
+            'access_entries': [
                 {
                     'role': 'OWNER',
                     'entity_type': 'specialGroup',
@@ -269,13 +269,13 @@ class TestModel(unittest.TestCase):
                 }
             ]
         })
-        dataset_with_access_grant_from_dict4 = BigQueryDataset.from_dict({
-            'name': 'test',
+        dataset_with_access_entry_from_dict4 = BigQueryDataset.from_dict({
+            'dataset_id': 'test',
             'friendly_name': 'test_friendly_name',
             'description': 'test_description',
             'default_table_expiration_ms': 24 * 30 * 60 * 1000,
             'location': 'US',
-            'access_grants': [
+            'access_entries': [
                 {
                     'role': 'OWNER',
                     'entity_type': 'specialGroup',
@@ -288,15 +288,15 @@ class TestModel(unittest.TestCase):
                 }
             ]
         })
-        self.assertEqual(dataset_with_access_grant1, dataset_with_access_grant_from_dict1)
-        self.assertNotEqual(dataset_with_access_grant1, dataset_with_access_grant_from_dict2)
-        self.assertNotEqual(dataset_with_access_grant1, dataset_with_access_grant_from_dict3)
-        self.assertEqual(dataset_with_access_grant2, dataset_with_access_grant_from_dict2)
-        self.assertNotEqual(dataset_with_access_grant2, dataset_with_access_grant_from_dict1)
-        self.assertNotEqual(dataset_with_access_grant2, dataset_with_access_grant_from_dict3)
-        self.assertEqual(dataset_with_access_grant3, dataset_with_access_grant_from_dict3)
-        self.assertNotEqual(dataset_with_access_grant3, dataset_with_access_grant_from_dict1)
-        self.assertNotEqual(dataset_with_access_grant3, dataset_with_access_grant_from_dict2)
-        self.assertEqual(dataset_with_access_grant4, dataset_with_access_grant_from_dict4)
-        self.assertEqual(dataset_with_access_grant1, dataset_with_access_grant_from_dict4)
-        self.assertEqual(dataset_with_access_grant4, dataset_with_access_grant_from_dict1)
+        self.assertEqual(dataset_with_access_entry1, dataset_with_access_entry_from_dict1)
+        self.assertNotEqual(dataset_with_access_entry1, dataset_with_access_entry_from_dict2)
+        self.assertNotEqual(dataset_with_access_entry1, dataset_with_access_entry_from_dict3)
+        self.assertEqual(dataset_with_access_entry2, dataset_with_access_entry_from_dict2)
+        self.assertNotEqual(dataset_with_access_entry2, dataset_with_access_entry_from_dict1)
+        self.assertNotEqual(dataset_with_access_entry2, dataset_with_access_entry_from_dict3)
+        self.assertEqual(dataset_with_access_entry3, dataset_with_access_entry_from_dict3)
+        self.assertNotEqual(dataset_with_access_entry3, dataset_with_access_entry_from_dict1)
+        self.assertNotEqual(dataset_with_access_entry3, dataset_with_access_entry_from_dict2)
+        self.assertEqual(dataset_with_access_entry4, dataset_with_access_entry_from_dict4)
+        self.assertEqual(dataset_with_access_entry1, dataset_with_access_entry_from_dict4)
+        self.assertEqual(dataset_with_access_entry4, dataset_with_access_entry_from_dict1)
diff --git a/tests/test_util.py b/tests/test_util.py
index 618d9b0..a122afc 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 import unittest
 
-from bqdm.model import BigQueryDataset, BigQueryAccessGrant
+from bqdm.model import BigQueryDataset, BigQueryAccessEntry
 from bqdm.util import dump_dataset
 
 
@@ -17,16 +17,16 @@ class TestUtil(unittest.TestCase):
             None
         )
         actual_dump_data1 = dump_dataset(dataset1)
-        expected_dump_data1 = """name: test1
+        expected_dump_data1 = """dataset_id: test1
 friendly_name: test_friendly_name
 description: test_description
 default_table_expiration_ms: 43200000
 location: US
-access_grants: null
+access_entries: null
 """
         self.assertEqual(actual_dump_data1, expected_dump_data1)
 
-        access_grant2 = BigQueryAccessGrant(
+        access_entry2 = BigQueryAccessEntry(
             'OWNER',
             'specialGroup',
             'projectOwners'
@@ -37,22 +37,22 @@ access_grants: null
             'test_description',
             24 * 30 * 60 * 1000,
             'US',
-            [access_grant2]
+            [access_entry2]
         )
         actual_dump_data2 = dump_dataset(dataset2)
-        expected_dump_data2 = """name: test2
+        expected_dump_data2 = """dataset_id: test2
 friendly_name: test_friendly_name
 description: test_description
 default_table_expiration_ms: 43200000
 location: US
-access_grants:
+access_entries:
 -   role: OWNER
     entity_type: specialGroup
     entity_id: projectOwners
 """
         self.assertEqual(actual_dump_data2, expected_dump_data2)
 
-        access_grant3 = BigQueryAccessGrant(
+        access_entry3 = BigQueryAccessEntry(
             None,
             'view',
             {
@@ -67,15 +67,15 @@ access_grants:
             'test_description',
             24 * 30 * 60 * 1000,
             'US',
-            [access_grant3]
+            [access_entry3]
         )
         actual_dump_data3 = dump_dataset(dataset3)
-        expected_dump_data3 = """name: test3
+        expected_dump_data3 = """dataset_id: test3
 friendly_name: test_friendly_name
 description: test_description
 default_table_expiration_ms: 43200000
 location: US
-access_grants:
+access_entries:
 -   role: null
     entity_type: view
     entity_id:
@@ -91,15 +91,15 @@ access_grants:
             'test_description',
             24 * 30 * 60 * 1000,
             'US',
-            [access_grant2, access_grant3]
+            [access_entry2, access_entry3]
         )
         actual_dump_data4 = dump_dataset(dataset4)
-        expected_dump_data4 = """name: test4
+        expected_dump_data4 = """dataset_id: test4
 friendly_name: test_friendly_name
 description: test_description
 default_table_expiration_ms: 43200000
 location: US
-access_grants:
+access_entries:
 -   role: OWNER
     entity_type: specialGroup
     entity_id: projectOwners