Commit edb53ffc authored by Brandon Dunn's avatar Brandon Dunn
Browse files

working on add host

parent a92d10e7
......@@ -153,8 +153,7 @@ export interface Hosts{
adapter_name: any,
mac: any,
ipv4: any,
ipv6: any,
subnet: any
ipv6: any
}
export interface Records{
......
......@@ -35,7 +35,6 @@ export class SampleService {
mac: '00:40:96:12:ab:23',
ipv4: '192.168.0.1',
ipv6: null,
subnet: 'ECE'
}
......@@ -50,7 +49,7 @@ export class SampleService {
AddHost(addInformation: AddHostInformation): void{
this.endpoint = 'api/AddHost'
this.http.put(this.HostLocation + this.endpoint, addInformation, this.httpOptions)
this.http.post(this.HostLocation + this.endpoint, addInformation, this.httpOptions)
}
RemoveHost(Host_Name: string): void{
......
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"django": true
}
]
}
\ No newline at end of file
......@@ -65,4 +65,4 @@ class IP(models.Model):
if self.ipv4 is not None:
return self.ipv4
if self.ipv6 is not None:
return ipv6
\ No newline at end of file
return self.ipv6
\ No newline at end of file
......@@ -7,7 +7,7 @@ class RecordSerializer(serializers.ModelSerializer):
class Meta:
model = Record
fields = '__all__'
depth=2
depth=1
class HostSerializer(serializers.ModelSerializer):
adapter = serializers.PrimaryKeyRelatedField(many=False, read_only=True)
......
......@@ -32,9 +32,31 @@ class IPRangeViewset(viewsets.ModelViewSet):
serializer = self.get_serializer(queryset, many=True)
return Response(serializer.data)
class AddRecordViewset(viewsets.ModelViewSet):
queryset = Record.objects.all()
serializer_class = RecordSerializer
def add_host(request):
if request.method =='POST':
record = request.POST.get('record_type')
record_serializer = RecordSerializer(data=record)
record_serializer.save()
host = request.POST.get('host_name')
host_serializer = HostSerializer(data=host)
host_serializer.save()
return Response(serializer.data)
class AddHostViewset(viewsets.ModelViewSet):
queryset = Host.objects.all()
serializer_class = RecordSerializer
serializer_class = HostSerializer
def add_host(request):
if request.method =='POST':
host = request.POST.get('host_name')
record_id = request.POST.get('id')
new_host = Host(host_name=host, record=record_id)
new_host.save()
return Response(serializer.data)
class AddPreambleViewset(viewsets.ModelViewSet):
queryset = Preamble.objects.all()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment