コード例 #1
0
        public async Task <NetworkSecurityGroup> RegisterAsync(RegisterNetworkSecurityGroupRequest request)
        {
            Ensure.Object(request, nameof(request)); // Validate the request

            var id = await db.NetworkSecurityGroups.GetNextScopedIdAsync(request.NetworkId);

            var nsg = new NetworkSecurityGroup(
                id: id,
                name: request.Name,
                resource: request.Resource
                );

            await db.NetworkSecurityGroups.InsertAsync(nsg);

            return(nsg);
        }
コード例 #2
0
        public async Task <NetworkSecurityGroup> GetAsync(
            NetworkInfo network,
            NetworkInterfaceSecurityGroup networkSecurityGroup)
        {
            Ensure.NotNull(network, nameof(network));
            Ensure.NotNull(networkSecurityGroup, nameof(networkSecurityGroup));

            var region = Locations.Get(network.LocationId);

            var nsg = await nsgService.FindAsync(ResourceProvider.Aws, networkSecurityGroup.GroupId);;

            if (nsg == null)
            {
                var registerRequest = new RegisterNetworkSecurityGroupRequest(
                    name: networkSecurityGroup.GroupName,
                    networkId: network.Id,
                    resource: ManagedResource.NetworkSecurityGroup(region, networkSecurityGroup.GroupId)
                    );

                nsg = await nsgService.RegisterAsync(registerRequest);;
            }

            return(nsg);
        }