createHostedConfigurationVersion method

Future<HostedConfigurationVersion> createHostedConfigurationVersion({
  1. required String applicationId,
  2. required String configurationProfileId,
  3. required Uint8List content,
  4. required String contentType,
  5. String? description,
  6. int? latestVersionNumber,
})

Create a new configuration in the AppConfig configuration store.

May throw BadRequestException. May throw ServiceQuotaExceededException. May throw ResourceNotFoundException. May throw ConflictException. May throw PayloadTooLargeException. May throw InternalServerException.

Parameter applicationId : The application ID.

Parameter configurationProfileId : The configuration profile ID.

Parameter content : The content of the configuration or the configuration data.

Parameter contentType : A standard MIME type describing the format of the configuration content. For more information, see Content-Type.

Parameter description : A description of the configuration.

Parameter latestVersionNumber : An optional locking token used to prevent race conditions from overwriting configuration updates when creating a new version. To ensure your data is not overwritten when creating multiple hosted configuration versions in rapid succession, specify the version of the latest hosted configuration version.

Implementation

Future<HostedConfigurationVersion> createHostedConfigurationVersion({
  required String applicationId,
  required String configurationProfileId,
  required Uint8List content,
  required String contentType,
  String? description,
  int? latestVersionNumber,
}) async {
  ArgumentError.checkNotNull(applicationId, 'applicationId');
  ArgumentError.checkNotNull(
      configurationProfileId, 'configurationProfileId');
  ArgumentError.checkNotNull(content, 'content');
  ArgumentError.checkNotNull(contentType, 'contentType');
  _s.validateStringLength(
    'contentType',
    contentType,
    1,
    255,
    isRequired: true,
  );
  _s.validateStringLength(
    'description',
    description,
    0,
    1024,
  );
  final headers = <String, String>{
    'Content-Type': contentType.toString(),
    if (description != null) 'Description': description.toString(),
    if (latestVersionNumber != null)
      'Latest-Version-Number': latestVersionNumber.toString(),
  };
  final response = await _protocol.sendRaw(
    payload: content,
    method: 'POST',
    requestUri:
        '/applications/${Uri.encodeComponent(applicationId)}/configurationprofiles/${Uri.encodeComponent(configurationProfileId)}/hostedconfigurationversions',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return HostedConfigurationVersion(
    content: await response.stream.toBytes(),
    applicationId:
        _s.extractHeaderStringValue(response.headers, 'Application-Id'),
    configurationProfileId: _s.extractHeaderStringValue(
        response.headers, 'Configuration-Profile-Id'),
    contentType:
        _s.extractHeaderStringValue(response.headers, 'Content-Type'),
    description: _s.extractHeaderStringValue(response.headers, 'Description'),
    versionNumber:
        _s.extractHeaderIntValue(response.headers, 'Version-Number'),
  );
}