MCPcopy Index your code
hub / github.com/google/go-github / UserMigrationArchiveURL

Method UserMigrationArchiveURL

github/migrations_user.go:157–185  ·  view source on GitHub ↗

UserMigrationArchiveURL gets the URL for a specific migration archive. id is the migration ID. GitHub API docs: https://docs.github.com/rest/migrations/users?apiVersion=2022-11-28#download-a-user-migration-archive meta:operation GET /user/migrations/{migration_id}/archive

(ctx context.Context, id int64)

Source from the content-addressed store, hash-verified

155//
156//meta:operation GET /user/migrations/{migration_id}/archive
157func (s *MigrationService) UserMigrationArchiveURL(ctx context.Context, id int64) (string, error) {
158 url := fmt.Sprintf("user/migrations/%v/archive", id)
159
160 req, err := s.client.NewRequest(ctx, "GET", url, nil)
161 if err != nil {
162 return "", err
163 }
164
165 req.Header.Set("Accept", mediaTypeMigrationsPreview)
166
167 var loc string
168 originalRedirect := s.client.client.CheckRedirect
169 s.client.client.CheckRedirect = func(req *http.Request, _ []*http.Request) error {
170 loc = req.URL.String()
171 return http.ErrUseLastResponse
172 }
173 defer func() {
174 s.client.client.CheckRedirect = originalRedirect
175 }()
176
177 var m *UserMigration
178 resp, err := s.client.Do(req, &m)
179 if err == nil {
180 return "", errors.New("expected redirect, none provided")
181 }
182
183 loc = resp.Header.Get("Location")
184 return loc, nil
185}
186
187// DeleteUserMigration will delete a previous migration archive.
188// id is the migration ID.

Calls 4

NewRequestMethod · 0.80
StringMethod · 0.45
DoMethod · 0.45
GetMethod · 0.45