Pipelines API Reference
Kubeflow Pipelines API
Version: 2.0.0-alpha.1
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Summary
Tag: RunService
Operation | Description |
---|---|
GET /apis/v1beta1/runs | Finds all runs. |
POST /apis/v1beta1/runs | Creates a new run. |
DELETE /apis/v1beta1/runs/{id} | Deletes a run. |
POST /apis/v1beta1/runs/{id}:archive | Archives a run. |
POST /apis/v1beta1/runs/{id}:unarchive | Restores an archived run. |
GET /apis/v1beta1/runs/{run_id} | Finds a specific run by ID. |
GET /apis/v1beta1/runs/{run_id}/nodes/{node_id}/artifacts/{artifact_name}:read | Finds a run's artifact data. |
POST /apis/v1beta1/runs/{run_id}/retry | Re-initiates a failed or terminated run. |
POST /apis/v1beta1/runs/{run_id}/terminate | Terminates an active run. |
POST /apis/v1beta1/runs/{run_id}:reportMetrics | ReportRunMetrics reports metrics of a run. Each metric is reported in its own transaction, so this API accepts partial failures. Metric can be uniquely identified by (run_id, node_id, name). Duplicate reporting will be ignored by the API. First reporting wins. |
Tag: JobService
Operation | Description |
---|---|
GET /apis/v1beta1/jobs | Finds all jobs. |
POST /apis/v1beta1/jobs | Creates a new job. |
GET /apis/v1beta1/jobs/{id} | Finds a specific job by ID. |
DELETE /apis/v1beta1/jobs/{id} | Deletes a job. |
POST /apis/v1beta1/jobs/{id}/disable | Stops a job and all its associated runs. The job is not deleted. |
POST /apis/v1beta1/jobs/{id}/enable | Restarts a job that was previously stopped. All runs associated with the job will continue. |
Tag: ExperimentService
Operation | Description |
---|---|
GET /apis/v1beta1/experiments | Finds all experiments. Supports pagination, and sorting on certain fields. |
POST /apis/v1beta1/experiments | Creates a new experiment. |
GET /apis/v1beta1/experiments/{id} | Finds a specific experiment by ID. |
DELETE /apis/v1beta1/experiments/{id} | Deletes an experiment without deleting the experiment's runs and jobs. To avoid unexpected behaviors, delete an experiment's runs and jobs before deleting the experiment. |
POST /apis/v1beta1/experiments/{id}:archive | Archives an experiment and the experiment's runs and jobs. |
POST /apis/v1beta1/experiments/{id}:unarchive | Restores an archived experiment. The experiment's archived runs and jobs will stay archived. |
Tag: PipelineService
Operation | Description |
---|---|
GET /apis/v1beta1/namespaces/{namespace}/pipelines/{name} | Finds a pipeline by Name (and namespace) |
GET /apis/v1beta1/pipeline_versions | Lists all pipeline versions of a given pipeline. |
POST /apis/v1beta1/pipeline_versions | Adds a pipeline version to the specified pipeline. |
GET /apis/v1beta1/pipeline_versions/{version_id} | Gets a pipeline version by pipeline version ID. |
DELETE /apis/v1beta1/pipeline_versions/{version_id} | Deletes a pipeline version by pipeline version ID. If the deleted pipeline version is the default pipeline version, the pipeline's default version changes to the pipeline's most recent pipeline version. If there are no remaining pipeline versions, the pipeline will have no default version. Examines the run_service_api.ipynb notebook to learn more about creating a run using a pipeline version (https://github.com/kubeflow/pipelines/blob/sdk/release-1.8/tools/benchmarks/run_service_api.ipynb). |
GET /apis/v1beta1/pipeline_versions/{version_id}/templates | Returns a YAML template that contains the specified pipeline version's description, parameters and metadata. |
GET /apis/v1beta1/pipelines | Finds all pipelines. |
POST /apis/v1beta1/pipelines | Creates a pipeline. |
GET /apis/v1beta1/pipelines/{id} | Finds a specific pipeline by ID. |
DELETE /apis/v1beta1/pipelines/{id} | Deletes a pipeline and its pipeline versions. |
GET /apis/v1beta1/pipelines/{id}/templates | Returns a single YAML template that contains the description, parameters, and metadata associated with the pipeline provided. |
POST /apis/v1beta1/pipelines/{pipeline_id}/default_version/{version_id} | Update the default pipeline version of a specific pipeline. |
Tag: PipelineUploadService
Operation | Description |
---|---|
POST /apis/v1beta1/pipelines/upload | |
POST /apis/v1beta1/pipelines/upload_version |
Tag: HealthzService
Operation | Description |
---|---|
GET /apis/v1beta1/healthz | Get healthz data. |
Security
Bearer
Type: apiKey- Name:
-
authorization
- In:
-
header
Paths
GET /apis/v1beta1/experiments
Tags: ExperimentServicepage_token | A page token to request the next page of results. The token is acquried from the nextPageToken field of the response from the previous ListExperiment call or can be omitted when fetching the first page. |
query | string | |
page_size | The number of experiments to be listed per page. If there are more experiments than this number, the response message will contain a nextPageToken field you can use to fetch the next page. |
query | integer (int32) | |
sort_by | Can be format of "field_name", "field_name asc" or "field_name desc" Ascending by default. |
query | string | |
filter | A url-encoded, JSON-serialized Filter protocol buffer (see filter.proto). |
query | string | |
resource_reference_key.type | The type of the resource that referred to. |
query | string , x ∈ { UNKNOWN_RESOURCE_TYPE (default) , EXPERIMENT , JOB , PIPELINE , PIPELINE_VERSION , NAMESPACE } | |
resource_reference_key.id | The ID of the resource that referred to. |
query | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
Uses default content-types: application/json
The experiment to be created.
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
DELETE /apis/v1beta1/experiments/{id}
Tags: ExperimentServiceid | The ID of the experiment to be deleted. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
id | The ID of the experiment to be retrieved. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
POST /apis/v1beta1/experiments/{id}:archive
Tags: ExperimentServiceid | The ID of the experiment to be archived. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
POST /apis/v1beta1/experiments/{id}:unarchive
Tags: ExperimentServiceid | The ID of the experiment to be restored. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
page_token | A page token to request the next page of results. The token is acquried from the nextPageToken field of the response from the previous ListJobs call or can be omitted when fetching the first page. |
query | string | |
page_size | The number of jobs to be listed per page. If there are more jobs than this number, the response message will contain a nextPageToken field you can use to fetch the next page. |
query | integer (int32) | |
sort_by | Can be format of "field_name", "field_name asc" or "field_name desc". Ascending by default. |
query | string | |
resource_reference_key.type | The type of the resource that referred to. |
query | string , x ∈ { UNKNOWN_RESOURCE_TYPE (default) , EXPERIMENT , JOB , PIPELINE , PIPELINE_VERSION , NAMESPACE } | |
resource_reference_key.id | The ID of the resource that referred to. |
query | string | |
filter | A url-encoded, JSON-serialized Filter protocol buffer (see filter.proto). |
query | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
Uses default content-types: application/json
The job to be created
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
id | The ID of the job to be deleted |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
id | The ID of the job to be retrieved |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
POST /apis/v1beta1/jobs/{id}/disable
Tags: JobServiceid | The ID of the job to be disabled |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
POST /apis/v1beta1/jobs/{id}/enable
Tags: JobServiceid | The ID of the job to be enabled |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
GET /apis/v1beta1/namespaces/{namespace}/pipelines/{name}
Tags: PipelineServicenamespace | The Namespace the pipeline belongs to. In the case of shared pipelines and KFPipeline standalone installation, the pipeline name is the only needed field for unique resource lookup (namespace is not required). In those case, please provide hyphen (dash character, "-"). |
path | string | |
name | The Name of the pipeline to be retrieved. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
GET /apis/v1beta1/pipeline_versions
Tags: PipelineServiceresource_key.type | The type of the resource that referred to. |
query | string , x ∈ { UNKNOWN_RESOURCE_TYPE (default) , EXPERIMENT , JOB , PIPELINE , PIPELINE_VERSION , NAMESPACE } | |
resource_key.id | The ID of the resource that referred to. |
query | string | |
page_size | The number of pipeline versions to be listed per page. If there are more pipeline versions than this number, the response message will contain a nextPageToken field you can use to fetch the next page. |
query | integer (int32) | |
page_token | A page token to request the next page of results. The token is acquried from the nextPageToken field of the response from the previous ListPipelineVersions call or can be omitted when fetching the first page. |
query | string | |
sort_by | Can be format of "field_name", "field_name asc" or "field_name desc" Ascending by default. |
query | string | |
filter | A base-64 encoded, JSON-serialized Filter protocol buffer (see filter.proto). |
query | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
POST /apis/v1beta1/pipeline_versions
Tags: PipelineServiceUses default content-types: application/json
ResourceReference inside PipelineVersion specifies the pipeline that this version belongs to.
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
DELETE /apis/v1beta1/pipeline_versions/{version_id}
Tags: PipelineServiceversion_id | The ID of the pipeline version to be deleted. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
GET /apis/v1beta1/pipeline_versions/{version_id}
Tags: PipelineServiceversion_id | The ID of the pipeline version to be retrieved. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
GET /apis/v1beta1/pipeline_versions/{version_id}/templates
Tags: PipelineServiceversion_id | The ID of the pipeline version whose template is to be retrieved. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
page_token | A page token to request the next page of results. The token is acquried from the nextPageToken field of the response from the previous ListPipelines call. |
query | string | |
page_size | The number of pipelines to be listed per page. If there are more pipelines than this number, the response message will contain a valid value in the nextPageToken field. |
query | integer (int32) | |
sort_by | Can be format of "field_name", "field_name asc" or "field_name desc" Ascending by default. |
query | string | |
filter | A url-encoded, JSON-serialized Filter protocol buffer (see filter.proto). |
query | string | |
resource_reference_key.type | The type of the resource that referred to. |
query | string , x ∈ { UNKNOWN_RESOURCE_TYPE (default) , EXPERIMENT , JOB , PIPELINE , PIPELINE_VERSION , NAMESPACE } | |
resource_reference_key.id | The ID of the resource that referred to. |
query | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
Uses default content-types: application/json
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
POST /apis/v1beta1/pipelines/upload
Tags: PipelineUploadServicemultipart/form-data
uploadfile | The pipeline to upload. Maximum size of 32MB is supported. |
formData | file | |
name | query | string | ||
description | query | string |
application/json
- 200 OK
-
- default
-
POST /apis/v1beta1/pipelines/upload_version
Tags: PipelineUploadServicemultipart/form-data
uploadfile | The pipeline to upload. Maximum size of 32MB is supported. |
formData | file | |
name | query | string | ||
pipelineid | query | string | ||
description | query | string |
application/json
- 200 OK
-
- default
-
DELETE /apis/v1beta1/pipelines/{id}
Tags: PipelineServiceid | The ID of the pipeline to be deleted. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
id | The ID of the pipeline to be retrieved. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
GET /apis/v1beta1/pipelines/{id}/templates
Tags: PipelineServiceid | The ID of the pipeline whose template is to be retrieved. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
POST /apis/v1beta1/pipelines/{pipeline_id}/default_version/{version_id}
Tags: PipelineServicepipeline_id | The ID of the pipeline to be updated. |
path | string | |
version_id | The ID of the default version. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
page_token | A page token to request the next page of results. The token is acquried from the nextPageToken field of the response from the previous ListRuns call or can be omitted when fetching the first page. |
query | string | |
page_size | The number of runs to be listed per page. If there are more runs than this number, the response message will contain a nextPageToken field you can use to fetch the next page. |
query | integer (int32) | |
sort_by | Can be format of "field_name", "field_name asc" or "field_name desc" (Example, "name asc" or "id desc"). Ascending by default. |
query | string | |
resource_reference_key.type | The type of the resource that referred to. |
query | string , x ∈ { UNKNOWN_RESOURCE_TYPE (default) , EXPERIMENT , JOB , PIPELINE , PIPELINE_VERSION , NAMESPACE } | |
resource_reference_key.id | The ID of the resource that referred to. |
query | string | |
filter | A url-encoded, JSON-serialized Filter protocol buffer (see filter.proto). |
query | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
Uses default content-types: application/json
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
id | The ID of the run to be deleted. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
id | The ID of the run to be archived. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
id | The ID of the run to be restored. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
run_id | The ID of the run to be retrieved. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
GET /apis/v1beta1/runs/{run_id}/nodes/{node_id}/artifacts/{artifact_name}:read
Tags: RunServicerun_id | The ID of the run. |
path | string | |
node_id | The ID of the running node. |
path | string | |
artifact_name | The name of the artifact. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
run_id | The ID of the run to be retried. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
run_id | The ID of the run to be terminated. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
POST /apis/v1beta1/runs/{run_id}:reportMetrics
Tags: RunServiceUses default content-types: application/json
run_id | Required. The parent run ID of the metric. |
path | string |
Uses default content-types: application/json
- 200 OK
-
A successful response.
- default
-
Schema definitions
- id: string
-
Output. Unique experiment ID. Generated by API server.
- name: string
-
Required input field. Unique experiment name provided by user.
- description: string
-
- created_at: string (date-time)
-
Output. The time that the experiment created.
- resource_references: object[]
-
Optional input field. Specify which resource this run belongs to. For Experiment, the only valid resource reference is a single Namespace.
- storage_state: apiExperimentStorageState
-
Output. Specifies whether this experiment is in archived or available state.
apiExperimentStorageState: string , x ∈ { STORAGESTATE_UNSPECIFIED (default) , STORAGESTATE_AVAILABLE , STORAGESTATE_ARCHIVED }
- template: string
-
The template of the pipeline specified in a GetTemplate request, or of a pipeline version specified in a GetPipelinesVersionTemplate request.
- id: string
-
Output. Unique run ID. Generated by API server.
- name: string
-
Required input field. Job name provided by user. Not unique.
- description: string
-
- pipeline_spec: apiPipelineSpec
-
Required input field. Describing what the pipeline manifest and parameters to use for the scheduled job.
- resource_references: object[]
-
Optional input field. Specify which resource this job belongs to.
- service_account: string
-
Optional input field. Specify which Kubernetes service account this job uses.
- max_concurrency: string (int64)
-
- trigger: apiTrigger
-
Required input field. Specify how a run is triggered. Support cron mode or periodic mode.
- mode: JobMode
-
- created_at: string (date-time)
-
Output. The time this job is created.
- updated_at: string (date-time)
-
Output. The last time this job is updated.
- status: string
-
- error: string
-
In case any error happens retrieving a job field, only job ID and the error message is returned. Client has the flexibility of choosing how to handle error. This is especially useful during listing call.
- enabled: boolean (boolean)
-
Input. Whether the job is enabled or not.
- no_catchup: boolean (boolean)
-
Optional input field. Whether the job should catch up if behind schedule. If true, the job will only schedule the latest interval if behind schedule. If false, the job will catch up on each past interval.
- experiments: object[]
-
A list of experiments returned.
- total_size: integer (int32)
-
The total number of experiments for the given query.
- next_page_token: string
-
The token to list the next page of experiments.
- jobs: object[]
-
A list of jobs returned.
- total_size: integer (int32)
-
The total number of jobs for the given query.
- next_page_token: string
-
The token to list the next page of jobs.
- pipelines: object[]
- total_size: integer (int32)
-
The total number of pipelines for the given query.
- next_page_token: string
-
The token to list the next page of pipelines.
- versions: object[]
- next_page_token: string
-
The token to list the next page of pipeline versions.
- total_size: integer (int32)
-
The total number of pipeline versions for the given query.
- runs: object[]
- total_size: integer (int32)
-
The total number of runs for the given query.
- next_page_token: string
-
The token to list the next page of runs.
- start_time: string (date-time)
-
- end_time: string (date-time)
-
- interval_second: string (int64)
-
- id: string
-
Output. Unique pipeline ID. Generated by API server.
- created_at: string (date-time)
-
Output. The time this pipeline is created.
- name: string
-
Optional input field. Pipeline name provided by user. If not specified, file name is used as pipeline name.
- description: string
-
Optional input field. Describing the purpose of the job.
- parameters: object[]
-
Output. The input parameters for this pipeline. TODO(jingzhang36): replace this parameters field with the parameters field inside PipelineVersion when all usage of the former has been changed to use the latter.
- url: apiUrl
-
The URL to the source of the pipeline. This is required when creating the pipeine through CreatePipeline API. TODO(jingzhang36): replace this url field with the code_source_urls field inside PipelineVersion when all usage of the former has been changed to use the latter.
- error: string
-
In case any error happens retrieving a pipeline field, only pipeline ID and the error message is returned. Client has the flexibility of choosing how to handle error. This is especially useful during listing call.
- default_version: apiPipelineVersion
-
- resource_references: object[]
-
Input field. Specify which resource this pipeline belongs to. For Pipeline, the only valid resource reference is a single Namespace.
- pipeline_manifest: string
-
Output. The runtime JSON manifest of the pipeline, including the status of pipeline steps and fields need for UI visualization etc.
- workflow_manifest: string
-
Output. The runtime JSON manifest of the argo workflow. This is deprecated after pipeline_runtime_manifest is in use.
- pipeline_id: string
-
Optional input field. The ID of the pipeline user uploaded before.
- pipeline_name: string
-
Optional output field. The name of the pipeline. Not empty if the pipeline id is not empty.
- workflow_manifest: string
-
Optional input field. The marshalled raw argo JSON workflow. This will be deprecated when pipeline_manifest is in use.
- pipeline_manifest: string
-
Optional input field. The raw pipeline JSON spec.
- parameters: object[]
- runtime_config: PipelineSpecRuntimeConfig
-
- id: string
-
Output. Unique version ID. Generated by API server.
- name: string
-
Optional input field. Version name provided by user.
- created_at: string (date-time)
-
Output. The time this pipeline version is created.
- parameters: object[]
-
Output. The input parameters for this pipeline.
- code_source_url: string
-
Input. Optional. Pipeline version code source.
- package_url: apiUrl
-
Input. Required. Pipeline version package url. Whe calling CreatePipelineVersion API method, need to provide one package file location.
- resource_references: object[]
-
Input. Required. E.g., specify which pipeline this pipeline version belongs to.
- description: string
-
Input. Optional. Description for the pipeline version.
- run_id: string
-
Required. The parent run ID of the metric.
- metrics: object[]
-
List of metrics to report.
- results: object[]
- type: apiResourceType
-
The type of the resource that referred to.
- id: string
-
The ID of the resource that referred to.
- key: apiResourceKey
-
- name: string
-
The name of the resource that referred to.
- relationship: apiRelationship
-
Required field. The relationship from referred resource to the object.
apiResourceType: string , x ∈ { UNKNOWN_RESOURCE_TYPE (default) , EXPERIMENT , JOB , PIPELINE , PIPELINE_VERSION , NAMESPACE }
- id: string
-
Output. Unique run ID. Generated by API server.
- name: string
-
Required input field. Name provided by user, or auto generated if run is created by scheduled job. Not unique.
- storage_state: apiRunStorageState
-
Output. Specify whether this run is in archived or available mode.
- description: string
-
- pipeline_spec: apiPipelineSpec
-
Required input field. Describing what the pipeline manifest and parameters to use for the run.
- resource_references: object[]
-
Optional input field. Specify which resource this run belongs to. When creating a run from a particular pipeline version, the pipeline version can be specified here.
- service_account: string
-
Optional input field. Specify which Kubernetes service account this run uses.
- created_at: string (date-time)
-
Output. The time that the run created.
- scheduled_at: string (date-time)
-
Output. When this run is scheduled to run. This could be different from created_at. For example, if a run is from a backfilling job that was supposed to run 2 month ago, the scheduled_at is 2 month ago, v.s. created_at is the current time.
- finished_at: string (date-time)
-
Output. The time this run is finished.
- status: string
-
- error: string
-
In case any error happens retrieving a run field, only run ID and the error message is returned. Client has the flexibility of choosing how to handle error. This is especially useful during listing call.
- metrics: object[]
-
Output. The metrics of the run. The metrics are reported by ReportMetrics API.
- run: apiRun
-
- pipeline_runtime: apiPipelineRuntime
-
- name: string
-
Required. The user defined name of the metric. It must between 1 and 63 characters long and must conform to the following regular expression:
[a-z]([-a-z0-9]*[a-z0-9])?
. - node_id: string
-
Required. The runtime node ID which reports the metric. The node ID can be found in the RunDetail.workflow.Status. Metric with same (node_id, name) are considerd as duplicate. Only the first reporting will be recorded. Max length is 128.
- number_value: number (double)
-
The number value of the metric.
- format: RunMetricFormat
-
The display format of metric.
- error: string
-
- code: integer (int32)
-
- details: object[]
Trigger defines what starts a pipeline run.
- cron_schedule: apiCronSchedule
-
- periodic_schedule: apiPeriodicSchedule
-
- pipeline_url: string
-
URL of the pipeline definition or the pipeline version definition.
Required input.
- DISABLED: The job won't schedule any run if disabled.
The runtime config of a PipelineSpec.
- parameters: object
-
The runtime parameters of the PipelineSpec. The parameters will be used to replace the placeholders at runtime.
- pipeline_root: string
-
Any
contains an arbitrary serialized protocol buffer message along with a
URL that describes the type of the serialized message.
Protobuf library provides support to pack/unpack Any values in the form of utility functions or additional generated methods of the Any type.
Example 1: Pack and unpack a message in C++.
Foo foo = ...;
Any any;
any.PackFrom(foo);
...
if (any.UnpackTo(&foo)) {
...
}
Example 2: Pack and unpack a message in Java.
Foo foo = ...;
Any any = Any.pack(foo);
...
if (any.is(Foo.class)) {
foo = any.unpack(Foo.class);
}
Example 3: Pack and unpack a message in Python.
foo = Foo(...)
any = Any()
any.Pack(foo)
...
if any.Is(Foo.DESCRIPTOR):
any.Unpack(foo)
...
Example 4: Pack and unpack a message in Go
foo := &pb.Foo{...}
any, err := anypb.New(foo)
if err != nil {
...
}
...
foo := &pb.Foo{}
if err := any.UnmarshalTo(foo); err != nil {
...
}
The pack methods provided by protobuf library will by default use 'type.googleapis.com/full.type.name' as the type URL and the unpack methods only use the fully qualified type name after the last '/' in the type URL, for example "foo.bar.com/x/y.z" will yield type name "y.z".
JSON
The JSON representation of an Any
value uses the regular
representation of the deserialized, embedded message, with an
additional field @type
which contains the type URL. Example:
package google.profile;
message Person {
string first_name = 1;
string last_name = 2;
}
{
"@type": "type.googleapis.com/google.profile.Person",
"firstName": <string>,
"lastName": <string>
}
If the embedded message type is well-known and has a custom JSON
representation, that representation will be embedded adding a field
value
which holds the custom JSON in addition to the @type
field. Example (for message [google.protobuf.Duration][]):
{
"@type": "type.googleapis.com/google.protobuf.Duration",
"value": "1.212s"
}
- type_url: string
-
A URL/resource name that uniquely identifies the type of the serialized protocol buffer message. This string must contain at least one "/" character. The last segment of the URL's path must represent the fully qualified name of the type (as in
path/google.protobuf.Duration
). The name should be in a canonical form (e.g., leading "." is not accepted).In practice, teams usually precompile into the binary all types that they expect it to use in the context of Any. However, for URLs which use the scheme
http
,https
, or no scheme, one can optionally set up a type server that maps type URLs to message definitions as follows:- If no scheme is provided,
https
is assumed. - An HTTP GET on the URL must yield a [google.protobuf.Type][] value in binary format, or produce an error.
- Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.)
Note: this functionality is not currently available in the official protobuf release, and it is not used for type URLs beginning with type.googleapis.com.
Schemes other than
http
,https
(or the empty scheme) might be used with implementation specific semantics. - If no scheme is provided,
- value: string (byte)
-
Must be a valid serialized protocol buffer of the above specified type.
ListValue
is a wrapper around a repeated field of values.
The JSON representation for ListValue
is JSON array.
- values: object[]
-
Repeated field of dynamically typed values.
NullValue
is a singleton enumeration to represent the null value for the
Value
type union.
The JSON representation for NullValue
is JSON null
.
- NULL_VALUE: Null value.
Struct
represents a structured data value, consisting of fields
which map to dynamically typed values. In some languages, Struct
might be supported by a native representation. For example, in
scripting languages like JS a struct is represented as an
object. The details of that representation are described together
with the proto support for the language.
The JSON representation for Struct
is JSON object.
- fields: object
-
Unordered map of dynamically typed values.
Value
represents a dynamically typed value which can be either
null, a number, a string, a boolean, a recursive struct value, or a
list of values. A producer of value is expected to set one of that
variants, absence of any variant indicates an error.
The JSON representation for Value
is JSON value.
- null_value: protobufNullValue
-
Represents a null value.
- number_value: number (double)
-
Represents a double value.
- string_value: string
-
Represents a string value.
- bool_value: boolean (boolean)
-
Represents a boolean value.
- struct_value: protobufStruct
-
Represents a structured value.
- list_value: protobufListValue
-
Represents a repeated
Value
.
- metric_name: string
-
Output. The name of the metric.
- metric_node_id: string
-
Output. The ID of the node which reports the metric.
- status: ReportRunMetricsResponseReportRunMetricResultStatus
-
Output. The status of the metric reporting.
- message: string
-
Output. The detailed message of the error of the reporting.
ReportRunMetricsResponseReportRunMetricResultStatus: string , x ∈ { UNSPECIFIED (default) , OK , INVALID_ARGUMENT , DUPLICATE_REPORTING , INTERNAL_ERROR }
- UNSPECIFIED: Default value if not present.
- OK: Indicates successful reporting.
- INVALID_ARGUMENT: Indicates that the payload of the metric is invalid.
- DUPLICATE_REPORTING: Indicates that the metric has been reported before.
- INTERNAL_ERROR: Indicates that something went wrong in the server.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.