Sha256: d3b7ba19e8cd2b4d31f8d15fcaffd5f2900c0edad6eac0c0e35de39c13ac636c

Contents?: true

Size: 1.97 KB

Versions: 12

Compression:

Stored size: 1.97 KB

Contents

/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
 *     Copyright 2020 Couchbase, Inc.
 *
 *   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.
 */

#pragma once

#include <tao/json.hpp>

namespace couchbase::operations
{

struct bucket_drop_response {
    std::error_code ec;
};

struct bucket_drop_request {
    using response_type = bucket_drop_response;
    using encoded_request_type = io::http_request;
    using encoded_response_type = io::http_response;

    static const inline service_type type = service_type::management;

    std::string name;
    std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };

    void encode_to(encoded_request_type& encoded)
    {
        encoded.method = "DELETE";
        encoded.path = fmt::format("/pools/default/buckets/{}", name);
    }
};

bucket_drop_response
make_response(std::error_code ec, bucket_drop_request&, bucket_drop_request::encoded_response_type encoded)
{
    bucket_drop_response response{ ec };
    if (!ec) {
        switch (encoded.status_code) {
            case 404:
                response.ec = std::make_error_code(error::common_errc::bucket_not_found);
                break;
            case 200:
                response.ec = {};
                break;
            default:
                response.ec = std::make_error_code(error::common_errc::internal_server_failure);
                break;
        }
    }
    return response;
}

} // namespace couchbase::operations

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
couchbase-3.0.0.alpha.5-x86_64-linux ext/couchbase/operations/bucket_drop.hxx
couchbase-3.0.0.alpha.5-universal-darwin-19 ext/couchbase/operations/bucket_drop.hxx
couchbase-3.0.0.alpha.5-x86_64-darwin-19 ext/couchbase/operations/bucket_drop.hxx
couchbase-3.0.0.alpha.5 ext/couchbase/operations/bucket_drop.hxx
couchbase-3.0.0.alpha.4-x86_64-linux ext/couchbase/operations/bucket_drop.hxx
couchbase-3.0.0.alpha.4-x86_64-darwin-19 ext/couchbase/operations/bucket_drop.hxx
couchbase-3.0.0.alpha.4-universal-darwin-19 ext/couchbase/operations/bucket_drop.hxx
couchbase-3.0.0.alpha.4 ext/couchbase/operations/bucket_drop.hxx
couchbase-3.0.0.alpha.3-x86_64-linux ext/couchbase/operations/bucket_drop.hxx
couchbase-3.0.0.alpha.3-x86_64-darwin-19 ext/couchbase/operations/bucket_drop.hxx
couchbase-3.0.0.alpha.3-universal-darwin-19 ext/couchbase/operations/bucket_drop.hxx
couchbase-3.0.0.alpha.3 ext/couchbase/operations/bucket_drop.hxx