class_docstr: Represent a GCS Bucket.
docstr: Verify that the preconditions in request are met.
  
  :param request:flask.Request the contents of the HTTP request.
  :rtype:NoneType
  :raises:ErrorResponse if the request does not pass the preconditions,
      for example, the request has a `ifMetagenerationMatch` restriction
      that is not met.
docstr_tok: ["Verify","that","the","preconditions","in","request","are","met",".",":","param","request",":","flask.Request","the","contents","of","the","HTTP","request",".",":","rtype",":","NoneType",":","raises",":","ErrorResponse","if","the","request","does","not","pass","the","preconditions",",","for","example",",","the","request","has","a","`","ifMetagenerationMatch","`","restriction","that","is","not","met","."]
code: def check_preconditions(self, request):
      """Verify that the preconditions in request are met.
  
      :param request:flask.Request the contents of the HTTP request.
      :rtype:NoneType
      :raises:ErrorResponse if the request does not pass the preconditions,
          for example, the request has a `ifMetagenerationMatch` restriction
          that is not met.
      """
  
      metageneration_match = request.args.get("ifMetagenerationMatch")
      metageneration_not_match = request.args.get(
          "ifMetagenerationNotMatch"
      )
      metageneration = self.metadata.get("metageneration")
  
      if (
          metageneration_not_match is not None
          and metageneration_not_match == metageneration
      ):
          raise error_response.ErrorResponse(
              "Precondition Failed (metageneration = %s)"
              % metageneration,
              status_code=412,
          )
  
      if (
          metageneration_match is not None
          and metageneration_match != metageneration
      ):
          raise error_response.ErrorResponse(
              "Precondition Failed (metageneration = %s)"
              % metageneration,
              status_code=412,
          )
  
file_path: io/tests/test_gcloud/testbench/gcs_bucket.py
imports: import base64
  import error_response
  import flask
  import gcs_object
  import json
  import re
  import testbench_utils
  import time
label_desc: Use image node_id 3 for calling the GcsBucket obj's underlying member method code with example usage: obj.check_preconditions(request) without return types