diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ef635507e..48e6782a2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,19 +53,8 @@ repos: | openstack/tests/functional/.* | openstack/tests/unit/.* | openstack/tests/fixtures.py - | openstack/accelerator/.* | openstack/cloud/.* - | openstack/container_infrastructure_management/.* - | openstack/database/.* - | openstack/dns/.* | openstack/fixture/.* - | openstack/instance_ha/.* - | openstack/key_manager/.* - | openstack/load_balancer/.* - | openstack/message/.* - | openstack/placement/.* - | openstack/shared_file_system/.* - | openstack/workflow/.* | doc/.* | examples/.* | releasenotes/.* diff --git a/openstack/database/v1/instance.py b/openstack/database/v1/instance.py index c24abaa4a..31f181862 100644 --- a/openstack/database/v1/instance.py +++ b/openstack/database/v1/instance.py @@ -89,7 +89,7 @@ class Instance(resource.Resource): :returns: ``None`` """ - body = {'restart': {}} + body = {'restart': None} url = utils.urljoin(self.base_path, self.id, 'action') session.post(url, json=body) diff --git a/openstack/dns/v2/_base.py b/openstack/dns/v2/_base.py index 791d9d537..0cac1eac5 100644 --- a/openstack/dns/v2/_base.py +++ b/openstack/dns/v2/_base.py @@ -9,6 +9,8 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. + +import typing as ty import urllib.parse from openstack import exceptions @@ -73,7 +75,7 @@ class Resource(resource.Resource): @classmethod def _get_next_link(cls, uri, response, data, marker, limit, total_yielded): next_link = None - params = {} + params: ty.Dict[str, ty.Union[ty.List[str], str]] = {} if isinstance(data, dict): links = data.get('links') if links: diff --git a/openstack/dns/v2/zone_share.py b/openstack/dns/v2/zone_share.py index b778b1620..af889d355 100644 --- a/openstack/dns/v2/zone_share.py +++ b/openstack/dns/v2/zone_share.py @@ -29,17 +29,16 @@ class ZoneShare(_base.Resource): _query_mapping = resource.QueryParameters('target_project_id') # Properties + #: The ID of the zone being shared. + zone_id = resource.URI('zone_id') #: Timestamp when the share was created. created_at = resource.Body('created_at') #: Timestamp when the member was last updated. updated_at = resource.Body('updated_at') + # FIXME(stephenfin): This conflicts since there is a zone ID in the URI #: The zone ID of the zone being shared. - zone_id = resource.Body('zone_id') + # zone_id = resource.Body('zone_id') #: The project ID that owns the share. project_id = resource.Body('project_id') #: The target project ID that the zone is shared with. target_project_id = resource.Body('target_project_id') - - # URI Properties - #: The ID of the zone being shared. - zone_id = resource.URI('zone_id') diff --git a/openstack/instance_ha/v1/host.py b/openstack/instance_ha/v1/host.py index 29cc94f9a..ff356797a 100644 --- a/openstack/instance_ha/v1/host.py +++ b/openstack/instance_ha/v1/host.py @@ -32,8 +32,6 @@ class Host(resource.Resource): allow_commit = True allow_delete = True - #: A ID of representing this host - id = resource.URI("id") #: A Uuid of representing this host uuid = resource.Body("uuid") #: A failover segment ID of this host(in URI) diff --git a/openstack/message/v2/message.py b/openstack/message/v2/message.py index 40db3a5e9..da36c58b0 100644 --- a/openstack/message/v2/message.py +++ b/openstack/message/v2/message.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +import typing as ty import uuid from openstack import resource @@ -53,6 +54,10 @@ class Message(resource.Resource): #: in case keystone auth is not enabled in Zaqar service. project_id = resource.Header("X-PROJECT-ID") + # FIXME(stephenfin): This is actually a query arg but we need it for + # deletions and resource.delete doesn't respect these currently + claim_id: ty.Optional[str] = None + def post(self, session, messages): request = self._prepare_request(requires_id=False, prepend_key=True) headers = { diff --git a/openstack/placement/v1/resource_provider_inventory.py b/openstack/placement/v1/resource_provider_inventory.py index 016bb49f3..4261e6ba1 100644 --- a/openstack/placement/v1/resource_provider_inventory.py +++ b/openstack/placement/v1/resource_provider_inventory.py @@ -19,7 +19,9 @@ class ResourceProviderInventory(resource.Resource): resources_key = None base_path = '/resource_providers/%(resource_provider_id)s/inventories' - _query_mapping = {} + _query_mapping = resource.QueryParameters( + include_pagination_defaults=False + ) # Capabilities diff --git a/openstack/resource.py b/openstack/resource.py index 54ca6bab1..7fa930ae2 100644 --- a/openstack/resource.py +++ b/openstack/resource.py @@ -468,7 +468,7 @@ class Resource(dict): #: The name of this resource. name: ty.Union[Body, URI] = Body("name") #: The OpenStack location of this resource. - location: ty.Union[Computed, Body] = Computed('location') + location: ty.Union[Computed, Body, Header] = Computed('location') #: Mapping of accepted query parameter names. _query_mapping = QueryParameters() diff --git a/openstack/tests/unit/database/v1/test_instance.py b/openstack/tests/unit/database/v1/test_instance.py index 0a329d379..bb2df451d 100644 --- a/openstack/tests/unit/database/v1/test_instance.py +++ b/openstack/tests/unit/database/v1/test_instance.py @@ -97,7 +97,7 @@ class TestInstance(base.TestCase): self.assertIsNone(sot.restart(sess)) url = "instances/%s/action" % IDENTIFIER - body = {'restart': {}} + body = {'restart': None} sess.post.assert_called_with(url, json=body) def test_action_resize(self): diff --git a/openstack/tests/unit/placement/v1/test_resource_provider_inventory.py b/openstack/tests/unit/placement/v1/test_resource_provider_inventory.py index 6f01f8e46..1194ca81a 100644 --- a/openstack/tests/unit/placement/v1/test_resource_provider_inventory.py +++ b/openstack/tests/unit/placement/v1/test_resource_provider_inventory.py @@ -39,7 +39,7 @@ class TestResourceProviderInventory(base.TestCase): self.assertTrue(sot.allow_list) self.assertFalse(sot.allow_patch) - self.assertDictEqual({}, sot._query_mapping) + self.assertDictEqual({}, sot._query_mapping._mapping) def test_make_it(self): sot = resource_provider_inventory.ResourceProviderInventory(**FAKE) diff --git a/setup.cfg b/setup.cfg index e5536e14b..f1a352187 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,19 +47,8 @@ exclude = (?x)( | openstack/tests/functional | openstack/tests/unit | openstack/tests/fixtures.py - | openstack/accelerator | openstack/cloud - | openstack/container_infrastructure_management - | openstack/database - | openstack/dns | openstack/fixture - | openstack/instance_ha - | openstack/key_manager - | openstack/load_balancer - | openstack/message - | openstack/placement - | openstack/shared_file_system - | openstack/workflow | doc | examples | releasenotes