setState method

Future<DeviceState> setState(
  1. DeviceState request,
  2. String enterpriseId,
  3. String userId,
  4. String deviceId, {
  5. String? $fields,
})

Sets whether a device's access to Google services (including Google Play) is enabled or disabled for the specified user.

Setting the state to "enabled" allows the Google Account to access Google services, while "disabled" blocks access by preventing OAuth token issuance. Preconditions for Enforcement: 1. This setting is only effective for Google-managed users. 2. The enterprise must be linked to a Google Managed Domain. 3. Enforcement requires third-party Android mobile management to be enabled within the Google Admin Console for the user's Organizational Unit. If these preconditions are not met, changes to this state may be ignored.

request - The metadata request object.

Request parameters:

enterpriseId - The ID of the enterprise.

userId - The ID of the user.

deviceId - The ID of the device.

$fields - Selector specifying which fields to include in a partial response.

Completes with a DeviceState.

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<DeviceState> setState(
  DeviceState request,
  core.String enterpriseId,
  core.String userId,
  core.String deviceId, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    'fields': ?$fields == null ? null : [$fields],
  };

  final url_ =
      'androidenterprise/v1/enterprises/' +
      commons.escapeVariable('$enterpriseId') +
      '/users/' +
      commons.escapeVariable('$userId') +
      '/devices/' +
      commons.escapeVariable('$deviceId') +
      '/state';

  final response_ = await _requester.request(
    url_,
    'PUT',
    body: body_,
    queryParams: queryParams_,
  );
  return DeviceState.fromJson(
    response_ as core.Map<core.String, core.dynamic>,
  );
}