port-ocean 0.4.12__tar.gz → 0.4.14__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of port-ocean might be problematic. Click here for more details.

Files changed (119) hide show
  1. {port_ocean-0.4.12 → port_ocean-0.4.14}/PKG-INFO +13 -13
  2. {port_ocean-0.4.12 → port_ocean-0.4.14}/README.md +12 -12
  3. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/cookiecutter.json +1 -1
  4. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/clients/port/mixins/blueprints.py +31 -2
  5. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/defaults/common.py +2 -0
  6. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/defaults/initialize.py +73 -4
  7. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/entities_state_applier/port/applier.py +2 -0
  8. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/port_app_config/models.py +1 -0
  9. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/integrations/mixins/sync_raw.py +4 -0
  10. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/exceptions/port_defaults.py +7 -1
  11. {port_ocean-0.4.12 → port_ocean-0.4.14}/pyproject.toml +1 -1
  12. {port_ocean-0.4.12 → port_ocean-0.4.14}/LICENSE.md +0 -0
  13. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/__init__.py +0 -0
  14. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/bootstrap.py +0 -0
  15. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/__init__.py +0 -0
  16. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cli.py +0 -0
  17. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/commands/__init__.py +0 -0
  18. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/commands/defaults/__init___.py +0 -0
  19. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/commands/defaults/clean.py +0 -0
  20. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/commands/defaults/dock.py +0 -0
  21. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/commands/defaults/group.py +0 -0
  22. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/commands/list_integrations.py +0 -0
  23. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/commands/main.py +0 -0
  24. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/commands/new.py +0 -0
  25. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/commands/pull.py +0 -0
  26. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/commands/sail.py +0 -0
  27. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/commands/version.py +0 -0
  28. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/__init__.py +0 -0
  29. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/extensions.py +0 -0
  30. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/hooks/post_gen_project.py +0 -0
  31. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.dockerignore +0 -0
  32. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.gitignore +0 -0
  33. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.port/resources/.gitignore +0 -0
  34. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/.port/spec.yaml +0 -0
  35. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/CHANGELOG.md +0 -0
  36. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/Dockerfile +0 -0
  37. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/Makefile +0 -0
  38. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/README.md +0 -0
  39. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/changelog/.gitignore +0 -0
  40. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/config.yaml +0 -0
  41. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/debug.py +0 -0
  42. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/main.py +0 -0
  43. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/poetry.toml +0 -0
  44. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/pyproject.toml +0 -0
  45. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/cookiecutter/{{cookiecutter.integration_slug}}/tests/__init__.py +0 -0
  46. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/cli/utils.py +0 -0
  47. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/clients/__init__.py +0 -0
  48. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/clients/port/__init__.py +0 -0
  49. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/clients/port/authentication.py +0 -0
  50. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/clients/port/client.py +0 -0
  51. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/clients/port/mixins/__init__.py +0 -0
  52. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/clients/port/mixins/entities.py +0 -0
  53. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/clients/port/mixins/integrations.py +0 -0
  54. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/clients/port/mixins/migrations.py +0 -0
  55. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/clients/port/retry_transport.py +0 -0
  56. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/clients/port/types.py +0 -0
  57. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/clients/port/utils.py +0 -0
  58. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/config/__init__.py +0 -0
  59. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/config/base.py +0 -0
  60. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/config/dynamic.py +0 -0
  61. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/config/settings.py +0 -0
  62. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/consumers/__init__.py +0 -0
  63. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/consumers/base_consumer.py +0 -0
  64. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/consumers/kafka_consumer.py +0 -0
  65. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/context/__init__.py +0 -0
  66. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/context/event.py +0 -0
  67. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/context/ocean.py +0 -0
  68. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/context/resource.py +0 -0
  69. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/context/utils.py +0 -0
  70. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/__init__.py +0 -0
  71. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/defaults/__init__.py +0 -0
  72. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/defaults/clean.py +0 -0
  73. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/event_listener/__init__.py +0 -0
  74. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/event_listener/base.py +0 -0
  75. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/event_listener/factory.py +0 -0
  76. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/event_listener/http.py +0 -0
  77. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/event_listener/kafka.py +0 -0
  78. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/event_listener/once.py +0 -0
  79. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/event_listener/polling.py +0 -0
  80. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/__init__.py +0 -0
  81. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/base.py +0 -0
  82. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/entities_state_applier/__init__.py +0 -0
  83. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/entities_state_applier/base.py +0 -0
  84. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/entities_state_applier/port/__init__.py +0 -0
  85. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/entities_state_applier/port/get_related_entities.py +0 -0
  86. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/entities_state_applier/port/order_by_entities_dependencies.py +0 -0
  87. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/entities_state_applier/port/validate_entity_relations.py +0 -0
  88. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/entity_processor/__init__.py +0 -0
  89. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/entity_processor/base.py +0 -0
  90. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/entity_processor/jq_entity_processor.py +0 -0
  91. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/port_app_config/__init__.py +0 -0
  92. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/port_app_config/api.py +0 -0
  93. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/handlers/port_app_config/base.py +0 -0
  94. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/integrations/__init__.py +0 -0
  95. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/integrations/base.py +0 -0
  96. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/integrations/mixins/__init__.py +0 -0
  97. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/integrations/mixins/events.py +0 -0
  98. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/integrations/mixins/handler.py +0 -0
  99. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/integrations/mixins/sync.py +0 -0
  100. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/integrations/mixins/utils.py +0 -0
  101. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/models.py +0 -0
  102. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/ocean_types.py +0 -0
  103. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/core/utils.py +0 -0
  104. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/exceptions/__init__.py +0 -0
  105. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/exceptions/api.py +0 -0
  106. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/exceptions/base.py +0 -0
  107. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/exceptions/clients.py +0 -0
  108. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/exceptions/context.py +0 -0
  109. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/exceptions/core.py +0 -0
  110. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/helpers/__init__.py +0 -0
  111. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/helpers/async_client.py +0 -0
  112. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/helpers/retry.py +0 -0
  113. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/logger_setup.py +0 -0
  114. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/middlewares.py +0 -0
  115. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/ocean.py +0 -0
  116. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/py.typed +0 -0
  117. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/run.py +0 -0
  118. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/utils.py +0 -0
  119. {port_ocean-0.4.12 → port_ocean-0.4.14}/port_ocean/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: port-ocean
3
- Version: 0.4.12
3
+ Version: 0.4.14
4
4
  Summary: Port Ocean is a CLI tool for managing your Port projects.
5
5
  Home-page: https://app.getport.io
6
6
  Keywords: ocean,port-ocean,port
@@ -61,13 +61,13 @@ empowering engineers to effortlessly prioritize key features and streamline the
61
61
  ## Installation
62
62
  In order to install the Ocean Framework, run the following command:
63
63
 
64
- ```sh
64
+ ```bash
65
65
  pip install port-ocean[cli]
66
66
  ```
67
67
 
68
68
  Or
69
69
 
70
- ```sh
70
+ ```bash
71
71
  poetry add port-ocean[cli]
72
72
  ```
73
73
 
@@ -75,13 +75,13 @@ poetry add port-ocean[cli]
75
75
 
76
76
  1. source the integration venv
77
77
 
78
- ```sh
78
+ ```bash
79
79
  . .venv/bin/activate
80
80
  ```
81
81
 
82
82
  2. Run
83
83
 
84
- ```sh
84
+ ```bash
85
85
  ocean sail ./path/to/
86
86
  integration
87
87
  ```
@@ -157,19 +157,19 @@ In order to learn how you can contribute to Ocean, read our [contributing guide]
157
157
 
158
158
  2. Install dependencies:
159
159
 
160
- ```sh
160
+ ```bash
161
161
  make install
162
162
  ```
163
163
 
164
164
  Or (For installing integrations dependencies as well)
165
165
 
166
- ```sh
166
+ ```bash
167
167
  make install/all
168
168
  ```
169
169
 
170
170
  3. source the integration venv
171
171
 
172
- ```sh
172
+ ```bash
173
173
  . .venv/bin/activate
174
174
  ```
175
175
 
@@ -178,7 +178,7 @@ In order to learn how you can contribute to Ocean, read our [contributing guide]
178
178
 
179
179
  2. For new integration run
180
180
 
181
- ```sh
181
+ ```bash
182
182
  make new
183
183
  ```
184
184
 
@@ -186,25 +186,25 @@ In order to learn how you can contribute to Ocean, read our [contributing guide]
186
186
 
187
187
  3. Install dependencies
188
188
 
189
- 4. ```sh
189
+ 4. ```bash
190
190
  cd DESIRED_INTEGRATION_FOLDER && make install
191
191
  ```
192
192
 
193
193
  5. source the integration venv
194
194
 
195
- ```sh
195
+ ```bash
196
196
  . .venv/bin/activate
197
197
  ```
198
198
 
199
199
  6. Run the integration
200
200
 
201
- ```sh
201
+ ```bash
202
202
  make run
203
203
  ```
204
204
 
205
205
  Or
206
206
 
207
- ```sh
207
+ ```bash
208
208
  ocean sail
209
209
  ```
210
210
 
@@ -17,13 +17,13 @@ empowering engineers to effortlessly prioritize key features and streamline the
17
17
  ## Installation
18
18
  In order to install the Ocean Framework, run the following command:
19
19
 
20
- ```sh
20
+ ```bash
21
21
  pip install port-ocean[cli]
22
22
  ```
23
23
 
24
24
  Or
25
25
 
26
- ```sh
26
+ ```bash
27
27
  poetry add port-ocean[cli]
28
28
  ```
29
29
 
@@ -31,13 +31,13 @@ poetry add port-ocean[cli]
31
31
 
32
32
  1. source the integration venv
33
33
 
34
- ```sh
34
+ ```bash
35
35
  . .venv/bin/activate
36
36
  ```
37
37
 
38
38
  2. Run
39
39
 
40
- ```sh
40
+ ```bash
41
41
  ocean sail ./path/to/
42
42
  integration
43
43
  ```
@@ -113,19 +113,19 @@ In order to learn how you can contribute to Ocean, read our [contributing guide]
113
113
 
114
114
  2. Install dependencies:
115
115
 
116
- ```sh
116
+ ```bash
117
117
  make install
118
118
  ```
119
119
 
120
120
  Or (For installing integrations dependencies as well)
121
121
 
122
- ```sh
122
+ ```bash
123
123
  make install/all
124
124
  ```
125
125
 
126
126
  3. source the integration venv
127
127
 
128
- ```sh
128
+ ```bash
129
129
  . .venv/bin/activate
130
130
  ```
131
131
 
@@ -134,7 +134,7 @@ In order to learn how you can contribute to Ocean, read our [contributing guide]
134
134
 
135
135
  2. For new integration run
136
136
 
137
- ```sh
137
+ ```bash
138
138
  make new
139
139
  ```
140
140
 
@@ -142,25 +142,25 @@ In order to learn how you can contribute to Ocean, read our [contributing guide]
142
142
 
143
143
  3. Install dependencies
144
144
 
145
- 4. ```sh
145
+ 4. ```bash
146
146
  cd DESIRED_INTEGRATION_FOLDER && make install
147
147
  ```
148
148
 
149
149
  5. source the integration venv
150
150
 
151
- ```sh
151
+ ```bash
152
152
  . .venv/bin/activate
153
153
  ```
154
154
 
155
155
  6. Run the integration
156
156
 
157
- ```sh
157
+ ```bash
158
158
  make run
159
159
  ```
160
160
 
161
161
  Or
162
162
 
163
- ```sh
163
+ ```bash
164
164
  ocean sail
165
165
  ```
166
166
 
@@ -10,4 +10,4 @@
10
10
  "jinja2_time.TimeExtension",
11
11
  "extensions.VersionExtension"
12
12
  ]
13
- }
13
+ }
@@ -14,13 +14,15 @@ class BlueprintClientMixin:
14
14
  self.auth = auth
15
15
  self.client = client
16
16
 
17
- async def get_blueprint(self, identifier: str) -> Blueprint:
17
+ async def get_blueprint(
18
+ self, identifier: str, should_log: bool = True
19
+ ) -> Blueprint:
18
20
  logger.info(f"Fetching blueprint with id: {identifier}")
19
21
  response = await self.client.get(
20
22
  f"{self.auth.api_url}/blueprints/{identifier}",
21
23
  headers=await self.auth.headers(),
22
24
  )
23
- handle_status_code(response)
25
+ handle_status_code(response, should_log=should_log)
24
26
  return Blueprint.parse_obj(response.json()["blueprint"])
25
27
 
26
28
  async def create_blueprint(
@@ -105,3 +107,30 @@ class BlueprintClientMixin:
105
107
  )
106
108
 
107
109
  handle_status_code(response)
110
+
111
+ async def create_page(
112
+ self,
113
+ page: dict[str, Any],
114
+ ) -> dict[str, Any]:
115
+ logger.info(f"Creating page: {page}")
116
+ response = await self.client.post(
117
+ f"{self.auth.api_url}/pages",
118
+ json=page,
119
+ headers=await self.auth.headers(),
120
+ )
121
+
122
+ handle_status_code(response)
123
+ return page
124
+
125
+ async def delete_page(
126
+ self,
127
+ identifier: str,
128
+ should_raise: bool = False,
129
+ ) -> None:
130
+ logger.info(f"Deleting page: {identifier}")
131
+ response = await self.client.delete(
132
+ f"{self.auth.api_url}/pages/{identifier}",
133
+ headers=await self.auth.headers(),
134
+ )
135
+
136
+ handle_status_code(response, should_raise)
@@ -26,6 +26,7 @@ class Defaults(BaseModel):
26
26
  blueprints: list[dict[str, Any]] = []
27
27
  actions: list[Preset] = []
28
28
  scorecards: list[Preset] = []
29
+ pages: list[dict[str, Any]] = []
29
30
  port_app_config: Optional[PortAppConfig] = Field(
30
31
  default=None, alias="port-app-config"
31
32
  )
@@ -108,6 +109,7 @@ def get_port_integration_defaults(
108
109
  blueprints=default_jsons.get("blueprints", []),
109
110
  actions=default_jsons.get("actions", []),
110
111
  scorecards=default_jsons.get("scorecards", []),
112
+ pages=default_jsons.get("pages", []),
111
113
  port_app_config=port_app_config_class(
112
114
  **default_jsons.get("port-app-config", {})
113
115
  ),
@@ -2,6 +2,7 @@ import asyncio
2
2
  from typing import Type, Any
3
3
 
4
4
  import httpx
5
+ from starlette import status
5
6
  from loguru import logger
6
7
 
7
8
  from port_ocean.clients.port.client import PortClient
@@ -10,6 +11,7 @@ from port_ocean.config.settings import IntegrationConfiguration
10
11
  from port_ocean.context.ocean import ocean
11
12
  from port_ocean.core.defaults.common import Defaults, get_port_integration_defaults
12
13
  from port_ocean.core.handlers.port_app_config.models import PortAppConfig
14
+ from port_ocean.core.models import Blueprint
13
15
  from port_ocean.exceptions.port_defaults import (
14
16
  AbortDefaultCreationError,
15
17
  )
@@ -52,10 +54,38 @@ async def _create_resources(
52
54
  defaults: Defaults,
53
55
  integration_config: IntegrationConfiguration,
54
56
  ) -> None:
57
+ response = await port_client._get_current_integration()
58
+ if response.status_code == status.HTTP_404_NOT_FOUND:
59
+ logger.info("Integration doesn't exist, creating new integration")
60
+ else:
61
+ logger.info("Integration already exists, skipping integration creation...")
62
+ return
63
+
55
64
  creation_stage, *blueprint_patches = deconstruct_blueprints_to_creation_steps(
56
65
  defaults.blueprints
57
66
  )
58
67
 
68
+ blueprints_results = await asyncio.gather(
69
+ *(
70
+ port_client.get_blueprint(blueprint["identifier"], should_log=False)
71
+ for blueprint in creation_stage
72
+ ),
73
+ return_exceptions=True,
74
+ )
75
+
76
+ existing_blueprints = [
77
+ result.identifier
78
+ for result in blueprints_results
79
+ if not isinstance(result, httpx.HTTPStatusError)
80
+ and isinstance(result, Blueprint)
81
+ ]
82
+
83
+ if existing_blueprints:
84
+ logger.info(
85
+ f"Blueprints already exist: {existing_blueprints}. Skipping integration default creation..."
86
+ )
87
+ return
88
+
59
89
  create_results = await asyncio.gather(
60
90
  *(
61
91
  port_client.create_blueprint(
@@ -81,7 +111,7 @@ async def _create_resources(
81
111
  )
82
112
 
83
113
  raise AbortDefaultCreationError(created_blueprints, errors)
84
-
114
+ created_pages = []
85
115
  try:
86
116
  for patch_stage in blueprint_patches:
87
117
  await asyncio.gather(
@@ -111,16 +141,42 @@ async def _create_resources(
111
141
  )
112
142
  )
113
143
 
144
+ create_pages_result = await asyncio.gather(
145
+ *(port_client.create_page(page) for page in defaults.pages),
146
+ return_exceptions=True,
147
+ )
148
+
149
+ created_pages = [
150
+ result.get("identifier", "")
151
+ for result in create_pages_result
152
+ if not isinstance(result, BaseException)
153
+ ]
154
+
155
+ pages_errors = [
156
+ result for result in create_pages_result if isinstance(result, Exception)
157
+ ]
158
+
159
+ if pages_errors:
160
+ for error in pages_errors:
161
+ if isinstance(error, httpx.HTTPStatusError):
162
+ logger.warning(
163
+ f"Failed to create resources: {error.response.text}. Rolling back changes..."
164
+ )
165
+
166
+ raise AbortDefaultCreationError(
167
+ created_blueprints, pages_errors, created_pages
168
+ )
169
+
114
170
  await port_client.create_integration(
115
171
  integration_config.integration.type,
116
172
  integration_config.event_listener.to_request(),
117
173
  port_app_config=defaults.port_app_config,
118
174
  )
119
- except httpx.HTTPStatusError as e:
175
+ except httpx.HTTPStatusError as err:
120
176
  logger.error(
121
- f"Failed to create resources: {e.response.text}. Rolling back changes..."
177
+ f"Failed to create resources: {err.response.text}. Rolling back changes..."
122
178
  )
123
- raise AbortDefaultCreationError(created_blueprints, [e])
179
+ raise AbortDefaultCreationError(created_blueprints, [err], created_pages)
124
180
 
125
181
 
126
182
  async def _initialize_defaults(
@@ -133,6 +189,7 @@ async def _initialize_defaults(
133
189
  return None
134
190
 
135
191
  try:
192
+ logger.info("Found default resources, starting creation process")
136
193
  await _create_resources(port_client, defaults, integration_config)
137
194
  except AbortDefaultCreationError as e:
138
195
  logger.warning(
@@ -148,6 +205,18 @@ async def _initialize_defaults(
148
205
  for identifier in e.blueprints_to_rollback
149
206
  )
150
207
  )
208
+ if e.pages_to_rollback:
209
+ logger.warning(
210
+ f"Failed to create resources. Rolling back pages : {e.pages_to_rollback}"
211
+ )
212
+ await asyncio.gather(
213
+ *(
214
+ port_client.delete_page(
215
+ identifier,
216
+ )
217
+ for identifier in e.pages_to_rollback
218
+ )
219
+ )
151
220
 
152
221
  raise ExceptionGroup(str(e), e.errors)
153
222
 
@@ -130,6 +130,7 @@ class HttpEntitiesStateApplier(BaseEntitiesStateApplier):
130
130
  logger.info("Upserting modified entities")
131
131
  await self.upsert(diff.modified, user_agent_type)
132
132
 
133
+ logger.info("Deleting diff entities")
133
134
  await self._delete_diff(
134
135
  diff.deleted, diff.created + diff.modified, user_agent_type
135
136
  )
@@ -149,6 +150,7 @@ class HttpEntitiesStateApplier(BaseEntitiesStateApplier):
149
150
  )
150
151
  await self._validate_entity_diff(diff)
151
152
 
153
+ logger.info("Deleting diff entities")
152
154
  await self._delete_diff(
153
155
  diff.deleted, diff.created + diff.modified, user_agent_type
154
156
  )
@@ -9,6 +9,7 @@ class EntityMapping(BaseModel):
9
9
  identifier: str
10
10
  title: str | None
11
11
  blueprint: str
12
+ team: str | None
12
13
  properties: dict[str, str] = Field(default_factory=dict)
13
14
  relations: dict[str, str] = Field(default_factory=dict)
14
15
 
@@ -352,6 +352,7 @@ class SyncRawMixin(HandlerMixin, EventsMixin):
352
352
  except asyncio.CancelledError as e:
353
353
  logger.warning("Resync aborted successfully")
354
354
  else:
355
+ logger.info("Starting resync diff calculation")
355
356
  flat_created_entities, errors = zip_and_sum(creation_results) or [
356
357
  [],
357
358
  [],
@@ -368,6 +369,9 @@ class SyncRawMixin(HandlerMixin, EventsMixin):
368
369
 
369
370
  logger.error(message, exc_info=error_group)
370
371
  else:
372
+ logger.info(
373
+ f"Running resync diff calculation, number of entities at Port before resync: {len(entities_at_port)}, number of entities created during sync: {len(flat_created_entities)}"
374
+ )
371
375
  await self.entities_state_applier.delete_diff(
372
376
  {"before": entities_at_port, "after": flat_created_entities},
373
377
  user_agent_type,
@@ -2,8 +2,14 @@ from port_ocean.exceptions.base import BaseOceanException
2
2
 
3
3
 
4
4
  class AbortDefaultCreationError(BaseOceanException):
5
- def __init__(self, blueprints_to_rollback: list[str], errors: list[Exception]):
5
+ def __init__(
6
+ self,
7
+ blueprints_to_rollback: list[str],
8
+ errors: list[Exception],
9
+ pages_to_rollback: list[str] | None = None,
10
+ ):
6
11
  self.blueprints_to_rollback = blueprints_to_rollback
12
+ self.pages_to_rollback = pages_to_rollback
7
13
  self.errors = errors
8
14
  super().__init__("Aborting defaults creation")
9
15
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "port-ocean"
3
- version = "0.4.12"
3
+ version = "0.4.14"
4
4
  description = "Port Ocean is a CLI tool for managing your Port projects."
5
5
  readme = "README.md"
6
6
  homepage = "https://app.getport.io"
File without changes