|
| 1 | +/*--------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | + *--------------------------------------------------------------------------------------------*/ |
| 4 | + |
| 5 | +package com.github.copilot.sdk.events; |
| 6 | + |
| 7 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 8 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 9 | + |
| 10 | +import java.util.List; |
| 11 | +import java.util.Map; |
| 12 | + |
| 13 | +/** |
| 14 | + * Event: session.shutdown |
| 15 | + * <p> |
| 16 | + * This event is emitted when a session is shutting down, either routinely or |
| 17 | + * due to an error. It contains metrics about the session's usage. |
| 18 | + * |
| 19 | + * @since 1.0.0 |
| 20 | + */ |
| 21 | +@JsonIgnoreProperties(ignoreUnknown = true) |
| 22 | +public final class SessionShutdownEvent extends AbstractSessionEvent { |
| 23 | + |
| 24 | + @JsonProperty("data") |
| 25 | + private SessionShutdownData data; |
| 26 | + |
| 27 | + @Override |
| 28 | + public String getType() { |
| 29 | + return "session.shutdown"; |
| 30 | + } |
| 31 | + |
| 32 | + public SessionShutdownData getData() { |
| 33 | + return data; |
| 34 | + } |
| 35 | + |
| 36 | + public void setData(SessionShutdownData data) { |
| 37 | + this.data = data; |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Data for the session shutdown event. |
| 42 | + */ |
| 43 | + @JsonIgnoreProperties(ignoreUnknown = true) |
| 44 | + public static class SessionShutdownData { |
| 45 | + |
| 46 | + @JsonProperty("shutdownType") |
| 47 | + private ShutdownType shutdownType; |
| 48 | + |
| 49 | + @JsonProperty("errorReason") |
| 50 | + private String errorReason; |
| 51 | + |
| 52 | + @JsonProperty("totalPremiumRequests") |
| 53 | + private double totalPremiumRequests; |
| 54 | + |
| 55 | + @JsonProperty("totalApiDurationMs") |
| 56 | + private double totalApiDurationMs; |
| 57 | + |
| 58 | + @JsonProperty("sessionStartTime") |
| 59 | + private double sessionStartTime; |
| 60 | + |
| 61 | + @JsonProperty("codeChanges") |
| 62 | + private CodeChanges codeChanges; |
| 63 | + |
| 64 | + @JsonProperty("modelMetrics") |
| 65 | + private Map<String, Object> modelMetrics; |
| 66 | + |
| 67 | + @JsonProperty("currentModel") |
| 68 | + private String currentModel; |
| 69 | + |
| 70 | + public ShutdownType getShutdownType() { |
| 71 | + return shutdownType; |
| 72 | + } |
| 73 | + |
| 74 | + public void setShutdownType(ShutdownType shutdownType) { |
| 75 | + this.shutdownType = shutdownType; |
| 76 | + } |
| 77 | + |
| 78 | + public String getErrorReason() { |
| 79 | + return errorReason; |
| 80 | + } |
| 81 | + |
| 82 | + public void setErrorReason(String errorReason) { |
| 83 | + this.errorReason = errorReason; |
| 84 | + } |
| 85 | + |
| 86 | + public double getTotalPremiumRequests() { |
| 87 | + return totalPremiumRequests; |
| 88 | + } |
| 89 | + |
| 90 | + public void setTotalPremiumRequests(double totalPremiumRequests) { |
| 91 | + this.totalPremiumRequests = totalPremiumRequests; |
| 92 | + } |
| 93 | + |
| 94 | + public double getTotalApiDurationMs() { |
| 95 | + return totalApiDurationMs; |
| 96 | + } |
| 97 | + |
| 98 | + public void setTotalApiDurationMs(double totalApiDurationMs) { |
| 99 | + this.totalApiDurationMs = totalApiDurationMs; |
| 100 | + } |
| 101 | + |
| 102 | + public double getSessionStartTime() { |
| 103 | + return sessionStartTime; |
| 104 | + } |
| 105 | + |
| 106 | + public void setSessionStartTime(double sessionStartTime) { |
| 107 | + this.sessionStartTime = sessionStartTime; |
| 108 | + } |
| 109 | + |
| 110 | + public CodeChanges getCodeChanges() { |
| 111 | + return codeChanges; |
| 112 | + } |
| 113 | + |
| 114 | + public void setCodeChanges(CodeChanges codeChanges) { |
| 115 | + this.codeChanges = codeChanges; |
| 116 | + } |
| 117 | + |
| 118 | + public Map<String, Object> getModelMetrics() { |
| 119 | + return modelMetrics; |
| 120 | + } |
| 121 | + |
| 122 | + public void setModelMetrics(Map<String, Object> modelMetrics) { |
| 123 | + this.modelMetrics = modelMetrics; |
| 124 | + } |
| 125 | + |
| 126 | + public String getCurrentModel() { |
| 127 | + return currentModel; |
| 128 | + } |
| 129 | + |
| 130 | + public void setCurrentModel(String currentModel) { |
| 131 | + this.currentModel = currentModel; |
| 132 | + } |
| 133 | + } |
| 134 | + |
| 135 | + /** |
| 136 | + * Code changes made during the session. |
| 137 | + */ |
| 138 | + @JsonIgnoreProperties(ignoreUnknown = true) |
| 139 | + public static class CodeChanges { |
| 140 | + |
| 141 | + @JsonProperty("linesAdded") |
| 142 | + private double linesAdded; |
| 143 | + |
| 144 | + @JsonProperty("linesRemoved") |
| 145 | + private double linesRemoved; |
| 146 | + |
| 147 | + @JsonProperty("filesModified") |
| 148 | + private List<String> filesModified; |
| 149 | + |
| 150 | + public double getLinesAdded() { |
| 151 | + return linesAdded; |
| 152 | + } |
| 153 | + |
| 154 | + public void setLinesAdded(double linesAdded) { |
| 155 | + this.linesAdded = linesAdded; |
| 156 | + } |
| 157 | + |
| 158 | + public double getLinesRemoved() { |
| 159 | + return linesRemoved; |
| 160 | + } |
| 161 | + |
| 162 | + public void setLinesRemoved(double linesRemoved) { |
| 163 | + this.linesRemoved = linesRemoved; |
| 164 | + } |
| 165 | + |
| 166 | + public List<String> getFilesModified() { |
| 167 | + return filesModified; |
| 168 | + } |
| 169 | + |
| 170 | + public void setFilesModified(List<String> filesModified) { |
| 171 | + this.filesModified = filesModified; |
| 172 | + } |
| 173 | + } |
| 174 | + |
| 175 | + /** |
| 176 | + * Type of session shutdown. |
| 177 | + */ |
| 178 | + public enum ShutdownType { |
| 179 | + @JsonProperty("routine") |
| 180 | + ROUTINE, @JsonProperty("error") |
| 181 | + ERROR |
| 182 | + } |
| 183 | +} |
0 commit comments