blob: 7e07264a65bdf3fcb76e8aafda29c191cf7b7b08 [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.castsetup;
/// Specifies the required security for a client of the API.
type SecurityState = strict enum : uint32 {
SECURITY_STATE_NONE = 0;
SECURITY_STATE_ENCRYPTED = 1;
SECURITY_STATE_TRUSTED = 2;
};
/// Registered API that handles an incoming request.
closed protocol ApiRequestHandler {
/// Called to handle a request to this setup API. The request `data` is JSON.
/// The response `data` must be JSON.
strict HandleRequest(struct {
data string:<MAX, optional>;
}) -> (struct {
response_code uint32;
data string:<MAX, optional>;
});
};
/// API operation mode to specify during registration.
type ApiMode = strict enum : uint32 {
ACCEPTS_NO_DATA = 1;
ACCEPTS_DATA = 2;
};
/// Registry that hosts APIs on behalf of clients.
@discoverable
closed protocol ApiRegistry {
/// Registers an API that may accept incoming data.
///
/// `path` identifies how to access the API. If multiple registrations occur with
/// the same path, then the last registration is bound, and the rest are unbound.
///
/// `accepts_data` indicates whether this API should allow callers to provide
/// data in the form of a JSON string.
///
/// `security_state` indicates what level of security the caller must
/// adhere to.
strict RegisterApi(resource struct {
path string:1024;
api_mode ApiMode;
security_state SecurityState;
api_handler client_end:ApiRequestHandler;
});
};