Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3: Make fields that return AWSIdentity universally optional #2752

Merged
merged 1 commit into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ import scala.xml.NodeSeq
val id = (i \ "ID").text
val displayName = (i \ "DisplayName").text
AWSIdentity(id, displayName)
}.head
}.headOption

val owner = (u \\ "Owner").map { o =>
val id = (o \ "ID").text
val displayName = (o \ "DisplayName").text
AWSIdentity(id, displayName)
}.head
}.headOption

val storageClass = (u \ "StorageClass").text
val initiated = Instant.parse((u \ "Initiated").text)
Expand Down Expand Up @@ -170,13 +170,13 @@ import scala.xml.NodeSeq
val id = (i \ "ID").text
val displayName = (i \ "DisplayName").text
AWSIdentity(id, displayName)
}.head
}.headOption

val owner = (x \\ "Owner").map { o =>
val id = (o \ "ID").text
val displayName = (o \ "DisplayName").text
AWSIdentity(id, displayName)
}.head
}.headOption

val storageClass = (x \ "StorageClass").text

Expand Down
4 changes: 2 additions & 2 deletions s3/src/main/scala/akka/stream/alpakka/s3/impl/S3Stream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ import scala.util.{Failure, Success, Try}
maxParts: Int,
isTruncated: Boolean,
parts: Seq[ListPartsResultParts],
initiator: AWSIdentity,
owner: AWSIdentity,
initiator: Option[AWSIdentity],
owner: Option[AWSIdentity],
storageClass: String) {

/**
Expand Down
26 changes: 13 additions & 13 deletions s3/src/main/scala/akka/stream/alpakka/s3/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ object AWSIdentity {

final class ListMultipartUploadResultUploads private (val key: String,
val uploadId: String,
val initiator: AWSIdentity,
val owner: AWSIdentity,
val initiator: Option[AWSIdentity],
val owner: Option[AWSIdentity],
val storageClass: String,
val initiated: Instant) {

Expand All @@ -184,10 +184,10 @@ final class ListMultipartUploadResultUploads private (val key: String,
def getUploadId: String = uploadId

/** Java API */
def getInitiator: AWSIdentity = initiator
def getInitiator: Optional[AWSIdentity] = initiator.asJava

/** Java API */
def getOwner: AWSIdentity = owner
def getOwner: Optional[AWSIdentity] = owner.asJava

/** Java API */
def getStorageClass: String = storageClass
Expand All @@ -197,15 +197,15 @@ final class ListMultipartUploadResultUploads private (val key: String,

def withKey(value: String): ListMultipartUploadResultUploads = copy(key = value)
def withUploadId(value: String): ListMultipartUploadResultUploads = copy(uploadId = value)
def withInitiator(value: AWSIdentity): ListMultipartUploadResultUploads = copy(initiator = value)
def withOwner(value: AWSIdentity): ListMultipartUploadResultUploads = copy(owner = value)
def withInitiator(value: AWSIdentity): ListMultipartUploadResultUploads = copy(initiator = Option(value))
def withOwner(value: AWSIdentity): ListMultipartUploadResultUploads = copy(owner = Option(value))
def withStorageClass(value: String): ListMultipartUploadResultUploads = copy(storageClass = value)
def withInitiated(value: Instant): ListMultipartUploadResultUploads = copy(initiated = value)

private def copy(key: String = key,
uploadId: String = uploadId,
initiator: AWSIdentity = initiator,
owner: AWSIdentity = owner,
initiator: Option[AWSIdentity] = initiator,
owner: Option[AWSIdentity] = owner,
storageClass: String = storageClass,
initiated: Instant = initiated): ListMultipartUploadResultUploads =
new ListMultipartUploadResultUploads(
Expand Down Expand Up @@ -248,20 +248,20 @@ object ListMultipartUploadResultUploads {
/** Scala API */
def apply(key: String,
uploadId: String,
initiator: AWSIdentity,
owner: AWSIdentity,
initiator: Option[AWSIdentity],
owner: Option[AWSIdentity],
storageClass: String,
initiated: Instant): ListMultipartUploadResultUploads =
new ListMultipartUploadResultUploads(key, uploadId, initiator, owner, storageClass, initiated)

/** Java API */
def create(key: String,
uploadId: String,
initiator: AWSIdentity,
owner: AWSIdentity,
initiator: Optional[AWSIdentity],
owner: Optional[AWSIdentity],
storageClass: String,
initiated: Instant): ListMultipartUploadResultUploads =
apply(key, uploadId, initiator, owner, storageClass, initiated)
apply(key, uploadId, initiator.asScala, owner.asScala, storageClass, initiated)
}

final class ListObjectVersionsResultVersions private (val eTag: String,
Expand Down