create method
- ServiceLevelObjective request,
- String parent, {
- String? serviceLevelObjectiveId,
- String? $fields,
Create a ServiceLevelObjective for the given Service.
request
- The metadata request object.
Request parameters:
parent
- Required. Resource name of the parent Service. The format is:
projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
Value must have pattern ^\[^/\]+/\[^/\]+/services/\[^/\]+$
.
serviceLevelObjectiveId
- Optional. The ServiceLevelObjective id to use
for this ServiceLevelObjective. If omitted, an id will be generated
instead. Must match the pattern ^[a-zA-Z0-9-_:.]+$
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a ServiceLevelObjective.
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<ServiceLevelObjective> create(
ServiceLevelObjective request,
core.String parent, {
core.String? serviceLevelObjectiveId,
core.String? $fields,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if (serviceLevelObjectiveId != null)
'serviceLevelObjectiveId': [serviceLevelObjectiveId],
if ($fields != null) 'fields': [$fields],
};
final url_ =
'v3/' + core.Uri.encodeFull('$parent') + '/serviceLevelObjectives';
final response_ = await _requester.request(
url_,
'POST',
body: body_,
queryParams: queryParams_,
);
return ServiceLevelObjective.fromJson(
response_ as core.Map<core.String, core.dynamic>);
}