Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Adding support for Memorystore Redis and Memcached #70

Merged
merged 5 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions rpe/resources/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,3 +917,22 @@ def _get_request_args(self):
'location': self._resource_data['location'],
'view': 'JOB_VIEW_DESCRIPTION'
}

class GcpMemorystoreRedis(GoogleAPIResource):
BrettPowell marked this conversation as resolved.
Show resolved Hide resolved

service_name = "redis"
resource_path = "projects.locations.instances"
version = "v1"

required_resource_data = ['name', 'project_id', 'location']

resource_type = 'redis.googleapis.com/Instance'

def _get_request_args(self):
return {
'name': 'projects/{}/locations/{}/instances/{}'.format(
self._resource_data['project_id'],
self._resource_data['location'],
self._resource_data['name']
),
}
11 changes: 11 additions & 0 deletions tests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from rpe.resources.gcp import GcpComputeFirewall
from rpe.resources.gcp import GcpComputeSubnetwork
from rpe.resources.gcp import GcpDataflowJob
from rpe.resources.gcp import GcpMemorystoreRedis

test_project = "my_project"
test_resource_name = "my_resource"
Expand Down Expand Up @@ -244,6 +245,16 @@
resource_type='dataflow.googleapis.com/Job',
name='//dataflow.googleapis.com/projects/my_project/locations/us-central1/jobs/my_resource'
),
ResourceTestCase(
resource_data={
'name': test_resource_name,
'location': 'us-central1',
'project_id': test_project
},
cls=GcpMemorystoreRedis,
resource_type='redis.googleapis.com/Instance',
name='//redis.googleapis.com/projects/my_project/locations/us-central1/instances/my_resource'
jceresini marked this conversation as resolved.
Show resolved Hide resolved
),
BrettPowell marked this conversation as resolved.
Show resolved Hide resolved
]


Expand Down
8 changes: 8 additions & 0 deletions tests/test_resources_cai.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from rpe.resources.gcp import GcpIamServiceAccount
from rpe.resources.gcp import GcpIamServiceAccountKey
from rpe.resources.gcp import GcpDataflowJob
from rpe.resources.gcp import GcpMemorystoreRedis

client_kwargs = {
'credentials': Credentials(token='')
Expand Down Expand Up @@ -212,6 +213,13 @@
},
resource_cls=GcpDataflowJob
),
CaiTestCase(
data={
"name": "//redis.googleapis.com/projects/test-project/locations/us-central1/instances/test-resource",
"asset_type": "redis.googleapis.com/Instance",
},
resource_cls=GcpMemorystoreRedis
),
]


Expand Down