├── .classpath
├── .github
└── workflows
│ └── maven.yml
├── .gitignore
├── .project
├── CONTRIBUTING.md
├── Jenkinsfile
├── License.txt
├── README.md
├── integration-example.properties
├── pom.xml
└── src
├── integration-test
└── java
│ └── edu
│ └── ksu
│ └── canvas
│ ├── calendar
│ ├── CalendarIT.java
│ ├── CourseUploadIT.java
│ └── FeatureFlagIT.java
│ └── contentMigration
│ └── ContentMigrationIT.java
├── main
└── java
│ └── edu
│ └── ksu
│ └── canvas
│ ├── CanvasApiFactory.java
│ ├── TestLauncher.java
│ ├── annotation
│ ├── CanvasField.java
│ └── CanvasObject.java
│ ├── constants
│ └── CanvasConstants.java
│ ├── enums
│ ├── SectionIncludes.java
│ └── package-info.java
│ ├── errors
│ ├── ErrorDetails.java
│ ├── ErrorHandler.java
│ ├── GenericErrorHandler.java
│ ├── GenericErrorResponse.java
│ ├── UserErrorHandler.java
│ └── UserErrorResponse.java
│ ├── exception
│ ├── CanvasException.java
│ ├── InvalidOauthTokenException.java
│ ├── ObjectNotFoundException.java
│ ├── RateLimitException.java
│ ├── RetriableException.java
│ ├── ThrottlingException.java
│ ├── UnauthorizedException.java
│ └── package-info.java
│ ├── impl
│ ├── AccountImpl.java
│ ├── AccountReportImpl.java
│ ├── AccountReportSummaryImpl.java
│ ├── AdminImpl.java
│ ├── AssignmentGroupImpl.java
│ ├── AssignmentImpl.java
│ ├── AssignmentOverrideImpl.java
│ ├── AuthenticationLogImpl.java
│ ├── BaseImpl.java
│ ├── CalendarEventImpl.java
│ ├── CommunicationChannelImpl.java
│ ├── ContentMigrationImpl.java
│ ├── ConversationImpl.java
│ ├── CourseImpl.java
│ ├── CourseSettingsImpl.java
│ ├── EnrollmentImpl.java
│ ├── EnrollmentTermImpl.java
│ ├── ExternalToolImpl.java
│ ├── FeatureFlagImpl.java
│ ├── FeatureImpl.java
│ ├── FileImpl.java
│ ├── GradingStandardImpl.java
│ ├── GsonResponseParser.java
│ ├── LoginImpl.java
│ ├── MigrationIssueImpl.java
│ ├── ModuleImpl.java
│ ├── PageImpl.java
│ ├── ProgressImpl.java
│ ├── QuizImpl.java
│ ├── QuizQuestionImpl.java
│ ├── QuizSubmissionImpl.java
│ ├── QuizSubmissionQuestionImpl.java
│ ├── RestCanvasMessenger.java
│ ├── RoleImpl.java
│ ├── RubricImpl.java
│ ├── SectionsImpl.java
│ ├── SelectiveDataImpl.java
│ ├── SisImportImpl.java
│ ├── SubmissionImpl.java
│ ├── TabImpl.java
│ ├── UserImpl.java
│ └── package-info.java
│ ├── interfaces
│ ├── AccountReader.java
│ ├── AccountReportReader.java
│ ├── AccountReportSummaryReader.java
│ ├── AccountReportSummaryWriter.java
│ ├── AccountReportWriter.java
│ ├── AccountWriter.java
│ ├── AdminReader.java
│ ├── AdminWriter.java
│ ├── AssignmentGroupReader.java
│ ├── AssignmentGroupWriter.java
│ ├── AssignmentOverrideReader.java
│ ├── AssignmentOverrideWriter.java
│ ├── AssignmentReader.java
│ ├── AssignmentWriter.java
│ ├── AuthenticationLogReader.java
│ ├── CalendarReader.java
│ ├── CalendarWriter.java
│ ├── CanvasMessenger.java
│ ├── CanvasReader.java
│ ├── CanvasWriter.java
│ ├── CommunicationChannelReader.java
│ ├── CommunicationChannelWriter.java
│ ├── ContentMigrationReader.java
│ ├── ContentMigrationWriter.java
│ ├── ConversationReader.java
│ ├── ConversationWriter.java
│ ├── CourseReader.java
│ ├── CourseSettingsReader.java
│ ├── CourseSettingsWriter.java
│ ├── CourseWriter.java
│ ├── EnrollmentReader.java
│ ├── EnrollmentTermReader.java
│ ├── EnrollmentTermWriter.java
│ ├── EnrollmentWriter.java
│ ├── ExternalToolReader.java
│ ├── ExternalToolWriter.java
│ ├── FeatureFlagReader.java
│ ├── FeatureFlagWriter.java
│ ├── FeatureReader.java
│ ├── FeatureWriter.java
│ ├── FileReader.java
│ ├── FileWriter.java
│ ├── GradingStandardReader.java
│ ├── GradingStandardWriter.java
│ ├── LoginReader.java
│ ├── LoginWriter.java
│ ├── MigrationIssueReader.java
│ ├── ModuleReader.java
│ ├── PageReader.java
│ ├── PageWriter.java
│ ├── ProgressReader.java
│ ├── ProgressWriter.java
│ ├── QuizQuestionReader.java
│ ├── QuizQuestionWriter.java
│ ├── QuizReader.java
│ ├── QuizSubmissionQuestionReader.java
│ ├── QuizSubmissionQuestionWriter.java
│ ├── QuizSubmissionReader.java
│ ├── QuizSubmissionWriter.java
│ ├── QuizWriter.java
│ ├── ResponseParser.java
│ ├── RoleReader.java
│ ├── RoleWriter.java
│ ├── RubricReader.java
│ ├── RubricWriter.java
│ ├── SectionReader.java
│ ├── SectionWriter.java
│ ├── SelectiveDataReader.java
│ ├── SisImportReader.java
│ ├── SisImportWriter.java
│ ├── SubmissionReader.java
│ ├── SubmissionWriter.java
│ ├── TabReader.java
│ ├── TabWriter.java
│ ├── UserReader.java
│ ├── UserWriter.java
│ └── package-info.java
│ ├── model
│ ├── Account.java
│ ├── AccountAdmin.java
│ ├── AuthenticationLog.java
│ ├── BaseCanvasModel.java
│ ├── CalendarEvent.java
│ ├── CommunicationChannel.java
│ ├── ContentMigration.java
│ ├── Conversation.java
│ ├── Course.java
│ ├── CourseSettings.java
│ ├── Deposit.java
│ ├── Enrollment.java
│ ├── EnrollmentTerm.java
│ ├── ExternalTool.java
│ ├── Feature.java
│ ├── FeatureFlag.java
│ ├── File.java
│ ├── Grade.java
│ ├── GradingStandard.java
│ ├── Login.java
│ ├── MigrationIssue.java
│ ├── Module.java
│ ├── Page.java
│ ├── Progress.java
│ ├── Role.java
│ ├── Section.java
│ ├── SelectiveData.java
│ ├── SisImport.java
│ ├── Tab.java
│ ├── User.java
│ ├── UserDisplay.java
│ ├── assignment
│ │ ├── Assignment.java
│ │ ├── AssignmentDate.java
│ │ ├── AssignmentGroup.java
│ │ ├── AssignmentOverride.java
│ │ ├── GradingRules.java
│ │ ├── LockInfo.java
│ │ ├── MediaComment.java
│ │ ├── Quiz.java
│ │ ├── QuizAnswer.java
│ │ ├── QuizPermission.java
│ │ ├── QuizQuestion.java
│ │ ├── QuizSubmission.java
│ │ ├── QuizSubmissionQuestion.java
│ │ ├── QuizSubmissionResponse.java
│ │ ├── Rubric.java
│ │ ├── RubricAssessment.java
│ │ ├── RubricAssociation.java
│ │ ├── RubricCriterion.java
│ │ ├── RubricRating.java
│ │ ├── RubricSettings.java
│ │ ├── Submission.java
│ │ └── SubmissionComment.java
│ ├── package-info.java
│ ├── report
│ │ ├── AccountReport.java
│ │ ├── AccountReportAttachment.java
│ │ └── AccountReportSummary.java
│ ├── status
│ │ ├── CanvasErrorResponse.java
│ │ ├── Conclude.java
│ │ ├── Delete.java
│ │ └── package-info.java
│ └── wrapper
│ │ ├── EnrollmentTermWrapper.java
│ │ ├── QuizSubmissionQuestionWrapper.java
│ │ ├── QuizSubmissionWrapper.java
│ │ └── package-info.java
│ ├── net
│ ├── ApiPost.java
│ ├── RefreshingRestClient.java
│ ├── Response.java
│ ├── RestClient.java
│ ├── SimpleRestClient.java
│ └── package-info.java
│ ├── oauth
│ ├── NonRefreshableOauthToken.java
│ ├── OauthToken.java
│ ├── OauthTokenRefresher.java
│ ├── RefreshableOauthToken.java
│ ├── TokenRefreshResponse.java
│ └── package-info.java
│ ├── requestOptions
│ ├── AccountReportOptions.java
│ ├── AddMessageToConversationOptions.java
│ ├── AnswerQuizQuestionOptions.java
│ ├── BaseOptions.java
│ ├── CompleteQuizSubmissionOptions.java
│ ├── CreateCommunicationChannelOptions.java
│ ├── CreateContentMigrationOptions.java
│ ├── CreateConversationOptions.java
│ ├── CreateCourseContentMigrationOptions.java
│ ├── CreateSisImportOptions.java
│ ├── CreateUserOptions.java
│ ├── DeleteAssignmentGroupOptions.java
│ ├── DeleteCalendarEventOptions.java
│ ├── DeleteCourseOptions.java
│ ├── GetAssignmentGroupOptions.java
│ ├── GetEnrollmentOptions.java
│ ├── GetEnrollmentTermOptions.java
│ ├── GetQuizQuestionsOptions.java
│ ├── GetQuizSubmissionsOptions.java
│ ├── GetRubricOptions.java
│ ├── GetSelectiveDataOptions.java
│ ├── GetSingleAssignmentOptions.java
│ ├── GetSingleConversationOptions.java
│ ├── GetSingleCourseOptions.java
│ ├── GetSubAccountsOptions.java
│ ├── GetSubmissionsOptions.java
│ ├── GetUsersInAccountOptions.java
│ ├── GetUsersInCourseOptions.java
│ ├── ListAccountAdminsOptions.java
│ ├── ListAccountOptions.java
│ ├── ListActiveCoursesInAccountOptions.java
│ ├── ListAssignmentGroupOptions.java
│ ├── ListCalendarEventsOptions.java
│ ├── ListCourseAssignmentsOptions.java
│ ├── ListCurrentUserCoursesOptions.java
│ ├── ListExternalToolsOptions.java
│ ├── ListModulesOptions.java
│ ├── ListRolesOptions.java
│ ├── ListUserAssignmentOptions.java
│ ├── ListUserCoursesOptions.java
│ ├── MultipleSubmissionsOptions.java
│ ├── StartQuizSubmissionOptions.java
│ ├── UnEnrollOptions.java
│ ├── UpdateCourseTabOptions.java
│ ├── UploadOptions.java
│ └── package-info.java
│ └── util
│ ├── CanvasURLBuilder.java
│ ├── HttpParameterBuilder.java
│ ├── KeyFirstComparator.java
│ └── package-info.java
└── test
├── java
└── edu
│ └── ksu
│ └── canvas
│ ├── ApiFactoryUTest.java
│ ├── BaseCanvasModelUTest.java
│ ├── BaseImplUTest.java
│ ├── CanvasTestBase.java
│ ├── EnrollmentTermUTest.java
│ ├── EnrollmentUTest.java
│ ├── LocalServerTestBase.java
│ ├── TestCanvasReader.java
│ ├── TestCanvasReaderImpl.java
│ ├── TestCanvasWriter.java
│ ├── config
│ ├── BaseTestConfig.java
│ └── CommonTestConfig.java
│ ├── errors
│ └── ErrorsJsonTest.java
│ ├── impl
│ ├── GsonResponseParserInstantTest.java
│ └── SubmissionImplTest.java
│ ├── model
│ ├── CalendarEventTest.java
│ └── TestCanvasModel.java
│ ├── net
│ ├── FakeRestClient.java
│ ├── RefreshingRestClientUTest.java
│ └── SimpleRestClientUTest.java
│ ├── oauth
│ ├── OauthTokenRefresherUTest.java
│ └── RefreshableTokenUTest.java
│ ├── tests
│ ├── account
│ │ └── AccountReaderUTest.java
│ ├── accountReport
│ │ └── AccountReportUTest.java
│ ├── accountReportSummary
│ │ └── AccountReportSummaryUTest.java
│ ├── assignment
│ │ ├── AssignmentGroupUTest.java
│ │ ├── AssignmentOverrideUTest.java
│ │ └── AssignmentRetrieverUTest.java
│ ├── authenticationLog
│ │ └── AuthenticationLogUTest.java
│ ├── calendar
│ │ ├── CalendarReaderUTest.java
│ │ └── CalendarWriterUTest.java
│ ├── communicationChannel
│ │ └── CommunicationChannelUTest.java
│ ├── contentMigration
│ │ └── ContentMigrationUTest.java
│ ├── course
│ │ ├── CourseGetUTest.java
│ │ ├── CourseListingUTest.java
│ │ ├── CourseManagerUTest.java
│ │ ├── DropCourseUTest.java
│ │ ├── SectionManagerUTest.java
│ │ └── UserManagerUTest.java
│ ├── file
│ │ └── CourseGetUTest.java
│ ├── gson
│ │ └── GsonDateParsingUTest.java
│ ├── login
│ │ └── LoginUTest.java
│ ├── module
│ │ └── ModuleListingTest.java
│ ├── quiz
│ │ ├── QuizQuestionRetrieverUTest.java
│ │ ├── QuizRetrieverUTest.java
│ │ └── QuizSubmissionRetrieverUTest.java
│ ├── roles
│ │ └── RolesUTest.java
│ ├── sisImport
│ │ └── SisImportUTest.java
│ ├── tab
│ │ └── TabUTest.java
│ └── user
│ │ └── UserRetrieverUTest.java
│ └── util
│ └── JsonTestUtil.java
└── resources
├── InvalidJson.json
├── SampleJson
├── BlankResponse.json
├── CreateUserResponse.json
├── EnrollmentDeleteResponse.json
├── EnrollmentResponse.json
├── EnrollmentTerm.json
├── Enrollments.json
├── Modules.json
├── Progress.json
├── account
│ ├── AccountWithLtiGuid.json
│ ├── FiveSubAccounts.json
│ └── RootAccount.json
├── accountReport
│ ├── AccountReportListing.json
│ └── SingleAccountReportListing.json
├── accountReportSummary
│ └── AccountReportSummary.json
├── assignment
│ ├── Assignment2.json
│ ├── AssignmentGroup.json
│ ├── AssignmentGroupList.json
│ ├── AssignmentGroupWithAssignments.json
│ ├── AssignmentList.json
│ ├── AssignmentOverride.json
│ ├── AssignmentOverrideList.json
│ └── MinimalAssignment.json
├── authenticationLog
│ ├── AuthenticationLogForAccount.json
│ ├── AuthenticationLogForLogin.json
│ └── AuthenticationLogForUser.json
├── calendar
│ ├── CalendarEvent.json
│ ├── CalendarEvents.json
│ ├── CalendarNotFound.json
│ ├── CreateCalendarEvent.json
│ ├── DeleteCalendarEvent.json
│ └── EditCalendarEvent.json
├── communicationChannel
│ ├── CommunicationChannelsList.json
│ ├── CreateCommunicationChannelResponse.json
│ ├── CreateCommunicationChannelSkipConfirmationResponse.json
│ └── DeleteCommunicationChannelResponse.json
├── contentMigration
│ ├── CreateContentMigrationRunning.json
│ ├── CreateContentMigrationWaiting.json
│ ├── CreateContentMigrationWithFile.json
│ ├── CreateContentMigrationWithFile2.json
│ ├── GetContentMigrationCompleted.json
│ ├── GetContentMigrationCompletedWithIssues.json
│ ├── GetContentMigrationSelectiveCompleted.json
│ ├── GetMigrationIssue.json
│ ├── GetSelectiveData.json
│ └── GetSelectiveDataTypeAssignments.json
├── course
│ ├── CreateCourseDateError.json
│ ├── CreateCourseSuccess.json
│ ├── DeleteConcludeCourseSuccess.json
│ ├── DeleteCourseSuccess.json
│ ├── GetCourseIncludeCourseImage.json
│ ├── UpdateCourseSuccess.json
│ └── UserCourseListResponse.json
├── file
│ └── GetFileSuccess.json
├── login
│ ├── DeleteLogin.json
│ ├── GetLoginForUser.json
│ ├── LoginUpdateFailedUniqueId.json
│ └── UpdateLogin.json
├── oauth
│ ├── InvalidAccessTokenResponse.json
│ ├── InvalidClientIdResponse.json
│ ├── InvalidRefreshTokenResponse.json
│ ├── SuccessfulAccessTokenResponse.json
│ └── UserUnauthorizedResponse.json
├── quiz
│ ├── Quiz1.json
│ ├── Quiz2.json
│ ├── QuizList.json
│ ├── QuizQuestionList.json
│ ├── QuizSubmissions.json
│ └── QuizSubmissionsIncludeUser.json
├── role
│ └── Role.json
├── sampleErrorMessageWithErrorArray.json
├── sampleErrorMessageWithoutErrorArray.json
├── section
│ ├── CreateSectionsSuccess.json
│ └── Sections.json
├── sisImport
│ └── SisImportCompleted.json
├── submission
│ └── submissionResponse.json
├── tab
│ └── UpdateTabSuccess.json
└── user
│ ├── IndividualUserList.json
│ ├── LargeUserList.json
│ ├── User1.json
│ ├── User2.json
│ ├── UserById.json
│ ├── UserByIdLong.json
│ ├── UserBySelfIdentifier.json
│ ├── UserBySisIntegrationId.json
│ ├── UserBySisUserId.json
│ ├── UserCreateFailedDuplicateId.json
│ ├── UserCreateFailedIntegrationId.json
│ ├── UserCreateFailedSisId.json
│ └── UserList.json
├── TestModels
├── TestModel.json
├── TestModels1.json
└── TestModels2.json
└── log4j.properties
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3 |
4 | name: Java CI with Maven
5 |
6 | on:
7 | push:
8 | branches: [ master ]
9 | pull_request:
10 | branches: [ master ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v2
19 | - name: Cache local Maven repository
20 | uses: actions/cache@v2
21 | with:
22 | path: ~/.m2/repository
23 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
24 | restore-keys: |
25 | ${{ runner.os }}-maven-
26 | - name: Set up JDK 1.8
27 | uses: actions/setup-java@v1
28 | with:
29 | java-version: 1.8
30 | - name: Build with Maven
31 | run: mvn -B package --file pom.xml
32 | # This is part of the release task so we don't want to allow failures.
33 | - name: Build JavaDoc with Maven
34 | run: mvn -B javadoc:javadoc --file pom.xml
35 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | .settings
3 | integration.properties
4 | rebel.xml
5 | rebel-remote.xml
6 | *.iml
7 | *.idea
8 | release.properties
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | canvas-api
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.common.project.facet.core.builder
10 |
11 |
12 |
13 |
14 | org.eclipse.jdt.core.javabuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.m2e.core.maven2Builder
20 |
21 |
22 |
23 |
24 | org.eclipse.wst.validation.validationbuilder
25 |
26 |
27 |
28 |
29 |
30 | org.eclipse.jem.workbench.JavaEMFNature
31 | org.eclipse.wst.common.modulecore.ModuleCoreNature
32 | org.eclipse.jdt.core.javanature
33 | org.eclipse.m2e.core.maven2Nature
34 | org.eclipse.wst.common.project.facet.core.nature
35 |
36 |
37 |
--------------------------------------------------------------------------------
/Jenkinsfile:
--------------------------------------------------------------------------------
1 | @Library('jenkins-shared-libs') _
2 | def config = [ appName: 'canvas-api',
3 | podName: 'java-11-maven-3.5.2.yaml',
4 | containerName: 'jdk-11-maven',
5 | runUnitTests: true,
6 | runIntegrationTests: false,
7 | runSonar: true
8 | ]
9 | javaPipeline(config)
10 |
--------------------------------------------------------------------------------
/integration-example.properties:
--------------------------------------------------------------------------------
1 | # Copy this file to integration.properties and set values to run integration tests.
2 | # The URL of the Canvas instance, best to use a best instance as when test fail they may leave traces in Canvas.
3 | url=https://instance.beta.instructure.com/
4 | # Set on live.
5 | # Token for a valid user who can create sections and create calendars in the course.
6 | token=11537~nqSvdZ55SkdnlqGyAuk7JHspdjlX7tZrXmjrlDMNLDWj2syiIwp4kwbrwJRS0nXC
7 | # ID of the user who's token it is.
8 | user=73
9 | # ID of course to use for course related tests.
10 | course=26841
11 | # ID of destination course to use for content migration.
12 | destination_course=26842
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/annotation/CanvasField.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Target(ElementType.METHOD)
10 | public @interface CanvasField {
11 |
12 | String postKey();
13 |
14 | /* Controls whether the key should be wrapped in the CanvasObject's postName.
15 | * For example if the class's CanvasObject annotation contains the postKey value of 'course',
16 | * and the CanvasField has a postKey value of 'id' then:
17 | * Setting array to true will result in the postMap key be 'course[id]'
18 | * Setting array to false will result in the postMap key to be 'id'
19 | */
20 | boolean array() default true;
21 |
22 | /*
23 | Used to override the key on the main Canvas Object. Leave empty unless necessary
24 | */
25 | String overrideObjectKey() default "";
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/annotation/CanvasObject.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.annotation;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.RetentionPolicy;
5 |
6 | @Retention(RetentionPolicy.RUNTIME)
7 | public @interface CanvasObject {
8 | String postKey();
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/constants/CanvasConstants.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.constants;
2 |
3 | public class CanvasConstants {
4 |
5 | private CanvasConstants(){}
6 |
7 | public static final String ACCOUNT_ID="1";
8 | public static final String MASQUERADE_SIS_USER="sis_user_id";
9 | public static final String MASQUERADE_CANVAS_USER="canvas_user_id";
10 |
11 | public static final String URLENCODING_TYPE = "UTF-8";
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/enums/SectionIncludes.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.enums;
2 |
3 | public enum SectionIncludes {
4 | STUDENTS,
5 | AVATAR_URL,
6 | ENROLLMENTS,
7 | TOTAL_STUDENTS,
8 | PASSBACK_STATUS;
9 |
10 | @Override
11 | public String toString() {
12 | return name().toLowerCase();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/enums/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Shared enums
3 | *
4 | * The hope was to consolidate enums, especially in the API options classes into
5 | * one place. The problem is that even when two different API calls accept (for
6 | * example) an enrollment_type
parameter, they may either accept
7 | * different values or require different string literals for the same logical
8 | * value.
9 | *
10 | * Example: the List your courses
API call takes an
11 | * enrollment_type
parameter which accepts the values: teacher,
12 | * student, ta, observer, designer. The Get users in course
API
13 | * call also has an enrollment_type
parameter and accepts all the
14 | * previously listed ones plus student_view. The List enrollments
15 | * API call also has the same parameter but it requires the strings
16 | * StudentEnrollment, TeacherEnrollment, TaEnrollment, DesignerEnrollment, and
17 | * ObserverEnrollment.
18 | *
19 | * So all the enums ended up getting sucked into the options classes where they
20 | * could reflect the actual values that Canvas allows and is expecting.
21 | */
22 | package edu.ksu.canvas.enums;
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/errors/ErrorDetails.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.errors;
2 |
3 | /**
4 | * This allows you to retrieve more information about what was wrong with your request.
5 | */
6 | public class ErrorDetails {
7 |
8 | private String type;
9 | private String attribute;
10 | private String message;
11 |
12 | public String getAttribute() {
13 | return attribute;
14 | }
15 |
16 | public void setAttribute(String attribute) {
17 | this.attribute = attribute;
18 | }
19 |
20 | public String getType() {
21 | return type;
22 | }
23 |
24 | public void setType(String type) {
25 | this.type = type;
26 | }
27 |
28 | public String getMessage() {
29 | return message;
30 | }
31 |
32 | public void setMessage(String message) {
33 | this.message = message;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/errors/ErrorHandler.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.errors;
2 |
3 | import org.apache.http.HttpRequest;
4 | import org.apache.http.HttpResponse;
5 |
6 | /**
7 | * This allows additional specific behaviour for handling errors.
8 | */
9 | public interface ErrorHandler {
10 |
11 | boolean shouldHandle(HttpRequest httpRequest, HttpResponse httpResponse);
12 |
13 | void handle(HttpRequest httpRequest, HttpResponse httpResponse);
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/errors/GenericErrorResponse.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.errors;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | /**
7 | * The error object that is returned when the creation of certain objects fails because the data isn't good.
8 | * This allows you to retrieve more information about what was wrong with your request.
9 | */
10 | public class GenericErrorResponse {
11 |
12 | private Map> errors;
13 |
14 | public Map> getErrors() {
15 | return errors;
16 | }
17 |
18 | public void setErrors(Map> errors) {
19 | this.errors = errors;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/errors/UserErrorHandler.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.errors;
2 |
3 | import com.google.gson.Gson;
4 | import edu.ksu.canvas.exception.CanvasException;
5 | import edu.ksu.canvas.impl.GsonResponseParser;
6 | import org.apache.http.HttpRequest;
7 | import org.apache.http.HttpResponse;
8 | import org.apache.http.util.EntityUtils;
9 |
10 | import java.io.IOException;
11 | import java.util.regex.Pattern;
12 |
13 | /**
14 | * The error handler that should be used when creation of a user fails.
15 | */
16 | public class UserErrorHandler implements ErrorHandler {
17 |
18 | private Pattern pattern = Pattern.compile("/api/v1/accounts/\\d+/users");
19 |
20 | @Override
21 | public boolean shouldHandle(HttpRequest httpRequest, HttpResponse httpResponse) {
22 | return
23 | pattern.matcher(httpRequest.getRequestLine().getUri()).find() &&
24 | httpResponse.getStatusLine().getStatusCode() == 400 &&
25 | httpResponse.getEntity().getContentType().getValue().contains("application/json");
26 | }
27 |
28 | @Override
29 | public void handle(HttpRequest httpRequest, HttpResponse httpResponse) {
30 | Gson gson = GsonResponseParser.getDefaultGsonParser(false);
31 | try {
32 | UserErrorResponse response = gson.fromJson(EntityUtils.toString(httpResponse.getEntity()), UserErrorResponse.class);
33 | if (response.getErrors() != null) {
34 | throw new CanvasException("Failed to create user.", httpRequest.getRequestLine().getUri(), response);
35 | }
36 | } catch (IOException e) {
37 | // Ignore.
38 | }
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/errors/UserErrorResponse.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.errors;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | /**
7 | * The error object that is returned when the creation of a user fails because the data isn't good.
8 | * This allows you to retrieve more information about what was wrong with your request.
9 | */
10 | public class UserErrorResponse {
11 |
12 | private Errors errors;
13 |
14 | public Errors getErrors() {
15 | return errors;
16 | }
17 |
18 | public void setErrors(Errors errors) {
19 | this.errors = errors;
20 | }
21 |
22 | public static class Errors {
23 | private Map> user;
24 | private Map> pseudonym;
25 |
26 | public Map> getUser() {
27 | return user;
28 | }
29 |
30 | public void setUser(Map> user) {
31 | this.user = user;
32 | }
33 |
34 | public Map> getPseudonym() {
35 | return pseudonym;
36 | }
37 |
38 | public void setPseudonym(Map> pseudonym) {
39 | this.pseudonym = pseudonym;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/exception/CanvasException.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.exception;
2 |
3 | /**
4 | * Base exception for errors arising while talking to Canvas.
5 | * When thrown, it can optionally carry a string containing the
6 | * human readable error message returned by Canvas, if any.
7 | * Sometimes it may be appropriate to display this error message
8 | * to the user.It can also carry the URL of the failed request.
9 | */
10 | public class CanvasException extends RuntimeException {
11 | private static final long serialVersionUID = 1L;
12 |
13 | private final String canvasErrorMessage;
14 | private final String requestUrl;
15 | private final Object error;
16 |
17 | public CanvasException() {
18 | canvasErrorMessage = null;
19 | requestUrl = null;
20 | error = null;
21 | }
22 |
23 | public CanvasException(String canvasErrorString, String url) {
24 | super(String.format("Error from URL %s : %s", url, canvasErrorString));
25 | canvasErrorMessage = canvasErrorString;
26 | requestUrl = url;
27 | error = null;
28 | }
29 |
30 | public CanvasException(String canvasErrorString, String url, Object error) {
31 | canvasErrorMessage = canvasErrorString;
32 | requestUrl = url;
33 | this.error = error;
34 | }
35 |
36 | public Object getError() {
37 | return error;
38 | }
39 |
40 | public String getCanvasErrorMessage() {
41 | return canvasErrorMessage;
42 | }
43 |
44 | public String getRequestUrl() {
45 | return requestUrl;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/exception/InvalidOauthTokenException.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.exception;
2 |
3 | /**
4 | * Thrown if Canvas returns a 401 response with a WWW-Authenticate header present.
5 | * Sometimes this is just because the access token has expired and
6 | * needs to be refreshed. If this is the case, the exception will
7 | * be caught in the RefreshingRestClient class and handled. If this
8 | * exception makes it back up to the calling code, it probably means
9 | * that the user's refresh token (or the manually generated admin token)
10 | * is invalid.
11 | */
12 | public class InvalidOauthTokenException extends CanvasException {
13 | private static final long serialVersionUID = 1L;
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/exception/ObjectNotFoundException.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.exception;
2 |
3 | /**
4 | * Thrown if Canvas returns a 404 response.
5 | */
6 | public class ObjectNotFoundException extends CanvasException {
7 | private static final long serialVersionUID = 1L;
8 |
9 | public ObjectNotFoundException() {
10 | super();
11 | }
12 |
13 | public ObjectNotFoundException(String canvasErrorString, String url) {
14 | super(canvasErrorString, url);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/exception/RateLimitException.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.exception;
2 |
3 | /**
4 | * Thrown if Canvas returns a 403 Rate Limit Exceeded response.
5 | */
6 | public class RateLimitException extends CanvasException {
7 |
8 | public RateLimitException() {
9 | super();
10 | }
11 |
12 | public RateLimitException(String canvasErrorString, String url) {
13 | super(canvasErrorString, url);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/exception/RetriableException.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.exception;
2 |
3 | /**
4 | * Thrown if Canvas returns a retriable response, for example, a 504, Gateway Timeout.
5 | * This usually means that the front end web server has timed out while waiting for the
6 | * application server to complete the request. The request could still be in flight on
7 | * the application server but there is no guarantee as to what state it is in.
8 | * Usually you will probably want to retry the request.
9 | */
10 | public class RetriableException extends CanvasException {
11 | private static final long serialVersionUID = 1L;
12 |
13 | public RetriableException() {
14 | super();
15 | }
16 |
17 | public RetriableException(String canvasErrorString, String url) {
18 | super(canvasErrorString, url);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/exception/ThrottlingException.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.exception;
2 |
3 | /**
4 | * Thrown if Canvas returns a 403 response in response to too many API requests
5 | * See https://canvas.instructure.com/doc/api/file.throttling.html
6 | */
7 | public class ThrottlingException extends CanvasException {
8 | private static final long serialVersionUID = 1L;
9 |
10 | public ThrottlingException() {
11 | super();
12 | }
13 |
14 | public ThrottlingException(String canvasErrorString, String url) {
15 | super(canvasErrorString, url);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/exception/UnauthorizedException.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.exception;
2 |
3 | /**
4 | * Thrown if Canvas returns a 401 response without a WWW-Authenticate header.
5 | * Indicates that the user does not have permission to access the
6 | * requested resource. I believe this is actually an incorrect use
7 | * of 401 and it should be 403 instead but this is how the Canvas API do.
8 | */
9 | public class UnauthorizedException extends CanvasException {
10 | private static final long serialVersionUID = 1L;
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Exceptions thrown when canvas returns errors.
3 | */
4 | package edu.ksu.canvas.exception;
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/impl/AdminImpl.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.impl;
2 |
3 | import com.google.gson.reflect.TypeToken;
4 |
5 | import edu.ksu.canvas.interfaces.*;
6 | import edu.ksu.canvas.model.AccountAdmin;
7 | import edu.ksu.canvas.net.RestClient;
8 | import edu.ksu.canvas.oauth.OauthToken;
9 | import edu.ksu.canvas.requestOptions.ListAccountAdminsOptions;
10 |
11 | import org.slf4j.Logger;
12 | import org.slf4j.LoggerFactory;
13 |
14 | import java.io.IOException;
15 | import java.lang.reflect.Type;
16 | import java.util.List;
17 |
18 | public class AdminImpl extends BaseImpl implements AdminReader, AdminWriter {
19 | private static final Logger LOG = LoggerFactory.getLogger(AdminImpl.class);
20 |
21 | public AdminImpl(String canvasBaseUrl, Integer apiVersion, OauthToken oauthToken, RestClient restClient,
22 | int connectTimeout, int readTimeout, Integer paginationPageSize, Boolean serializeNulls) {
23 | super(canvasBaseUrl, apiVersion, oauthToken, restClient, connectTimeout, readTimeout,
24 | paginationPageSize, serializeNulls);
25 | }
26 |
27 | @Override
28 | public List listAccountAdmins(ListAccountAdminsOptions options) throws IOException {
29 | LOG.debug("Getting list of account admins");
30 | String url = buildCanvasUrl("accounts/" + options.getAccountId() + "/admins", options.getOptionsMap());
31 | return getListFromCanvas(url);
32 | }
33 |
34 | @Override
35 | protected Type listType() {
36 | return new TypeToken>(){}.getType();
37 | }
38 |
39 | @Override
40 | protected Class objectType() {
41 | return AccountAdmin.class;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/impl/ModuleImpl.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.impl;
2 |
3 | import com.google.gson.reflect.TypeToken;
4 | import edu.ksu.canvas.interfaces.CanvasWriter;
5 | import edu.ksu.canvas.interfaces.ModuleReader;
6 | import edu.ksu.canvas.model.Module;
7 | import edu.ksu.canvas.net.RestClient;
8 | import edu.ksu.canvas.oauth.OauthToken;
9 | import edu.ksu.canvas.requestOptions.ListModulesOptions;
10 | import org.slf4j.Logger;
11 | import org.slf4j.LoggerFactory;
12 |
13 | import java.io.IOException;
14 | import java.lang.reflect.Type;
15 | import java.util.List;
16 |
17 | public class ModuleImpl extends BaseImpl implements ModuleReader {
18 | private static final Logger LOG = LoggerFactory.getLogger(ModuleImpl.class);
19 |
20 | public ModuleImpl(final String canvasBaseUrl, final Integer apiVersion, final OauthToken oauthToken, final RestClient restClient, final int connectTimeout, final int readTimeout, final Integer paginationPageSize, final Boolean serializeNulls) {
21 | super(canvasBaseUrl, apiVersion, oauthToken, restClient, connectTimeout, readTimeout, paginationPageSize, serializeNulls);
22 | }
23 |
24 | @Override
25 | public List getModulesInCourse(final ListModulesOptions options) throws IOException {
26 | LOG.debug("Retrieving modules for course {}", options.getCourseId());
27 | String url = buildCanvasUrl(String.format("courses/%d/modules", options.getCourseId()), options.getOptionsMap());
28 | return getListFromCanvas(url);
29 | }
30 |
31 | @Override
32 | protected Class objectType() {
33 | return Module.class;
34 | }
35 |
36 | @Override
37 | protected Type listType() {
38 | return new TypeToken>() {
39 | }.getType();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/impl/RoleImpl.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.impl;
2 |
3 | import com.google.gson.reflect.TypeToken;
4 |
5 | import edu.ksu.canvas.interfaces.*;
6 | import edu.ksu.canvas.model.Role;
7 | import edu.ksu.canvas.net.RestClient;
8 | import edu.ksu.canvas.oauth.OauthToken;
9 | import edu.ksu.canvas.requestOptions.ListRolesOptions;
10 |
11 | import org.slf4j.Logger;
12 | import org.slf4j.LoggerFactory;
13 |
14 | import java.io.IOException;
15 | import java.lang.reflect.Type;
16 | import java.util.List;
17 |
18 | public class RoleImpl extends BaseImpl implements RoleReader, RoleWriter {
19 | private static final Logger LOG = LoggerFactory.getLogger(RoleImpl.class);
20 |
21 | public RoleImpl(String canvasBaseUrl, Integer apiVersion, OauthToken oauthToken, RestClient restClient,
22 | int connectTimeout, int readTimeout, Integer paginationPageSize, Boolean serializeNulls) {
23 | super(canvasBaseUrl, apiVersion, oauthToken, restClient, connectTimeout, readTimeout,
24 | paginationPageSize, serializeNulls);
25 | }
26 |
27 | @Override
28 | public List listRoles(ListRolesOptions options) throws IOException {
29 | LOG.debug("Retrieving roles for account {}", options.getAccountId());
30 | String url = buildCanvasUrl("accounts/" + options.getAccountId() + "/roles", options.getOptionsMap());
31 | return getListFromCanvas(url);
32 | }
33 |
34 | @Override
35 | protected Type listType() {
36 | return new TypeToken>(){}.getType();
37 | }
38 |
39 | @Override
40 | protected Class objectType() {
41 | return Role.class;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/impl/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Default implementations for Canvas API calls.
3 | */
4 | package edu.ksu.canvas.impl;
5 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/AccountReportReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import java.io.IOException;
4 | import java.util.List;
5 | import java.util.Optional;
6 |
7 | import edu.ksu.canvas.model.report.AccountReport;
8 |
9 | public interface AccountReportReader extends CanvasReader {
10 |
11 | /**
12 | * Generate a list of previously run reports for a given report type.
13 | * @param accountId the account ID to run the reports against
14 | * @param report the specific name of the report (e.g. sis_export_csv)
15 | * @return a list of run reports specified by the report ID
16 | * @throws IOException When there is an error communicating with Canvas
17 | */
18 | List listReports(String accountId, String report) throws IOException;
19 |
20 | /**
21 | * Pull back the status of a given report.
22 | * @param accountId the account ID to run the reports against
23 | * @param report the specific name of the report (e.g. sis_export_csv)
24 | * @param id the ID of the running report
25 | * @return a report outlining the status of its run, or a summary of its completed run
26 | * @throws IOException When there is an error communicating with Canvas
27 | */
28 | Optional reportStatus(String accountId, String report, Long id) throws IOException;
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/AccountReportSummaryReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import java.io.IOException;
4 | import java.util.List;
5 |
6 | import edu.ksu.canvas.model.report.AccountReportSummary;
7 |
8 | public interface AccountReportSummaryReader extends CanvasReader {
9 |
10 | /**
11 | * Generate a list of reports available for the specified account.
12 | * See the Canvas API documentation for more details.
13 | * @param accountId the account ID to run the reports against
14 | * @return a summary list of reports, showing the most recent runs if any exist
15 | * @throws IOException When there is an error communicating with Canvas
16 | */
17 | List listAvailableReports(String accountId) throws IOException;
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/AccountReportSummaryWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.report.AccountReportSummary;
4 |
5 | public interface AccountReportSummaryWriter extends CanvasWriter {
6 | }
7 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/AccountReportWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import java.io.IOException;
4 | import java.util.Optional;
5 |
6 | import edu.ksu.canvas.model.report.AccountReport;
7 | import edu.ksu.canvas.requestOptions.AccountReportOptions;
8 |
9 | public interface AccountReportWriter extends CanvasWriter {
10 |
11 | /**
12 | * Start a new report, specifying a set of options to run with.
13 | *
14 | * Note that the options used vary depending on the report you wish to start.
15 | * @param options options that should be passed to start the report
16 | * @return an Optional<AccountReport>
which contains a reference to the generated report
17 | * @throws IOException When there is an error communicating with Canvas
18 | * @see Account Report API documentation
19 | * @see AccountReportOptions
20 | */
21 | Optional startReport(AccountReportOptions options) throws IOException;
22 |
23 |
24 | /**
25 | * Delete a report. This can also be used to stop the run of a report.
26 | * @param accountId the account id used to generate the report
27 | * @param report the name of the report
28 | * @param reportId the ID of the report
29 | * @return an Optional<AccountReport>
which contains a reference to the deleted report
30 | * @throws IOException When there is an error communicating with Canvas
31 | * @see Account Report API documentation
32 | */
33 | Optional deleteReport(String accountId, String report, Long reportId) throws IOException;
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/AccountWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.Account;
4 |
5 | import java.io.IOException;
6 | import java.util.Optional;
7 |
8 | public interface AccountWriter extends CanvasWriter {
9 | /**
10 | * Create a new account in Canvas
11 | * @param accountId the account ID of the account under which to place this account
12 | * @param account A account object containing the information needed to create a account in Canvas
13 | * @return The newly created account
14 | * @throws IOException When there is an error communicating with Canvas
15 | */
16 | Optional createAccount(String accountId, Account account) throws IOException;
17 |
18 | /**
19 | * Update a account in Canvas
20 | * @param account A account object containing the information needed to update a account in Canvas
21 | * @return The newly updated account
22 | * @throws IOException When there is an error communicating with Canvas
23 | */
24 | Optional updateAccount(Account account) throws IOException;
25 |
26 | /**
27 | * @param parentAccountId The ID of the parent account to the account to delete.
28 | * @param accountId The ID of the account you wish to delete
29 | * @return true if the account was deleted
30 | * @throws IOException When there is an error communicating with Canvas
31 | */
32 | Boolean deleteAccount(String parentAccountId, String accountId) throws IOException;
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/AdminReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.AccountAdmin;
4 | import edu.ksu.canvas.requestOptions.ListAccountAdminsOptions;
5 |
6 | import java.io.IOException;
7 | import java.util.List;
8 |
9 | public interface AdminReader extends CanvasReader {
10 | /**
11 | * Return a list of account admins that the current user can view or manage.
12 | * @param options Object encapsulating parameters to the list accounts API call
13 | * @return List of account admins
14 | * @throws IOException When there is an error communicating with Canvas
15 | */
16 | List listAccountAdmins(ListAccountAdminsOptions options) throws IOException;
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/AdminWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.AccountAdmin;
4 |
5 | public interface AdminWriter extends CanvasWriter {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/AssignmentGroupReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.assignment.AssignmentGroup;
4 | import edu.ksu.canvas.requestOptions.GetAssignmentGroupOptions;
5 | import edu.ksu.canvas.requestOptions.ListAssignmentGroupOptions;
6 |
7 | import java.io.IOException;
8 | import java.util.List;
9 | import java.util.Optional;
10 |
11 | public interface AssignmentGroupReader extends CanvasReader{
12 |
13 | /**
14 | * Return a list of AssignmentGroups that the current user can view or manage.
15 | * @param options A mapping of optional parameters for assignment groups
16 | * @return List of AssignmentGroups
17 | * @throws IOException When there is an error communicating with Canvas
18 | */
19 | List listAssignmentGroup(ListAssignmentGroupOptions options) throws IOException;
20 |
21 | /**
22 | * Returns the requested assignment group by ID
23 | * @param options Collection of optional parameters to the Canvas API
24 | * @return The requested assignment group
25 | * @throws IOException When there is an error communicating with Canvas
26 | */
27 | Optional getAssignmentGroup(GetAssignmentGroupOptions options) throws IOException;
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/AssignmentOverrideReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.assignment.AssignmentOverride;
4 | import java.io.IOException;
5 | import java.util.List;
6 | import java.util.Optional;
7 |
8 | public interface AssignmentOverrideReader extends CanvasReader {
9 |
10 | /***
11 | * Returns the list of overrides for this assignment that target sections/groups/students visible to the current user.
12 | * @param courseId Canvas course ID or "sis_course_id:1234" for SIS course ID
13 | * @param assignmentId Canvas assignment ID
14 | * @return List of assignment overrides
15 | * @throws IOException When there is an error communicating with Canvas
16 | */
17 | List listAssignmentOverrides(String courseId, Long assignmentId) throws IOException;
18 |
19 | /***
20 | * Returns details of the the override with the given id.
21 | * @param courseId Canvas course ID or "sis_course_id:1234" for SIS course ID
22 | * @param assignmentId Canvas assignment ID
23 | * @param overrideId Canvas ID of the specific assignment override to query for
24 | * @return The requested assigment override object
25 | * @throws IOException When there is an error communicating with Canvas
26 | */
27 | Optional getAssignmentOverride(String courseId, Long assignmentId, Long overrideId) throws IOException;
28 | }
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/AssignmentOverrideWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import java.io.IOException;
4 | import java.util.Optional;
5 |
6 | import edu.ksu.canvas.model.assignment.AssignmentOverride;
7 |
8 | public interface AssignmentOverrideWriter extends CanvasWriter {
9 |
10 | /**
11 | * Creates an assignment override in canvas. The override object must have an assignment ID set.
12 | * @param courseId Course that the assignment is in
13 | * @param assignmentOverride The Override object to create
14 | * @return AssignmentOverride object created in Canvas
15 | * @throws IOException When there is an error communicating with Canvas
16 | */
17 | Optional createAssignmentOverride(String courseId, AssignmentOverride assignmentOverride) throws IOException;
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/AssignmentWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import java.io.IOException;
4 | import java.util.Optional;
5 |
6 | import edu.ksu.canvas.model.assignment.Assignment;
7 |
8 | public interface AssignmentWriter extends CanvasWriter {
9 |
10 | /**
11 | * Create an assignment in Canvas. The only required field is name.
12 | * @param courseId ID of the course to create the assignment in
13 | * @param assignment Assignment object to create. Must have at least a name set
14 | * @return The created assignment object
15 | * @throws IOException When there is an error communicating with Canvas
16 | */
17 | Optional createAssignment(String courseId, Assignment assignment) throws IOException;
18 |
19 | /**
20 | * Deletes a specified assignment in canvas
21 | * @param courseId Course ID of course to delete assignment from
22 | * @param assignmentId Assignment ID of assignment to delete
23 | * @return The deleted Assignment object as returned by the Canvas API
24 | * @throws IOException When there is an error communicating with Canvas
25 | */
26 | Optional deleteAssignment(String courseId, Long assignmentId) throws IOException;
27 |
28 | /**
29 | * Writes an Assignment object to the Canvas API
30 | * @param courseId Course ID that this assignment is associated with
31 | * @param assignment The assignment settings to write to the API
32 | * @return The modified Assignment returned by the API
33 | * @throws IOException When there is an error communicating with Canvas
34 | */
35 | Optional editAssignment(String courseId, Assignment assignment) throws IOException;
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/AuthenticationLogReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.AuthenticationLog;
4 |
5 | import java.io.IOException;
6 | import java.util.Optional;
7 |
8 | public interface AuthenticationLogReader extends CanvasReader {
9 |
10 | /**
11 | * Returns an authentication log.
12 | * @param accountId The account ID for the authentication log
13 | * @return An authentication log
14 | * @throws IOException When there is an error communicating with Canvas
15 | */
16 | Optional getAuthenticationLogForAccount(String accountId) throws IOException;
17 |
18 | /**
19 | * Returns an authentication log.
20 | * @param loginId The login ID for the authentication log
21 | * @return An authentication log
22 | * @throws IOException When there is an error communicating with Canvas
23 | */
24 | Optional getAuthenticationLogForLogin(String loginId) throws IOException;
25 |
26 | /**
27 | * Returns an authentication log.
28 | * @param userId The user ID for the authentication log
29 | * @return An authentication log
30 | * @throws IOException When there is an error communicating with Canvas
31 | */
32 | Optional getAuthenticationLogForUser(String userId) throws IOException;
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/CalendarWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.CalendarEvent;
4 | import edu.ksu.canvas.requestOptions.DeleteCalendarEventOptions;
5 |
6 | import java.io.IOException;
7 | import java.util.Optional;
8 |
9 | /**
10 | * Methods to manipulate calendar events in Canvas.
11 | * @see Canvas calendar event documentation
12 | *
13 | */
14 | public interface CalendarWriter extends CanvasWriter {
15 |
16 | /**
17 | * Delete a calendar event from Canvas.
18 | * @param options Options class containing required and optional parameters for the delete action
19 | * @return The deleted calendar event
20 | * @throws IOException When there is an error communicating with Canvas
21 | */
22 | Optional deleteCalendarEvent(DeleteCalendarEventOptions options) throws IOException;
23 |
24 | /**
25 | * Create a new calendar event in Canvas.
26 | * @param calendarEvent Calendar event object to persist to Canvas. Context code is required.
27 | * @return The newly created calendar event
28 | * @throws IOException When there is an error communicating with Canvas
29 | */
30 | Optional createCalendarEvent(CalendarEvent calendarEvent) throws IOException;
31 |
32 | /**
33 | * Modify a calendar event in Canvas.
34 | * @param calendarEvent An existing calendar event to modify
35 | * @return The updated calendar event
36 | * @throws IOException When there is an error communicating with Canvas
37 | */
38 | Optional editCalendarEvent(CalendarEvent calendarEvent) throws IOException;
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/CanvasReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 |
4 | import java.util.List;
5 | import java.util.function.Consumer;
6 |
7 | public interface CanvasReader {
8 | /*
9 | * Perform an operation with a callback. This is used to
10 | * to perform operations on paginated calls before the final
11 | * response is complete.
12 | */
13 | READERTYPE withCallback(Consumer> responseConsumer);
14 |
15 | READERTYPE readAsCanvasUser(String masqueradeAs);
16 |
17 | READERTYPE readAsSisUser(String masqueradeAs);
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/CanvasWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | public interface CanvasWriter {
4 |
5 | WRITERTYPE writeAsCanvasUser(String masqueradeAs);
6 |
7 | WRITERTYPE writeAsSisUser(String masqueradeAs);
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/CommunicationChannelReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.CommunicationChannel;
4 |
5 | import java.io.IOException;
6 | import java.util.List;
7 |
8 | public interface CommunicationChannelReader extends CanvasReader {
9 | /**
10 | * Retrieve a user's communication channels.
11 | * @param userId the id of the user to retrieve communication channels for
12 | * @return List of the user's communication channels
13 | * @throws IOException When there is an error communicating with Canvas
14 | */
15 | public List getCommunicationChannelsForUser(String userId) throws IOException;
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/CommunicationChannelWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import java.io.IOException;
4 | import java.util.Optional;
5 |
6 | import edu.ksu.canvas.model.CommunicationChannel;
7 | import edu.ksu.canvas.requestOptions.CreateCommunicationChannelOptions;
8 |
9 | public interface CommunicationChannelWriter extends CanvasWriter {
10 |
11 | /**
12 | * Adds a communication channel to a Canvas user.
13 | * @param options The communication channel to create. Must contain user ID and address.
14 | * @return The created communication channel object if creation was successful
15 | * @throws IOException When there is an error communicating with Canvas
16 | */
17 | Optional createCommunicationChannel(CreateCommunicationChannelOptions options) throws IOException;
18 |
19 | /**
20 | * Delete a communication channel from Canvas
21 | * @param cc The communication channel record to delete. Must contain User ID and communication channel ID.
22 | * @return The now deleted communication channel record
23 | * @throws IOException When there is an error communicating with Canvas
24 | */
25 | Optional deleteCommunicationChannel(CommunicationChannel cc) throws IOException;
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/ContentMigrationWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.ContentMigration;
4 | import edu.ksu.canvas.requestOptions.CreateContentMigrationOptions;
5 | import edu.ksu.canvas.requestOptions.CreateCourseContentMigrationOptions;
6 |
7 | import java.io.IOException;
8 |
9 | import java.util.Optional;
10 |
11 | public interface ContentMigrationWriter extends CanvasWriter{
12 |
13 | Optional createCourseContentMigration(CreateCourseContentMigrationOptions options) throws IOException;
14 | Optional updateCourseContentMigration(Long id, CreateCourseContentMigrationOptions options) throws IOException;
15 |
16 | Optional createUserContentMigration(CreateContentMigrationOptions options) throws IOException;
17 | Optional updateUserContentMigration(Long id, CreateContentMigrationOptions options) throws IOException;
18 |
19 | Optional createGroupContentMigration(CreateContentMigrationOptions options) throws IOException;
20 | Optional updateGroupContentMigration(Long id, CreateContentMigrationOptions options) throws IOException;
21 |
22 | Optional createAccountContentMigration(CreateContentMigrationOptions options) throws IOException;
23 | Optional updateAccountContentMigration(Long id, CreateContentMigrationOptions options) throws IOException;
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/ConversationReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import java.io.IOException;
4 | import java.util.Optional;
5 |
6 | import edu.ksu.canvas.model.Conversation;
7 | import edu.ksu.canvas.requestOptions.GetSingleConversationOptions;
8 |
9 | public interface ConversationReader extends CanvasReader {
10 |
11 | /**
12 | * Get a single conversation from Canvas
13 | * @param options API options for the conversation call
14 | * @return The requested conversation, if it exists
15 | * @throws IOException if there is an error communicating with Canvas
16 | */
17 | public Optional getSingleConversation(GetSingleConversationOptions options) throws IOException;
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/CourseSettingsReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.CourseSettings;
4 |
5 | import java.io.IOException;
6 | import java.util.Optional;
7 |
8 | public interface CourseSettingsReader extends CanvasReader {
9 |
10 | /**
11 | * Returns course settings from Canvas
12 | *
13 | * See Get course settings
14 | * in the Canvas docs for details.
15 | * @param courseId The Canvas ID of the course or sis_course_id:SISID
16 | * @return The course settings from Canvas
17 | * @throws IOException When there is an error communicating with Canvas
18 | */
19 | Optional getCourseSettings(String courseId) throws IOException;
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/CourseSettingsWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.CourseSettings;
4 |
5 | import java.io.IOException;
6 | import java.util.Optional;
7 |
8 | public interface CourseSettingsWriter extends CanvasWriter {
9 |
10 | /**
11 | * Push modified course settings to Canvas.
12 | *
13 | * Only fields with the @CanvasField annotation can be changed.
14 | * @param courseId Canvas ID (or sis_course_id:XXXX) of the course
15 | * @param settings New settings to push to Canvas
16 | * @return The updated course settings
17 | * @throws IOException When there is an error communicating with Canvas
18 | */
19 | Optional updateCourseSettings(String courseId, CourseSettings settings) throws IOException;
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/EnrollmentReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.Enrollment;
4 | import edu.ksu.canvas.requestOptions.GetEnrollmentOptions;
5 |
6 | import java.io.IOException;
7 | import java.util.List;
8 |
9 | public interface EnrollmentReader extends CanvasReader {
10 | /**
11 | * Retrieve a user's enrollments. Object ID in the options class must be a user ID.
12 | * @param options API options available to this call
13 | * @return List of the user's enrollments
14 | * @throws IOException When there is an error communicating with Canvas
15 | */
16 | List getUserEnrollments(GetEnrollmentOptions options) throws IOException;
17 |
18 | /**
19 | * Retrieve enrollments in a given section. Object ID in the options class must be a section ID.
20 | * @param options API options available to this call
21 | * @return List of enrollments in a section
22 | * @throws IOException When there is an error communicating with Canvas
23 | */
24 | List getSectionEnrollments(GetEnrollmentOptions options) throws IOException;
25 |
26 | /**
27 | * Retrieve enrollments in a given course. Object ID in the options class must be a course ID.
28 | * @param options API options available to this call
29 | * @return List of enrollments in a course
30 | * @throws IOException When there is an error communicating with Canvas
31 | */
32 | List getCourseEnrollments(GetEnrollmentOptions options) throws IOException;
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/EnrollmentTermReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.EnrollmentTerm;
4 | import edu.ksu.canvas.requestOptions.GetEnrollmentTermOptions;
5 |
6 | import java.io.IOException;
7 | import java.util.List;
8 | import java.util.Optional;
9 |
10 | public interface EnrollmentTermReader extends CanvasReader {
11 |
12 | /**
13 | * Retrieve the enrollment terms for a single account.
14 | * @param options API options available to this call
15 | * @return the list of enrollment terms for that account
16 | * @throws IOException When there is an error communicating with Canvas
17 | */
18 | List getEnrollmentTerms(GetEnrollmentTermOptions options) throws IOException;
19 |
20 | /**
21 | * Get a single enrollment term.
22 | * @param accountId The account ID to look in.
23 | * @param termId The term ID to lookup.
24 | * @return an Optional EnrollmentTerm for the ID.
25 | * @throws IOException When there is an error communicating with Canvas
26 | */
27 | Optional getEnrollmentTerm(String accountId, String termId) throws IOException;
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/EnrollmentTermWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 |
4 | import edu.ksu.canvas.model.EnrollmentTerm;
5 |
6 | public interface EnrollmentTermWriter extends CanvasWriter {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/FeatureFlagReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.FeatureFlag;
4 |
5 | import java.io.IOException;
6 | import java.util.Optional;
7 |
8 | public interface FeatureFlagReader extends CanvasReader {
9 |
10 | Optional getCourseFeatureFlag(String courseId, String feature) throws IOException;
11 | Optional getAccountFeatureFlag(String accountId, String feature) throws IOException;
12 | Optional getUserFeatureFlag(String userId, String feature) throws IOException;
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/FeatureFlagWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.FeatureFlag;
4 |
5 | import java.io.IOException;
6 | import java.util.Optional;
7 |
8 | public interface FeatureFlagWriter extends CanvasWriter {
9 |
10 | Optional updateCourseFeatureFlag(String courseId, String feature, FeatureFlag.State state) throws IOException;
11 | Optional updateAccountFeatureFlag(String accountId, String feature, FeatureFlag.State state) throws IOException;
12 | Optional updateUserFeatureFlag(String userId, String feature, FeatureFlag.State state) throws IOException;
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/FeatureReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.Feature;
4 |
5 | import java.io.IOException;
6 | import java.util.List;
7 |
8 | public interface FeatureReader extends CanvasReader {
9 |
10 | List getCourseFeatures(String courseId) throws IOException;
11 |
12 | List getAccountFeatures(String accountId) throws IOException;
13 |
14 | List getUserFeatures(String userId) throws IOException;
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/FeatureWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.Feature;
4 |
5 | public interface FeatureWriter extends CanvasWriter {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/FileReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.File;
4 |
5 | import java.io.IOException;
6 | import java.util.Optional;
7 |
8 | /**
9 | * This is just used for getting a file after it's been uploaded at the moment.
10 | */
11 | public interface FileReader extends CanvasReader {
12 |
13 | /**
14 | * This is used primarily when you have a redirect after you've uploaded a file.
15 | * @param url The URL of the file that has been uploaded.
16 | * @return The file object wrapped in an optional.
17 | * @throws IOException When there is an error communicating with Canvas
18 | */
19 | Optional getFile(String url) throws IOException;
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/FileWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.Deposit;
4 | import edu.ksu.canvas.model.File;
5 |
6 | import java.io.IOException;
7 | import java.io.InputStream;
8 | import java.util.Optional;
9 |
10 | /**
11 | * This just allows you to upload a file once you've requested a file to be uploaded.
12 | * https://canvas.instructure.com/doc/api/file.file_uploads.html
13 | */
14 | public interface FileWriter extends CanvasWriter {
15 |
16 | Optional upload(Deposit deposit, InputStream in, String filename) throws IOException;
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/GradingStandardWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.GradingStandard;
4 |
5 | public interface GradingStandardWriter extends CanvasWriter {
6 | }
7 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/LoginReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.Login;
4 |
5 | import java.io.IOException;
6 | import java.util.List;
7 |
8 | public interface LoginReader extends CanvasReader {
9 | /**
10 | * Retrieve a user's logins.
11 | * @param userId the id of the user to retrieve logins for
12 | * @return List of the user's logins
13 | * @throws IOException When there is an error communicating with Canvas
14 | */
15 | public List getLoginForUser(String userId) throws IOException;
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/LoginWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import java.io.IOException;
4 | import java.util.Optional;
5 |
6 | import edu.ksu.canvas.model.Login;
7 |
8 | public interface LoginWriter extends CanvasWriter {
9 |
10 | /**
11 | * Write changes to a login to Canvas.
12 | * @param login The modified login to update. Must contain account ID and login ID.
13 | * @return The modified login object if update was successful
14 | * @throws IOException When there is an error communicating with Canvas
15 | */
16 | Optional updateLogin(Login login) throws IOException;
17 |
18 | /**
19 | * Delete a login from Canvas
20 | * @param login The login record to delete. Must contain User ID and login ID.
21 | * @return The now deleted login record
22 | * @throws IOException When there is an error communicating with Canvas
23 | */
24 | Optional deleteLogin(Login login) throws IOException;
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/ModuleReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.Module;
4 | import edu.ksu.canvas.requestOptions.ListModulesOptions;
5 |
6 | import java.io.IOException;
7 | import java.util.List;
8 |
9 | public interface ModuleReader extends CanvasReader {
10 | /**
11 | * Retrieve the list of modules in a course.
12 | *
13 | * @param options The object holding options for this API call
14 | * @return List of the course's modules
15 | * @throws IOException When there is an error communicating with Canvas
16 | */
17 | public List getModulesInCourse(ListModulesOptions options) throws IOException;
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/PageWriter.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import java.io.IOException;
4 | import java.util.Optional;
5 |
6 | import edu.ksu.canvas.model.Page;
7 |
8 | public interface PageWriter extends CanvasWriter {
9 |
10 | /**
11 | * Save a course page to Canvas
12 | * @param page The page object to save
13 | * @param courseId The Canvas course ID that this page is to be saved to
14 | * @return The update page after saving
15 | * @throws IOException When there is an error communicating with Canvas
16 | */
17 | Optional updateCoursePage(Page page, String courseId) throws IOException;
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/edu/ksu/canvas/interfaces/ProgressReader.java:
--------------------------------------------------------------------------------
1 | package edu.ksu.canvas.interfaces;
2 |
3 | import edu.ksu.canvas.model.Progress;
4 |
5 | import java.io.IOException;
6 | import java.util.Optional;
7 |
8 | public interface ProgressReader extends CanvasReader