func (da *PackageArchive) DownloadArchiveInfo(tracer trace.Tracer, packageName string, version string) (string, error) {
	var cachedDocumentHash string
	var err error
	versionPtr := &version
	if version == "" {
		versionPtr = nil
	}
	MaxDelayBeforeCall := 15 //seconds
	// random back off before GetDocument call
	time.Sleep(time.Duration(getRandomBackOffTime(MaxDelayBeforeCall)*(da.timeUnit)) * time.Millisecond)
	descDocResponse, err := da.facadeClient.DescribeDocument(
		&ssm.DescribeDocumentInput{
			Name:        &packageName,
			VersionName: versionPtr,
		},
	)

	if err != nil {
		return "", fmt.Errorf("failed to retrieve package document description: %v", err)
	}

	if descDocResponse == nil || descDocResponse.Document == nil {
		return "", fmt.Errorf("Failed to retreive document description for package installation")
	}

	if *descDocResponse.Document.Status != ssm.DocumentStatusActive {
		return "", fmt.Errorf("package document is not currently active, kindly retry when the status is active. Current document status - %v", *descDocResponse.Document.Status)
	}

	if descDocResponse.Document.Name == nil || *descDocResponse.Document.Name == "" {
		return "", fmt.Errorf("document name cannot be empty")
	}
	if descDocResponse.Document.DocumentVersion == nil {
		return "", fmt.Errorf("document version cannot be nil")
	}
	da.documentDesc = descDocResponse.Document

	// DescribeDocument returns the Name of the document if it belongs to the account of the instance.
	// If it is a shared document, DescribeDocument returns the document ARN as Name
	da.documentArn = *da.documentDesc.Name
	da.docVersion = *da.documentDesc.DocumentVersion
	// Read the cached manifest hash file
	hashData, err := da.manifestCache.ReadManifestHash(packageName, da.docVersion)
	if err != nil {
		// if manifest hash does not exist, getDocument to download the manifest
		return da.getDocument(packageName, version)
	}
	// if no error, proceed to describe document
	cachedDocumentHash = string(hashData)

	if cachedDocumentHash != *da.documentDesc.Hash {
		// If the hash value of the cached hash and the document hash isn't the same, then getDocument to download the content
		return da.getDocument(packageName, version)
	} else {
		// If the hash matches, read the cached manifest. If there is an error reading the manifest, because
		// it does not exist or is corrupted, getDocument to download the manifest
		manifestData, err := da.manifestCache.ReadManifest(*da.documentDesc.Name, da.docVersion)
		if err != nil || string(manifestData) == "" {
			return da.getDocument(packageName, version)
		}

		// if hash of stored anifest is the same
		// Store manifests separately for document type packages
		da.manifest = string(manifestData)
	}
	return da.manifest, nil
}
// DownloadArtifactInfo downloads the document using GetDocument and eventually gets the manifest from that and returns it
DownloadArtifactInfo downloads the document using GetDocument and eventually gets the manifest from that and returns it
// DownloadArtifactInfo downloads the document using GetDocument and eventually gets the manifest from that and returns it
func (da *PackageArchive) DownloadArchiveInfo(tracer trace.Tracer, packageName string, version string) (string, error) {
	var cachedDocumentHash string
	var err error
	versionPtr := &version
	if version == "" {
		versionPtr = nil
	}
	MaxDelayBeforeCall := 15 
	time.Sleep(time.Duration(getRandomBackOffTime(MaxDelayBeforeCall)*(da.timeUnit)) * time.Millisecond)
	descDocResponse, err := da.facadeClient.DescribeDocument(
		&ssm.DescribeDocumentInput{
			Name:        &packageName,
			VersionName: versionPtr,
		},
	)
	if err != nil {
		return "", fmt.Errorf("failed to retrieve package document description: %v", err)
	}
	if descDocResponse == nil || descDocResponse.Document == nil {
		return "", fmt.Errorf("Failed to retreive document description for package installation")
	}
	if *descDocResponse.Document.Status != ssm.DocumentStatusActive {
		return "", fmt.Errorf("package document is not currently active, kindly retry when the status is active. Current document status - %v", *descDocResponse.Document.Status)
	}
	if descDocResponse.Document.Name == nil || *descDocResponse.Document.Name == "" {
		return "", fmt.Errorf("document name cannot be empty")
	}
	if descDocResponse.Document.DocumentVersion == nil {
		return "", fmt.Errorf("document version cannot be nil")
	}
	da.documentDesc = descDocResponse.Document
	da.documentArn = *da.documentDesc.Name
	da.docVersion = *da.documentDesc.DocumentVersion
	hashData, err := da.manifestCache.ReadManifestHash(packageName, da.docVersion)
	if err != nil {
		return da.getDocument(packageName, version)
	}
	cachedDocumentHash = string(hashData)
	if cachedDocumentHash != *da.documentDesc.Hash {
		return da.getDocument(packageName, version)
	} else {
		manifestData, err := da.manifestCache.ReadManifest(*da.documentDesc.Name, da.docVersion)
		if err != nil || string(manifestData) == "" {
			return da.getDocument(packageName, version)
		}
		da.manifest = string(manifestData)
	}
	return da.manifest, nil
}
func ( da * PackageArchive ) DownloadArchiveInfo ( tracer trace . Tracer , packageName string , version string ) ( string , error ) { var cachedDocumentHash string var err error versionPtr := & version if version == " " { versionPtr = nil } MaxDelayBeforeCall := 15 time . Sleep ( time . Duration ( getRandomBackOffTime ( MaxDelayBeforeCall ) * ( da . timeUnit ) ) * time . Millisecond ) descDocResponse , err := da . facadeClient . DescribeDocument ( & ssm . DescribeDocumentInput { Name : & packageName , VersionName : versionPtr , } , ) if err != nil { return " " , fmt . Errorf ( " " , err ) } if descDocResponse == nil || descDocResponse . Document == nil { return " " , fmt . Errorf ( " " ) } if * descDocResponse . Document . Status != ssm . DocumentStatusActive { return " " , fmt . Errorf ( " " , * descDocResponse . Document . Status ) } if descDocResponse . Document . Name == nil || * descDocResponse . Document . Name == " " { return " " , fmt . Errorf ( " " ) } if descDocResponse . Document . DocumentVersion == nil { return " " , fmt . Errorf ( " " ) } da . documentDesc = descDocResponse . Document da . documentArn = * da . documentDesc . Name da . docVersion = * da . documentDesc . DocumentVersion hashData , err := da . manifestCache . ReadManifestHash ( packageName , da . docVersion ) if err != nil { return da . getDocument ( packageName , version ) } cachedDocumentHash = string ( hashData ) if cachedDocumentHash != * da . documentDesc . Hash { return da . getDocument ( packageName , version ) } else { manifestData , err := da . manifestCache . ReadManifest ( * da . documentDesc . Name , da . docVersion ) if err != nil || string ( manifestData ) == " " { return da . getDocument ( packageName , version ) } da . manifest = string ( manifestData ) } return da . manifest , nil }
DownloadArtifactInfo downloads the document using GetDocument and eventually gets the manifest from that and returns it
DownloadArtifactInfo downloads the document using GetDocument and eventually gets the manifest from that and returns it
//seconds // random back off before GetDocument call // DescribeDocument returns the Name of the document if it belongs to the account of the instance. // If it is a shared document, DescribeDocument returns the document ARN as Name // Read the cached manifest hash file // if manifest hash does not exist, getDocument to download the manifest // if no error, proceed to describe document // If the hash value of the cached hash and the document hash isn't the same, then getDocument to download the content // If the hash matches, read the cached manifest. If there is an error reading the manifest, because // it does not exist or is corrupted, getDocument to download the manifest // if hash of stored anifest is the same // Store manifests separately for document type packages