From 626970a353c158158173dac0730cf1204fcf2f11 Mon Sep 17 00:00:00 2001 From: elajkat Date: Fri, 8 May 2020 12:17:40 +0200 Subject: [PATCH] Add segments client code Related-Bug: #1878632 Needed-By: https://review.opendev.org/728904 Change-Id: I85b8e7b3fb84e7e9fd133edffc300a83eeb7c56d --- neutronclient/v2_0/client.py | 25 +++++++++++++++++++ .../notes/segments-8557f5b0caa5ee26.yaml | 5 ++++ 2 files changed, 30 insertions(+) create mode 100644 releasenotes/notes/segments-8557f5b0caa5ee26.yaml diff --git a/neutronclient/v2_0/client.py b/neutronclient/v2_0/client.py index 5fa869840..0cc48ea24 100644 --- a/neutronclient/v2_0/client.py +++ b/neutronclient/v2_0/client.py @@ -516,6 +516,8 @@ class Client(ClientBase): security_group_path = "/security-groups/%s" security_group_rules_path = "/security-group-rules" security_group_rule_path = "/security-group-rules/%s" + segments_path = "/segments" + segment_path = "/segments/%s" sfc_flow_classifiers_path = "/sfc/flow_classifiers" sfc_flow_classifier_path = "/sfc/flow_classifiers/%s" @@ -669,6 +671,7 @@ class Client(ClientBase): 'service_definitions': 'service_definition', 'security_groups': 'security_group', 'security_group_rules': 'security_group_rule', + 'segments': 'segment', 'ipsecpolicies': 'ipsecpolicy', 'ikepolicies': 'ikepolicy', 'ipsec_site_connections': 'ipsec_site_connection', @@ -1048,6 +1051,28 @@ class Client(ClientBase): return self.get(self.security_group_rule_path % (security_group_rule), params=_params) + def create_segment(self, body=None): + """Creates a new segment.""" + return self.post(self.segments_path, body=body) + + def update_segment(self, segment, body=None, revision_number=None): + """Updates a segment.""" + return self._update_resource(self.segment_path % segment, body=body, + revision_number=revision_number) + + def list_segments(self, retrieve_all=True, **_params): + """Fetches a list of all segments for a project.""" + return self.list('segments', self.segments_path, retrieve_all, + **_params) + + def show_segment(self, segment, **_params): + """Fetches information of a certain segment.""" + return self.get(self.segment_path % segment, params=_params) + + def delete_segment(self, segment): + """Deletes the specified segment.""" + return self.delete(self.segment_path % segment) + def list_endpoint_groups(self, retrieve_all=True, **_params): """Fetches a list of all VPN endpoint groups for a project.""" return self.list('endpoint_groups', self.endpoint_groups_path, diff --git a/releasenotes/notes/segments-8557f5b0caa5ee26.yaml b/releasenotes/notes/segments-8557f5b0caa5ee26.yaml new file mode 100644 index 000000000..292adf85e --- /dev/null +++ b/releasenotes/notes/segments-8557f5b0caa5ee26.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + New client methods: ``create_segment``, ``update_segment``, + ``list_segments``, ``show_segment`` and ``delete_segment``.