View Javadoc
1   /*
2    * Copyright 2019 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.bremersee.dccon.service;
18  
19  import java.util.List;
20  import java.util.Optional;
21  import javax.validation.Valid;
22  import javax.validation.constraints.NotNull;
23  import org.bremersee.dccon.model.DhcpLease;
24  import org.bremersee.dccon.model.DnsNode;
25  import org.bremersee.dccon.model.DnsZone;
26  import org.bremersee.dccon.model.UnknownFilter;
27  import org.springframework.lang.Nullable;
28  import org.springframework.validation.annotation.Validated;
29  
30  /**
31   * The name server service.
32   *
33   * @author Christian Bremer
34   */
35  @Validated
36  public interface NameServerService {
37  
38    /**
39     * Query dns nodes.
40     *
41     * @param query the query, can be a host name, an IP or a MAC address
42     * @param unknownFilter the unknown filter (default is {@link UnknownFilter#NO_UNKNOWN}
43     * @return found dns nodes
44     */
45    List<DnsNode> query(@NotNull String query, @Nullable UnknownFilter unknownFilter);
46  
47    /**
48     * Get dhcp leases.
49     *
50     * @param all if {@code true}, expired leases will also be returned, otherwise only active
51     *     ones (default is {@code false})
52     * @param sort the sort order (default is {@link DhcpLease#SORT_ORDER_BEGIN_HOSTNAME})
53     * @return the dhcp leases
54     */
55    List<DhcpLease> getDhcpLeases(@Nullable Boolean all, @Nullable String sort);
56  
57    /**
58     * Get dns zones.
59     *
60     * @return the dns zones
61     */
62    List<DnsZone> getDnsZones();
63  
64    /**
65     * Add dns zone.
66     *
67     * @param dnsZone the dns zone
68     * @return the added dns zone
69     */
70    DnsZone addDnsZone(@NotNull @Valid DnsZone dnsZone);
71  
72    /**
73     * Delete dns zone.
74     *
75     * @param zoneName the zone name
76     * @return {@code true} if the dns zone was removed; {@code false} if the dns zone didn't exist
77     */
78    Boolean deleteDnsZone(@NotNull String zoneName);
79  
80  
81    /**
82     * Gets dns nodes.
83     *
84     * @param zoneName the zone name
85     * @param unknownFilter the unknown filter (default is {@link UnknownFilter#NO_UNKNOWN}
86     * @param query the query
87     * @return the dns nodes
88     */
89    List<DnsNode> getDnsNodes(
90        @NotNull String zoneName,
91        @Nullable UnknownFilter unknownFilter,
92        @Nullable String query);
93  
94    /**
95     * Save dns node.
96     *
97     * @param zoneName the zone name
98     * @param dnsNode the dns node
99     * @return the dns node
100    */
101   Optional<DnsNode> save(
102       @NotNull String zoneName,
103       @NotNull @Valid DnsNode dnsNode);
104 
105   /**
106    * Get dns node.
107    *
108    * @param zoneName the zone name
109    * @param nodeName the node name
110    * @param unknownFilter the unknown filter (default is {@link UnknownFilter#NO_UNKNOWN}
111    * @return the dns node
112    */
113   Optional<DnsNode> getDnsNode(
114       @NotNull String zoneName,
115       @NotNull String nodeName,
116       @Nullable UnknownFilter unknownFilter);
117 
118   /**
119    * Delete dns node.
120    *
121    * @param zoneName the zone name
122    * @param nodeName the node name
123    * @return {@code true} if the dns node was removed; {@code false} if dns node didn't exist
124    */
125   Boolean deleteDnsNode(
126       @NotNull String zoneName,
127       @NotNull String nodeName);
128 
129   /**
130    * Delete all dns nodes.
131    *
132    * @param zoneName the zone name
133    */
134   @SuppressWarnings("unused")
135   void deleteAllDnsNodes(
136       @NotNull String zoneName);
137 
138   /**
139    * Delete all dns nodes.
140    *
141    * @param zoneName the zone name
142    * @param nodeNames the node names
143    */
144   void deleteAllDnsNodes(
145       @NotNull String zoneName,
146       @Nullable List<String> nodeNames);
147 
148 }