1 /**
2 * Copyright (c) 2012-2017, s3auth.com
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met: 1) Redistributions of source code must retain the above
8 * copyright notice, this list of conditions and the following
9 * disclaimer. 2) Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution. 3) Neither the name of the s3auth.com nor
13 * the names of its contributors may be used to endorse or promote
14 * products derived from this software without specific prior written
15 * permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
19 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 package com.s3auth.hosts;
31
32 import com.amazonaws.services.cloudwatch.AmazonCloudWatchClient;
33 import com.jcabi.aspects.Immutable;
34 import java.io.Closeable;
35 import java.io.IOException;
36 import java.net.URI;
37
38 /**
39 * One host.
40 *
41 * @author Yegor Bugayenko (yegor@tpc2.com)
42 * @version $Id: a6bc38a0631081d95ea5f793e6ccd617418b6711 $
43 * @since 0.0.1
44 */
45 @Immutable
46 public interface Host extends Closeable {
47
48 /**
49 * Find resource and return its input stream.
50 * @param uri Name of resource
51 * @param range Range of data to return
52 * @param version The version of the data to return
53 * @return The stream
54 * @throws IOException If some error with I/O inside
55 */
56 Resource fetch(URI uri, Range range, Version version) throws IOException;
57
58 /**
59 * This URI require authentication?
60 * @param uri Which URI we're trying to access
61 * @return Yes or no
62 * @throws IOException If some error with I/O inside
63 */
64 boolean isHidden(URI uri) throws IOException;
65
66 /**
67 * Can this user login in with this credentials?
68 * @param user User name
69 * @param password Password
70 * @return Yes or no
71 * @throws IOException If some error with I/O inside
72 */
73 boolean authorized(String user, String password) throws IOException;
74
75 /**
76 * Get this resource's syslog host and port.
77 * @return Syslog host and port
78 */
79 String syslog();
80
81 /**
82 * Get the stats for this host's domain.
83 * @return Statistics for this domain
84 */
85 Stats stats();
86
87 /**
88 * Client to Amazon CloudWatch.
89 */
90 @Immutable
91 interface CloudWatch {
92 /**
93 * Get Amazon client.
94 * @return The client
95 */
96 AmazonCloudWatchClient get();
97 }
98
99 }