text:
package main

import (
	"bytes"
	"flag"
	"fmt"
	"github.com/golang/glog"
	"github.com/spf13/pflag"
	"io"
	"k8s.io/kops/dns-controller/pkg/dns"
	"k8s.io/kops/protokube/pkg/gossip"
	gossipdns "k8s.io/kops/protokube/pkg/gossip/dns"
	"k8s.io/kops/protokube/pkg/gossip/mesh"
	"k8s.io/kops/protokube/pkg/protokube"
	"k8s.io/kubernetes/federation/pkg/dnsprovider"
	"net"
	"os"
	"path"
	"strings"

	// Load DNS plugins
	_ "k8s.io/kubernetes/federation/pkg/dnsprovider/providers/aws/route53"
	k8scoredns "k8s.io/kubernetes/federation/pkg/dnsprovider/providers/coredns"
	_ "k8s.io/kubernetes/federation/pkg/dnsprovider/providers/google/clouddns"
)

var (
	flags = pflag.NewFlagSet("", pflag.ExitOnError)

	// value overwritten during build. This can be used to resolve issues.
	BuildVersion = "0.1"
)

func main() {
	fmt.Printf("protokube version %s\n", BuildVersion)

	err := run()
	if err != nil {
		glog.Errorf("Error: %v", err)
		os.Exit(1)
	}
	os.Exit(0)
}

func run() error {
	dnsProviderId := "aws-route53"
	flags.StringVar(&dnsProviderId, "dns", dnsProviderId, "DNS provider we should use (aws-route53, google-clouddns, coredns)")

	var zones []string
	flags.StringSliceVarP(&zones, "zone", "z", []string{}, "Configure permitted zones and their mappings")

	master := false
	flag.BoolVar(&master, "master", master, "Act as master")

	applyTaints := false
	flag.BoolVar(&applyTaints, "apply-taints", applyTaints, "Apply taints to nodes based on the role")

	initializeRBAC := false
	flag.BoolVar(&initializeRBAC, "initialize-rbac", initializeRBAC, "Set if we should initialize RBAC")

	containerized := false
	flag.BoolVar(&containerized, "containerized", containerized, "Set if we are running containerized.")

	cloud := "aws"
	flag.StringVar(&cloud, "cloud", cloud, "CloudProvider we are using (aws,gce)")

	dnsInternalSuffix := ""
	flag.StringVar(&dnsInternalSuffix, "dns-internal-suffix", dnsInternalSuffix, "DNS suffix for internal domain names")

	clusterID := ""
	flag.StringVar(&clusterID, "cluster-id", clusterID, "Cluster ID")

	dnsServer := ""
	flag.StringVar(&dnsServer, "dns-server", dnsServer, "DNS Server")

	flagChannels := ""
	flag.StringVar(&flagChannels, "channels", flagChannels, "channels to install")

	gossipListen := "0.0.0.0:3999"
	flag.StringVar(&gossipListen, "gossip-listen", gossipListen, "address:port on which to bind for gossip")

	var gossipSecret string
	flags.StringVar(&gossipSecret, "gossip-secret", gossipSecret, "Secret to use to secure gossip")

	// Trick to avoid 'logging before flag.Parse' warning
	flag.CommandLine.Parse([]string{})

	flag.Set("logtostderr", "true")

	flags.AddGoFlagSet(flag.CommandLine)

	flags.Parse(os.Args)

	var volumes protokube.Volumes
	var internalIP net.IP

	if cloud == "aws" {
		awsVolumes, err := protokube.NewAWSVolumes()
		if err != nil {
			glog.Errorf("Error initializing AWS: %q", err)
			os.Exit(1)
		}
		volumes = awsVolumes

		if clusterID == "" {
			clusterID = awsVolumes.ClusterID()
		}
		if internalIP == nil {
			internalIP = awsVolumes.InternalIP()
		}
	} else if cloud == "gce" {
		gceVolumes, err := protokube.NewGCEVolumes()
		if err != nil {
			glog.Errorf("Error initializing GCE: %q", err)
			os.Exit(1)
		}

		volumes = gceVolumes

		//gceProject = gceVolumes.Project()

		if clusterID == "" {
			clusterID = gceVolumes.ClusterID()
		}

		if internalIP == nil {
			internalIP = gceVolumes.InternalIP()
		}
	} else if cloud == "vsphere" {
		glog.Info("Initializing vSphere volumes")
		vsphereVolumes, err := protokube.NewVSphereVolumes()
		if err != nil {
			glog.Errorf("Error initializing vSphere: %q", err)
			os.Exit(1)
		}
		volumes = vsphereVolumes
		if internalIP == nil {
			internalIP = vsphereVolumes.InternalIp()
		}

	} else {
		glog.Errorf("Unknown cloud %q", cloud)
		os.Exit(1)
	}

	if clusterID == "" {
		if clusterID == "" {
			return fmt.Errorf("cluster-id is required (cannot be determined from cloud)")
		} else {
			glog.Infof("Setting cluster-id from cloud: %s", clusterID)
		}
	}

	if internalIP == nil {
		glog.Errorf("Cannot determine internal IP")
		os.Exit(1)
	}

	if dnsInternalSuffix == "" {
		// TODO: Maybe only master needs DNS?
		dnsInternalSuffix = ".internal." + clusterID
		glog.Infof("Setting dns-internal-suffix to %q", dnsInternalSuffix)
	}

	// Make sure it's actually a suffix (starts with .)
	if !strings.HasPrefix(dnsInternalSuffix, ".") {
		dnsInternalSuffix = "." + dnsInternalSuffix
	}

	// Get internal IP from cloud, to avoid problems if we're in a container
	// TODO: Just run with --net=host ??
	//internalIP, err := findInternalIP()
	//if err != nil {
	//	glog.Errorf("Error finding internal IP: %q", err)
	//	os.Exit(1)
	//}

	rootfs := "/"
	if containerized {
		rootfs = "/rootfs/"
	}
	protokube.RootFS = rootfs
	protokube.Containerized = containerized

	var dnsProvider protokube.DNSProvider
	if dnsProviderId == "gossip" {
		dnsTarget := &gossipdns.HostsFile{
			Path: path.Join(rootfs, "etc/hosts"),
		}

		var gossipSeeds gossip.SeedProvider
		var err error
		var gossipName string
		if cloud == "aws" {
			gossipSeeds, err = volumes.(*protokube.AWSVolumes).GossipSeeds()
			if err != nil {
				return err
			}
			gossipName = volumes.(*protokube.AWSVolumes).InstanceID()
		} else if cloud == "gce" {
			gossipSeeds, err = volumes.(*protokube.GCEVolumes).GossipSeeds()
			if err != nil {
				return err
			}
			gossipName = volumes.(*protokube.GCEVolumes).InstanceName()
		} else {
			glog.Fatalf("seed provider for %q not yet implemented", cloud)
		}

		id := os.Getenv("HOSTNAME")
		if id == "" {
			glog.Warningf("Unable to fetch HOSTNAME for use as node identifier")
		}

		channelName := "dns"
		gossipState, err := mesh.NewMeshGossiper(gossipListen, channelName, gossipName, []byte(gossipSecret), gossipSeeds)
		if err != nil {
			glog.Errorf("Error initializing gossip: %v", err)
			os.Exit(1)
		}

		go func() {
			err := gossipState.Start()
			if err != nil {
				glog.Fatalf("gossip exited unexpectedly: %v", err)
			} else {
				glog.Fatalf("gossip exited unexpectedly, but without error")
			}
		}()

		dnsView := gossipdns.NewDNSView(gossipState)
		go func() {
			gossipdns.RunDNSUpdates(dnsTarget, dnsView)
			glog.Fatalf("RunDNSUpdates exited unexpectedly")
		}()

		zoneInfo := gossipdns.DNSZoneInfo{
			Name: gossipdns.DefaultZoneName,
		}
		dnsProvider = &protokube.GossipDnsProvider{DNSView: dnsView, Zone: zoneInfo}
	} else {
		var dnsScope dns.Scope
		var dnsController *dns.DNSController
		{
			var file io.Reader
			if dnsProviderId == k8scoredns.ProviderName {
				var lines []string
				lines = append(lines, "etcd-endpoints = "+dnsServer)
				lines = append(lines, "zones = "+zones[0])
				config := "[global]\n" + strings.Join(lines, "\n") + "\n"
				file = bytes.NewReader([]byte(config))
			}

			dnsProvider, err := dnsprovider.GetDnsProvider(dnsProviderId, file)
			if err != nil {
				return fmt.Errorf("Error initializing DNS provider %q: %v", dnsProviderId, err)
			}
			if dnsProvider == nil {
				return fmt.Errorf("DNS provider %q could not be initialized", dnsProviderId)
			}

			zoneRules, err := dns.ParseZoneRules(zones)
			if err != nil {
				return fmt.Errorf("unexpected zone flags: %q", err)
			}

			dnsController, err = dns.NewDNSController([]dnsprovider.Interface{dnsProvider}, zoneRules)
			if err != nil {
				return err
			}

			dnsScope, err = dnsController.CreateScope("protokube")
			if err != nil {
				return err
			}

			// We don't really use readiness - our records are simple
			dnsScope.MarkReady()
		}

		dnsProvider = &protokube.KopsDnsProvider{
			DNSScope:      dnsScope,
			DNSController: dnsController,
		}
	}

	modelDir := "model/etcd"

	var channels []string
	if flagChannels != "" {
		channels = strings.Split(flagChannels, ",")
	}

	k := &protokube.KubeBoot{
		Master:            master,
		ApplyTaints:       applyTaints,
		InternalDNSSuffix: dnsInternalSuffix,
		InternalIP:        internalIP,
		//MasterID          : fromVolume
		//EtcdClusters   : fromVolume

		InitializeRBAC: initializeRBAC,

		ModelDir: modelDir,
		DNS:      dnsProvider,

		Channels: channels,

		Kubernetes: protokube.NewKubernetesContext(),
	}
	k.Init(volumes)

	if dnsProvider != nil {
		go dnsProvider.Run()
	}

	k.RunSyncLoop()

	return fmt.Errorf("Unexpected exit")
}

// TODO: run with --net=host ??
func findInternalIP() (net.IP, error) {
	var ips []net.IP

	networkInterfaces, err := net.Interfaces()
	if err != nil {
		return nil, fmt.Errorf("error querying interfaces to determine internal ip: %v", err)
	}

	for i := range networkInterfaces {
		networkInterface := &networkInterfaces[i]
		flags := networkInterface.Flags
		name := networkInterface.Name

		if (flags & net.FlagLoopback) != 0 {
			glog.V(2).Infof("Ignoring interface %s - loopback", name)
			continue
		}

		// Not a lot else to go on...
		if !strings.HasPrefix(name, "eth") {
			glog.V(2).Infof("Ignoring interface %s - name does not look like ethernet device", name)
			continue
		}

		addrs, err := networkInterface.Addrs()
		if err != nil {
			return nil, fmt.Errorf("error querying network interface %s for IP adddresses: %v", name, err)
		}

		for _, addr := range addrs {
			ip, _, err := net.ParseCIDR(addr.String())
			if err != nil {
				return nil, fmt.Errorf("error parsing address %s on network interface %s: %v", addr.String(), name, err)
			}

			if ip.IsLoopback() {
				glog.V(2).Infof("Ignoring address %s (loopback)", ip)
				continue
			}

			if ip.IsLinkLocalMulticast() || ip.IsLinkLocalUnicast() {
				glog.V(2).Infof("Ignoring address %s (link-local)", ip)
				continue
			}

			ips = append(ips, ip)
		}
	}

	if len(ips) == 0 {
		return nil, fmt.Errorf("unable to determine internal ip (no adddresses found)")
	}

	if len(ips) != 1 {
		glog.Warningf("Found multiple internal IPs; making arbitrary choice")
		for _, ip := range ips {
			glog.Warningf("\tip: %s", ip.String())
		}
	}
	return ips[0], nil
}


text:
module Google
  module Cloud
    module AIPlatform
      module V1
        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#create_featurestore FeaturestoreService.CreateFeaturestore}.
        # @!attribute [rw] parent
        #   @return [::String]
        #     Required. The resource name of the Location to create Featurestores.
        #     Format:
        #     `projects/{project}/locations/{location}'`
        # @!attribute [rw] featurestore
        #   @return [::Google::Cloud::AIPlatform::V1::Featurestore]
        #     Required. The Featurestore to create.
        # @!attribute [rw] featurestore_id
        #   @return [::String]
        #     Required. The ID to use for this Featurestore, which will become the final component
        #     of the Featurestore's resource name.
        #
        #     This value may be up to 60 characters, and valid characters are
        #     `[a-z0-9_]`. The first character cannot be a number.
        #
        #     The value must be unique within the project and location.
        class CreateFeaturestoreRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#get_featurestore FeaturestoreService.GetFeaturestore}.
        # @!attribute [rw] name
        #   @return [::String]
        #     Required. The name of the Featurestore resource.
        class GetFeaturestoreRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#list_featurestores FeaturestoreService.ListFeaturestores}.
        # @!attribute [rw] parent
        #   @return [::String]
        #     Required. The resource name of the Location to list Featurestores.
        #     Format:
        #     `projects/{project}/locations/{location}`
        # @!attribute [rw] filter
        #   @return [::String]
        #     Lists the featurestores that match the filter expression. The following
        #     fields are supported:
        #
        #     * `create_time`: Supports `=`, `!=`, `<`, `>`, `<=`, and `>=` comparisons.
        #     Values must be
        #       in RFC 3339 format.
        #     * `update_time`: Supports `=`, `!=`, `<`, `>`, `<=`, and `>=` comparisons.
        #     Values must be
        #       in RFC 3339 format.
        #     * `online_serving_config.fixed_node_count`: Supports `=`, `!=`, `<`, `>`,
        #     `<=`, and `>=` comparisons.
        #     * `labels`: Supports key-value equality and key presence.
        #
        #     Examples:
        #
        #     * `create_time > "2020-01-01" OR update_time > "2020-01-01"`
        #        Featurestores created or updated after 2020-01-01.
        #     * `labels.env = "prod"`
        #        Featurestores with label "env" set to "prod".
        # @!attribute [rw] page_size
        #   @return [::Integer]
        #     The maximum number of Featurestores to return. The service may return fewer
        #     than this value. If unspecified, at most 100 Featurestores will be
        #     returned. The maximum value is 100; any value greater than 100 will be
        #     coerced to 100.
        # @!attribute [rw] page_token
        #   @return [::String]
        #     A page token, received from a previous
        #     {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#list_featurestores FeaturestoreService.ListFeaturestores} call.
        #     Provide this to retrieve the subsequent page.
        #
        #     When paginating, all other parameters provided to
        #     {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#list_featurestores FeaturestoreService.ListFeaturestores} must
        #     match the call that provided the page token.
        # @!attribute [rw] order_by
        #   @return [::String]
        #     A comma-separated list of fields to order by, sorted in ascending order.
        #     Use "desc" after a field name for descending.
        #     Supported Fields:
        #
        #       * `create_time`
        #       * `update_time`
        #       * `online_serving_config.fixed_node_count`
        # @!attribute [rw] read_mask
        #   @return [::Google::Protobuf::FieldMask]
        #     Mask specifying which fields to read.
        class ListFeaturestoresRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Response message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#list_featurestores FeaturestoreService.ListFeaturestores}.
        # @!attribute [rw] featurestores
        #   @return [::Array<::Google::Cloud::AIPlatform::V1::Featurestore>]
        #     The Featurestores matching the request.
        # @!attribute [rw] next_page_token
        #   @return [::String]
        #     A token, which can be sent as {::Google::Cloud::AIPlatform::V1::ListFeaturestoresRequest#page_token ListFeaturestoresRequest.page_token} to
        #     retrieve the next page.
        #     If this field is omitted, there are no subsequent pages.
        class ListFeaturestoresResponse
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#update_featurestore FeaturestoreService.UpdateFeaturestore}.
        # @!attribute [rw] featurestore
        #   @return [::Google::Cloud::AIPlatform::V1::Featurestore]
        #     Required. The Featurestore's `name` field is used to identify the Featurestore to be
        #     updated.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}`
        # @!attribute [rw] update_mask
        #   @return [::Google::Protobuf::FieldMask]
        #     Field mask is used to specify the fields to be overwritten in the
        #     Featurestore resource by the update.
        #     The fields specified in the update_mask are relative to the resource, not
        #     the full request. A field will be overwritten if it is in the mask. If the
        #     user does not provide a mask then only the non-empty fields present in the
        #     request will be overwritten. Set the update_mask to `*` to override all
        #     fields.
        #
        #     Updatable fields:
        #
        #       * `labels`
        #       * `online_serving_config.fixed_node_count`
        #       * `online_serving_config.scaling`
        class UpdateFeaturestoreRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#delete_featurestore FeaturestoreService.DeleteFeaturestore}.
        # @!attribute [rw] name
        #   @return [::String]
        #     Required. The name of the Featurestore to be deleted.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}`
        # @!attribute [rw] force
        #   @return [::Boolean]
        #     If set to true, any EntityTypes and Features for this Featurestore will
        #     also be deleted. (Otherwise, the request will only work if the Featurestore
        #     has no EntityTypes.)
        class DeleteFeaturestoreRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#import_feature_values FeaturestoreService.ImportFeatureValues}.
        # @!attribute [rw] avro_source
        #   @return [::Google::Cloud::AIPlatform::V1::AvroSource]
        # @!attribute [rw] bigquery_source
        #   @return [::Google::Cloud::AIPlatform::V1::BigQuerySource]
        # @!attribute [rw] csv_source
        #   @return [::Google::Cloud::AIPlatform::V1::CsvSource]
        # @!attribute [rw] feature_time_field
        #   @return [::String]
        #     Source column that holds the Feature timestamp for all Feature
        #     values in each entity.
        # @!attribute [rw] feature_time
        #   @return [::Google::Protobuf::Timestamp]
        #     Single Feature timestamp for all entities being imported. The
        #     timestamp must not have higher than millisecond precision.
        # @!attribute [rw] entity_type
        #   @return [::String]
        #     Required. The resource name of the EntityType grouping the Features for which values
        #     are being imported. Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entityType}`
        # @!attribute [rw] entity_id_field
        #   @return [::String]
        #     Source column that holds entity IDs. If not provided, entity IDs are
        #     extracted from the column named `entity_id`.
        # @!attribute [rw] feature_specs
        #   @return [::Array<::Google::Cloud::AIPlatform::V1::ImportFeatureValuesRequest::FeatureSpec>]
        #     Required. Specifications defining which Feature values to import from the entity. The
        #     request fails if no feature_specs are provided, and having multiple
        #     feature_specs for one Feature is not allowed.
        # @!attribute [rw] disable_online_serving
        #   @return [::Boolean]
        #     If set, data will not be imported for online serving. This
        #     is typically used for backfilling, where Feature generation timestamps are
        #     not in the timestamp range needed for online serving.
        # @!attribute [rw] worker_count
        #   @return [::Integer]
        #     Specifies the number of workers that are used to write data to the
        #     Featurestore. Consider the online serving capacity that you require to
        #     achieve the desired import throughput without interfering with online
        #     serving. The value must be positive, and less than or equal to 100.
        #     If not set, defaults to using 1 worker. The low count ensures minimal
        #     impact on online serving performance.
        # @!attribute [rw] disable_ingestion_analysis
        #   @return [::Boolean]
        #     If true, API doesn't start ingestion analysis pipeline.
        class ImportFeatureValuesRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods

          # Defines the Feature value(s) to import.
          # @!attribute [rw] id
          #   @return [::String]
          #     Required. ID of the Feature to import values of. This Feature must exist in the
          #     target EntityType, or the request will fail.
          # @!attribute [rw] source_field
          #   @return [::String]
          #     Source column to get the Feature values from. If not set, uses the column
          #     with the same name as the Feature ID.
          class FeatureSpec
            include ::Google::Protobuf::MessageExts
            extend ::Google::Protobuf::MessageExts::ClassMethods
          end
        end

        # Response message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#import_feature_values FeaturestoreService.ImportFeatureValues}.
        # @!attribute [rw] imported_entity_count
        #   @return [::Integer]
        #     Number of entities that have been imported by the operation.
        # @!attribute [rw] imported_feature_value_count
        #   @return [::Integer]
        #     Number of Feature values that have been imported by the operation.
        # @!attribute [rw] invalid_row_count
        #   @return [::Integer]
        #     The number of rows in input source that weren't imported due to either
        #     * Not having any featureValues.
        #     * Having a null entityId.
        #     * Having a null timestamp.
        #     * Not being parsable (applicable for CSV sources).
        # @!attribute [rw] timestamp_outside_retention_rows_count
        #   @return [::Integer]
        #     The number rows that weren't ingested due to having feature timestamps
        #     outside the retention boundary.
        class ImportFeatureValuesResponse
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#batch_read_feature_values FeaturestoreService.BatchReadFeatureValues}.
        # @!attribute [rw] csv_read_instances
        #   @return [::Google::Cloud::AIPlatform::V1::CsvSource]
        #     Each read instance consists of exactly one read timestamp and one or more
        #     entity IDs identifying entities of the corresponding EntityTypes whose
        #     Features are requested.
        #
        #     Each output instance contains Feature values of requested entities
        #     concatenated together as of the read time.
        #
        #     An example read instance may be `foo_entity_id, bar_entity_id,
        #     2020-01-01T10:00:00.123Z`.
        #
        #     An example output instance may be `foo_entity_id, bar_entity_id,
        #     2020-01-01T10:00:00.123Z, foo_entity_feature1_value,
        #     bar_entity_feature2_value`.
        #
        #     Timestamp in each read instance must be millisecond-aligned.
        #
        #     `csv_read_instances` are read instances stored in a plain-text CSV file.
        #     The header should be:
        #         [ENTITY_TYPE_ID1], [ENTITY_TYPE_ID2], ..., timestamp
        #
        #     The columns can be in any order.
        #
        #     Values in the timestamp column must use the RFC 3339 format, e.g.
        #     `2012-07-30T10:43:17.123Z`.
        # @!attribute [rw] bigquery_read_instances
        #   @return [::Google::Cloud::AIPlatform::V1::BigQuerySource]
        #     Similar to csv_read_instances, but from BigQuery source.
        # @!attribute [rw] featurestore
        #   @return [::String]
        #     Required. The resource name of the Featurestore from which to query Feature values.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}`
        # @!attribute [rw] destination
        #   @return [::Google::Cloud::AIPlatform::V1::FeatureValueDestination]
        #     Required. Specifies output location and format.
        # @!attribute [rw] pass_through_fields
        #   @return [::Array<::Google::Cloud::AIPlatform::V1::BatchReadFeatureValuesRequest::PassThroughField>]
        #     When not empty, the specified fields in the *_read_instances source will be
        #     joined as-is in the output, in addition to those fields from the
        #     Featurestore Entity.
        #
        #     For BigQuery source, the type of the pass-through values will be
        #     automatically inferred. For CSV source, the pass-through values will be
        #     passed as opaque bytes.
        # @!attribute [rw] entity_type_specs
        #   @return [::Array<::Google::Cloud::AIPlatform::V1::BatchReadFeatureValuesRequest::EntityTypeSpec>]
        #     Required. Specifies EntityType grouping Features to read values of and settings.
        #     Each EntityType referenced in
        #     [BatchReadFeatureValuesRequest.entity_type_specs] must have a column
        #     specifying entity IDs in the EntityType in
        #     [BatchReadFeatureValuesRequest.request][] .
        # @!attribute [rw] start_time
        #   @return [::Google::Protobuf::Timestamp]
        #     Optional. Excludes Feature values with feature generation timestamp before this
        #     timestamp. If not set, retrieve oldest values kept in Feature Store.
        #     Timestamp, if present, must not have higher than millisecond precision.
        class BatchReadFeatureValuesRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods

          # Describe pass-through fields in read_instance source.
          # @!attribute [rw] field_name
          #   @return [::String]
          #     Required. The name of the field in the CSV header or the name of the column in
          #     BigQuery table. The naming restriction is the same as {::Google::Cloud::AIPlatform::V1::Feature#name Feature.name}.
          class PassThroughField
            include ::Google::Protobuf::MessageExts
            extend ::Google::Protobuf::MessageExts::ClassMethods
          end

          # Selects Features of an EntityType to read values of and specifies read
          # settings.
          # @!attribute [rw] entity_type_id
          #   @return [::String]
          #     Required. ID of the EntityType to select Features. The EntityType id is the
          #     {::Google::Cloud::AIPlatform::V1::CreateEntityTypeRequest#entity_type_id entity_type_id} specified
          #     during EntityType creation.
          # @!attribute [rw] feature_selector
          #   @return [::Google::Cloud::AIPlatform::V1::FeatureSelector]
          #     Required. Selectors choosing which Feature values to read from the EntityType.
          # @!attribute [rw] settings
          #   @return [::Array<::Google::Cloud::AIPlatform::V1::DestinationFeatureSetting>]
          #     Per-Feature settings for the batch read.
          class EntityTypeSpec
            include ::Google::Protobuf::MessageExts
            extend ::Google::Protobuf::MessageExts::ClassMethods
          end
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#export_feature_values FeaturestoreService.ExportFeatureValues}.
        # @!attribute [rw] snapshot_export
        #   @return [::Google::Cloud::AIPlatform::V1::ExportFeatureValuesRequest::SnapshotExport]
        #     Exports the latest Feature values of all entities of the EntityType
        #     within a time range.
        # @!attribute [rw] full_export
        #   @return [::Google::Cloud::AIPlatform::V1::ExportFeatureValuesRequest::FullExport]
        #     Exports all historical values of all entities of the EntityType within a
        #     time range
        # @!attribute [rw] entity_type
        #   @return [::String]
        #     Required. The resource name of the EntityType from which to export Feature values.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}`
        # @!attribute [rw] destination
        #   @return [::Google::Cloud::AIPlatform::V1::FeatureValueDestination]
        #     Required. Specifies destination location and format.
        # @!attribute [rw] feature_selector
        #   @return [::Google::Cloud::AIPlatform::V1::FeatureSelector]
        #     Required. Selects Features to export values of.
        # @!attribute [rw] settings
        #   @return [::Array<::Google::Cloud::AIPlatform::V1::DestinationFeatureSetting>]
        #     Per-Feature export settings.
        class ExportFeatureValuesRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods

          # Describes exporting the latest Feature values of all entities of the
          # EntityType between [start_time, snapshot_time].
          # @!attribute [rw] snapshot_time
          #   @return [::Google::Protobuf::Timestamp]
          #     Exports Feature values as of this timestamp. If not set,
          #     retrieve values as of now. Timestamp, if present, must not have higher
          #     than millisecond precision.
          # @!attribute [rw] start_time
          #   @return [::Google::Protobuf::Timestamp]
          #     Excludes Feature values with feature generation timestamp before this
          #     timestamp. If not set, retrieve oldest values kept in Feature Store.
          #     Timestamp, if present, must not have higher than millisecond precision.
          class SnapshotExport
            include ::Google::Protobuf::MessageExts
            extend ::Google::Protobuf::MessageExts::ClassMethods
          end

          # Describes exporting all historical Feature values of all entities of the
          # EntityType between [start_time, end_time].
          # @!attribute [rw] start_time
          #   @return [::Google::Protobuf::Timestamp]
          #     Excludes Feature values with feature generation timestamp before this
          #     timestamp. If not set, retrieve oldest values kept in Feature Store.
          #     Timestamp, if present, must not have higher than millisecond precision.
          # @!attribute [rw] end_time
          #   @return [::Google::Protobuf::Timestamp]
          #     Exports Feature values as of this timestamp. If not set,
          #     retrieve values as of now. Timestamp, if present, must not have higher
          #     than millisecond precision.
          class FullExport
            include ::Google::Protobuf::MessageExts
            extend ::Google::Protobuf::MessageExts::ClassMethods
          end
        end

        # @!attribute [rw] feature_id
        #   @return [::String]
        #     Required. The ID of the Feature to apply the setting to.
        # @!attribute [rw] destination_field
        #   @return [::String]
        #     Specify the field name in the export destination. If not specified,
        #     Feature ID is used.
        class DestinationFeatureSetting
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # A destination location for Feature values and format.
        # @!attribute [rw] bigquery_destination
        #   @return [::Google::Cloud::AIPlatform::V1::BigQueryDestination]
        #     Output in BigQuery format.
        #     {::Google::Cloud::AIPlatform::V1::BigQueryDestination#output_uri BigQueryDestination.output_uri} in
        #     {::Google::Cloud::AIPlatform::V1::FeatureValueDestination#bigquery_destination FeatureValueDestination.bigquery_destination} must refer to a table.
        # @!attribute [rw] tfrecord_destination
        #   @return [::Google::Cloud::AIPlatform::V1::TFRecordDestination]
        #     Output in TFRecord format.
        #
        #     Below are the mapping from Feature value type
        #     in Featurestore to Feature value type in TFRecord:
        #
        #         Value type in Featurestore                 | Value type in TFRecord
        #         DOUBLE, DOUBLE_ARRAY                       | FLOAT_LIST
        #         INT64, INT64_ARRAY                         | INT64_LIST
        #         STRING, STRING_ARRAY, BYTES                | BYTES_LIST
        #         true -> byte_string("true"), false -> byte_string("false")
        #         BOOL, BOOL_ARRAY (true, false)             | BYTES_LIST
        # @!attribute [rw] csv_destination
        #   @return [::Google::Cloud::AIPlatform::V1::CsvDestination]
        #     Output in CSV format. Array Feature value types are not allowed in CSV
        #     format.
        class FeatureValueDestination
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Response message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#export_feature_values FeaturestoreService.ExportFeatureValues}.
        class ExportFeatureValuesResponse
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Response message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#batch_read_feature_values FeaturestoreService.BatchReadFeatureValues}.
        class BatchReadFeatureValuesResponse
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#create_entity_type FeaturestoreService.CreateEntityType}.
        # @!attribute [rw] parent
        #   @return [::String]
        #     Required. The resource name of the Featurestore to create EntityTypes.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}`
        # @!attribute [rw] entity_type
        #   @return [::Google::Cloud::AIPlatform::V1::EntityType]
        #     The EntityType to create.
        # @!attribute [rw] entity_type_id
        #   @return [::String]
        #     Required. The ID to use for the EntityType, which will become the final component of
        #     the EntityType's resource name.
        #
        #     This value may be up to 60 characters, and valid characters are
        #     `[a-z0-9_]`. The first character cannot be a number.
        #
        #     The value must be unique within a featurestore.
        class CreateEntityTypeRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#get_entity_type FeaturestoreService.GetEntityType}.
        # @!attribute [rw] name
        #   @return [::String]
        #     Required. The name of the EntityType resource.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}`
        class GetEntityTypeRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#list_entity_types FeaturestoreService.ListEntityTypes}.
        # @!attribute [rw] parent
        #   @return [::String]
        #     Required. The resource name of the Featurestore to list EntityTypes.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}`
        # @!attribute [rw] filter
        #   @return [::String]
        #     Lists the EntityTypes that match the filter expression. The following
        #     filters are supported:
        #
        #     * `create_time`: Supports `=`, `!=`, `<`, `>`, `>=`, and `<=` comparisons.
        #     Values must be in RFC 3339 format.
        #     * `update_time`: Supports `=`, `!=`, `<`, `>`, `>=`, and `<=` comparisons.
        #     Values must be in RFC 3339 format.
        #     * `labels`: Supports key-value equality as well as key presence.
        #
        #     Examples:
        #
        #     * `create_time > \"2020-01-31T15:30:00.000000Z\" OR
        #          update_time > \"2020-01-31T15:30:00.000000Z\"` --> EntityTypes created
        #          or updated after 2020-01-31T15:30:00.000000Z.
        #     * `labels.active = yes AND labels.env = prod` --> EntityTypes having both
        #         (active: yes) and (env: prod) labels.
        #     * `labels.env: *` --> Any EntityType which has a label with 'env' as the
        #       key.
        # @!attribute [rw] page_size
        #   @return [::Integer]
        #     The maximum number of EntityTypes to return. The service may return fewer
        #     than this value. If unspecified, at most 1000 EntityTypes will be returned.
        #     The maximum value is 1000; any value greater than 1000 will be coerced to
        #     1000.
        # @!attribute [rw] page_token
        #   @return [::String]
        #     A page token, received from a previous
        #     {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#list_entity_types FeaturestoreService.ListEntityTypes} call.
        #     Provide this to retrieve the subsequent page.
        #
        #     When paginating, all other parameters provided to
        #     {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#list_entity_types FeaturestoreService.ListEntityTypes} must
        #     match the call that provided the page token.
        # @!attribute [rw] order_by
        #   @return [::String]
        #     A comma-separated list of fields to order by, sorted in ascending order.
        #     Use "desc" after a field name for descending.
        #
        #     Supported fields:
        #
        #       * `entity_type_id`
        #       * `create_time`
        #       * `update_time`
        # @!attribute [rw] read_mask
        #   @return [::Google::Protobuf::FieldMask]
        #     Mask specifying which fields to read.
        class ListEntityTypesRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Response message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#list_entity_types FeaturestoreService.ListEntityTypes}.
        # @!attribute [rw] entity_types
        #   @return [::Array<::Google::Cloud::AIPlatform::V1::EntityType>]
        #     The EntityTypes matching the request.
        # @!attribute [rw] next_page_token
        #   @return [::String]
        #     A token, which can be sent as {::Google::Cloud::AIPlatform::V1::ListEntityTypesRequest#page_token ListEntityTypesRequest.page_token} to
        #     retrieve the next page.
        #     If this field is omitted, there are no subsequent pages.
        class ListEntityTypesResponse
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#update_entity_type FeaturestoreService.UpdateEntityType}.
        # @!attribute [rw] entity_type
        #   @return [::Google::Cloud::AIPlatform::V1::EntityType]
        #     Required. The EntityType's `name` field is used to identify the EntityType to be
        #     updated.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}`
        # @!attribute [rw] update_mask
        #   @return [::Google::Protobuf::FieldMask]
        #     Field mask is used to specify the fields to be overwritten in the
        #     EntityType resource by the update.
        #     The fields specified in the update_mask are relative to the resource, not
        #     the full request. A field will be overwritten if it is in the mask. If the
        #     user does not provide a mask then only the non-empty fields present in the
        #     request will be overwritten. Set the update_mask to `*` to override all
        #     fields.
        #
        #     Updatable fields:
        #
        #       * `description`
        #       * `labels`
        #       * `monitoring_config.snapshot_analysis.disabled`
        #       * `monitoring_config.snapshot_analysis.monitoring_interval_days`
        #       * `monitoring_config.snapshot_analysis.staleness_days`
        #       * `monitoring_config.import_features_analysis.state`
        #       * `monitoring_config.import_features_analysis.anomaly_detection_baseline`
        #       * `monitoring_config.numerical_threshold_config.value`
        #       * `monitoring_config.categorical_threshold_config.value`
        class UpdateEntityTypeRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for [FeaturestoreService.DeleteEntityTypes][].
        # @!attribute [rw] name
        #   @return [::String]
        #     Required. The name of the EntityType to be deleted.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}`
        # @!attribute [rw] force
        #   @return [::Boolean]
        #     If set to true, any Features for this EntityType will also be deleted.
        #     (Otherwise, the request will only work if the EntityType has no Features.)
        class DeleteEntityTypeRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#create_feature FeaturestoreService.CreateFeature}.
        # @!attribute [rw] parent
        #   @return [::String]
        #     Required. The resource name of the EntityType to create a Feature.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}`
        # @!attribute [rw] feature
        #   @return [::Google::Cloud::AIPlatform::V1::Feature]
        #     Required. The Feature to create.
        # @!attribute [rw] feature_id
        #   @return [::String]
        #     Required. The ID to use for the Feature, which will become the final component of
        #     the Feature's resource name.
        #
        #     This value may be up to 128 characters, and valid characters are
        #     `[a-z0-9_]`. The first character cannot be a number.
        #
        #     The value must be unique within an EntityType.
        class CreateFeatureRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#batch_create_features FeaturestoreService.BatchCreateFeatures}.
        # @!attribute [rw] parent
        #   @return [::String]
        #     Required. The resource name of the EntityType to create the batch of Features under.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}`
        # @!attribute [rw] requests
        #   @return [::Array<::Google::Cloud::AIPlatform::V1::CreateFeatureRequest>]
        #     Required. The request message specifying the Features to create. All Features must be
        #     created under the same parent EntityType. The `parent` field in each child
        #     request message can be omitted. If `parent` is set in a child request, then
        #     the value must match the `parent` value in this request message.
        class BatchCreateFeaturesRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Response message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#batch_create_features FeaturestoreService.BatchCreateFeatures}.
        # @!attribute [rw] features
        #   @return [::Array<::Google::Cloud::AIPlatform::V1::Feature>]
        #     The Features created.
        class BatchCreateFeaturesResponse
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#get_feature FeaturestoreService.GetFeature}.
        # @!attribute [rw] name
        #   @return [::String]
        #     Required. The name of the Feature resource.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}`
        class GetFeatureRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#list_features FeaturestoreService.ListFeatures}.
        # @!attribute [rw] parent
        #   @return [::String]
        #     Required. The resource name of the Location to list Features.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}`
        # @!attribute [rw] filter
        #   @return [::String]
        #     Lists the Features that match the filter expression. The following
        #     filters are supported:
        #
        #     * `value_type`: Supports = and != comparisons.
        #     * `create_time`: Supports =, !=, <, >, >=, and <= comparisons. Values must
        #     be in RFC 3339 format.
        #     * `update_time`: Supports =, !=, <, >, >=, and <= comparisons. Values must
        #     be in RFC 3339 format.
        #     * `labels`: Supports key-value equality as well as key presence.
        #
        #     Examples:
        #
        #     * `value_type = DOUBLE` --> Features whose type is DOUBLE.
        #     * `create_time > \"2020-01-31T15:30:00.000000Z\" OR
        #          update_time > \"2020-01-31T15:30:00.000000Z\"` --> EntityTypes created
        #          or updated after 2020-01-31T15:30:00.000000Z.
        #     * `labels.active = yes AND labels.env = prod` --> Features having both
        #         (active: yes) and (env: prod) labels.
        #     * `labels.env: *` --> Any Feature which has a label with 'env' as the
        #       key.
        # @!attribute [rw] page_size
        #   @return [::Integer]
        #     The maximum number of Features to return. The service may return fewer
        #     than this value. If unspecified, at most 1000 Features will be returned.
        #     The maximum value is 1000; any value greater than 1000 will be coerced to
        #     1000.
        # @!attribute [rw] page_token
        #   @return [::String]
        #     A page token, received from a previous
        #     {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#list_features FeaturestoreService.ListFeatures} call.
        #     Provide this to retrieve the subsequent page.
        #
        #     When paginating, all other parameters provided to
        #     {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#list_features FeaturestoreService.ListFeatures} must
        #     match the call that provided the page token.
        # @!attribute [rw] order_by
        #   @return [::String]
        #     A comma-separated list of fields to order by, sorted in ascending order.
        #     Use "desc" after a field name for descending.
        #     Supported fields:
        #
        #       * `feature_id`
        #       * `value_type`
        #       * `create_time`
        #       * `update_time`
        # @!attribute [rw] read_mask
        #   @return [::Google::Protobuf::FieldMask]
        #     Mask specifying which fields to read.
        # @!attribute [rw] latest_stats_count
        #   @return [::Integer]
        #     If set, return the most recent {::Google::Cloud::AIPlatform::V1::ListFeaturesRequest#latest_stats_count ListFeaturesRequest.latest_stats_count}
        #     of stats for each Feature in response. Valid value is [0, 10]. If number of
        #     stats exists < {::Google::Cloud::AIPlatform::V1::ListFeaturesRequest#latest_stats_count ListFeaturesRequest.latest_stats_count}, return all
        #     existing stats.
        class ListFeaturesRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Response message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#list_features FeaturestoreService.ListFeatures}.
        # @!attribute [rw] features
        #   @return [::Array<::Google::Cloud::AIPlatform::V1::Feature>]
        #     The Features matching the request.
        # @!attribute [rw] next_page_token
        #   @return [::String]
        #     A token, which can be sent as {::Google::Cloud::AIPlatform::V1::ListFeaturesRequest#page_token ListFeaturesRequest.page_token} to
        #     retrieve the next page.
        #     If this field is omitted, there are no subsequent pages.
        class ListFeaturesResponse
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#search_features FeaturestoreService.SearchFeatures}.
        # @!attribute [rw] location
        #   @return [::String]
        #     Required. The resource name of the Location to search Features.
        #     Format:
        #     `projects/{project}/locations/{location}`
        # @!attribute [rw] query
        #   @return [::String]
        #     Query string that is a conjunction of field-restricted queries and/or
        #     field-restricted filters.  Field-restricted queries and filters can be
        #     combined using `AND` to form a conjunction.
        #
        #     A field query is in the form FIELD:QUERY. This implicitly checks if QUERY
        #     exists as a substring within Feature's FIELD. The QUERY
        #     and the FIELD are converted to a sequence of words (i.e. tokens) for
        #     comparison. This is done by:
        #
        #       * Removing leading/trailing whitespace and tokenizing the search value.
        #       Characters that are not one of alphanumeric `[a-zA-Z0-9]`, underscore
        #       `_`, or asterisk `*` are treated as delimiters for tokens. `*` is treated
        #       as a wildcard that matches characters within a token.
        #       * Ignoring case.
        #       * Prepending an asterisk to the first and appending an asterisk to the
        #       last token in QUERY.
        #
        #     A QUERY must be either a singular token or a phrase. A phrase is one or
        #     multiple words enclosed in double quotation marks ("). With phrases, the
        #     order of the words is important. Words in the phrase must be matching in
        #     order and consecutively.
        #
        #     Supported FIELDs for field-restricted queries:
        #
        #     * `feature_id`
        #     * `description`
        #     * `entity_type_id`
        #
        #     Examples:
        #
        #     * `feature_id: foo` --> Matches a Feature with ID containing the substring
        #     `foo` (eg. `foo`, `foofeature`, `barfoo`).
        #     * `feature_id: foo*feature` --> Matches a Feature with ID containing the
        #     substring `foo*feature` (eg. `foobarfeature`).
        #     * `feature_id: foo AND description: bar` --> Matches a Feature with ID
        #     containing the substring `foo` and description containing the substring
        #     `bar`.
        #
        #
        #     Besides field queries, the following exact-match filters are
        #     supported. The exact-match filters do not support wildcards. Unlike
        #     field-restricted queries, exact-match filters are case-sensitive.
        #
        #     * `feature_id`: Supports = comparisons.
        #     * `description`: Supports = comparisons. Multi-token filters should be
        #     enclosed in quotes.
        #     * `entity_type_id`: Supports = comparisons.
        #     * `value_type`: Supports = and != comparisons.
        #     * `labels`: Supports key-value equality as well as key presence.
        #     * `featurestore_id`: Supports = comparisons.
        #
        #     Examples:
        #     * `description = "foo bar"` --> Any Feature with description exactly equal
        #     to `foo bar`
        #     * `value_type = DOUBLE` --> Features whose type is DOUBLE.
        #     * `labels.active = yes AND labels.env = prod` --> Features having both
        #         (active: yes) and (env: prod) labels.
        #     * `labels.env: *` --> Any Feature which has a label with `env` as the
        #       key.
        # @!attribute [rw] page_size
        #   @return [::Integer]
        #     The maximum number of Features to return. The service may return fewer
        #     than this value. If unspecified, at most 100 Features will be returned.
        #     The maximum value is 100; any value greater than 100 will be coerced to
        #     100.
        # @!attribute [rw] page_token
        #   @return [::String]
        #     A page token, received from a previous
        #     {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#search_features FeaturestoreService.SearchFeatures} call.
        #     Provide this to retrieve the subsequent page.
        #
        #     When paginating, all other parameters provided to
        #     {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#search_features FeaturestoreService.SearchFeatures}, except `page_size`, must
        #     match the call that provided the page token.
        class SearchFeaturesRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Response message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#search_features FeaturestoreService.SearchFeatures}.
        # @!attribute [rw] features
        #   @return [::Array<::Google::Cloud::AIPlatform::V1::Feature>]
        #     The Features matching the request.
        #
        #     Fields returned:
        #
        #      * `name`
        #      * `description`
        #      * `labels`
        #      * `create_time`
        #      * `update_time`
        # @!attribute [rw] next_page_token
        #   @return [::String]
        #     A token, which can be sent as {::Google::Cloud::AIPlatform::V1::SearchFeaturesRequest#page_token SearchFeaturesRequest.page_token} to
        #     retrieve the next page.
        #     If this field is omitted, there are no subsequent pages.
        class SearchFeaturesResponse
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#update_feature FeaturestoreService.UpdateFeature}.
        # @!attribute [rw] feature
        #   @return [::Google::Cloud::AIPlatform::V1::Feature]
        #     Required. The Feature's `name` field is used to identify the Feature to be
        #     updated.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}/features/{feature}`
        # @!attribute [rw] update_mask
        #   @return [::Google::Protobuf::FieldMask]
        #     Field mask is used to specify the fields to be overwritten in the
        #     Features resource by the update.
        #     The fields specified in the update_mask are relative to the resource, not
        #     the full request. A field will be overwritten if it is in the mask. If the
        #     user does not provide a mask then only the non-empty fields present in the
        #     request will be overwritten. Set the update_mask to `*` to override all
        #     fields.
        #
        #     Updatable fields:
        #
        #       * `description`
        #       * `labels`
        #       * `disable_monitoring`
        class UpdateFeatureRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Request message for {::Google::Cloud::AIPlatform::V1::FeaturestoreService::Client#delete_feature FeaturestoreService.DeleteFeature}.
        # @!attribute [rw] name
        #   @return [::String]
        #     Required. The name of the Features to be deleted.
        #     Format:
        #     `projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}/features/{feature}`
        class DeleteFeatureRequest
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Details of operations that perform create Featurestore.
        # @!attribute [rw] generic_metadata
        #   @return [::Google::Cloud::AIPlatform::V1::GenericOperationMetadata]
        #     Operation metadata for Featurestore.
        class CreateFeaturestoreOperationMetadata
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Details of operations that perform update Featurestore.
        # @!attribute [rw] generic_metadata
        #   @return [::Google::Cloud::AIPlatform::V1::GenericOperationMetadata]
        #     Operation metadata for Featurestore.
        class UpdateFeaturestoreOperationMetadata
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Details of operations that perform import Feature values.
        # @!attribute [rw] generic_metadata
        #   @return [::Google::Cloud::AIPlatform::V1::GenericOperationMetadata]
        #     Operation metadata for Featurestore import Feature values.
        # @!attribute [rw] imported_entity_count
        #   @return [::Integer]
        #     Number of entities that have been imported by the operation.
        # @!attribute [rw] imported_feature_value_count
        #   @return [::Integer]
        #     Number of Feature values that have been imported by the operation.
        # @!attribute [rw] invalid_row_count
        #   @return [::Integer]
        #     The number of rows in input source that weren't imported due to either
        #     * Not having any featureValues.
        #     * Having a null entityId.
        #     * Having a null timestamp.
        #     * Not being parsable (applicable for CSV sources).
        # @!attribute [rw] timestamp_outside_retention_rows_count
        #   @return [::Integer]
        #     The number rows that weren't ingested due to having timestamps outside the
        #     retention boundary.
        class ImportFeatureValuesOperationMetadata
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Details of operations that exports Features values.
        # @!attribute [rw] generic_metadata
        #   @return [::Google::Cloud::AIPlatform::V1::GenericOperationMetadata]
        #     Operation metadata for Featurestore export Feature values.
        class ExportFeatureValuesOperationMetadata
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Details of operations that batch reads Feature values.
        # @!attribute [rw] generic_metadata
        #   @return [::Google::Cloud::AIPlatform::V1::GenericOperationMetadata]
        #     Operation metadata for Featurestore batch read Features values.
        class BatchReadFeatureValuesOperationMetadata
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Details of operations that perform create EntityType.
        # @!attribute [rw] generic_metadata
        #   @return [::Google::Cloud::AIPlatform::V1::GenericOperationMetadata]
        #     Operation metadata for EntityType.
        class CreateEntityTypeOperationMetadata
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Details of operations that perform create Feature.
        # @!attribute [rw] generic_metadata
        #   @return [::Google::Cloud::AIPlatform::V1::GenericOperationMetadata]
        #     Operation metadata for Feature.
        class CreateFeatureOperationMetadata
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end

        # Details of operations that perform batch create Features.
        # @!attribute [rw] generic_metadata
        #   @return [::Google::Cloud::AIPlatform::V1::GenericOperationMetadata]
        #     Operation metadata for Feature.
        class BatchCreateFeaturesOperationMetadata
          include ::Google::Protobuf::MessageExts
          extend ::Google::Protobuf::MessageExts::ClassMethods
        end
      end
    end
  end
end

redpajama_set_name: RedPajamaGithub


text:
package com.sequenceiq.cloudbreak.core.flow2.externaldatabase.provision.handler;

import java.util.Map;
import java.util.stream.Collectors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType;
import com.sequenceiq.cloudbreak.cloud.model.CloudSubnet;
import com.sequenceiq.cloudbreak.common.exception.BadRequestException;
import com.sequenceiq.cloudbreak.common.mappable.CloudPlatform;
import com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse;

@Component
public class EnvironmentValidator {

    private static final Logger LOGGER = LoggerFactory.getLogger(EnvironmentValidator.class);

    public void checkValidEnvironment(String stackName, DatabaseAvailabilityType externalDatabase, DetailedEnvironmentResponse environment) {
        LOGGER.debug("Checking environment validity for stack {}", stackName);
        if (CloudPlatform.AWS.name().equalsIgnoreCase(environment.getCloudPlatform())) {
            checkAwsEnvironment(stackName, externalDatabase, environment);
        }
    }

    private void checkAwsEnvironment(String stackName, DatabaseAvailabilityType externalDatabase, DetailedEnvironmentResponse environment) {
        if (externalDatabase == DatabaseAvailabilityType.HA) {
            LOGGER.info("Checking external HA Database prerequisites");
            String message;
            if (environment.getNetwork().getSubnetMetas().size() < 2) {
                message = String.format("Cannot create external HA database for stack: %s, not enough subnets in the vpc", stackName);
                LOGGER.debug(message);
                throw new BadRequestException(message);
            }

            Map<String, Long> zones = environment.getNetwork().getSubnetMetas().values().stream()
                    .collect(Collectors.groupingBy(CloudSubnet::getAvailabilityZone, Collectors.counting()));
            if (zones.size() < 2) {
                message = String.format("Cannot create external HA database for stack: %s, "
                        + "vpc subnets must cover at least two different availability zones", stackName);
                LOGGER.debug(message);
                throw new BadRequestException(message);
            }
            LOGGER.info("Prerequisites PASSED");
        }
    }
}


text:
package org.bpmscript.js;

import junit.framework.TestCase;

import org.bpmscript.test.IServiceLookup;
import org.bpmscript.test.ITestCallback;
import org.bpmscript.test.js.JavascriptTestSupport;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Script;
import org.mozilla.javascript.Scriptable;

/**
 *
 */
public class ExtendTest extends TestCase {
    public void testExtend() throws Exception {
        JavascriptTestSupport testSupport = new JavascriptTestSupport("/org/bpmscript/js/extend.js");
        testSupport.execute(new ITestCallback<IServiceLookup>() {
            public void execute(IServiceLookup services) throws Exception {
                Context context = services.get("context");
                Script script = services.get("script");
                Scriptable scope = services.get("scope");
                Object result = script.exec(context, scope);
                assertNotNull(result);
            }
        });
    }
}


text:
package builds

// xlCrypto_go/builds/unsignedBList_test.go

import (
	"bytes"
	"encoding/base64"
	"fmt"
	xr "github.com/jddixon/rnglib_go"
	xu "github.com/jddixon/xlUtil_go"
	. "gopkg.in/check.v1"
	"strings"
)

var _ = fmt.Print

const (
	uDocTitle = "document 1"
	uDocTime  = "2004-11-18 20:03:34"
)

func (s *XLSuite) TestEmptyUnsignedBList(c *C) {
	var (
		err    error
		myList *UnsignedBList
	)
	myList, err = NewUnsignedBList("document 1")
	c.Assert(err, IsNil)
	c.Assert(myList, NotNil)
	c.Assert(myList.Size(), Equals, uint(0))

	c.Assert(myList.IsHashed(), Equals, false)
	c.Assert(myList.Verify(), Equals, false)

	myList.SetDocHash()
	c.Assert(myList.IsHashed(), Equals, true)
	c.Assert(myList.Verify(), Equals, true)
}

func (s *XLSuite) TestGeneratedUnsignedBList(c *C) {
	var (
		err    error
		myList *UnsignedBList
	)
	rng := xr.MakeSimpleRNG()

	hash0 := make([]byte, xu.SHA1_BIN_LEN)
	hash1 := make([]byte, xu.SHA1_BIN_LEN)
	hash2 := make([]byte, xu.SHA1_BIN_LEN)
	hash3 := make([]byte, xu.SHA1_BIN_LEN)
	rng.NextBytes(hash0)
	rng.NextBytes(hash1)
	rng.NextBytes(hash2)
	rng.NextBytes(hash3)

	myList, err = NewUnsignedBList("document 1")
	c.Assert(err, IsNil)
	c.Assert(myList, NotNil)
	c.Assert(myList.Size(), Equals, uint(0))
	c.Assert(myList.IsHashed(), Equals, false)

	// XXX SHOULD SET TIME to uDocTime HERE XXX
	t, err := xu.ParseTimestamp(uDocTime)
	c.Assert(err, IsNil)
	myList.setTimestamp(t)

	// XXX NOTE WE CAN ADD DUPLICATE OR CONFLICTING ITEMS !! XXX
	err = myList.Add(hash0, "fileForHash0")
	c.Assert(err, IsNil)
	c.Assert(myList.Size(), Equals, uint(1))

	err = myList.Add(hash1, "fileForHash1")
	c.Assert(err, IsNil)
	c.Assert(myList.Size(), Equals, uint(2))

	err = myList.Add(hash2, "fileForHash2")
	c.Assert(err, IsNil)
	c.Assert(myList.Size(), Equals, uint(3))

	err = myList.Add(hash3, "fileForHash3")
	c.Assert(err, IsNil)
	c.Assert(myList.Size(), Equals, uint(4))

	// check (arbitrarily) second content line
	expected1 := base64.StdEncoding.EncodeToString(hash1) + " fileForHash1"
	actual1, err := myList.Get(1)
	c.Assert(err, IsNil)
	c.Assert(expected1, Equals, actual1)

	c.Assert(myList.IsHashed(), Equals, false)
	myList.SetDocHash()
	docHash := myList.GetDocHash()
	c.Assert(docHash, NotNil)
	c.Assert(myList.IsHashed(), Equals, true)
	ok := myList.Verify()
	c.Assert(ok, Equals, true)
	myDoc, err := myList.String()
	c.Assert(err, IsNil)

	// DEBUG
	fmt.Printf("MY_DOC - UNSIGNED:\n%s", myDoc)
	// END

	reader := strings.NewReader(myDoc)
	list2, err := ParseUnsignedBList(reader)
	c.Assert(err, IsNil)
	c.Assert(list2, NotNil)

	c.Assert(list2.Size(), Equals, uint(4))
	c.Assert(list2.IsHashed(), Equals, true)
	c.Assert(list2.Verify(), Equals, true)

	str, err := list2.String()
	c.Assert(err, IsNil)
	c.Assert(str, Equals, myDoc)

	// yes, this is fully redundant
	docHash2 := list2.GetDocHash()
	c.Assert(bytes.Equal(docHash2, docHash), Equals, true)

}


text:
<?php

declare (strict_types=1);
namespace Ssch\TYPO3Rector\Rector\v7\v5;

use PhpParser\Node;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Expr\BinaryOp\Concat;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Return_;
use PHPStan\Type\ObjectType;
use Rector\Core\Rector\AbstractRector;
use Ssch\TYPO3Rector\Helper\TcaHelperTrait;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
 * @changelog https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/7.5/Deprecation-69754-TcaCtrlIconfileUsingRelativePathToExtAndFilenameOnly.html
 * @see \Ssch\TYPO3Rector\Tests\Rector\v7\v5\UseExtPrefixForTcaIconFileRector\UseExtPrefixForTcaIconFileRectorTest
 */
final class UseExtPrefixForTcaIconFileRector extends \Rector\Core\Rector\AbstractRector
{
    use TcaHelperTrait;
    /**
     * @codeCoverageIgnore
     */
    public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
    {
        return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Deprecate relative path to extension directory and using filename only in TCA ctrl iconfile', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
[
    'ctrl' => [
        'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('my_extension') . 'Resources/Public/Icons/image.png'
    ]
];
CODE_SAMPLE
, <<<'CODE_SAMPLE'
[
    'ctrl' => [
        'iconfile' => 'EXT:my_extension/Resources/Public/Icons/image.png'
    ]
];
CODE_SAMPLE
)]);
    }
    /**
     * @return array<class-string<Node>>
     */
    public function getNodeTypes() : array
    {
        return [\PhpParser\Node\Stmt\Return_::class];
    }
    /**
     * @param Return_ $node
     */
    public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
    {
        if (!$this->isFullTca($node)) {
            return null;
        }
        $ctrl = $this->extractCtrl($node);
        if (!$ctrl instanceof \PhpParser\Node\Expr\ArrayItem) {
            return null;
        }
        $ctrlItems = $ctrl->value;
        if (!$ctrlItems instanceof \PhpParser\Node\Expr\Array_) {
            return null;
        }
        foreach ($ctrlItems->items as $fieldValue) {
            if (!$fieldValue instanceof \PhpParser\Node\Expr\ArrayItem) {
                continue;
            }
            if (null === $fieldValue->key) {
                continue;
            }
            if ($this->valueResolver->isValue($fieldValue->key, 'iconfile')) {
                $this->refactorIconFile($fieldValue);
                return $node;
            }
        }
        return null;
    }
    private function refactorIconFile(\PhpParser\Node\Expr\ArrayItem $fieldValue) : void
    {
        if (null === $fieldValue->value) {
            return;
        }
        if ($fieldValue->value instanceof \PhpParser\Node\Expr\BinaryOp\Concat) {
            $staticCall = $fieldValue->value->left;
            if (!$staticCall instanceof \PhpParser\Node\Expr\StaticCall) {
                return;
            }
            if (!$this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($staticCall, new \PHPStan\Type\ObjectType('TYPO3\\CMS\\Core\\Utility\\ExtensionManagementUtility'))) {
                return;
            }
            if (!$this->isName($staticCall->name, 'extRelPath')) {
                return;
            }
            if (!isset($staticCall->args[0])) {
                return;
            }
            $extensionKey = $this->valueResolver->getValue($staticCall->args[0]->value);
            if (null === $extensionKey) {
                return;
            }
            $pathToFileNode = $fieldValue->value->right;
            if (!$pathToFileNode instanceof \PhpParser\Node\Scalar\String_) {
                return;
            }
            $pathToFile = $this->valueResolver->getValue($pathToFileNode);
            if (null === $pathToFile) {
                return;
            }
            $fieldValue->value = new \PhpParser\Node\Scalar\String_(\sprintf('EXT:%s/%s', $extensionKey, \ltrim($pathToFile, '/')));
        }
        if (!$fieldValue->value instanceof \PhpParser\Node\Scalar\String_) {
            return;
        }
        $pathToFile = $this->valueResolver->getValue($fieldValue->value);
        if (null === $pathToFile) {
            return;
        }
        if (\false !== \strpos($pathToFile, '/')) {
            return;
        }
        $fieldValue->value = new \PhpParser\Node\Scalar\String_(\sprintf('EXT:t3skin/icons/gfx/i/%s', $pathToFile));
    }
}


text:
package cn.edu.ustc.appseed.clubseed.activity;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

import cn.edu.ustc.appseed.clubseed.R;

public class AuthorActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_author);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        if(toolbar != null) {
            setSupportActionBar(toolbar);
        }
        setTitle("APPSeed");
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_author, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}


text:
<?php

declare(strict_types=1);

namespace Vpn\Portal\Http;

use Closure;
use RangeException;
use Vpn\Portal\Binary;
use Vpn\Portal\Http\Exception\HttpException;
use Vpn\Portal\Validator;

class Request
{
    /** @var array<string,mixed> */
    private $serverData;

    /** @var array<string,string|string[]> */
    private $getData;

    /** @var array<string,string|string[]> */
    private $postData;

    /** @var array<string,string> */
    private $cookieData;

    /**
     * @param array<string,mixed>           $serverData
     * @param array<string,string|string[]> $getData
     * @param array<string,string|string[]> $postData
     * @param array<string,string>          $cookieData
     */
    public function __construct(array $serverData, array $getData, array $postData, array $cookieData)
    {
        $this->serverData = $serverData;
        $this->getData = $getData;
        $this->postData = $postData;
        $this->cookieData = $cookieData;
    }

    public static function createFromGlobals(): self
    {
        return new self(
            $_SERVER,
            $_GET,
            $_POST,
            $_COOKIE
        );
    }

    public function getScheme(): string
    {
        $requestScheme = 'http';
        if ('on' === $this->optionalHeader('HTTPS')) {
            $requestScheme = 'https';
        }
        if ('https' === $this->optionalHeader('REQUEST_SCHEME')) {
            $requestScheme = 'https';
        }

        return $requestScheme;
    }

    /**
     * URI = scheme:[//authority]path[?query][#fragment]
     * authority = [userinfo@]host[:port].
     *
     * @see https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Generic_syntax
     */
    public function getAuthority(): string
    {
        // we do NOT care about "userinfo"
        $requestScheme = $this->getScheme();
        $serverName = $this->requireHeader('SERVER_NAME');
        $serverPort = (int) $this->requireHeader('SERVER_PORT');

        if ('https' === $requestScheme && 443 === $serverPort) {
            return $serverName;
        }
        if ('http' === $requestScheme && 80 === $serverPort) {
            return $serverName;
        }

        return $serverName.':'.$serverPort;
    }

    public function getUri(): string
    {
        return $this->getScheme().'://'.$this->getAuthority().$this->requireHeader('REQUEST_URI');
    }

    public function getRoot(): string
    {
        if (null === $appRoot = $this->optionalHeader('VPN_APP_ROOT')) {
            return '/';
        }

        return $appRoot.'/';
    }

    public function getRootUri(): string
    {
        return $this->getScheme().'://'.$this->getAuthority().$this->getRoot();
    }

    public function getRequestMethod(): string
    {
        return $this->requireHeader('REQUEST_METHOD');
    }

    public function getServerName(): string
    {
        return $this->requireHeader('SERVER_NAME');
    }

    public function getOrigin(): string
    {
        return sprintf('%s://%s', $this->getScheme(), $this->getAuthority());
    }

    public function getPathInfo(): string
    {
        // if we have PATH_INFO available, use it
        if (null !== $pathInfo = $this->optionalHeader('PATH_INFO')) {
            return $pathInfo;
        }

        // if not, we have to reconstruct it
        $requestUri = $this->requireHeader('REQUEST_URI');

        // trim the query string (if any)
        if (false !== $queryStart = strpos($requestUri, '?')) {
            $requestUri = Binary::safeSubstr($requestUri, 0, $queryStart);
        }

        // remove the VPN_APP_ROOT (if any)
        if (null !== $appRoot = $this->optionalHeader('VPN_APP_ROOT')) {
            $requestUri = Binary::safeSubstr($requestUri, Binary::safeStrlen($appRoot));
        }

        return $requestUri;
    }

    /**
     * @param Closure(string):void $c
     */
    public function requireQueryParameter(string $queryKey, Closure $c): string
    {
        if (!\array_key_exists($queryKey, $this->getData)) {
            throw new HttpException(sprintf('missing query parameter "%s"', $queryKey), 400);
        }
        if (!\is_string($this->getData[$queryKey])) {
            throw new HttpException(sprintf('value of query parameter "%s" MUST be string', $queryKey), 400);
        }

        try {
            $c($this->getData[$queryKey]);
        } catch (RangeException $e) {
            throw new HttpException(sprintf('invalid "%s" [%s]', $queryKey, $e->getMessage()), 400);
        }

        return $this->getData[$queryKey];
    }

    /**
     * @param Closure(string):void $c
     */
    public function optionalQueryParameter(string $queryKey, Closure $c): ?string
    {
        if (!\array_key_exists($queryKey, $this->getData)) {
            return null;
        }

        return $this->requireQueryParameter($queryKey, $c);
    }

    /**
     * @param Closure(array<string>):void $c
     */
    public function optionalArrayPostParameter(string $postKey, Closure $c): array
    {
        if (!\array_key_exists($postKey, $this->postData)) {
            return [];
        }
        $postValue = $this->postData[$postKey];
        if (\is_string($postValue)) {
            $postValue = [$postValue];
        }

        try {
            $c($postValue);
        } catch (RangeException $e) {
            throw new HttpException(sprintf('invalid "%s" [%s]', $postKey, $e->getMessage()), 400);
        }

        return $postValue;
    }

    /**
     * @param Closure(string):void $c
     */
    public function requirePostParameter(string $postKey, Closure $c): string
    {
        if (!\array_key_exists($postKey, $this->postData)) {
            throw new HttpException(sprintf('missing post parameter "%s"', $postKey), 400);
        }
        if (!\is_string($this->postData[$postKey])) {
            throw new HttpException(sprintf('value of post parameter "%s" MUST be string', $postKey), 400);
        }

        try {
            $c($this->postData[$postKey]);
        } catch (RangeException $e) {
            throw new HttpException(sprintf('invalid "%s" [%s]', $postKey, $e->getMessage()), 400);
        }

        return $this->postData[$postKey];
    }

    /**
     * @param Closure(string):void $c
     */
    public function optionalPostParameter(string $postKey, Closure $c): ?string
    {
        if (!\array_key_exists($postKey, $this->postData)) {
            return null;
        }

        return $this->requirePostParameter($postKey, $c);
    }

    /**
     * @param Closure(string):void $c
     */
    public function getCookie(string $cookieKey, Closure $c): ?string
    {
        if (!\array_key_exists($cookieKey, $this->cookieData)) {
            return null;
        }

        try {
            $c($this->cookieData[$cookieKey]);

            return $this->cookieData[$cookieKey];
        } catch (RangeException $e) {
            // when a cookie value is malformed, we consider it not set at all
            return null;
        }
    }

    // XXX introduce validator function as well?!
    public function requireHeader(string $headerKey): string
    {
        if (!\array_key_exists($headerKey, $this->serverData)) {
            throw new HttpException(sprintf('missing request header "%s"', $headerKey), 400);
        }

        if (!\is_string($this->serverData[$headerKey])) {
            throw new HttpException(sprintf('value of request header "%s" MUST be string', $headerKey), 400);
        }

        return $this->serverData[$headerKey];
    }

    // XXX introduce validator function as well?!
    public function optionalHeader(string $headerKey): ?string
    {
        if (!\array_key_exists($headerKey, $this->serverData)) {
            return null;
        }

        return $this->requireHeader($headerKey);
    }

    /**
     * If the HTTP_REFERER header is set, verify it and return it.
     */
    public function optionalReferrer(): ?string
    {
        if (null === $referrerHeaderValue = $this->optionalHeader('HTTP_REFERER')) {
            return null;
        }

        try {
            Validator::matchesOrigin($this->getOrigin(), $referrerHeaderValue);

            return $referrerHeaderValue;
        } catch (RangeException $e) {
            throw new HttpException('unexpected HTTP_REFERER', 400);
        }
    }

    /**
     * Verify the HTTP_REFERER and return it.
     */
    public function requireReferrer(): string
    {
        if (null === $referrerHeaderValue = $this->optionalReferrer()) {
            throw new HttpException('missing HTTP_REFERER', 400);
        }

        return $referrerHeaderValue;
    }
}


text:
'use strict';
const {
  mustCall,
  mustCallAtLeast,
} = require('../common');
const assert = require('assert');
const fork = require('child_process').fork;
const net = require('net');
const debug = require('util').debuglog('test');

if (process.argv[2] === 'child') {

  const onSocket = mustCall((msg, socket) => {
    if (msg.what !== 'socket') return;
    process.removeListener('message', onSocket);
    socket.end('echo');
    debug('CHILD: got socket');
  });

  process.on('message', onSocket);

  process.send({ what: 'ready' });
} else {

  const child = fork(process.argv[1], ['child']);

  child.on('exit', mustCall((code, signal) => {
    const message = `CHILD: died with ${code}, ${signal}`;
    assert.strictEqual(code, 0, message);
  }));

  // Send net.Socket to child.
  function testSocket() {

    // Create a new server and connect to it,
    // but the socket will be handled by the child.
    const server = net.createServer();
    server.on('connection', mustCall((socket) => {
      // TODO(@jasnell): Close does not seem to actually be called.
      // It is not clear if it is needed.
      socket.on('close', () => {
        debug('CLIENT: socket closed');
      });
      child.send({ what: 'socket' }, socket);
    }));
    server.on('close', mustCall(() => {
      debug('PARENT: server closed');
    }));

    server.listen(0, mustCall(() => {
      debug('testSocket, listening');
      const connect = net.connect(server.address().port);
      let store = '';
      connect.on('data', mustCallAtLeast((chunk) => {
        store += chunk;
        debug('CLIENT: got data');
      }));
      connect.on('close', mustCall(() => {
        debug('CLIENT: closed');
        assert.strictEqual(store, 'echo');
        server.close();
      }));
    }));
  }

  const onReady = mustCall((msg) => {
    if (msg.what !== 'ready') return;
    child.removeListener('message', onReady);

    testSocket();
  });

  // Create socket and send it to child.
  child.on('message', onReady);
}


text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:paddingStart="@dimen/horizontal_margin"
                android:paddingEnd="@dimen/horizontal_margin"
                android:paddingTop="@dimen/vertical_margin_half"
                android:paddingBottom="@dimen/vertical_margin_half">

    <ProgressBar
            android:id="@+id/progress_bar"
            android:layout_width="@dimen/progress_bar_size"
            android:layout_height="@dimen/progress_bar_size"
            android:layout_alignParentStart="true"
            android:layout_centerVertical="true"/>

    <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toEndOf="@id/progress_bar"
            android:layout_centerVertical="true"
            android:layout_marginStart="@dimen/horizontal_margin"
            android:maxLines="1"
            android:text="@string/please_wait"/>

</RelativeLayout>


text: <!DOCTYPE html>