blob: 2cdfc844d8effe990a7c6382cde16e7ca0b45c3e [file] [log] [blame]
// This is a generated file (see the discoveryapis_generator project).
// ignore_for_file: camel_case_types
// ignore_for_file: comment_references
// ignore_for_file: file_names
// ignore_for_file: library_names
// ignore_for_file: lines_longer_than_80_chars
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: prefer_expression_function_bodies
// ignore_for_file: prefer_final_locals
// ignore_for_file: prefer_interpolation_to_compose_strings
// ignore_for_file: unnecessary_brace_in_string_interps
// ignore_for_file: unnecessary_cast
// ignore_for_file: unnecessary_lambdas
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: unnecessary_string_interpolations
/// Firebase ML API - v1beta2
///
/// Access custom machine learning models hosted via Firebase ML.
///
/// For more information, see <https://firebase.google.com>
library firebaseml.v1beta2;
import 'dart:async' as async;
import 'dart:convert' as convert;
import 'dart:core' as core;
import 'package:_discoveryapis_commons/_discoveryapis_commons.dart' as commons;
import 'package:http/http.dart' as http;
import '../src/user_agent.dart';
export 'package:_discoveryapis_commons/_discoveryapis_commons.dart'
show ApiRequestError, DetailedApiRequestError;
/// Access custom machine learning models hosted via Firebase ML.
class FirebasemlApi {
/// View and manage your data across Google Cloud Platform services
static const cloudPlatformScope =
'https://www.googleapis.com/auth/cloud-platform';
final commons.ApiRequester _requester;
ProjectsResourceApi get projects => ProjectsResourceApi(_requester);
FirebasemlApi(http.Client client,
{core.String rootUrl = 'https://firebaseml.googleapis.com/',
core.String servicePath = ''})
: _requester =
commons.ApiRequester(client, rootUrl, servicePath, userAgent);
}
class ProjectsResourceApi {
final commons.ApiRequester _requester;
ProjectsModelsResourceApi get models => ProjectsModelsResourceApi(_requester);
ProjectsOperationsResourceApi get operations =>
ProjectsOperationsResourceApi(_requester);
ProjectsResourceApi(commons.ApiRequester client) : _requester = client;
}
class ProjectsModelsResourceApi {
final commons.ApiRequester _requester;
ProjectsModelsResourceApi(commons.ApiRequester client) : _requester = client;
/// Creates a model in Firebase ML. The longrunning operation will eventually
/// return a Model
///
/// [request] - The metadata request object.
///
/// Request parameters:
///
/// [parent] - Required. The parent project resource where the model is to be
/// created. The parent must have the form `projects/{project_id}`
/// Value must have pattern "^projects/[^/]+$".
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Operation].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Operation> create(
Model request,
core.String parent, {
core.String $fields,
}) {
core.String _url;
final _queryParams = <core.String, core.List<core.String>>{};
commons.Media _uploadMedia;
commons.UploadOptions _uploadOptions;
var _downloadOptions = commons.DownloadOptions.Metadata;
core.String _body;
if (request != null) {
_body = convert.json.encode(request.toJson());
}
if (parent == null) {
throw core.ArgumentError('Parameter parent is required.');
}
if ($fields != null) {
_queryParams['fields'] = [$fields];
}
_url = 'v1beta2/' +
commons.Escaper.ecapeVariableReserved('$parent') +
'/models';
final _response = _requester.request(
_url,
'POST',
body: _body,
queryParams: _queryParams,
uploadOptions: _uploadOptions,
uploadMedia: _uploadMedia,
downloadOptions: _downloadOptions,
);
return _response.then(
(data) => Operation.fromJson(data as core.Map<core.String, core.dynamic>),
);
}
/// Deletes a model
///
/// Request parameters:
///
/// [name] - Required. The name of the model to delete. The name must have the
/// form `projects/{project_id}/models/{model_id}`
/// Value must have pattern "^projects/[^/]+/models/[^/]+$".
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Empty].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Empty> delete(
core.String name, {
core.String $fields,
}) {
core.String _url;
final _queryParams = <core.String, core.List<core.String>>{};
commons.Media _uploadMedia;
commons.UploadOptions _uploadOptions;
var _downloadOptions = commons.DownloadOptions.Metadata;
core.String _body;
if (name == null) {
throw core.ArgumentError('Parameter name is required.');
}
if ($fields != null) {
_queryParams['fields'] = [$fields];
}
_url = 'v1beta2/' + commons.Escaper.ecapeVariableReserved('$name');
final _response = _requester.request(
_url,
'DELETE',
body: _body,
queryParams: _queryParams,
uploadOptions: _uploadOptions,
uploadMedia: _uploadMedia,
downloadOptions: _downloadOptions,
);
return _response.then(
(data) => Empty.fromJson(data as core.Map<core.String, core.dynamic>),
);
}
/// Gets a model resource.
///
/// Request parameters:
///
/// [name] - Required. The name of the model to get. The name must have the
/// form `projects/{project_id}/models/{model_id}`
/// Value must have pattern "^projects/[^/]+/models/[^/]+$".
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Model].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Model> get(
core.String name, {
core.String $fields,
}) {
core.String _url;
final _queryParams = <core.String, core.List<core.String>>{};
commons.Media _uploadMedia;
commons.UploadOptions _uploadOptions;
var _downloadOptions = commons.DownloadOptions.Metadata;
core.String _body;
if (name == null) {
throw core.ArgumentError('Parameter name is required.');
}
if ($fields != null) {
_queryParams['fields'] = [$fields];
}
_url = 'v1beta2/' + commons.Escaper.ecapeVariableReserved('$name');
final _response = _requester.request(
_url,
'GET',
body: _body,
queryParams: _queryParams,
uploadOptions: _uploadOptions,
uploadMedia: _uploadMedia,
downloadOptions: _downloadOptions,
);
return _response.then(
(data) => Model.fromJson(data as core.Map<core.String, core.dynamic>),
);
}
/// Lists the models
///
/// Request parameters:
///
/// [parent] - Required. The name of the parent to list models for. The parent
/// must have the form `projects/{project_id}'
/// Value must have pattern "^projects/[^/]+$".
///
/// [filter] - A filter for the list e.g. 'tags: abc' to list models which are
/// tagged with "abc"
///
/// [pageSize] - The maximum number of items to return
///
/// [pageToken] - The next_page_token value returned from a previous List
/// request, if any.
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [ListModelsResponse].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<ListModelsResponse> list(
core.String parent, {
core.String filter,
core.int pageSize,
core.String pageToken,
core.String $fields,
}) {
core.String _url;
final _queryParams = <core.String, core.List<core.String>>{};
commons.Media _uploadMedia;
commons.UploadOptions _uploadOptions;
var _downloadOptions = commons.DownloadOptions.Metadata;
core.String _body;
if (parent == null) {
throw core.ArgumentError('Parameter parent is required.');
}
if (filter != null) {
_queryParams['filter'] = [filter];
}
if (pageSize != null) {
_queryParams['pageSize'] = ['${pageSize}'];
}
if (pageToken != null) {
_queryParams['pageToken'] = [pageToken];
}
if ($fields != null) {
_queryParams['fields'] = [$fields];
}
_url = 'v1beta2/' +
commons.Escaper.ecapeVariableReserved('$parent') +
'/models';
final _response = _requester.request(
_url,
'GET',
body: _body,
queryParams: _queryParams,
uploadOptions: _uploadOptions,
uploadMedia: _uploadMedia,
downloadOptions: _downloadOptions,
);
return _response.then(
(data) => ListModelsResponse.fromJson(
data as core.Map<core.String, core.dynamic>),
);
}
/// Updates a model. The longrunning operation will eventually return a Model.
///
/// [request] - The metadata request object.
///
/// Request parameters:
///
/// [name] - The resource name of the Model. Model names have the form
/// `projects/{project_id}/models/{model_id}` The name is ignored when
/// creating a model.
/// Value must have pattern "^projects/[^/]+/models/[^/]+$".
///
/// [updateMask] - The update mask
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Operation].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Operation> patch(
Model request,
core.String name, {
core.String updateMask,
core.String $fields,
}) {
core.String _url;
final _queryParams = <core.String, core.List<core.String>>{};
commons.Media _uploadMedia;
commons.UploadOptions _uploadOptions;
var _downloadOptions = commons.DownloadOptions.Metadata;
core.String _body;
if (request != null) {
_body = convert.json.encode(request.toJson());
}
if (name == null) {
throw core.ArgumentError('Parameter name is required.');
}
if (updateMask != null) {
_queryParams['updateMask'] = [updateMask];
}
if ($fields != null) {
_queryParams['fields'] = [$fields];
}
_url = 'v1beta2/' + commons.Escaper.ecapeVariableReserved('$name');
final _response = _requester.request(
_url,
'PATCH',
body: _body,
queryParams: _queryParams,
uploadOptions: _uploadOptions,
uploadMedia: _uploadMedia,
downloadOptions: _downloadOptions,
);
return _response.then(
(data) => Operation.fromJson(data as core.Map<core.String, core.dynamic>),
);
}
}
class ProjectsOperationsResourceApi {
final commons.ApiRequester _requester;
ProjectsOperationsResourceApi(commons.ApiRequester client)
: _requester = client;
/// Gets the latest state of a long-running operation. Clients can use this
/// method to poll the operation result at intervals as recommended by the API
/// service.
///
/// Request parameters:
///
/// [name] - The name of the operation resource.
/// Value must have pattern "^projects/[^/]+/operations/[^/]+$".
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Operation].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Operation> get(
core.String name, {
core.String $fields,
}) {
core.String _url;
final _queryParams = <core.String, core.List<core.String>>{};
commons.Media _uploadMedia;
commons.UploadOptions _uploadOptions;
var _downloadOptions = commons.DownloadOptions.Metadata;
core.String _body;
if (name == null) {
throw core.ArgumentError('Parameter name is required.');
}
if ($fields != null) {
_queryParams['fields'] = [$fields];
}
_url = 'v1beta2/' + commons.Escaper.ecapeVariableReserved('$name');
final _response = _requester.request(
_url,
'GET',
body: _body,
queryParams: _queryParams,
uploadOptions: _uploadOptions,
uploadMedia: _uploadMedia,
downloadOptions: _downloadOptions,
);
return _response.then(
(data) => Operation.fromJson(data as core.Map<core.String, core.dynamic>),
);
}
}
/// A generic empty message that you can re-use to avoid defining duplicated
/// empty messages in your APIs. A typical example is to use it as the request
/// or the response type of an API method. For instance: service Foo { rpc
/// Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } The JSON
/// representation for `Empty` is empty JSON object `{}`.
class Empty {
Empty();
Empty.fromJson(
// ignore: avoid_unused_constructor_parameters
core.Map _json);
core.Map<core.String, core.Object> toJson() {
final _json = <core.String, core.Object>{};
return _json;
}
}
/// The response for list models
class ListModelsResponse {
/// The list of models
core.List<Model> models;
/// Token to retrieve the next page of results, or empty if there are no more
/// results in the list.
core.String nextPageToken;
ListModelsResponse();
ListModelsResponse.fromJson(core.Map _json) {
if (_json.containsKey('models')) {
models = (_json['models'] as core.List)
.map<Model>((value) =>
Model.fromJson(value as core.Map<core.String, core.dynamic>))
.toList();
}
if (_json.containsKey('nextPageToken')) {
nextPageToken = _json['nextPageToken'] as core.String;
}
}
core.Map<core.String, core.Object> toJson() {
final _json = <core.String, core.Object>{};
if (models != null) {
_json['models'] = models.map((value) => value.toJson()).toList();
}
if (nextPageToken != null) {
_json['nextPageToken'] = nextPageToken;
}
return _json;
}
}
/// An ML model hosted in Firebase ML
class Model {
/// Output only. Lists operation ids associated with this model whose status
/// is NOT done.
core.List<Operation> activeOperations;
/// Output only. Timestamp when this model was created in Firebase ML.
core.String createTime;
/// Required. The name of the model to create. The name can be up to 32
/// characters long and can consist only of ASCII Latin letters A-Z and a-z,
/// underscores(_) and ASCII digits 0-9. It must start with a letter.
core.String displayName;
/// Output only. See RFC7232 https://tools.ietf.org/html/rfc7232#section-2.3
core.String etag;
/// Output only. The model_hash will change if a new file is available for
/// download.
core.String modelHash;
/// The resource name of the Model. Model names have the form
/// `projects/{project_id}/models/{model_id}` The name is ignored when
/// creating a model.
core.String name;
/// State common to all model types. Includes publishing and validation
/// information.
ModelState state;
/// User defined tags which can be used to group/filter models during listing
core.List<core.String> tags;
/// A TFLite Model
TfLiteModel tfliteModel;
/// Output only. Timestamp when this model was updated in Firebase ML.
core.String updateTime;
Model();
Model.fromJson(core.Map _json) {
if (_json.containsKey('activeOperations')) {
activeOperations = (_json['activeOperations'] as core.List)
.map<Operation>((value) =>
Operation.fromJson(value as core.Map<core.String, core.dynamic>))
.toList();
}
if (_json.containsKey('createTime')) {
createTime = _json['createTime'] as core.String;
}
if (_json.containsKey('displayName')) {
displayName = _json['displayName'] as core.String;
}
if (_json.containsKey('etag')) {
etag = _json['etag'] as core.String;
}
if (_json.containsKey('modelHash')) {
modelHash = _json['modelHash'] as core.String;
}
if (_json.containsKey('name')) {
name = _json['name'] as core.String;
}
if (_json.containsKey('state')) {
state = ModelState.fromJson(
_json['state'] as core.Map<core.String, core.dynamic>);
}
if (_json.containsKey('tags')) {
tags = (_json['tags'] as core.List)
.map<core.String>((value) => value as core.String)
.toList();
}
if (_json.containsKey('tfliteModel')) {
tfliteModel = TfLiteModel.fromJson(
_json['tfliteModel'] as core.Map<core.String, core.dynamic>);
}
if (_json.containsKey('updateTime')) {
updateTime = _json['updateTime'] as core.String;
}
}
core.Map<core.String, core.Object> toJson() {
final _json = <core.String, core.Object>{};
if (activeOperations != null) {
_json['activeOperations'] =
activeOperations.map((value) => value.toJson()).toList();
}
if (createTime != null) {
_json['createTime'] = createTime;
}
if (displayName != null) {
_json['displayName'] = displayName;
}
if (etag != null) {
_json['etag'] = etag;
}
if (modelHash != null) {
_json['modelHash'] = modelHash;
}
if (name != null) {
_json['name'] = name;
}
if (state != null) {
_json['state'] = state.toJson();
}
if (tags != null) {
_json['tags'] = tags;
}
if (tfliteModel != null) {
_json['tfliteModel'] = tfliteModel.toJson();
}
if (updateTime != null) {
_json['updateTime'] = updateTime;
}
return _json;
}
}
/// This is returned in the longrunning operations for create/update.
class ModelOperationMetadata {
///
/// Possible string values are:
/// - "BASIC_OPERATION_STATUS_UNSPECIFIED" : The status is unspecified
/// - "BASIC_OPERATION_STATUS_UPLOADING" : The model file is being uploaded
/// - "BASIC_OPERATION_STATUS_VERIFYING" : The model file is being verified
core.String basicOperationStatus;
/// The name of the model we are creating/updating The name must have the form
/// `projects/{project_id}/models/{model_id}`
core.String name;
ModelOperationMetadata();
ModelOperationMetadata.fromJson(core.Map _json) {
if (_json.containsKey('basicOperationStatus')) {
basicOperationStatus = _json['basicOperationStatus'] as core.String;
}
if (_json.containsKey('name')) {
name = _json['name'] as core.String;
}
}
core.Map<core.String, core.Object> toJson() {
final _json = <core.String, core.Object>{};
if (basicOperationStatus != null) {
_json['basicOperationStatus'] = basicOperationStatus;
}
if (name != null) {
_json['name'] = name;
}
return _json;
}
}
/// State common to all model types. Includes publishing and validation
/// information.
class ModelState {
/// Indicates if this model has been published.
core.bool published;
/// Output only. Indicates the latest validation error on the model if any. A
/// model may have validation errors if there were problems during the model
/// creation/update. e.g. in the case of a TfLiteModel, if a tflite model file
/// was missing or in the wrong format. This field will be empty for valid
/// models.
Status validationError;
ModelState();
ModelState.fromJson(core.Map _json) {
if (_json.containsKey('published')) {
published = _json['published'] as core.bool;
}
if (_json.containsKey('validationError')) {
validationError = Status.fromJson(
_json['validationError'] as core.Map<core.String, core.dynamic>);
}
}
core.Map<core.String, core.Object> toJson() {
final _json = <core.String, core.Object>{};
if (published != null) {
_json['published'] = published;
}
if (validationError != null) {
_json['validationError'] = validationError.toJson();
}
return _json;
}
}
/// This resource represents a long-running operation that is the result of a
/// network API call.
class Operation {
/// If the value is `false`, it means the operation is still in progress. If
/// `true`, the operation is completed, and either `error` or `response` is
/// available.
core.bool done;
/// The error result of the operation in case of failure or cancellation.
Status error;
/// Service-specific metadata associated with the operation. It typically
/// contains progress information and common metadata such as create time.
/// Some services might not provide such metadata. Any method that returns a
/// long-running operation should document the metadata type, if any.
///
/// The values for Object must be JSON objects. It can consist of `num`,
/// `String`, `bool` and `null` as well as `Map` and `List` values.
core.Map<core.String, core.Object> metadata;
/// The server-assigned name, which is only unique within the same service
/// that originally returns it. If you use the default HTTP mapping, the
/// `name` should be a resource name ending with `operations/{unique_id}`.
core.String name;
/// The normal response of the operation in case of success. If the original
/// method returns no data on success, such as `Delete`, the response is
/// `google.protobuf.Empty`. If the original method is standard
/// `Get`/`Create`/`Update`, the response should be the resource. For other
/// methods, the response should have the type `XxxResponse`, where `Xxx` is
/// the original method name. For example, if the original method name is
/// `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
///
/// The values for Object must be JSON objects. It can consist of `num`,
/// `String`, `bool` and `null` as well as `Map` and `List` values.
core.Map<core.String, core.Object> response;
Operation();
Operation.fromJson(core.Map _json) {
if (_json.containsKey('done')) {
done = _json['done'] as core.bool;
}
if (_json.containsKey('error')) {
error = Status.fromJson(
_json['error'] as core.Map<core.String, core.dynamic>);
}
if (_json.containsKey('metadata')) {
metadata =
(_json['metadata'] as core.Map).cast<core.String, core.Object>().map(
(key, item) => core.MapEntry(
key,
item as core.Object,
),
);
}
if (_json.containsKey('name')) {
name = _json['name'] as core.String;
}
if (_json.containsKey('response')) {
response =
(_json['response'] as core.Map).cast<core.String, core.Object>().map(
(key, item) => core.MapEntry(
key,
item as core.Object,
),
);
}
}
core.Map<core.String, core.Object> toJson() {
final _json = <core.String, core.Object>{};
if (done != null) {
_json['done'] = done;
}
if (error != null) {
_json['error'] = error.toJson();
}
if (metadata != null) {
_json['metadata'] = metadata;
}
if (name != null) {
_json['name'] = name;
}
if (response != null) {
_json['response'] = response;
}
return _json;
}
}
/// The `Status` type defines a logical error model that is suitable for
/// different programming environments, including REST APIs and RPC APIs. It is
/// used by [gRPC](https://github.com/grpc). Each `Status` message contains
/// three pieces of data: error code, error message, and error details. You can
/// find out more about this error model and how to work with it in the [API
/// Design Guide](https://cloud.google.com/apis/design/errors).
class Status {
/// The status code, which should be an enum value of google.rpc.Code.
core.int code;
/// A list of messages that carry the error details. There is a common set of
/// message types for APIs to use.
///
/// The values for Object must be JSON objects. It can consist of `num`,
/// `String`, `bool` and `null` as well as `Map` and `List` values.
core.List<core.Map<core.String, core.Object>> details;
/// A developer-facing error message, which should be in English. Any
/// user-facing error message should be localized and sent in the
/// google.rpc.Status.details field, or localized by the client.
core.String message;
Status();
Status.fromJson(core.Map _json) {
if (_json.containsKey('code')) {
code = _json['code'] as core.int;
}
if (_json.containsKey('details')) {
details = (_json['details'] as core.List)
.map<core.Map<core.String, core.Object>>((value) =>
(value as core.Map).cast<core.String, core.Object>().map(
(key, item) => core.MapEntry(
key,
item as core.Object,
),
))
.toList();
}
if (_json.containsKey('message')) {
message = _json['message'] as core.String;
}
}
core.Map<core.String, core.Object> toJson() {
final _json = <core.String, core.Object>{};
if (code != null) {
_json['code'] = code;
}
if (details != null) {
_json['details'] = details;
}
if (message != null) {
_json['message'] = message;
}
return _json;
}
}
/// Information that is specific to TfLite models.
class TfLiteModel {
/// The AutoML model id referencing a model you created with the AutoML API.
/// The name should have format 'projects//locations//models/' (This is the
/// model resource name returned from the AutoML API)
core.String automlModel;
/// The TfLite file containing the model. (Stored in Google Cloud). The
/// gcs_tflite_uri should have form: gs://some-bucket/some-model.tflite Note:
/// If you update the file in the original location, it is necessary to call
/// UpdateModel for ML to pick up and validate the updated file.
core.String gcsTfliteUri;
/// Output only. The size of the TFLite model
core.String sizeBytes;
TfLiteModel();
TfLiteModel.fromJson(core.Map _json) {
if (_json.containsKey('automlModel')) {
automlModel = _json['automlModel'] as core.String;
}
if (_json.containsKey('gcsTfliteUri')) {
gcsTfliteUri = _json['gcsTfliteUri'] as core.String;
}
if (_json.containsKey('sizeBytes')) {
sizeBytes = _json['sizeBytes'] as core.String;
}
}
core.Map<core.String, core.Object> toJson() {
final _json = <core.String, core.Object>{};
if (automlModel != null) {
_json['automlModel'] = automlModel;
}
if (gcsTfliteUri != null) {
_json['gcsTfliteUri'] = gcsTfliteUri;
}
if (sizeBytes != null) {
_json['sizeBytes'] = sizeBytes;
}
return _json;
}
}