class Gitlab::QA::Component::Staging::Version

def api_get!

def api_get!
  @response_body ||= # rubocop:disable Naming/MemoizedInstanceVariableName
    begin
      response = Support::GetRequest.new(uri, Runtime::Env.qa_access_token).execute!
      JSON.parse(response.body)
    end
end

def initialize(address)

def initialize(address)
  @uri = URI.join(address, '/api/v4/version')
  Runtime::Env.require_qa_access_token!
end

def major_minor_revision

def major_minor_revision
  api_response = api_get!
  version_regexp = /^v?(?<major>\d+)\.(?<minor>\d+)\.\d+/
  match = version_regexp.match(api_response.fetch('version'))
  "#{match[:major]}.#{match[:minor]}-#{api_response.fetch('revision')}"
end

def official?

def official?
  QA::Release::DEV_OFFICIAL_TAG_REGEX.match?(version)
end

def revision

def revision
  api_get!.fetch('revision')
end

def tag_end

def tag_end
  official? ? version : revision
end

def version

def version
  api_get!.fetch('version')
end