Branch | Status |
---|---|
master | |
dev |
- General
- Pull Requests
- Tests
- General APIs
- Artifactory APIs
- Creating Artifactory Service Manager
- Using Artifactory Services
- Uploading Files to Artifactory
- Downloading Files from Artifactory
- Copying Files in Artifactory
- Moving Files in Artifactory
- Deleting Files from Artifactory
- Searching Files in Artifactory
- Setting Properties on Files in Artifactory
- Deleting Properties from Files in Artifactory
- Publishing Build Info to Artifactory
- Fetching Build Info from Artifactory
- Promoting Published Builds in Artifactory
- Promoting a Docker Image in Artifactory
- Distributing Published Builds to JFrog Bintray
- Triggering Build Scanning with JFrog Xray
- Discarding Old Builds
- Cleaning Unreferenced Git LFS Files from Artifactory
- Executing AQLs
- Reading Files in Artifactory
- Creating an Access Token
- Fetching Access Tokens
- Refreshing an Access Token
- Revoking an Access Token
- Regenerate API Key
- Creating and Updating Local Repository
- Creating and Updating Remote Repository
- Creating and Updating Virtual Repository
- Getting Repository Details
- Creating and Updating Repository Replications
- Getting a Repository Replication
- Removing a Repository Replication
- Creating and Updating Permission Targets
- Removing a Permission Target
- Fetching Artifactory's Version
- Fetching Artifactory's Service ID
- Distribution APIs
- Bintray APIs
- Creating Bintray Details
- Creating Bintray Service Manager
- Using Bintray Services
- Uploading a Single File to Bintray
- Downloading a Single File from Bintray
- Downloading Version Files from Bintray
- Showing and Deleting a Bintray Package
- Creating and Updating a Bintray Package
- Showing and Deleting a Bintray Version
- Creating and Updating a Bintray Version
- Creating and Updating Entitlements
- Showing and Deleting Entitlements
- Creating and Updating Access Keys
- Showing and Deleting Access Keys
- Signing a URL
- GPG Signing a File
- GPG Signing Version Files
- Listing Logs
- Downloading Logs
- Using ContentReader
jfrog-client-go is a library which provides Go APIs to performs actions on JFrog Artifactory or Bintray from your Go application. The project is still relatively new, and its APIs may therefore change frequently between releases. The library can be used as a go-module, which should be added to your project's go.mod file. As a reference you may look at JFrog CLI's go.mod file, which uses this library as a dependency.
We welcome pull requests from the community.
- If the existing tests do not already cover your changes, please add tests.
- Pull requests should be created on the dev branch.
- Please use gofmt for formatting the code before submitting the pull request.
To run tests on the source code, you'll need a running JFrog Artifactory Pro instance. Use the following command with the below options to run the tests.
go test -v github.com/jfrog/jfrog-client-go/tests
Optional flags:
Flag | Description |
---|---|
-rt.url |
[Default: http://localhost:8081/artifactory] Artifactory URL. |
-rt.user |
[Default: admin] Artifactory username. |
-rt.password |
[Default: password] Artifactory password. |
-rt.distUrl |
[Optional] JFrog Distribution URL. |
-rt.apikey |
[Optional] Artifactory API key. |
-rt.sshKeyPath |
[Optional] Ssh key file path. Should be used only if the Artifactory URL format is ssh://[domain]:port |
-rt.sshPassphrase |
[Optional] Ssh key passphrase. |
-rt.accessToken |
[Optional] Artifactory access token. |
-log-level |
[Default: INFO] Sets the log level. |
- The tests create an Artifactory repository named jfrog-client-tests-repo1.
Once the tests are completed, the content of this repository is deleted.
var file *os.File
...
log.SetLogger(log.NewLogger(log.INFO, file))
The default temp dir used is 'os.TempDir()'. Use the following API to set a new temp dir:
fileutils.SetTempDirBase(filepath.Join("my", "temp", "path"))
rtDetails := auth.NewArtifactoryDetails()
rtDetails.SetUrl("http://localhost:8081/artifactory")
rtDetails.SetSshKeysPath("path/to/.ssh/")
rtDetails.SetApiKey("apikey")
rtDetails.SetUser("user")
rtDetails.SetPassword("password")
rtDetails.SetAccessToken("accesstoken")
// if client certificates are required
rtDetails.SetClientCertPath("path/to/.cer")
rtDetails.SetClientCertKeyPath("path/to/.key")
serviceConfig, err := config.NewConfigBuilder().
SetServiceDetails(rtDetails).
SetCertificatesPath(certPath).
SetThreads(threads).
SetDryRun(false).
Build()
rtManager, err := artifactory.New(&rtDetails, serviceConfig)
params := services.NewUploadParams()
params.Pattern = "repo/*/*.zip"
params.Target = "repo/path/"
// Attach properties to the uploaded files.
params.Props = "key1=val1;key2=val2"
params.Recursive = true
params.Regexp = false
params.IncludeDirs = false
params.Flat = true
params.Explode = false
params.Deb = ""
params.Symlink = false
params.AddVcsProps = false
// Retries default value: 3
params.Retries = 5
// MinChecksumDeploy default value: 10400
params.MinChecksumDeploy = 15360
rtManager.UploadFiles(params)
Using the DownloadFiles()
function, we can download files and get the general statistics of the action (The actual number of files downloaded, and the number of files we expected to download), and the error value if it occurred.
params := services.NewDownloadParams()
params.Pattern = "repo/*/*.zip"
params.Target = "target/path/"
// Filter the downloaded files by properties.
params.Props = "key1=val1;key2=val2"
params.Recursive = true
params.IncludeDirs = false
params.Flat = false
params.Explode = false
params.Symlink = true
params.ValidateSymlink = false
// Retries default value: 3
params.Retries = 5
// SplitCount default value: 3
params.SplitCount = 2
// MinSplitSize default value: 5120
params.MinSplitSize = 7168
totalDownloaded, totalExpected, err := rtManager.DownloadFiles(params)
Similar to DownloadFiles()
, but returns a reader, which allows iterating over the details of the downloaded files. Only files which were successfully downloaded are available by the reader.
params := services.NewDownloadParams()
params.Pattern = "repo/*/*.zip"
params.Target = "target/path/"
// Filter the downloaded files by properties.
params.Props = "key1=val1;key2=val2"
params.Recursive = true
params.IncludeDirs = false
params.Flat = false
params.Explode = false
params.Symlink = true
params.ValidateSymlink = false
params.Retries = 5
params.SplitCount = 2
params.MinSplitSize = 7168
reader, totalDownloaded, totalExpected, err := rtManager.DownloadFilesWithResultReader(params)
Read more about ContentReader.
params := services.NewMoveCopyParams()
params.Pattern = "repo/*/*.zip"
params.Target = "target/path/"
// Filter the files by properties.
params.Props = "key1=val1;key2=val2"
params.Recursive = true
params.Flat = false
rtManager.Copy(params)
params := services.NewMoveCopyParams()
params.Pattern = "repo/*/*.zip"
params.Target = "target/path/"
// Filter the files by properties.
params.Props = "key1=val1;key2=val2"
params.Recursive = true
params.Flat = false
rtManager.Move(params)
params := services.NewDeleteParams()
params.Pattern = "repo/*/*.zip"
// Filter the files by properties.
params.Props = "key1=val1;key2=val2"
params.Recursive = true
pathsToDelete, err := rtManager.GetPathsToDelete(params)
if err != nil {
return err
}
defer pathsToDelete.Close()
rtManager.DeleteFiles(pathsToDelete)
Read more about ContentReader.
params := services.NewSearchParams()
params.Pattern = "repo/*/*.zip"
// Filter the files by properties.
params.Props = "key1=val1;key2=val2"
params.Recursive = true
reader, err := rtManager.SearchFiles(params)
if err != nil {
return err
}
defer reader.Close()
Read more about ContentReader.
searchParams = services.NewSearchParams()
searchParams.Recursive = true
searchParams.IncludeDirs = false
reader, err = rtManager.SearchFiles(searchParams)
if err != nil {
return err
}
defer reader.Close()
propsParams = services.NewPropsParams()
propsParams.Pattern = "repo/*/*.zip"
propsParams.Reader = reader
// Filter the files by properties.
propsParams.Props = "key=value"
rtManager.SetProps(propsParams)
Read more about ContentReader.
searchParams = services.NewSearchParams()
searchParams.Recursive = true
searchParams.IncludeDirs = false
resultItems, err = rtManager.SearchFiles(searchParams)
if err != nil {
return err
}
defer reader.Close()
propsParams = services.NewPropsParams()
propsParams.Pattern = "repo/*/*.zip"
propsParams.Reader = reader
// Filter the files by properties.
propsParams.Props = "key=value"
rtManager.DeleteProps(propsParams)
Read more about ContentReader.
buildInfo := &buildinfo.BuildInfo{}
...
rtManager.PublishBuildInfo(buildInfo)
buildInfoParams := services.NewBuildInfoParams{}
buildInfoParams.BuildName = "buildName"
buildInfoParams.BuildNumber = "LATEST"
rtManager.GetBuildInfo(buildInfoParams)
params := services.NewPromotionParams()
params.BuildName = "buildName"
params.BuildNumber = "10"
params.TargetRepo = "target-repo"
params.Status = "status"
params.Comment = "comment"
params.Copy = true
params.IncludeDependencies = false
params.SourceRepo = "source-repo"
rtManager.DownloadFiles(params)
sourceDockerImage := "hello-world"
sourceRepo := "docker-local-1"
targetRepo := "docker-local-2"
params := services.NewDockerPromoteParams(sourceDockerImage, sourceRepo, targetRepo)
// Optional parameters:
params.TargetDockerImage = "target-docker-image"
params.SourceTag = "42"
params.TargetTag = "43"
params.Copy = true
rtManager.PromoteDocker(params)
params := services.NewBuildDistributionParams()
params.SourceRepos = "source-repo"
params.TargetRepo = "target-repo"
params.GpgPassphrase = "GpgPassphrase"
params.Publish = false
params.OverrideExistingFiles = false
params.Async = true
params.BuildName = "buildName"
params.BuildNumber = "10"
params.Pattern = "repo/*/*.zip"
rtManager.DistributeBuild(params)
params := services.NewXrayScanParams()
params.BuildName = buildName
params.BuildNumber = buildNumber
rtManager.XrayScanBuild(params)
params := services.NewDiscardBuildsParams()
params.BuildName = "buildName"
params.MaxDays = "max-days"
params.MaxBuilds = "max-builds"
params.ExcludeBuilds = "1,2"
params.DeleteArtifacts = false
params.Async = false
rtManager.DiscardBuilds(params)
params := services.NewGitLfsCleanParams()
params.Refs = "refs/remotes/*"
params.Repo = "my-project-lfs"
params.GitPath = "path/to/git"
reader,err := rtManager.GetUnreferencedGitLfsFiles(params)
defer reader.Close()
rtManager.DeleteFiles(reader)
rtManager.Aql(aql string)
rtManager.ReadRemoteFile(FilePath string)
params := services.NewCreateTokenParams()
params.Scope = "api:* member-of-groups:readers"
params.Username = "user"
params.ExpiresIn = 3600 // default -1 (use server default)
params.GrantType = "client_credentials"
params.Refreshable = true
params.Audience = "jfrt@<serviceID1> jfrt@<serviceID2>"
results, err := rtManager.CreateToken(params)
results, err := rtManager.GetTokens()
params := services.NewRefreshTokenParams()
params.AccessToken = "<access token>"
params.RefreshToken = "<refresh token>"
params.Token.Scope = "api:*"
params.Token.ExpiresIn = 3600
results, err := rtManager.RefreshToken(params)
params := services.NewRevokeTokenParams()
// Provide either TokenId or Token
params.TokenId = "<token id>"
// params.Token = "access token"
err := rtManager.RevokeToken(params)
apiKey, err := rtManager.RegenerateAPIKey()
You can create and update a local repository for the following package types:
Maven, Gradle, Ivy, Sbt, Helm, Cocoapods, Opkg, Rpm, Nuget, Cran, Gems, Npm, Bower, Debian, Composer, Pypi, Docker, Vagrant, Gitlfs, Go, Yum, Conan, Chef, Puppet and Generic.
Each package type has it's own parameters struct, can be created using the method
New<packageType>LocalRepositoryParams()
.
Example for creating local Generic repository:
params := services.NewGenericLocalRepositoryParams()
params.Key = "generic-repo"
params.Description = "This is a public description for generic-repo"
params.Notes = "These are internal notes for generic-repo"
params.RepoLayoutRef = "simple-default"
params.ArchiveBrowsingEnabled = true
params.XrayIndex = true
params.IncludesPattern = "**/*"
params.ExcludesPattern = "excludedDir/*"
params.DownloadRedirect = true
err = servicesManager.CreateLocalRepository().Generic(params)
Updating local Generic repository:
err = servicesManager.UpdateLocalRepository().Generic(params)
You can create and update a remote repository for the following package types:
Maven, Gradle, Ivy, Sbt, Helm, Cocoapods, Opkg, Rpm, Nuget, Cran, Gems, Npm, Bower, Debian, Composer, Pypi, Docker, Gitlfs, Go, Yum, Conan, Chef, Puppet, Conda, P2, Vcs and Generic.
Each package type has it's own parameters struct, can be created using the method
New<packageType>RemoteRepositoryParams()
.
Example for creating remote Maven repository:
params := services.NewMavenRemoteRepositoryParams()
params.Key = "jcenter-remote"
params.Url = "http://jcenter.bintray.com"
params.RepoLayoutRef = "maven-2-default"
params.Description = "A caching proxy repository for a JFrog's jcenter"
params.HandleSnapshot = false
params.HandleReleases = true
params.FetchJarsEagerly = true
params.AssumedOfflinePeriodSecs = 600
params.SuppressPomConsistencyChecks = true
params.RemoteRepoChecksumPolicyType = "pass-thru"
err = servicesManager.CreateRemoteRepository().Maven(params)
Updating remote Maven repository:
err = servicesManager.UpdateRemoteRepository().Maven(params)
You can create and update a virtual repository for the following package types:
Maven, Gradle, Ivy, Sbt, Helm, Rpm, Nuget, Cran, Gems, Npm, Bower, Debian, Pypi, Docker, Gitlfs, Go, Yum, Conan, Chef, Puppet, Conda, P2 and Generic
Each package type has it's own parameters struct, can be created using the method
New<packageType>VirtualRepositoryParams()
.
Example for creating virtual Go repository:
params := services.NewGoVirtualRepositoryParams()
params.Description = "This is an aggregated repository for several go repositories"
params.RepoLayoutRef = "go-default"
params.Repositories = {"gocenter-remote", "go-local"}
params.DefaultDeploymentRepo = "go-local"
params.ExternalDependenciesEnabled = true
params.ExternalDependenciesPatterns = {"**/github.com/**", "**/golang.org/**", "**/gopkg.in/**"}
params.ArtifactoryRequestsCanRetrieveRemoteArtifacts = true
err = servicesManager.CreateVirtualRepository().Go(params)
Updating remote Maven repository:
err = servicesManager.UpdateVirtualRepository().Go(params)
You can remove a repository from Artifactory using its key:
servicesManager.DeleteRepository("generic-repo")
You can get repository details from Artifactory using its key:
servicesManager.GetRepository("generic-repo")
Example of creating a repository replication:
params := services.NewCreateReplicationParams()
// Source replication repository.
params.RepoKey = "my-repository"
params.CronExp = "0 0 12 * * ?"
params.Username = "admin"
params.Password = "password"
params.Url = "http://localhost:8081/artifactory/remote-repo"
params.Enabled = true
params.SocketTimeoutMillis = 15000
params.EnableEventReplication = true
params.SyncDeletes = true
params.SyncProperties = true
params.SyncStatistics = true
params.PathPrefix = "/path/to/repo"
err = servicesManager.CreateReplication(params)
Example of updating a local repository replication:
params := services.NewUpdateReplicationParams()
// Source replication repository.
params.RepoKey = "my-repository"
params.CronExp = "0 0 12 * * ?"
params.Enabled = true
params.SocketTimeoutMillis = 15000
params.EnableEventReplication = true
params.SyncDeletes = true
params.SyncProperties = true
params.SyncStatistics = true
params.PathPrefix = "/path/to/repo"
err = servicesManager.UpdateReplication(params)
You can get a repository replication configuration from Artifactory using its key:
replicationConfiguration, err := servicesManager.GetReplication("my-repository")
You can remove a repository replication configuration from Artifactory using its key:
err := servicesManager.DeleteReplication("my-repository")
You can create or update a permission target in Artifactory.
Permissions are set according to the following conventions:
read, write, annotate, delete, manage, managedXrayMeta, distribute
For repositories You can specify the name "ANY"
in order to apply to all repositories, "ANY REMOTE"
for all remote repositories or "ANY LOCAL"
for all local repositories.
Creating a new permission target :
params := services.NewPermissionTargetParams()
params.Name = "java-developers"
params.Repo.Repositories = []string{"ANY REMOTE", "local-repo1", "local-repo2"}
params.Repo.ExcludePatterns = []string{"dir/*"}
params.Repo.Actions.Users = map[string][]string {
"user1" : {"read", "write"},
"user2" : {"write","annotate", "read"},
}
params.Repo.Actions.Groups = map[string][]string {
"group1" : {"manage","read","annotate"},
}
// This is the default value that cannot be changed
params.Build.Repositories = []string{"artifactory-build-info"}
params.Build.Actions.Groups = map[string][]string {
"group1" : {"manage","read","write","annotate","delete"},
"group2" : {"read"},
}
err = servicesManager.CreatePermissionTarget(params)
Updating an existing permission target :
err = servicesManager.UpdatePermissionTarget(params)
You can remove a permission target from Artifactory using its name:
servicesManager.DeletePermissionTarget("java-developers")
version, err := servicesManager.GetVersion()
serviceId, err := servicesManager.GetServiceId()
distDetails := auth.NewDistributionDetails()
distDetails.SetUrl("http://localhost:8081/distribution")
distDetails.SetSshKeysPath("path/to/.ssh/")
distDetails.SetApiKey("apikey")
distDetails.SetUser("user")
distDetails.SetPassword("password")
distDetails.SetAccessToken("accesstoken")
// if client certificates are required
distDetails.SetClientCertPath("path/to/.cer")
distDetails.SetClientCertKeyPath("path/to/.key")
serviceConfig, err := config.NewConfigBuilder().
SetServiceDetails(rtDetails).
SetCertificatesPath(certPath).
SetThreads(threads).
SetDryRun(false).
Build()
distManager, err := distribution.New(&distDetails, serviceConfig)
params := services.NewSetSigningKeyParams("private-gpg-key", "public-gpg-key")
err := distManager.SetSigningKey(params)
params := services.NewCreateReleaseBundleParams("bundle-name", "1")
params.SpecFiles = []*utils.ArtifactoryCommonParams{{Pattern: "repo/*/*.zip"}}
params.Description = "Description"
params.ReleaseNotes = "Release notes"
params.ReleaseNotesSyntax = "plain_text"
err := distManager.CreateReleaseBundle(params)
params := services.NewUpdateReleaseBundleParams("bundle-name", "1")
params.SpecFiles = []*utils.ArtifactoryCommonParams{{Pattern: "repo/*/*.zip"}}
params.Description = "New Description"
params.ReleaseNotes = "New Release notes"
params.ReleaseNotesSyntax = "plain_text"
err := distManager.CreateReleaseBundle(params)
params := services.NewSignBundleParams("bundle-name", "1")
params.GpgPassphrase = "123456"
err := distManager.SignReleaseBundle(params)
params := services.NewDistributeReleaseBundleParams("bundle-name", "1")
distributionRules := utils.DistributionCommonParams{SiteName: "Swamp-1", "CityName": "Tel-Aviv", "CountryCodes": []string{"123"}}}
params.DistributionRules = []*utils.DistributionCommonParams{distributionRules}
err := distManager.DistributeReleaseBundle(params)
params := services.NewDistributeReleaseBundleParams("bundle-name", "1")
distributionRules := utils.DistributionCommonParams{SiteName: "Swamp-1", "CityName": "Tel-Aviv", "CountryCodes": []string{"123"}}}
params.DistributionRules = []*utils.DistributionCommonParams{distributionRules}
// Wait up to 120 minutes for the release bundle distribution
err := distManager.DistributeReleaseBundleSync(params, 120)
params := services.NewDistributionStatusParams()
// Optional parameters:
// If missing, get status for all distributions
params.Name = "bundle-name"
// If missing, get status for all versions of "bundle-name"
params.Version = "1"
// If missing, get status for all "bundle-name" with version "1"
params.TrackerId = "123456789"
status, err := distributeBundleService.GetStatus(params)
params := services.NewDeleteReleaseBundleParams("bundle-name", "1")
params.DeleteFromDistribution = true
distributionRules := utils.DistributionCommonParams{SiteName: "Swamp-1", "CityName": "Tel-Aviv", "CountryCodes": []string{"123"}}}
params.DistributionRules = []*utils.DistributionCommonParams{distributionRules}
err := distManager.DeleteReleaseBundle(params)
params := services.NewDeleteReleaseBundleParams("bundle-name", "1")
err := distManager.DeleteLocalReleaseBundle(params)
btDetails := auth.NewBintrayDetails()
btDetails.SetUser("user")
btDetails.SetKey("key")
btDetails.SetDefPackageLicense("Apache 2.0")
serviceConfig := bintray.NewConfigBuilder().
SetBintrayDetails(btDetails).
SetDryRun(false).
SetThreads(threads).
Build()
btManager, err := bintray.New(serviceConfig)
params := services.NewUploadParams()
params.Pattern = "*/*.zip"
params.Path = versions.CreatePath("subject/repo/pkg/version")
params.TargetPath = "path/to/files"
params.Deb = "distribution/component/architecture"
params.Recursive = true
params.Flat = true
params.Publish = false
params.Override = false
params.Explode = false
params.UseRegExp = false
params.ShowInDownloadList = false
btManager.UploadFiles(params)
params := services.NewDownloadFileParams()
params.Flat = false
params.IncludeUnpublished = false
params.PathDetails = "path/to/file"
params.TargetPath = "target/path/"
// SplitCount default value: 3
params.SplitCount = 2
// MinSplitSize default value: 5120
params.MinSplitSize = 7168
btManager.DownloadFile(params)
params := services.NewDownloadVersionParams()
params.Path, err = versions.CreatePath("subject/repo/pkg/version")
params.IncludeUnpublished = false
params.TargetPath = "target/path/"
btManager.DownloadVersion(params)
pkgPath, err := packages.CreatePath("subject/repo/pkg")
btManager.ShowPackage(pkgPath)
btManager.DeletePackage(pkgPath)
params := packages.NewPackageParams()
params.Path, err = packages.CreatePath("subject/repo/pkg")
params.Desc = "description"
params.Labels = "labels"
params.Licenses = "licences"
params.CustomLicenses = "custum-licenses"
params.VcsUrl = "https://github.com/jfrog/jfrog-cli-go"
params.WebsiteUrl = "https://jfrog.com"
params.IssueTrackerUrl = "https://github.com/bintray/bintray-client-java/issues"
params.GithubRepo = "bintray/bintray-client-java"
params.GithubReleaseNotesFile = "RELEASE_1.2.3.txt" "github-rel-notes"
params.PublicDownloadNumbers = "true"
params.PublicStats = "true"
btManager.CreatePackage(params)
btManager.UpdatePackage(params)
versionPath, err := versions.CreatePath("subject/repo/pkg/version")
btManager.ShowVersion(versionPath)
btManager.DeleteVersion(versionPath)
params := versions.NewVersionParams()
params.Path, err = versions.CreatePath("subject/repo/pkg/version")
params.Desc = "description"
params.VcsTag = "1.1.5"
params.Released = "true"
params.GithubReleaseNotesFile = "RELEASE_1.2.3.txt"
params.GithubUseTagReleaseNotes = "false"
btManager.CreateVersion(params)
btManager.UpdateVersion(params)
params := entitlements.NewEntitlementsParams()
params.VersionPath, err = versions.CreatePath("subject/repo/pkg/version")
params.Path = "a/b/c"
params.Access = "rw"
params.Keys = "keys"
btManager.CreateEntitlement(params)
params.Id = "entitlementID"
btManager.UpdateEntitlement(params)
versionPath, err := versions.CreatePath("subject/repo/pkg/version")
btManager.ShowAllEntitlements(versionPath)
btManager.ShowEntitlement("entitelmentID", versionPath)
btManager.DeleteEntitlement("entitelmentID", versionPath)
params := accesskeys.NewAccessKeysParams()
params.Password = "password"
params.Org = "org"
params.Expiry = time.Now() + time.Hour * 10
params.ExistenceCheckUrl = "http://callbacks.myci.org/username=:username,password=:password"
params.ExistenceCheckCache = 60
params.WhiteCidrs = "127.0.0.1/22,193.5.0.1/92"
params.BlackCidrs = "127.0.0.1/22,193.5.0.1/92"
params.ApiOnly = true
btManager.CreateAccessKey(params)
params.Id = "KeyID"
btManager.UpdateAccessKey(params)
btManager.ShowAllAccessKeys("org")
btManager.ShowAccessKey("org", "KeyID")
btManager.DeleteAccessKey("org", "KeyID")
params := url.NewURLParams()
params.PathDetails, err = utils.CreatePathDetails("subject/repository/file-path")
// Check for errors
params.Expiry = time.Now() + time.Hour * 10
params.ValidFor = 60
params.CallbackId = "callback-id"
params.CallbackEmail = "callback-email"
params.CallbackUrl = "callback-url"
params.CallbackMethod = "callback-method"
btManager.SignUrl(params)
path, err := utils.CreatePathDetails("subject/repository/file-path")
btManager.GpgSignFile(path, "passphrase")
path, err := versions.CreatePath("subject/repo/pkg/version")
btManager.GpgSignVersion(path, "passphrase")
path, err := versions.CreatePath("subject/repo/pkg/version")
btManager.LogsList(versionPath)
path, err := versions.CreatePath("subject/repo/pkg/version")
btManager.DownloadLog(path, "logName")
params := mavensync.NewParams("user","password", false)
path, err = versions.CreatePath("subject/repo/pkg/version")
btManager.MavenCentralContentSync(params, path)
Some APIs return a content.ContentReader which allow reading the API output. Here's an example for how it can be used:
reader, err := servicesManager.SearchFiles(searchParams)
if err != nil {
return err
}
defer reader.Close()
// Iterate over the results.
for currentResult := new(ResultItem); reader.NextRecord(currentResult) == nil; currentResult = new(ResultItem) {
fmt.Printf("Found artifact: %s of type: %s\n", searchResult.Name, searchResult.Type)
}
if err := resultReader.GetError(); err != nil {
return err
}
resultReader.Reset()
reader.NextRecord(currentResult)
loads the next record from the reader into currentResult
of type ResultItem
.
reader.Close()
removes the file used by the reader after it is used (preferably using defer
).
reader.GetError()
any error that may occur during NextRecord()
, can be returned using GetError()
.
reader.Reset()
sets the reader back to the begging of the input.