You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: registry_client.rb
    path of file: ./repos/Portus/lib/portus
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module Portus
  # RegistryClient is a a layer between Portus and the Registry. Gi
    
    def manifest(repository, tag = "latest")
      res = safe_request("#{repository}/manifests/#{tag}", "get")

      if res.code.to_i == 200
        mf = JSON.parse(res.body)
        id = mf.try(:[], "config").try(:[], "digest")
        id = id.split(":").last if id.is_a? String
        digest = res["Docker-Content-Digest"]
        size = calculate_tag_size(mf)
        OpenStruct.new(id: id, digest: digest, size: size, mf: mf)
      elsif res.code.to_i == 404
        handle_error res, repository: repository, tag: tag
      else
        raise ::Portus::RegistryClient::ManifestError,
              "Something went wrong while fetching manifest for " \
              "#{repository}:#{tag}:[#{res.code}] - #{res.body}"
      end