Timeline.attachments: list
Stay organized with collections
Save and categorize content based on your preferences.
Requires authorization
Returns a list of attachments for a timeline item.
See an example.
Request
HTTP request
GET https://www.googleapis.com/mirror/v1/timeline/itemId/attachments
Parameters
Parameter name |
Value |
Description |
Path parameters |
itemId |
string |
The ID of the timeline item whose attachments should be listed.
|
Authorization
This request requires authorization with the following scope (read more about authentication and authorization).
Scope |
https://www.googleapis.com/auth/glass.timeline |
Request body
Do not supply a request body with this method.
Response
If successful, this method returns a response body with the following structure:
{
"kind": "mirror#attachmentsList",
"items": [
timeline.attachments Resource
]
}
Property name |
Value |
Description |
Notes |
kind |
string |
The type of resource. This is always mirror#attachmentsList . |
|
items[] |
list |
The list of attachments. |
|
Examples
Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).
Java
Uses the Java client library.
import com.google.api.services.mirror.Mirror;
import com.google.api.services.mirror.model.Attachment;
import com.google.api.services.mirror.model.AttachmentsListResponse;
import java.io.IOException;
public class MyClass {
// ...
/**
* Print all attachments' metadata.
*
* @param service Authorized Mirror service.
* @param itemId ID of the timeline item the attachments belong to.
*/
public static void printAllAttachmentsMetadata(Mirror service, String itemId) {
try {
AttachmentsListResponse attachments = service.timeline().attachments().list(itemId).execute();
for (Attachment attachment : attachments.getItems()) {
System.out.println("Attachment content type: " + attachment.getContentType());
System.out.println("Attachment content URL: " + attachment.getContentUrl());
}
} catch (IOException e) {
System.out.println("An error occured: " + e);
}
}
// ...
}
.NET
Uses the .NET client library.
using System;
using Google.Apis.Mirror.v1;
using Google.Apis.Mirror.v1.Data;
public class MyClass {
// ...
/// <summary>
/// Print all attachments' metadata.
/// </summary>
/// <param name="service">Authorized Mirror service.</param>
/// <param name="itemId">ID of the timeline item the attachments belong to.</param>
public static void PrintAllAttachmentsMetadata(MirrorService service, String itemId) {
try {
AttachmentsListResponse attachments = service.Timeline.Attachments.List(itemId).Fetch();
foreach (Attachment attachment in attachments.Items) {
Console.WriteLine("Attachment content type: " + attachment.ContentType);
Console.WriteLine("Attachment content URL: " + attachment.ContentUrl);
}
} catch (Exception e) {
Console.WriteLine("An error occurred: " + e.Message);
}
}
// ...
}
PHP
Uses the PHP client library.
/**
* Print all attachments' metadata.
*
* @param Google_MirrorService $service Authorized Mirror service.
* @param string $itemId ID of the timeline item the attachments belong to.
*/
function printAllAttachmentsMetadata($service, $itemId) {
try {
$attachments = $service->timeline_attachments->listTimelineAttachments(
$itemId);
foreach ($attachments->getItems() as $attachment) {
print "Attachment content type: " . $attachment->getContentType() . "\n";
print "Attachment content URL: " . $attachment->getContentUrl() . "\n";
}
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
}
}
Python
Uses the Python client library.
from apiclient import errors
# ...
def print_all_attachments_metadata(service, item_id):
"""Print all attachments' metadata.
Args:
service: Authorized Mirror service.
item_id: ID of the timeline item the attachments belong to.
"""
try:
attachments = service.timeline().attachments().list(
itemId=item_id).execute()
for attachment in attachments.get('items', []):
print 'Attachment content type: %s' % attachment['contentType']
print 'Attachment content URL: %s' % attachment['contentUrl']
except errors.HttpError, error:
print 'An error occurred: %s' % error
Ruby
Uses the Ruby client library.
##
# Print all attachments' metadata.
#
# @param [Google::APIClient] client
# Authorized client instance.
# @param [String] item_id
# ID of the timeline item the attachments belong to.
# @return nil
def print_all_attachments_metadata(client, item_id)
mirror = client.discovered_api('mirror', 'v1')
result = client.execute(
:api_method => mirror.timeline.attachments.list,
:parameters => { 'itemId' => item_id })
if result.success?
attachments = result.data
attachments.items.each do |attachment|
puts "Attachment content type: #{attachment.content_type}"
puts "Attachment content URL: #{attachment.content_url}"
end
else
puts "An error occurred: #{result.data['error']['message']}"
end
end
Raw HTTP
Does not use a client library.
GET /mirror/v1/timeline/timeline item id/attachments HTTP/1.1
Host: www.googleapis.com
Authorization: Bearer auth token
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eRetrieves a list of attachments associated with a specific timeline item using the \u003ccode\u003eitemId\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eRequires authorization with the \u003ccode\u003ehttps://www.googleapis.com/auth/glass.timeline\u003c/code\u003e scope.\u003c/p\u003e\n"],["\u003cp\u003eReturns an \u003ccode\u003eattachmentsList\u003c/code\u003e resource containing an array of \u003ccode\u003etimeline.attachments\u003c/code\u003e resources, each representing an attachment.\u003c/p\u003e\n"],["\u003cp\u003eProvides code examples in Java, .NET, PHP, Python, and Ruby demonstrating how to retrieve and utilize attachment metadata.\u003c/p\u003e\n"]]],[],null,["# Timeline.attachments: list\n\n**Requires [authorization](#auth)**\n\nReturns a list of attachments for a timeline item.\n[See an example](#examples).\n\nRequest\n-------\n\n### HTTP request\n\n```\nGET https://www.googleapis.com/mirror/v1/timeline/itemId/attachments\n```\n\n### Parameters\n\n| Parameter name | Value | Description |\n|----------------|----------|-----------------------------------------------------------------|\n| **Path parameters** |||\n| `itemId` | `string` | The ID of the timeline item whose attachments should be listed. |\n\n### Authorization\n\nThis request requires authorization with the following scope ([read more about authentication and authorization](/glass/authorization)).\n\n| Scope |\n|--------------------------------------------------|\n| `https://www.googleapis.com/auth/glass.timeline` |\n\n### Request body\n\nDo not supply a request body with this method.\n\nResponse\n--------\n\nIf successful, this method returns a response body with the following structure:\n\n```text\n{\n \"kind\": \"mirror#attachmentsList\",\n \"items\": [\n timeline.attachments Resource\n ]\n}\n```\n\n| Property name | Value | Description | Notes |\n|---------------|----------|----------------------------------------------------------------|-------|\n| `kind` | `string` | The type of resource. This is always `mirror#attachmentsList`. | |\n| `items[]` | `list` | The list of attachments. | |\n\nExamples\n--------\n\n**Note:** The code examples available for this method do not represent all supported programming languages (see the [client libraries page](/glass/tools-downloads/client-libraries) for a list of supported languages). \n\n### Java\n\nUses the [Java client library](/glass/tools-downloads/client-libraries). \n\n```java\nimport com.google.api.services.mirror.Mirror;\nimport com.google.api.services.mirror.model.Attachment;\nimport com.google.api.services.mirror.model.AttachmentsListResponse;\n\nimport java.io.IOException;\n\npublic class MyClass {\n // ...\n\n /**\n * Print all attachments' metadata.\n * \n * @param service Authorized Mirror service.\n * @param itemId ID of the timeline item the attachments belong to.\n */\n public static void printAllAttachmentsMetadata(Mirror service, String itemId) {\n try {\n AttachmentsListResponse attachments = service.timeline().attachments().list(itemId).execute();\n\n for (Attachment attachment : attachments.getItems()) {\n System.out.println(\"Attachment content type: \" + attachment.getContentType());\n System.out.println(\"Attachment content URL: \" + attachment.getContentUrl());\n }\n } catch (IOException e) {\n System.out.println(\"An error occured: \" + e);\n }\n\n }\n\n // ...\n}\n```\n\n### .NET\n\nUses the [.NET client library](/glass/tools-downloads/client-libraries). \n\n```carbon\nusing System;\nusing Google.Apis.Mirror.v1;\nusing Google.Apis.Mirror.v1.Data;\n\npublic class MyClass {\n // ...\n\n /// \u003csummary\u003e\n /// Print all attachments' metadata.\n /// \u003c/summary\u003e\n /// \u003cparam name=\"service\"\u003eAuthorized Mirror service.\u003c/param\u003e\n /// \u003cparam name=\"itemId\"\u003eID of the timeline item the attachments belong to.\u003c/param\u003e\n public static void PrintAllAttachmentsMetadata(MirrorService service, String itemId) {\n try {\n AttachmentsListResponse attachments = service.Timeline.Attachments.List(itemId).Fetch();\n\n foreach (Attachment attachment in attachments.Items) {\n Console.WriteLine(\"Attachment content type: \" + attachment.ContentType);\n Console.WriteLine(\"Attachment content URL: \" + attachment.ContentUrl);\n }\n } catch (Exception e) {\n Console.WriteLine(\"An error occurred: \" + e.Message);\n }\n }\n\n // ...\n}\n```\n\n### PHP\n\nUses the [PHP client library](/glass/tools-downloads/client-libraries). \n\n```php\n/**\n * Print all attachments' metadata.\n *\n * @param Google_MirrorService $service Authorized Mirror service.\n * @param string $itemId ID of the timeline item the attachments belong to.\n */\nfunction printAllAttachmentsMetadata($service, $itemId) {\n try {\n $attachments = $service-\u003etimeline_attachments-\u003elistTimelineAttachments(\n $itemId);\n\n foreach ($attachments-\u003egetItems() as $attachment) {\n print \"Attachment content type: \" . $attachment-\u003egetContentType() . \"\\n\";\n print \"Attachment content URL: \" . $attachment-\u003egetContentUrl() . \"\\n\";\n }\n } catch (Exception $e) {\n print \"An error occurred: \" . $e-\u003egetMessage();\n }\n}\n```\n\n### Python\n\nUses the [Python client library](/glass/tools-downloads/client-libraries). \n\n```python\nfrom apiclient import errors\n# ...\n\ndef print_all_attachments_metadata(service, item_id):\n \"\"\"Print all attachments' metadata.\n\n Args:\n service: Authorized Mirror service.\n item_id: ID of the timeline item the attachments belong to.\n \"\"\"\n try:\n attachments = service.timeline().attachments().list(\n itemId=item_id).execute()\n for attachment in attachments.get('items', []):\n print 'Attachment content type: %s' % attachment['contentType']\n print 'Attachment content URL: %s' % attachment['contentUrl']\n except errors.HttpError, error:\n print 'An error occurred: %s' % error\n```\n\n### Ruby\n\nUses the [Ruby client library](/glass/tools-downloads/client-libraries). \n\n```ruby\n##\n# Print all attachments' metadata.\n#\n# @param [Google::APIClient] client\n# Authorized client instance.\n# @param [String] item_id\n# ID of the timeline item the attachments belong to.\n# @return nil\ndef print_all_attachments_metadata(client, item_id)\n mirror = client.discovered_api('mirror', 'v1')\n result = client.execute(\n :api_method =\u003e mirror.timeline.attachments.list,\n :parameters =\u003e { 'itemId' =\u003e item_id })\n if result.success?\n attachments = result.data\n attachments.items.each do |attachment|\n puts \"Attachment content type: #{attachment.content_type}\"\n puts \"Attachment content URL: #{attachment.content_url}\"\n end\n else\n puts \"An error occurred: #{result.data['error']['message']}\"\n end\nend\n```\n\n### Raw HTTP\n\nDoes not use a client library. \n\n```text\nGET /mirror/v1/timeline/timeline item id/attachments HTTP/1.1\nHost: www.googleapis.com\nAuthorization: Bearer auth token\n```"]]