Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011 GitHub Inc. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: Kevin Sawicki (GitHub Inc.) - initial API and implementation /
 
 package org.eclipse.egit.github.core.service;
 
 import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_KEYS;
 import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_REPOS;
 
 
 import java.util.List;
 
Service for interacting with a repository's deploy keys

See also:
GitHub deploy key API documentation
 
 public class DeployKeyService extends GitHubService {

Create deploy key service
 
 	public DeployKeyService() {
 		super();
 	}

Create deploy key service

Parameters:
client
 
 	public DeployKeyService(GitHubClient client) {
 		super(client);
 	}

Get all deploys keys associated with the given repository

Parameters:
repository
Returns:
non-null but possibly empty list of deploy keys
Throws:
java.io.IOException
 
 	public List<KeygetKeys(IRepositoryIdProvider repository)
 			throws IOException {
 		String id = getId(repository);
 		uri.append('/').append(id);
 		request.setUri(uri);
 		request.setType(new TypeToken<List<Key>>() {
 		}.getType());
 		return getAll(request);
 	}

Get deploy key with given id from given repository

Parameters:
repository
id
Returns:
deploy key
Throws:
java.io.IOException
 
 	public Key getKey(IRepositoryIdProvider repositoryint id)
 			throws IOException {
 		String repoId = getId(repository);
 		uri.append('/').append(repoId);
 		uri.append('/').append(id);
 		GitHubRequest request = createRequest();
 		request.setUri(uri);
 		request.setType(Key.class);
 		return (Key.get(request).getBody();
 	}

Create deploy key to be associated with given repository

Parameters:
repository
key
Returns:
created deploy key
Throws:
java.io.IOException
 
	public Key createKey(IRepositoryIdProvider repositoryKey key)
			throws IOException {
		String id = getId(repository);
		uri.append('/').append(id);
		return .post(uri.toString(), keyKey.class);
	}

Edit given deploy key

Parameters:
repository
key
Returns:
edited deploy key
Throws:
java.io.IOException
	public Key editKey(IRepositoryIdProvider repositoryKey key)
			throws IOException {
		if (key == null)
			throw new IllegalArgumentException("Key cannot be null"); //$NON-NLS-1$
		String repoId = getId(repository);
		uri.append('/').append(repoId);
		uri.append('/').append(key.getId());
		return .post(uri.toString(), keyKey.class);
	}

Deploy deploy key with given id from given repository

Parameters:
repository
id
Throws:
java.io.IOException
	public void deleteKey(IRepositoryIdProvider repositoryint id)
			throws IOException {
		String repoId = getId(repository);
		uri.append('/').append(repoId);
		uri.append('/').append(id);
	}
New to GrepCode? Check out our FAQ X