1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright 2017 LambdaStack All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

use aws::common::params::*;
use aws::s3::endpoint::*;

/// Enum of output format (JSON or XML)
#[derive(Debug, Clone, PartialEq, RustcDecodable, RustcEncodable)]
pub enum AdminOutputType {
    Json,
    Xml,
}

/// Admin request for Ceph RGW Admin
#[derive(Debug, Clone, Default)]
pub struct AdminRequest {
    /// Defaults to GET
    pub method: Option<String>,
    /// Specify the path using the default 'admin'. For example, admin/bucket etc.
    pub admin_path: Option<String>,
    /// Allows for speacial path option that does NOT have a value but only a key like
    /// ```admin/user?quota``` where you would admin/user in admin_path and quota in path_options.
    pub path_options: Option<String>,
    /// User's ID
    pub uid: Option<String>,
    /// Name of bucket
    pub bucket: Option<String>,
    /// Name of Object
    pub object: Option<String>,
    /// Parameters used in the query string
    pub params: Params,
    /// Endpoint that can override the default
    pub endpoint: Option<Endpoint>,
    /// Access key ID
    pub access_key: Option<String>,
    /// Secret key ID
    pub secret_key: Option<String>,
    /// Output format (JSON or XML). Default is JSON
    pub format: Option<AdminOutputType>,
}

/// Default output of all admin functions
#[derive(Debug, Clone, RustcDecodable, RustcEncodable)]
pub struct AdminOutput {
    /// Status code from the restful server
    pub code: u16,
    /// Payload of output
    pub payload: String,
    /// Output format (JSON or XML). Default is JSON
    pub format: AdminOutputType,
}

/// Ceph RGW Users
#[derive(Debug, Default, Clone, RustcDecodable, RustcEncodable)]
pub struct AdminUsers {
    /// Vec of users
    pub users: Vec<String>,
}

/// Ceph RGW Buckets
#[derive(Debug, Default, Clone, RustcDecodable, RustcEncodable)]
pub struct AdminBuckets {
    /// Vec of buckets
    pub buckets: Vec<String>,
}

/// Ceph RGW Usage
#[derive(Debug, Default, Clone, RustcDecodable, RustcEncodable)]
pub struct AdminUsage {
    /// Usage
    pub usage: String,
}

/// Ceph RGW Bucket Quota
#[derive(Debug, Clone, RustcDecodable, RustcEncodable)]
pub struct AdminQuota {
    /// Quota enabled
    pub enabled: bool,
    /// Default -1 which indicates no quota for bucket sizes
    pub max_size_kb: i64,
    /// Default -1 which indicates no quota for number of total objects
    pub max_objects: i64,
}

impl Default for AdminQuota {
    fn default() -> AdminQuota {
        AdminQuota{ enabled: false, max_size_kb: -1, max_objects: -1 }
    }
}

/// Ceph RGW Bucket Metadata
#[derive(Debug, Default, Clone, RustcDecodable, RustcEncodable)]
pub struct AdminBucketMetadata {
    pub bucket: String,
    pub pool: String,
    pub index_pool: String,
    pub id: String,
    pub marker: String,
    pub owner: String,
    pub ver: String,
    pub master_ver: String,
    pub mtime: String, // Could be time
    pub max_marker: String,
    pub usage: AdminUsage,
    pub bucket_quota: AdminQuota,
}