cloud-8.x-2.0-beta1/modules/cloud_service_providers/k8s/src/Entity/K8sReplicaSet.php
modules/cloud_service_providers/k8s/src/Entity/K8sReplicaSet.php
<?php
namespace Drupal\k8s\Entity;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
* Defines the ReplicaSet entity.
*
* @ingroup k8s
*
* @ContentEntityType(
* id = "k8s_replica_set",
* label = @Translation("Kubernetes Replica Set"),
* handlers = {
* "view_builder" = "Drupal\k8s\Entity\K8sReplicaSetViewBuilder",
* "list_builder" = "Drupal\cloud\Controller\CloudContentListBuilder",
* "views_data" = "Drupal\k8s\Entity\K8sReplicaSetViewsData",
* "access" = "Drupal\k8s\Controller\K8sReplicaSetAccessControlHandler",
* "form" = {
* "add" = "Drupal\k8s\Form\K8sCreateForm",
* "edit" = "Drupal\k8s\Form\K8sEditForm",
* "delete" = "Drupal\k8s\Form\K8sDeleteForm",
* "delete-multiple-confirm" = "Drupal\k8s\Form\K8sDeleteMultipleForm",
* },
* "route_provider" = {
* "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
* },
* },
* base_table = "k8s_replica_set",
* admin_permission = "administer k8s replica set",
* fieldable = TRUE,
* entity_keys = {
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid",
* },
* links = {
* "canonical" = "/clouds/k8s/{cloud_context}/replica_set/{k8s_replica_set}",
* "collection" = "/clouds/k8s/{cloud_context}/replica_set",
* "add-form" = "/clouds/k8s/{cloud_context}/replica_set/add",
* "edit-form" = "/clouds/k8s/{cloud_context}/replica_set/{k8s_replica_set}/edit",
* "delete-form" = "/clouds/k8s/{cloud_context}/replica_set/{k8s_replica_set}/delete",
* "delete-multiple-form" = "/clouds/k8s/{cloud_context}/replica_set/delete_multiple",
* },
* field_ui_base_route = "k8s_replica_set.settings"
* )
*/
class K8sReplicaSet extends K8sEntityBase implements K8sReplicaSetInterface {
/**
* {@inheritdoc}
*/
public function getName() {
return $this->get('name')->value;
}
/**
* {@inheritdoc}
*/
public function setName($name) {
return $this->set('name', $name);
}
/**
* {@inheritdoc}
*/
public function getNamespace() {
return $this->get('namespace')->value;
}
/**
* {@inheritdoc}
*/
public function setNamespace($namespace) {
return $this->set('namespace', $namespace);
}
/**
* {@inheritdoc}
*/
public function getLabels() {
return $this->get('labels');
}
/**
* {@inheritdoc}
*/
public function setLabels($labels) {
return $this->set('labels', $labels);
}
/**
* {@inheritdoc}
*/
public function getAnnotations() {
return $this->get('annotations');
}
/**
* {@inheritdoc}
*/
public function setAnnotations($annotations) {
return $this->set('annotations', $annotations);
}
/**
* {@inheritdoc}
*/
public function getReplicas() {
return $this->get('replicas');
}
/**
* {@inheritdoc}
*/
public function setReplicas($replicas) {
return $this->set('replicas', $replicas);
}
/**
* {@inheritdoc}
*/
public function getSelector() {
return $this->get('selector');
}
/**
* {@inheritdoc}
*/
public function setSelector($selector) {
return $this->set('selector', $selector);
}
/**
* {@inheritdoc}
*/
public function getTemplate() {
return $this->get('template');
}
/**
* {@inheritdoc}
*/
public function setTemplate($template) {
return $this->set('template', $template);
}
/**
* {@inheritdoc}
*/
public function getConditions() {
return $this->get('conditions');
}
/**
* {@inheritdoc}
*/
public function setConditions($conditions) {
return $this->set('conditions', $conditions);
}
/**
* {@inheritdoc}
*/
public function getAvailableReplicas() {
return $this->get('available_replicas');
}
/**
* {@inheritdoc}
*/
public function setAvailableReplicas($available_replicas) {
return $this->set('available_replicas', $available_replicas);
}
/**
* {@inheritdoc}
*/
public function getFullyLabeledReplicas() {
return $this->get('fully_labeled_replicas');
}
/**
* {@inheritdoc}
*/
public function setFullyLabeledReplicas($fully_labeled_replicas) {
return $this->set('fully_labeled_replicas', $fully_labeled_replicas);
}
/**
* {@inheritdoc}
*/
public function getReadyReplicas() {
return $this->get('ready_replicas');
}
/**
* {@inheritdoc}
*/
public function setReadyReplicas($ready_replicas) {
return $this->set('ready_replicas', $ready_replicas);
}
/**
* {@inheritdoc}
*/
public function getObservedGeneration() {
return $this->get('observed_generation');
}
/**
* {@inheritdoc}
*/
public function setObservedGeneration($observed_generation) {
return $this->set('observed_generation', $observed_generation);
}
/**
* {@inheritdoc}
*/
public function getDetail() {
return $this->get('detail')->value;
}
/**
* {@inheritdoc}
*/
public function setDetail($detail) {
return $this->set('detail', $detail);
}
/**
* {@inheritdoc}
*/
public function getRefreshed() {
return $this->get('refreshed')->value;
}
/**
* {@inheritdoc}
*/
public function setRefreshed($time) {
return $this->set('refreshed', $time);
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['id'] = BaseFieldDefinition::create('integer')
->setLabel(t('ID'))
->setDescription(t('The ID of the Replica Set entity.'))
->setReadOnly(TRUE);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The UUID of the Replica Set entity.'))
->setReadOnly(TRUE);
$fields['cloud_context'] = BaseFieldDefinition::create('string')
->setRequired(TRUE)
->setLabel(t('Cloud Service Provider ID'))
->setDescription(t('A unique machine name for the cloud service provider.'))
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'string',
'weight' => -5,
]);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The replica set name.'))
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'string',
'weight' => -5,
])
->setReadOnly(TRUE);
$fields['namespace'] = BaseFieldDefinition::create('string')
->setLabel(t('Namespace'))
->setDescription(t('The namespace of replica set.'))
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'string',
'weight' => -5,
])
->setReadOnly(TRUE);
$fields['labels'] = BaseFieldDefinition::create('key_value')
->setLabel(t('Labels'))
->setDescription(t('Map of string keys and values that can be used to organize and categorize (scope and select) objects.'))
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
->setDisplayOptions('view', [
'type' => 'key_value_formatter',
'weight' => -5,
]);
$fields['annotations'] = BaseFieldDefinition::create('key_value')
->setLabel(t('Annotations'))
->setDescription(t('Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata.'))
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
->setSetting('max_length', 4096)
->setDisplayOptions('view', [
'type' => 'key_value_formatter',
'weight' => -5,
]);
$fields['replicas'] = BaseFieldDefinition::create('integer')
->setLabel(t('Replica'))
->setDescription(t('Total number of non-terminated pods on manifest.'))
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'string',
'weight' => -5,
])
->setReadOnly(TRUE);
$fields['selector'] = BaseFieldDefinition::create('string_long')
->setLabel(t('Selector'))
->setDescription(t('Label selector on manifest'))
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'string',
'weight' => -5,
])
->setReadOnly(TRUE);
$fields['template'] = BaseFieldDefinition::create('string_long')
->setLabel(t('Template'))
->setDescription(t('Template used for pod'))
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'string',
'weight' => -5,
])
->setReadOnly(TRUE);
$fields['available_replicas'] = BaseFieldDefinition::create('integer')
->setLabel(t('Available Replicas'))
->setDescription(t('The number of available replicas (ready for at least minReadySeconds) for this replica set.'))
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'string',
'weight' => -5,
])
->setReadOnly(TRUE);
$fields['fully_labeled_replicas'] = BaseFieldDefinition::create('integer')
->setLabel(t('Fully Labeled Replicas'))
->setDescription(t('The number of pods that have labels matching the labels of the pod template of the replicaset.'))
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'string',
'weight' => -5,
])
->setReadOnly(TRUE);
$fields['conditions'] = BaseFieldDefinition::create('integer')
->setLabel(t('Conditions'))
->setDescription(t('Represents the latest available observations of current state of a replica set.'))
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'string',
'weight' => -5,
])
->setReadOnly(TRUE);
$fields['observed_generation'] = BaseFieldDefinition::create('integer')
->setLabel(t('Observed Generation'))
->setDescription(t('ObservedGeneration reflects the generation of the most recently observed ReplicaSet.'))
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'string',
'weight' => -5,
])
->setReadOnly(TRUE);
$fields['ready_replicas'] = BaseFieldDefinition::create('integer')
->setLabel(t('Ready Replicas'))
->setDescription(t('The number of ready replicas for this replica set.'))
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'string',
'weight' => -5,
])
->setReadOnly(TRUE);
$fields['detail'] = BaseFieldDefinition::create('string_long')
->setLabel(t('Detail'))
->setDescription(t('Deployment detail.'))
->setRequired(TRUE)
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'pre_string_formatter',
'weight' => -5,
])
->setDisplayOptions('form', [
'type' => 'string_textarea',
'settings' => [
'rows' => 20,
],
])
->addConstraint('yaml_array_data');
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the entity was created.'));
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the entity was last edited.'));
$fields['refreshed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Refreshed'))
->setDescription(t('The time that the entity was last refreshed.'));
$fields['uid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Authored by'))
->setDescription(t('The user ID of the Pod entity author.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setDefaultValueCallback('Drupal\node\Entity\Node::getCurrentUserId')
->setTranslatable(TRUE)
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'author',
'weight' => 0,
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
],
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
return $fields;
}
}
