Commit ba31b678 authored by Eric Dieckman's avatar Eric Dieckman
Browse files

feat: add delete VLAN endpoints for firewall and vsys

parent bd3ca496
Loading
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -102,4 +102,24 @@ public class PaloAltoFirewallVsysesController : ControllerBase

        return CreatedAtRoute("GetPaloAltoFirewallVlanById", new { firewallVlanId = vlan.FirewallVlanId }, vlan);
    }

    // DELETE: /palo_alto/firewalls/vsyses/{firewallId}/vsyses/{vsysId}/vlans/{firewallVlanId}
    [Authorize(Policy = Policies.CanEdit)]
    [ProducesResponseType(StatusCodes.Status204NoContent)]
    [ProducesResponseType(StatusCodes.Status404NotFound)]
    [HttpDelete("{firewallId:long}/vsyses/{vsysId:long}/vlans/{firewallVlanId:long}", Name = "RemoveVlanFromPaloAltoVsys")]
    public async Task<IActionResult> RemoveVlanFromVsysAsync(long firewallId, long vsysId, long firewallVlanId)
    {
        PaloAltoFirewallVlan? entity = await _context.PaloAltoFirewallVlans
            .Where(e => e.FirewallId == firewallId && e.VsysId == vsysId && e.FirewallVlanId == firewallVlanId)
            .FirstOrDefaultAsync();

        if (entity == null)
            return NotFound();

        _context.PaloAltoFirewallVlans.Remove(entity);
        await _context.SaveChangesAsync();

        return NoContent();
    }
}
+20 −0
Original line number Diff line number Diff line
@@ -101,4 +101,24 @@ public class PaloAltoFirewallsController : ControllerBase

        return CreatedAtRoute("GetPaloAltoFirewallVlanById", new { firewallVlanId = vlan.FirewallVlanId }, vlan);
    }

    // DELETE: /palo_alto/firewalls/2/vlans/5
    [Authorize(Policy = Policies.CanEdit)]
    [ProducesResponseType(StatusCodes.Status204NoContent)]
    [ProducesResponseType(StatusCodes.Status404NotFound)]
    [HttpDelete("{firewallId:long}/vlans/{firewallVlanId:long}", Name = "RemoveVlanFromPaloAltoFirewall")]
    public async Task<IActionResult> RemoveVlanFromFirewallAsync(long firewallId, long firewallVlanId)
    {
        PaloAltoFirewallVlan? entity = await _context.PaloAltoFirewallVlans
            .Where(e => e.FirewallId == firewallId && e.FirewallVlanId == firewallVlanId && e.VsysId == null)
            .FirstOrDefaultAsync();

        if (entity == null)
            return NotFound();

        _context.PaloAltoFirewallVlans.Remove(entity);
        await _context.SaveChangesAsync();

        return NoContent();
    }
}