Skip to content

Commit e856fc2

Browse files
authored
Merge pull request #87 from toolsplus/feature/support-host-record-deletion
Add TTL host column
2 parents 0e04b0b + 25caf04 commit e856fc2

File tree

16 files changed

+460
-229
lines changed

16 files changed

+460
-229
lines changed

.scalafmt.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
style = default
2-
maxColumn = 80
1+
version = 3.9.9
2+
runner.dialect = scala213
33
project.git = true

build.sbt

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import ReleaseTransformations._
1+
import ReleaseTransformations.*
2+
import xerial.sbt.Sonatype.sonatypeCentralHost
23

34
val commonSettings = Seq(
45
organization := "io.toolsplus",
5-
scalaVersion := "2.13.14",
6+
scalaVersion := "2.13.16",
67
versionScheme := Some("early-semver"),
78
resolvers ++= Seq(
89
Resolver.typesafeRepo("releases"),
@@ -18,19 +19,14 @@ lazy val publishSettings = Seq(
1819
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
1920
homepage := Some(url("https://github.com/toolsplus/atlassian-connect-play")),
2021
licenses := Seq(
21-
"Apache 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
22+
"Apache 2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")),
2223
publishMavenStyle := true,
2324
Test / publishArtifact := false,
2425
pomIncludeRepository := { _ =>
2526
false
2627
},
27-
publishTo := {
28-
val nexus = "https://oss.sonatype.org/"
29-
if (isSnapshot.value)
30-
Some("snapshots" at nexus + "content/repositories/snapshots")
31-
else
32-
Some("releases" at nexus + "service/local/staging/deploy/maven2")
33-
},
28+
ThisBuild / publishTo := sonatypePublishToBundle.value,
29+
ThisBuild / sonatypeCredentialHost := sonatypeCentralHost,
3430
autoAPIMappings := true,
3531
scmInfo := Some(
3632
ScmInfo(
@@ -47,6 +43,7 @@ lazy val publishSettings = Seq(
4743
)
4844

4945
lazy val noPublishSettings = Seq(
46+
publish / skip := true,
5047
publish := {},
5148
publishLocal := {},
5249
publishArtifact := false,
@@ -63,9 +60,9 @@ releaseProcess := Seq[ReleaseStep](
6360
commitReleaseVersion,
6461
tagRelease,
6562
releaseStepCommand("publishSigned"),
63+
releaseStepCommand("sonatypeBundleRelease"),
6664
setNextVersion,
6765
commitNextVersion,
68-
releaseStepCommand("sonatypeReleaseAll"),
6966
pushChanges
7067
)
7168

@@ -82,12 +79,12 @@ lazy val `atlassian-connect-play` = project
8279
`atlassian-connect-play-api`,
8380
`atlassian-connect-play-core`
8481
)
85-
.settings(commonSettings: _*)
82+
.settings(commonSettings)
8683
.settings(noPublishSettings)
8784

8885
lazy val `atlassian-connect-play-api` = project
8986
.in(file("modules/api"))
90-
.settings(commonSettings: _*)
87+
.settings(commonSettings)
9188
.settings(publishSettings)
9289
.settings(moduleSettings(project))
9390

@@ -96,8 +93,8 @@ lazy val `atlassian-connect-play-core` = project
9693
.enablePlugins(PlayScala)
9794
.settings(libraryDependencies ++= Dependencies.core)
9895
.settings(libraryDependencies ++= Seq(ws, guice))
99-
.settings(commonSettings: _*)
100-
.settings(scoverageSettings: _*)
96+
.settings(commonSettings)
97+
.settings(scoverageSettings)
10198
.settings(publishSettings)
10299
.settings(moduleSettings(project))
103100
.dependsOn(`atlassian-connect-play-api`)

modules/api/src/main/scala/io/toolsplus/atlassian/connect/play/api/models/AtlassianHost.scala

Lines changed: 78 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,139 +2,161 @@ package io.toolsplus.atlassian.connect.play.api.models
22

33
import io.toolsplus.atlassian.connect.play.api.models.Predefined.ClientKey
44

5+
import java.time.Instant
6+
57
/** An Atlassian host in which the app is or has been installed. Hosts are
68
* stored in AtlassianHostRepository.
79
*
810
* During processing of a request from an Atlassian host, the details of the
9-
* host and of the user at the browser can be obtained from the [[AtlassianHostUser]].
11+
* host and of the user at the browser can be obtained from the
12+
* [[AtlassianHostUser]].
1013
*
11-
* @see https://developer.atlassian.com/cloud/jira/platform/connect-app-descriptor/#lifecycle-http-request-payload
14+
* @see
15+
* https://developer.atlassian.com/cloud/jira/platform/connect-app-descriptor/#lifecycle-http-request-payload
1216
*/
1317
trait AtlassianHost {
1418

15-
/** Identifying key for the Atlassian product
16-
* instance that the app was installed into.
19+
/** Identifying key for the Atlassian product instance that the app was
20+
* installed into.
1721
*
18-
* @return Client key for this product instance.
22+
* @return
23+
* Client key for this product instance.
1924
*/
2025
def clientKey: ClientKey
2126

22-
/** App key that was installed into the
23-
* Atlassian product, as it appears in your
24-
* app's descriptor.
27+
/** App key that was installed into the Atlassian product, as it appears in
28+
* your app's descriptor.
2529
*
26-
* @return App key for this app.
30+
* @return
31+
* App key for this app.
2732
*/
2833
def key: String
2934

30-
/** OAuth 2.0 client ID for the app used
31-
* for OAuth 2.0 - JWT Bearer token
35+
/** OAuth 2.0 client ID for the app used for OAuth 2.0 - JWT Bearer token
3236
* authorization grant type.
3337
*
34-
* @return OAuth 2.0 client id.
38+
* @return
39+
* OAuth 2.0 client id.
3540
*/
3641
def oauthClientId: Option[String]
3742

38-
/**
39-
* Identifier for this host's Forge installation, if the host has migrated to Connect on Forge.
43+
/** Identifier for this host's Forge installation, if the host has migrated to
44+
* Connect on Forge.
4045
*
4146
* This is also the ID that any remote storage should be keyed against.
4247
*
43-
* @return Forge installation id.
48+
* @return
49+
* Forge installation id.
4450
*/
4551
def installationId: Option[String]
4652

47-
/** Secret to sign outgoing JWT tokens and
48-
* validate incoming JWT tokens. Only sent
49-
* on the installed event.
53+
/** Secret to sign outgoing JWT tokens and validate incoming JWT tokens. Only
54+
* sent on the installed event.
5055
*
51-
* @return Shared secret for this product instance.
56+
* @return
57+
* Shared secret for this product instance.
5258
*/
5359
def sharedSecret: String
5460

55-
/** URL prefix for this Atlassian product
56-
* instance.
61+
/** URL prefix for this Atlassian product instance.
5762
*
58-
* @return Base URL for this product instance.
63+
* @return
64+
* Base URL for this product instance.
5965
*/
6066
def baseUrl: String
6167

62-
/**
63-
* If the Atlassian product instance has an associated custom domain, this is the URL through which users will
64-
* access the product. Any links which an app renders server-side should use this as the prefix of the link.
65-
* This ensures links are rendered in the same context as the remainder of the user's site. If a custom domain
66-
* is not configured, this field will still be present but will be the same as the baseUrl.
68+
/** If the Atlassian product instance has an associated custom domain, this is
69+
* the URL through which users will access the product. Any links which an
70+
* app renders server-side should use this as the prefix of the link. This
71+
* ensures links are rendered in the same context as the remainder of the
72+
* user's site. If a custom domain is not configured, this field will still
73+
* be present but will be the same as the baseUrl.
6774
*
6875
* Note that API requests from your app should always use the baseUrl value.
6976
*
70-
* @return Custom domain URL if configured, app's base URL otherwise.
77+
* @return
78+
* Custom domain URL if configured, app's base URL otherwise.
7179
*/
7280
def displayUrl: String
7381

74-
/**
75-
* If the Atlassian product instance has an associated custom domain for Jira Service Desk functionality, this is
76-
* the URL for the Jira Service Desk Help Center. Any related links which an app renders server-side should use this
77-
* as the prefix of the link.
78-
* This ensures links are rendered in the same context as the user's Jira Service Desk. If a custom domain is not
79-
* configured, this field will still be present but will be the same as the baseUrl.
82+
/** If the Atlassian product instance has an associated custom domain for Jira
83+
* Service Desk functionality, this is the URL for the Jira Service Desk Help
84+
* Center. Any related links which an app renders server-side should use this
85+
* as the prefix of the link. This ensures links are rendered in the same
86+
* context as the user's Jira Service Desk. If a custom domain is not
87+
* configured, this field will still be present but will be the same as the
88+
* baseUrl.
8089
*
8190
* Note that API requests from your App should always use the baseUrl value.
8291
*
83-
* @return Custom domain URL for Jira Service Desk if configured, app's base URL otherwise.
92+
* @return
93+
* Custom domain URL for Jira Service Desk if configured, app's base URL
94+
* otherwise.
8495
*/
8596
def displayUrlServicedeskHelpCenter: String
8697

87-
/** Identifies the category of Atlassian
88-
* product, e.g. jira or confluence.
98+
/** Identifies the category of Atlassian product, e.g. jira or confluence.
8999
*
90-
* @return Category of this product.
100+
* @return
101+
* Category of this product.
91102
*/
92103
def productType: String
93104

94105
/** Host product description.
95106
*
96-
* @return Description of this product.
107+
* @return
108+
* Description of this product.
97109
*/
98110
def description: String
99111

100-
/** Service entitlement number (SEN) is the
101-
* app license id. Only included during
102-
* installation of a paid app.
112+
/** Service entitlement number (SEN) is the app license id. Only included
113+
* during installation of a paid app.
103114
*
104-
* @return App license id if this is a paid app.
115+
* @return
116+
* App license id if this is a paid app.
105117
*/
106118
@deprecated("No replacement")
107119
def serviceEntitlementNumber: Option[String]
108120

109-
/**
110-
* License entitlement ID is the app license ID.
121+
/** License entitlement ID is the app license ID.
111122
*
112123
* This attribute will only be included during installation of a paid app.
113124
*
114-
* @return App entitlement ID if this is a paid app.
125+
* @return
126+
* App entitlement ID if this is a paid app.
115127
*/
116128
def entitlementId: Option[String]
117129

118-
/**
119-
* License entitlement number is the app license number.
130+
/** License entitlement number is the app license number.
120131
*
121132
* This attribute will only be included during installation of a paid app.
122133
*
123-
* @return App entitlement number if this is a paid app.
134+
* @return
135+
* App entitlement number if this is a paid app.
124136
*/
125137
def entitlementNumber: Option[String]
126138

127-
/** Indicates if the app is currently
128-
* installed on the host. Upon uninstallation,
129-
* the value of this flag will be set to false.
139+
/** Indicates if the app is currently installed on the host. Upon
140+
* uninstallation, the value of this flag will be set to false.
130141
*
131-
* @return Installation status for this app.
142+
* @return
143+
* Installation status for this app.
132144
*/
133145
def installed: Boolean
134146

135-
/** Uninstalls this host by setting the installed field to false.
147+
/** Time to live for this host record.
148+
*
149+
* This allows marking a host record for deletion in the future.
150+
*
151+
* @return
152+
* Point in time when this host record should be deleted.
153+
*/
154+
def ttl: Option[Instant]
155+
156+
/** Uninstalls this host by setting the installed field to false and optionally set a TTL.
136157
*
137-
* @return A new version of this host with the installed field set to false.
158+
* @return
159+
* A new version of this host with the installed field set to false.
138160
*/
139-
def uninstalled: AtlassianHost
161+
def uninstalled(ttl: Option[Instant]): AtlassianHost
140162
}

modules/api/src/main/scala/io/toolsplus/atlassian/connect/play/api/models/DefaultAtlassianHost.scala

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@ package io.toolsplus.atlassian.connect.play.api.models
22

33
import io.toolsplus.atlassian.connect.play.api.models.Predefined.ClientKey
44

5+
import java.time.Instant
6+
57
/** Default case class implementation of [[AtlassianHost]].
68
*/
7-
case class DefaultAtlassianHost(clientKey: ClientKey,
8-
key: String,
9-
oauthClientId: Option[String],
10-
installationId: Option[String],
11-
sharedSecret: String,
12-
baseUrl: String,
13-
displayUrl: String,
14-
displayUrlServicedeskHelpCenter: String,
15-
productType: String,
16-
description: String,
17-
serviceEntitlementNumber: Option[String],
18-
entitlementId: Option[String],
19-
entitlementNumber: Option[String],
20-
installed: Boolean) extends AtlassianHost {
9+
case class DefaultAtlassianHost(
10+
clientKey: ClientKey,
11+
key: String,
12+
oauthClientId: Option[String],
13+
installationId: Option[String],
14+
sharedSecret: String,
15+
baseUrl: String,
16+
displayUrl: String,
17+
displayUrlServicedeskHelpCenter: String,
18+
productType: String,
19+
description: String,
20+
serviceEntitlementNumber: Option[String],
21+
entitlementId: Option[String],
22+
entitlementNumber: Option[String],
23+
installed: Boolean,
24+
ttl: Option[Instant]
25+
) extends AtlassianHost {
2126

22-
override def uninstalled: AtlassianHost = copy(installed = false)
27+
override def uninstalled(ttl: Option[Instant]): AtlassianHost =
28+
copy(installed = false, ttl = ttl)
2329
}

0 commit comments

Comments
 (0)