create method
Creates a new metric descriptor.
The creation is executed asynchronously. User-created metric descriptors define custom metrics (https://cloud.google.com/monitoring/custom-metrics). The metric descriptor is updated if it already exists, except that metric labels are never removed.
request
- The metadata request object.
Request parameters:
name
- Required. The project
(https://cloud.google.com/monitoring/api/v3#project_name) on which to
execute the request. The format is: 4 projects/PROJECT_ID_OR_NUMBER
Value must have pattern ^projects/\[^/\]+$
.
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a MetricDescriptor.
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.
Implementation
async.Future<MetricDescriptor> create(
MetricDescriptor request,
core.String name, {
core.String? $fields,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final url_ = 'v3/' + core.Uri.encodeFull('$name') + '/metricDescriptors';
final response_ = await _requester.request(
url_,
'POST',
body: body_,
queryParams: queryParams_,
);
return MetricDescriptor.fromJson(
response_ as core.Map<core.String, core.dynamic>);
}