Add outputs and vpc interfaces to a mediaconnect flow (#4034)
* Add outputs and vpc interfaces to a mediaconnect flow * Add negative tests for add_flow_outputs and add_flow_vpc_interfaces * fix: fstring to format * MediaConnect - add appropriate URLs for ServerMode tests Co-authored-by: Bert Blommers <info@bertblommers.nl>
This commit is contained in:
parent
f68d807467
commit
167423777b
@ -6740,9 +6740,9 @@
|
|||||||
<details>
|
<details>
|
||||||
<summary>29% implemented</summary>
|
<summary>29% implemented</summary>
|
||||||
|
|
||||||
- [ ] add_flow_outputs
|
- [X] add_flow_outputs
|
||||||
- [ ] add_flow_sources
|
- [ ] add_flow_sources
|
||||||
- [ ] add_flow_vpc_interfaces
|
- [X] add_flow_vpc_interfaces
|
||||||
- [X] create_flow
|
- [X] create_flow
|
||||||
- [X] delete_flow
|
- [X] delete_flow
|
||||||
- [X] describe_flow
|
- [X] describe_flow
|
||||||
|
@ -185,6 +185,26 @@ class MediaConnectBackend(BaseBackend):
|
|||||||
raise NotFoundException(message="Resource not found.")
|
raise NotFoundException(message="Resource not found.")
|
||||||
return resource.tags
|
return resource.tags
|
||||||
|
|
||||||
|
def add_flow_vpc_interfaces(self, flow_arn, vpc_interfaces):
|
||||||
|
if flow_arn in self._flows:
|
||||||
|
flow = self._flows[flow_arn]
|
||||||
|
flow.vpc_interfaces = vpc_interfaces
|
||||||
|
else:
|
||||||
|
raise NotFoundException(
|
||||||
|
message="flow with arn={} not found".format(flow_arn)
|
||||||
|
)
|
||||||
|
return flow_arn, flow.vpc_interfaces
|
||||||
|
|
||||||
|
def add_flow_outputs(self, flow_arn, outputs):
|
||||||
|
if flow_arn in self._flows:
|
||||||
|
flow = self._flows[flow_arn]
|
||||||
|
flow.outputs = outputs
|
||||||
|
else:
|
||||||
|
raise NotFoundException(
|
||||||
|
message="flow with arn={} not found".format(flow_arn)
|
||||||
|
)
|
||||||
|
return flow_arn, flow.outputs
|
||||||
|
|
||||||
# add methods from here
|
# add methods from here
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,3 +81,21 @@ class MediaConnectResponse(BaseResponse):
|
|||||||
resource_arn=resource_arn,
|
resource_arn=resource_arn,
|
||||||
)
|
)
|
||||||
return json.dumps(dict(tags=tags))
|
return json.dumps(dict(tags=tags))
|
||||||
|
|
||||||
|
def add_flow_vpc_interfaces(self):
|
||||||
|
flow_arn = unquote(self._get_param("flowArn"))
|
||||||
|
vpc_interfaces = self._get_param("vpcInterfaces")
|
||||||
|
flow_arn, vpc_interfaces = self.mediaconnect_backend.add_flow_vpc_interfaces(
|
||||||
|
flow_arn=flow_arn, vpc_interfaces=vpc_interfaces
|
||||||
|
)
|
||||||
|
return json.dumps(dict(flow_arn=flow_arn, vpc_interfaces=vpc_interfaces))
|
||||||
|
|
||||||
|
def add_flow_outputs(self):
|
||||||
|
flow_arn = unquote(self._get_param("flowArn"))
|
||||||
|
outputs = self._get_param("outputs")
|
||||||
|
flow_arn, outputs = self.mediaconnect_backend.add_flow_outputs(
|
||||||
|
flow_arn=flow_arn, outputs=outputs
|
||||||
|
)
|
||||||
|
return json.dumps(dict(flow_arn=flow_arn, outputs=outputs))
|
||||||
|
|
||||||
|
# add methods from here
|
||||||
|
@ -12,6 +12,8 @@ response = MediaConnectResponse()
|
|||||||
url_paths = {
|
url_paths = {
|
||||||
"{0}/v1/flows": response.dispatch,
|
"{0}/v1/flows": response.dispatch,
|
||||||
"{0}/v1/flows/(?P<flowarn>[^/.]+)": response.dispatch,
|
"{0}/v1/flows/(?P<flowarn>[^/.]+)": response.dispatch,
|
||||||
|
"{0}/v1/flows/(?P<flowarn>[^/.]+)/vpcInterfaces": response.dispatch,
|
||||||
|
"{0}/v1/flows/(?P<flowarn>[^/.]+)/outputs": response.dispatch,
|
||||||
"{0}/v1/flows/start/(?P<flowarn>[^/.]+)": response.dispatch,
|
"{0}/v1/flows/start/(?P<flowarn>[^/.]+)": response.dispatch,
|
||||||
"{0}/v1/flows/stop/(?P<flowarn>[^/.]+)": response.dispatch,
|
"{0}/v1/flows/stop/(?P<flowarn>[^/.]+)": response.dispatch,
|
||||||
"{0}/tags/(?P<resourcearn>[^/.]+)": response.dispatch,
|
"{0}/tags/(?P<resourcearn>[^/.]+)": response.dispatch,
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
|
import botocore
|
||||||
|
import pytest
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
from moto import mock_mediaconnect
|
from botocore.exceptions import ClientError
|
||||||
|
|
||||||
|
from moto import mock_mediaconnect
|
||||||
|
|
||||||
region = "eu-west-1"
|
region = "eu-west-1"
|
||||||
|
|
||||||
@ -153,3 +156,93 @@ def test_tag_resource_succeeds():
|
|||||||
list_response = client.list_tags_for_resource(ResourceArn="some-arn")
|
list_response = client.list_tags_for_resource(ResourceArn="some-arn")
|
||||||
list_response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
list_response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||||
list_response["Tags"].should.equal({"Tag1": "Value1"})
|
list_response["Tags"].should.equal({"Tag1": "Value1"})
|
||||||
|
|
||||||
|
|
||||||
|
@mock_mediaconnect
|
||||||
|
def test_add_flow_vpc_interfaces_succeeds():
|
||||||
|
client = boto3.client("mediaconnect", region_name=region)
|
||||||
|
channel_config = _create_flow_config("test Flow 1")
|
||||||
|
|
||||||
|
create_response = client.create_flow(**channel_config)
|
||||||
|
create_response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||||
|
create_response["Flow"]["Status"].should.equal("STANDBY")
|
||||||
|
flow_arn = create_response["Flow"]["FlowArn"]
|
||||||
|
|
||||||
|
client.add_flow_vpc_interfaces(
|
||||||
|
FlowArn=flow_arn,
|
||||||
|
VpcInterfaces=[
|
||||||
|
{
|
||||||
|
"Name": "VPCInterface",
|
||||||
|
"SubnetId": "",
|
||||||
|
"SecurityGroupIds": [],
|
||||||
|
"RoleArn": "",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
describe_response = client.describe_flow(FlowArn=flow_arn)
|
||||||
|
describe_response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||||
|
describe_response["Flow"]["VpcInterfaces"].should.equal(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"Name": "VPCInterface",
|
||||||
|
"RoleArn": "",
|
||||||
|
"SecurityGroupIds": [],
|
||||||
|
"SubnetId": "",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_mediaconnect
|
||||||
|
def test_add_flow_vpc_interfaces_fails():
|
||||||
|
client = boto3.client("mediaconnect", region_name=region)
|
||||||
|
flow_arn = "unknown-flow"
|
||||||
|
with pytest.raises(ClientError) as err:
|
||||||
|
client.add_flow_vpc_interfaces(
|
||||||
|
FlowArn=flow_arn, VpcInterfaces=[],
|
||||||
|
)
|
||||||
|
err = err.value.response["Error"]
|
||||||
|
err["Code"].should.equal("NotFoundException")
|
||||||
|
err["Message"].should.equal(
|
||||||
|
"flow with arn=unknown-flow not found".format(str(flow_arn))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_mediaconnect
|
||||||
|
def test_add_flow_outputs_succeeds():
|
||||||
|
client = boto3.client("mediaconnect", region_name=region)
|
||||||
|
channel_config = _create_flow_config("test Flow 1")
|
||||||
|
|
||||||
|
create_response = client.create_flow(**channel_config)
|
||||||
|
create_response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||||
|
create_response["Flow"]["Status"].should.equal("STANDBY")
|
||||||
|
flow_arn = create_response["Flow"]["FlowArn"]
|
||||||
|
|
||||||
|
client.add_flow_outputs(
|
||||||
|
FlowArn=flow_arn,
|
||||||
|
Outputs=[
|
||||||
|
{"Description": "string", "Name": "string", "Port": 123, "Protocol": "rist"}
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
describe_response = client.describe_flow(FlowArn=flow_arn)
|
||||||
|
describe_response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
|
||||||
|
describe_response["Flow"]["Outputs"].should.equal(
|
||||||
|
[{"Description": "string", "Name": "string", "Port": 123}]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_mediaconnect
|
||||||
|
def test_add_flow_outputs_fails():
|
||||||
|
client = boto3.client("mediaconnect", region_name=region)
|
||||||
|
flow_arn = "unknown-flow"
|
||||||
|
with pytest.raises(ClientError) as err:
|
||||||
|
client.add_flow_outputs(
|
||||||
|
FlowArn=flow_arn, Outputs=[],
|
||||||
|
)
|
||||||
|
err = err.value.response["Error"]
|
||||||
|
err["Code"].should.equal("NotFoundException")
|
||||||
|
err["Message"].should.equal(
|
||||||
|
"flow with arn=unknown-flow not found".format(str(flow_arn))
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user