Timeline: patch
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
승인 필요
제자리에 있는 타임라인 항목을 업데이트합니다. 이 메서드는 패치 시멘틱스를 지원합니다.
예시 보기
요청
HTTP 요청
PATCH https://www.googleapis.com/mirror/v1/timeline/id
매개변수
매개변수 이름 |
값 |
설명 |
경로 매개변수 |
id |
string |
타임라인 항목의 ID입니다.
|
승인
이 요청에는 다음 범위 중 최소 하나를 사용하여 인증이 필요합니다. (인증 및 승인에 대해 자세히 알아보기)
범위 |
https://www.googleapis.com/auth/glass.timeline |
https://www.googleapis.com/auth/glass.location |
요청 본문
요청 본문에 패치 의미 체계의 규칙에 따라 타임라인 리소스의 관련 부분을 제공합니다.
응답
요청에 성공할 경우 이 메서드는 응답 본문에 타임라인 리소스를 반환합니다.
예
참고: 이 메서드에 제공되는 코드 예시가 지원되는 모든 프로그래밍 언어를 나타내는 것은 아닙니다. 지원되는 언어 목록은 클라이언트 라이브러리 페이지를 참조하세요.
자바
Java 클라이언트 라이브러리를 사용합니다.
import com.google.api.services.mirror.Mirror;
import com.google.api.services.mirror.model.TimelineItem;
import java.io.IOException;
public class MyClass {
// ...
/**
* Update the text of an existing timeline item.
*
* @param service Authorized Mirror service.
* @param itemId ID of the timeline item to update.
* @param newText New text content for the timeline item.
* @return Updated timeline item on success, {@code null} otherwise.
*/
public static TimelineItem patchTimelineItem(Mirror service, String itemId, String newText) {
TimelineItem patchedTimelineItem = new TimelineItem();
patchedTimelineItem.setText(newText);
try {
return service.timeline().patch(itemId, patchedTimelineItem).execute();
} catch (IOException e) {
System.err.println("An error occurred: " + e);
return null;
}
}
// ...
}
.NET
.NET 클라이언트 라이브러리를 사용합니다.
using System;
using Google.Apis.Mirror.v1;
using Google.Apis.Mirror.v1.Data;
public class MyClass {
// ...
/// <summary>
/// Update the text of an existing timeline item.
/// </summary>
/// <param name='service'>Authorized Mirror service.</param>
/// <param name='itemId'>ID of the timeline item to update.</param>
/// <param name='newText'>
/// New text content for the timeline item.
/// </param>
/// <returns>
/// Updated timeline item on success, null otherwise.
/// </returns>
public static TimelineItem PatchTimelineItem(MirrorService service,
String itemId, String newText) {
TimelineItem patchedTimelineItem = new TimelineItem() {
Text = newText
};
try {
return service.Timeline.Patch(patchedTimelineItem, itemId).Fetch();
} catch (Exception e) {
Console.WriteLine("An error occurred: " + e.Message);
return null;
}
}
// ...
}
PHP
PHP 클라이언트 라이브러리를 사용합니다.
/**
* Update the text of an existing timeline item.
*
* @param Google_MirrorService $service Authorized Mirror service.
* @param string $itemId ID of the timeline item to update.
* @param string $newText New text content for the timeline item.
* @return Google_TimelineItem Updated timeline item on success,
* null otherwise.
*/
function patchTimelineItem($service, $itemId, $newText) {
try {
$patchedTimelineItem = new Google_TimelineItem();
$patchedTimelineItem->setText($text);
return $service->timeline->patch($itemId, $patchedTimelineItem);
} catch (Exception $e) {
print 'An error occurred: ' . $e->getMessage();
return null;
}
}
Python
Python 클라이언트 라이브러리를 사용합니다.
from apiclient import errors
# ...
def patch_timeline_item(service, item_id, new_text):
"""Update the text of an existing timeline item.
Args:
service: Authorized Mirror service.
item_id: ID of the timeline item to update.
new_text: New text content for the timeline item.
Returns:
Updated timeline item on success, None otherwise.
"""
patched_timeline_item = {'text': new_text}
try:
return service.timeline().patch(
id=item_id, body=patched_timeline_item).execute()
except errors.HttpError, error:
print 'An error occurred: %s' % error
return None
Ruby
Ruby 클라이언트 라이브러리 사용
##
# Update the text of an existing Timeline Item.
#
# @param [Google::APIClient] client
# Authorized client instance.
# @param [String] item_id
# ID of the timeline item to update.
# @param [String] new_text
# New text content for the timeline item.
# @return [Google::APIClient::Schema::Mirror::V1::TimelineItem]
# Updated timeline item on success, nil otherwise.
def patch_timeline_item(client, item_id, new_text)
mirror = client.discovered_api('mirror', 'v1')
result = client.execute(
:api_method => mirror.timeline.patch,
:body_object => { 'text' => new_text },
:parameters => { 'id' => item_id })
if result.success?
return result.data
end
puts "An error occurred: #{result.data['error']['message']}"
end
Go
Go 클라이언트 라이브러리를 사용합니다.
import (
"code.google.com/p/google-api-go-client/mirror/v1"
"fmt"
)
// PatchTimelineItem updates the text of an existing timeline item.
func PatchTimelineItem(g *mirror.Service, itemId string, newText string) (
*mirror.TimelineItem, error) {
t := &mirror.TimelineItem{Text: newText}
r, err := g.Timeline.Patch(itemId, t).Do()
if err != nil {
fmt.Printf("An error occurred: %v\n", err)
return nil, err
}
return r, nil
}
원시 HTTP
클라이언트 라이브러리를 사용하지 않습니다.
PATCH /mirror/v1/timeline/timeline item id HTTP/1.1
Host: www.googleapis.com
Authorization: Bearer auth token
Content-Type: application/json
Content-Length: 26
{ "text": "Hello world" }
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2024-08-22(UTC)
[null,null,["최종 업데이트: 2024-08-22(UTC)"],[[["\u003cp\u003eUpdates an existing timeline item using patch semantics, allowing for partial modifications.\u003c/p\u003e\n"],["\u003cp\u003eRequires authorization with either \u003ccode\u003eglass.timeline\u003c/code\u003e or \u003ccode\u003eglass.location\u003c/code\u003e scope.\u003c/p\u003e\n"],["\u003cp\u003eThe request body should contain the desired changes to the Timeline resource.\u003c/p\u003e\n"],["\u003cp\u003eSuccessful requests return the updated Timeline resource.\u003c/p\u003e\n"],["\u003cp\u003eProvides code examples in Java, .NET, PHP, Python, Ruby, and Go demonstrating how to use this method.\u003c/p\u003e\n"]]],[],null,["# Timeline: patch\n\n**Requires [authorization](#auth)**\n\nUpdates a timeline item in place. This method supports [patch semantics](/glass/performance#patch).\n[See an example](#examples).\n\nRequest\n-------\n\n### HTTP request\n\n```\nPATCH https://www.googleapis.com/mirror/v1/timeline/id\n```\n\n### Parameters\n\n| Parameter name | Value | Description |\n|----------------|----------|------------------------------|\n| **Path parameters** |||\n| `id` | `string` | The ID of the timeline item. |\n\n### Authorization\n\nThis request requires authorization with at least one of the following scopes ([read more about authentication and authorization](/glass/authorization)).\n\n| Scope |\n|--------------------------------------------------|\n| `https://www.googleapis.com/auth/glass.timeline` |\n| `https://www.googleapis.com/auth/glass.location` |\n\n### Request body\n\nIn the request body, supply the relevant portions of a [Timeline resource](/glass/v1/reference/timeline#resource), according to the rules of patch semantics.\n\nResponse\n--------\n\nIf successful, this method returns a [Timeline resource](/glass/v1/reference/timeline#resource) in the response body.\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.TimelineItem;\n\nimport java.io.IOException;\n\npublic class MyClass {\n // ...\n\n /**\n * Update the text of an existing timeline item.\n * \n * @param service Authorized Mirror service.\n * @param itemId ID of the timeline item to update.\n * @param newText New text content for the timeline item.\n * @return Updated timeline item on success, {@code null} otherwise.\n */\n public static TimelineItem patchTimelineItem(Mirror service, String itemId, String newText) {\n TimelineItem patchedTimelineItem = new TimelineItem();\n patchedTimelineItem.setText(newText);\n try {\n return service.timeline().patch(itemId, patchedTimelineItem).execute();\n } catch (IOException e) {\n System.err.println(\"An error occurred: \" + e);\n return null;\n }\n }\n\n // ...\n}\n```\n\n### .NET\n\nUses the [.NET client library](/glass/tools-downloads/client-libraries). \n\n```css+lasso\nusing System;\n\nusing Google.Apis.Mirror.v1;\nusing Google.Apis.Mirror.v1.Data;\n\npublic class MyClass {\n // ...\n\n /// \u003csummary\u003e\n /// Update the text of an existing timeline item.\n /// \u003c/summary\u003e\n /// \u003cparam name='service'\u003eAuthorized Mirror service.\u003c/param\u003e\n /// \u003cparam name='itemId'\u003eID of the timeline item to update.\u003c/param\u003e\n /// \u003cparam name='newText'\u003e\n /// New text content for the timeline item.\n /// \u003c/param\u003e\n /// \u003creturns\u003e\n /// Updated timeline item on success, null otherwise.\n /// \u003c/returns\u003e\n public static TimelineItem PatchTimelineItem(MirrorService service,\n String itemId, String newText) {\n TimelineItem patchedTimelineItem = new TimelineItem() {\n Text = newText\n };\n try {\n return service.Timeline.Patch(patchedTimelineItem, itemId).Fetch();\n } catch (Exception e) {\n Console.WriteLine(\"An error occurred: \" + e.Message);\n return null;\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 * Update the text of an existing timeline item.\n *\n * @param Google_MirrorService $service Authorized Mirror service.\n * @param string $itemId ID of the timeline item to update.\n * @param string $newText New text content for the timeline item.\n * @return Google_TimelineItem Updated timeline item on success,\n * null otherwise.\n */\nfunction patchTimelineItem($service, $itemId, $newText) {\n try {\n $patchedTimelineItem = new Google_TimelineItem();\n $patchedTimelineItem-\u003esetText($text);\n return $service-\u003etimeline-\u003epatch($itemId, $patchedTimelineItem);\n } catch (Exception $e) {\n print 'An error occurred: ' . $e-\u003egetMessage();\n return null;\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 patch_timeline_item(service, item_id, new_text):\n \"\"\"Update the text of an existing timeline item.\n\n Args:\n service: Authorized Mirror service.\n item_id: ID of the timeline item to update.\n new_text: New text content for the timeline item.\n\n Returns:\n Updated timeline item on success, None otherwise.\n \"\"\"\n patched_timeline_item = {'text': new_text}\n try:\n return service.timeline().patch(\n id=item_id, body=patched_timeline_item).execute()\n except errors.HttpError, error:\n print 'An error occurred: %s' % error\n return None\n```\n\n### Ruby\n\nUses the [Ruby client library](/glass/tools-downloads/client-libraries). \n\n```ruby\n##\n# Update the text of an existing Timeline Item.\n#\n# @param [Google::APIClient] client\n# Authorized client instance.\n# @param [String] item_id\n# ID of the timeline item to update.\n# @param [String] new_text\n# New text content for the timeline item.\n# @return [Google::APIClient::Schema::Mirror::V1::TimelineItem]\n# Updated timeline item on success, nil otherwise.\ndef patch_timeline_item(client, item_id, new_text)\n mirror = client.discovered_api('mirror', 'v1')\n result = client.execute(\n :api_method =\u003e mirror.timeline.patch,\n :body_object =\u003e { 'text' =\u003e new_text },\n :parameters =\u003e { 'id' =\u003e item_id })\n if result.success?\n return result.data\n end\n puts \"An error occurred: #{result.data['error']['message']}\"\nend\n```\n\n### Go\n\nUses the [Go client library](/glass/tools-downloads/client-libraries). \n\n```go\nimport (\n\t\"code.google.com/p/google-api-go-client/mirror/v1\"\n\t\"fmt\"\n)\n\n// PatchTimelineItem updates the text of an existing timeline item.\nfunc PatchTimelineItem(g *mirror.Service, itemId string, newText string) (\n\t*mirror.TimelineItem, error) {\n\tt := &mirror.TimelineItem{Text: newText}\n\tr, err := g.Timeline.Patch(itemId, t).Do()\n\tif err != nil {\n\t\tfmt.Printf(\"An error occurred: %v\\n\", err)\n\t\treturn nil, err\n\t}\n\treturn r, nil\n}\n```\n\n### Raw HTTP\n\nDoes not use a client library. \n\n```text\nPATCH /mirror/v1/timeline/timeline item id HTTP/1.1\nHost: www.googleapis.com\nAuthorization: Bearer auth token\nContent-Type: application/json\nContent-Length: 26\n\n{ \"text\": \"Hello world\" }\n```"]]