Package io.fabric8.kubernetes.api.model
Interface HasMetadata
-
- All Superinterfaces:
KubernetesResource,Serializable
- All Known Implementing Classes:
APIService,Binding,ComponentStatus,ConfigMap,Endpoints,Event,GenericKubernetesResource,LimitRange,Namespace,Node,PersistentVolume,PersistentVolumeClaim,Pod,PodTemplate,ReplicationController,ResourceQuota,Secret,Service,ServiceAccount
public interface HasMetadata extends KubernetesResource
Represents anyKubernetesResourcewhich possesses aObjectMetaand is associated with a kind and API version.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDNS_LABEL_ENDstatic StringDNS_LABEL_REGEXPstatic StringDNS_LABEL_STARTstatic PatternFINALIZER_NAME_MATCHERPattern that checks the format of finalizer identifiers, which should be in<domain name>/<finalizer name>format.static StringREQUIRES_NON_NULL_METADATAstatic StringREQUIRES_NON_NULL_NAMEstatic StringREQUIRES_NON_NULL_NAMESPACE
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleanaddFinalizer(String finalizer)Adds the specified finalizer to thisHasMetadataif it's valid.default OwnerReferenceaddOwnerReference(HasMetadata owner)Adds anOwnerReferenceto the specified owner if possible.default OwnerReferenceaddOwnerReference(OwnerReference ownerReference)Adds the specified, supposed valid (for example because validated by callingsanitizeAndValidate(OwnerReference)beforehand),OwnerReferenceto thisHasMetadatadefault StringgetApiVersion()static StringgetApiVersion(Class<?> clazz)Computes theapiVersionassociated with this HasMetadata implementation.default List<String>getFinalizers()default StringgetFullResourceName()static StringgetFullResourceName(Class<?> clazz)static StringgetFullResourceName(String plural, String group)static StringgetGroup(Class<?> clazz)Retrieves the group associated with the specified HasMetadata as defined by theGroupannotation.default StringgetKind()static StringgetKind(Class<?> clazz)Retrieves the kind associated with the specified HasMetadata implementation.ObjectMetagetMetadata()default Optional<OwnerReference>getOwnerReferenceFor(HasMetadata owner)Retrieves theOwnerReferenceassociated with the specified owner if it's part of thisHasMetadata's owners.default Optional<OwnerReference>getOwnerReferenceFor(String ownerUid)Retrieves theOwnerReferenceassociated with the owner identified by the specified UID if it's part of thisHasMetadata's owners.default StringgetPlural()static StringgetPlural(Class<?> clazz)Retrieves the plural form associated with the specified class if annotated withPluralor computes a default value using the value returned bygetSingular(Class)as input toPluralize.toPlural(String).default StringgetSingular()static StringgetSingular(Class<?> clazz)Retrieves the singular form associated with the specified class as defined by theSingularannotation or computes a default value (lower-cased version of the value returned bygetKind(Class)) if the annotation is not present.static StringgetVersion(Class<?> clazz)Retrieves the version associated with the specified HasMetadata as defined by theVersionannotation.default booleanhasFinalizer(String finalizer)Determines whether thisHasMetadataholds the specified finalizer.default booleanhasOwnerReferenceFor(HasMetadata owner)Checks whether the providedHasMetadatais defined as an owner for thisHasMetadata.default booleanhasOwnerReferenceFor(String ownerUid)Checks whether the provided UID identifies an owner for thisHasMetadata.static ObjectMetaBuilderinitMetadataBuilderNameAndNamespaceFrom(HasMetadata original)Creates and initializes a newObjectMetaBuilderwith name and namespace (if the provided instance to initialize from represents a namespaced resource) provided by the specified HasMetadata instance.default voidinitNameAndNamespaceFrom(HasMetadata original)Initializes thisObjectMetafield with name and namespace (if this instance represents a namespaced resource) provided by the specified HasMetadata instance.default booleanisFinalizerValid(String finalizer)default booleanisMarkedForDeletion()Determines whether thisHasMetadatais marked for deletion or not.default Optional<ObjectMeta>optionalMetadata()default booleanremoveFinalizer(String finalizer)Removes the specified finalizer if it's held by thisHasMetadata.default voidremoveOwnerReference(HasMetadata owner)Removes theOwnerReferenceassociated with the specified owner if it's part of thisHasMetadata's owner referencesdefault voidremoveOwnerReference(String ownerUid)Removes theOwnerReferenceidentified by the specified UID if it's part of thisHasMetadata's owner referencesstatic OwnerReferencesanitizeAndValidate(OwnerReference ownerReference)Sanitizes and validates the specifiedOwnerReference, presumably to add itvoidsetApiVersion(String version)voidsetMetadata(ObjectMeta metadata)static booleanvalidateFinalizer(String finalizer)Determines whether the specified finalizer is valid according to the finalizer specification.
-
-
-
Field Detail
-
DNS_LABEL_START
static final String DNS_LABEL_START
- See Also:
- Constant Field Values
-
DNS_LABEL_END
static final String DNS_LABEL_END
- See Also:
- Constant Field Values
-
DNS_LABEL_REGEXP
static final String DNS_LABEL_REGEXP
- See Also:
- Constant Field Values
-
FINALIZER_NAME_MATCHER
static final Pattern FINALIZER_NAME_MATCHER
Pattern that checks the format of finalizer identifiers, which should be in<domain name>/<finalizer name>format.
-
REQUIRES_NON_NULL_METADATA
static final String REQUIRES_NON_NULL_METADATA
- See Also:
- Constant Field Values
-
REQUIRES_NON_NULL_NAME
static final String REQUIRES_NON_NULL_NAME
- See Also:
- Constant Field Values
-
REQUIRES_NON_NULL_NAMESPACE
static final String REQUIRES_NON_NULL_NAMESPACE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getKind
static String getKind(Class<?> clazz)
Retrieves the kind associated with the specified HasMetadata implementation. If the implementation is annotated withKind, the annotation value will be used, otherwise the value will be derived from the class name.- Parameters:
clazz- the HasMetadata implementation whose Kind we want to retrieve- Returns:
- the kind associated with the specified HasMetadata
-
getApiVersion
static String getApiVersion(Class<?> clazz)
Computes theapiVersionassociated with this HasMetadata implementation. The value is derived from theGroupandVersionannotations.- Parameters:
clazz- the HasMetadata whoseapiVersionwe want to compute- Returns:
- the computed
apiVersionornullif neitherGrouporVersionannotations are present - Throws:
IllegalArgumentException- if only one ofGrouporVersionis provided
-
getGroup
static String getGroup(Class<?> clazz)
Retrieves the group associated with the specified HasMetadata as defined by theGroupannotation.- Parameters:
clazz- the HasMetadata whose group we want to retrieve- Returns:
- the associated group or
nullif the HasMetadata is not annotated withGroup
-
getVersion
static String getVersion(Class<?> clazz)
Retrieves the version associated with the specified HasMetadata as defined by theVersionannotation.- Parameters:
clazz- the HasMetadata whose version we want to retrieve- Returns:
- the associated version or
nullif the HasMetadata is not annotated withVersion
-
getPlural
static String getPlural(Class<?> clazz)
Retrieves the plural form associated with the specified class if annotated withPluralor computes a default value using the value returned bygetSingular(Class)as input toPluralize.toPlural(String).- Parameters:
clazz- the CustomResource whose plural form we want to retrieve- Returns:
- the plural form defined by the
Pluralannotation or a computed default value
-
getSingular
static String getSingular(Class<?> clazz)
Retrieves the singular form associated with the specified class as defined by theSingularannotation or computes a default value (lower-cased version of the value returned bygetKind(Class)) if the annotation is not present.- Parameters:
clazz- the class whose singular form we want to retrieve- Returns:
- the singular form defined by the
Singularannotation or a computed default value
-
validateFinalizer
static boolean validateFinalizer(String finalizer)
Determines whether the specified finalizer is valid according to the finalizer specification.- Parameters:
finalizer- the identifier of the finalizer which validity we want to check- Returns:
trueif the identifier is valid,falseotherwise
-
sanitizeAndValidate
static OwnerReference sanitizeAndValidate(OwnerReference ownerReference)
Sanitizes and validates the specifiedOwnerReference, presumably to add it- Parameters:
ownerReference- theOwnerReferenceto sanitize and validate- Returns:
- the sanitized and validated
OwnerReferencewhich should be used instead of the original one
-
getMetadata
ObjectMeta getMetadata()
-
setMetadata
void setMetadata(ObjectMeta metadata)
-
getKind
default String getKind()
-
getApiVersion
default String getApiVersion()
-
setApiVersion
void setApiVersion(String version)
-
getPlural
default String getPlural()
-
getSingular
default String getSingular()
-
getFullResourceName
default String getFullResourceName()
-
isMarkedForDeletion
default boolean isMarkedForDeletion()
Determines whether thisHasMetadatais marked for deletion or not.- Returns:
trueif the cluster marked thisHasMetadatafor deletion,falseotherwise
-
hasFinalizer
default boolean hasFinalizer(String finalizer)
Determines whether thisHasMetadataholds the specified finalizer.- Parameters:
finalizer- the identifier of the finalizer we want to check- Returns:
trueif thisHasMetadataholds the specified finalizer,falseotherwise
-
addFinalizer
default boolean addFinalizer(String finalizer)
Adds the specified finalizer to thisHasMetadataif it's valid. SeeisFinalizerValid(String).- Parameters:
finalizer- the identifier of the finalizer to add to thisHasMetadatain<domain name>/<finalizer name>format.- Returns:
trueif the finalizer was successfully added,falseotherwise (in particular, if the object is marked for deletion)- Throws:
IllegalArgumentException- if the specified finalizer identifier is null or is invalid
-
isFinalizerValid
default boolean isFinalizerValid(String finalizer)
- Parameters:
finalizer- the identifier of the finalizer which validity we want to check- Returns:
trueif the identifier is valid,falseotherwise- See Also:
validateFinalizer(String)
-
removeFinalizer
default boolean removeFinalizer(String finalizer)
Removes the specified finalizer if it's held by thisHasMetadata.- Parameters:
finalizer- the identifier of the finalizer we want to remove- Returns:
trueif the finalizer was successfully removed,falseotherwise
-
hasOwnerReferenceFor
default boolean hasOwnerReferenceFor(HasMetadata owner)
Checks whether the providedHasMetadatais defined as an owner for thisHasMetadata.- Parameters:
owner- theHasMetadatato check for potential ownership- Returns:
trueif the providedHasMetadatais an owner of this instance
-
hasOwnerReferenceFor
default boolean hasOwnerReferenceFor(String ownerUid)
Checks whether the provided UID identifies an owner for thisHasMetadata.- Parameters:
ownerUid- the UID of aHasMetadatato check for potential ownership- Returns:
trueif the providedHasMetadatais an owner of this instance
-
getOwnerReferenceFor
default Optional<OwnerReference> getOwnerReferenceFor(HasMetadata owner)
Retrieves theOwnerReferenceassociated with the specified owner if it's part of thisHasMetadata's owners.- Parameters:
owner- the potential owner of which we want to retrieve the associatedOwnerReference- Returns:
- an
Optionalcontaining theOwnerReferenceassociated with the specified owner if it exists orOptional.empty()otherwise.
-
getOwnerReferenceFor
default Optional<OwnerReference> getOwnerReferenceFor(String ownerUid)
Retrieves theOwnerReferenceassociated with the owner identified by the specified UID if it's part of thisHasMetadata's owners.- Parameters:
ownerUid- the UID of the potential owner of which we want to retrieve the associatedOwnerReference- Returns:
- an
Optionalcontaining theOwnerReferenceassociated with the owner identified by the specified UID if it exists orOptional.empty()otherwise.
-
addOwnerReference
default OwnerReference addOwnerReference(HasMetadata owner)
Adds anOwnerReferenceto the specified owner if possible.- Parameters:
owner- the owner to add a reference to- Returns:
- the newly added
OwnerReference
-
addOwnerReference
default OwnerReference addOwnerReference(OwnerReference ownerReference)
Adds the specified, supposed valid (for example because validated by callingsanitizeAndValidate(OwnerReference)beforehand),OwnerReferenceto thisHasMetadata- Parameters:
ownerReference- theOwnerReferenceto add to thisHasMetadata's owner references- Returns:
- the newly added
OwnerReference
-
removeOwnerReference
default void removeOwnerReference(String ownerUid)
Removes theOwnerReferenceidentified by the specified UID if it's part of thisHasMetadata's owner references- Parameters:
ownerUid- the UID of theOwnerReferenceto remove
-
removeOwnerReference
default void removeOwnerReference(HasMetadata owner)
Removes theOwnerReferenceassociated with the specified owner if it's part of thisHasMetadata's owner references- Parameters:
owner- the owner whose reference we want to remove
-
optionalMetadata
default Optional<ObjectMeta> optionalMetadata()
-
initNameAndNamespaceFrom
default void initNameAndNamespaceFrom(HasMetadata original)
Initializes thisObjectMetafield with name and namespace (if this instance represents a namespaced resource) provided by the specified HasMetadata instance. This is a convenience method to avoid boilerplate, notably when using Server-Side Apply, when creating a new instance with only some fields of the original one. CallssetMetadata(ObjectMeta)when done, if you want to further configure this instance's metadata, please useinitMetadataBuilderNameAndNamespaceFrom(HasMetadata)instead, which doesn't sets the metadata, leaving it up to the user once configuration is finished.- Parameters:
original- a HasMetadata instance from which to retrieve the name and namespace
-
initMetadataBuilderNameAndNamespaceFrom
static ObjectMetaBuilder initMetadataBuilderNameAndNamespaceFrom(HasMetadata original)
Creates and initializes a newObjectMetaBuilderwith name and namespace (if the provided instance to initialize from represents a namespaced resource) provided by the specified HasMetadata instance. This is a convenience method to avoid boilerplate, notably when using Server-Side Apply, when creating a new instance with only some fields of the original one. This method assumes that further configuration will occur on the newly created ObjectMetaBuilder.- Parameters:
original- an HasMetadata instance from which to retrieve the name and namespace- Returns:
- a new ObjectMetaBuilder instance initialized with the name and namespace (if needed) of the specified HasMetadata
-
-