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 anyKubernetesResource
which possesses aObjectMeta
and is associated with a kind and API version.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DNS_LABEL_END
static String
DNS_LABEL_REGEXP
static String
DNS_LABEL_START
static Pattern
FINALIZER_NAME_MATCHER
Pattern that checks the format of finalizer identifiers, which should be in<domain name>/<finalizer name>
format.static String
REQUIRES_NON_NULL_METADATA
static String
REQUIRES_NON_NULL_NAME
static String
REQUIRES_NON_NULL_NAMESPACE
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default boolean
addFinalizer(String finalizer)
Adds the specified finalizer to thisHasMetadata
if it's valid.default OwnerReference
addOwnerReference(HasMetadata owner)
Adds anOwnerReference
to the specified owner if possible.default OwnerReference
addOwnerReference(OwnerReference ownerReference)
Adds the specified, supposed valid (for example because validated by callingsanitizeAndValidate(OwnerReference)
beforehand),OwnerReference
to thisHasMetadata
default String
getApiVersion()
static String
getApiVersion(Class<?> clazz)
Computes theapiVersion
associated with this HasMetadata implementation.default List<String>
getFinalizers()
default String
getFullResourceName()
static String
getFullResourceName(Class<?> clazz)
static String
getFullResourceName(String plural, String group)
static String
getGroup(Class<?> clazz)
Retrieves the group associated with the specified HasMetadata as defined by theGroup
annotation.default String
getKind()
static String
getKind(Class<?> clazz)
Retrieves the kind associated with the specified HasMetadata implementation.ObjectMeta
getMetadata()
default Optional<OwnerReference>
getOwnerReferenceFor(HasMetadata owner)
Retrieves theOwnerReference
associated with the specified owner if it's part of thisHasMetadata
's owners.default Optional<OwnerReference>
getOwnerReferenceFor(String ownerUid)
Retrieves theOwnerReference
associated with the owner identified by the specified UID if it's part of thisHasMetadata
's owners.default String
getPlural()
static String
getPlural(Class<?> clazz)
Retrieves the plural form associated with the specified class if annotated withPlural
or computes a default value using the value returned bygetSingular(Class)
as input toPluralize.toPlural(String)
.default String
getSingular()
static String
getSingular(Class<?> clazz)
Retrieves the singular form associated with the specified class as defined by theSingular
annotation or computes a default value (lower-cased version of the value returned bygetKind(Class)
) if the annotation is not present.static String
getVersion(Class<?> clazz)
Retrieves the version associated with the specified HasMetadata as defined by theVersion
annotation.default boolean
hasFinalizer(String finalizer)
Determines whether thisHasMetadata
holds the specified finalizer.default boolean
hasOwnerReferenceFor(HasMetadata owner)
Checks whether the providedHasMetadata
is defined as an owner for thisHasMetadata
.default boolean
hasOwnerReferenceFor(String ownerUid)
Checks whether the provided UID identifies an owner for thisHasMetadata
.static ObjectMetaBuilder
initMetadataBuilderNameAndNamespaceFrom(HasMetadata original)
Creates and initializes a newObjectMetaBuilder
with name and namespace (if the provided instance to initialize from represents a namespaced resource) provided by the specified HasMetadata instance.default void
initNameAndNamespaceFrom(HasMetadata original)
Initializes thisObjectMeta
field with name and namespace (if this instance represents a namespaced resource) provided by the specified HasMetadata instance.default boolean
isFinalizerValid(String finalizer)
default boolean
isMarkedForDeletion()
Determines whether thisHasMetadata
is marked for deletion or not.default Optional<ObjectMeta>
optionalMetadata()
default boolean
removeFinalizer(String finalizer)
Removes the specified finalizer if it's held by thisHasMetadata
.default void
removeOwnerReference(HasMetadata owner)
Removes theOwnerReference
associated with the specified owner if it's part of thisHasMetadata
's owner referencesdefault void
removeOwnerReference(String ownerUid)
Removes theOwnerReference
identified by the specified UID if it's part of thisHasMetadata
's owner referencesstatic OwnerReference
sanitizeAndValidate(OwnerReference ownerReference)
Sanitizes and validates the specifiedOwnerReference
, presumably to add itvoid
setApiVersion(String version)
void
setMetadata(ObjectMeta metadata)
static boolean
validateFinalizer(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 theapiVersion
associated with this HasMetadata implementation. The value is derived from theGroup
andVersion
annotations.- Parameters:
clazz
- the HasMetadata whoseapiVersion
we want to compute- Returns:
- the computed
apiVersion
ornull
if neitherGroup
orVersion
annotations are present - Throws:
IllegalArgumentException
- if only one ofGroup
orVersion
is provided
-
getGroup
static String getGroup(Class<?> clazz)
Retrieves the group associated with the specified HasMetadata as defined by theGroup
annotation.- Parameters:
clazz
- the HasMetadata whose group we want to retrieve- Returns:
- the associated group or
null
if the HasMetadata is not annotated withGroup
-
getVersion
static String getVersion(Class<?> clazz)
Retrieves the version associated with the specified HasMetadata as defined by theVersion
annotation.- Parameters:
clazz
- the HasMetadata whose version we want to retrieve- Returns:
- the associated version or
null
if the HasMetadata is not annotated withVersion
-
getPlural
static String getPlural(Class<?> clazz)
Retrieves the plural form associated with the specified class if annotated withPlural
or 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
Plural
annotation or a computed default value
-
getSingular
static String getSingular(Class<?> clazz)
Retrieves the singular form associated with the specified class as defined by theSingular
annotation 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
Singular
annotation 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:
true
if the identifier is valid,false
otherwise
-
sanitizeAndValidate
static OwnerReference sanitizeAndValidate(OwnerReference ownerReference)
Sanitizes and validates the specifiedOwnerReference
, presumably to add it- Parameters:
ownerReference
- theOwnerReference
to sanitize and validate- Returns:
- the sanitized and validated
OwnerReference
which 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 thisHasMetadata
is marked for deletion or not.- Returns:
true
if the cluster marked thisHasMetadata
for deletion,false
otherwise
-
hasFinalizer
default boolean hasFinalizer(String finalizer)
Determines whether thisHasMetadata
holds the specified finalizer.- Parameters:
finalizer
- the identifier of the finalizer we want to check- Returns:
true
if thisHasMetadata
holds the specified finalizer,false
otherwise
-
addFinalizer
default boolean addFinalizer(String finalizer)
Adds the specified finalizer to thisHasMetadata
if it's valid. SeeisFinalizerValid(String)
.- Parameters:
finalizer
- the identifier of the finalizer to add to thisHasMetadata
in<domain name>/<finalizer name>
format.- Returns:
true
if the finalizer was successfully added,false
otherwise (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:
true
if the identifier is valid,false
otherwise- 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:
true
if the finalizer was successfully removed,false
otherwise
-
hasOwnerReferenceFor
default boolean hasOwnerReferenceFor(HasMetadata owner)
Checks whether the providedHasMetadata
is defined as an owner for thisHasMetadata
.- Parameters:
owner
- theHasMetadata
to check for potential ownership- Returns:
true
if the providedHasMetadata
is 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 aHasMetadata
to check for potential ownership- Returns:
true
if the providedHasMetadata
is an owner of this instance
-
getOwnerReferenceFor
default Optional<OwnerReference> getOwnerReferenceFor(HasMetadata owner)
Retrieves theOwnerReference
associated 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
Optional
containing theOwnerReference
associated with the specified owner if it exists orOptional.empty()
otherwise.
-
getOwnerReferenceFor
default Optional<OwnerReference> getOwnerReferenceFor(String ownerUid)
Retrieves theOwnerReference
associated 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
Optional
containing theOwnerReference
associated with the owner identified by the specified UID if it exists orOptional.empty()
otherwise.
-
addOwnerReference
default OwnerReference addOwnerReference(HasMetadata owner)
Adds anOwnerReference
to 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),OwnerReference
to thisHasMetadata
- Parameters:
ownerReference
- theOwnerReference
to add to thisHasMetadata
's owner references- Returns:
- the newly added
OwnerReference
-
removeOwnerReference
default void removeOwnerReference(String ownerUid)
Removes theOwnerReference
identified by the specified UID if it's part of thisHasMetadata
's owner references- Parameters:
ownerUid
- the UID of theOwnerReference
to remove
-
removeOwnerReference
default void removeOwnerReference(HasMetadata owner)
Removes theOwnerReference
associated 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 thisObjectMeta
field 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 newObjectMetaBuilder
with 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
-
-