create method
Creates a course.
The user specified in ownerId
is the owner of the created course and
added as a teacher. A non-admin requesting user can only create a course
with themselves as the owner. Domain admins can create courses owned by
any user within their domain. This method returns the following error
codes: * PERMISSION_DENIED
if the requesting user is not permitted to
create courses or for access errors. * NOT_FOUND
if the primary teacher
is not a valid user. * FAILED_PRECONDITION
if the course owner's account
is disabled or for the following request errors: * UserCannotOwnCourse *
UserGroupsMembershipLimitReached * ALREADY_EXISTS
if an alias was
specified in the id
and already exists.
request
- The metadata request object.
Request parameters:
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a Course.
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<Course> create(
Course request, {
core.String? $fields,
}) async {
final body_ = convert.json.encode(request);
final queryParams_ = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
const url_ = 'v1/courses';
final response_ = await _requester.request(
url_,
'POST',
body: body_,
queryParams: queryParams_,
);
return Course.fromJson(response_ as core.Map<core.String, core.dynamic>);
}