Add support for remove_flow_output and remove_flow_vpc_interface (#4058)
Co-authored-by: Alexandre Blanchet <alexandre.blanchet@m2amedia.tv>
This commit is contained in:
parent
00be464c05
commit
cf5007b97d
@ -6755,9 +6755,9 @@
|
|||||||
- [ ] list_reservations
|
- [ ] list_reservations
|
||||||
- [X] list_tags_for_resource
|
- [X] list_tags_for_resource
|
||||||
- [ ] purchase_offering
|
- [ ] purchase_offering
|
||||||
- [ ] remove_flow_output
|
- [X] remove_flow_output
|
||||||
- [ ] remove_flow_source
|
- [ ] remove_flow_source
|
||||||
- [ ] remove_flow_vpc_interface
|
- [X] remove_flow_vpc_interface
|
||||||
- [ ] revoke_flow_entitlement
|
- [ ] revoke_flow_entitlement
|
||||||
- [X] start_flow
|
- [X] start_flow
|
||||||
- [X] stop_flow
|
- [X] stop_flow
|
||||||
|
@ -205,6 +205,34 @@ class MediaConnectBackend(BaseBackend):
|
|||||||
)
|
)
|
||||||
return flow_arn, flow.outputs
|
return flow_arn, flow.outputs
|
||||||
|
|
||||||
|
def remove_flow_vpc_interface(self, flow_arn, vpc_interface_name):
|
||||||
|
if flow_arn in self._flows:
|
||||||
|
flow = self._flows[flow_arn]
|
||||||
|
flow.vpc_interfaces = [
|
||||||
|
vpc_interface
|
||||||
|
for vpc_interface in self._flows[flow_arn].vpc_interfaces
|
||||||
|
if vpc_interface["name"] != vpc_interface_name
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
raise NotFoundException(
|
||||||
|
message="flow with arn={} not found".format(flow_arn)
|
||||||
|
)
|
||||||
|
return flow_arn, vpc_interface_name
|
||||||
|
|
||||||
|
def remove_flow_output(self, flow_arn, output_name):
|
||||||
|
if flow_arn in self._flows:
|
||||||
|
flow = self._flows[flow_arn]
|
||||||
|
flow.outputs = [
|
||||||
|
output
|
||||||
|
for output in self._flows[flow_arn].outputs
|
||||||
|
if output["name"] != output_name
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
raise NotFoundException(
|
||||||
|
message="flow with arn={} not found".format(flow_arn)
|
||||||
|
)
|
||||||
|
return flow_arn, output_name
|
||||||
|
|
||||||
# add methods from here
|
# add methods from here
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,6 +90,19 @@ class MediaConnectResponse(BaseResponse):
|
|||||||
)
|
)
|
||||||
return json.dumps(dict(flow_arn=flow_arn, vpc_interfaces=vpc_interfaces))
|
return json.dumps(dict(flow_arn=flow_arn, vpc_interfaces=vpc_interfaces))
|
||||||
|
|
||||||
|
def remove_flow_vpc_interface(self):
|
||||||
|
flow_arn = unquote(self._get_param("flowArn"))
|
||||||
|
vpc_interface_name = unquote(self._get_param("vpcInterfaceName"))
|
||||||
|
(
|
||||||
|
flow_arn,
|
||||||
|
vpc_interface_name,
|
||||||
|
) = self.mediaconnect_backend.remove_flow_vpc_interface(
|
||||||
|
flow_arn=flow_arn, vpc_interface_name=vpc_interface_name
|
||||||
|
)
|
||||||
|
return json.dumps(
|
||||||
|
dict(flow_arn=flow_arn, vpc_interface_name=vpc_interface_name)
|
||||||
|
)
|
||||||
|
|
||||||
def add_flow_outputs(self):
|
def add_flow_outputs(self):
|
||||||
flow_arn = unquote(self._get_param("flowArn"))
|
flow_arn = unquote(self._get_param("flowArn"))
|
||||||
outputs = self._get_param("outputs")
|
outputs = self._get_param("outputs")
|
||||||
@ -98,4 +111,12 @@ class MediaConnectResponse(BaseResponse):
|
|||||||
)
|
)
|
||||||
return json.dumps(dict(flow_arn=flow_arn, outputs=outputs))
|
return json.dumps(dict(flow_arn=flow_arn, outputs=outputs))
|
||||||
|
|
||||||
|
def remove_flow_output(self):
|
||||||
|
flow_arn = unquote(self._get_param("flowArn"))
|
||||||
|
output_name = unquote(self._get_param("outputArn"))
|
||||||
|
flow_arn, output_name = self.mediaconnect_backend.remove_flow_output(
|
||||||
|
flow_arn=flow_arn, output_name=output_name
|
||||||
|
)
|
||||||
|
return json.dumps(dict(flow_arn=flow_arn, output_name=output_name))
|
||||||
|
|
||||||
# add methods from here
|
# add methods from here
|
||||||
|
@ -13,7 +13,9 @@ 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>[^/.]+)/vpcInterfaces": response.dispatch,
|
||||||
|
"{0}/v1/flows/(?P<flowarn>[^/.]+)/vpcInterfaces/(?P<vpcinterfacename>[^/.]+)": response.dispatch,
|
||||||
"{0}/v1/flows/(?P<flowarn>[^/.]+)/outputs": response.dispatch,
|
"{0}/v1/flows/(?P<flowarn>[^/.]+)/outputs": response.dispatch,
|
||||||
|
"{0}/v1/flows/(?P<flowarn>[^/.]+)/outputs/(?P<outputarn>[^/.]+)": 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,7 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
import botocore
|
|
||||||
import pytest
|
import pytest
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
@ -209,6 +208,53 @@ def test_add_flow_vpc_interfaces_fails():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_mediaconnect
|
||||||
|
def test_remove_flow_vpc_interface_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)
|
||||||
|
len(describe_response["Flow"]["VpcInterfaces"]).should.equal(1)
|
||||||
|
|
||||||
|
client.remove_flow_vpc_interface(FlowArn=flow_arn, VpcInterfaceName="VPCInterface")
|
||||||
|
|
||||||
|
describe_response = client.describe_flow(FlowArn=flow_arn)
|
||||||
|
len(describe_response["Flow"]["VpcInterfaces"]).should.equal(0)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_mediaconnect
|
||||||
|
def test_remove_flow_vpc_interface_fails():
|
||||||
|
client = boto3.client("mediaconnect", region_name=region)
|
||||||
|
flow_arn = "unknown-flow"
|
||||||
|
with pytest.raises(ClientError) as err:
|
||||||
|
client.remove_flow_vpc_interface(
|
||||||
|
FlowArn=flow_arn, VpcInterfaceName="VPCInterface"
|
||||||
|
)
|
||||||
|
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
|
@mock_mediaconnect
|
||||||
def test_add_flow_outputs_succeeds():
|
def test_add_flow_outputs_succeeds():
|
||||||
client = boto3.client("mediaconnect", region_name=region)
|
client = boto3.client("mediaconnect", region_name=region)
|
||||||
@ -246,3 +292,46 @@ def test_add_flow_outputs_fails():
|
|||||||
err["Message"].should.equal(
|
err["Message"].should.equal(
|
||||||
"flow with arn=unknown-flow not found".format(str(flow_arn))
|
"flow with arn=unknown-flow not found".format(str(flow_arn))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_mediaconnect
|
||||||
|
def test_remove_flow_output_fails():
|
||||||
|
client = boto3.client("mediaconnect", region_name=region)
|
||||||
|
flow_arn = "unknown-flow"
|
||||||
|
output_arn = "unknown-arn"
|
||||||
|
with pytest.raises(ClientError) as err:
|
||||||
|
client.remove_flow_output(
|
||||||
|
FlowArn=flow_arn, OutputArn=output_arn,
|
||||||
|
)
|
||||||
|
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_remove_flow_output_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)
|
||||||
|
len(describe_response["Flow"]["Outputs"]).should.equal(1)
|
||||||
|
|
||||||
|
client.remove_flow_output(FlowArn=flow_arn, OutputArn="string")
|
||||||
|
|
||||||
|
describe_response = client.describe_flow(FlowArn=flow_arn)
|
||||||
|
len(describe_response["Flow"]["Outputs"]).should.equal(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user