All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.codebuild.model.UpdateWebhookRequest Maven / Gradle / Ivy

Go to download

The AWS Java SDK for AWS Code Build module holds the client classes that are used for communicating with AWS Code Build.

There is a newer version: 2.29.39
Show newest version
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

package software.amazon.awssdk.services.codebuild.model;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class UpdateWebhookRequest extends CodeBuildRequest implements
        ToCopyableBuilder {
    private static final SdkField PROJECT_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("projectName").getter(getter(UpdateWebhookRequest::projectName)).setter(setter(Builder::projectName))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("projectName").build()).build();

    private static final SdkField BRANCH_FILTER_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("branchFilter").getter(getter(UpdateWebhookRequest::branchFilter)).setter(setter(Builder::branchFilter))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("branchFilter").build()).build();

    private static final SdkField ROTATE_SECRET_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
            .memberName("rotateSecret").getter(getter(UpdateWebhookRequest::rotateSecret)).setter(setter(Builder::rotateSecret))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("rotateSecret").build()).build();

    private static final SdkField>> FILTER_GROUPS_FIELD = SdkField
            .>> builder(MarshallingType.LIST)
            .memberName("filterGroups")
            .getter(getter(UpdateWebhookRequest::filterGroups))
            .setter(setter(Builder::filterGroups))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("filterGroups").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField.> builder(MarshallingType.LIST)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build(),
                                                    ListTrait
                                                            .builder()
                                                            .memberLocationName(null)
                                                            .memberFieldInfo(
                                                                    SdkField. builder(MarshallingType.SDK_POJO)
                                                                            .constructor(WebhookFilter::builder)
                                                                            .traits(LocationTrait.builder()
                                                                                    .location(MarshallLocation.PAYLOAD)
                                                                                    .locationName("member").build()).build())
                                                            .build()).build()).build()).build();

    private static final SdkField BUILD_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("buildType").getter(getter(UpdateWebhookRequest::buildTypeAsString)).setter(setter(Builder::buildType))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("buildType").build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(PROJECT_NAME_FIELD,
            BRANCH_FILTER_FIELD, ROTATE_SECRET_FIELD, FILTER_GROUPS_FIELD, BUILD_TYPE_FIELD));

    private final String projectName;

    private final String branchFilter;

    private final Boolean rotateSecret;

    private final List> filterGroups;

    private final String buildType;

    private UpdateWebhookRequest(BuilderImpl builder) {
        super(builder);
        this.projectName = builder.projectName;
        this.branchFilter = builder.branchFilter;
        this.rotateSecret = builder.rotateSecret;
        this.filterGroups = builder.filterGroups;
        this.buildType = builder.buildType;
    }

    /**
     * 

* The name of the CodeBuild project. *

* * @return The name of the CodeBuild project. */ public final String projectName() { return projectName; } /** *

* A regular expression used to determine which repository branches are built when a webhook is triggered. If the * name of a branch matches the regular expression, then it is built. If branchFilter is empty, then * all branches are built. *

* *

* It is recommended that you use filterGroups instead of branchFilter. *

*
* * @return A regular expression used to determine which repository branches are built when a webhook is triggered. * If the name of a branch matches the regular expression, then it is built. If branchFilter is * empty, then all branches are built.

*

* It is recommended that you use filterGroups instead of branchFilter. *

*/ public final String branchFilter() { return branchFilter; } /** *

* A boolean value that specifies whether the associated GitHub repository's secret token should be updated. If you * use Bitbucket for your repository, rotateSecret is ignored. *

* * @return A boolean value that specifies whether the associated GitHub repository's secret token should be updated. * If you use Bitbucket for your repository, rotateSecret is ignored. */ public final Boolean rotateSecret() { return rotateSecret; } /** * For responses, this returns true if the service returned a value for the FilterGroups property. This DOES NOT * check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). * This is useful because the SDK will never return a null collection or map, but you may need to differentiate * between the service returning nothing (or null) and the service returning an empty collection or map. For * requests, this returns true if a value for the property was specified in the request builder, and false if a * value was not specified. */ public final boolean hasFilterGroups() { return filterGroups != null && !(filterGroups instanceof SdkAutoConstructList); } /** *

* An array of arrays of WebhookFilter objects used to determine if a webhook event can trigger a * build. A filter group must contain at least one EVENT WebhookFilter. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasFilterGroups} method. *

* * @return An array of arrays of WebhookFilter objects used to determine if a webhook event can trigger * a build. A filter group must contain at least one EVENT WebhookFilter. */ public final List> filterGroups() { return filterGroups; } /** *

* Specifies the type of build this webhook will trigger. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #buildType} will * return {@link WebhookBuildType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #buildTypeAsString}. *

* * @return Specifies the type of build this webhook will trigger. * @see WebhookBuildType */ public final WebhookBuildType buildType() { return WebhookBuildType.fromValue(buildType); } /** *

* Specifies the type of build this webhook will trigger. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #buildType} will * return {@link WebhookBuildType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #buildTypeAsString}. *

* * @return Specifies the type of build this webhook will trigger. * @see WebhookBuildType */ public final String buildTypeAsString() { return buildType; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(projectName()); hashCode = 31 * hashCode + Objects.hashCode(branchFilter()); hashCode = 31 * hashCode + Objects.hashCode(rotateSecret()); hashCode = 31 * hashCode + Objects.hashCode(hasFilterGroups() ? filterGroups() : null); hashCode = 31 * hashCode + Objects.hashCode(buildTypeAsString()); return hashCode; } @Override public final boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof UpdateWebhookRequest)) { return false; } UpdateWebhookRequest other = (UpdateWebhookRequest) obj; return Objects.equals(projectName(), other.projectName()) && Objects.equals(branchFilter(), other.branchFilter()) && Objects.equals(rotateSecret(), other.rotateSecret()) && hasFilterGroups() == other.hasFilterGroups() && Objects.equals(filterGroups(), other.filterGroups()) && Objects.equals(buildTypeAsString(), other.buildTypeAsString()); } /** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. */ @Override public final String toString() { return ToString.builder("UpdateWebhookRequest").add("ProjectName", projectName()).add("BranchFilter", branchFilter()) .add("RotateSecret", rotateSecret()).add("FilterGroups", hasFilterGroups() ? filterGroups() : null) .add("BuildType", buildTypeAsString()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "projectName": return Optional.ofNullable(clazz.cast(projectName())); case "branchFilter": return Optional.ofNullable(clazz.cast(branchFilter())); case "rotateSecret": return Optional.ofNullable(clazz.cast(rotateSecret())); case "filterGroups": return Optional.ofNullable(clazz.cast(filterGroups())); case "buildType": return Optional.ofNullable(clazz.cast(buildTypeAsString())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((UpdateWebhookRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends CodeBuildRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The name of the CodeBuild project. *

* * @param projectName * The name of the CodeBuild project. * @return Returns a reference to this object so that method calls can be chained together. */ Builder projectName(String projectName); /** *

* A regular expression used to determine which repository branches are built when a webhook is triggered. If * the name of a branch matches the regular expression, then it is built. If branchFilter is empty, * then all branches are built. *

* *

* It is recommended that you use filterGroups instead of branchFilter. *

*
* * @param branchFilter * A regular expression used to determine which repository branches are built when a webhook is * triggered. If the name of a branch matches the regular expression, then it is built. If * branchFilter is empty, then all branches are built.

*

* It is recommended that you use filterGroups instead of branchFilter. *

* @return Returns a reference to this object so that method calls can be chained together. */ Builder branchFilter(String branchFilter); /** *

* A boolean value that specifies whether the associated GitHub repository's secret token should be updated. If * you use Bitbucket for your repository, rotateSecret is ignored. *

* * @param rotateSecret * A boolean value that specifies whether the associated GitHub repository's secret token should be * updated. If you use Bitbucket for your repository, rotateSecret is ignored. * @return Returns a reference to this object so that method calls can be chained together. */ Builder rotateSecret(Boolean rotateSecret); /** *

* An array of arrays of WebhookFilter objects used to determine if a webhook event can trigger a * build. A filter group must contain at least one EVENT WebhookFilter. *

* * @param filterGroups * An array of arrays of WebhookFilter objects used to determine if a webhook event can * trigger a build. A filter group must contain at least one EVENT * WebhookFilter. * @return Returns a reference to this object so that method calls can be chained together. */ Builder filterGroups(Collection> filterGroups); /** *

* An array of arrays of WebhookFilter objects used to determine if a webhook event can trigger a * build. A filter group must contain at least one EVENT WebhookFilter. *

* * @param filterGroups * An array of arrays of WebhookFilter objects used to determine if a webhook event can * trigger a build. A filter group must contain at least one EVENT * WebhookFilter. * @return Returns a reference to this object so that method calls can be chained together. */ Builder filterGroups(Collection... filterGroups); /** *

* Specifies the type of build this webhook will trigger. *

* * @param buildType * Specifies the type of build this webhook will trigger. * @see WebhookBuildType * @return Returns a reference to this object so that method calls can be chained together. * @see WebhookBuildType */ Builder buildType(String buildType); /** *

* Specifies the type of build this webhook will trigger. *

* * @param buildType * Specifies the type of build this webhook will trigger. * @see WebhookBuildType * @return Returns a reference to this object so that method calls can be chained together. * @see WebhookBuildType */ Builder buildType(WebhookBuildType buildType); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends CodeBuildRequest.BuilderImpl implements Builder { private String projectName; private String branchFilter; private Boolean rotateSecret; private List> filterGroups = DefaultSdkAutoConstructList.getInstance(); private String buildType; private BuilderImpl() { } private BuilderImpl(UpdateWebhookRequest model) { super(model); projectName(model.projectName); branchFilter(model.branchFilter); rotateSecret(model.rotateSecret); filterGroups(model.filterGroups); buildType(model.buildType); } public final String getProjectName() { return projectName; } public final void setProjectName(String projectName) { this.projectName = projectName; } @Override public final Builder projectName(String projectName) { this.projectName = projectName; return this; } public final String getBranchFilter() { return branchFilter; } public final void setBranchFilter(String branchFilter) { this.branchFilter = branchFilter; } @Override public final Builder branchFilter(String branchFilter) { this.branchFilter = branchFilter; return this; } public final Boolean getRotateSecret() { return rotateSecret; } public final void setRotateSecret(Boolean rotateSecret) { this.rotateSecret = rotateSecret; } @Override public final Builder rotateSecret(Boolean rotateSecret) { this.rotateSecret = rotateSecret; return this; } public final List> getFilterGroups() { List> result = FilterGroupsCopier.copyToBuilder(this.filterGroups); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setFilterGroups(Collection> filterGroups) { this.filterGroups = FilterGroupsCopier.copyFromBuilder(filterGroups); } @Override public final Builder filterGroups(Collection> filterGroups) { this.filterGroups = FilterGroupsCopier.copy(filterGroups); return this; } @Override @SafeVarargs public final Builder filterGroups(Collection... filterGroups) { filterGroups(Arrays.asList(filterGroups)); return this; } public final String getBuildType() { return buildType; } public final void setBuildType(String buildType) { this.buildType = buildType; } @Override public final Builder buildType(String buildType) { this.buildType = buildType; return this; } @Override public final Builder buildType(WebhookBuildType buildType) { this.buildType(buildType == null ? null : buildType.toString()); return this; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public UpdateWebhookRequest build() { return new UpdateWebhookRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy