We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please add ability to get or set a team's property privacy (see https://developer.github.com/v3/teams/#parameters). Current version 1.94.
privacy
1.94
Usecases
Affected API elements (list may not exchaustive):
Class GHTeam
Class GHOrganization
Methods createTeam
This is my workaround using in my groovy scripts currently:
// File kohsuke_github_workarounds.groovy // Use it with import kohsuke_github_workarounds @Grab(group='org.kohsuke', module='github-api', version='1.94') import org.kohsuke.github.* // Works around https://github.com/kohsuke/github-api/issues/455 static void setPrivacy (String token, GHTeam team, String privacy) { allowMethods('PATCH') def jsonString = "{ \"name\": \"${team.getName()}\", \"privacy\": \"$privacy\" }" def con = "https://api.github.com/teams/${team.getId()}".toURL().openConnection() con.setDoOutput(true) con.setDoInput(true) con.setRequestMethod("PATCH"); con.setRequestProperty("Authorization", "token $token") con.setRequestProperty("Content-Type", "application/json") con.connect() con.outputStream.withWriter { writer -> writer << jsonString } String response = con.inputStream.withReader { Reader reader -> reader.text } } import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.net.HttpURLConnection; import java.net.URL; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.Set; private static void allowMethods(String... methods) { try { Field methodsField = HttpURLConnection.class.getDeclaredField("methods"); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(methodsField, methodsField.getModifiers() & ~Modifier.FINAL); methodsField.setAccessible(true); String[] oldMethods = (String[]) methodsField.get(null); Set<String> methodsSet = new LinkedHashSet<>(Arrays.asList(oldMethods)); methodsSet.addAll(Arrays.asList(methods)); String[] newMethods = methodsSet.toArray(new String[0]); methodsField.set(null/*static field*/, newMethods); } catch (NoSuchFieldException | IllegalAccessException e) { throw new IllegalStateException(e); } }
The text was updated successfully, but these errors were encountered:
It would be good to have support for this :)
Sorry, something went wrong.
This + more is covered in: #683
Successfully merging a pull request may close this issue.
Please add ability to get or set a team's property
privacy
(see https://developer.github.com/v3/teams/#parameters). Current version1.94
.Usecases
Affected API elements (list may not exchaustive):
Class GHTeam
Class GHOrganization
Methods createTeam
(2x)(Dirty) workaround
This is my workaround using in my groovy scripts currently:
The text was updated successfully, but these errors were encountered: