Package org.jdrupes.vmoperator.common
Class K8s
java.lang.Object
org.jdrupes.vmoperator.common.K8s
Helpers for K8s API.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends io.kubernetes.client.common.KubernetesObject,LT extends io.kubernetes.client.common.KubernetesListObject>
TApply the given patch data.static Optional<io.kubernetes.client.Discovery.APIResource> Lookup the specified API resource.static voidcreateEvent(io.kubernetes.client.openapi.ApiClient client, io.kubernetes.client.common.KubernetesObject object, io.kubernetes.client.openapi.models.EventsV1Event event) Creates an event related to the object, adding reasonable defaults.static io.kubernetes.client.openapi.models.V1ObjectReferenceobjectReference(io.kubernetes.client.common.KubernetesObject object) Create an object reference.static <T extends io.kubernetes.client.common.KubernetesType>
Optional<T> optional(io.kubernetes.client.util.generic.KubernetesApiResponse<T> response) Returns the result from an API call asOptionalif the call was successful.static io.kubernetes.client.Discovery.APIResourceReturns a new context with the given version as preferred version.static StringtoString(io.kubernetes.client.Discovery.APIResource context) Return a string representation of the context (API resource).static com.google.gson.JsonObjectyamlToJson(io.kubernetes.client.openapi.ApiClient client, Reader yaml) Convert Yaml to Json.
-
Constructor Details
-
K8s
public K8s()
-
-
Method Details
-
optional
public static <T extends io.kubernetes.client.common.KubernetesType> Optional<T> optional(io.kubernetes.client.util.generic.KubernetesApiResponse<T> response) throws io.kubernetes.client.openapi.ApiException Returns the result from an API call asOptionalif the call was successful.Returns an empty
Optionalif the status code is 404 (not found). Else throws an exception.- Type Parameters:
T- the generic type- Parameters:
response- the response- Returns:
- the optional
- Throws:
io.kubernetes.client.openapi.ApiException- the API exception
-
preferred
public static io.kubernetes.client.Discovery.APIResource preferred(io.kubernetes.client.Discovery.APIResource context, String version) Returns a new context with the given version as preferred version.- Parameters:
context- the contextversion- the version- Returns:
- the API resource
-
toString
Return a string representation of the context (API resource).- Parameters:
context- the context- Returns:
- the string
-
yamlToJson
public static com.google.gson.JsonObject yamlToJson(io.kubernetes.client.openapi.ApiClient client, Reader yaml) Convert Yaml to Json.- Parameters:
client- the clientyaml- the yaml- Returns:
- the json element
-
context
public static Optional<io.kubernetes.client.Discovery.APIResource> context(io.kubernetes.client.openapi.ApiClient client, String group, String version, String kind) throws io.kubernetes.client.openapi.ApiException Lookup the specified API resource.If the version is
nullor empty, the preferred version in the result is the default returned from the server.- Parameters:
client- the clientgroup- the groupversion- the versionkind- the kind- Returns:
- the optional
- Throws:
io.kubernetes.client.openapi.ApiException- the api exception
-
apply
public static <T extends io.kubernetes.client.common.KubernetesObject,LT extends io.kubernetes.client.common.KubernetesListObject> T apply(io.kubernetes.client.util.generic.GenericKubernetesApi<T, LT> api, T existing, String update) throws io.kubernetes.client.openapi.ApiExceptionApply the given patch data.- Type Parameters:
T- the generic typeLT- the generic type- Parameters:
api- the apiexisting- the existingupdate- the update- Returns:
- the t
- Throws:
io.kubernetes.client.openapi.ApiException- the api exception
-
objectReference
public static io.kubernetes.client.openapi.models.V1ObjectReference objectReference(io.kubernetes.client.common.KubernetesObject object) Create an object reference.- Parameters:
object- the object- Returns:
- the v 1 object reference
-
createEvent
public static void createEvent(io.kubernetes.client.openapi.ApiClient client, io.kubernetes.client.common.KubernetesObject object, io.kubernetes.client.openapi.models.EventsV1Event event) throws io.kubernetes.client.openapi.ApiException Creates an event related to the object, adding reasonable defaults.- If
kindis not set, it is set to “Event”.- If
metadata.namespaceis not set, it is set to the object’s namespace. - If neither
metadata.namenormatadata.generateNameare set, setgenerateNameto the object’s name with a dash appended. - If
reportingInstanceis not set, set it to the object’s name. - If
eventTimeis not set, set it to now. - If
typeis not set, set it to “Normal” - If
regardingis not set, set it to the given object.
- If
- Parameters:
client- the clientobject- the objectevent- the event- Throws:
io.kubernetes.client.openapi.ApiException- the api exception
- If
-