Skip to content

Commit

Permalink
Add service ARNs support to the DescribeServices ECS API
Browse files Browse the repository at this point in the history
  • Loading branch information
hltbra committed Dec 16, 2016
1 parent a20906f commit c807ce5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions moto/ecs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,15 @@ def list_services(self, cluster_str):
service_arns.append(self.services[key].arn)
return sorted(service_arns)

def describe_services(self, cluster_str, service_names):
def describe_services(self, cluster_str, service_names_or_arns):
cluster_name = cluster_str.split('/')[-1]
services = []
for service_name in service_names:
cluster_service_pair = '{0}:{1}'.format(cluster_name, service_name)
if cluster_service_pair in self.services:
services.append(self.services[cluster_service_pair])
return services
result = []
for existing_service_name, existing_service_obj in sorted(self.services.items()):
for requested_name_or_arn in service_names_or_arns:
cluster_service_pair = '{0}:{1}'.format(cluster_name, requested_name_or_arn)
if cluster_service_pair == existing_service_name or existing_service_obj.arn == requested_name_or_arn:
result.append(existing_service_obj)
return result

def update_service(self, cluster_str, service_name, task_definition_str, desired_count):
cluster_name = cluster_str.split('/')[-1]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ecs/test_ecs_boto3.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def test_describe_services():
)
response = client.describe_services(
cluster='test_ecs_cluster',
services=['test_ecs_service1', 'test_ecs_service2']
services=['test_ecs_service1', 'arn:aws:ecs:us-east-1:012345678910:service/test_ecs_service2']
)
len(response['services']).should.equal(2)
response['services'][0]['serviceArn'].should.equal('arn:aws:ecs:us-east-1:012345678910:service/test_ecs_service1')
Expand Down

0 comments on commit c807ce5

Please sign in to comment.