bugdantic 0.2.7__tar.gz → 0.2.8__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bugdantic
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: Bugzilla client based on pydantic
5
5
  Author-email: James Graham <james@hoppipolla.co.uk>
6
6
  Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
@@ -4,11 +4,11 @@ import json
4
4
  import logging
5
5
  from dataclasses import dataclass
6
6
  from datetime import datetime
7
- from typing import Any, Mapping, MutableMapping, Optional, Sequence
7
+ from typing import Any, Mapping, MutableMapping, Optional, Sequence, Self
8
8
  from urllib.parse import urljoin
9
9
 
10
10
  import httpx
11
- from pydantic import BaseModel, ConfigDict, field_validator
11
+ from pydantic import BaseModel, ConfigDict
12
12
 
13
13
  Json = dict[str, "Json"] | list["Json"] | str | int | float | bool | None
14
14
 
@@ -348,7 +348,7 @@ class AttachmentCreate(BaseModel):
348
348
  data: str
349
349
  file_name: str
350
350
  summary: str
351
- content_type: Optional[str] = None
351
+ content_type: str
352
352
  comment: Optional[str] = None
353
353
  is_markdown: Optional[bool] = None
354
354
  is_patch: Optional[bool] = None
@@ -356,16 +356,60 @@ class AttachmentCreate(BaseModel):
356
356
  flags: Optional[list[FlagChange]] = None
357
357
  bug_flags: Optional[list[FlagChange]] = None
358
358
 
359
- @field_validator("data", mode="before")
360
359
  @classmethod
361
- def encode_data(cls, value: bytes | str) -> str:
362
- if isinstance(value, bytes):
363
- return base64.b64encode(value).decode("ascii")
364
- return value
360
+ def from_raw_data(
361
+ cls,
362
+ data: str | bytes,
363
+ file_name: str,
364
+ summary: str,
365
+ content_type: str,
366
+ ids: Optional[list[int | str]] = None,
367
+ comment: Optional[str] = None,
368
+ is_markdown: Optional[bool] = None,
369
+ is_patch: Optional[bool] = None,
370
+ is_private: Optional[bool] = None,
371
+ flags: Optional[list[FlagChange]] = None,
372
+ bug_flags: Optional[list[FlagChange]] = None,
373
+ ) -> Self:
374
+ if isinstance(data, str):
375
+ data = data.encode("utf8")
376
+ return cls(
377
+ ids=ids,
378
+ data=base64.b64encode(data).decode("ascii"),
379
+ file_name=file_name,
380
+ summary=summary,
381
+ content_type=content_type,
382
+ comment=comment,
383
+ is_markdown=is_markdown,
384
+ is_patch=is_patch,
385
+ is_private=is_private,
386
+ flags=flags,
387
+ bug_flags=bug_flags,
388
+ )
365
389
 
366
390
 
367
391
  class AttachmentCreateResponse(BaseModel):
368
- ids: list[int]
392
+ attacher: str
393
+ bug_id: int
394
+ content_type: str
395
+ creation_time: datetime
396
+ creator: str
397
+ creator_detail: User
398
+ data: str
399
+ description: str
400
+ file_name: str
401
+ flags: Optional[list[FlagChange]]
402
+ id: int
403
+ is_obsolete: bool
404
+ is_patch: bool
405
+ is_private: bool
406
+ last_change_time: datetime
407
+ size: int
408
+ summary: str
409
+
410
+
411
+ class AttachmentsCreateResponse(BaseModel):
412
+ attachments: Mapping[str, AttachmentCreateResponse]
369
413
 
370
414
 
371
415
  @dataclass
@@ -573,7 +617,7 @@ class Bugzilla:
573
617
 
574
618
  def create_attachment(
575
619
  self, attachment: AttachmentCreate, bug_id: Optional[int] = None
576
- ) -> list[int]:
620
+ ) -> list[AttachmentCreateResponse]:
577
621
  """Add an attachment to one or more bugs"""
578
622
  if bug_id is not None:
579
623
  id_str = str(bug_id)
@@ -591,7 +635,7 @@ class Bugzilla:
591
635
  response = self.request("POST", path, json_body=json_body)
592
636
 
593
637
  if self.config.allow_writes:
594
- create_result = AttachmentCreateResponse.model_validate(response)
595
- return create_result.ids
638
+ create_result = AttachmentsCreateResponse.model_validate(response)
639
+ return list(create_result.attachments.values())
596
640
 
597
641
  return []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bugdantic
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: Bugzilla client based on pydantic
5
5
  Author-email: James Graham <james@hoppipolla.co.uk>
6
6
  Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
@@ -5,7 +5,7 @@ authors = [
5
5
  {name = "James Graham", email = "james@hoppipolla.co.uk"}
6
6
  ]
7
7
 
8
- version = "0.2.7"
8
+ version = "0.2.8"
9
9
  requires-python = ">=3.11"
10
10
  classifiers = [
11
11
  "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
File without changes
File without changes
File without changes
File without changes