Issues (5)

src/Ipam/IpAddress.php (1 issue)

1
<?php
2
3
namespace CmdrSharp\NetBox\Ipam;
4
5
use CmdrSharp\NetBox\NetBox;
6
use CmdrSharp\NetBox\Tenancy\Tenant;
7
use CmdrSharp\NetBox\Traits\HandlesNetBoxResults;
8
use Psr\Http\Message\ResponseInterface;
9
10
class IpAddress extends NetBox
11
{
12
    use HandlesNetBoxResults;
0 ignored issues
show
The trait CmdrSharp\NetBox\Traits\HandlesNetBoxResults requires some properties which are not provided by CmdrSharp\NetBox\Ipam\IpAddress: $count, $results, $id
Loading history...
13
14
    /** @var string */
15
    const API_PATH = parent::API_PATH . 'ipam/ip-addresses/';
16
17
    /** @var array|string[] */
18
    protected array $fillable = [
19
        'address',
20
        'vrf',
21
        'tenant',
22
        'status',
23
        'role',
24
        'assigned_object_type',
25
        'assigned_object_id',
26
        'nat_inside',
27
        'nat_outside',
28
        'dns_name',
29
        'description',
30
    ];
31
32
    /**
33
     * @param string $ipAddress
34
     * @return ResponseInterface
35
     */
36
    public static function whereAddress(string $ipAddress): ResponseInterface
37
    {
38
        return parent::where("?address={$ipAddress}");
39
    }
40
41
    /**
42
     * @param string $ipAddress
43
     * @return $this
44
     */
45
    public function setAddress(string $ipAddress): IpAddress
46
    {
47
        $this->setAttribute('address', $ipAddress);
48
49
        return $this;
50
    }
51
52
    /**
53
     * @param int $vrf
54
     * @return $this
55
     */
56
    public function setVrf(int $vrf): IpAddress
57
    {
58
        $this->setAttribute('vrf', $vrf);
59
60
        return $this;
61
    }
62
63
    /**
64
     * @param int $tenant
65
     * @return $this
66
     */
67
    public function setTenant(int $tenant): IpAddress
68
    {
69
        $this->setAttribute('tenant', $tenant);
70
71
        return $this;
72
    }
73
74
    /**
75
     * @param string $tenant
76
     * @return $this
77
     */
78
    public function setTenantByName(string $tenant): IpAddress
79
    {
80
        $tenantQuery = Tenant::whereName($tenant);
81
        $tenant = $this->getOnlyResult($tenantQuery);
82
83
        $this->setAttribute('tenant', $tenant->id);
84
85
        return $this;
86
    }
87
88
    /**
89
     * @param string $status
90
     * @return $this
91
     */
92
    public function setStatus(string $status): IpAddress
93
    {
94
        $this->setAttribute('status', $status);
95
96
        return $this;
97
    }
98
99
    /**
100
     * @param int $role
101
     * @return $this
102
     */
103
    public function setRole(int $role): IpAddress
104
    {
105
        $this->setAttribute('role', $role);
106
107
        return $this;
108
    }
109
110
    /**
111
     * @param string $assignedObjectType
112
     * @return $this
113
     */
114
    public function setAssignedObjectType(string $assignedObjectType): IpAddress
115
    {
116
        $this->setAttribute('assigned_object_type', $assignedObjectType);
117
118
        return $this;
119
    }
120
121
    /**
122
     * @param int $assignedObjectId
123
     * @return $this
124
     */
125
    public function setAssignedObjectId(int $assignedObjectId): IpAddress
126
    {
127
        $this->setAttribute('assigned_object_id', $assignedObjectId);
128
129
        return $this;
130
    }
131
132
    /**
133
     * @param int $natInside
134
     * @return $this
135
     */
136
    public function setNatInside(int $natInside): IpAddress
137
    {
138
        $this->setAttribute('nat_inside', $natInside);
139
140
        return $this;
141
    }
142
143
    /**
144
     * @param int $natOutside
145
     * @return $this
146
     */
147
    public function setNatOutside(int $natOutside): IpAddress
148
    {
149
        $this->setAttribute('nat_outside', $natOutside);
150
151
        return $this;
152
    }
153
154
    /**
155
     * @param string $dnsName
156
     * @return $this
157
     */
158
    public function setDnsName(string $dnsName): IpAddress
159
    {
160
        $this->setAttribute('dns_name', $dnsName);
161
162
        return $this;
163
    }
164
165
    /**
166
     * @param string $description
167
     * @return $this
168
     */
169
    public function setDescription(string $description): IpAddress
170
    {
171
        $this->setAttribute('description', $description);
172
173
        return $this;
174
    }
175
}
176