{ "cells": [ { "cell_type": "code", "execution_count": 5, "id": "cdcbfae8-4395-433b-a163-dad94ff23e8e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[\n", " {\n", " \"type\": \"log--harvest\",\n", " \"id\": \"ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4\",\n", " \"links\": {\n", " \"self\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4?resourceVersion=id%3A117\"\n", " }\n", " },\n", " \"attributes\": {\n", " \"drupal_internal__id\": 40,\n", " \"drupal_internal__revision_id\": 117,\n", " \"langcode\": \"en\",\n", " \"revision_created\": \"2024-09-23T09:15:08+00:00\",\n", " \"revision_log_message\": null,\n", " \"name\": \"Harvest log 40\",\n", " \"timestamp\": \"2024-09-23T09:13:35+00:00\",\n", " \"status\": \"done\",\n", " \"created\": \"2024-09-23T09:13:41+00:00\",\n", " \"changed\": \"2024-09-23T09:15:08+00:00\",\n", " \"default_langcode\": true,\n", " \"revision_translation_affected\": true,\n", " \"comment\": {\n", " \"status\": 2,\n", " \"cid\": 0,\n", " \"last_comment_timestamp\": 1727082908,\n", " \"last_comment_name\": null,\n", " \"last_comment_uid\": 1,\n", " \"comment_count\": 0\n", " },\n", " \"data\": null,\n", " \"notes\": null,\n", " \"flag\": [],\n", " \"is_group_assignment\": false,\n", " \"geometry\": {\n", " \"value\": \"POLYGON ((10.747713618221 48.694039316345, 10.747655366943 48.694041854983, 10.747352668456 48.694044456288, 10.746988118483 48.6940287062, 10.746433053748 48.693978472556, 10.746250998619 48.693961759714, 10.7461753607 48.693960936447, 10.746104245243 48.693957216059, 10.745939475211 48.693961314975, 10.745850196702 48.693972128187, 10.745790599455 48.694042190467, 10.745716117113 48.694173962885, 10.745502573537 48.695164024359, 10.745406797387 48.695235372785, 10.74520498955 48.695380745378, 10.745059826758 48.695487886107, 10.744978900971 48.695628460197, 10.744886906689 48.695842654082, 10.744784109987 48.696114283663, 10.744667158164 48.69633234191, 10.744618839846 48.69653271304, 10.744621273526 48.696652592521, 10.744641989421 48.696721633074, 10.744663189454 48.696863319971, 10.744719459551 48.697091539599, 10.744795409464 48.697276808576, 10.744950823047 48.697506108774, 10.745094966035 48.697686095699, 10.745257208999 48.697886693248, 10.745422114877 48.69810091126, 10.745634035074 48.698288053176, 10.745801394254 48.698411469309, 10.745905721986 48.698480736343, 10.746117077321 48.698595800492, 10.746424826502 48.698701343233, 10.746632693636 48.698767915052, 10.74681660007 48.698791741071, 10.747067264596 48.698832112942, 10.747295390227 48.698869250842, 10.747629399231 48.698894527626, 10.747960078898 48.698884061631, 10.748345959049 48.698853129008, 10.748566129586 48.698822421861, 10.748545941747 48.69878156207, 10.748520165013 48.698736318038, 10.748374465229 48.69845415984, 10.747053879092 48.698540875939, 10.747053546046 48.698540745584, 10.747053066437 48.698540777169, 10.746298814758 48.698245698355, 10.745821378975 48.697843469215, 10.747824633382 48.697711224506, 10.747658060988 48.697520475029, 10.747534619252 48.697387298543, 10.747428214692 48.697295673988, 10.74732669971 48.697204102543, 10.747282255281 48.697139320811, 10.747209284332 48.697030703761, 10.747182734932 48.696907214079, 10.7471967115 48.696803859423, 10.747235378259 48.696707338066, 10.747295016607 48.696625163451, 10.747355744508 48.696564763137, 10.747449337765 48.696510205824, 10.747588996812 48.696455070263, 10.747769616027 48.69640802375, 10.747913973991 48.696360582709, 10.748020387579 48.696314887248, 10.748368174046 48.696166060134, 10.748570023971 48.696057102913, 10.748695929525 48.695959370518, 10.748787396004 48.695853529492, 10.749054840599 48.695558951186, 10.749267245237 48.695352893485, 10.749357962031 48.695211432198, 10.749426252116 48.695092389323, 10.749559471935 48.694830885773, 10.749734443117 48.694468666186, 10.749841284384 48.694251930002, 10.749991043074 48.693975137752, 10.75008552632 48.693806176353, 10.750019634095 48.693658836055, 10.749974724823 48.693521278107, 10.749859249445 48.693253752548, 10.749833263471 48.693209083015, 10.749706219355 48.693234135446, 10.749598375148 48.693258388025, 10.749289429746 48.693373683396, 10.749010188146 48.693497671446, 10.748513873361 48.693724475341, 10.747884352359 48.693999288542, 10.747777729553 48.694036522286, 10.747776945448 48.694036556458, 10.747713618221 48.694039316345))\",\n", " \"geo_type\": \"Polygon\",\n", " \"lat\": 48.694039316345,\n", " \"lon\": 10.747713618221,\n", " \"left\": 10.744618839846,\n", " \"top\": 48.698894527626,\n", " \"right\": 10.75008552632,\n", " \"bottom\": 48.693209083015,\n", " \"geohash\": \"u0xth\",\n", " \"latlon\": \"48.694039316345,10.747713618221\"\n", " },\n", " \"is_movement\": false,\n", " \"quick\": [],\n", " \"lot_number\": null\n", " },\n", " \"relationships\": {\n", " \"log_type\": {\n", " \"data\": {\n", " \"type\": \"log_type--log_type\",\n", " \"id\": \"bb376a51-4586-46c8-b1cd-cdeea278599a\",\n", " \"meta\": {\n", " \"drupal_internal__target_id\": \"harvest\"\n", " }\n", " },\n", " \"links\": {\n", " \"related\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/log_type?resourceVersion=id%3A117\"\n", " },\n", " \"self\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/relationships/log_type?resourceVersion=id%3A117\"\n", " }\n", " }\n", " },\n", " \"revision_user\": {\n", " \"data\": {\n", " \"type\": \"user--user\",\n", " \"id\": \"a93c675c-72b1-40ea-90ae-41df789b7607\",\n", " \"meta\": {\n", " \"drupal_internal__target_id\": 1\n", " }\n", " },\n", " \"links\": {\n", " \"related\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/revision_user?resourceVersion=id%3A117\"\n", " },\n", " \"self\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/relationships/revision_user?resourceVersion=id%3A117\"\n", " }\n", " }\n", " },\n", " \"uid\": {\n", " \"data\": {\n", " \"type\": \"user--user\",\n", " \"id\": \"a93c675c-72b1-40ea-90ae-41df789b7607\",\n", " \"meta\": {\n", " \"drupal_internal__target_id\": 1\n", " }\n", " },\n", " \"links\": {\n", " \"related\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/uid?resourceVersion=id%3A117\"\n", " },\n", " \"self\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/relationships/uid?resourceVersion=id%3A117\"\n", " }\n", " }\n", " },\n", " \"file\": {\n", " \"data\": [],\n", " \"links\": {\n", " \"related\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/file?resourceVersion=id%3A117\"\n", " },\n", " \"self\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/relationships/file?resourceVersion=id%3A117\"\n", " }\n", " }\n", " },\n", " \"image\": {\n", " \"data\": [],\n", " \"links\": {\n", " \"related\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/image?resourceVersion=id%3A117\"\n", " },\n", " \"self\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/relationships/image?resourceVersion=id%3A117\"\n", " }\n", " }\n", " },\n", " \"group\": {\n", " \"data\": [],\n", " \"links\": {\n", " \"related\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/group?resourceVersion=id%3A117\"\n", " },\n", " \"self\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/relationships/group?resourceVersion=id%3A117\"\n", " }\n", " }\n", " },\n", " \"location\": {\n", " \"data\": [\n", " {\n", " \"type\": \"asset--land\",\n", " \"id\": \"7842c79e-d2be-41a7-b6a6-e9af36dd9f7e\",\n", " \"meta\": {\n", " \"drupal_internal__target_id\": 54\n", " }\n", " }\n", " ],\n", " \"links\": {\n", " \"related\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/location?resourceVersion=id%3A117\"\n", " },\n", " \"self\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/relationships/location?resourceVersion=id%3A117\"\n", " }\n", " }\n", " },\n", " \"asset\": {\n", " \"data\": [\n", " {\n", " \"type\": \"asset--plant\",\n", " \"id\": \"71c136e3-fae0-40a6-b3d7-8e1581ee4882\",\n", " \"meta\": {\n", " \"drupal_internal__target_id\": 69\n", " }\n", " }\n", " ],\n", " \"links\": {\n", " \"related\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/asset?resourceVersion=id%3A117\"\n", " },\n", " \"self\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/relationships/asset?resourceVersion=id%3A117\"\n", " }\n", " }\n", " },\n", " \"category\": {\n", " \"data\": [],\n", " \"links\": {\n", " \"related\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/category?resourceVersion=id%3A117\"\n", " },\n", " \"self\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/relationships/category?resourceVersion=id%3A117\"\n", " }\n", " }\n", " },\n", " \"quantity\": {\n", " \"data\": [\n", " {\n", " \"type\": \"quantity--standard\",\n", " \"id\": \"51c3d816-6256-4386-92a0-6d12b626cad0\",\n", " \"meta\": {\n", " \"target_revision_id\": 37,\n", " \"drupal_internal__target_id\": 27\n", " }\n", " }\n", " ],\n", " \"links\": {\n", " \"related\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/quantity?resourceVersion=id%3A117\"\n", " },\n", " \"self\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/relationships/quantity?resourceVersion=id%3A117\"\n", " }\n", " }\n", " },\n", " \"owner\": {\n", " \"data\": [\n", " {\n", " \"type\": \"user--user\",\n", " \"id\": \"a93c675c-72b1-40ea-90ae-41df789b7607\",\n", " \"meta\": {\n", " \"drupal_internal__target_id\": 1\n", " }\n", " }\n", " ],\n", " \"links\": {\n", " \"related\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/owner?resourceVersion=id%3A117\"\n", " },\n", " \"self\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/relationships/owner?resourceVersion=id%3A117\"\n", " }\n", " }\n", " },\n", " \"equipment\": {\n", " \"data\": [],\n", " \"links\": {\n", " \"related\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/equipment?resourceVersion=id%3A117\"\n", " },\n", " \"self\": {\n", " \"href\": \"https://farmos.wagframe.duckdns.org/api/log/harvest/ae417c7e-e1f2-4184-b6f9-e5c8027a2fc4/relationships/equipment?resourceVersion=id%3A117\"\n", " }\n", " }\n", " }\n", " }\n", " }\n", "]\n" ] } ], "source": [ "from farmOS import farmOS\n", "\n", "hostname = \"farmos.wagframe.duckdns.org\"\n", "username = \"matze\"\n", "password = \"m6ChEHx5gMqgctr8dpb3fhATZbQS8hv4\"\n", "\n", "# Create the client.\n", "farm_client = farmOS(\n", " hostname=hostname,\n", " client_id = \"jupyter\", # Optional. The default oauth client_id \"farm\" is enabled on all farmOS servers.\n", ")\n", "\n", "# Authorize the client, save the token.\n", "# A scope can be specified, but will default to the default scope set when initializing the client.\n", "token = farm_client.authorize(username, password)\n", "#farm_client.info()\n", "#response = farm_client.resource.get('log', 'harvest')\n", "#print(json.dumps(response, indent=2))\n", "\n", "# Get all observation logs.\n", "#logs = list(farm_client.log.iterate('observation'))\n", "\n", "# Filter to 'done' logs.\n", "filters = farm_client.filter('name', 'Harvest log 40')\n", "done_observations = list(farm_client.log.iterate('harvest', params=filters))\n", "print(json.dumps(done_observations, indent=2))" ] }, { "cell_type": "code", "execution_count": null, "id": "685f20c8-567a-4911-8b99-9be87f71b237", "metadata": { "scrolled": true }, "outputs": [], "source": [ "print(json.dumps(response, indent=8))" ] }, { "cell_type": "code", "execution_count": null, "id": "7fc852bd-12bb-4385-b84c-f28b68ed29bf", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.5" } }, "nbformat": 4, "nbformat_minor": 5 }